@blocknote/xl-docx-exporter 0.30.0 → 0.30.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.
@@ -1,3 +1,3 @@
1
- "use strict";var A=Object.create;var b=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var O=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of B(t))!v.call(e,i)&&i!==n&&b(e,i,{get:()=>t[i],enumerable:!(r=D(t,i))||r.enumerable});return e};var h=(e,t,n)=>(n=e!=null?A(S(e)):{},O(t||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@blocknote/core"),o=require("docx");async function I(e){if(typeof window<"u"){const t=await createImageBitmap(e),{width:n,height:r}=t;return t.close(),{width:n,height:r}}else{const t=(await import("image-meta")).imageMeta,n=new Uint8Array(await e.arrayBuffer()),r=t(n);if(!r.width||!r.height)throw new Error("Image dimensions not found");return{width:r.width,height:r.height}}}const k=(e,t)=>{const r=new Array(e.headerRows??0).fill(!0),i=new Array(e.headerCols??0).fill(!0);return new o.Table({layout:"autofit",columnWidths:e.columnWidths.map(s=>(s??120)*.75*20),rows:e.rows.map((s,u)=>{const c=r[u];return new o.TableRow({tableHeader:c,children:s.cells.map((m,w)=>{var x;const y=(x=e.columnWidths)==null?void 0:x[w],a=p.mapTableCell(m),T=i[w];return new o.TableCell({width:y?{size:`${y*.75}pt`,type:"dxa"}:void 0,columnSpan:a.props.colspan,rowSpan:a.props.rowspan,shading:a.props.backgroundColor==="default"||!a.props.backgroundColor?void 0:{type:o.ShadingType.SOLID,color:t.options.colors[a.props.backgroundColor].background.slice(1)},children:[new o.Paragraph({children:t.transformInlineContent(a.content),alignment:!a.props.textAlignment||a.props.textAlignment==="left"?void 0:a.props.textAlignment==="center"?"center":a.props.textAlignment==="right"?"right":a.props.textAlignment==="justify"?"distribute":(()=>{throw new p.UnreachableCaseError(a.props.textAlignment)})(),run:{bold:c||T,color:a.props.textColor==="default"||!a.props.textColor?void 0:t.options.colors[a.props.textColor].text.slice(1)}})]})})})})})};function l(e,t){return{shading:e.backgroundColor==="default"||!e.backgroundColor?void 0:{type:o.ShadingType.SOLID,color:t[e.backgroundColor].background.slice(1)},run:e.textColor==="default"||!e.textColor?void 0:{color:t[e.textColor].text.slice(1)},alignment:!e.textAlignment||e.textAlignment==="left"?void 0:e.textAlignment==="center"?"center":e.textAlignment==="right"?"right":e.textAlignment==="justify"?"distribute":(()=>{throw new p.UnreachableCaseError(e.textAlignment)})()}}const P={paragraph:(e,t)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),style:"Normal",run:{font:"Inter"}}),numberedListItem:(e,t,n)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),numbering:{reference:"blocknote-numbered-list",level:n}}),bulletListItem:(e,t,n)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),numbering:{reference:"blocknote-bullet-list",level:n}}),checkListItem:(e,t)=>new o.Paragraph({...l(e.props,t.options.colors),children:[new o.CheckBox({checked:e.props.checked}),new o.TextRun({children:[" "]}),...t.transformInlineContent(e.content)]}),heading:(e,t)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),heading:`Heading${e.props.level}`}),quote:(e,t)=>new o.Paragraph({shading:{color:"#7D797A"},border:{left:{color:"#7D797A",space:100,style:"single",size:8}},...l(e.props,t.options.colors),children:t.transformInlineContent(e.content)}),audio:(e,t)=>[g(e.props,"Open audio",t),...f(e.props,t)],video:(e,t)=>[g(e.props,"Open video",t),...f(e.props,t)],file:(e,t)=>[g(e.props,"Open file",t),...f(e.props,t)],codeBlock:e=>{var n;const t=((n=e.content[0])==null?void 0:n.text)||"";return new o.Paragraph({style:"Codeblock",shading:{type:o.ShadingType.SOLID,fill:"161616",color:"161616"},children:[...t.split(`
2
- `).map((r,i)=>new o.TextRun({text:r,break:i>0?1:0}))]})},pageBreak:()=>new o.Paragraph({children:[new o.PageBreak]}),image:async(e,t)=>{const n=await t.resolveFile(e.props.url),{width:r,height:i}=await I(n);return[new o.Paragraph({...l(e.props,t.options.colors),children:[new o.ImageRun({data:await n.arrayBuffer(),type:"gif",altText:e.props.caption?{description:e.props.caption,name:e.props.caption,title:e.props.caption}:void 0,transformation:{width:e.props.previewWidth||r,height:(e.props.previewWidth||r)/r*i}})]}),...f(e.props,t)]},table:(e,t)=>k(e.content,t)};function g(e,t,n){return new o.Paragraph({...l(e,n.options.colors),children:[new o.ExternalHyperlink({children:[new o.TextRun({text:e.name||t,style:"Hyperlink"})],link:e.url})]})}function f(e,t){return e.caption?[new o.Paragraph({...l(e,t.options.colors),children:[new o.TextRun({text:e.caption})],style:"Caption"})]:[]}const F={link:(e,t)=>new o.ExternalHyperlink({children:e.content.map(n=>t.transformStyledText(n,!0)),link:e.href}),text:(e,t)=>t.transformStyledText(e)},R={bold:e=>e?{bold:e}:{},italic:e=>e?{italics:e}:{},underline:e=>e?{underline:{type:"single"}}:{},strike:e=>e?{strike:e}:{},backgroundColor:(e,t)=>e?{shading:{fill:t.options.colors[e].background.slice(1)}}:{},textColor:(e,t)=>e?{color:t.options.colors[e].text.slice(1)}:{},code:e=>e?{font:"GeistMono"}:{}},L={blockMapping:P,inlineContentMapping:F,styleMapping:R};async function M(e){return"https://corsproxy.api.blocknotejs.org/corsproxy/?url="+encodeURIComponent(e)}async function C(e){{const t=e.default;return await(await fetch(t)).arrayBuffer()}}const d=16*.75*1.5*20;class E extends p.Exporter{constructor(t,n,r){const s={...{colors:p.COLORS_DEFAULT,resolveFileUrl:M},...r};super(t,n,s),this.schema=t,this.mappings=n}transformStyledText(t,n){const r=this.mapStyles(t.styles),i=Object.assign({},...r);return new o.TextRun({...i,style:n?"Hyperlink":void 0,text:t.text})}async transformBlocks(t,n=0){const r=[];for(const i of t){let s=await this.transformBlocks(i.children,n+1);s=s.map((c,m)=>(c instanceof o.Paragraph&&!c.properties.numberingReferences.length&&c.addRunToFront(new o.TextRun({children:[new o.Tab]})),c));const u=await this.mapBlock(i,n,0);Array.isArray(u)?r.push(...u,...s):r.push(u,...s)}return r}async getFonts(){let t=await C(await Promise.resolve().then(()=>require("./Inter_18pt-Regular-CCMUw8TC.cjs"))),n=await C(await Promise.resolve().then(()=>require("./GeistMono-Regular--NrcstcO.cjs")));if(t instanceof ArrayBuffer||n instanceof Uint8Array){const r=(await import("buffer")).default.Buffer;t instanceof ArrayBuffer&&(t=r.from(t)),n instanceof ArrayBuffer&&(n=r.from(n))}return[{name:"Inter",data:t},{name:"GeistMono",data:n}]}async createDefaultDocumentOptions(){const t=(await Promise.resolve().then(()=>require("./styles-C7c5RlKz.cjs"))).default,n=["•"];return{numbering:{config:[{reference:"blocknote-numbered-list",levels:Array.from({length:9},(r,i)=>({start:1,level:i,format:o.LevelFormat.DECIMAL,text:`%${i+1}.`,alignment:o.AlignmentType.LEFT,style:{paragraph:{indent:{left:d*(i+1),hanging:d}}}}))},{reference:"blocknote-bullet-list",levels:Array.from({length:9},(r,i)=>({start:1,level:i,format:o.LevelFormat.BULLET,text:n[i%n.length],alignment:o.AlignmentType.LEFT,style:{paragraph:{indent:{left:d*(i+1),hanging:d}}}}))}]},fonts:await this.getFonts(),defaultTabStop:200,externalStyles:t}}async toBlob(t,n={sectionOptions:{},documentOptions:{}}){const r=await this.toDocxJsDocument(t,n),i=globalThis.Buffer;try{return globalThis.Buffer||(globalThis.Buffer=(await import("buffer")).default.Buffer),o.Packer.toBlob(r)}finally{globalThis.Buffer=i}}async toDocxJsDocument(t,n={sectionOptions:{},documentOptions:{}}){const r=new o.Document({...await this.createDefaultDocumentOptions(),...n.documentOptions,sections:[{children:await this.transformBlocks(t),...n.sectionOptions}]});return r.Document.Relationships.createRelationship(r.Document.Relationships.RelationshipCount+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable","fontTable.xml"),r}}exports.DOCXExporter=E;exports.docxDefaultSchemaMappings=L;
1
+ "use strict";var A=Object.create;var x=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var O=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of D(t))!S.call(e,i)&&i!==n&&x(e,i,{get:()=>t[i],enumerable:!(r=B(t,i))||r.enumerable});return e};var b=(e,t,n)=>(n=e!=null?A(v(e)):{},O(t||!e||!e.__esModule?x(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@blocknote/core"),o=require("docx");async function I(e){if(typeof window<"u"){const t=await createImageBitmap(e),{width:n,height:r}=t;return t.close(),{width:n,height:r}}else{const t=(await import("image-meta")).imageMeta,n=new Uint8Array(await e.arrayBuffer()),r=t(n);if(!r.width||!r.height)throw new Error("Image dimensions not found");return{width:r.width,height:r.height}}}const P=(e,t)=>{const r=new Array(e.headerRows??0).fill(!0),i=new Array(e.headerCols??0).fill(!0);return new o.Table({layout:"autofit",columnWidths:e.columnWidths.map(s=>(s??120)*.75*20),rows:e.rows.map((s,u)=>{const c=r[u];return new o.TableRow({tableHeader:c,children:s.cells.map((g,m)=>{var y;const w=(y=e.columnWidths)==null?void 0:y[m],a=p.mapTableCell(g),T=i[m];return new o.TableCell({width:w?{size:`${w*.75}pt`,type:"dxa"}:void 0,columnSpan:a.props.colspan,rowSpan:a.props.rowspan,shading:a.props.backgroundColor==="default"||!a.props.backgroundColor?void 0:{type:o.ShadingType.SOLID,color:t.options.colors[a.props.backgroundColor].background.slice(1)},children:[new o.Paragraph({children:t.transformInlineContent(a.content),alignment:!a.props.textAlignment||a.props.textAlignment==="left"?void 0:a.props.textAlignment==="center"?"center":a.props.textAlignment==="right"?"right":a.props.textAlignment==="justify"?"distribute":(()=>{throw new p.UnreachableCaseError(a.props.textAlignment)})(),run:{bold:c||T,color:a.props.textColor==="default"||!a.props.textColor?void 0:t.options.colors[a.props.textColor].text.slice(1)}})]})})})})})};function l(e,t){return{shading:e.backgroundColor==="default"||!e.backgroundColor?void 0:{type:o.ShadingType.SOLID,color:t[e.backgroundColor].background.slice(1)},run:e.textColor==="default"||!e.textColor?void 0:{color:t[e.textColor].text.slice(1)},alignment:!e.textAlignment||e.textAlignment==="left"?void 0:e.textAlignment==="center"?"center":e.textAlignment==="right"?"right":e.textAlignment==="justify"?"distribute":(()=>{throw new p.UnreachableCaseError(e.textAlignment)})()}}const k={paragraph:(e,t)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),style:"Normal",run:{font:"Inter"}}),numberedListItem:(e,t,n)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),numbering:{reference:"blocknote-numbered-list",level:n}}),bulletListItem:(e,t,n)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),numbering:{reference:"blocknote-bullet-list",level:n}}),checkListItem:(e,t)=>new o.Paragraph({...l(e.props,t.options.colors),children:[new o.CheckBox({checked:e.props.checked}),new o.TextRun({children:[" "]}),...t.transformInlineContent(e.content)]}),heading:(e,t)=>new o.Paragraph({...l(e.props,t.options.colors),children:t.transformInlineContent(e.content),heading:`Heading${e.props.level}`}),quote:(e,t)=>new o.Paragraph({shading:{color:"#7D797A"},border:{left:{color:"#7D797A",space:100,style:"single",size:8}},...l(e.props,t.options.colors),children:t.transformInlineContent(e.content)}),audio:(e,t)=>[h(e.props,"Open audio",t),...f(e.props,t)],video:(e,t)=>[h(e.props,"Open video",t),...f(e.props,t)],file:(e,t)=>[h(e.props,"Open file",t),...f(e.props,t)],codeBlock:e=>{var n;const t=((n=e.content[0])==null?void 0:n.text)||"";return new o.Paragraph({style:"Codeblock",shading:{type:o.ShadingType.SOLID,fill:"161616",color:"161616"},children:[...t.split(`
2
+ `).map((r,i)=>new o.TextRun({text:r,break:i>0?1:0}))]})},pageBreak:()=>new o.Paragraph({children:[new o.PageBreak]}),image:async(e,t)=>{const n=await t.resolveFile(e.props.url),{width:r,height:i}=await I(n);return[new o.Paragraph({...l(e.props,t.options.colors),children:[new o.ImageRun({data:await n.arrayBuffer(),type:"gif",altText:e.props.caption?{description:e.props.caption,name:e.props.caption,title:e.props.caption}:void 0,transformation:{width:e.props.previewWidth||r,height:(e.props.previewWidth||r)/r*i}})]}),...f(e.props,t)]},table:(e,t)=>P(e.content,t)};function h(e,t,n){return new o.Paragraph({...l(e,n.options.colors),children:[new o.ExternalHyperlink({children:[new o.TextRun({text:e.name||t,style:"Hyperlink"})],link:e.url})]})}function f(e,t){return e.caption?[new o.Paragraph({...l(e,t.options.colors),children:[new o.TextRun({text:e.caption})],style:"Caption"})]:[]}const F={link:(e,t)=>new o.ExternalHyperlink({children:e.content.map(n=>t.transformStyledText(n,!0)),link:e.href}),text:(e,t)=>t.transformStyledText(e)},R={bold:e=>e?{bold:e}:{},italic:e=>e?{italics:e}:{},underline:e=>e?{underline:{type:"single"}}:{},strike:e=>e?{strike:e}:{},backgroundColor:(e,t)=>e?{shading:{fill:t.options.colors[e].background.slice(1)}}:{},textColor:(e,t)=>e?{color:t.options.colors[e].text.slice(1)}:{},code:e=>e?{font:"GeistMono"}:{}},L={blockMapping:k,inlineContentMapping:F,styleMapping:R};async function M(e){return"https://corsproxy.api.blocknotejs.org/corsproxy/?url="+encodeURIComponent(e)}async function C(e){{const t=e.default;return await(await fetch(t)).arrayBuffer()}}const d=16*.75*1.5*20;class E extends p.Exporter{constructor(t,n,r){const s={...{colors:p.COLORS_DEFAULT,resolveFileUrl:M},...r};super(t,n,s),this.schema=t,this.mappings=n}transformStyledText(t,n){const r=this.mapStyles(t.styles),i=Object.assign({},...r);return new o.TextRun({...i,style:n?"Hyperlink":void 0,text:t.text})}async transformBlocks(t,n=0){const r=[];for(const i of t){let s=await this.transformBlocks(i.children,n+1);s=s.map((c,g)=>(c instanceof o.Paragraph&&!c.properties.numberingReferences.length&&c.addRunToFront(new o.TextRun({children:[new o.Tab]})),c));const u=await this.mapBlock(i,n,0);Array.isArray(u)?r.push(...u,...s):r.push(u,...s)}return r}async getFonts(){let t=await C(await Promise.resolve().then(()=>require("./Inter_18pt-Regular-CCMUw8TC.cjs"))),n=await C(await Promise.resolve().then(()=>require("./GeistMono-Regular--NrcstcO.cjs")));if(t instanceof ArrayBuffer||n instanceof ArrayBuffer){const r=(await Promise.resolve().then(()=>require("./index-B-FmPo2r.cjs")).then(i=>i.index)).Buffer;t instanceof ArrayBuffer&&(t=r.from(t)),n instanceof ArrayBuffer&&(n=r.from(n))}return[{name:"Inter",data:t},{name:"GeistMono",data:n}]}async createDefaultDocumentOptions(){const t=(await Promise.resolve().then(()=>require("./styles-C7c5RlKz.cjs"))).default,n=["•"];return{numbering:{config:[{reference:"blocknote-numbered-list",levels:Array.from({length:9},(r,i)=>({start:1,level:i,format:o.LevelFormat.DECIMAL,text:`%${i+1}.`,alignment:o.AlignmentType.LEFT,style:{paragraph:{indent:{left:d*(i+1),hanging:d}}}}))},{reference:"blocknote-bullet-list",levels:Array.from({length:9},(r,i)=>({start:1,level:i,format:o.LevelFormat.BULLET,text:n[i%n.length],alignment:o.AlignmentType.LEFT,style:{paragraph:{indent:{left:d*(i+1),hanging:d}}}}))}]},fonts:await this.getFonts(),defaultTabStop:200,externalStyles:t}}async toBlob(t,n={sectionOptions:{},documentOptions:{}}){const r=await this.toDocxJsDocument(t,n),i=globalThis.Buffer;try{return globalThis.Buffer||(globalThis.Buffer=(await import("buffer")).default.Buffer),o.Packer.toBlob(r)}finally{globalThis.Buffer=i}}async toDocxJsDocument(t,n={sectionOptions:{},documentOptions:{}}){const r=new o.Document({...await this.createDefaultDocumentOptions(),...n.documentOptions,sections:[{children:await this.transformBlocks(t),...n.sectionOptions}]});return r.Document.Relationships.createRelationship(r.Document.Relationships.RelationshipCount+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable","fontTable.xml"),r}}exports.DOCXExporter=E;exports.docxDefaultSchemaMappings=L;
3
3
  //# sourceMappingURL=blocknote-xl-docx-exporter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"blocknote-xl-docx-exporter.cjs","sources":["../../../shared/util/imageUtil.ts","../src/docx/util/Table.tsx","../src/docx/defaultSchema/blocks.ts","../src/docx/defaultSchema/inlinecontent.ts","../src/docx/defaultSchema/styles.ts","../src/docx/defaultSchema/index.ts","../../../shared/api/corsProxy.ts","../../../shared/util/fileUtil.ts","../src/docx/docxExporter.ts"],"sourcesContent":["export async function getImageDimensions(blob: Blob) {\n if (typeof window !== \"undefined\" && import.meta.env.NODE_ENV !== \"test\") {\n const bmp = await createImageBitmap(blob);\n const { width, height } = bmp;\n bmp.close(); // free memory\n return { width, height };\n } else {\n // node or vitest\n const imageMetaFunc = (await import(\"image-meta\")).imageMeta;\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const meta = imageMetaFunc(bytes);\n if (!meta.width || !meta.height) {\n throw new Error(\"Image dimensions not found\");\n }\n return { width: meta.width, height: meta.height };\n }\n}\n","import {\n Exporter,\n InlineContentSchema,\n mapTableCell,\n TableContent,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport {\n Table as DocxTable,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TableCell,\n TableRow,\n} from \"docx\";\n\nexport const Table = (\n data: TableContent<InlineContentSchema>,\n t: Exporter<any, any, any, any, ParagraphChild, any, any>\n) => {\n const DEFAULT_COLUMN_WIDTH = 120;\n\n // If headerRows is 1, then the first row is a header row\n const headerRows = new Array(data.headerRows ?? 0).fill(true);\n // If headerCols is 1, then the first column is a header column\n const headerCols = new Array(data.headerCols ?? 0).fill(true);\n\n return new DocxTable({\n layout: \"autofit\",\n columnWidths: data.columnWidths.map(\n (w) =>\n (w ?? DEFAULT_COLUMN_WIDTH) * /* to points */ 0.75 * /* to twips */ 20\n ),\n rows: data.rows.map((row, rowIndex) => {\n const isHeaderRow = headerRows[rowIndex];\n return new TableRow({\n tableHeader: isHeaderRow,\n children: row.cells.map((c, colIndex) => {\n const width = data.columnWidths?.[colIndex];\n const cell = mapTableCell(c);\n const isHeaderColumn = headerCols[colIndex];\n\n return new TableCell({\n width: width\n ? {\n size: `${width * 0.75}pt`,\n type: \"dxa\",\n }\n : undefined,\n columnSpan: cell.props.colspan,\n rowSpan: cell.props.rowspan,\n shading:\n cell.props.backgroundColor === \"default\" ||\n !cell.props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n t.options.colors[\n cell.props\n .backgroundColor as keyof typeof t.options.colors\n ].background.slice(1),\n },\n children: [\n new Paragraph({\n children: t.transformInlineContent(cell.content),\n\n alignment:\n !cell.props.textAlignment ||\n cell.props.textAlignment === \"left\"\n ? undefined\n : cell.props.textAlignment === \"center\"\n ? \"center\"\n : cell.props.textAlignment === \"right\"\n ? \"right\"\n : cell.props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(\n cell.props.textAlignment\n );\n })(),\n run: {\n // TODO add support for table headers exporting, bolding seems to not be working at the moment\n bold: isHeaderRow || isHeaderColumn,\n // TODO table paragraph color seems to not be working at the moment\n // Probably because the runs are setting their own color\n color:\n cell.props.textColor === \"default\" || !cell.props.textColor\n ? undefined\n : t.options.colors[\n cell.props.textColor as keyof typeof t.options.colors\n ].text.slice(1),\n },\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n","import {\n BlockMapping,\n COLORS_DEFAULT,\n DefaultBlockSchema,\n DefaultProps,\n pageBreakSchema,\n StyledText,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport { getImageDimensions } from \"@shared/util/imageUtil.js\";\nimport {\n CheckBox,\n Table as DocxTable,\n ExternalHyperlink,\n ImageRun,\n IParagraphOptions,\n PageBreak,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\n\nfunction blockPropsToStyles(\n props: Partial<DefaultProps>,\n colors: typeof COLORS_DEFAULT\n): IParagraphOptions {\n return {\n shading:\n props.backgroundColor === \"default\" || !props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n colors[\n props.backgroundColor as keyof typeof colors\n ].background.slice(1),\n },\n run:\n props.textColor === \"default\" || !props.textColor\n ? undefined\n : {\n color: colors[props.textColor as keyof typeof colors].text.slice(1),\n },\n alignment:\n !props.textAlignment || props.textAlignment === \"left\"\n ? undefined\n : props.textAlignment === \"center\"\n ? \"center\"\n : props.textAlignment === \"right\"\n ? \"right\"\n : props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(props.textAlignment);\n })(),\n };\n}\nexport const docxBlockMappingForDefaultSchema: BlockMapping<\n DefaultBlockSchema & typeof pageBreakSchema.blockSchema,\n any,\n any,\n | Promise<Paragraph[] | Paragraph | DocxTable>\n | Paragraph[]\n | Paragraph\n | DocxTable,\n ParagraphChild\n> = {\n paragraph: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n style: \"Normal\",\n run: {\n font: \"Inter\",\n },\n });\n },\n numberedListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-numbered-list\",\n level: nestingLevel,\n },\n });\n },\n bulletListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-bullet-list\",\n level: nestingLevel,\n },\n });\n },\n checkListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new CheckBox({ checked: block.props.checked }),\n new TextRun({\n children: [\" \"],\n }),\n ...exporter.transformInlineContent(block.content),\n ],\n });\n },\n heading: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n heading: `Heading${block.props.level}`,\n });\n },\n quote: (block, exporter) => {\n return new Paragraph({\n shading: {\n color: \"#7D797A\",\n },\n border: {\n left: {\n color: \"#7D797A\",\n space: 100,\n style: \"single\",\n size: 8,\n },\n },\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n });\n },\n audio: (block, exporter) => {\n return [\n file(block.props, \"Open audio\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n video: (block, exporter) => {\n return [\n file(block.props, \"Open video\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n file: (block, exporter) => {\n return [\n file(block.props, \"Open file\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n codeBlock: (block) => {\n const textContent = (block.content as StyledText<any>[])[0]?.text || \"\";\n\n return new Paragraph({\n style: \"Codeblock\",\n shading: {\n type: ShadingType.SOLID,\n fill: \"161616\",\n color: \"161616\",\n },\n children: [\n ...textContent.split(\"\\n\").map((line, index) => {\n return new TextRun({\n text: line,\n break: index > 0 ? 1 : 0,\n });\n }),\n ],\n });\n },\n pageBreak: () => {\n return new Paragraph({\n children: [new PageBreak()],\n });\n },\n image: async (block, exporter) => {\n const blob = await exporter.resolveFile(block.props.url);\n const { width, height } = await getImageDimensions(blob);\n\n return [\n new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new ImageRun({\n data: await blob.arrayBuffer(),\n // it would be nicer to set the actual data type here, but then we'd need to use a mime type / image type\n // detector. atm passing gif does not seem to be causing issues as the \"type\" is mainly used by docxjs internally\n // (i.e.: to make sure it's not svg)\n type: \"gif\",\n altText: block.props.caption\n ? {\n description: block.props.caption,\n name: block.props.caption,\n title: block.props.caption,\n }\n : undefined,\n transformation: {\n width: block.props.previewWidth || width,\n height: ((block.props.previewWidth || width) / width) * height,\n },\n }),\n ],\n }),\n ...caption(block.props, exporter),\n ];\n },\n table: (block, exporter) => {\n return Table(block.content, exporter);\n },\n};\n\nfunction file(\n props: Partial<DefaultProps & { name: string; url: string }>,\n defaultText: string,\n exporter: any\n) {\n return new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new ExternalHyperlink({\n children: [\n new TextRun({\n text: props.name || defaultText,\n style: \"Hyperlink\",\n }),\n ],\n link: props.url!,\n }),\n ],\n });\n}\n\nfunction caption(\n props: Partial<DefaultProps & { caption: string }>,\n exporter: any\n) {\n if (!props.caption) {\n return [];\n }\n return [\n new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new TextRun({\n text: props.caption,\n }),\n ],\n style: \"Caption\",\n }),\n ];\n}\n","import {\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n InlineContentMapping,\n} from \"@blocknote/core\";\nimport { ExternalHyperlink, ParagraphChild, TextRun } from \"docx\";\nimport type { DOCXExporter } from \"../docxExporter.js\";\n\nexport const docxInlineContentMappingForDefaultSchema: InlineContentMapping<\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n ParagraphChild,\n TextRun\n> = {\n link: (ic, exporter) => {\n return new ExternalHyperlink({\n children: ic.content.map((content) => {\n return (exporter as DOCXExporter<any, any, any>).transformStyledText(\n content,\n true\n );\n }),\n link: ic.href,\n });\n },\n text: (ic, t) => {\n return t.transformStyledText(ic);\n },\n};\n","import { DefaultStyleSchema, StyleMapping } from \"@blocknote/core\";\nimport { IRunPropertiesOptions } from \"docx\";\n\nexport const docxStyleMappingForDefaultSchema: StyleMapping<\n DefaultStyleSchema,\n IRunPropertiesOptions\n> = {\n bold: (val) => {\n if (!val) {\n return {};\n }\n return {\n bold: val,\n };\n },\n italic: (val) => {\n if (!val) {\n return {};\n }\n return {\n italics: val,\n };\n },\n underline: (val) => {\n if (!val) {\n return {};\n }\n return {\n underline: {\n type: \"single\",\n },\n };\n },\n strike: (val) => {\n if (!val) {\n return {};\n }\n return {\n strike: val,\n };\n },\n backgroundColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n shading: {\n fill: exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].background.slice(1),\n },\n };\n },\n textColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n color:\n exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].text.slice(1),\n };\n },\n code: (val) => {\n if (!val) {\n return {};\n }\n return {\n font: \"GeistMono\",\n };\n },\n};\n","import { docxBlockMappingForDefaultSchema } from \"./blocks.js\";\nimport { docxInlineContentMappingForDefaultSchema } from \"./inlinecontent.js\";\nimport { docxStyleMappingForDefaultSchema } from \"./styles.js\";\n\nexport const docxDefaultSchemaMappings = {\n blockMapping: docxBlockMappingForDefaultSchema,\n inlineContentMapping: docxInlineContentMappingForDefaultSchema,\n styleMapping: docxStyleMappingForDefaultSchema,\n};\n","export async function corsProxyResolveFileUrl(url: string) {\n return (\n \"https://corsproxy.api.blocknotejs.org/corsproxy/?url=\" +\n encodeURIComponent(url)\n );\n}\n","/**\n *\n * Helper functions so that we can import files both on vitest, browser and node\n * TODO: should find a way to test automatically in all environments\n */\n\nexport async function loadFileDataUrl(\n requireUrl: { default: string },\n mimeType: string\n) {\n if (import.meta.env.NODE_ENV === \"test\") {\n const buffer = await loadFileBuffer(requireUrl);\n const fileBase64 = buffer.toString(\"base64\");\n\n const dataUrl = `data:${mimeType};base64,${fileBase64}`;\n return dataUrl;\n } else {\n // in browser, this is already a data url\n return requireUrl.default as string;\n }\n}\n\nexport async function loadFontDataUrl(requireUrl: { default: string }) {\n return loadFileDataUrl(requireUrl, \"font/ttf\");\n}\n\nexport async function loadFileBuffer(requireUrl: {\n default: string;\n}): Promise<Buffer | ArrayBuffer> {\n if (import.meta.env.NODE_ENV === \"test\") {\n // in vitest, this is the url we need to load with readfilesync\n // eslint-disable-next-line\n const fs = require(\"fs\");\n let url = requireUrl.default;\n\n if (url.startsWith(\"/@fs/\")) {\n url = url.substring(\"/@fs\".length);\n }\n const buffer = fs.readFileSync(url);\n return buffer;\n } else {\n // in browser, this is already a data url\n const dataUrl = requireUrl.default as string;\n // convert to buffer on browser\n const response = await fetch(dataUrl);\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n}\n\n/**\n * usage:\n * \n * await loadFontDataUrl(\n await import(\"../fonts/inter/Inter_18pt-Italic.ttf\")\n );\n */\n","import {\n Block,\n BlockNoteSchema,\n BlockSchema,\n COLORS_DEFAULT,\n InlineContentSchema,\n StyleSchema,\n StyledText,\n} from \"@blocknote/core\";\nimport {\n AlignmentType,\n Document,\n IRunPropertiesOptions,\n ISectionOptions,\n LevelFormat,\n Packer,\n Paragraph,\n ParagraphChild,\n Tab,\n Table,\n TextRun,\n} from \"docx\";\n\nimport { Exporter, ExporterOptions } from \"@blocknote/core\";\nimport { corsProxyResolveFileUrl } from \"@shared/api/corsProxy.js\";\nimport { loadFileBuffer } from \"@shared/util/fileUtil.js\";\n\n// get constructor arg type from Document\ntype DocumentOptions = Partial<ConstructorParameters<typeof Document>[0]>;\n\nconst DEFAULT_TAB_STOP =\n /* default font size */ 16 *\n /* 1 pixel is 0.75 points */ 0.75 *\n /* 1.5em*/ 1.5 *\n /* 1 point is 20 twips */ 20;\n\n/**\n * Exports a BlockNote document to a .docx file using the docxjs library.\n */\nexport class DOCXExporter<\n B extends BlockSchema,\n S extends StyleSchema,\n I extends InlineContentSchema\n> extends Exporter<\n B,\n I,\n S,\n Promise<Paragraph[] | Paragraph | Table> | Paragraph[] | Paragraph | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n> {\n public constructor(\n /**\n * The schema of your editor. The mappings are automatically typed checked against this schema.\n */\n protected readonly schema: BlockNoteSchema<B, I, S>,\n /**\n * The mappings that map the BlockNote schema to the docxjs content.\n * Pass {@link docxDefaultSchemaMappings} for the default schema.\n */\n protected readonly mappings: Exporter<\n NoInfer<B>,\n NoInfer<I>,\n NoInfer<S>,\n | Promise<Paragraph[] | Paragraph | Table>\n | Paragraph[]\n | Paragraph\n | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n >[\"mappings\"],\n options?: Partial<ExporterOptions>\n ) {\n const defaults = {\n colors: COLORS_DEFAULT,\n resolveFileUrl: corsProxyResolveFileUrl,\n } satisfies Partial<ExporterOptions>;\n\n const newOptions = {\n ...defaults,\n ...options,\n };\n super(schema, mappings, newOptions);\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public transformStyledText(styledText: StyledText<S>, hyperlink?: boolean) {\n const stylesArray = this.mapStyles(styledText.styles);\n\n const styles: IRunPropertiesOptions = Object.assign(\n {} as IRunPropertiesOptions,\n ...stylesArray\n );\n\n return new TextRun({\n ...styles,\n style: hyperlink ? \"Hyperlink\" : undefined,\n text: styledText.text,\n });\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public async transformBlocks(\n blocks: Block<B, I, S>[],\n nestingLevel = 0\n ): Promise<Array<Paragraph | Table>> {\n const ret: Array<Paragraph | Table> = [];\n\n for (const b of blocks) {\n let children = await this.transformBlocks(b.children, nestingLevel + 1);\n children = children.map((c, _i) => {\n // NOTE: nested tables not supported (we can't insert the new Tab before a table)\n if (\n c instanceof Paragraph &&\n !(c as any).properties.numberingReferences.length\n ) {\n c.addRunToFront(\n new TextRun({\n children: [new Tab()],\n })\n );\n }\n return c;\n });\n const self = await this.mapBlock(b as any, nestingLevel, 0 /*unused*/); // TODO: any\n if (Array.isArray(self)) {\n ret.push(...self, ...children);\n } else {\n ret.push(self, ...children);\n }\n }\n return ret;\n }\n\n protected async getFonts(): Promise<DocumentOptions[\"fonts\"]> {\n // Unfortunately, loading the variable font doesn't work\n // \"./src/fonts/Inter-VariableFont_opsz,wght.ttf\",\n\n let interFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Regular.ttf\")\n );\n let geistMonoFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/GeistMono-Regular.ttf\")\n );\n\n if (\n interFont instanceof ArrayBuffer ||\n geistMonoFont instanceof Uint8Array\n ) {\n // conversion with Polyfill needed because docxjs requires Buffer\n const Buffer = (await import(\"buffer\")).default.Buffer;\n\n if (interFont instanceof ArrayBuffer) {\n interFont = Buffer.from(interFont);\n }\n if (geistMonoFont instanceof ArrayBuffer) {\n geistMonoFont = Buffer.from(geistMonoFont);\n }\n }\n\n return [\n { name: \"Inter\", data: interFont as Buffer },\n {\n name: \"GeistMono\",\n data: geistMonoFont as Buffer,\n },\n ];\n }\n\n protected async createDefaultDocumentOptions(): Promise<DocumentOptions> {\n const externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n const bullets = [\"•\"]; //, \"◦\", \"▪\"]; (these don't look great, just use solid bullet for now)\n return {\n numbering: {\n config: [\n {\n reference: \"blocknote-numbered-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.DECIMAL,\n text: `%${i + 1}.`,\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n {\n reference: \"blocknote-bullet-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.BULLET,\n text: bullets[i % bullets.length],\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n ],\n },\n fonts: await this.getFonts(),\n defaultTabStop: 200,\n externalStyles,\n };\n }\n\n /**\n * Convert a document (array of Blocks to a Blob representing a .docx file)\n */\n public async toBlob(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n }\n ) {\n const doc = await this.toDocxJsDocument(blocks, options);\n type GlobalThis = typeof globalThis & { Buffer?: any };\n const prevBuffer = (globalThis as GlobalThis).Buffer;\n try {\n if (!(globalThis as GlobalThis).Buffer) {\n // load Buffer polyfill because docxjs requires this\n (globalThis as GlobalThis).Buffer = (\n await import(\"buffer\")\n ).default.Buffer;\n }\n return Packer.toBlob(doc);\n } finally {\n (globalThis as GlobalThis).Buffer = prevBuffer;\n }\n }\n\n /**\n * Convert a document (array of Blocks to a docxjs Document)\n */\n public async toDocxJsDocument(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n }\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions()),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\n });\n\n // fix https://github.com/dolanmiu/docx/pull/2800/files\n doc.Document.Relationships.createRelationship(\n doc.Document.Relationships.RelationshipCount + 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\",\n \"fontTable.xml\"\n );\n\n return doc;\n }\n}\n"],"names":["getImageDimensions","blob","bmp","width","height","imageMetaFunc","bytes","meta","Table","data","headerRows","headerCols","DocxTable","w","row","rowIndex","isHeaderRow","TableRow","c","colIndex","_a","cell","mapTableCell","isHeaderColumn","TableCell","ShadingType","Paragraph","UnreachableCaseError","blockPropsToStyles","props","colors","docxBlockMappingForDefaultSchema","block","exporter","nestingLevel","CheckBox","TextRun","file","caption","textContent","line","index","PageBreak","ImageRun","defaultText","ExternalHyperlink","docxInlineContentMappingForDefaultSchema","ic","content","docxStyleMappingForDefaultSchema","val","docxDefaultSchemaMappings","corsProxyResolveFileUrl","url","loadFileBuffer","requireUrl","dataUrl","DEFAULT_TAB_STOP","DOCXExporter","Exporter","schema","mappings","options","newOptions","COLORS_DEFAULT","styledText","hyperlink","stylesArray","styles","blocks","ret","b","children","_i","Tab","self","interFont","geistMonoFont","Buffer","externalStyles","bullets","_","LevelFormat","AlignmentType","doc","prevBuffer","Packer","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c,mBACzBA,EAAI,SAAS,cAAc,kBAAoB,EAC/C,gFACA,eACF,EAEOA,CAAA,CAEX"}
1
+ {"version":3,"file":"blocknote-xl-docx-exporter.cjs","sources":["../../../shared/util/imageUtil.ts","../src/docx/util/Table.tsx","../src/docx/defaultSchema/blocks.ts","../src/docx/defaultSchema/inlinecontent.ts","../src/docx/defaultSchema/styles.ts","../src/docx/defaultSchema/index.ts","../../../shared/api/corsProxy.ts","../../../shared/util/fileUtil.ts","../src/docx/docxExporter.ts"],"sourcesContent":["export async function getImageDimensions(blob: Blob) {\n if (typeof window !== \"undefined\" && import.meta.env.NODE_ENV !== \"test\") {\n const bmp = await createImageBitmap(blob);\n const { width, height } = bmp;\n bmp.close(); // free memory\n return { width, height };\n } else {\n // node or vitest\n const imageMetaFunc = (await import(\"image-meta\")).imageMeta;\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const meta = imageMetaFunc(bytes);\n if (!meta.width || !meta.height) {\n throw new Error(\"Image dimensions not found\");\n }\n return { width: meta.width, height: meta.height };\n }\n}\n","import {\n Exporter,\n InlineContentSchema,\n mapTableCell,\n TableContent,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport {\n Table as DocxTable,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TableCell,\n TableRow,\n} from \"docx\";\n\nexport const Table = (\n data: TableContent<InlineContentSchema>,\n t: Exporter<any, any, any, any, ParagraphChild, any, any>,\n) => {\n const DEFAULT_COLUMN_WIDTH = 120;\n\n // If headerRows is 1, then the first row is a header row\n const headerRows = new Array(data.headerRows ?? 0).fill(true);\n // If headerCols is 1, then the first column is a header column\n const headerCols = new Array(data.headerCols ?? 0).fill(true);\n\n return new DocxTable({\n layout: \"autofit\",\n columnWidths: data.columnWidths.map(\n (w) =>\n (w ?? DEFAULT_COLUMN_WIDTH) * /* to points */ 0.75 * /* to twips */ 20,\n ),\n rows: data.rows.map((row, rowIndex) => {\n const isHeaderRow = headerRows[rowIndex];\n return new TableRow({\n tableHeader: isHeaderRow,\n children: row.cells.map((c, colIndex) => {\n const width = data.columnWidths?.[colIndex];\n const cell = mapTableCell(c);\n const isHeaderColumn = headerCols[colIndex];\n\n return new TableCell({\n width: width\n ? {\n size: `${width * 0.75}pt`,\n type: \"dxa\",\n }\n : undefined,\n columnSpan: cell.props.colspan,\n rowSpan: cell.props.rowspan,\n shading:\n cell.props.backgroundColor === \"default\" ||\n !cell.props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n t.options.colors[\n cell.props\n .backgroundColor as keyof typeof t.options.colors\n ].background.slice(1),\n },\n children: [\n new Paragraph({\n children: t.transformInlineContent(cell.content),\n\n alignment:\n !cell.props.textAlignment ||\n cell.props.textAlignment === \"left\"\n ? undefined\n : cell.props.textAlignment === \"center\"\n ? \"center\"\n : cell.props.textAlignment === \"right\"\n ? \"right\"\n : cell.props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(\n cell.props.textAlignment,\n );\n })(),\n run: {\n // TODO add support for table headers exporting, bolding seems to not be working at the moment\n bold: isHeaderRow || isHeaderColumn,\n // TODO table paragraph color seems to not be working at the moment\n // Probably because the runs are setting their own color\n color:\n cell.props.textColor === \"default\" || !cell.props.textColor\n ? undefined\n : t.options.colors[\n cell.props.textColor as keyof typeof t.options.colors\n ].text.slice(1),\n },\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n","import {\n BlockMapping,\n COLORS_DEFAULT,\n DefaultBlockSchema,\n DefaultProps,\n pageBreakSchema,\n StyledText,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport { getImageDimensions } from \"@shared/util/imageUtil.js\";\nimport {\n CheckBox,\n Table as DocxTable,\n ExternalHyperlink,\n ImageRun,\n IParagraphOptions,\n PageBreak,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\n\nfunction blockPropsToStyles(\n props: Partial<DefaultProps>,\n colors: typeof COLORS_DEFAULT,\n): IParagraphOptions {\n return {\n shading:\n props.backgroundColor === \"default\" || !props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n colors[\n props.backgroundColor as keyof typeof colors\n ].background.slice(1),\n },\n run:\n props.textColor === \"default\" || !props.textColor\n ? undefined\n : {\n color: colors[props.textColor as keyof typeof colors].text.slice(1),\n },\n alignment:\n !props.textAlignment || props.textAlignment === \"left\"\n ? undefined\n : props.textAlignment === \"center\"\n ? \"center\"\n : props.textAlignment === \"right\"\n ? \"right\"\n : props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(props.textAlignment);\n })(),\n };\n}\nexport const docxBlockMappingForDefaultSchema: BlockMapping<\n DefaultBlockSchema & typeof pageBreakSchema.blockSchema,\n any,\n any,\n | Promise<Paragraph[] | Paragraph | DocxTable>\n | Paragraph[]\n | Paragraph\n | DocxTable,\n ParagraphChild\n> = {\n paragraph: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n style: \"Normal\",\n run: {\n font: \"Inter\",\n },\n });\n },\n numberedListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-numbered-list\",\n level: nestingLevel,\n },\n });\n },\n bulletListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-bullet-list\",\n level: nestingLevel,\n },\n });\n },\n checkListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new CheckBox({ checked: block.props.checked }),\n new TextRun({\n children: [\" \"],\n }),\n ...exporter.transformInlineContent(block.content),\n ],\n });\n },\n heading: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n heading: `Heading${block.props.level}`,\n });\n },\n quote: (block, exporter) => {\n return new Paragraph({\n shading: {\n color: \"#7D797A\",\n },\n border: {\n left: {\n color: \"#7D797A\",\n space: 100,\n style: \"single\",\n size: 8,\n },\n },\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n });\n },\n audio: (block, exporter) => {\n return [\n file(block.props, \"Open audio\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n video: (block, exporter) => {\n return [\n file(block.props, \"Open video\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n file: (block, exporter) => {\n return [\n file(block.props, \"Open file\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n codeBlock: (block) => {\n const textContent = (block.content as StyledText<any>[])[0]?.text || \"\";\n\n return new Paragraph({\n style: \"Codeblock\",\n shading: {\n type: ShadingType.SOLID,\n fill: \"161616\",\n color: \"161616\",\n },\n children: [\n ...textContent.split(\"\\n\").map((line, index) => {\n return new TextRun({\n text: line,\n break: index > 0 ? 1 : 0,\n });\n }),\n ],\n });\n },\n pageBreak: () => {\n return new Paragraph({\n children: [new PageBreak()],\n });\n },\n image: async (block, exporter) => {\n const blob = await exporter.resolveFile(block.props.url);\n const { width, height } = await getImageDimensions(blob);\n\n return [\n new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new ImageRun({\n data: await blob.arrayBuffer(),\n // it would be nicer to set the actual data type here, but then we'd need to use a mime type / image type\n // detector. atm passing gif does not seem to be causing issues as the \"type\" is mainly used by docxjs internally\n // (i.e.: to make sure it's not svg)\n type: \"gif\",\n altText: block.props.caption\n ? {\n description: block.props.caption,\n name: block.props.caption,\n title: block.props.caption,\n }\n : undefined,\n transformation: {\n width: block.props.previewWidth || width,\n height: ((block.props.previewWidth || width) / width) * height,\n },\n }),\n ],\n }),\n ...caption(block.props, exporter),\n ];\n },\n table: (block, exporter) => {\n return Table(block.content, exporter);\n },\n};\n\nfunction file(\n props: Partial<DefaultProps & { name: string; url: string }>,\n defaultText: string,\n exporter: any,\n) {\n return new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new ExternalHyperlink({\n children: [\n new TextRun({\n text: props.name || defaultText,\n style: \"Hyperlink\",\n }),\n ],\n link: props.url!,\n }),\n ],\n });\n}\n\nfunction caption(\n props: Partial<DefaultProps & { caption: string }>,\n exporter: any,\n) {\n if (!props.caption) {\n return [];\n }\n return [\n new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new TextRun({\n text: props.caption,\n }),\n ],\n style: \"Caption\",\n }),\n ];\n}\n","import {\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n InlineContentMapping,\n} from \"@blocknote/core\";\nimport { ExternalHyperlink, ParagraphChild, TextRun } from \"docx\";\nimport type { DOCXExporter } from \"../docxExporter.js\";\n\nexport const docxInlineContentMappingForDefaultSchema: InlineContentMapping<\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n ParagraphChild,\n TextRun\n> = {\n link: (ic, exporter) => {\n return new ExternalHyperlink({\n children: ic.content.map((content) => {\n return (exporter as DOCXExporter<any, any, any>).transformStyledText(\n content,\n true,\n );\n }),\n link: ic.href,\n });\n },\n text: (ic, t) => {\n return t.transformStyledText(ic);\n },\n};\n","import { DefaultStyleSchema, StyleMapping } from \"@blocknote/core\";\nimport { IRunPropertiesOptions } from \"docx\";\n\nexport const docxStyleMappingForDefaultSchema: StyleMapping<\n DefaultStyleSchema,\n IRunPropertiesOptions\n> = {\n bold: (val) => {\n if (!val) {\n return {};\n }\n return {\n bold: val,\n };\n },\n italic: (val) => {\n if (!val) {\n return {};\n }\n return {\n italics: val,\n };\n },\n underline: (val) => {\n if (!val) {\n return {};\n }\n return {\n underline: {\n type: \"single\",\n },\n };\n },\n strike: (val) => {\n if (!val) {\n return {};\n }\n return {\n strike: val,\n };\n },\n backgroundColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n shading: {\n fill: exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].background.slice(1),\n },\n };\n },\n textColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n color:\n exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].text.slice(1),\n };\n },\n code: (val) => {\n if (!val) {\n return {};\n }\n return {\n font: \"GeistMono\",\n };\n },\n};\n","import { docxBlockMappingForDefaultSchema } from \"./blocks.js\";\nimport { docxInlineContentMappingForDefaultSchema } from \"./inlinecontent.js\";\nimport { docxStyleMappingForDefaultSchema } from \"./styles.js\";\n\nexport const docxDefaultSchemaMappings = {\n blockMapping: docxBlockMappingForDefaultSchema,\n inlineContentMapping: docxInlineContentMappingForDefaultSchema,\n styleMapping: docxStyleMappingForDefaultSchema,\n};\n","export async function corsProxyResolveFileUrl(url: string) {\n return (\n \"https://corsproxy.api.blocknotejs.org/corsproxy/?url=\" +\n encodeURIComponent(url)\n );\n}\n","/**\n *\n * Helper functions so that we can import files both on vitest, browser and node\n * TODO: should find a way to test automatically in all environments\n */\n\nexport async function loadFileDataUrl(\n requireUrl: { default: string },\n mimeType: string,\n) {\n if (import.meta.env.NODE_ENV === \"test\") {\n const buffer = await loadFileBuffer(requireUrl);\n const fileBase64 = buffer.toString(\"base64\");\n\n const dataUrl = `data:${mimeType};base64,${fileBase64}`;\n return dataUrl;\n } else {\n // in browser, this is already a data url\n return requireUrl.default as string;\n }\n}\n\nexport async function loadFontDataUrl(requireUrl: { default: string }) {\n return loadFileDataUrl(requireUrl, \"font/ttf\");\n}\n\nexport async function loadFileBuffer(requireUrl: {\n default: string;\n}): Promise<Buffer | ArrayBuffer> {\n if (import.meta.env.NODE_ENV === \"test\") {\n // in vitest, this is the url we need to load with readfilesync\n // eslint-disable-next-line\n const fs = require(\"fs\");\n let url = requireUrl.default;\n\n if (url.startsWith(\"/@fs/\")) {\n url = url.substring(\"/@fs\".length);\n }\n const buffer = fs.readFileSync(url);\n return buffer;\n } else {\n // in browser, this is already a data url\n const dataUrl = requireUrl.default as string;\n // convert to buffer on browser\n const response = await fetch(dataUrl);\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n}\n\n/**\n * usage:\n * \n * await loadFontDataUrl(\n await import(\"../fonts/inter/Inter_18pt-Italic.ttf\")\n );\n */\n","import {\n Block,\n BlockNoteSchema,\n BlockSchema,\n COLORS_DEFAULT,\n InlineContentSchema,\n StyleSchema,\n StyledText,\n} from \"@blocknote/core\";\nimport {\n AlignmentType,\n Document,\n IRunPropertiesOptions,\n ISectionOptions,\n LevelFormat,\n Packer,\n Paragraph,\n ParagraphChild,\n Tab,\n Table,\n TextRun,\n} from \"docx\";\n\nimport { Exporter, ExporterOptions } from \"@blocknote/core\";\nimport { corsProxyResolveFileUrl } from \"@shared/api/corsProxy.js\";\nimport { loadFileBuffer } from \"@shared/util/fileUtil.js\";\n\n// get constructor arg type from Document\ntype DocumentOptions = Partial<ConstructorParameters<typeof Document>[0]>;\n\nconst DEFAULT_TAB_STOP =\n /* default font size */ 16 *\n /* 1 pixel is 0.75 points */ 0.75 *\n /* 1.5em*/ 1.5 *\n /* 1 point is 20 twips */ 20;\n\n/**\n * Exports a BlockNote document to a .docx file using the docxjs library.\n */\nexport class DOCXExporter<\n B extends BlockSchema,\n S extends StyleSchema,\n I extends InlineContentSchema,\n> extends Exporter<\n B,\n I,\n S,\n Promise<Paragraph[] | Paragraph | Table> | Paragraph[] | Paragraph | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n> {\n public constructor(\n /**\n * The schema of your editor. The mappings are automatically typed checked against this schema.\n */\n protected readonly schema: BlockNoteSchema<B, I, S>,\n /**\n * The mappings that map the BlockNote schema to the docxjs content.\n * Pass {@link docxDefaultSchemaMappings} for the default schema.\n */\n protected readonly mappings: Exporter<\n NoInfer<B>,\n NoInfer<I>,\n NoInfer<S>,\n | Promise<Paragraph[] | Paragraph | Table>\n | Paragraph[]\n | Paragraph\n | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n >[\"mappings\"],\n options?: Partial<ExporterOptions>,\n ) {\n const defaults = {\n colors: COLORS_DEFAULT,\n resolveFileUrl: corsProxyResolveFileUrl,\n } satisfies Partial<ExporterOptions>;\n\n const newOptions = {\n ...defaults,\n ...options,\n };\n super(schema, mappings, newOptions);\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public transformStyledText(styledText: StyledText<S>, hyperlink?: boolean) {\n const stylesArray = this.mapStyles(styledText.styles);\n\n const styles: IRunPropertiesOptions = Object.assign(\n {} as IRunPropertiesOptions,\n ...stylesArray,\n );\n\n return new TextRun({\n ...styles,\n style: hyperlink ? \"Hyperlink\" : undefined,\n text: styledText.text,\n });\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public async transformBlocks(\n blocks: Block<B, I, S>[],\n nestingLevel = 0,\n ): Promise<Array<Paragraph | Table>> {\n const ret: Array<Paragraph | Table> = [];\n\n for (const b of blocks) {\n let children = await this.transformBlocks(b.children, nestingLevel + 1);\n children = children.map((c, _i) => {\n // NOTE: nested tables not supported (we can't insert the new Tab before a table)\n if (\n c instanceof Paragraph &&\n !(c as any).properties.numberingReferences.length\n ) {\n c.addRunToFront(\n new TextRun({\n children: [new Tab()],\n }),\n );\n }\n return c;\n });\n const self = await this.mapBlock(b as any, nestingLevel, 0 /*unused*/); // TODO: any\n if (Array.isArray(self)) {\n ret.push(...self, ...children);\n } else {\n ret.push(self, ...children);\n }\n }\n return ret;\n }\n\n protected async getFonts(): Promise<DocumentOptions[\"fonts\"]> {\n // Unfortunately, loading the variable font doesn't work\n // \"./src/fonts/Inter-VariableFont_opsz,wght.ttf\",\n\n let interFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Regular.ttf\"),\n );\n let geistMonoFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/GeistMono-Regular.ttf\"),\n );\n\n if (\n interFont instanceof ArrayBuffer ||\n geistMonoFont instanceof ArrayBuffer\n ) {\n // conversion with Polyfill needed because docxjs requires Buffer\n // NOTE: the buffer/ import is intentional and as documented in\n // the `buffer` package usage instructions\n // https://github.com/feross/buffer?tab=readme-ov-file#usage\n const Buffer = (await import(\"buffer/\")).Buffer;\n\n if (interFont instanceof ArrayBuffer) {\n interFont = Buffer.from(interFont) as unknown as Buffer;\n }\n if (geistMonoFont instanceof ArrayBuffer) {\n geistMonoFont = Buffer.from(geistMonoFont) as unknown as Buffer;\n }\n }\n\n return [\n { name: \"Inter\", data: interFont },\n {\n name: \"GeistMono\",\n data: geistMonoFont,\n },\n ];\n }\n\n protected async createDefaultDocumentOptions(): Promise<DocumentOptions> {\n const externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n const bullets = [\"•\"]; //, \"◦\", \"▪\"]; (these don't look great, just use solid bullet for now)\n return {\n numbering: {\n config: [\n {\n reference: \"blocknote-numbered-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.DECIMAL,\n text: `%${i + 1}.`,\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n {\n reference: \"blocknote-bullet-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.BULLET,\n text: bullets[i % bullets.length],\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n ],\n },\n fonts: await this.getFonts(),\n defaultTabStop: 200,\n externalStyles,\n };\n }\n\n /**\n * Convert a document (array of Blocks to a Blob representing a .docx file)\n */\n public async toBlob(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = await this.toDocxJsDocument(blocks, options);\n type GlobalThis = typeof globalThis & { Buffer?: any };\n const prevBuffer = (globalThis as GlobalThis).Buffer;\n try {\n if (!(globalThis as GlobalThis).Buffer) {\n // load Buffer polyfill because docxjs requires this\n (globalThis as GlobalThis).Buffer = (\n await import(\"buffer\")\n ).default.Buffer;\n }\n return Packer.toBlob(doc);\n } finally {\n (globalThis as GlobalThis).Buffer = prevBuffer;\n }\n }\n\n /**\n * Convert a document (array of Blocks to a docxjs Document)\n */\n public async toDocxJsDocument(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions()),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\n });\n\n // fix https://github.com/dolanmiu/docx/pull/2800/files\n doc.Document.Relationships.createRelationship(\n doc.Document.Relationships.RelationshipCount + 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\",\n \"fontTable.xml\",\n );\n\n return doc;\n }\n}\n"],"names":["getImageDimensions","blob","bmp","width","height","imageMetaFunc","bytes","meta","Table","data","headerRows","headerCols","DocxTable","w","row","rowIndex","isHeaderRow","TableRow","c","colIndex","_a","cell","mapTableCell","isHeaderColumn","TableCell","ShadingType","Paragraph","UnreachableCaseError","blockPropsToStyles","props","colors","docxBlockMappingForDefaultSchema","block","exporter","nestingLevel","CheckBox","TextRun","file","caption","textContent","line","index","PageBreak","ImageRun","defaultText","ExternalHyperlink","docxInlineContentMappingForDefaultSchema","ic","content","docxStyleMappingForDefaultSchema","val","docxDefaultSchemaMappings","corsProxyResolveFileUrl","url","loadFileBuffer","requireUrl","dataUrl","DEFAULT_TAB_STOP","DOCXExporter","Exporter","schema","mappings","options","newOptions","COLORS_DEFAULT","styledText","hyperlink","stylesArray","styles","blocks","ret","b","children","_i","Tab","self","interFont","geistMonoFont","Buffer","n","externalStyles","bullets","_","LevelFormat","AlignmentType","doc","prevBuffer","Packer","Document"],"mappings":"glBAAA,eAAsBA,EAAmBC,EAAY,CACnD,GAAI,OAAO,OAAW,IAAoD,CAClE,MAAAC,EAAM,MAAM,kBAAkBD,CAAI,EAClC,CAAE,MAAAE,EAAO,OAAAC,CAAA,EAAWF,EAC1B,OAAAA,EAAI,MAAM,EACH,CAAE,MAAAC,EAAO,OAAAC,CAAO,CAAA,KAClB,CAEL,MAAMC,GAAiB,KAAM,QAAO,YAAY,GAAG,UAC7CC,EAAQ,IAAI,WAAW,MAAML,EAAK,aAAa,EAC/CM,EAAOF,EAAcC,CAAK,EAChC,GAAI,CAACC,EAAK,OAAS,CAACA,EAAK,OACjB,MAAA,IAAI,MAAM,4BAA4B,EAE9C,MAAO,CAAE,MAAOA,EAAK,MAAO,OAAQA,EAAK,MAAO,CAAA,CAEpD,CCAa,MAAAC,EAAQ,CACnBC,EACA,IACG,CAIG,MAAAC,EAAa,IAAI,MAAMD,EAAK,YAAc,CAAC,EAAE,KAAK,EAAI,EAEtDE,EAAa,IAAI,MAAMF,EAAK,YAAc,CAAC,EAAE,KAAK,EAAI,EAE5D,OAAO,IAAIG,EAAAA,MAAU,CACnB,OAAQ,UACR,aAAcH,EAAK,aAAa,IAC7BI,IACEA,GAAK,KAAwC,IAAsB,EACxE,EACA,KAAMJ,EAAK,KAAK,IAAI,CAACK,EAAKC,IAAa,CAC/B,MAAAC,EAAcN,EAAWK,CAAQ,EACvC,OAAO,IAAIE,EAAAA,SAAS,CAClB,YAAaD,EACb,SAAUF,EAAI,MAAM,IAAI,CAACI,EAAGC,IAAa,OACjC,MAAAhB,GAAQiB,EAAAX,EAAK,eAAL,YAAAW,EAAoBD,GAC5BE,EAAOC,eAAaJ,CAAC,EACrBK,EAAiBZ,EAAWQ,CAAQ,EAE1C,OAAO,IAAIK,EAAAA,UAAU,CACnB,MAAOrB,EACH,CACE,KA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EAC5C,GAAG1B,EAAQ,gBACX,SAAU,CACR,CACE,SAAU,MAAM,KAAK,gBAAgBO,CAAM,EAC3C,GAAGP,EAAQ,cAAA,CACb,CACF,CACD,EAGD,OAAAuB,EAAI,SAAS,cAAc,mBACzBA,EAAI,SAAS,cAAc,kBAAoB,EAC/C,gFACA,eACF,EAEOA,CAAA,CAEX"}
@@ -1,5 +1,5 @@
1
1
  import { mapTableCell as I, UnreachableCaseError as T, Exporter as O, COLORS_DEFAULT as k } from "@blocknote/core";
2
- import { Table as F, TableRow as S, TableCell as v, Paragraph as s, ShadingType as m, ImageRun as L, PageBreak as M, TextRun as u, CheckBox as R, ExternalHyperlink as B, Tab as U, AlignmentType as b, LevelFormat as C, Packer as E, Document as _ } from "docx";
2
+ import { Table as F, TableRow as S, TableCell as v, Paragraph as s, ShadingType as m, ImageRun as L, PageBreak as M, TextRun as u, CheckBox as R, ExternalHyperlink as B, Tab as E, AlignmentType as b, LevelFormat as C, Packer as U, Document as _ } from "docx";
3
3
  async function H(e) {
4
4
  if (typeof window < "u") {
5
5
  const t = await createImageBitmap(e), { width: n, height: r } = t;
@@ -312,7 +312,7 @@ class q extends O {
312
312
  let a = await this.transformBlocks(o.children, n + 1);
313
313
  a = a.map((c, g) => (c instanceof s && !c.properties.numberingReferences.length && c.addRunToFront(
314
314
  new u({
315
- children: [new U()]
315
+ children: [new E()]
316
316
  })
317
317
  ), c));
318
318
  const p = await this.mapBlock(
@@ -331,8 +331,8 @@ class q extends O {
331
331
  ), n = await A(
332
332
  await import("./GeistMono-Regular-D4rKXxwr.js")
333
333
  );
334
- if (t instanceof ArrayBuffer || n instanceof Uint8Array) {
335
- const r = (await import("buffer")).default.Buffer;
334
+ if (t instanceof ArrayBuffer || n instanceof ArrayBuffer) {
335
+ const r = (await import("./index-cA_PmnZy.js").then((o) => o.i)).Buffer;
336
336
  t instanceof ArrayBuffer && (t = r.from(t)), n instanceof ArrayBuffer && (n = r.from(n));
337
337
  }
338
338
  return [
@@ -400,7 +400,7 @@ class q extends O {
400
400
  }) {
401
401
  const r = await this.toDocxJsDocument(t, n), o = globalThis.Buffer;
402
402
  try {
403
- return globalThis.Buffer || (globalThis.Buffer = (await import("buffer")).default.Buffer), E.toBlob(r);
403
+ return globalThis.Buffer || (globalThis.Buffer = (await import("buffer")).default.Buffer), U.toBlob(r);
404
404
  } finally {
405
405
  globalThis.Buffer = o;
406
406
  }
@@ -1 +1 @@
1
- {"version":3,"file":"blocknote-xl-docx-exporter.js","sources":["../../../shared/util/imageUtil.ts","../src/docx/util/Table.tsx","../src/docx/defaultSchema/blocks.ts","../src/docx/defaultSchema/inlinecontent.ts","../src/docx/defaultSchema/styles.ts","../src/docx/defaultSchema/index.ts","../../../shared/api/corsProxy.ts","../../../shared/util/fileUtil.ts","../src/docx/docxExporter.ts"],"sourcesContent":["export async function getImageDimensions(blob: Blob) {\n if (typeof window !== \"undefined\" && import.meta.env.NODE_ENV !== \"test\") {\n const bmp = await createImageBitmap(blob);\n const { width, height } = bmp;\n bmp.close(); // free memory\n return { width, height };\n } else {\n // node or vitest\n const imageMetaFunc = (await import(\"image-meta\")).imageMeta;\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const meta = imageMetaFunc(bytes);\n if (!meta.width || !meta.height) {\n throw new Error(\"Image dimensions not found\");\n }\n return { width: meta.width, height: meta.height };\n }\n}\n","import {\n Exporter,\n InlineContentSchema,\n mapTableCell,\n TableContent,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport {\n Table as DocxTable,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TableCell,\n TableRow,\n} from \"docx\";\n\nexport const Table = (\n data: TableContent<InlineContentSchema>,\n t: Exporter<any, any, any, any, ParagraphChild, any, any>\n) => {\n const DEFAULT_COLUMN_WIDTH = 120;\n\n // If headerRows is 1, then the first row is a header row\n const headerRows = new Array(data.headerRows ?? 0).fill(true);\n // If headerCols is 1, then the first column is a header column\n const headerCols = new Array(data.headerCols ?? 0).fill(true);\n\n return new DocxTable({\n layout: \"autofit\",\n columnWidths: data.columnWidths.map(\n (w) =>\n (w ?? DEFAULT_COLUMN_WIDTH) * /* to points */ 0.75 * /* to twips */ 20\n ),\n rows: data.rows.map((row, rowIndex) => {\n const isHeaderRow = headerRows[rowIndex];\n return new TableRow({\n tableHeader: isHeaderRow,\n children: row.cells.map((c, colIndex) => {\n const width = data.columnWidths?.[colIndex];\n const cell = mapTableCell(c);\n const isHeaderColumn = headerCols[colIndex];\n\n return new TableCell({\n width: width\n ? {\n size: `${width * 0.75}pt`,\n type: \"dxa\",\n }\n : undefined,\n columnSpan: cell.props.colspan,\n rowSpan: cell.props.rowspan,\n shading:\n cell.props.backgroundColor === \"default\" ||\n !cell.props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n t.options.colors[\n cell.props\n .backgroundColor as keyof typeof t.options.colors\n ].background.slice(1),\n },\n children: [\n new Paragraph({\n children: t.transformInlineContent(cell.content),\n\n alignment:\n !cell.props.textAlignment ||\n cell.props.textAlignment === \"left\"\n ? undefined\n : cell.props.textAlignment === \"center\"\n ? \"center\"\n : cell.props.textAlignment === \"right\"\n ? \"right\"\n : cell.props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(\n cell.props.textAlignment\n );\n })(),\n run: {\n // TODO add support for table headers exporting, bolding seems to not be working at the moment\n bold: isHeaderRow || isHeaderColumn,\n // TODO table paragraph color seems to not be working at the moment\n // Probably because the runs are setting their own color\n color:\n cell.props.textColor === \"default\" || !cell.props.textColor\n ? undefined\n : t.options.colors[\n cell.props.textColor as keyof typeof t.options.colors\n ].text.slice(1),\n },\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n","import {\n BlockMapping,\n COLORS_DEFAULT,\n DefaultBlockSchema,\n DefaultProps,\n pageBreakSchema,\n StyledText,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport { getImageDimensions } from \"@shared/util/imageUtil.js\";\nimport {\n CheckBox,\n Table as DocxTable,\n ExternalHyperlink,\n ImageRun,\n IParagraphOptions,\n PageBreak,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\n\nfunction blockPropsToStyles(\n props: Partial<DefaultProps>,\n colors: typeof COLORS_DEFAULT\n): IParagraphOptions {\n return {\n shading:\n props.backgroundColor === \"default\" || !props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n colors[\n props.backgroundColor as keyof typeof colors\n ].background.slice(1),\n },\n run:\n props.textColor === \"default\" || !props.textColor\n ? undefined\n : {\n color: colors[props.textColor as keyof typeof colors].text.slice(1),\n },\n alignment:\n !props.textAlignment || props.textAlignment === \"left\"\n ? undefined\n : props.textAlignment === \"center\"\n ? \"center\"\n : props.textAlignment === \"right\"\n ? \"right\"\n : props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(props.textAlignment);\n })(),\n };\n}\nexport const docxBlockMappingForDefaultSchema: BlockMapping<\n DefaultBlockSchema & typeof pageBreakSchema.blockSchema,\n any,\n any,\n | Promise<Paragraph[] | Paragraph | DocxTable>\n | Paragraph[]\n | Paragraph\n | DocxTable,\n ParagraphChild\n> = {\n paragraph: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n style: \"Normal\",\n run: {\n font: \"Inter\",\n },\n });\n },\n numberedListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-numbered-list\",\n level: nestingLevel,\n },\n });\n },\n bulletListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-bullet-list\",\n level: nestingLevel,\n },\n });\n },\n checkListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new CheckBox({ checked: block.props.checked }),\n new TextRun({\n children: [\" \"],\n }),\n ...exporter.transformInlineContent(block.content),\n ],\n });\n },\n heading: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n heading: `Heading${block.props.level}`,\n });\n },\n quote: (block, exporter) => {\n return new Paragraph({\n shading: {\n color: \"#7D797A\",\n },\n border: {\n left: {\n color: \"#7D797A\",\n space: 100,\n style: \"single\",\n size: 8,\n },\n },\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n });\n },\n audio: (block, exporter) => {\n return [\n file(block.props, \"Open audio\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n video: (block, exporter) => {\n return [\n file(block.props, \"Open video\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n file: (block, exporter) => {\n return [\n file(block.props, \"Open file\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n codeBlock: (block) => {\n const textContent = (block.content as StyledText<any>[])[0]?.text || \"\";\n\n return new Paragraph({\n style: \"Codeblock\",\n shading: {\n type: ShadingType.SOLID,\n fill: \"161616\",\n color: \"161616\",\n },\n children: [\n ...textContent.split(\"\\n\").map((line, index) => {\n return new TextRun({\n text: line,\n break: index > 0 ? 1 : 0,\n });\n }),\n ],\n });\n },\n pageBreak: () => {\n return new Paragraph({\n children: [new PageBreak()],\n });\n },\n image: async (block, exporter) => {\n const blob = await exporter.resolveFile(block.props.url);\n const { width, height } = await getImageDimensions(blob);\n\n return [\n new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new ImageRun({\n data: await blob.arrayBuffer(),\n // it would be nicer to set the actual data type here, but then we'd need to use a mime type / image type\n // detector. atm passing gif does not seem to be causing issues as the \"type\" is mainly used by docxjs internally\n // (i.e.: to make sure it's not svg)\n type: \"gif\",\n altText: block.props.caption\n ? {\n description: block.props.caption,\n name: block.props.caption,\n title: block.props.caption,\n }\n : undefined,\n transformation: {\n width: block.props.previewWidth || width,\n height: ((block.props.previewWidth || width) / width) * height,\n },\n }),\n ],\n }),\n ...caption(block.props, exporter),\n ];\n },\n table: (block, exporter) => {\n return Table(block.content, exporter);\n },\n};\n\nfunction file(\n props: Partial<DefaultProps & { name: string; url: string }>,\n defaultText: string,\n exporter: any\n) {\n return new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new ExternalHyperlink({\n children: [\n new TextRun({\n text: props.name || defaultText,\n style: \"Hyperlink\",\n }),\n ],\n link: props.url!,\n }),\n ],\n });\n}\n\nfunction caption(\n props: Partial<DefaultProps & { caption: string }>,\n exporter: any\n) {\n if (!props.caption) {\n return [];\n }\n return [\n new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new TextRun({\n text: props.caption,\n }),\n ],\n style: \"Caption\",\n }),\n ];\n}\n","import {\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n InlineContentMapping,\n} from \"@blocknote/core\";\nimport { ExternalHyperlink, ParagraphChild, TextRun } from \"docx\";\nimport type { DOCXExporter } from \"../docxExporter.js\";\n\nexport const docxInlineContentMappingForDefaultSchema: InlineContentMapping<\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n ParagraphChild,\n TextRun\n> = {\n link: (ic, exporter) => {\n return new ExternalHyperlink({\n children: ic.content.map((content) => {\n return (exporter as DOCXExporter<any, any, any>).transformStyledText(\n content,\n true\n );\n }),\n link: ic.href,\n });\n },\n text: (ic, t) => {\n return t.transformStyledText(ic);\n },\n};\n","import { DefaultStyleSchema, StyleMapping } from \"@blocknote/core\";\nimport { IRunPropertiesOptions } from \"docx\";\n\nexport const docxStyleMappingForDefaultSchema: StyleMapping<\n DefaultStyleSchema,\n IRunPropertiesOptions\n> = {\n bold: (val) => {\n if (!val) {\n return {};\n }\n return {\n bold: val,\n };\n },\n italic: (val) => {\n if (!val) {\n return {};\n }\n return {\n italics: val,\n };\n },\n underline: (val) => {\n if (!val) {\n return {};\n }\n return {\n underline: {\n type: \"single\",\n },\n };\n },\n strike: (val) => {\n if (!val) {\n return {};\n }\n return {\n strike: val,\n };\n },\n backgroundColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n shading: {\n fill: exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].background.slice(1),\n },\n };\n },\n textColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n color:\n exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].text.slice(1),\n };\n },\n code: (val) => {\n if (!val) {\n return {};\n }\n return {\n font: \"GeistMono\",\n };\n },\n};\n","import { docxBlockMappingForDefaultSchema } from \"./blocks.js\";\nimport { docxInlineContentMappingForDefaultSchema } from \"./inlinecontent.js\";\nimport { docxStyleMappingForDefaultSchema } from \"./styles.js\";\n\nexport const docxDefaultSchemaMappings = {\n blockMapping: docxBlockMappingForDefaultSchema,\n inlineContentMapping: docxInlineContentMappingForDefaultSchema,\n styleMapping: docxStyleMappingForDefaultSchema,\n};\n","export async function corsProxyResolveFileUrl(url: string) {\n return (\n \"https://corsproxy.api.blocknotejs.org/corsproxy/?url=\" +\n encodeURIComponent(url)\n );\n}\n","/**\n *\n * Helper functions so that we can import files both on vitest, browser and node\n * TODO: should find a way to test automatically in all environments\n */\n\nexport async function loadFileDataUrl(\n requireUrl: { default: string },\n mimeType: string\n) {\n if (import.meta.env.NODE_ENV === \"test\") {\n const buffer = await loadFileBuffer(requireUrl);\n const fileBase64 = buffer.toString(\"base64\");\n\n const dataUrl = `data:${mimeType};base64,${fileBase64}`;\n return dataUrl;\n } else {\n // in browser, this is already a data url\n return requireUrl.default as string;\n }\n}\n\nexport async function loadFontDataUrl(requireUrl: { default: string }) {\n return loadFileDataUrl(requireUrl, \"font/ttf\");\n}\n\nexport async function loadFileBuffer(requireUrl: {\n default: string;\n}): Promise<Buffer | ArrayBuffer> {\n if (import.meta.env.NODE_ENV === \"test\") {\n // in vitest, this is the url we need to load with readfilesync\n // eslint-disable-next-line\n const fs = require(\"fs\");\n let url = requireUrl.default;\n\n if (url.startsWith(\"/@fs/\")) {\n url = url.substring(\"/@fs\".length);\n }\n const buffer = fs.readFileSync(url);\n return buffer;\n } else {\n // in browser, this is already a data url\n const dataUrl = requireUrl.default as string;\n // convert to buffer on browser\n const response = await fetch(dataUrl);\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n}\n\n/**\n * usage:\n * \n * await loadFontDataUrl(\n await import(\"../fonts/inter/Inter_18pt-Italic.ttf\")\n );\n */\n","import {\n Block,\n BlockNoteSchema,\n BlockSchema,\n COLORS_DEFAULT,\n InlineContentSchema,\n StyleSchema,\n StyledText,\n} from \"@blocknote/core\";\nimport {\n AlignmentType,\n Document,\n IRunPropertiesOptions,\n ISectionOptions,\n LevelFormat,\n Packer,\n Paragraph,\n ParagraphChild,\n Tab,\n Table,\n TextRun,\n} from \"docx\";\n\nimport { Exporter, ExporterOptions } from \"@blocknote/core\";\nimport { corsProxyResolveFileUrl } from \"@shared/api/corsProxy.js\";\nimport { loadFileBuffer } from \"@shared/util/fileUtil.js\";\n\n// get constructor arg type from Document\ntype DocumentOptions = Partial<ConstructorParameters<typeof Document>[0]>;\n\nconst DEFAULT_TAB_STOP =\n /* default font size */ 16 *\n /* 1 pixel is 0.75 points */ 0.75 *\n /* 1.5em*/ 1.5 *\n /* 1 point is 20 twips */ 20;\n\n/**\n * Exports a BlockNote document to a .docx file using the docxjs library.\n */\nexport class DOCXExporter<\n B extends BlockSchema,\n S extends StyleSchema,\n I extends InlineContentSchema\n> extends Exporter<\n B,\n I,\n S,\n Promise<Paragraph[] | Paragraph | Table> | Paragraph[] | Paragraph | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n> {\n public constructor(\n /**\n * The schema of your editor. The mappings are automatically typed checked against this schema.\n */\n protected readonly schema: BlockNoteSchema<B, I, S>,\n /**\n * The mappings that map the BlockNote schema to the docxjs content.\n * Pass {@link docxDefaultSchemaMappings} for the default schema.\n */\n protected readonly mappings: Exporter<\n NoInfer<B>,\n NoInfer<I>,\n NoInfer<S>,\n | Promise<Paragraph[] | Paragraph | Table>\n | Paragraph[]\n | Paragraph\n | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n >[\"mappings\"],\n options?: Partial<ExporterOptions>\n ) {\n const defaults = {\n colors: COLORS_DEFAULT,\n resolveFileUrl: corsProxyResolveFileUrl,\n } satisfies Partial<ExporterOptions>;\n\n const newOptions = {\n ...defaults,\n ...options,\n };\n super(schema, mappings, newOptions);\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public transformStyledText(styledText: StyledText<S>, hyperlink?: boolean) {\n const stylesArray = this.mapStyles(styledText.styles);\n\n const styles: IRunPropertiesOptions = Object.assign(\n {} as IRunPropertiesOptions,\n ...stylesArray\n );\n\n return new TextRun({\n ...styles,\n style: hyperlink ? \"Hyperlink\" : undefined,\n text: styledText.text,\n });\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public async transformBlocks(\n blocks: Block<B, I, S>[],\n nestingLevel = 0\n ): Promise<Array<Paragraph | Table>> {\n const ret: Array<Paragraph | Table> = [];\n\n for (const b of blocks) {\n let children = await this.transformBlocks(b.children, nestingLevel + 1);\n children = children.map((c, _i) => {\n // NOTE: nested tables not supported (we can't insert the new Tab before a table)\n if (\n c instanceof Paragraph &&\n !(c as any).properties.numberingReferences.length\n ) {\n c.addRunToFront(\n new TextRun({\n children: [new Tab()],\n })\n );\n }\n return c;\n });\n const self = await this.mapBlock(b as any, nestingLevel, 0 /*unused*/); // TODO: any\n if (Array.isArray(self)) {\n ret.push(...self, ...children);\n } else {\n ret.push(self, ...children);\n }\n }\n return ret;\n }\n\n protected async getFonts(): Promise<DocumentOptions[\"fonts\"]> {\n // Unfortunately, loading the variable font doesn't work\n // \"./src/fonts/Inter-VariableFont_opsz,wght.ttf\",\n\n let interFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Regular.ttf\")\n );\n let geistMonoFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/GeistMono-Regular.ttf\")\n );\n\n if (\n interFont instanceof ArrayBuffer ||\n geistMonoFont instanceof Uint8Array\n ) {\n // conversion with Polyfill needed because docxjs requires Buffer\n const Buffer = (await import(\"buffer\")).default.Buffer;\n\n if (interFont instanceof ArrayBuffer) {\n interFont = Buffer.from(interFont);\n }\n if (geistMonoFont instanceof ArrayBuffer) {\n geistMonoFont = Buffer.from(geistMonoFont);\n }\n }\n\n return [\n { name: \"Inter\", data: interFont as Buffer },\n {\n name: \"GeistMono\",\n data: geistMonoFont as Buffer,\n },\n ];\n }\n\n protected async createDefaultDocumentOptions(): Promise<DocumentOptions> {\n const externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n const bullets = [\"•\"]; //, \"◦\", \"▪\"]; (these don't look great, just use solid bullet for now)\n return {\n numbering: {\n config: [\n {\n reference: \"blocknote-numbered-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.DECIMAL,\n text: `%${i + 1}.`,\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n {\n reference: \"blocknote-bullet-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.BULLET,\n text: bullets[i % bullets.length],\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n ],\n },\n fonts: await this.getFonts(),\n defaultTabStop: 200,\n externalStyles,\n };\n }\n\n /**\n * Convert a document (array of Blocks to a Blob representing a .docx file)\n */\n public async toBlob(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n }\n ) {\n const doc = await this.toDocxJsDocument(blocks, options);\n type GlobalThis = typeof globalThis & { Buffer?: any };\n const prevBuffer = (globalThis as GlobalThis).Buffer;\n try {\n if (!(globalThis as GlobalThis).Buffer) {\n // load Buffer polyfill because docxjs requires this\n (globalThis as GlobalThis).Buffer = (\n await import(\"buffer\")\n ).default.Buffer;\n }\n return Packer.toBlob(doc);\n } finally {\n (globalThis as GlobalThis).Buffer = prevBuffer;\n }\n }\n\n /**\n * Convert a document (array of Blocks to a docxjs Document)\n */\n public async toDocxJsDocument(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n }\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions()),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\n });\n\n // fix https://github.com/dolanmiu/docx/pull/2800/files\n doc.Document.Relationships.createRelationship(\n doc.Document.Relationships.RelationshipCount + 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\",\n \"fontTable.xml\"\n );\n\n return doc;\n }\n}\n"],"names":["getImageDimensions","blob","bmp","width","height","imageMetaFunc","bytes","meta","Table","data","headerRows","headerCols","DocxTable","w","row","rowIndex","isHeaderRow","TableRow","c","colIndex","_a","cell","mapTableCell","isHeaderColumn","TableCell","ShadingType","Paragraph","UnreachableCaseError","blockPropsToStyles","props","colors","docxBlockMappingForDefaultSchema","block","exporter","nestingLevel","CheckBox","TextRun","file","caption","textContent","line","index","PageBreak","ImageRun","defaultText","ExternalHyperlink","docxInlineContentMappingForDefaultSchema","ic","content","docxStyleMappingForDefaultSchema","val","docxDefaultSchemaMappings","corsProxyResolveFileUrl","url","loadFileBuffer","requireUrl","dataUrl","DEFAULT_TAB_STOP","DOCXExporter","Exporter","schema","mappings","options","newOptions","COLORS_DEFAULT","styledText","hyperlink","stylesArray","styles","blocks","ret","b","children","_i","Tab","self","interFont","geistMonoFont","Buffer","externalStyles","bullets","_","i","LevelFormat","AlignmentType","doc","prevBuffer","Packer","Document"],"mappings":";;AAAA,eAAsBA,EAAmBC,GAAY;AACnD,MAAI,OAAO,SAAW,KAAoD;AAClE,UAAAC,IAAM,MAAM,kBAAkBD,CAAI,GAClC,EAAE,OAAAE,GAAO,QAAAC,EAAA,IAAWF;AAC1B,WAAAA,EAAI,MAAM,GACH,EAAE,OAAAC,GAAO,QAAAC,EAAO;AAAA,EAAA,OAClB;AAEL,UAAMC,KAAiB,MAAM,OAAO,YAAY,GAAG,WAC7CC,IAAQ,IAAI,WAAW,MAAML,EAAK,aAAa,GAC/CM,IAAOF,EAAcC,CAAK;AAChC,QAAI,CAACC,EAAK,SAAS,CAACA,EAAK;AACjB,YAAA,IAAI,MAAM,4BAA4B;AAE9C,WAAO,EAAE,OAAOA,EAAK,OAAO,QAAQA,EAAK,OAAO;AAAA,EAAA;AAEpD;ACAa,MAAAC,IAAQ,CACnBC,GACA,MACG;AAIG,QAAAC,IAAa,IAAI,MAAMD,EAAK,cAAc,CAAC,EAAE,KAAK,EAAI,GAEtDE,IAAa,IAAI,MAAMF,EAAK,cAAc,CAAC,EAAE,KAAK,EAAI;AAE5D,SAAO,IAAIG,EAAU;AAAA,IACnB,QAAQ;AAAA,IACR,cAAcH,EAAK,aAAa;AAAA,MAC9B,CAACI,OACEA,KAAK;AAAA,MAAwC;AAAA,MAAsB;AAAA,IACxE;AAAA,IACA,MAAMJ,EAAK,KAAK,IAAI,CAACK,GAAKC,MAAa;AAC/B,YAAAC,IAAcN,EAAWK,CAAQ;AACvC,aAAO,IAAIE,EAAS;AAAA,QAClB,aAAaD;AAAA,QACb,UAAUF,EAAI,MAAM,IAAI,CAACI,GAAGC,MAAa;;AACjC,gBAAAhB,KAAQiB,IAAAX,EAAK,iBAAL,gB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A,UAAA;AAAA,QACJ;AAAA,MAEJ;AAAA,MACA,OAAO,MAAM,KAAK,SAAS;AAAA,MAC3B,gBAAgB;AAAA,MAChB,gBAAAsB;AAAA,IACF;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMF,MAAa,OACXV,GACAP,IAGI;AAAA,IACF,gBAAgB,CAAC;AAAA,IACjB,iBAAiB,CAAA;AAAA,EAAC,GAEpB;AACA,UAAMuB,IAAM,MAAM,KAAK,iBAAiBhB,GAAQP,CAAO,GAEjDwB,IAAc,WAA0B;AAC1C,QAAA;AACE,aAAE,WAA0B,WAE7B,WAA0B,UACzB,MAAM,OAAO,QAAQ,GACrB,QAAQ,SAELC,EAAO,OAAOF,CAAG;AAAA,IAAA,UACxB;AACC,iBAA0B,SAASC;AAAA,IAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAMF,MAAa,iBACXjB,GACAP,IAGI;AAAA,IACF,gBAAgB,CAAC;AAAA,IACjB,iBAAiB,CAAA;AAAA,EAAC,GAEpB;AACM,UAAAuB,IAAM,IAAIG,EAAS;AAAA,MACvB,GAAI,MAAM,KAAK,6BAA6B;AAAA,MAC5C,GAAG1B,EAAQ;AAAA,MACX,UAAU;AAAA,QACR;AAAA,UACE,UAAU,MAAM,KAAK,gBAAgBO,CAAM;AAAA,UAC3C,GAAGP,EAAQ;AAAA,QAAA;AAAA,MACb;AAAA,IACF,CACD;AAGD,WAAAuB,EAAI,SAAS,cAAc;AAAA,MACzBA,EAAI,SAAS,cAAc,oBAAoB;AAAA,MAC/C;AAAA,MACA;AAAA,IACF,GAEOA;AAAA,EAAA;AAEX;"}
1
+ {"version":3,"file":"blocknote-xl-docx-exporter.js","sources":["../../../shared/util/imageUtil.ts","../src/docx/util/Table.tsx","../src/docx/defaultSchema/blocks.ts","../src/docx/defaultSchema/inlinecontent.ts","../src/docx/defaultSchema/styles.ts","../src/docx/defaultSchema/index.ts","../../../shared/api/corsProxy.ts","../../../shared/util/fileUtil.ts","../src/docx/docxExporter.ts"],"sourcesContent":["export async function getImageDimensions(blob: Blob) {\n if (typeof window !== \"undefined\" && import.meta.env.NODE_ENV !== \"test\") {\n const bmp = await createImageBitmap(blob);\n const { width, height } = bmp;\n bmp.close(); // free memory\n return { width, height };\n } else {\n // node or vitest\n const imageMetaFunc = (await import(\"image-meta\")).imageMeta;\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const meta = imageMetaFunc(bytes);\n if (!meta.width || !meta.height) {\n throw new Error(\"Image dimensions not found\");\n }\n return { width: meta.width, height: meta.height };\n }\n}\n","import {\n Exporter,\n InlineContentSchema,\n mapTableCell,\n TableContent,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport {\n Table as DocxTable,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TableCell,\n TableRow,\n} from \"docx\";\n\nexport const Table = (\n data: TableContent<InlineContentSchema>,\n t: Exporter<any, any, any, any, ParagraphChild, any, any>,\n) => {\n const DEFAULT_COLUMN_WIDTH = 120;\n\n // If headerRows is 1, then the first row is a header row\n const headerRows = new Array(data.headerRows ?? 0).fill(true);\n // If headerCols is 1, then the first column is a header column\n const headerCols = new Array(data.headerCols ?? 0).fill(true);\n\n return new DocxTable({\n layout: \"autofit\",\n columnWidths: data.columnWidths.map(\n (w) =>\n (w ?? DEFAULT_COLUMN_WIDTH) * /* to points */ 0.75 * /* to twips */ 20,\n ),\n rows: data.rows.map((row, rowIndex) => {\n const isHeaderRow = headerRows[rowIndex];\n return new TableRow({\n tableHeader: isHeaderRow,\n children: row.cells.map((c, colIndex) => {\n const width = data.columnWidths?.[colIndex];\n const cell = mapTableCell(c);\n const isHeaderColumn = headerCols[colIndex];\n\n return new TableCell({\n width: width\n ? {\n size: `${width * 0.75}pt`,\n type: \"dxa\",\n }\n : undefined,\n columnSpan: cell.props.colspan,\n rowSpan: cell.props.rowspan,\n shading:\n cell.props.backgroundColor === \"default\" ||\n !cell.props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n t.options.colors[\n cell.props\n .backgroundColor as keyof typeof t.options.colors\n ].background.slice(1),\n },\n children: [\n new Paragraph({\n children: t.transformInlineContent(cell.content),\n\n alignment:\n !cell.props.textAlignment ||\n cell.props.textAlignment === \"left\"\n ? undefined\n : cell.props.textAlignment === \"center\"\n ? \"center\"\n : cell.props.textAlignment === \"right\"\n ? \"right\"\n : cell.props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(\n cell.props.textAlignment,\n );\n })(),\n run: {\n // TODO add support for table headers exporting, bolding seems to not be working at the moment\n bold: isHeaderRow || isHeaderColumn,\n // TODO table paragraph color seems to not be working at the moment\n // Probably because the runs are setting their own color\n color:\n cell.props.textColor === \"default\" || !cell.props.textColor\n ? undefined\n : t.options.colors[\n cell.props.textColor as keyof typeof t.options.colors\n ].text.slice(1),\n },\n }),\n ],\n });\n }),\n });\n }),\n });\n};\n","import {\n BlockMapping,\n COLORS_DEFAULT,\n DefaultBlockSchema,\n DefaultProps,\n pageBreakSchema,\n StyledText,\n UnreachableCaseError,\n} from \"@blocknote/core\";\nimport { getImageDimensions } from \"@shared/util/imageUtil.js\";\nimport {\n CheckBox,\n Table as DocxTable,\n ExternalHyperlink,\n ImageRun,\n IParagraphOptions,\n PageBreak,\n Paragraph,\n ParagraphChild,\n ShadingType,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\n\nfunction blockPropsToStyles(\n props: Partial<DefaultProps>,\n colors: typeof COLORS_DEFAULT,\n): IParagraphOptions {\n return {\n shading:\n props.backgroundColor === \"default\" || !props.backgroundColor\n ? undefined\n : {\n type: ShadingType.SOLID,\n color:\n colors[\n props.backgroundColor as keyof typeof colors\n ].background.slice(1),\n },\n run:\n props.textColor === \"default\" || !props.textColor\n ? undefined\n : {\n color: colors[props.textColor as keyof typeof colors].text.slice(1),\n },\n alignment:\n !props.textAlignment || props.textAlignment === \"left\"\n ? undefined\n : props.textAlignment === \"center\"\n ? \"center\"\n : props.textAlignment === \"right\"\n ? \"right\"\n : props.textAlignment === \"justify\"\n ? \"distribute\"\n : (() => {\n throw new UnreachableCaseError(props.textAlignment);\n })(),\n };\n}\nexport const docxBlockMappingForDefaultSchema: BlockMapping<\n DefaultBlockSchema & typeof pageBreakSchema.blockSchema,\n any,\n any,\n | Promise<Paragraph[] | Paragraph | DocxTable>\n | Paragraph[]\n | Paragraph\n | DocxTable,\n ParagraphChild\n> = {\n paragraph: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n style: \"Normal\",\n run: {\n font: \"Inter\",\n },\n });\n },\n numberedListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-numbered-list\",\n level: nestingLevel,\n },\n });\n },\n bulletListItem: (block, exporter, nestingLevel) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n numbering: {\n reference: \"blocknote-bullet-list\",\n level: nestingLevel,\n },\n });\n },\n checkListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new CheckBox({ checked: block.props.checked }),\n new TextRun({\n children: [\" \"],\n }),\n ...exporter.transformInlineContent(block.content),\n ],\n });\n },\n heading: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n heading: `Heading${block.props.level}`,\n });\n },\n quote: (block, exporter) => {\n return new Paragraph({\n shading: {\n color: \"#7D797A\",\n },\n border: {\n left: {\n color: \"#7D797A\",\n space: 100,\n style: \"single\",\n size: 8,\n },\n },\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: exporter.transformInlineContent(block.content),\n });\n },\n audio: (block, exporter) => {\n return [\n file(block.props, \"Open audio\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n video: (block, exporter) => {\n return [\n file(block.props, \"Open video\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n file: (block, exporter) => {\n return [\n file(block.props, \"Open file\", exporter),\n ...caption(block.props, exporter),\n ];\n },\n codeBlock: (block) => {\n const textContent = (block.content as StyledText<any>[])[0]?.text || \"\";\n\n return new Paragraph({\n style: \"Codeblock\",\n shading: {\n type: ShadingType.SOLID,\n fill: \"161616\",\n color: \"161616\",\n },\n children: [\n ...textContent.split(\"\\n\").map((line, index) => {\n return new TextRun({\n text: line,\n break: index > 0 ? 1 : 0,\n });\n }),\n ],\n });\n },\n pageBreak: () => {\n return new Paragraph({\n children: [new PageBreak()],\n });\n },\n image: async (block, exporter) => {\n const blob = await exporter.resolveFile(block.props.url);\n const { width, height } = await getImageDimensions(blob);\n\n return [\n new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new ImageRun({\n data: await blob.arrayBuffer(),\n // it would be nicer to set the actual data type here, but then we'd need to use a mime type / image type\n // detector. atm passing gif does not seem to be causing issues as the \"type\" is mainly used by docxjs internally\n // (i.e.: to make sure it's not svg)\n type: \"gif\",\n altText: block.props.caption\n ? {\n description: block.props.caption,\n name: block.props.caption,\n title: block.props.caption,\n }\n : undefined,\n transformation: {\n width: block.props.previewWidth || width,\n height: ((block.props.previewWidth || width) / width) * height,\n },\n }),\n ],\n }),\n ...caption(block.props, exporter),\n ];\n },\n table: (block, exporter) => {\n return Table(block.content, exporter);\n },\n};\n\nfunction file(\n props: Partial<DefaultProps & { name: string; url: string }>,\n defaultText: string,\n exporter: any,\n) {\n return new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new ExternalHyperlink({\n children: [\n new TextRun({\n text: props.name || defaultText,\n style: \"Hyperlink\",\n }),\n ],\n link: props.url!,\n }),\n ],\n });\n}\n\nfunction caption(\n props: Partial<DefaultProps & { caption: string }>,\n exporter: any,\n) {\n if (!props.caption) {\n return [];\n }\n return [\n new Paragraph({\n ...blockPropsToStyles(props, exporter.options.colors),\n children: [\n new TextRun({\n text: props.caption,\n }),\n ],\n style: \"Caption\",\n }),\n ];\n}\n","import {\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n InlineContentMapping,\n} from \"@blocknote/core\";\nimport { ExternalHyperlink, ParagraphChild, TextRun } from \"docx\";\nimport type { DOCXExporter } from \"../docxExporter.js\";\n\nexport const docxInlineContentMappingForDefaultSchema: InlineContentMapping<\n DefaultInlineContentSchema,\n DefaultStyleSchema,\n ParagraphChild,\n TextRun\n> = {\n link: (ic, exporter) => {\n return new ExternalHyperlink({\n children: ic.content.map((content) => {\n return (exporter as DOCXExporter<any, any, any>).transformStyledText(\n content,\n true,\n );\n }),\n link: ic.href,\n });\n },\n text: (ic, t) => {\n return t.transformStyledText(ic);\n },\n};\n","import { DefaultStyleSchema, StyleMapping } from \"@blocknote/core\";\nimport { IRunPropertiesOptions } from \"docx\";\n\nexport const docxStyleMappingForDefaultSchema: StyleMapping<\n DefaultStyleSchema,\n IRunPropertiesOptions\n> = {\n bold: (val) => {\n if (!val) {\n return {};\n }\n return {\n bold: val,\n };\n },\n italic: (val) => {\n if (!val) {\n return {};\n }\n return {\n italics: val,\n };\n },\n underline: (val) => {\n if (!val) {\n return {};\n }\n return {\n underline: {\n type: \"single\",\n },\n };\n },\n strike: (val) => {\n if (!val) {\n return {};\n }\n return {\n strike: val,\n };\n },\n backgroundColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n shading: {\n fill: exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].background.slice(1),\n },\n };\n },\n textColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n color:\n exporter.options.colors[\n val as keyof typeof exporter.options.colors\n ].text.slice(1),\n };\n },\n code: (val) => {\n if (!val) {\n return {};\n }\n return {\n font: \"GeistMono\",\n };\n },\n};\n","import { docxBlockMappingForDefaultSchema } from \"./blocks.js\";\nimport { docxInlineContentMappingForDefaultSchema } from \"./inlinecontent.js\";\nimport { docxStyleMappingForDefaultSchema } from \"./styles.js\";\n\nexport const docxDefaultSchemaMappings = {\n blockMapping: docxBlockMappingForDefaultSchema,\n inlineContentMapping: docxInlineContentMappingForDefaultSchema,\n styleMapping: docxStyleMappingForDefaultSchema,\n};\n","export async function corsProxyResolveFileUrl(url: string) {\n return (\n \"https://corsproxy.api.blocknotejs.org/corsproxy/?url=\" +\n encodeURIComponent(url)\n );\n}\n","/**\n *\n * Helper functions so that we can import files both on vitest, browser and node\n * TODO: should find a way to test automatically in all environments\n */\n\nexport async function loadFileDataUrl(\n requireUrl: { default: string },\n mimeType: string,\n) {\n if (import.meta.env.NODE_ENV === \"test\") {\n const buffer = await loadFileBuffer(requireUrl);\n const fileBase64 = buffer.toString(\"base64\");\n\n const dataUrl = `data:${mimeType};base64,${fileBase64}`;\n return dataUrl;\n } else {\n // in browser, this is already a data url\n return requireUrl.default as string;\n }\n}\n\nexport async function loadFontDataUrl(requireUrl: { default: string }) {\n return loadFileDataUrl(requireUrl, \"font/ttf\");\n}\n\nexport async function loadFileBuffer(requireUrl: {\n default: string;\n}): Promise<Buffer | ArrayBuffer> {\n if (import.meta.env.NODE_ENV === \"test\") {\n // in vitest, this is the url we need to load with readfilesync\n // eslint-disable-next-line\n const fs = require(\"fs\");\n let url = requireUrl.default;\n\n if (url.startsWith(\"/@fs/\")) {\n url = url.substring(\"/@fs\".length);\n }\n const buffer = fs.readFileSync(url);\n return buffer;\n } else {\n // in browser, this is already a data url\n const dataUrl = requireUrl.default as string;\n // convert to buffer on browser\n const response = await fetch(dataUrl);\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n}\n\n/**\n * usage:\n * \n * await loadFontDataUrl(\n await import(\"../fonts/inter/Inter_18pt-Italic.ttf\")\n );\n */\n","import {\n Block,\n BlockNoteSchema,\n BlockSchema,\n COLORS_DEFAULT,\n InlineContentSchema,\n StyleSchema,\n StyledText,\n} from \"@blocknote/core\";\nimport {\n AlignmentType,\n Document,\n IRunPropertiesOptions,\n ISectionOptions,\n LevelFormat,\n Packer,\n Paragraph,\n ParagraphChild,\n Tab,\n Table,\n TextRun,\n} from \"docx\";\n\nimport { Exporter, ExporterOptions } from \"@blocknote/core\";\nimport { corsProxyResolveFileUrl } from \"@shared/api/corsProxy.js\";\nimport { loadFileBuffer } from \"@shared/util/fileUtil.js\";\n\n// get constructor arg type from Document\ntype DocumentOptions = Partial<ConstructorParameters<typeof Document>[0]>;\n\nconst DEFAULT_TAB_STOP =\n /* default font size */ 16 *\n /* 1 pixel is 0.75 points */ 0.75 *\n /* 1.5em*/ 1.5 *\n /* 1 point is 20 twips */ 20;\n\n/**\n * Exports a BlockNote document to a .docx file using the docxjs library.\n */\nexport class DOCXExporter<\n B extends BlockSchema,\n S extends StyleSchema,\n I extends InlineContentSchema,\n> extends Exporter<\n B,\n I,\n S,\n Promise<Paragraph[] | Paragraph | Table> | Paragraph[] | Paragraph | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n> {\n public constructor(\n /**\n * The schema of your editor. The mappings are automatically typed checked against this schema.\n */\n protected readonly schema: BlockNoteSchema<B, I, S>,\n /**\n * The mappings that map the BlockNote schema to the docxjs content.\n * Pass {@link docxDefaultSchemaMappings} for the default schema.\n */\n protected readonly mappings: Exporter<\n NoInfer<B>,\n NoInfer<I>,\n NoInfer<S>,\n | Promise<Paragraph[] | Paragraph | Table>\n | Paragraph[]\n | Paragraph\n | Table,\n ParagraphChild,\n IRunPropertiesOptions,\n TextRun\n >[\"mappings\"],\n options?: Partial<ExporterOptions>,\n ) {\n const defaults = {\n colors: COLORS_DEFAULT,\n resolveFileUrl: corsProxyResolveFileUrl,\n } satisfies Partial<ExporterOptions>;\n\n const newOptions = {\n ...defaults,\n ...options,\n };\n super(schema, mappings, newOptions);\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public transformStyledText(styledText: StyledText<S>, hyperlink?: boolean) {\n const stylesArray = this.mapStyles(styledText.styles);\n\n const styles: IRunPropertiesOptions = Object.assign(\n {} as IRunPropertiesOptions,\n ...stylesArray,\n );\n\n return new TextRun({\n ...styles,\n style: hyperlink ? \"Hyperlink\" : undefined,\n text: styledText.text,\n });\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.\n */\n public async transformBlocks(\n blocks: Block<B, I, S>[],\n nestingLevel = 0,\n ): Promise<Array<Paragraph | Table>> {\n const ret: Array<Paragraph | Table> = [];\n\n for (const b of blocks) {\n let children = await this.transformBlocks(b.children, nestingLevel + 1);\n children = children.map((c, _i) => {\n // NOTE: nested tables not supported (we can't insert the new Tab before a table)\n if (\n c instanceof Paragraph &&\n !(c as any).properties.numberingReferences.length\n ) {\n c.addRunToFront(\n new TextRun({\n children: [new Tab()],\n }),\n );\n }\n return c;\n });\n const self = await this.mapBlock(b as any, nestingLevel, 0 /*unused*/); // TODO: any\n if (Array.isArray(self)) {\n ret.push(...self, ...children);\n } else {\n ret.push(self, ...children);\n }\n }\n return ret;\n }\n\n protected async getFonts(): Promise<DocumentOptions[\"fonts\"]> {\n // Unfortunately, loading the variable font doesn't work\n // \"./src/fonts/Inter-VariableFont_opsz,wght.ttf\",\n\n let interFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Regular.ttf\"),\n );\n let geistMonoFont = await loadFileBuffer(\n await import(\"@shared/assets/fonts/GeistMono-Regular.ttf\"),\n );\n\n if (\n interFont instanceof ArrayBuffer ||\n geistMonoFont instanceof ArrayBuffer\n ) {\n // conversion with Polyfill needed because docxjs requires Buffer\n // NOTE: the buffer/ import is intentional and as documented in\n // the `buffer` package usage instructions\n // https://github.com/feross/buffer?tab=readme-ov-file#usage\n const Buffer = (await import(\"buffer/\")).Buffer;\n\n if (interFont instanceof ArrayBuffer) {\n interFont = Buffer.from(interFont) as unknown as Buffer;\n }\n if (geistMonoFont instanceof ArrayBuffer) {\n geistMonoFont = Buffer.from(geistMonoFont) as unknown as Buffer;\n }\n }\n\n return [\n { name: \"Inter\", data: interFont },\n {\n name: \"GeistMono\",\n data: geistMonoFont,\n },\n ];\n }\n\n protected async createDefaultDocumentOptions(): Promise<DocumentOptions> {\n const externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n const bullets = [\"•\"]; //, \"◦\", \"▪\"]; (these don't look great, just use solid bullet for now)\n return {\n numbering: {\n config: [\n {\n reference: \"blocknote-numbered-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.DECIMAL,\n text: `%${i + 1}.`,\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n {\n reference: \"blocknote-bullet-list\",\n levels: Array.from({ length: 9 }, (_, i) => ({\n start: 1,\n level: i,\n format: LevelFormat.BULLET,\n text: bullets[i % bullets.length],\n alignment: AlignmentType.LEFT,\n style: {\n paragraph: {\n indent: {\n left: DEFAULT_TAB_STOP * (i + 1),\n hanging: DEFAULT_TAB_STOP,\n },\n },\n },\n })),\n },\n ],\n },\n fonts: await this.getFonts(),\n defaultTabStop: 200,\n externalStyles,\n };\n }\n\n /**\n * Convert a document (array of Blocks to a Blob representing a .docx file)\n */\n public async toBlob(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = await this.toDocxJsDocument(blocks, options);\n type GlobalThis = typeof globalThis & { Buffer?: any };\n const prevBuffer = (globalThis as GlobalThis).Buffer;\n try {\n if (!(globalThis as GlobalThis).Buffer) {\n // load Buffer polyfill because docxjs requires this\n (globalThis as GlobalThis).Buffer = (\n await import(\"buffer\")\n ).default.Buffer;\n }\n return Packer.toBlob(doc);\n } finally {\n (globalThis as GlobalThis).Buffer = prevBuffer;\n }\n }\n\n /**\n * Convert a document (array of Blocks to a docxjs Document)\n */\n public async toDocxJsDocument(\n blocks: Block<B, I, S>[],\n options: {\n sectionOptions: Omit<ISectionOptions, \"children\">;\n documentOptions: DocumentOptions;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions()),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\n });\n\n // fix https://github.com/dolanmiu/docx/pull/2800/files\n doc.Document.Relationships.createRelationship(\n doc.Document.Relationships.RelationshipCount + 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\",\n \"fontTable.xml\",\n );\n\n return doc;\n }\n}\n"],"names":["getImageDimensions","blob","bmp","width","height","imageMetaFunc","bytes","meta","Table","data","headerRows","headerCols","DocxTable","w","row","rowIndex","isHeaderRow","TableRow","c","colIndex","_a","cell","mapTableCell","isHeaderColumn","TableCell","ShadingType","Paragraph","UnreachableCaseError","blockPropsToStyles","props","colors","docxBlockMappingForDefaultSchema","block","exporter","nestingLevel","CheckBox","TextRun","file","caption","textContent","line","index","PageBreak","ImageRun","defaultText","ExternalHyperlink","docxInlineContentMappingForDefaultSchema","ic","content","docxStyleMappingForDefaultSchema","val","docxDefaultSchemaMappings","corsProxyResolveFileUrl","url","loadFileBuffer","requireUrl","dataUrl","DEFAULT_TAB_STOP","DOCXExporter","Exporter","schema","mappings","options","newOptions","COLORS_DEFAULT","styledText","hyperlink","stylesArray","styles","blocks","ret","b","children","_i","Tab","self","interFont","geistMonoFont","Buffer","n","externalStyles","bullets","_","i","LevelFormat","AlignmentType","doc","prevBuffer","Packer","Document"],"mappings":";;AAAA,eAAsBA,EAAmBC,GAAY;AACnD,MAAI,OAAO,SAAW,KAAoD;AAClE,UAAAC,IAAM,MAAM,kBAAkBD,CAAI,GAClC,EAAE,OAAAE,GAAO,QAAAC,EAAA,IAAWF;AAC1B,WAAAA,EAAI,MAAM,GACH,EAAE,OAAAC,GAAO,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AAC1C,QAAA;AACE,aAAE,WAA0B,WAE7B,WAA0B,UACzB,MAAM,OAAO,QAAQ,GACrB,QAAQ,SAELC,EAAO,OAAOF,CAAG;AAAA,IAAA,UACxB;AACC,iBAA0B,SAASC;AAAA,IAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAMF,MAAa,iBACXlB,GACAP,IAGI;AAAA,IACF,gBAAgB,CAAC;AAAA,IACjB,iBAAiB,CAAA;AAAA,EAAC,GAEpB;AACM,UAAAwB,IAAM,IAAIG,EAAS;AAAA,MACvB,GAAI,MAAM,KAAK,6BAA6B;AAAA,MAC5C,GAAG3B,EAAQ;AAAA,MACX,UAAU;AAAA,QACR;AAAA,UACE,UAAU,MAAM,KAAK,gBAAgBO,CAAM;AAAA,UAC3C,GAAGP,EAAQ;AAAA,QAAA;AAAA,MACb;AAAA,IACF,CACD;AAGD,WAAAwB,EAAI,SAAS,cAAc;AAAA,MACzBA,EAAI,SAAS,cAAc,oBAAoB;AAAA,MAC/C;AAAA,MACA;AAAA,IACF,GAEOA;AAAA,EAAA;AAEX;"}
@@ -0,0 +1,7 @@
1
+ "use strict";function _r(c,f){for(var s=0;s<f.length;s++){const w=f[s];if(typeof w!="string"&&!Array.isArray(w)){for(const y in w)if(y!=="default"&&!(y in c)){const l=Object.getOwnPropertyDescriptor(w,y);l&&Object.defineProperty(c,y,l.get?l:{enumerable:!0,get:()=>w[y]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var ur={},j={};j.byteLength=br;j.toByteArray=Mr;j.fromByteArray=Pr;var _=[],R=[],Sr=typeof Uint8Array<"u"?Uint8Array:Array,H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var k=0,Lr=H.length;k<Lr;++k)_[k]=H[k],R[H.charCodeAt(k)]=k;R[45]=62;R[95]=63;function hr(c){var f=c.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=c.indexOf("=");s===-1&&(s=f);var w=s===f?0:4-s%4;return[s,w]}function br(c){var f=hr(c),s=f[0],w=f[1];return(s+w)*3/4-w}function Nr(c,f,s){return(f+s)*3/4-s}function Mr(c){var f,s=hr(c),w=s[0],y=s[1],l=new Sr(Nr(c,w,y)),p=0,o=y>0?w-4:w,B;for(B=0;B<o;B+=4)f=R[c.charCodeAt(B)]<<18|R[c.charCodeAt(B+1)]<<12|R[c.charCodeAt(B+2)]<<6|R[c.charCodeAt(B+3)],l[p++]=f>>16&255,l[p++]=f>>8&255,l[p++]=f&255;return y===2&&(f=R[c.charCodeAt(B)]<<2|R[c.charCodeAt(B+1)]>>4,l[p++]=f&255),y===1&&(f=R[c.charCodeAt(B)]<<10|R[c.charCodeAt(B+1)]<<4|R[c.charCodeAt(B+2)]>>2,l[p++]=f>>8&255,l[p++]=f&255),l}function kr(c){return _[c>>18&63]+_[c>>12&63]+_[c>>6&63]+_[c&63]}function Dr(c,f,s){for(var w,y=[],l=f;l<s;l+=3)w=(c[l]<<16&16711680)+(c[l+1]<<8&65280)+(c[l+2]&255),y.push(kr(w));return y.join("")}function Pr(c){for(var f,s=c.length,w=s%3,y=[],l=16383,p=0,o=s-w;p<o;p+=l)y.push(Dr(c,p,p+l>o?o:p+l));return w===1?(f=c[s-1],y.push(_[f>>2]+_[f<<4&63]+"==")):w===2&&(f=(c[s-2]<<8)+c[s-1],y.push(_[f>>10]+_[f>>4&63]+_[f<<2&63]+"=")),y.join("")}var V={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */V.read=function(c,f,s,w,y){var l,p,o=y*8-w-1,B=(1<<o)-1,T=B>>1,I=-7,F=s?y-1:0,S=s?-1:1,A=c[f+F];for(F+=S,l=A&(1<<-I)-1,A>>=-I,I+=o;I>0;l=l*256+c[f+F],F+=S,I-=8);for(p=l&(1<<-I)-1,l>>=-I,I+=w;I>0;p=p*256+c[f+F],F+=S,I-=8);if(l===0)l=1-T;else{if(l===B)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,w),l=l-T}return(A?-1:1)*p*Math.pow(2,l-w)};V.write=function(c,f,s,w,y,l){var p,o,B,T=l*8-y-1,I=(1<<T)-1,F=I>>1,S=y===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=w?0:l-1,D=w?1:-1,P=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(o=isNaN(f)?1:0,p=I):(p=Math.floor(Math.log(f)/Math.LN2),f*(B=Math.pow(2,-p))<1&&(p--,B*=2),p+F>=1?f+=S/B:f+=S*Math.pow(2,1-F),f*B>=2&&(p++,B/=2),p+F>=I?(o=0,p=I):p+F>=1?(o=(f*B-1)*Math.pow(2,y),p=p+F):(o=f*Math.pow(2,F-1)*Math.pow(2,y),p=0));y>=8;c[s+A]=o&255,A+=D,o/=256,y-=8);for(p=p<<y|o,T+=y;T>0;c[s+A]=p&255,A+=D,p/=256,T-=8);c[s+A-D]|=P*128};/*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */(function(c){const f=j,s=V,w=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.Buffer=o,c.SlowBuffer=cr,c.INSPECT_MAX_BYTES=50;const y=2147483647;c.kMaxLength=y,o.TYPED_ARRAY_SUPPORT=l(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const i=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(i,r),i.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function p(i){if(i>y)throw new RangeError('The value "'+i+'" is invalid for option "size"');const r=new Uint8Array(i);return Object.setPrototypeOf(r,o.prototype),r}function o(i,r,t){if(typeof i=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(i)}return B(i,r,t)}o.poolSize=8192;function B(i,r,t){if(typeof i=="string")return S(i,r);if(ArrayBuffer.isView(i))return D(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(C(i,ArrayBuffer)||i&&C(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(C(i,SharedArrayBuffer)||i&&C(i.buffer,SharedArrayBuffer)))return P(i,r,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const n=i.valueOf&&i.valueOf();if(n!=null&&n!==i)return o.from(n,r,t);const e=fr(i);if(e)return e;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return o.from(i[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}o.from=function(i,r,t){return B(i,r,t)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function T(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function I(i,r,t){return T(i),i<=0?p(i):r!==void 0?typeof t=="string"?p(i).fill(r,t):p(i).fill(r):p(i)}o.alloc=function(i,r,t){return I(i,r,t)};function F(i){return T(i),p(i<0?0:G(i)|0)}o.allocUnsafe=function(i){return F(i)},o.allocUnsafeSlow=function(i){return F(i)};function S(i,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const t=X(i,r)|0;let n=p(t);const e=n.write(i,r);return e!==t&&(n=n.slice(0,e)),n}function A(i){const r=i.length<0?0:G(i.length)|0,t=p(r);for(let n=0;n<r;n+=1)t[n]=i[n]&255;return t}function D(i){if(C(i,Uint8Array)){const r=new Uint8Array(i);return P(r.buffer,r.byteOffset,r.byteLength)}return A(i)}function P(i,r,t){if(r<0||i.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return r===void 0&&t===void 0?n=new Uint8Array(i):t===void 0?n=new Uint8Array(i,r):n=new Uint8Array(i,r,t),Object.setPrototypeOf(n,o.prototype),n}function fr(i){if(o.isBuffer(i)){const r=G(i.length)|0,t=p(r);return t.length===0||i.copy(t,0,0,r),t}if(i.length!==void 0)return typeof i.length!="number"||q(i.length)?p(0):A(i);if(i.type==="Buffer"&&Array.isArray(i.data))return A(i.data)}function G(i){if(i>=y)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+y.toString(16)+" bytes");return i|0}function cr(i){return+i!=i&&(i=0),o.alloc(+i)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,t){if(C(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),C(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(r)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,e=t.length;for(let u=0,h=Math.min(n,e);u<h;++u)if(r[u]!==t[u]){n=r[u],e=t[u];break}return n<e?-1:e<n?1:0},o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<r.length;++n)t+=r[n].length;const e=o.allocUnsafe(t);let u=0;for(n=0;n<r.length;++n){let h=r[n];if(C(h,Uint8Array))u+h.length>e.length?(o.isBuffer(h)||(h=o.from(h)),h.copy(e,u)):Uint8Array.prototype.set.call(e,h,u);else if(o.isBuffer(h))h.copy(e,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=h.length}return e};function X(i,r){if(o.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||C(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);const t=i.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let e=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return W(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return or(i).length;default:if(e)return n?-1:W(i).length;r=(""+r).toLowerCase(),e=!0}}o.byteLength=X;function pr(i,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(i||(i="utf8");;)switch(i){case"hex":return gr(this,r,t);case"utf8":case"utf-8":return K(this,r,t);case"ascii":return Er(this,r,t);case"latin1":case"binary":return dr(this,r,t);case"base64":return xr(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),n=!0}}o.prototype._isBuffer=!0;function b(i,r,t){const n=i[r];i[r]=i[t],i[t]=n}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)b(this,t,t+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?K(this,0,r):pr.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const t=c.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"},w&&(o.prototype[w]=o.prototype.inspect),o.prototype.compare=function(r,t,n,e,u){if(C(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),e===void 0&&(e=0),u===void 0&&(u=this.length),t<0||n>r.length||e<0||u>this.length)throw new RangeError("out of range index");if(e>=u&&t>=n)return 0;if(e>=u)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,e>>>=0,u>>>=0,this===r)return 0;let h=u-e,a=n-t;const d=Math.min(h,a),E=this.slice(e,u),g=r.slice(t,n);for(let x=0;x<d;++x)if(E[x]!==g[x]){h=E[x],a=g[x];break}return h<a?-1:a<h?1:0};function z(i,r,t,n,e){if(i.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,q(t)&&(t=e?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(e)return-1;t=i.length-1}else if(t<0)if(e)t=0;else return-1;if(typeof r=="string"&&(r=o.from(r,n)),o.isBuffer(r))return r.length===0?-1:J(i,r,t,n,e);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?e?Uint8Array.prototype.indexOf.call(i,r,t):Uint8Array.prototype.lastIndexOf.call(i,r,t):J(i,[r],t,n,e);throw new TypeError("val must be string, number or Buffer")}function J(i,r,t,n,e){let u=1,h=i.length,a=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(i.length<2||r.length<2)return-1;u=2,h/=2,a/=2,t/=2}function d(g,x){return u===1?g[x]:g.readUInt16BE(x*u)}let E;if(e){let g=-1;for(E=t;E<h;E++)if(d(i,E)===d(r,g===-1?0:E-g)){if(g===-1&&(g=E),E-g+1===a)return g*u}else g!==-1&&(E-=E-g),g=-1}else for(t+a>h&&(t=h-a),E=t;E>=0;E--){let g=!0;for(let x=0;x<a;x++)if(d(i,E+x)!==d(r,x)){g=!1;break}if(g)return E}return-1}o.prototype.includes=function(r,t,n){return this.indexOf(r,t,n)!==-1},o.prototype.indexOf=function(r,t,n){return z(this,r,t,n,!0)},o.prototype.lastIndexOf=function(r,t,n){return z(this,r,t,n,!1)};function sr(i,r,t,n){t=Number(t)||0;const e=i.length-t;n?(n=Number(n),n>e&&(n=e)):n=e;const u=r.length;n>u/2&&(n=u/2);let h;for(h=0;h<n;++h){const a=parseInt(r.substr(h*2,2),16);if(q(a))return h;i[t+h]=a}return h}function lr(i,r,t,n){return O(W(r,i.length-t),i,t,n)}function ar(i,r,t,n){return O(Ur(r),i,t,n)}function yr(i,r,t,n){return O(or(r),i,t,n)}function wr(i,r,t,n){return O(Rr(r,i.length-t),i,t,n)}o.prototype.write=function(r,t,n,e){if(t===void 0)e="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")e=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,e===void 0&&(e="utf8")):(e=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const u=this.length-t;if((n===void 0||n>u)&&(n=u),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");let h=!1;for(;;)switch(e){case"hex":return sr(this,r,t,n);case"utf8":case"utf-8":return lr(this,r,t,n);case"ascii":case"latin1":case"binary":return ar(this,r,t,n);case"base64":return yr(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wr(this,r,t,n);default:if(h)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),h=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function xr(i,r,t){return r===0&&t===i.length?f.fromByteArray(i):f.fromByteArray(i.slice(r,t))}function K(i,r,t){t=Math.min(i.length,t);const n=[];let e=r;for(;e<t;){const u=i[e];let h=null,a=u>239?4:u>223?3:u>191?2:1;if(e+a<=t){let d,E,g,x;switch(a){case 1:u<128&&(h=u);break;case 2:d=i[e+1],(d&192)===128&&(x=(u&31)<<6|d&63,x>127&&(h=x));break;case 3:d=i[e+1],E=i[e+2],(d&192)===128&&(E&192)===128&&(x=(u&15)<<12|(d&63)<<6|E&63,x>2047&&(x<55296||x>57343)&&(h=x));break;case 4:d=i[e+1],E=i[e+2],g=i[e+3],(d&192)===128&&(E&192)===128&&(g&192)===128&&(x=(u&15)<<18|(d&63)<<12|(E&63)<<6|g&63,x>65535&&x<1114112&&(h=x))}}h===null?(h=65533,a=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|h&1023),n.push(h),e+=a}return Br(n)}const Z=4096;function Br(i){const r=i.length;if(r<=Z)return String.fromCharCode.apply(String,i);let t="",n=0;for(;n<r;)t+=String.fromCharCode.apply(String,i.slice(n,n+=Z));return t}function Er(i,r,t){let n="";t=Math.min(i.length,t);for(let e=r;e<t;++e)n+=String.fromCharCode(i[e]&127);return n}function dr(i,r,t){let n="";t=Math.min(i.length,t);for(let e=r;e<t;++e)n+=String.fromCharCode(i[e]);return n}function gr(i,r,t){const n=i.length;(!r||r<0)&&(r=0),(!t||t<0||t>n)&&(t=n);let e="";for(let u=r;u<t;++u)e+=Tr[i[u]];return e}function mr(i,r,t){const n=i.slice(r,t);let e="";for(let u=0;u<n.length-1;u+=2)e+=String.fromCharCode(n[u]+n[u+1]*256);return e}o.prototype.slice=function(r,t){const n=this.length;r=~~r,t=t===void 0?n:~~t,r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<r&&(t=r);const e=this.subarray(r,t);return Object.setPrototypeOf(e,o.prototype),e};function m(i,r,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+r>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=this[r],u=1,h=0;for(;++h<t&&(u*=256);)e+=this[r+h]*u;return e},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=this[r+--t],u=1;for(;t>0&&(u*=256);)e+=this[r+--t]*u;return e},o.prototype.readUint8=o.prototype.readUInt8=function(r,t){return r=r>>>0,t||m(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||m(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||m(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||m(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||m(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&$(r,this.length-8);const e=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,u=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(e)+(BigInt(u)<<BigInt(32))}),o.prototype.readBigUInt64BE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&$(r,this.length-8);const e=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],u=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(e)<<BigInt(32))+BigInt(u)}),o.prototype.readIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=this[r],u=1,h=0;for(;++h<t&&(u*=256);)e+=this[r+h]*u;return u*=128,e>=u&&(e-=Math.pow(2,8*t)),e},o.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||m(r,t,this.length);let e=t,u=1,h=this[r+--e];for(;e>0&&(u*=256);)h+=this[r+--e]*u;return u*=128,h>=u&&(h-=Math.pow(2,8*t)),h},o.prototype.readInt8=function(r,t){return r=r>>>0,t||m(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,t){r=r>>>0,t||m(r,2,this.length);const n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n},o.prototype.readInt16BE=function(r,t){r=r>>>0,t||m(r,2,this.length);const n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n},o.prototype.readInt32LE=function(r,t){return r=r>>>0,t||m(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,t){return r=r>>>0,t||m(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&$(r,this.length-8);const e=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(e)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)}),o.prototype.readBigInt64BE=L(function(r){r=r>>>0,M(r,"offset");const t=this[r],n=this[r+7];(t===void 0||n===void 0)&&$(r,this.length-8);const e=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(e)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n)}),o.prototype.readFloatLE=function(r,t){return r=r>>>0,t||m(r,4,this.length),s.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,t){return r=r>>>0,t||m(r,4,this.length),s.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||m(r,8,this.length),s.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||m(r,8,this.length),s.read(this,r,!1,52,8)};function U(i,r,t,n,e,u){if(!o.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>e||r<u)throw new RangeError('"value" argument is out of bounds');if(t+n>i.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,n=n>>>0,!e){const a=Math.pow(2,8*n)-1;U(this,r,t,n,a,0)}let u=1,h=0;for(this[t]=r&255;++h<n&&(u*=256);)this[t+h]=r/u&255;return t+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,t,n,e){if(r=+r,t=t>>>0,n=n>>>0,!e){const a=Math.pow(2,8*n)-1;U(this,r,t,n,a,0)}let u=n-1,h=1;for(this[t+u]=r&255;--u>=0&&(h*=256);)this[t+u]=r/h&255;return t+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,1,255,0),this[t]=r&255,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function Q(i,r,t,n,e){er(r,n,e,i,t,7);let u=Number(r&BigInt(4294967295));i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u;let h=Number(r>>BigInt(32)&BigInt(4294967295));return i[t++]=h,h=h>>8,i[t++]=h,h=h>>8,i[t++]=h,h=h>>8,i[t++]=h,t}function v(i,r,t,n,e){er(r,n,e,i,t,7);let u=Number(r&BigInt(4294967295));i[t+7]=u,u=u>>8,i[t+6]=u,u=u>>8,i[t+5]=u,u=u>>8,i[t+4]=u;let h=Number(r>>BigInt(32)&BigInt(4294967295));return i[t+3]=h,h=h>>8,i[t+2]=h,h=h>>8,i[t+1]=h,h=h>>8,i[t]=h,t+8}o.prototype.writeBigUInt64LE=L(function(r,t=0){return Q(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=L(function(r,t=0){return v(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){const d=Math.pow(2,8*n-1);U(this,r,t,n,d-1,-d)}let u=0,h=1,a=0;for(this[t]=r&255;++u<n&&(h*=256);)r<0&&a===0&&this[t+u-1]!==0&&(a=1),this[t+u]=(r/h>>0)-a&255;return t+n},o.prototype.writeIntBE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){const d=Math.pow(2,8*n-1);U(this,r,t,n,d-1,-d)}let u=n-1,h=1,a=0;for(this[t+u]=r&255;--u>=0&&(h*=256);)r<0&&a===0&&this[t+u+1]!==0&&(a=1),this[t+u]=(r/h>>0)-a&255;return t+n},o.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1},o.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2},o.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2},o.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4},o.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||U(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4},o.prototype.writeBigInt64LE=L(function(r,t=0){return Q(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=L(function(r,t=0){return v(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function rr(i,r,t,n,e,u){if(t+n>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function tr(i,r,t,n,e){return r=+r,t=t>>>0,e||rr(i,r,t,4),s.write(i,r,t,n,23,4),t+4}o.prototype.writeFloatLE=function(r,t,n){return tr(this,r,t,!0,n)},o.prototype.writeFloatBE=function(r,t,n){return tr(this,r,t,!1,n)};function ir(i,r,t,n,e){return r=+r,t=t>>>0,e||rr(i,r,t,8),s.write(i,r,t,n,52,8),t+8}o.prototype.writeDoubleLE=function(r,t,n){return ir(this,r,t,!0,n)},o.prototype.writeDoubleBE=function(r,t,n){return ir(this,r,t,!1,n)},o.prototype.copy=function(r,t,n,e){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!e&&e!==0&&(e=this.length),t>=r.length&&(t=r.length),t||(t=0),e>0&&e<n&&(e=n),e===n||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),r.length-t<e-n&&(e=r.length-t+n);const u=e-n;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,e):Uint8Array.prototype.set.call(r,this.subarray(n,e),t),u},o.prototype.fill=function(r,t,n,e){if(typeof r=="string"){if(typeof t=="string"?(e=t,t=0,n=this.length):typeof n=="string"&&(e=n,n=this.length),e!==void 0&&typeof e!="string")throw new TypeError("encoding must be a string");if(typeof e=="string"&&!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);if(r.length===1){const h=r.charCodeAt(0);(e==="utf8"&&h<128||e==="latin1")&&(r=h)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let u;if(typeof r=="number")for(u=t;u<n;++u)this[u]=r;else{const h=o.isBuffer(r)?r:o.from(r,e),a=h.length;if(a===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=h[u%a]}return this};const N={};function Y(i,r,t){N[i]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}Y("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Y("ERR_INVALID_ARG_TYPE",function(i,r){return`The "${i}" argument must be of type number. Received type ${typeof r}`},TypeError),Y("ERR_OUT_OF_RANGE",function(i,r,t){let n=`The value of "${i}" is out of range.`,e=t;return Number.isInteger(t)&&Math.abs(t)>2**32?e=nr(String(t)):typeof t=="bigint"&&(e=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(e=nr(e)),e+="n"),n+=` It must be ${r}. Received ${e}`,n},RangeError);function nr(i){let r="",t=i.length;const n=i[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${i.slice(t-3,t)}${r}`;return`${i.slice(0,t)}${r}`}function Ir(i,r,t){M(r,"offset"),(i[r]===void 0||i[r+t]===void 0)&&$(r,i.length-(t+1))}function er(i,r,t,n,e,u){if(i>t||i<r){const h=typeof r=="bigint"?"n":"";let a;throw r===0||r===BigInt(0)?a=`>= 0${h} and < 2${h} ** ${(u+1)*8}${h}`:a=`>= -(2${h} ** ${(u+1)*8-1}${h}) and < 2 ** ${(u+1)*8-1}${h}`,new N.ERR_OUT_OF_RANGE("value",a,i)}Ir(n,e,u)}function M(i,r){if(typeof i!="number")throw new N.ERR_INVALID_ARG_TYPE(r,"number",i)}function $(i,r,t){throw Math.floor(i)!==i?(M(i,t),new N.ERR_OUT_OF_RANGE("offset","an integer",i)):r<0?new N.ERR_BUFFER_OUT_OF_BOUNDS:new N.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,i)}const Fr=/[^+/0-9A-Za-z-_]/g;function Ar(i){if(i=i.split("=")[0],i=i.trim().replace(Fr,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function W(i,r){r=r||1/0;let t;const n=i.length;let e=null;const u=[];for(let h=0;h<n;++h){if(t=i.charCodeAt(h),t>55295&&t<57344){if(!e){if(t>56319){(r-=3)>-1&&u.push(239,191,189);continue}else if(h+1===n){(r-=3)>-1&&u.push(239,191,189);continue}e=t;continue}if(t<56320){(r-=3)>-1&&u.push(239,191,189),e=t;continue}t=(e-55296<<10|t-56320)+65536}else e&&(r-=3)>-1&&u.push(239,191,189);if(e=null,t<128){if((r-=1)<0)break;u.push(t)}else if(t<2048){if((r-=2)<0)break;u.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;u.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;u.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return u}function Ur(i){const r=[];for(let t=0;t<i.length;++t)r.push(i.charCodeAt(t)&255);return r}function Rr(i,r){let t,n,e;const u=[];for(let h=0;h<i.length&&!((r-=2)<0);++h)t=i.charCodeAt(h),n=t>>8,e=t%256,u.push(e),u.push(n);return u}function or(i){return f.toByteArray(Ar(i))}function O(i,r,t,n){let e;for(e=0;e<n&&!(e+t>=r.length||e>=i.length);++e)r[e+t]=i[e];return e}function C(i,r){return i instanceof r||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===r.name}function q(i){return i!==i}const Tr=function(){const i="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){const n=t*16;for(let e=0;e<16;++e)r[n+e]=i[t]+i[e]}return r}();function L(i){return typeof BigInt>"u"?Cr:i}function Cr(){throw new Error("BigInt not supported")}})(ur);const $r=_r({__proto__:null},[ur]);exports.index=$r;
7
+ //# sourceMappingURL=index-B-FmPo2r.cjs.map