revise 2.1.0 → 2.2.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/CHANGELOG.md +94 -0
- package/assets/historyMaterializeWorker-B51R08XN.js +612 -0
- package/backend.d.ts +8 -2
- package/backend.js +1 -1
- package/chunks/AgentPageRenderer-CH8kSTJn.js +1 -0
- package/chunks/AgentPageRenderer-P23XVguo.js +1 -0
- package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +1 -0
- package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +1 -0
- package/chunks/{BidiText-C8PBPSQY.js → BidiText-Swm5fl9J.js} +74 -74
- package/chunks/DocumentMutator-btiDK57e.js +31 -0
- package/chunks/{DocumentScrubber-DS4LFDKS.js → DocumentScrubber-CMPfm_HF.js} +1 -1
- package/chunks/{DocumentScrubber-COPepQKE.js → DocumentScrubber-Cm2kH8op.js} +1 -1
- package/chunks/{DocumentScrubber-Cf_QqHhF.js → DocumentScrubber-bJoKijol.js} +1 -1
- package/chunks/DocumentStylesheet-DreoD7sD.js +7 -0
- package/chunks/DocxConverter-BcVG-p5K.js +13 -0
- package/chunks/DocxConverter-D2bO5RE-.js +1125 -0
- package/chunks/DocxConverter-haCfRuWb.js +13 -0
- package/chunks/{DocxGraft-Ba63IRP4.js → DocxGraft-BRKh4mHQ.js} +1 -1
- package/chunks/{DocxGraft-DjERgl-z.js → DocxGraft-BxSQtl12.js} +2 -2
- package/chunks/{DocxGraft-cYlmw4Ab.js → DocxGraft-C9MBQCnf.js} +1 -1
- package/chunks/FileImporter-CszqRfVU.js +1 -0
- package/chunks/FileImporter-DObFoCCn.js +1 -0
- package/chunks/{HtmlConverter-Sd9t49vH.js → HtmlConverter-DwXB4IDh.js} +12 -12
- package/chunks/{MarkdownConverter-BdJgh8xt.js → MarkdownConverter-CUC8GgsS.js} +1 -1
- package/chunks/MathRenderer-DT6GyJXb.js +68 -0
- package/chunks/OdtConverter-7h9HHMpL.js +125 -0
- package/chunks/OdtConverter-Ct4qypJk.js +6 -0
- package/chunks/OdtConverter-DFl__sJc.js +6 -0
- package/chunks/OfficeImportShared-BY6FdZ8d.js +1 -0
- package/chunks/OfficeImportShared-BrZoDM0j.js +30 -0
- package/chunks/OfficeImportShared-Bvm-mOyj.js +1 -0
- package/chunks/PdfConverter-1wyvoT7X.js +21 -0
- package/chunks/PdfConverter-BAoEHILo.js +21 -0
- package/chunks/PdfConverter-CKEvFj11.js +448 -0
- package/chunks/{PdfImportService-CQCgsRX1.js → PdfImportService-BhLPp5uG.js} +2 -2
- package/chunks/{PdfImportService-xl7fstr-.js → PdfImportService-xbzrN__L.js} +2 -2
- package/chunks/RtfConverter-Bxn-enp8.js +15 -0
- package/chunks/RtfConverter-LZPzBDSr.js +15 -0
- package/chunks/RtfConverter-_bacXqr1.js +186 -0
- package/chunks/{TableBorders-Cdkc62cX.js → TableBorders-CwnF3jvH.js} +1 -1
- package/chunks/{TxtConverter-C-oiFUAp.js → TxtConverter-C7FOwHpH.js} +1 -1
- package/chunks/XmlConverter-7oo8oeQB.js +2 -0
- package/chunks/XmlConverter-DGORHJcZ.js +96 -0
- package/chunks/XmlConverter-DeLHReK_.js +2 -0
- package/chunks/ar-ComXvtmh.js +13 -0
- package/chunks/backend-DecaBz-I.js +490 -0
- package/chunks/base64-sSPOzq-u.js +198 -0
- package/chunks/{browser-module-CYGCfEyx.js → browser-module-Dj5o3kuL.js} +1 -1
- package/chunks/{browser-module-DgvTMhpA.js → browser-module-UuM_O36W.js} +1 -1
- package/chunks/{capture-BAJ2in5p.js → capture-1btcWcPF.js} +1 -1
- package/chunks/{carrier-C5VZRMxZ.js → carrier-DQeng6yq.js} +1 -1
- package/chunks/de-BkbpIKxx.js +13 -0
- package/chunks/es-CKkXujOF.js +13 -0
- package/chunks/fil-piIHMc8F.js +13 -0
- package/chunks/{footnoteFlatten-Bekh8ZfM.js → footnoteFlatten-DUQticYy.js} +1 -1
- package/chunks/fr-DuA8qLje.js +13 -0
- package/chunks/{graftExport-CRRm1Oe_.js → graftExport-CYnStOdU.js} +1 -1
- package/chunks/index-2TBhRkX7.js +387 -0
- package/chunks/{index-B1idHquf.js → index-Bf14eTEW.js} +231 -229
- package/chunks/index-BwcX_r62.js +387 -0
- package/chunks/{index.es-Bwt05m_b.js → index.es-CI7cDExj.js} +1 -1
- package/chunks/{index.es-DAQD57G4.js → index.es-DHpGt6Y5.js} +1 -1
- package/chunks/ja-DgrSs555.js +13 -0
- package/chunks/{jspdf.es.min-DlTF8uTw.js → jspdf.es.min--GshOuIm.js} +1 -1
- package/chunks/{jspdf.es.min-CnNRolk9.js → jspdf.es.min-DurJZ1zW.js} +1 -1
- package/chunks/pseudoLocale-BoYTjmiK.js +1 -0
- package/chunks/pseudoLocale-DG2NnZmz.js +1 -0
- package/chunks/serverDocumentSession-CJ1EH3Tp.js +15 -0
- package/chunks/{signatures-CBF7NZUy.js → signatures-Bwt_OGik.js} +1 -1
- package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
- package/chunks/zh-9OF3SWWO.js +13 -0
- package/full.js +1 -1
- package/index.d.ts +13 -5
- package/index.js +1 -1
- package/package.json +1 -1
- package/root.js +2 -2
- package/style.css +1 -1
- package/assets/historyMaterializeWorker-C4uxcZEh.js +0 -607
- package/chunks/AgentPageRenderer-BFB0arQL.js +0 -1
- package/chunks/AgentPageRenderer-Dn6SaRjW.js +0 -1
- package/chunks/AttachmentDocumentImporter-BHDJAdky.js +0 -1
- package/chunks/AttachmentDocumentImporter-CxOZqzt1.js +0 -1
- package/chunks/DocumentMutator-4vBJQ74L.js +0 -31
- package/chunks/DocumentStylesheet-byN5dtC6.js +0 -7
- package/chunks/DocxConverter-BCEB7jWY.js +0 -1083
- package/chunks/DocxConverter-C3NflpDr.js +0 -11
- package/chunks/DocxConverter-D9ZNn4nX.js +0 -11
- package/chunks/FileImporter-CHXj9sNX.js +0 -1
- package/chunks/FileImporter-DetvRoJc.js +0 -1
- package/chunks/MathRenderer-B0Y1h1JU.js +0 -62
- package/chunks/OdtConverter-BKtyx012.js +0 -1
- package/chunks/OdtConverter-Ce9j8PRt.js +0 -1
- package/chunks/OdtConverter-D709qfYb.js +0 -31
- package/chunks/PdfConverter-BA8XLTAM.js +0 -21
- package/chunks/PdfConverter-CkDClffR.js +0 -438
- package/chunks/PdfConverter-CxLxd-LJ.js +0 -21
- package/chunks/RtfConverter-BZOnMUGH.js +0 -14
- package/chunks/RtfConverter-Bs81AfXt.js +0 -14
- package/chunks/RtfConverter-DfuE5olb.js +0 -45
- package/chunks/XmlConverter-C0FnrVYk.js +0 -70
- package/chunks/XmlConverter-CQa8baOF.js +0 -2
- package/chunks/XmlConverter-DjEYaIyf.js +0 -2
- package/chunks/ar-BdmGnaKI.js +0 -14
- package/chunks/backend-BIhAX-Gi.js +0 -484
- package/chunks/base64-Qx0OzT4p.js +0 -196
- package/chunks/de-DldIXRFC.js +0 -14
- package/chunks/es-CnyKlSPK.js +0 -14
- package/chunks/index-C-4H81OE.js +0 -378
- package/chunks/index-iZC8xN0t.js +0 -378
- package/chunks/pseudoLocale-BoJwIubw.js +0 -1
- package/chunks/pseudoLocale-DWAm7Dpa.js +0 -1
- package/chunks/serverDocumentSession-DASrQAbW.js +0 -15
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-C-4H81OE.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-iZC8xN0t.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as l,R as y,T as D}from"./index-iZC8xN0t.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function k(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function b(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const s=e.getWorkingDocument(),f=s.children.length,p=l(s);if(!p&&!t&&l(e.getDocumentWithPendingSuggestionsApplied())&&(t=s.children.at(-1)?.id),!p&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!s.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await k(o);let g;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-CHXj9sNX.js"),h=await a.parseFile(m),i=e.getYDoc();if(t)g=y(i,h,t);else{if(!l(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const d=h.pendingDocxCarrier;if(delete h.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),D(i,h)}),d){const{storeDocxCarrier:c}=await import("./DocxGraft-cYlmw4Ab.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-CQCgsRX1.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:g??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{b as importAttachmentIntoDocument,l as isEmptyDocumentForAttachmentImport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as l,R as y,T as D}from"./index-C-4H81OE.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function k(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function b(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const s=e.getWorkingDocument(),f=s.children.length,p=l(s);if(!p&&!t&&l(e.getDocumentWithPendingSuggestionsApplied())&&(t=s.children.at(-1)?.id),!p&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!s.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await k(o);let g;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-DetvRoJc.js"),h=await a.parseFile(m),i=e.getYDoc();if(t)g=y(i,h,t);else{if(!l(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const d=h.pendingDocxCarrier;if(delete h.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),D(i,h)}),d){const{storeDocxCarrier:c}=await import("./DocxGraft-Ba63IRP4.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-xl7fstr-.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:g??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{b as importAttachmentIntoDocument,l as isEmptyDocumentForAttachmentImport};
|