filecat 7.32.0 → 7.32.1
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/build/dist/1852.16cec79aa004d7d496ee.js +1 -0
- package/build/dist/2515.df3393e66df975984e10.js +1 -0
- package/build/dist/26.63fd77a3075a6e071bc8.js +1 -0
- package/build/dist/3187.03c9284e30214b476487.js +1 -0
- package/build/dist/3322.36f73d119334675d9bc4.js +1 -0
- package/build/dist/4350.7412b41befe12857677f.js +1 -0
- package/build/dist/{4935.d07d9ef7e03632dcb51c.js → 4935.72f92a4a0e80fd72c68d.js} +1 -1
- package/build/dist/{6439.f3ddea3c0ef57dcbf23c.js → 6439.b1b588626009af7ba7cb.js} +1 -1
- package/build/dist/index.html +1 -1
- package/build/dist/main.6e543784024f3ed07f70.js +2 -0
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/2091.8324e03dcf28985539eb.js +0 -1
- package/build/dist/3187.67ad7348b6b7231e657d.js +0 -1
- package/build/dist/4350.799e1d3b7382a15d295b.js +0 -1
- package/build/dist/7212.a825bc171875985e1aab.js +0 -1
- package/build/dist/main.b0bcf1b153b849530789.js +0 -2
- /package/build/dist/{main.b0bcf1b153b849530789.js.LICENSE.txt → main.6e543784024f3ed07f70.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[26,1852],{21852(e,t,n){n.r(t),n.d(t,{default:()=>h});var o=n(96540),r=n(34843),c=n(82893),i=n(42562),s=n(26),a=n(99018),l=n(93245),d=n(23430),u=n(22022),f=n(74848);function h(){const{t:e}=(0,u.Bd)(),[t,n]=(0,r.fp)(c.AG.docx_editor),[h,p]=(0,o.useState)(!1),[m,g]=(0,o.useState)(!1),v=(0,o.useRef)(),b=async(t=!1)=>{if(!v.current)return!1;g(!0);try{return await v.current(t?"":e("保存成功"))}finally{g(!1)}},y=(0,o.useRef)(h);return y.current=h,(0,l.a)(d.nE.docx,()=>y.current,()=>b(!0)),(0,f.jsx)(i.A,{name:t.name,dirty:h,loading:!1,error:"",saving:m,on_save:b,on_close:()=>{const e=t.close;n({}),e?.()},children:t.url&&(0,f.jsx)(s.default,{url:t.url,save_path:(0,a.Vi)(t.name??""),on_dirty:p,bind_save:e=>v.current=e})})}},26(e,t,n){n.r(t),n.d(t,{default:()=>f});var o=n(96540),r=n(39290),c=n(33036);const i=15;function s(e){const t=e.getBoundingClientRect().top,n=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=null;for(;o.nextNode();){const e=o.currentNode,c=e.textContent??"";if(!c.trim())continue;const i=document.createRange();for(let o=0;o<c.length;o++){i.setStart(e,o),i.setEnd(e,o+1);const c=i.getBoundingClientRect();0!==c.height&&((null===r||Math.abs(c.top-r)>1)&&(null!==r&&n.push(c.top-t),r=c.top))}}return null!==r&&n.push(e.offsetHeight),0===n.length&&n.push(e.offsetHeight),n}var a=n(74848);function l(e){const t=(0,r.OE)(e);if(!t)throw new Error(`docx 命令不存在: ${e}`);return t}function d(e){const{model:t,on_change:n,bind_save:d}=e,u=(0,o.useRef)(null),f=(0,o.useRef)([]),h=(0,o.useRef)(),p=(0,o.useRef)(new Map),m=(0,o.useRef)(""),g=(0,o.useCallback)(()=>{const e=u.current,n=t.selection?.focus;if(!e||!n)return;const o=e.querySelector(`[data-wk-block="${n.block}"]`);if(!o)return;let r=o;if(void 0!==n.inline){const e=o.querySelector(`[data-wk-inline="${n.inline}"]`);e&&(r=e)}const c=r.firstChild;if(!c)return;const i=document.createRange(),s=Math.min(n.offset??0,c.textContent?.length??0);i.setStart(c,s),i.collapse(!0);const a=window.getSelection();a?.removeAllRanges(),a?.addRange(i)},[t]),v=(0,o.useCallback)((e=!1)=>{const n=u.current;if(!n)return;let o=-1;const c=window.getSelection();if(c&&c.anchorNode&&n.contains(c.anchorNode)){const e=1===c.anchorNode.nodeType?c.anchorNode:c.anchorNode.parentElement,t=e?.closest("[data-wk-block]");t&&(o=Number(t.getAttribute("data-wk-block")))}const s=document.createElement("div");s.innerHTML=(0,r.j7)(t.document);const a=Array.from(s.children).map(e=>e.outerHTML),l=f.current;if(e||l.length!==a.length)n.innerHTML=s.innerHTML,p.current.clear(),Array.from(n.children).forEach(e=>{const t=e,n=Number(t.getAttribute("data-wk-block"));Number.isNaN(n)||p.current.set(n,t)});else for(let e=0;e<a.length;e++){if(l[e]===a[e])continue;const t=p.current.get(e);t&&(t.innerHTML=s.children[e].innerHTML)}f.current=a,h.current??=function(e){const t=(0,r.yj)(e);return{width:t.width/i,height:t.height/i,top:t.top/i,right:t.right/i,bottom:t.bottom/i,left:t.left/i,body_height:(t.height-t.top-t.bottom)/i}}(t.document);const d=h.current,{heights:m,lines:g}=b(a.length,d),v=function(e,t,n,o){const c=(0,r.Bv)(e),i=(0,r.w$)(e),s=c.map((e,o)=>{const r=t[o]??0;return{height:r,section:0,lines:()=>n[o]??[r]}}),a=i.map(()=>({start:"continuous",columns:1,titlePage:!1,vAlign:"top",bodyHeight:()=>o.body_height}));return(0,r.En)(s,a,{evenAndOddHeaders:!1,noteSeparatorHeight:0}).map(e=>{const n=[];for(const o of e.regions)for(const e of o.columns)for(const o of e.fragments)"block"===o.kind?n.push({block:o.block,from:0,to:t[o.block]??o.height}):"slice"===o.kind&&n.push({block:o.block,from:o.from,to:o.to});return{fragments:n,number:e.number}})}(t.document,m,g,d);y(n,v,d)},[t]),b=(0,o.useCallback)((e,t)=>{const n=document.createElement("div");n.className="docx-page",n.style.cssText=[`width:${t.width}px`,`padding:${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`,"position:absolute","left:-99999px","top:0","visibility:hidden","pointer-events:none"].join(";");const o=document.createElement("div");o.className="docx-page__body",n.appendChild(o),document.body.appendChild(n);const r=[];for(let t=0;t<e;t++){const e=p.current.get(t);if(!e){const e=document.createElement("div");o.appendChild(e),r.push(e);continue}o.appendChild(e),r.push(e)}const c=[],i=[],a=o.scrollHeight;for(let e=0;e<r.length;e++){const t=r[e],n=t.offsetTop,o=e+1<r.length?r[e+1].offsetTop:a;let l=Math.max(0,o-n);e===r.length-1&&(l+=parseFloat(getComputedStyle(t).marginBottom)||0),c[e]=l,i[e]=s(t)}return n.remove(),{heights:c,lines:i}},[]),y=(0,o.useCallback)((e,t,n)=>{const o=t.map(e=>e.fragments.map(e=>e.block).join(",")).join("|");m.current=o,e.innerHTML="";for(const o of t){const t=document.createElement("div");t.className="docx-page",t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.padding=`${n.top}px ${n.right}px ${n.bottom}px ${n.left}px`;const r=document.createElement("div");r.className="docx-page__body",t.appendChild(r);const c=document.createElement("div");c.className="docx-page__number",c.textContent=String(o.number),t.appendChild(c);for(const e of o.fragments){const t=p.current.get(e.block);if(!t)continue;if(0===e.from&&e.to>=t.offsetHeight-1){r.appendChild(t);continue}const n=document.createElement("div");n.className="docx-page__slice",n.style.height=e.to-e.from+"px",n.style.overflow="hidden";const o=t.cloneNode(!0);o.style.marginTop=-e.from+"px",n.appendChild(o),r.appendChild(n)}e.appendChild(t)}e.querySelectorAll(".docx-page__body").forEach(e=>{e.setAttribute("contenteditable","true"),e.setAttribute("suppresscontenteditablewarning","true")})},[]);(0,o.useEffect)(()=>{v(!0);const e=t.subscribe(()=>{const e=u.current,t=window.getSelection(),o=!!(e&&t&&t.anchorNode&&e.contains(t.anchorNode));v(!1),o&&g(),n?.(!0)});return()=>{e()}},[t,v,g,n]),(0,o.useEffect)(()=>{d?.(()=>function(e){return(0,c.FoA)(e.document)}(t))},[t,d]);const x=(0,o.useCallback)(()=>{const e=(0,r.Ff)(document);if(!e)return!1;const n=t.selection;return n&&JSON.stringify(n.anchor)===JSON.stringify(e.anchor)&&JSON.stringify(n.focus)===JSON.stringify(e.focus)||t.setSelection(e),!0},[t]),_=(0,o.useCallback)((e,n)=>{x(),(0,r.d1)(t,l(e),n)},[t,x]),k=(0,o.useCallback)(()=>{(0,r.d1)(t,l("structure.insertText"),{text:""})},[t]),N=(0,o.useCallback)(e=>{if(!x())return;const n=t.selection;if(!n)return;const{anchor:o,focus:c}=n;if(o.block!==c.block||o.inline!==c.inline||o.offset!==c.offset)return void k();const i=o.offset;if(e&&i<=0)return void(0,r.d1)(t,l("structure.mergeBack"),void 0);const s=e?i-1:i,a=e?i:i+1,d={block:o.block,para:o.para,cell:o.cell,inline:o.inline};t.setSelection({anchor:(0,r.zf)({...d,offset:s}).anchor,focus:(0,r.zf)({...d,offset:a}).anchor}),k()},[t,x,k]),w=(0,o.useCallback)(e=>{x(),(0,r.d1)(t,l("structure.insertText"),{text:e})},[t,x]);return(0,o.useEffect)(()=>{const e=u.current;if(!e)return;const n=n=>{const o=window.getSelection();if(o&&o.anchorNode&&e.contains(o.anchorNode)){if(n.ctrlKey||n.metaKey){const e=n.key.toLowerCase();return n.shiftKey||"b"!==e&&"i"!==e&&"u"!==e?"z"===e?(n.preventDefault(),void((n.shiftKey?t.canRedo():t.canUndo())&&(n.shiftKey?t.redo():t.undo()))):void 0:(n.preventDefault(),void _("b"===e?"text.bold":"i"===e?"text.italic":"text.underline"))}return"Enter"===n.key?(n.preventDefault(),void _("structure.insertParagraph")):"Backspace"===n.key?(n.preventDefault(),void N(!0)):"Delete"===n.key?(n.preventDefault(),void N(!1)):void(1!==n.key.length||n.altKey||(n.preventDefault(),w(n.key)))}},o=t=>{const n=window.getSelection();n&&n.anchorNode&&e.contains(n.anchorNode)&&t.data&&w(t.data)},r=t=>{const n=window.getSelection();if(!n||!n.anchorNode||!e.contains(n.anchorNode))return;t.preventDefault();const o=t.clipboardData?.getData("text/plain");o&&w(o)};return e.addEventListener("keydown",n),e.addEventListener("compositionend",o),e.addEventListener("paste",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("compositionend",o),e.removeEventListener("paste",r)}},[t,_,N,w]),(0,a.jsx)("div",{className:"docx-body",children:(0,a.jsx)("div",{className:"docx-pages",ref:u})})}var u=n(99018);function f(e){const{url:t,save_path:n,on_dirty:c,bind_save:i}=e,[s,l]=(0,o.useState)(),[f,h]=(0,o.useState)(""),[p,m]=(0,o.useState)(!0),[g,v]=(0,o.useState)(!1),b=(0,o.useRef)();return(0,o.useEffect)(()=>{if(!t)return;let e=!0;return m(!0),h(""),v(!1),l(void 0),(0,u.PQ)(t).then(t=>{e&&l(function(e){return(0,r.k3)(e)}(t))}).catch(t=>e&&h(String(t?.message??t))).finally(()=>e&&m(!1)),()=>{e=!1}},[t]),(0,o.useEffect)(()=>{c?.(g)},[g,c]),(0,o.useEffect)(()=>{i?.(async e=>{if(!b.current)return!1;const t=await(0,u.GB)(n,b.current(),e);return t&&v(!1),t})},[n,i]),f?(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:f}):p||!s?(0,a.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,a.jsx)(d,{model:s,on_change:v,bind_save:e=>b.current=e})}},42562(e,t,n){n.d(t,{A:()=>s});var o=n(96540),r=n(85997),c=n(45907),i=n(74848);function s(e){const{name:t,dirty:n,loading:s,error:a,saving:l,on_save:d,on_close:u,children:f,extra:h}=e,p=(0,c.y)(),m=(0,o.useRef)(u),g=(0,o.useRef)(d),v=(0,o.useRef)(n);m.current=u,g.current=d,v.current=n;const b=()=>{v.current?p({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>m.current?.()}):m.current?.()};return(0,o.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),g.current?.(!1)):"Escape"===e.key&&b()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,i.jsxs)("div",{className:"office-editor",children:[(0,i.jsxs)("div",{className:"office-editor__topbar",children:[(0,i.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,i.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,i.jsxs)("div",{className:"office-editor__ops",children:[h,l&&(0,i.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),d&&(0,i.jsx)(r.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>d()}),(0,i.jsx)(r.rA,{icon:"close",title:"关闭 (Esc)",onClick:b})]})]}),(0,i.jsxs)("div",{className:"office-editor__body",children:[s&&(0,i.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!s&&a&&(0,i.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}),!s&&!a&&f]})]})}},99018(e,t,n){n.d(t,{GB:()=>l,PQ:()=>a,Vi:()=>s});var o=n(14284),r=n(57889),c=n(34289),i=n(62042);function s(e){return`${encodeURIComponent(function(){const e=(0,c.GG)("file",(0,c.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function a(e){return r.l.get_bytes_url(e)}function l(e,t,n){return async function(e,t,n){const r=await o.$M.post(`save_bin/${e}`,{base64:d(t)});return 0!==r.code?((0,i.zN)(r.message??"保存失败"),!1):(n&&(0,i.SK)(n),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,n)}function d(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2515],{72515(e,t,n){n.r(t),n.d(t,{default:()=>i});var r=n(96540),c=n(50610),s=n(99018),a=n(74848);function i(e){const{url:t,save_path:n,file_name:i,on_dirty:o,bind_save:u}=e,f=(0,r.useRef)(null),l=(0,r.useRef)(),d=(0,r.useRef)(""),[p,h]=(0,r.useState)(""),[_,m]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{if(!t)return;const e=f.current;if(!e)return;let r,a=!0;return m(!0),h(""),(0,s.PQ)(t).then(t=>{a&&(r=(0,c.t)(e,{source:t,fileName:i,onSave:async e=>{const t=await(0,s.GB)(n,e,d.current);return t&&o?.(!1),t},autoSave:!1,compact:!0}),l.current=r,r.on("dirtychange",e=>{o?.(e.dirty)}))}).catch(e=>{a&&h(String(e?.message??e))}).finally(()=>a&&m(!1)),()=>{a=!1,r?.destroy(),l.current=void 0}},[t,i,n]),(0,r.useEffect)(()=>{u?.(async e=>{const t=l.current;return!!t&&(d.current=e,await t.save(),d.current="",!t.dirty)})},[u]),(0,a.jsxs)("div",{className:"pptx-pane",children:[p&&(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:p}),_&&!p&&(0,a.jsx)("div",{className:"office-editor__tip",children:"读取中…"}),(0,a.jsx)("div",{className:"pptx-pane__host",ref:f})]})}},99018(e,t,n){n.d(t,{GB:()=>u,PQ:()=>o,Vi:()=>i});var r=n(14284),c=n(57889),s=n(34289),a=n(62042);function i(e){return`${encodeURIComponent(function(){const e=(0,s.GG)("file",(0,s.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function o(e){return c.l.get_bytes_url(e)}function u(e,t,n){return async function(e,t,n){const c=await r.$M.post(`save_bin/${e}`,{base64:f(t)});return 0!==c.code?((0,a.zN)(c.message??"保存失败"),!1):(n&&(0,a.SK)(n),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,n)}function f(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[26],{26(e,t,n){n.r(t),n.d(t,{default:()=>f});var o=n(96540),r=n(39290),c=n(33036);const i=15;function s(e){const t=e.getBoundingClientRect().top,n=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=null;for(;o.nextNode();){const e=o.currentNode,c=e.textContent??"";if(!c.trim())continue;const i=document.createRange();for(let o=0;o<c.length;o++){i.setStart(e,o),i.setEnd(e,o+1);const c=i.getBoundingClientRect();0!==c.height&&((null===r||Math.abs(c.top-r)>1)&&(null!==r&&n.push(c.top-t),r=c.top))}}return null!==r&&n.push(e.offsetHeight),0===n.length&&n.push(e.offsetHeight),n}var a=n(74848);function l(e){const t=(0,r.OE)(e);if(!t)throw new Error(`docx 命令不存在: ${e}`);return t}function u(e){const{model:t,on_change:n,bind_save:u}=e,d=(0,o.useRef)(null),f=(0,o.useRef)([]),h=(0,o.useRef)(),p=(0,o.useRef)(new Map),m=(0,o.useRef)(""),g=(0,o.useCallback)(()=>{const e=d.current,n=t.selection?.focus;if(!e||!n)return;const o=e.querySelector(`[data-wk-block="${n.block}"]`);if(!o)return;let r=o;if(void 0!==n.inline){const e=o.querySelector(`[data-wk-inline="${n.inline}"]`);e&&(r=e)}const c=r.firstChild;if(!c)return;const i=document.createRange(),s=Math.min(n.offset??0,c.textContent?.length??0);i.setStart(c,s),i.collapse(!0);const a=window.getSelection();a?.removeAllRanges(),a?.addRange(i)},[t]),b=(0,o.useCallback)((e=!1)=>{const n=d.current;if(!n)return;let o=-1;const c=window.getSelection();if(c&&c.anchorNode&&n.contains(c.anchorNode)){const e=1===c.anchorNode.nodeType?c.anchorNode:c.anchorNode.parentElement,t=e?.closest("[data-wk-block]");t&&(o=Number(t.getAttribute("data-wk-block")))}const s=document.createElement("div");s.innerHTML=(0,r.j7)(t.document);const a=Array.from(s.children).map(e=>e.outerHTML),l=f.current;if(e||l.length!==a.length)n.innerHTML=s.innerHTML,p.current.clear(),Array.from(n.children).forEach(e=>{const t=e,n=Number(t.getAttribute("data-wk-block"));Number.isNaN(n)||p.current.set(n,t)});else for(let e=0;e<a.length;e++){if(l[e]===a[e])continue;const t=p.current.get(e);t&&(t.innerHTML=s.children[e].innerHTML)}f.current=a,h.current??=function(e){const t=(0,r.yj)(e);return{width:t.width/i,height:t.height/i,top:t.top/i,right:t.right/i,bottom:t.bottom/i,left:t.left/i,body_height:(t.height-t.top-t.bottom)/i}}(t.document);const u=h.current,{heights:m,lines:g}=v(a.length,u),b=function(e,t,n,o){const c=(0,r.Bv)(e),i=(0,r.w$)(e),s=c.map((e,o)=>{const r=t[o]??0;return{height:r,section:0,lines:()=>n[o]??[r]}}),a=i.map(()=>({start:"continuous",columns:1,titlePage:!1,vAlign:"top",bodyHeight:()=>o.body_height}));return(0,r.En)(s,a,{evenAndOddHeaders:!1,noteSeparatorHeight:0}).map(e=>{const n=[];for(const o of e.regions)for(const e of o.columns)for(const o of e.fragments)"block"===o.kind?n.push({block:o.block,from:0,to:t[o.block]??o.height}):"slice"===o.kind&&n.push({block:o.block,from:o.from,to:o.to});return{fragments:n,number:e.number}})}(t.document,m,g,u);y(n,b,u)},[t]),v=(0,o.useCallback)((e,t)=>{const n=document.createElement("div");n.className="docx-page",n.style.cssText=[`width:${t.width}px`,`padding:${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`,"position:absolute","left:-99999px","top:0","visibility:hidden","pointer-events:none"].join(";");const o=document.createElement("div");o.className="docx-page__body",n.appendChild(o),document.body.appendChild(n);const r=[];for(let t=0;t<e;t++){const e=p.current.get(t);if(!e){const e=document.createElement("div");o.appendChild(e),r.push(e);continue}o.appendChild(e),r.push(e)}const c=[],i=[],a=o.scrollHeight;for(let e=0;e<r.length;e++){const t=r[e],n=t.offsetTop,o=e+1<r.length?r[e+1].offsetTop:a;let l=Math.max(0,o-n);e===r.length-1&&(l+=parseFloat(getComputedStyle(t).marginBottom)||0),c[e]=l,i[e]=s(t)}return n.remove(),{heights:c,lines:i}},[]),y=(0,o.useCallback)((e,t,n)=>{const o=t.map(e=>e.fragments.map(e=>e.block).join(",")).join("|");m.current=o,e.innerHTML="";for(const o of t){const t=document.createElement("div");t.className="docx-page",t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.padding=`${n.top}px ${n.right}px ${n.bottom}px ${n.left}px`;const r=document.createElement("div");r.className="docx-page__body",t.appendChild(r);const c=document.createElement("div");c.className="docx-page__number",c.textContent=String(o.number),t.appendChild(c);for(const e of o.fragments){const t=p.current.get(e.block);if(!t)continue;if(0===e.from&&e.to>=t.offsetHeight-1){r.appendChild(t);continue}const n=document.createElement("div");n.className="docx-page__slice",n.style.height=e.to-e.from+"px",n.style.overflow="hidden";const o=t.cloneNode(!0);o.style.marginTop=-e.from+"px",n.appendChild(o),r.appendChild(n)}e.appendChild(t)}e.querySelectorAll(".docx-page__body").forEach(e=>{e.setAttribute("contenteditable","true"),e.setAttribute("suppresscontenteditablewarning","true")})},[]);(0,o.useEffect)(()=>{b(!0);const e=t.subscribe(()=>{const e=d.current,t=window.getSelection(),o=!!(e&&t&&t.anchorNode&&e.contains(t.anchorNode));b(!1),o&&g(),n?.(!0)});return()=>{e()}},[t,b,g,n]),(0,o.useEffect)(()=>{u?.(()=>function(e){return(0,c.FoA)(e.document)}(t))},[t,u]);const k=(0,o.useCallback)(()=>{const e=(0,r.Ff)(document);if(!e)return!1;const n=t.selection;return n&&JSON.stringify(n.anchor)===JSON.stringify(e.anchor)&&JSON.stringify(n.focus)===JSON.stringify(e.focus)||t.setSelection(e),!0},[t]),x=(0,o.useCallback)((e,n)=>{k(),(0,r.d1)(t,l(e),n)},[t,k]),N=(0,o.useCallback)(()=>{(0,r.d1)(t,l("structure.insertText"),{text:""})},[t]),w=(0,o.useCallback)(e=>{if(!k())return;const n=t.selection;if(!n)return;const{anchor:o,focus:c}=n;if(o.block!==c.block||o.inline!==c.inline||o.offset!==c.offset)return void N();const i=o.offset;if(e&&i<=0)return void(0,r.d1)(t,l("structure.mergeBack"),void 0);const s=e?i-1:i,a=e?i:i+1,u={block:o.block,para:o.para,cell:o.cell,inline:o.inline};t.setSelection({anchor:(0,r.zf)({...u,offset:s}).anchor,focus:(0,r.zf)({...u,offset:a}).anchor}),N()},[t,k,N]),C=(0,o.useCallback)(e=>{k(),(0,r.d1)(t,l("structure.insertText"),{text:e})},[t,k]);return(0,o.useEffect)(()=>{const e=d.current;if(!e)return;const n=n=>{const o=window.getSelection();if(o&&o.anchorNode&&e.contains(o.anchorNode)){if(n.ctrlKey||n.metaKey){const e=n.key.toLowerCase();return n.shiftKey||"b"!==e&&"i"!==e&&"u"!==e?"z"===e?(n.preventDefault(),void((n.shiftKey?t.canRedo():t.canUndo())&&(n.shiftKey?t.redo():t.undo()))):void 0:(n.preventDefault(),void x("b"===e?"text.bold":"i"===e?"text.italic":"text.underline"))}return"Enter"===n.key?(n.preventDefault(),void x("structure.insertParagraph")):"Backspace"===n.key?(n.preventDefault(),void w(!0)):"Delete"===n.key?(n.preventDefault(),void w(!1)):void(1!==n.key.length||n.altKey||(n.preventDefault(),C(n.key)))}},o=t=>{const n=window.getSelection();n&&n.anchorNode&&e.contains(n.anchorNode)&&t.data&&C(t.data)},r=t=>{const n=window.getSelection();if(!n||!n.anchorNode||!e.contains(n.anchorNode))return;t.preventDefault();const o=t.clipboardData?.getData("text/plain");o&&C(o)};return e.addEventListener("keydown",n),e.addEventListener("compositionend",o),e.addEventListener("paste",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("compositionend",o),e.removeEventListener("paste",r)}},[t,x,w,C]),(0,a.jsx)("div",{className:"docx-body",children:(0,a.jsx)("div",{className:"docx-pages",ref:d})})}var d=n(99018);function f(e){const{url:t,save_path:n,on_dirty:c,bind_save:i}=e,[s,l]=(0,o.useState)(),[f,h]=(0,o.useState)(""),[p,m]=(0,o.useState)(!0),[g,b]=(0,o.useState)(!1),v=(0,o.useRef)();return(0,o.useEffect)(()=>{if(!t)return;let e=!0;return m(!0),h(""),b(!1),l(void 0),(0,d.PQ)(t).then(t=>{e&&l(function(e){return(0,r.k3)(e)}(t))}).catch(t=>e&&h(String(t?.message??t))).finally(()=>e&&m(!1)),()=>{e=!1}},[t]),(0,o.useEffect)(()=>{c?.(g)},[g,c]),(0,o.useEffect)(()=>{i?.(async e=>{if(!v.current)return!1;const t=await(0,d.GB)(n,v.current(),e);return t&&b(!1),t})},[n,i]),f?(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:f}):p||!s?(0,a.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,a.jsx)(u,{model:s,on_change:b,bind_save:e=>v.current=e})}},99018(e,t,n){n.d(t,{GB:()=>l,PQ:()=>a,Vi:()=>s});var o=n(14284),r=n(57889),c=n(34289),i=n(62042);function s(e){return`${encodeURIComponent(function(){const e=(0,c.GG)("file",(0,c.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function a(e){return r.l.get_bytes_url(e)}function l(e,t,n){return async function(e,t,n){const r=await o.$M.post(`save_bin/${e}`,{base64:u(t)});return 0!==r.code?((0,i.zN)(r.message??"保存失败"),!1):(n&&(0,i.SK)(n),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,n)}function u(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[3187,4935],{42562(e,t,n){n.d(t,{A:()=>c});var r=n(96540),s=n(85997),l=n(45907),o=n(74848);function c(e){const{name:t,dirty:n,loading:c,error:a,saving:i,on_save:u,on_close:f,children:d,extra:h}=e,m=(0,l.y)(),g=(0,r.useRef)(f),x=(0,r.useRef)(u),p=(0,r.useRef)(n);g.current=f,x.current=u,p.current=n;const y=()=>{p.current?m({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>g.current?.()}):g.current?.()};return(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),x.current?.(!1)):"Escape"===e.key&&y()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,o.jsxs)("div",{className:"office-editor",children:[(0,o.jsxs)("div",{className:"office-editor__topbar",children:[(0,o.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,o.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,o.jsxs)("div",{className:"office-editor__ops",children:[h,i&&(0,o.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),u&&(0,o.jsx)(s.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>u()}),(0,o.jsx)(s.rA,{icon:"close",title:"关闭 (Esc)",onClick:y})]})]}),(0,o.jsxs)("div",{className:"office-editor__body",children:[c&&(0,o.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!c&&a&&(0,o.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}),!c&&!a&&d]})]})}},43187(e,t,n){n.r(t),n.d(t,{default:()=>h});var r=n(96540),s=n(34843),l=n(82893),o=n(42562),c=n(24935),a=n(99018),i=n(93245),u=n(23430),f=n(22022),d=n(74848);function h(){const{t:e}=(0,f.Bd)(),[t,n]=(0,s.fp)(l.AG.excel_editor),[h,m]=(0,r.useState)(!1),[g,x]=(0,r.useState)(!1),p=(0,r.useRef)(),y=async(t=!1)=>{if(!p.current)return!1;x(!0);try{return await p.current(t?"":e("保存成功"))}finally{x(!1)}},_=(0,r.useRef)(h);return _.current=h,(0,i.a)(u.nE.excel,()=>_.current,()=>y(!0)),(0,d.jsx)(o.A,{name:t.name,dirty:h,loading:!1,error:"",saving:g,on_save:y,on_close:()=>{const e=t.close;n({}),e?.()},children:t.url&&(0,d.jsx)(c.default,{url:t.url,save_path:(0,a.Vi)(t.name??""),on_dirty:m,bind_save:e=>p.current=e})})}},24935(e,t,n){n.r(t),n.d(t,{default:()=>b});var r=n(96540),s=n(47049),l=n(8890);const o=e=>Math.round(7*e+5),c=e=>Math.round(4*e/3);function a(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),s=r%100,l=e.getUTCMonth()+1,o=e.getUTCDate(),c="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(s)).replace(/(?<!m)m(?!m)/g,String(l)).replace(/mm/g,n(l)).replace(/d(?!d)/g,String(o)).replace(/dd/g,n(o)).replace(/aaaa/g,`星期${c}`)}const d=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function h(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&d(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&d(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const s=t.cellXfs?.[r];if(!s)return;const l=t.fills?.[s.fillId],o=t.fonts?.[s.fontId],c={};"solid"===l?.patternType&&(c.bg=i(l.fgColor,n)),c.color=i(o?.color,n),o?.bold&&(c.bold=!0),o?.italic&&(c.italic=!0),o?.size&&(c.fontSize=o.size),o?.name&&(c.fontFamily=o.name),o?.underline&&(c.underline=!0),o?.strike&&(c.strike=!0);const a=s.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(c.align=a.horizontal),a?.vertical&&(c.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(c.wrap=!0),a?.indent&&(c.indent=a.indent),Object.keys(c).length?c:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const s=r.numFmtId;if(void 0===s||0===s)return;const l={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(l[s])return l[s];const o=t.numFmts;return o instanceof Map?o.get(s):void 0}async function x(e){const t=await(0,s.a)(a(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const s=[],l=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,o=new Map;let c;for(;c=l.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(c[2])?.[1];e&&o.set(c[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>s[n]=o.get(e)??t[n]),s}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,s=t.styles;let l=0,a=0;r.rows.forEach((e,t)=>{e.size&&(l=Math.max(l,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=l;e++){const t=[],l=r.rows.get(e);for(let r=1;r<=a;r++){const o=l?.get(r),c=h(o,n,g(o,s));t.push(c.text);const a=m(o,s,n);c.runs&&(a?a.runs=c.runs:u.set(`${e-1}_${r-1}`,{runs:c.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const f=o(r.defaultColumnWidth??8.43),d=new Array(a).fill(f);r.columnDimensions?.forEach(e=>{const t=o(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<d.length&&(d[n-1]=t)});const x=c(r.defaultRowHeight??15),p=new Array(l).fill(x),y=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<p.length&&e.height&&(p[t-1]=c(e.height)),e.hidden&&t-1<l&&y.add(t-1)});const _=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:d,row_heights:p,hidden_rows:y,merges:_}})}var p=n(74848);function y(e){const{bytes:t,on_change:n,bind_save:o}=e,[c,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,d]=(0,r.useState)(0),[h,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),y=(0,r.useRef)(null),[w,b]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),x(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const S=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{o(async()=>{const e=await async function(e,t){const n=await(0,s.a)(a(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const s=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,l=n+1;let o=s.rows.get(r);o||(o=new Map,s.rows.set(r,o));const c=o.get(l);null!==e&&""!==e?c?c.value=e:o.set(l,{row:r,col:l,value:e}):c&&(c.value=null)})})}),await(0,l.n)(n)}(t,c);return g.current=!1,n(!1),e})},[c,t,o,n]),(0,r.useEffect)(()=>{e.bind_view?.({get_state:()=>({sheet:u,scroll_left:y.current?.scrollLeft??0,scroll_top:y.current?.scrollTop??0}),set_state:e=>{"number"==typeof e.sheet&&e.sheet>=0&&e.sheet<c.length&&f(e.sheet);const t=y.current;t&&(t.scrollLeft=e.scroll_left??0,t.scrollTop=e.scroll_top??0)}})},[u,c.length,e.bind_view]);const C=c[u],{col_x:j,row_y:E,total_w:k,total_h:M}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),N=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const s=n+r>>1;e[s]<t?n=s+1:r=s}return n},$=(0,r.useCallback)(()=>{const e=y.current;if(!e||!j.length)return;const t=Math.max(0,N(j,e.scrollLeft)-1),n=Math.max(0,N(E,e.scrollTop)-1);b({c0:t,c1:Math.min(j.length-1,N(j,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,N(E,e.scrollTop+e.clientHeight)+2)})},[j,E]);(0,r.useEffect)(()=>{$()},[C,$]);if(h)return(0,p.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:h});if(!c.length)return(0,p.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const F=C?.values??[],A=(E.length,j.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let s=e;s<=n;s++)for(let n=t;n<=r;n++)s===e&&n===t||A.add(`${s}_${n}`)});const D=(e,t)=>{const n=F[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,p.jsxs)("div",{className:"xlsx-body",children:[(0,p.jsx)("div",{className:"xlsx-tabs",children:c.map((e,t)=>(0,p.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),y.current&&(y.current.scrollTop=0,y.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,p.jsx)("div",{className:"xlsx-scroll",ref:y,onScroll:$,children:(0,p.jsxs)("div",{className:"xlsx-grid",style:{width:46+k,height:24+M},children:[Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const n=w.c0+t;return(0,p.jsx)("div",{className:"xlsx-head",style:{left:46+j[n],top:0,width:j[n+1]-j[n],height:24},children:v(n)},"ch"+n)}),Array.from({length:Math.max(0,w.r1-w.r0)}).map((e,t)=>{const n=w.r0+t;return(0,p.jsxs)(r.Fragment,{children:[(0,p.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const r=w.c0+t;if(A.has(`${n}_${r}`))return null;const s=C.merges.find(e=>e[0]===n&&e[1]===r),l=s?j[s[3]+1]-j[s[1]]:j[r+1]-j[r],o=s?E[s[2]+1]-E[s[0]]:E[n+1]-E[n];return(0,p.jsx)(_,{value:F[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:D(n,r+1),style:{left:46+j[r],top:24+E[n],width:l,height:o,zIndex:s?2:1},on_change:e=>((e,t,n)=>{const r=c[u];r&&(r.values[e][t]=""===n?null:n,S(),d(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function _(e){const{value:t,cell_style:n,style:s,spillable:l,on_change:o}=e,[c,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{c&&f.current&&(f.current.focus(),f.current.select())},[c]);const d=()=>{a(!1),i!==(t??"")&&o(i)},h={};return n?.bg&&(h.backgroundColor=n.bg),n?.color&&(h.color=n.color),n?.bold&&(h.fontWeight=600),n?.italic&&(h.fontStyle="italic"),n?.fontSize&&(h.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(h.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(h.textDecoration="underline"),n?.strike&&(h.textDecoration=h.textDecoration?`${h.textDecoration} line-through`:"line-through"),n?.align&&(h.textAlign=n.align,h.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(h.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(h.whiteSpace="pre-wrap"),n?.indent&&(h.paddingLeft=.35+1.4*n.indent+"em"),(0,p.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${l?"xlsx-cell--spill":""}`,style:{...s,...h,"--cell-h":n?.wrap?"1.4":s.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:c?(0,p.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:d,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),d())}}):n?.runs?(0,p.jsx)("span",{children:n.runs.map((e,t)=>(0,p.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function v(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var w=n(99018);function b(e){const{url:t,save_path:n,on_dirty:s,bind_save:l}=e,[o,c]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[d,h]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),h(!1),c(void 0),(0,w.PQ)(t).then(t=>e&&c(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{s?.(d)},[d,s]),(0,r.useEffect)(()=>{l?.(async e=>{if(!m.current)return!1;const t=await m.current(),r=await(0,w.GB)(n,t,e);return r&&(c(t),h(!1)),r})},[n,l]),a?(0,p.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!o?(0,p.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,p.jsx)(y,{bytes:o,on_change:h,bind_save:e=>m.current=e,bind_view:e.bind_view})}},99018(e,t,n){n.d(t,{GB:()=>i,PQ:()=>a,Vi:()=>c});var r=n(14284),s=n(57889),l=n(34289),o=n(62042);function c(e){return`${encodeURIComponent(function(){const e=(0,l.GG)("file",(0,l.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function a(e){return s.l.get_bytes_url(e)}function i(e,t,n){return async function(e,t,n){const s=await r.$M.post(`save_bin/${e}`,{base64:u(t)});return 0!==s.code?((0,o.zN)(s.message??"保存失败"),!1):(n&&(0,o.SK)(n),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,n)}function u(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2515,3322],{42562(e,t,r){r.d(t,{A:()=>a});var n=r(96540),s=r(85997),c=r(45907),i=r(74848);function a(e){const{name:t,dirty:r,loading:a,error:o,saving:u,on_save:d,on_close:f,children:l,extra:_}=e,p=(0,c.y)(),m=(0,n.useRef)(f),v=(0,n.useRef)(d),y=(0,n.useRef)(r);m.current=f,v.current=d,y.current=r;const h=()=>{y.current?p({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>m.current?.()}):m.current?.()};return(0,n.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),v.current?.(!1)):"Escape"===e.key&&h()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,i.jsxs)("div",{className:"office-editor",children:[(0,i.jsxs)("div",{className:"office-editor__topbar",children:[(0,i.jsxs)("div",{className:"office-editor__name",children:[t,r&&(0,i.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,i.jsxs)("div",{className:"office-editor__ops",children:[_,u&&(0,i.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),d&&(0,i.jsx)(s.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>d()}),(0,i.jsx)(s.rA,{icon:"close",title:"关闭 (Esc)",onClick:h})]})]}),(0,i.jsxs)("div",{className:"office-editor__body",children:[a&&(0,i.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!a&&o&&(0,i.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:o}),!a&&!o&&l]})]})}},13322(e,t,r){r.r(t),r.d(t,{default:()=>_});var n=r(96540),s=r(34843),c=r(82893),i=r(42562),a=r(72515),o=r(99018),u=r(93245),d=r(23430),f=r(22022),l=r(74848);function _(){const{t:e}=(0,f.Bd)(),[t,r]=(0,s.fp)(c.AG.pptx_editor),[_,p]=(0,n.useState)(!1),[m,v]=(0,n.useState)(!1),y=(0,n.useRef)(),h=async(t=!1)=>{if(!y.current)return!1;v(!0);try{return await y.current(t?"":e("保存成功"))}finally{v(!1)}},x=(0,n.useRef)(_);return x.current=_,(0,u.a)(d.nE.pptx,()=>x.current,()=>h(!0)),(0,l.jsx)(i.A,{name:t.name,dirty:_,loading:!1,error:"",saving:m,on_save:h,on_close:()=>{const e=t.close;r({}),e?.()},children:t.url&&(0,l.jsx)(a.default,{url:t.url,file_name:t.name??"",save_path:(0,o.Vi)(t.name??""),on_dirty:p,bind_save:e=>y.current=e})})}},72515(e,t,r){r.r(t),r.d(t,{default:()=>a});var n=r(96540),s=r(50610),c=r(99018),i=r(74848);function a(e){const{url:t,save_path:r,file_name:a,on_dirty:o,bind_save:u}=e,d=(0,n.useRef)(null),f=(0,n.useRef)(),l=(0,n.useRef)(""),[_,p]=(0,n.useState)(""),[m,v]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{if(!t)return;const e=d.current;if(!e)return;let n,i=!0;return v(!0),p(""),(0,c.PQ)(t).then(t=>{i&&(n=(0,s.t)(e,{source:t,fileName:a,onSave:async e=>{const t=await(0,c.GB)(r,e,l.current);return t&&o?.(!1),t},autoSave:!1,compact:!0}),f.current=n,n.on("dirtychange",e=>{o?.(e.dirty)}))}).catch(e=>{i&&p(String(e?.message??e))}).finally(()=>i&&v(!1)),()=>{i=!1,n?.destroy(),f.current=void 0}},[t,a,r]),(0,n.useEffect)(()=>{u?.(async e=>{const t=f.current;return!!t&&(l.current=e,await t.save(),l.current="",!t.dirty)})},[u]),(0,i.jsxs)("div",{className:"pptx-pane",children:[_&&(0,i.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:_}),m&&!_&&(0,i.jsx)("div",{className:"office-editor__tip",children:"读取中…"}),(0,i.jsx)("div",{className:"pptx-pane__host",ref:d})]})}},99018(e,t,r){r.d(t,{GB:()=>u,PQ:()=>o,Vi:()=>a});var n=r(14284),s=r(57889),c=r(34289),i=r(62042);function a(e){return`${encodeURIComponent(function(){const e=(0,c.GG)("file",(0,c.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function o(e){return s.l.get_bytes_url(e)}function u(e,t,r){return async function(e,t,r){const s=await n.$M.post(`save_bin/${e}`,{base64:d(t)});return 0!==s.code?((0,i.zN)(s.message??"保存失败"),!1):(r&&(0,i.SK)(r),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,r)}function d(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4350],{34350(e,t,n){n.r(t),n.d(t,{default:()=>H});var s=n(96540),o=n(82893),i=n(34843),l=n(85997),a=n(57952),r=n(3198),c=n(14284),d=n(34289),u=n(53459),m=n(32768),p=n(78247),h=n(62042),f=n(2543),v=n(34251),_=n(78150),x=n(22022),w=n(88815),y=n(52671),j=n(23430),g=n(87361),k=n(99214);const C="filecat_studio_view_state";function S(e,t){return`${e}::${t}`}function b(){try{const e=localStorage.getItem(C);if(!e)return{};const t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch(e){return{}}}function R(e){try{localStorage.setItem(C,JSON.stringify(e))}catch(e){}}function A(e,t){if(t)return b()[S(e,t)]}function I(e,t,n){if(!t)return;const s=b();s[S(e,t)]=n,R(s)}var $=n(72458),N=n(74848);const U=s.lazy(()=>Promise.all([n.e(122),n.e(4091)]).then(n.bind(n,84091))),M=s.lazy(()=>Promise.all([n.e(1384),n.e(1075),n.e(1142)]).then(n.bind(n,71142))),P=s.lazy(()=>n.e(4877).then(n.bind(n,64877))),E=s.lazy(()=>Promise.all([n.e(3277),n.e(9345)]).then(n.bind(n,49345))),z=s.lazy(()=>Promise.all([n.e(3140),n.e(5744)]).then(n.bind(n,16575))),D=s.lazy(()=>Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8781),n.e(6404)]).then(n.bind(n,35304))),L=s.lazy(()=>Promise.resolve().then(n.bind(n,20892))),F=s.lazy(()=>Promise.all([n.e(9861),n.e(1922),n.e(4935)]).then(n.bind(n,24935))),G=s.lazy(()=>Promise.all([n.e(9861),n.e(9290),n.e(26)]).then(n.bind(n,26))),K=s.lazy(()=>Promise.all([n.e(9861),n.e(610),n.e(2515)]).then(n.bind(n,72515)));function W(e){return(0,v.uL)(e)===m.Iw.md}function B(e){return(0,v.uL)(e)===m.Iw.excalidraw}function J(e){return(0,v.uL)(e)===m.Iw.mind}function T(e){return(0,v.uL)(e)===m.Iw.timeline}function X(e){return(0,v.uL)(e)===m.Iw.excel}function H(e){const[t,n]=(0,s.useState)([]),[S,b]=(0,s.useState)(""),[R,H]=(0,s.useState)(!1),[O,V]=(0,s.useState)({path:"",name:""}),[Y,Z]=(0,s.useState)(0),[q,Q]=(0,s.useState)([]),[ee,te]=(0,s.useState)(""),ne=(0,s.useRef)(""),se=(0,s.useRef)({path:"",name:""}),[oe,ie]=(0,i.fp)(o.AG.confirm),[le,ae]=(0,s.useState)(!1),[re,ce]=(0,i.fp)(o.AG.fileShellShow),[de,ue]=(0,i.fp)(o.AG.file_shell_hidden),me=(0,k.Cf)(),pe=(0,s.useRef)(null),he=(0,s.useRef)(null),[fe,ve]=(0,s.useState)(!1),[_e,xe]=(0,s.useState)(16),[we,ye]=(0,i.fp)(o.AG.showPrompt),{t:je}=(0,x.Bd)(),ge=(0,y.Zp)(),ke=W(O.name),Ce=B(O.name),Se=J(O.name),be=T(O.name),Re=X(O.name),Ae=(Ie=O.name,(0,v.uL)(Ie)===m.Iw.docx);var Ie;const $e=function(e){return(0,v.uL)(e)===m.Iw.pptx}(O.name),Ne=(0,s.useRef)(null),Ue=(0,s.useRef)(null),Me=(0,s.useRef)(null),Pe=(0,s.useRef)(null),Ee=(0,s.useRef)(null),ze=(0,s.useRef)(null),De=(0,s.useRef)(null),Le=(0,s.useRef)(null),Fe=(0,s.useRef)(null),[Ge,Ke]=(0,s.useState)([]),[We,Be]=(0,s.useState)(-1),Je=(0,s.useCallback)(()=>{const e=ne.current,t=se.current.name;if(!e)return;let n="ace";W(t)?n="md":B(t)?n="draw":J(t)?n="mind":T(t)?n="timeline":X(t)&&(n="excel");const s="ace"===n?Ue.current:"draw"===n?Me.current:"mind"===n?Pe.current:"timeline"===n?Ee.current:"md"===n?Ne.current?{get_view_state:()=>({scroll:Ne.current?.get_scroll()??0})}:null:"excel"===n?Fe.current:null,o=s?.get_view_state?.();o&&I(n,e,o)},[]),[Te,Xe]=(0,s.useState)("folder"),[He,Oe]=(0,s.useState)(!0),Ve=(0,k.oT)(),[Ye]=(0,y.ok)(),Ze="1"===Ye.get("chat_open"),[qe,Qe]=(0,i.fp)(o.AG.studio_chat_width),et=(0,s.useRef)(null),[tt,nt]=(0,s.useState)(!1),[st,ot]=(0,s.useState)(void 0),[it,lt]=(0,i.fp)(o.AG.ai_chat_session_by_cwd),at=(0,y.zy)(),rt=(()=>{const e=`${g.o.studio_page}/`,t=at.pathname.startsWith(e)?at.pathname.slice(e.length):"",n=(0,d.GG)("file",decodeURIComponent(t));return n.endsWith("/")?n:`${n}/`})(),{check_user_auth:ct}=(0,p.MH)(),[dt]=(0,i.fp)(o.AG.user_base_info),ut=ct(j.oV.ai_agent_page);(0,s.useEffect)(()=>{dt?.user_data&&Ze&&!ut&&Ve("chat_open",null)},[Ze,ut,dt]);const mt=(0,$.Jn)(j.nM.get_now_dir(dt),rt);(0,k.rJ)(mt);const pt=async()=>{const e=rt;b(e);const t=await c.$M.post("studio/get/item",{path:e});if(t.code===u.m.Success){const e=[],s=[];for(const n of t.data.list)"folder"===n.type?e.push(n):"file"===n.type&&s.push(n);n([...e,...s])}},ht=(e,t)=>e===t||e.startsWith(t+"/");(0,s.useEffect)(()=>{ae(!1),V({path:"",name:""}),te(""),p.xK.set_value_temp(""),Q([]),pt()},[at]);const ft=async(e,t)=>{if(Je(),p.xK.set_value_temp(""),!X(e)){const e=await c.$M.get(`${encodeURIComponent(t)}`);p.xK.set_value_temp(e.data)}V({path:t,name:e}),te(t),ne.current=t,se.current={path:t,name:e},Xe("folder"),ae(!1)},vt=(e,t)=>{e.size>w.o5?ie({open:!0,handle:()=>{ft(e.name,t),ie({open:!1,handle:null}),ae(!1)},title:"超过20MB了还要打开吗?"}):ft(e.name,t)};function _t(){Ue.current?.save()}const xt=e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()){if(e.preventDefault(),ke||Ce||Se||be)return;if(Re)return void ze.current?.save(je("保存成功"));if(Ae)return void De.current?.save(je("保存成功"));if($e)return void Le.current?.save(je("保存成功"));le&&_t()}};(0,s.useEffect)(()=>(document.addEventListener("keydown",xt),()=>{document.removeEventListener("keydown",xt)}),[le,ke,Ce,Se,be,Re,Ae,$e]);const wt=(0,s.useCallback)(f.throttle(e=>{const t=parseFloat(getComputedStyle(he.current).fontSize),n=window.innerWidth/t-4,s=e.clientX/t,o=2.25+pe.current.offsetWidth/t;s<=n&&s>=o&&xe(parseFloat(s.toFixed(2)))},32),[]),yt=()=>{ve(!1),he.current.removeEventListener("pointermove",wt)},jt=(0,s.useCallback)(f.throttle(e=>{const t=et.current;if(!t)return;const n=parseFloat(getComputedStyle(t).fontSize),s=t.parentElement.getBoundingClientRect().right-e.clientX,o=Math.min(Math.max(s,0),t.parentElement.getBoundingClientRect().width);Qe(parseFloat((o/n).toFixed(2)))},32),[]),gt=()=>{nt(!1),document.removeEventListener("pointermove",jt)},kt=[{r:je("创建文件"),v:"创建文件"},{r:je("创建目录"),v:"创建目录"},{r:je("重命名"),v:"重命名"},{r:je("删除"),v:"删除"}],Ct=[{r:je("重命名"),v:"重命名"},{r:je("删除"),v:"删除"}],St=(e,t,n,s,o)=>{e.preventDefault();const i=new v.ik;i.path=n,i.filename=t,i.x=e.clientX,i.y=e.clientY,i.items=s?kt:Ct,o===pt&&(i.items=i.items.slice(0,2)),i.type=s?m.Iw.studio_folder:m.Iw.studio_file;const l=e=>{o(e)};i.textClick=e=>{switch(e){case"创建文件":ye({show:!0,type:_.PromptEnum.FileNew,overlay:!0,data:{dir:n,call:l}});break;case"创建目录":ye({show:!0,type:_.PromptEnum.DirNew,overlay:!0,data:{dir:n,call:l}});break;case"删除":if(le&&(O.path===n||O.path.includes(n))){const e=()=>{l(s),ae(!1),V({}),p.xK.set_value_temp("")};ye({show:!0,type:_.PromptEnum.FilesDelete,overlay:!0,data:{path:n,call:e,filename:t}});break}ye({show:!0,type:_.PromptEnum.FilesDelete,overlay:!0,data:{path:n,filename:t,call:s?()=>{l(!0)}:l}});break;case"重命名":ye({show:!0,type:_.PromptEnum.FileRename,overlay:!0,data:{path:n,dir:(0,d.Yp)(n),call:(e,t)=>{((e,t)=>{if(ee&&ht(ee,e)){const n=t+ee.slice(e.length);te(n),V({path:n,name:(0,d.mH)(n)})}const n=(0,d.oW)(rt);if(ht(n,e)){const s=t+n.slice(e.length);return void ge(`${g.o.studio_page}/${encodeURIComponent(`/file/${s}`)}`,{replace:!0})}Z(e=>e+1),pt()})(e,t)},filename:t}})}},ye({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:i})};const bt=ke&&"outline"===Te;return(0,N.jsxs)("div",{className:"studio studio--file",children:[(0,N.jsxs)(a.A,{ignore_tags:!0,left_children:[(0,N.jsx)(l.rA,{title:"取消",icon:"close",onClick:()=>{Je(),function(){try{localStorage.removeItem(C)}catch(e){}}(),ce({show:!1,path:""}),ue(void 0),ge(-1)}},1),(0,N.jsx)("div",{children:O.name},2)],children:[(0,N.jsx)("title",{children:O.name}),(0,N.jsx)(l.rA,{title:"侧边栏",icon:"list",onClick:()=>Oe(e=>!e),selected:He}),ke&&[(0,N.jsx)(l.rA,{icon:"source"===Ne.current?.mode()?"edit":"code",title:"source"===Ne.current?.mode()?je("实时编辑模式"):je("源码模式"),onClick:()=>Ne.current?.toggle_mode()},"mode"),(0,N.jsx)(l.rA,{title:je("导出PDF"),icon:"print",onClick:()=>Ne.current?.export_pdf()},"pdf")],!ke&&(0,v.zr)(O.name)&&(0,N.jsx)(l.rA,{title:"格式化",icon:"data_object",onClick:function(){p.xK.get_editor()?.formatCode()}}),me.can_terminal&&(0,N.jsx)(l.rA,{icon:"terminal",title:"shell",onClick:function(){!0!==de&&!1!==de?re.show?ce({show:!1,path:""}):(ce({show:!0,path:rt}),ue(!1)):ue(!de)}}),ct(j.oV.ai_agent_page)&&me.ai_chat_available&&(0,N.jsx)(l.rA,{title:je("AI 聊天"),icon:"smart_toy",selected:Ze,onClick:()=>Ve("chat_open",!Ze?"1":null)}),le&&(ke?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>Ne.current?.save()}):Ce?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>Me.current?.save()}):Se?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>Pe.current?.save()}):be?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>Ee.current?.save()}):Re?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>ze.current?.save(je("保存成功"))}):Ae?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>De.current?.save(je("保存成功"))}):$e?(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:()=>Le.current?.save(je("保存成功"))}):(0,N.jsx)(l.rA,{title:je("保存"),icon:"save",onClick:_t}))]}),(0,N.jsxs)("div",{className:"studio-body",ref:he,children:[(0,N.jsxs)("div",{className:"studio-nav",style:{display:He?void 0:"none",width:_e-1+"em"},onContextMenu:e=>{St(e,O.name,rt,!0,pt)},children:[(0,N.jsx)("div",{className:"studio-nav-outline",style:{display:bt?void 0:"none"},children:(0,N.jsx)(P,{items:Ge,active_pos:We,on_click:e=>Ne.current?.goto_heading(e)})}),(0,N.jsx)("div",{className:"studio-nav-folder",style:{display:bt?"none":void 0},children:(0,N.jsx)(s.Fragment,{children:(0,N.jsx)(r.z,{pre_path:S,list:t,click:async(e,t,n)=>{if("folder"===e.type){Q(e=>e.includes(n)?e:[...e,n]);const e=await c.$M.post("studio/get/item",{path:`${n}`});if(e.code===u.m.Success){const n=[],s=[];for(const t of e.data.list)"folder"===t.type?n.push(t):"file"===t.type&&s.push(t);t([...n,...s])}}else{if(le)return void ie({open:!0,handle:()=>{ie({open:!1,handle:null}),ae(!1),vt(e,n)},title:"确定不保存就切换吗?"});vt(e,n)}},active_path:ee,expand_paths:q,handleContextMenu:St,fatherNowToggleExpansion:pt})},Y)}),ke&&(0,N.jsx)("div",{className:"studio-nav-switch",children:(0,N.jsx)(l.rA,{icon:bt?"folder":"list",title:je(bt?"文件目录":"大纲"),onClick:()=>Xe(bt?"folder":"outline")})})]}),He&&(0,N.jsx)("div",{className:"studio__divider",ref:pe,onPointerDown:()=>{ve(!0),he.current.addEventListener("pointermove",wt)},onPointerUp:yt}),fe&&(0,N.jsx)("div",{className:"shell__overlay",onPointerUp:yt}),ke?(0,N.jsx)("div",{className:"studio-editor studio-editor--md",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(M,{pane:{path:ee,url:c.$M.getDownloadUrl(encodeURIComponent(ee)),name:O.name,on_dirty:ae,on_outline:(e,t)=>{Ke(e),Be(t)},register:e=>{Ne.current=e;const t=A("md",ee);if(!t?.scroll)return;const n=t.scroll;let s=0;const o=()=>{++s>40||(e.set_scroll(n),e.get_scroll()!==n&&window.setTimeout(o,50))};window.setTimeout(o,50)}}})})},ee):Ce?(0,N.jsx)("div",{className:"studio-editor studio-editor--draw",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(z,{reset_key:ee,view_state:A("draw",ee),url:c.$M.getDownloadUrl(encodeURIComponent(ee)),save_path:ee,on_dirty:ae,on_saved:()=>ae(!1),register:e=>{Me.current=e}})})},ee):Se?(0,N.jsx)("div",{className:"studio-editor studio-editor--mind",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(D,{reset_key:ee,view_state:A("mind",ee),url:c.$M.getDownloadUrl(encodeURIComponent(ee)),on_dirty:ae,on_saved:()=>ae(!1),register:e=>{Pe.current=e},on_save:async e=>(await c.$M.post(`save/${encodeURIComponent(ee)}`,{context:e})).code===u.m.Success})})},ee):be?(0,N.jsx)("div",{className:"studio-editor studio-editor--timeline",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(L,{reset_key:ee,view_state:A("timeline",ee),url:c.$M.getDownloadUrl(encodeURIComponent(ee)),on_dirty:ae,register:e=>{Ee.current=e},on_save:async e=>(await c.$M.post(`save/${encodeURIComponent(ee)}`,{context:e})).code===u.m.Success})})},ee):Re?(0,N.jsx)("div",{className:"studio-editor studio-editor--excel",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(F,{url:c.$M.getDownloadUrl(encodeURIComponent(ee)),save_path:ee,on_dirty:ae,bind_save:e=>{ze.current={save:e}},bind_view:e=>{const t=A("excel",ee);Fe.current={get_view_state:()=>{const t=e.get_state();return{sheet:t.sheet,scroll_x:t.scroll_left,scroll_y:t.scroll_top}}},t&&e.set_state({sheet:t.sheet,scroll_left:t.scroll_x,scroll_top:t.scroll_y})}})})},ee):Ae?(0,N.jsx)("div",{className:"studio-editor studio-editor--office",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(G,{url:c.$M.getDownloadUrl(encodeURIComponent(ee)),save_path:ee,on_dirty:ae,bind_save:e=>{De.current={save:e}}})})},ee):$e?(0,N.jsx)("div",{className:"studio-editor studio-editor--office",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(K,{url:c.$M.getDownloadUrl(encodeURIComponent(ee)),save_path:ee,on_dirty:ae,bind_save:e=>{Le.current={save:e}}})})},ee):(0,N.jsx)("div",{className:"studio-editor",children:O.name&&(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(U,{name:O.name,on_dirty:ae,view_state:A("ace",ee),on_view_state:e=>I("ace",ee,e),register:e=>{Ue.current=e},save:async e=>{const t={context:p.xK.get_editor_value()},n=await c.$M.post(`save/${encodeURIComponent(ee)}`,t);return n.code===u.m.Success||e||(0,h.zN)(je("保存失败")),n.code===u.m.Success}})})},ee),Ze&&(0,N.jsxs)(s.Fragment,{children:[(0,N.jsx)("div",{className:"studio__divider studio__divider--chat",ref:et,onPointerDown:e=>{e.preventDefault(),nt(!0),document.addEventListener("pointermove",jt),document.addEventListener("pointerup",gt,{once:!0})}}),(0,N.jsx)("div",{className:"studio-chat-panel",style:{width:`${qe}em`},children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(E,{inline_header:!0,sync_url:!1,file_cwd_path:mt,session_id:st??(Rt=mt,o.AG.get_ai_chat_session(it,Rt)),on_session_change:e=>{ot(e),((e,t)=>{lt({...it,[e]:t})})(mt,e)}})})})]})]})]});var Rt}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4935],{24935(e,t,n){n.r(t),n.d(t,{default:()=>b});var r=n(96540),l=n(47049),s=n(8890);const o=e=>Math.round(7*e+5),c=e=>Math.round(4*e/3);function a(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),l=r%100,s=e.getUTCMonth()+1,o=e.getUTCDate(),c="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(l)).replace(/(?<!m)m(?!m)/g,String(s)).replace(/mm/g,n(s)).replace(/d(?!d)/g,String(o)).replace(/dd/g,n(o)).replace(/aaaa/g,`星期${c}`)}const h=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function d(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&h(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&h(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const l=t.cellXfs?.[r];if(!l)return;const s=t.fills?.[l.fillId],o=t.fonts?.[l.fontId],c={};"solid"===s?.patternType&&(c.bg=i(s.fgColor,n)),c.color=i(o?.color,n),o?.bold&&(c.bold=!0),o?.italic&&(c.italic=!0),o?.size&&(c.fontSize=o.size),o?.name&&(c.fontFamily=o.name),o?.underline&&(c.underline=!0),o?.strike&&(c.strike=!0);const a=l.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(c.align=a.horizontal),a?.vertical&&(c.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(c.wrap=!0),a?.indent&&(c.indent=a.indent),Object.keys(c).length?c:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const l=r.numFmtId;if(void 0===l||0===l)return;const s={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(s[l])return s[l];const o=t.numFmts;return o instanceof Map?o.get(l):void 0}async function p(e){const t=await(0,l.a)(a(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const l=[],s=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,o=new Map;let c;for(;c=s.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(c[2])?.[1];e&&o.set(c[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>l[n]=o.get(e)??t[n]),l}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,l=t.styles;let s=0,a=0;r.rows.forEach((e,t)=>{e.size&&(s=Math.max(s,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=s;e++){const t=[],s=r.rows.get(e);for(let r=1;r<=a;r++){const o=s?.get(r),c=d(o,n,g(o,l));t.push(c.text);const a=m(o,l,n);c.runs&&(a?a.runs=c.runs:u.set(`${e-1}_${r-1}`,{runs:c.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const f=o(r.defaultColumnWidth??8.43),h=new Array(a).fill(f);r.columnDimensions?.forEach(e=>{const t=o(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<h.length&&(h[n-1]=t)});const p=c(r.defaultRowHeight??15),x=new Array(s).fill(p),y=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<x.length&&e.height&&(x[t-1]=c(e.height)),e.hidden&&t-1<s&&y.add(t-1)});const v=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:h,row_heights:x,hidden_rows:y,merges:v}})}var x=n(74848);function y(e){const{bytes:t,on_change:n,bind_save:o}=e,[c,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,h]=(0,r.useState)(0),[d,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),y=(0,r.useRef)(null),[_,b]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),p(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const S=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{o(async()=>{const e=await async function(e,t){const n=await(0,l.a)(a(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const l=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,s=n+1;let o=l.rows.get(r);o||(o=new Map,l.rows.set(r,o));const c=o.get(s);null!==e&&""!==e?c?c.value=e:o.set(s,{row:r,col:s,value:e}):c&&(c.value=null)})})}),await(0,s.n)(n)}(t,c);return g.current=!1,n(!1),e})},[c,t,o,n]),(0,r.useEffect)(()=>{e.bind_view?.({get_state:()=>({sheet:u,scroll_left:y.current?.scrollLeft??0,scroll_top:y.current?.scrollTop??0}),set_state:e=>{"number"==typeof e.sheet&&e.sheet>=0&&e.sheet<c.length&&f(e.sheet);const t=y.current;t&&(t.scrollLeft=e.scroll_left??0,t.scrollTop=e.scroll_top??0)}})},[u,c.length,e.bind_view]);const C=c[u],{col_x:M,row_y:E,total_w:j,total_h:$}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),k=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const l=n+r>>1;e[l]<t?n=l+1:r=l}return n},F=(0,r.useCallback)(()=>{const e=y.current;if(!e||!M.length)return;const t=Math.max(0,k(M,e.scrollLeft)-1),n=Math.max(0,k(E,e.scrollTop)-1);b({c0:t,c1:Math.min(M.length-1,k(M,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,k(E,e.scrollTop+e.clientHeight)+2)})},[M,E]);(0,r.useEffect)(()=>{F()},[C,F]);if(d)return(0,x.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:d});if(!c.length)return(0,x.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const D=C?.values??[],N=(E.length,M.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let l=e;l<=n;l++)for(let n=t;n<=r;n++)l===e&&n===t||N.add(`${l}_${n}`)});const A=(e,t)=>{const n=D[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,x.jsxs)("div",{className:"xlsx-body",children:[(0,x.jsx)("div",{className:"xlsx-tabs",children:c.map((e,t)=>(0,x.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),y.current&&(y.current.scrollTop=0,y.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,x.jsx)("div",{className:"xlsx-scroll",ref:y,onScroll:F,children:(0,x.jsxs)("div",{className:"xlsx-grid",style:{width:46+j,height:24+$},children:[Array.from({length:Math.max(0,_.c1-_.c0)}).map((e,t)=>{const n=_.c0+t;return(0,x.jsx)("div",{className:"xlsx-head",style:{left:46+M[n],top:0,width:M[n+1]-M[n],height:24},children:w(n)},"ch"+n)}),Array.from({length:Math.max(0,_.r1-_.r0)}).map((e,t)=>{const n=_.r0+t;return(0,x.jsxs)(r.Fragment,{children:[(0,x.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,_.c1-_.c0)}).map((e,t)=>{const r=_.c0+t;if(N.has(`${n}_${r}`))return null;const l=C.merges.find(e=>e[0]===n&&e[1]===r),s=l?M[l[3]+1]-M[l[1]]:M[r+1]-M[r],o=l?E[l[2]+1]-E[l[0]]:E[n+1]-E[n];return(0,x.jsx)(v,{value:D[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:A(n,r+1),style:{left:46+M[r],top:24+E[n],width:s,height:o,zIndex:l?2:1},on_change:e=>((e,t,n)=>{const r=c[u];r&&(r.values[e][t]=""===n?null:n,S(),h(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function v(e){const{value:t,cell_style:n,style:l,spillable:s,on_change:o}=e,[c,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{c&&f.current&&(f.current.focus(),f.current.select())},[c]);const h=()=>{a(!1),i!==(t??"")&&o(i)},d={};return n?.bg&&(d.backgroundColor=n.bg),n?.color&&(d.color=n.color),n?.bold&&(d.fontWeight=600),n?.italic&&(d.fontStyle="italic"),n?.fontSize&&(d.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(d.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(d.textDecoration="underline"),n?.strike&&(d.textDecoration=d.textDecoration?`${d.textDecoration} line-through`:"line-through"),n?.align&&(d.textAlign=n.align,d.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(d.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(d.whiteSpace="pre-wrap"),n?.indent&&(d.paddingLeft=.35+1.4*n.indent+"em"),(0,x.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${s?"xlsx-cell--spill":""}`,style:{...l,...d,"--cell-h":n?.wrap?"1.4":l.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:c?(0,x.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:h,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),h())}}):n?.runs?(0,x.jsx)("span",{children:n.runs.map((e,t)=>(0,x.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function w(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var _=n(99018);function b(e){const{url:t,save_path:n,on_dirty:l,bind_save:s}=e,[o,c]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[h,d]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),d(!1),c(void 0),(0,_.PQ)(t).then(t=>e&&c(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{l?.(h)},[h,l]),(0,r.useEffect)(()=>{s?.(async()=>{if(!m.current)return!1;const e=await m.current(),t=await(0,_.GB)(n,e);return t&&(c(e),d(!1)),t})},[n,s]),a?(0,x.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!o?(0,x.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,x.jsx)(y,{bytes:o,on_change:d,bind_save:e=>m.current=e,bind_view:e.bind_view})}},99018(e,t,n){n.d(t,{GB:()=>i,PQ:()=>a,Vi:()=>c});var r=n(14284),l=n(57889),s=n(34289),o=n(62042);function c(e){return`${encodeURIComponent((0,s.GG)("file",(0,s.vX)()))}${e}`}async function a(e){return l.l.get_bytes_url(e)}function i(e,t){return async function(e,t){const n=await r.$M.post(`save_bin/${e}`,{base64:u(t)});return 0===n.code||((0,o.zN)(n.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function u(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4935],{24935(e,t,n){n.r(t),n.d(t,{default:()=>b});var r=n(96540),l=n(47049),s=n(8890);const o=e=>Math.round(7*e+5),c=e=>Math.round(4*e/3);function a(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),l=r%100,s=e.getUTCMonth()+1,o=e.getUTCDate(),c="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(l)).replace(/(?<!m)m(?!m)/g,String(s)).replace(/mm/g,n(s)).replace(/d(?!d)/g,String(o)).replace(/dd/g,n(o)).replace(/aaaa/g,`星期${c}`)}const h=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function d(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&h(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&h(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const l=t.cellXfs?.[r];if(!l)return;const s=t.fills?.[l.fillId],o=t.fonts?.[l.fontId],c={};"solid"===s?.patternType&&(c.bg=i(s.fgColor,n)),c.color=i(o?.color,n),o?.bold&&(c.bold=!0),o?.italic&&(c.italic=!0),o?.size&&(c.fontSize=o.size),o?.name&&(c.fontFamily=o.name),o?.underline&&(c.underline=!0),o?.strike&&(c.strike=!0);const a=l.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(c.align=a.horizontal),a?.vertical&&(c.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(c.wrap=!0),a?.indent&&(c.indent=a.indent),Object.keys(c).length?c:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const l=r.numFmtId;if(void 0===l||0===l)return;const s={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(s[l])return s[l];const o=t.numFmts;return o instanceof Map?o.get(l):void 0}async function p(e){const t=await(0,l.a)(a(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const l=[],s=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,o=new Map;let c;for(;c=s.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(c[2])?.[1];e&&o.set(c[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>l[n]=o.get(e)??t[n]),l}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,l=t.styles;let s=0,a=0;r.rows.forEach((e,t)=>{e.size&&(s=Math.max(s,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=s;e++){const t=[],s=r.rows.get(e);for(let r=1;r<=a;r++){const o=s?.get(r),c=d(o,n,g(o,l));t.push(c.text);const a=m(o,l,n);c.runs&&(a?a.runs=c.runs:u.set(`${e-1}_${r-1}`,{runs:c.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const f=o(r.defaultColumnWidth??8.43),h=new Array(a).fill(f);r.columnDimensions?.forEach(e=>{const t=o(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<h.length&&(h[n-1]=t)});const p=c(r.defaultRowHeight??15),x=new Array(s).fill(p),y=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<x.length&&e.height&&(x[t-1]=c(e.height)),e.hidden&&t-1<s&&y.add(t-1)});const v=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:h,row_heights:x,hidden_rows:y,merges:v}})}var x=n(74848);function y(e){const{bytes:t,on_change:n,bind_save:o}=e,[c,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,h]=(0,r.useState)(0),[d,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),y=(0,r.useRef)(null),[_,b]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),p(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const S=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{o(async()=>{const e=await async function(e,t){const n=await(0,l.a)(a(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const l=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,s=n+1;let o=l.rows.get(r);o||(o=new Map,l.rows.set(r,o));const c=o.get(s);null!==e&&""!==e?c?c.value=e:o.set(s,{row:r,col:s,value:e}):c&&(c.value=null)})})}),await(0,s.n)(n)}(t,c);return g.current=!1,n(!1),e})},[c,t,o,n]),(0,r.useEffect)(()=>{e.bind_view?.({get_state:()=>({sheet:u,scroll_left:y.current?.scrollLeft??0,scroll_top:y.current?.scrollTop??0}),set_state:e=>{"number"==typeof e.sheet&&e.sheet>=0&&e.sheet<c.length&&f(e.sheet);const t=y.current;t&&(t.scrollLeft=e.scroll_left??0,t.scrollTop=e.scroll_top??0)}})},[u,c.length,e.bind_view]);const C=c[u],{col_x:M,row_y:E,total_w:j,total_h:$}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),k=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const l=n+r>>1;e[l]<t?n=l+1:r=l}return n},F=(0,r.useCallback)(()=>{const e=y.current;if(!e||!M.length)return;const t=Math.max(0,k(M,e.scrollLeft)-1),n=Math.max(0,k(E,e.scrollTop)-1);b({c0:t,c1:Math.min(M.length-1,k(M,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,k(E,e.scrollTop+e.clientHeight)+2)})},[M,E]);(0,r.useEffect)(()=>{F()},[C,F]);if(d)return(0,x.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:d});if(!c.length)return(0,x.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const D=C?.values??[],N=(E.length,M.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let l=e;l<=n;l++)for(let n=t;n<=r;n++)l===e&&n===t||N.add(`${l}_${n}`)});const A=(e,t)=>{const n=D[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,x.jsxs)("div",{className:"xlsx-body",children:[(0,x.jsx)("div",{className:"xlsx-tabs",children:c.map((e,t)=>(0,x.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),y.current&&(y.current.scrollTop=0,y.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,x.jsx)("div",{className:"xlsx-scroll",ref:y,onScroll:F,children:(0,x.jsxs)("div",{className:"xlsx-grid",style:{width:46+j,height:24+$},children:[Array.from({length:Math.max(0,_.c1-_.c0)}).map((e,t)=>{const n=_.c0+t;return(0,x.jsx)("div",{className:"xlsx-head",style:{left:46+M[n],top:0,width:M[n+1]-M[n],height:24},children:w(n)},"ch"+n)}),Array.from({length:Math.max(0,_.r1-_.r0)}).map((e,t)=>{const n=_.r0+t;return(0,x.jsxs)(r.Fragment,{children:[(0,x.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,_.c1-_.c0)}).map((e,t)=>{const r=_.c0+t;if(N.has(`${n}_${r}`))return null;const l=C.merges.find(e=>e[0]===n&&e[1]===r),s=l?M[l[3]+1]-M[l[1]]:M[r+1]-M[r],o=l?E[l[2]+1]-E[l[0]]:E[n+1]-E[n];return(0,x.jsx)(v,{value:D[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:A(n,r+1),style:{left:46+M[r],top:24+E[n],width:s,height:o,zIndex:l?2:1},on_change:e=>((e,t,n)=>{const r=c[u];r&&(r.values[e][t]=""===n?null:n,S(),h(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function v(e){const{value:t,cell_style:n,style:l,spillable:s,on_change:o}=e,[c,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{c&&f.current&&(f.current.focus(),f.current.select())},[c]);const h=()=>{a(!1),i!==(t??"")&&o(i)},d={};return n?.bg&&(d.backgroundColor=n.bg),n?.color&&(d.color=n.color),n?.bold&&(d.fontWeight=600),n?.italic&&(d.fontStyle="italic"),n?.fontSize&&(d.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(d.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(d.textDecoration="underline"),n?.strike&&(d.textDecoration=d.textDecoration?`${d.textDecoration} line-through`:"line-through"),n?.align&&(d.textAlign=n.align,d.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(d.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(d.whiteSpace="pre-wrap"),n?.indent&&(d.paddingLeft=.35+1.4*n.indent+"em"),(0,x.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${s?"xlsx-cell--spill":""}`,style:{...l,...d,"--cell-h":n?.wrap?"1.4":l.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:c?(0,x.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:h,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),h())}}):n?.runs?(0,x.jsx)("span",{children:n.runs.map((e,t)=>(0,x.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function w(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var _=n(99018);function b(e){const{url:t,save_path:n,on_dirty:l,bind_save:s}=e,[o,c]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[h,d]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),d(!1),c(void 0),(0,_.PQ)(t).then(t=>e&&c(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{l?.(h)},[h,l]),(0,r.useEffect)(()=>{s?.(async e=>{if(!m.current)return!1;const t=await m.current(),r=await(0,_.GB)(n,t,e);return r&&(c(t),d(!1)),r})},[n,s]),a?(0,x.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!o?(0,x.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,x.jsx)(y,{bytes:o,on_change:d,bind_save:e=>m.current=e,bind_view:e.bind_view})}},99018(e,t,n){n.d(t,{GB:()=>i,PQ:()=>a,Vi:()=>c});var r=n(14284),l=n(57889),s=n(34289),o=n(62042);function c(e){return`${encodeURIComponent(function(){const e=(0,s.GG)("file",(0,s.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function a(e){return l.l.get_bytes_url(e)}function i(e,t,n){return async function(e,t,n){const l=await r.$M.post(`save_bin/${e}`,{base64:u(t)});return 0!==l.code?((0,o.zN)(l.message??"保存失败"),!1):(n&&(0,o.SK)(n),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,n)}function u(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|