@eigenpal/docx-js-editor 0.0.26 → 0.0.27

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.
Files changed (78) hide show
  1. package/README.md +6 -5
  2. package/dist/{ClipboardManager-Bbo5MM_U.d.cts → ClipboardManager-BYO62Qs5.d.cts} +1 -1
  3. package/dist/{ClipboardManager-CR843H7H.d.ts → ClipboardManager-YQYq5X_Z.d.ts} +1 -1
  4. package/dist/{DocumentAgent-lHtXgMFN.d.ts → DocumentAgent-BW1-gnqM.d.ts} +1 -1
  5. package/dist/{DocumentAgent-cHf96hwL.d.cts → DocumentAgent-ZcA8CUmC.d.cts} +1 -1
  6. package/dist/{agentApi-DmDuQm0e.d.cts → agentApi-B0688ssC.d.cts} +6 -0
  7. package/dist/{agentApi-DmDuQm0e.d.ts → agentApi-B0688ssC.d.ts} +6 -0
  8. package/dist/{chunk-FUK46DWH.js → chunk-4XF5YD4I.js} +2 -2
  9. package/dist/chunk-76GITSCY.cjs +258 -0
  10. package/dist/{chunk-OWMG5MW5.cjs → chunk-7YCCCWUZ.cjs} +3 -3
  11. package/dist/{chunk-6TUCNECX.js → chunk-ABNIHWGF.js} +1 -1
  12. package/dist/{chunk-PIVLDW7B.cjs → chunk-CL62W2HQ.cjs} +7 -7
  13. package/dist/chunk-E7U5ZBOK.js +3 -0
  14. package/dist/{chunk-Y62HOQL2.cjs → chunk-EUH3GF72.cjs} +4 -4
  15. package/dist/chunk-H7AKDCWH.js +258 -0
  16. package/dist/{chunk-5ILXHRJS.cjs → chunk-J5YOIHCW.cjs} +2 -2
  17. package/dist/chunk-JO2CKU4O.js +1 -0
  18. package/dist/chunk-MHUCHYNM.cjs +59 -0
  19. package/dist/{chunk-KL2RYY6G.cjs → chunk-NKW2UER2.cjs} +2 -2
  20. package/dist/chunk-OJ7NJK46.cjs +1 -0
  21. package/dist/chunk-PP54GVGD.js +59 -0
  22. package/dist/{chunk-JIKVCUR6.js → chunk-T2SRPPZY.js} +1 -1
  23. package/dist/{chunk-3X3LTNK4.js → chunk-YP3CXYSU.js} +7 -7
  24. package/dist/{clipboard-CU-zASXS.d.ts → clipboard-D0EG6AxE.d.ts} +1 -1
  25. package/dist/{clipboard-DBabJ6mU.d.cts → clipboard-Da1iPK0O.d.cts} +1 -1
  26. package/dist/{colorResolver-yl7Xh_Qg.d.cts → colorResolver-DR1p8Eg-.d.cts} +2 -2
  27. package/dist/{colorResolver-BTTqW66Q.d.ts → colorResolver-Dk7bMHIa.d.ts} +2 -2
  28. package/dist/core-plugins-reexport.cjs +1 -1
  29. package/dist/core-plugins-reexport.d.cts +4 -4
  30. package/dist/core-plugins-reexport.d.ts +4 -4
  31. package/dist/core-plugins-reexport.js +1 -1
  32. package/dist/core-reexport.cjs +1 -1
  33. package/dist/core-reexport.d.cts +10 -10
  34. package/dist/core-reexport.d.ts +10 -10
  35. package/dist/core-reexport.js +1 -1
  36. package/dist/{fontLoader-Daq8y8C2.d.cts → fontLoader-54sS8rtN.d.cts} +1 -1
  37. package/dist/{fontLoader-DQJOS1sb.d.ts → fontLoader-C7RvUiHx.d.ts} +1 -1
  38. package/dist/headless-reexport.cjs +2 -2
  39. package/dist/headless-reexport.d.cts +7 -7
  40. package/dist/headless-reexport.d.ts +7 -7
  41. package/dist/headless-reexport.js +1 -1
  42. package/dist/index.cjs +2 -2
  43. package/dist/index.d.cts +11 -11
  44. package/dist/index.d.ts +11 -11
  45. package/dist/index.js +1 -1
  46. package/dist/mcp-reexport.cjs +3 -3
  47. package/dist/mcp-reexport.d.cts +2 -2
  48. package/dist/mcp-reexport.d.ts +2 -2
  49. package/dist/mcp-reexport.js +1 -1
  50. package/dist/{react-CFPWe7nV.d.ts → react-C_O0Z9ci.d.ts} +10 -4
  51. package/dist/{react-CKqhN17E.d.cts → react-XjilVrXZ.d.cts} +10 -4
  52. package/dist/react.cjs +1 -1
  53. package/dist/react.d.cts +5 -5
  54. package/dist/react.d.ts +5 -5
  55. package/dist/react.js +1 -1
  56. package/dist/{registry-C2DPl-QW.d.ts → registry-BHOeZbR9.d.ts} +1 -1
  57. package/dist/{registry-CXGC344v.d.cts → registry-CqFFeBgF.d.cts} +1 -1
  58. package/dist/selectionRects-BMXJJCPJ.cjs +1 -0
  59. package/dist/selectionRects-TWK7CAC3.js +1 -0
  60. package/dist/styles.css +1 -1
  61. package/dist/{types-BpokDLqL.d.ts → types-BwCYaZKB.d.ts} +1 -1
  62. package/dist/{types-COQvtZji.d.cts → types-DAxXgYu5.d.cts} +1 -1
  63. package/dist/ui.cjs +1 -1
  64. package/dist/ui.d.cts +3 -3
  65. package/dist/ui.d.ts +3 -3
  66. package/dist/ui.js +1 -1
  67. package/dist/{variableDetector-BYzE_RXw.d.ts → variableDetector-B2FHghLx.d.ts} +1 -1
  68. package/dist/{variableDetector-C8ST_dnq.d.cts → variableDetector-DIeB1Nxd.d.cts} +1 -1
  69. package/package.json +1 -1
  70. package/dist/chunk-4CUGBNL2.cjs +0 -1
  71. package/dist/chunk-5GFXHUMP.js +0 -1
  72. package/dist/chunk-MUIREXKH.js +0 -3
  73. package/dist/chunk-PGEORVCG.js +0 -59
  74. package/dist/chunk-PUVSVHHB.cjs +0 -59
  75. package/dist/chunk-S36T7OK5.cjs +0 -258
  76. package/dist/chunk-YYBSUBRG.js +0 -258
  77. package/dist/selectionRects-7QU337P5.cjs +0 -1
  78. package/dist/selectionRects-V5RC2BYX.js +0 -1
@@ -1,4 +1,4 @@
1
- import {b as b$1,f as f$1}from'./chunk-CLDB6TL7.js';import {n}from'./chunk-3X3LTNK4.js';function H(e){return g(e).variables}function g(e){let t=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let r=$(e.package.document);r.forEach(o=>{t.push({name:o,location:"body"});}),n.body=Array.from(new Set(r)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((r,o)=>{r.properties.headerReferences&&r.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let r=D(e.package.footnotes);r.forEach(o=>{t.push({name:o,location:"footnote"});}),n.footnotes=Array.from(new Set(r)).sort();}if(e.package?.endnotes){let r=D(e.package.endnotes);r.forEach(o=>{t.push({name:o,location:"endnote"});}),n.endnotes=Array.from(new Set(r)).sort();}e.templateVariables&&e.templateVariables.forEach(r=>{t.some(o=>o.name===r)||t.push({name:r,location:"body"});});let a=new Set;return t.forEach(r=>a.add(r.name)),{variables:Array.from(a).sort(),totalOccurrences:t.length,byLocation:n,occurrences:t}}function $(e){let t=[];if(e.content&&t.push(...R(e.content)),e.sections)for(let n of e.sections)n.content&&t.push(...R(n.content));return t}function R(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(...b(n)):n.type==="table"&&t.push(...P(n));return t}function b(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="run"?t.push(...d(n)):n.type==="hyperlink"?t.push(...J(n)):n.type==="simpleField"?t.push(...L(n)):n.type==="complexField"&&t.push(...F(n));return t}function d(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="text"&&n.text&&t.push(...E(n.text));return t}function J(e){let t=[];if(!e.children)return t;for(let n of e.children)n.type==="run"&&t.push(...d(n));return t}function L(e){let t=[];if(e.instruction&&t.push(...E(e.instruction)),e.content)for(let n of e.content)n.type==="run"&&t.push(...d(n));return t}function F(e){let t=[];if(e.fieldCode)for(let n of e.fieldCode)n.type==="run"&&t.push(...d(n));if(e.fieldResult)for(let n of e.fieldResult)n.type==="run"&&t.push(...d(n));return t}function P(e){let t=[];if(!e.rows)return t;for(let n of e.rows)if(n.cells)for(let a of n.cells)t.push(...B(a));return t}function B(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="paragraph"?t.push(...b(n)):n.type==="table"&&t.push(...P(n));return t}function D(e){let t=[];for(let n of e)if(n.content)for(let a of n.content)t.push(...b(a));return t}var k=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,M=/\{(.+?)\}/g;function E(e){if(!e)return [];let t=[],n=new RegExp(k),a;for(;(a=n.exec(e))!==null;)t.push(a[1]);return t}function q(e){return k.test(e)}function U(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function X(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function G(e){return `{${e}}`}function K(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function Q(e,t){return e&&e.replace(M,(n,a)=>{let r=a.trim();return r in t?t[r]:n})}function Y(e,t=""){return e&&e.replace(M,t)}function ee(e){return H(e).length>0}function Z(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function h(e,t){let n=t,{position:a,variableName:r}=n,o=JSON.parse(JSON.stringify(e)),s=o.package.document.content.filter(u=>u.type==="paragraph");if(a.paragraphIndex>=s.length)throw new Error(`Paragraph index ${a.paragraphIndex} out of bounds`);let c=s[a.paragraphIndex],l=`{${r}}`;return S(c,a.offset,l),o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(r)||o.templateVariables.push(r),o}function y(e,t){let n=t,{range:a,variableName:r}=n,o=JSON.parse(JSON.stringify(e)),s=o.package.document.content.filter(u=>u.type==="paragraph");if(a.start.paragraphIndex!==a.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(a.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${a.start.paragraphIndex} out of bounds`);let c=s[a.start.paragraphIndex];z(c,a.start.offset,a.end.offset);let l=`{${r}}`;return S(c,a.start.offset,l),o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(r)||o.templateVariables.push(r),o}function S(e,t,n){let a=0,r=false;for(let o=0;o<e.content.length;o++){let i=e.content[o];if(i.type==="run"){let s=x(i),c=a,l=a+s.length;if(!r&&t>=c&&t<=l){let u=t-c,v=s.slice(0,u),V=s.slice(u),m=[];for(let p=0;p<o;p++)m.push(e.content[p]);v&&m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:v}]}),m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:n}]}),V&&m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:V}]});for(let p=o+1;p<e.content.length;p++)m.push(e.content[p]);e.content=m,r=true;break}a=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(a+=x(s).length);}r||e.content.push({type:"run",content:[{type:"text",text:n}]});}function z(e,t,n){let a=[],r=0;for(let o of e.content)if(o.type==="run"){let i=x(o),s=r,c=r+i.length;if(c<=t||s>=n)a.push(o);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>n&&(l+=i.slice(n-s)),l.length>0&&a.push({type:"run",formatting:o.formatting,content:[{type:"text",text:l}]});}r=c;}else a.push(o);e.content=a;}function x(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}var f={type:"string",description:"Document ID from a previous docx_load call"},j={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},_={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
1
+ import {b as b$1,f as f$1}from'./chunk-CLDB6TL7.js';import {n}from'./chunk-YP3CXYSU.js';function H(e){return g(e).variables}function g(e){let t=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let r=$(e.package.document);r.forEach(o=>{t.push({name:o,location:"body"});}),n.body=Array.from(new Set(r)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((r,o)=>{r.properties.headerReferences&&r.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let r=D(e.package.footnotes);r.forEach(o=>{t.push({name:o,location:"footnote"});}),n.footnotes=Array.from(new Set(r)).sort();}if(e.package?.endnotes){let r=D(e.package.endnotes);r.forEach(o=>{t.push({name:o,location:"endnote"});}),n.endnotes=Array.from(new Set(r)).sort();}e.templateVariables&&e.templateVariables.forEach(r=>{t.some(o=>o.name===r)||t.push({name:r,location:"body"});});let a=new Set;return t.forEach(r=>a.add(r.name)),{variables:Array.from(a).sort(),totalOccurrences:t.length,byLocation:n,occurrences:t}}function $(e){let t=[];if(e.content&&t.push(...R(e.content)),e.sections)for(let n of e.sections)n.content&&t.push(...R(n.content));return t}function R(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(...b(n)):n.type==="table"&&t.push(...P(n));return t}function b(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="run"?t.push(...d(n)):n.type==="hyperlink"?t.push(...J(n)):n.type==="simpleField"?t.push(...L(n)):n.type==="complexField"&&t.push(...F(n));return t}function d(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="text"&&n.text&&t.push(...E(n.text));return t}function J(e){let t=[];if(!e.children)return t;for(let n of e.children)n.type==="run"&&t.push(...d(n));return t}function L(e){let t=[];if(e.instruction&&t.push(...E(e.instruction)),e.content)for(let n of e.content)n.type==="run"&&t.push(...d(n));return t}function F(e){let t=[];if(e.fieldCode)for(let n of e.fieldCode)n.type==="run"&&t.push(...d(n));if(e.fieldResult)for(let n of e.fieldResult)n.type==="run"&&t.push(...d(n));return t}function P(e){let t=[];if(!e.rows)return t;for(let n of e.rows)if(n.cells)for(let a of n.cells)t.push(...B(a));return t}function B(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="paragraph"?t.push(...b(n)):n.type==="table"&&t.push(...P(n));return t}function D(e){let t=[];for(let n of e)if(n.content)for(let a of n.content)t.push(...b(a));return t}var k=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,M=/\{(.+?)\}/g;function E(e){if(!e)return [];let t=[],n=new RegExp(k),a;for(;(a=n.exec(e))!==null;)t.push(a[1]);return t}function q(e){return k.test(e)}function U(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function X(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function G(e){return `{${e}}`}function K(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function Q(e,t){return e&&e.replace(M,(n,a)=>{let r=a.trim();return r in t?t[r]:n})}function Y(e,t=""){return e&&e.replace(M,t)}function ee(e){return H(e).length>0}function Z(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function h(e,t){let n=t,{position:a,variableName:r}=n,o=JSON.parse(JSON.stringify(e)),s=o.package.document.content.filter(u=>u.type==="paragraph");if(a.paragraphIndex>=s.length)throw new Error(`Paragraph index ${a.paragraphIndex} out of bounds`);let c=s[a.paragraphIndex],l=`{${r}}`;return S(c,a.offset,l),o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(r)||o.templateVariables.push(r),o}function y(e,t){let n=t,{range:a,variableName:r}=n,o=JSON.parse(JSON.stringify(e)),s=o.package.document.content.filter(u=>u.type==="paragraph");if(a.start.paragraphIndex!==a.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(a.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${a.start.paragraphIndex} out of bounds`);let c=s[a.start.paragraphIndex];z(c,a.start.offset,a.end.offset);let l=`{${r}}`;return S(c,a.start.offset,l),o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(r)||o.templateVariables.push(r),o}function S(e,t,n){let a=0,r=false;for(let o=0;o<e.content.length;o++){let i=e.content[o];if(i.type==="run"){let s=x(i),c=a,l=a+s.length;if(!r&&t>=c&&t<=l){let u=t-c,v=s.slice(0,u),V=s.slice(u),m=[];for(let p=0;p<o;p++)m.push(e.content[p]);v&&m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:v}]}),m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:n}]}),V&&m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:V}]});for(let p=o+1;p<e.content.length;p++)m.push(e.content[p]);e.content=m,r=true;break}a=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(a+=x(s).length);}r||e.content.push({type:"run",content:[{type:"text",text:n}]});}function z(e,t,n){let a=[],r=0;for(let o of e.content)if(o.type==="run"){let i=x(o),s=r,c=r+i.length;if(c<=t||s>=n)a.push(o);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>n&&(l+=i.slice(n-s)),l.length>0&&a.push({type:"run",formatting:o.formatting,content:[{type:"text",text:l}]});}r=c;}else a.push(o);e.content=a;}function x(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}var f={type:"string",description:"Document ID from a previous docx_load call"},j={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},_={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
2
2
  Returns variable names without braces, along with their locations (body, headers, footers, etc.).
3
3
  Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,a=t.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let r=g(a.document);return {content:[{type:"text",text:JSON.stringify({variables:r.variables,count:r.variables.length,totalOccurrences:r.totalOccurrences,byLocation:r.byLocation},null,2)}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${r.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},A={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
4
4
  The variable can later be substituted with actual values using docx_apply_template.