@blocknote/xl-docx-exporter 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 TableCell,\n TableRow,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\nimport { multiColumnSchema } from \"@blocknote/xl-multi-column\";\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 &\n typeof pageBreakSchema.blockSchema &\n typeof multiColumnSchema.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 toggleListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new TextRun({\n children: [\"> \"],\n }),\n ...exporter.transformInlineContent(block.content),\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 column: (block, _exporter, _nestingLevel, _numberedListIndex, children) => {\n return new TableCell({\n width: {\n size: `${block.props.width * 100}%`,\n type: \"pct\",\n },\n children: (children || []).flatMap((child) => {\n if (Array.isArray(child)) {\n return child;\n }\n\n return [child];\n }),\n }) as any;\n },\n columnList: (\n _block,\n _exporter,\n _nestingLevel,\n _numberedListIndex,\n children,\n ) => {\n return new DocxTable({\n layout: \"autofit\",\n borders: {\n bottom: { style: \"nil\" },\n top: { style: \"nil\" },\n left: { style: \"nil\" },\n right: { style: \"nil\" },\n insideHorizontal: { style: \"nil\" },\n insideVertical: { style: \"nil\" },\n },\n rows: [\n new TableRow({\n children: (children as unknown as TableCell[]).map(\n (cell, _index, children) => {\n return new TableCell({\n width: {\n size: `${(parseFloat(`${cell.options.width?.size || \"100%\"}`) / (children.length * 100)) * 100}%`,\n type: \"pct\",\n },\n children: cell.options.children,\n });\n },\n ),\n }),\n ],\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 // On Windows, vite/vitest may yield paths like \"/C:/...\" after removing /@fs\n // Node on Windows treats paths starting with \"/\" as relative to current drive,\n // which would produce \"C:\\C:\\...\". Strip leading slash when followed by a drive letter.\n if (/^\\/[A-Za-z]:/.test(url)) {\n url = url.slice(1);\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\n if (![\"columnList\", \"column\"].includes(b.type)) {\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 }\n\n const self = await this.mapBlock(\n b as any,\n nestingLevel,\n 0 /*unused*/,\n children,\n ); // TODO: any\n if ([\"columnList\", \"column\"].includes(b.type)) {\n ret.push(self as Table);\n } else 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(\n locale?: string,\n ): Promise<DocumentOptions> {\n let externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n // Replace the default language in styles.xml with the provided locale.\n // If not provided, default to en-US.\n const resolvedLocale = (locale && locale.trim()) || \"en-US\";\n\n externalStyles = externalStyles.replace(\n /(<w:lang\\b[^>]*\\bw:val=\")([^\"]+)(\"[^>]*\\/>)/g,\n `$1${resolvedLocale}$3`,\n );\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions(options.locale)),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\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","TextRun","nestingLevel","CheckBox","file","caption","textContent","line","index","PageBreak","_exporter","_nestingLevel","_numberedListIndex","children","child","_block","_index","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","_i","Tab","self","interFont","geistMonoFont","Buffer","n","locale","externalStyles","resolvedLocale","bullets","_","i","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,EA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AAQP,CAAO,EAEjD0B,EAAc,WAA0B,OAC1C,GAAA,CACE,OAAE,WAA0B,SAE7B,WAA0B,QACzB,KAAM,QAAO,QAAQ,GACrB,QAAQ,QAELC,EAAA,OAAO,OAAOF,CAAG,CAAA,QACxB,CACC,WAA0B,OAASC,CAAA,CACtC,CAMF,MAAa,iBACXnB,EACAP,EAQI,CACF,eAAgB,CAAC,EACjB,gBAAiB,CAAA,CAAC,EAEpB,CAYO,OAXK,IAAI4B,WAAS,CACvB,GAAI,MAAM,KAAK,6BAA6B5B,EAAQ,MAAM,EAC1D,GAAGA,EAAQ,gBACX,SAAU,CACR,CACE,SAAU,MAAM,KAAK,gBAAgBO,CAAM,EAC3C,GAAGP,EAAQ,cAAA,CACb,CACF,CACD,CAEM,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 createPageBreakBlockConfig,\n DefaultBlockSchema,\n DefaultProps,\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 TableCell,\n TableRow,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\nimport { multiColumnSchema } from \"@blocknote/xl-multi-column\";\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 & {\n pageBreak: ReturnType<typeof createPageBreakBlockConfig>;\n } & typeof multiColumnSchema.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 toggleListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new TextRun({\n children: [\"> \"],\n }),\n ...exporter.transformInlineContent(block.content),\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 as 1 | 2 | 3 | 4 | 5 | 6}`,\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 column: (block, _exporter, _nestingLevel, _numberedListIndex, children) => {\n return new TableCell({\n width: {\n size: `${block.props.width * 100}%`,\n type: \"pct\",\n },\n children: (children || []).flatMap((child) => {\n if (Array.isArray(child)) {\n return child;\n }\n\n return [child];\n }),\n }) as any;\n },\n columnList: (\n _block,\n _exporter,\n _nestingLevel,\n _numberedListIndex,\n children,\n ) => {\n return new DocxTable({\n layout: \"autofit\",\n borders: {\n bottom: { style: \"nil\" },\n top: { style: \"nil\" },\n left: { style: \"nil\" },\n right: { style: \"nil\" },\n insideHorizontal: { style: \"nil\" },\n insideVertical: { style: \"nil\" },\n },\n rows: [\n new TableRow({\n children: (children as unknown as TableCell[]).map(\n (cell, _index, children) => {\n return new TableCell({\n width: {\n size: `${(parseFloat(`${cell.options.width?.size || \"100%\"}`) / (children.length * 100)) * 100}%`,\n type: \"pct\",\n },\n children: cell.options.children,\n });\n },\n ),\n }),\n ],\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 // On Windows, vite/vitest may yield paths like \"/C:/...\" after removing /@fs\n // Node on Windows treats paths starting with \"/\" as relative to current drive,\n // which would produce \"C:\\C:\\...\". Strip leading slash when followed by a drive letter.\n if (/^\\/[A-Za-z]:/.test(url)) {\n url = url.slice(1);\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\n if (![\"columnList\", \"column\"].includes(b.type)) {\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 }\n\n const self = await this.mapBlock(\n b as any,\n nestingLevel,\n 0 /*unused*/,\n children,\n ); // TODO: any\n if ([\"columnList\", \"column\"].includes(b.type)) {\n ret.push(self as Table);\n } else 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(\n locale?: string,\n ): Promise<DocumentOptions> {\n let externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n // Replace the default language in styles.xml with the provided locale.\n // If not provided, default to en-US.\n const resolvedLocale = (locale && locale.trim()) || \"en-US\";\n\n externalStyles = externalStyles.replace(\n /(<w:lang\\b[^>]*\\bw:val=\")([^\"]+)(\"[^>]*\\/>)/g,\n `$1${resolvedLocale}$3`,\n );\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions(options.locale)),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\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","TextRun","nestingLevel","CheckBox","file","caption","textContent","line","index","PageBreak","_exporter","_nestingLevel","_numberedListIndex","children","child","_block","_index","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","_i","Tab","self","interFont","geistMonoFont","Buffer","n","locale","externalStyles","resolvedLocale","bullets","_","i","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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,OAAQC,EAAY,YAAA,OACpB,KAAMH,EAAQE,EAAIF,EAAQ,MAAM,EAChC,UAAWI,EAAc,cAAA,KACzB,MAAO,CACL,UAAW,CACT,OAAQ,CACN,KAAM7B,GAAoB2B,EAAI,GAC9B,QAAS3B,CAAA,CACX,CACF,CACF,EACA,CAAA,CACJ,CAEJ,EACA,MAAO,MAAM,KAAK,SAAS,EAC3B,eAAgB,IAChB,eAAAuB,CACF,CAAA,CAMF,MAAa,OACXX,EACAP,EAQI,CACF,eAAgB,CAAC,EACjB,gBAAiB,CAAA,CAAC,EAEpB,CACA,MAAMyB,EAAM,MAAM,KAAK,iBAAiBlB,EAAQP,CAAO,EAEjD0B,EAAc,WAA0B,OAC1C,GAAA,CACE,OAAE,WAA0B,SAE7B,WAA0B,QACzB,KAAM,QAAO,QAAQ,GACrB,QAAQ,QAELC,EAAA,OAAO,OAAOF,CAAG,CAAA,QACxB,CACC,WAA0B,OAASC,CAAA,CACtC,CAMF,MAAa,iBACXnB,EACAP,EAQI,CACF,eAAgB,CAAC,EACjB,gBAAiB,CAAA,CAAC,EAEpB,CAYO,OAXK,IAAI4B,WAAS,CACvB,GAAI,MAAM,KAAK,6BAA6B5B,EAAQ,MAAM,EAC1D,GAAGA,EAAQ,gBACX,SAAU,CACR,CACE,SAAU,MAAM,KAAK,gBAAgBO,CAAM,EAC3C,GAAGP,EAAQ,cAAA,CACb,CACF,CACD,CAEM,CAEX"}
@@ -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 TableCell,\n TableRow,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\nimport { multiColumnSchema } from \"@blocknote/xl-multi-column\";\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 &\n typeof pageBreakSchema.blockSchema &\n typeof multiColumnSchema.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 toggleListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new TextRun({\n children: [\"> \"],\n }),\n ...exporter.transformInlineContent(block.content),\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 column: (block, _exporter, _nestingLevel, _numberedListIndex, children) => {\n return new TableCell({\n width: {\n size: `${block.props.width * 100}%`,\n type: \"pct\",\n },\n children: (children || []).flatMap((child) => {\n if (Array.isArray(child)) {\n return child;\n }\n\n return [child];\n }),\n }) as any;\n },\n columnList: (\n _block,\n _exporter,\n _nestingLevel,\n _numberedListIndex,\n children,\n ) => {\n return new DocxTable({\n layout: \"autofit\",\n borders: {\n bottom: { style: \"nil\" },\n top: { style: \"nil\" },\n left: { style: \"nil\" },\n right: { style: \"nil\" },\n insideHorizontal: { style: \"nil\" },\n insideVertical: { style: \"nil\" },\n },\n rows: [\n new TableRow({\n children: (children as unknown as TableCell[]).map(\n (cell, _index, children) => {\n return new TableCell({\n width: {\n size: `${(parseFloat(`${cell.options.width?.size || \"100%\"}`) / (children.length * 100)) * 100}%`,\n type: \"pct\",\n },\n children: cell.options.children,\n });\n },\n ),\n }),\n ],\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 // On Windows, vite/vitest may yield paths like \"/C:/...\" after removing /@fs\n // Node on Windows treats paths starting with \"/\" as relative to current drive,\n // which would produce \"C:\\C:\\...\". Strip leading slash when followed by a drive letter.\n if (/^\\/[A-Za-z]:/.test(url)) {\n url = url.slice(1);\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\n if (![\"columnList\", \"column\"].includes(b.type)) {\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 }\n\n const self = await this.mapBlock(\n b as any,\n nestingLevel,\n 0 /*unused*/,\n children,\n ); // TODO: any\n if ([\"columnList\", \"column\"].includes(b.type)) {\n ret.push(self as Table);\n } else 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(\n locale?: string,\n ): Promise<DocumentOptions> {\n let externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n // Replace the default language in styles.xml with the provided locale.\n // If not provided, default to en-US.\n const resolvedLocale = (locale && locale.trim()) || \"en-US\";\n\n externalStyles = externalStyles.replace(\n /(<w:lang\\b[^>]*\\bw:val=\")([^\"]+)(\"[^>]*\\/>)/g,\n `$1${resolvedLocale}$3`,\n );\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions(options.locale)),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\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","TextRun","nestingLevel","CheckBox","file","caption","textContent","line","index","PageBreak","_exporter","_nestingLevel","_numberedListIndex","children","child","_block","_index","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","_i","Tab","self","interFont","geistMonoFont","Buffer","n","locale","externalStyles","resolvedLocale","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,EAA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AAAA,oBAC9B,SAAS3B;AAAA,kBAAA;AAAA,gBACX;AAAA,cACF;AAAA,YACF,EACA;AAAA,UAAA;AAAA,QACJ;AAAA,MAEJ;AAAA,MACA,OAAO,MAAM,KAAK,SAAS;AAAA,MAC3B,gBAAgB;AAAA,MAChB,gBAAAuB;AAAA,IACF;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMF,MAAa,OACXX,GACAP,IAQI;AAAA,IACF,gBAAgB,CAAC;AAAA,IACjB,iBAAiB,CAAA;AAAA,EAAC,GAEpB;AACA,UAAMyB,IAAM,MAAM,KAAK,iBAAiBlB,GAAQP,CAAO,GAEjD0B,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,iBACXnB,GACAP,IAQI;AAAA,IACF,gBAAgB,CAAC;AAAA,IACjB,iBAAiB,CAAA;AAAA,EAAC,GAEpB;AAYO,WAXK,IAAI4B,EAAS;AAAA,MACvB,GAAI,MAAM,KAAK,6BAA6B5B,EAAQ,MAAM;AAAA,MAC1D,GAAGA,EAAQ;AAAA,MACX,UAAU;AAAA,QACR;AAAA,UACE,UAAU,MAAM,KAAK,gBAAgBO,CAAM;AAAA,UAC3C,GAAGP,EAAQ;AAAA,QAAA;AAAA,MACb;AAAA,IACF,CACD;AAAA,EAEM;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 createPageBreakBlockConfig,\n DefaultBlockSchema,\n DefaultProps,\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 TableCell,\n TableRow,\n TextRun,\n} from \"docx\";\nimport { Table } from \"../util/Table.js\";\nimport { multiColumnSchema } from \"@blocknote/xl-multi-column\";\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 & {\n pageBreak: ReturnType<typeof createPageBreakBlockConfig>;\n } & typeof multiColumnSchema.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 toggleListItem: (block, exporter) => {\n return new Paragraph({\n ...blockPropsToStyles(block.props, exporter.options.colors),\n children: [\n new TextRun({\n children: [\"> \"],\n }),\n ...exporter.transformInlineContent(block.content),\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 as 1 | 2 | 3 | 4 | 5 | 6}`,\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 column: (block, _exporter, _nestingLevel, _numberedListIndex, children) => {\n return new TableCell({\n width: {\n size: `${block.props.width * 100}%`,\n type: \"pct\",\n },\n children: (children || []).flatMap((child) => {\n if (Array.isArray(child)) {\n return child;\n }\n\n return [child];\n }),\n }) as any;\n },\n columnList: (\n _block,\n _exporter,\n _nestingLevel,\n _numberedListIndex,\n children,\n ) => {\n return new DocxTable({\n layout: \"autofit\",\n borders: {\n bottom: { style: \"nil\" },\n top: { style: \"nil\" },\n left: { style: \"nil\" },\n right: { style: \"nil\" },\n insideHorizontal: { style: \"nil\" },\n insideVertical: { style: \"nil\" },\n },\n rows: [\n new TableRow({\n children: (children as unknown as TableCell[]).map(\n (cell, _index, children) => {\n return new TableCell({\n width: {\n size: `${(parseFloat(`${cell.options.width?.size || \"100%\"}`) / (children.length * 100)) * 100}%`,\n type: \"pct\",\n },\n children: cell.options.children,\n });\n },\n ),\n }),\n ],\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 // On Windows, vite/vitest may yield paths like \"/C:/...\" after removing /@fs\n // Node on Windows treats paths starting with \"/\" as relative to current drive,\n // which would produce \"C:\\C:\\...\". Strip leading slash when followed by a drive letter.\n if (/^\\/[A-Za-z]:/.test(url)) {\n url = url.slice(1);\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\n if (![\"columnList\", \"column\"].includes(b.type)) {\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 }\n\n const self = await this.mapBlock(\n b as any,\n nestingLevel,\n 0 /*unused*/,\n children,\n ); // TODO: any\n if ([\"columnList\", \"column\"].includes(b.type)) {\n ret.push(self as Table);\n } else 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(\n locale?: string,\n ): Promise<DocumentOptions> {\n let externalStyles = (await import(\"./template/word/styles.xml?raw\"))\n .default;\n\n // Replace the default language in styles.xml with the provided locale.\n // If not provided, default to en-US.\n const resolvedLocale = (locale && locale.trim()) || \"en-US\";\n\n externalStyles = externalStyles.replace(\n /(<w:lang\\b[^>]*\\bw:val=\")([^\"]+)(\"[^>]*\\/>)/g,\n `$1${resolvedLocale}$3`,\n );\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\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 * The document locale in OOXML format (e.g. en-US, fr-FR, de-DE).\n * If omitted, defaults to en-US.\n */\n locale?: string;\n } = {\n sectionOptions: {},\n documentOptions: {},\n },\n ) {\n const doc = new Document({\n ...(await this.createDefaultDocumentOptions(options.locale)),\n ...options.documentOptions,\n sections: [\n {\n children: await this.transformBlocks(blocks),\n ...options.sectionOptions,\n },\n ],\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","TextRun","nestingLevel","CheckBox","file","caption","textContent","line","index","PageBreak","_exporter","_nestingLevel","_numberedListIndex","children","child","_block","_index","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","_i","Tab","self","interFont","geistMonoFont","Buffer","n","locale","externalStyles","resolvedLocale","bullets","_","i","LevelFormat","AlignmentType","doc","prevBuffer","Packer","Document"],"mappings":";;AAAA,eAAsBA,EAAmBC,GAAY;AACnD,MAAI,OAAO,SAAW,KAAoD;AAClE,UAAAC,IAAM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{"name":"GeistMono-Regular--NrcstcO.cjs","size":155187},{"name":"index-B-FmPo2r.cjs","size":28104},{"name":"styles-C7c5RlKz.cjs","size":55568},{"name":"styles-C7c5RlKz.cjs.map","size":72356},{"name":"GeistMono-Regular--NrcstcO.cjs.map","size":155239},{"name":"index-B-FmPo2r.cjs.map","size":109769},{"name":"Inter_18pt-Regular-CCMUw8TC.cjs.map","size":457156},{"name":"blocknote-xl-docx-exporter.cjs.map","size":38575}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-docx-exporter.cjs"],"names":["blocknote-xl-docx-exporter"]},{"id":"b6f14fb","entry":false,"initial":false,"files":["Inter_18pt-Regular-CCMUw8TC.cjs"],"names":["Inter_18pt-Regular"]},{"id":"642be88","entry":false,"initial":false,"files":["GeistMono-Regular--NrcstcO.cjs"],"names":["GeistMono-Regular"]},{"id":"d3d6f02","entry":false,"initial":false,"files":["index-B-FmPo2r.cjs"],"names":["index"]},{"id":"714dba6","entry":false,"initial":false,"files":["styles-C7c5RlKz.cjs"],"names":["styles"]}],"modules":[{"name":"../../shared/util/imageUtil.ts","size":592,"chunks":["a1ee98a"]},{"name":"./src/docx/util/Table.tsx","size":2384,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/blocks.ts","size":7146,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/inlinecontent.ts","size":363,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/styles.ts","size":941,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/index.ts","size":203,"chunks":["a1ee98a"]},{"name":"../../shared/api/corsProxy.ts","size":139,"chunks":["a1ee98a"]},{"name":"../../shared/util/fileUtil.ts","size":214,"chunks":["a1ee98a"]},{"name":"./src/docx/docxExporter.ts","size":5471,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"../../shared/assets/fonts/inter/Inter_18pt-Regular.ttf","size":456958,"chunks":["b6f14fb"]},{"name":"../../shared/assets/fonts/GeistMono-Regular.ttf","size":155049,"chunks":["642be88"]},{"name":"../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js?commonjs-exports","size":16,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js?commonjs-exports","size":18,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js","size":3969,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js?commonjs-exports","size":17,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js","size":2201,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js","size":60535,"chunks":["d3d6f02"]},{"name":"./src/docx/template/word/styles.xml?raw","size":59368,"chunks":["714dba6"]}]}
1
+ {"builtAt":1758181095381,"assets":[{"name":"blocknote-xl-docx-exporter.cjs","size":8924},{"name":"Inter_18pt-Regular-CCMUw8TC.cjs","size":457096},{"name":"GeistMono-Regular--NrcstcO.cjs","size":155187},{"name":"index-B-FmPo2r.cjs","size":28104},{"name":"styles-C7c5RlKz.cjs","size":55568},{"name":"styles-C7c5RlKz.cjs.map","size":72356},{"name":"GeistMono-Regular--NrcstcO.cjs.map","size":155239},{"name":"index-B-FmPo2r.cjs.map","size":109769},{"name":"Inter_18pt-Regular-CCMUw8TC.cjs.map","size":457156},{"name":"blocknote-xl-docx-exporter.cjs.map","size":38637}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-docx-exporter.cjs"],"names":["blocknote-xl-docx-exporter"]},{"id":"b6f14fb","entry":false,"initial":false,"files":["Inter_18pt-Regular-CCMUw8TC.cjs"],"names":["Inter_18pt-Regular"]},{"id":"642be88","entry":false,"initial":false,"files":["GeistMono-Regular--NrcstcO.cjs"],"names":["GeistMono-Regular"]},{"id":"d3d6f02","entry":false,"initial":false,"files":["index-B-FmPo2r.cjs"],"names":["index"]},{"id":"714dba6","entry":false,"initial":false,"files":["styles-C7c5RlKz.cjs"],"names":["styles"]}],"modules":[{"name":"../../shared/util/imageUtil.ts","size":592,"chunks":["a1ee98a"]},{"name":"./src/docx/util/Table.tsx","size":2384,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/blocks.ts","size":7146,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/inlinecontent.ts","size":363,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/styles.ts","size":941,"chunks":["a1ee98a"]},{"name":"./src/docx/defaultSchema/index.ts","size":203,"chunks":["a1ee98a"]},{"name":"../../shared/api/corsProxy.ts","size":139,"chunks":["a1ee98a"]},{"name":"../../shared/util/fileUtil.ts","size":214,"chunks":["a1ee98a"]},{"name":"./src/docx/docxExporter.ts","size":5471,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"../../shared/assets/fonts/inter/Inter_18pt-Regular.ttf","size":456958,"chunks":["b6f14fb"]},{"name":"../../shared/assets/fonts/GeistMono-Regular.ttf","size":155049,"chunks":["642be88"]},{"name":"../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js?commonjs-exports","size":16,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js?commonjs-exports","size":18,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js","size":3969,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js?commonjs-exports","size":17,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js","size":2201,"chunks":["d3d6f02"]},{"name":"../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js","size":60535,"chunks":["d3d6f02"]},{"name":"./src/docx/template/word/styles.xml?raw","size":59368,"chunks":["714dba6"]}]}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "directory": "packages/xl-docx-exporter"
10
10
  },
11
11
  "license": "GPL-3.0 OR PROPRIETARY",
12
- "version": "0.38.0",
12
+ "version": "0.39.0",
13
13
  "files": [
14
14
  "dist",
15
15
  "types",
@@ -49,8 +49,8 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@blocknote/core": "0.38.0",
53
- "@blocknote/xl-multi-column": "0.38.0",
52
+ "@blocknote/core": "0.39.0",
53
+ "@blocknote/xl-multi-column": "0.39.0",
54
54
  "buffer": "^6.0.3",
55
55
  "docx": "^9.0.2",
56
56
  "image-meta": "^0.2.1"
@@ -60,14 +60,14 @@
60
60
  "@types/react-dom": "^19.1.0",
61
61
  "@zip.js/zip.js": "^2.7.57",
62
62
  "eslint": "^8.10.0",
63
+ "react": "^19.1.0",
64
+ "react-dom": "^19.1.0",
63
65
  "rollup-plugin-webpack-stats": "^0.2.2",
64
66
  "typescript": "^5.0.4",
65
67
  "vite": "^5.3.4",
66
68
  "vite-plugin-eslint": "^1.8.1",
67
69
  "vitest": "^2.0.3",
68
- "xml-formatter": "^3.6.3",
69
- "react": "^19.1.0",
70
- "react-dom": "^19.1.0"
70
+ "xml-formatter": "^3.6.3"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "react": "^18.0 || ^19.0 || >= 19.0.0-rc",
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  BlockMapping,
3
3
  COLORS_DEFAULT,
4
+ createPageBreakBlockConfig,
4
5
  DefaultBlockSchema,
5
6
  DefaultProps,
6
- pageBreakSchema,
7
7
  StyledText,
8
8
  UnreachableCaseError,
9
9
  } from "@blocknote/core";
@@ -61,9 +61,9 @@ function blockPropsToStyles(
61
61
  };
62
62
  }
63
63
  export const docxBlockMappingForDefaultSchema: BlockMapping<
64
- DefaultBlockSchema &
65
- typeof pageBreakSchema.blockSchema &
66
- typeof multiColumnSchema.blockSchema,
64
+ DefaultBlockSchema & {
65
+ pageBreak: ReturnType<typeof createPageBreakBlockConfig>;
66
+ } & typeof multiColumnSchema.blockSchema,
67
67
  any,
68
68
  any,
69
69
  | Promise<Paragraph[] | Paragraph | DocxTable>
@@ -129,7 +129,7 @@ export const docxBlockMappingForDefaultSchema: BlockMapping<
129
129
  return new Paragraph({
130
130
  ...blockPropsToStyles(block.props, exporter.options.colors),
131
131
  children: exporter.transformInlineContent(block.content),
132
- heading: `Heading${block.props.level}`,
132
+ heading: `Heading${block.props.level as 1 | 2 | 3 | 4 | 5 | 6}`,
133
133
  });
134
134
  },
135
135
  quote: (block, exporter) => {
@@ -1,4 +1,8 @@
1
- import { BlockNoteSchema, defaultBlockSpecs, PageBreak } from "@blocknote/core";
1
+ import {
2
+ BlockNoteSchema,
3
+ defaultBlockSpecs,
4
+ createPageBreakBlockSpec,
5
+ } from "@blocknote/core";
2
6
  import { testDocument } from "@shared/testDocument.js";
3
7
  import { BlobReader, Entry, TextWriter, ZipReader } from "@zip.js/zip.js";
4
8
  import { Packer, Paragraph, TextRun } from "docx";
@@ -24,7 +28,10 @@ describe("exporter", () => {
24
28
  it("should export a document", { timeout: 10000 }, async () => {
25
29
  const exporter = new DOCXExporter(
26
30
  BlockNoteSchema.create({
27
- blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak },
31
+ blockSpecs: {
32
+ ...defaultBlockSpecs,
33
+ pageBreak: createPageBreakBlockSpec(),
34
+ },
28
35
  }),
29
36
  docxDefaultSchemaMappings,
30
37
  );
@@ -54,7 +61,10 @@ describe("exporter", () => {
54
61
  async () => {
55
62
  const exporter = new DOCXExporter(
56
63
  BlockNoteSchema.create({
57
- blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak },
64
+ blockSpecs: {
65
+ ...defaultBlockSpecs,
66
+ pageBreak: createPageBreakBlockSpec(),
67
+ },
58
68
  }),
59
69
  docxDefaultSchemaMappings,
60
70
  );
@@ -124,7 +134,7 @@ describe("exporter", () => {
124
134
  const schema = BlockNoteSchema.create({
125
135
  blockSpecs: {
126
136
  ...defaultBlockSpecs,
127
- pageBreak: PageBreak,
137
+ pageBreak: createPageBreakBlockSpec(),
128
138
  column: ColumnBlock,
129
139
  columnList: ColumnListBlock,
130
140
  },
@@ -1,4 +1,6 @@
1
- import { BlockMapping, DefaultBlockSchema, pageBreakSchema } from "@blocknote/core";
1
+ import { BlockMapping, createPageBreakBlockConfig, DefaultBlockSchema } from "@blocknote/core";
2
2
  import { Table as DocxTable, Paragraph, ParagraphChild } from "docx";
3
3
  import { multiColumnSchema } from "@blocknote/xl-multi-column";
4
- export declare const docxBlockMappingForDefaultSchema: BlockMapping<DefaultBlockSchema & typeof pageBreakSchema.blockSchema & typeof multiColumnSchema.blockSchema, any, any, Promise<Paragraph[] | Paragraph | DocxTable> | Paragraph[] | Paragraph | DocxTable, ParagraphChild>;
4
+ export declare const docxBlockMappingForDefaultSchema: BlockMapping<DefaultBlockSchema & {
5
+ pageBreak: ReturnType<typeof createPageBreakBlockConfig>;
6
+ } & typeof multiColumnSchema.blockSchema, any, any, Promise<Paragraph[] | Paragraph | DocxTable> | Paragraph[] | Paragraph | DocxTable, ParagraphChild>;
@@ -1,577 +1,13 @@
1
1
  export declare const docxDefaultSchemaMappings: {
2
- blockMapping: import("@blocknote/core").BlockMapping<import("@blocknote/core").BlockSchemaFromSpecs<{
3
- paragraph: {
4
- config: {
5
- type: "paragraph";
6
- content: "inline";
7
- propSchema: {
8
- backgroundColor: {
9
- default: "default";
10
- };
11
- textColor: {
12
- default: "default";
13
- };
14
- textAlignment: {
15
- default: "left";
16
- values: readonly ["left", "center", "right", "justify"];
17
- };
18
- };
19
- };
20
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
21
- type: "paragraph";
22
- content: "inline";
23
- propSchema: {
24
- backgroundColor: {
25
- default: "default";
26
- };
27
- textColor: {
28
- default: "default";
29
- };
30
- textAlignment: {
31
- default: "left";
32
- values: readonly ["left", "center", "right", "justify"];
33
- };
34
- };
35
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
36
- };
37
- heading: {
38
- config: {
39
- type: "heading";
40
- content: "inline";
41
- propSchema: {
42
- level: {
43
- default: number;
44
- values: readonly [1, 2, 3, 4, 5, 6];
45
- };
46
- isToggleable: {
47
- default: false;
48
- };
49
- backgroundColor: {
50
- default: "default";
51
- };
52
- textColor: {
53
- default: "default";
54
- };
55
- textAlignment: {
56
- default: "left";
57
- values: readonly ["left", "center", "right", "justify"];
58
- };
59
- };
60
- };
61
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
62
- type: "heading";
63
- content: "inline";
64
- propSchema: {
65
- level: {
66
- default: number;
67
- values: readonly [1, 2, 3, 4, 5, 6];
68
- };
69
- isToggleable: {
70
- default: false;
71
- };
72
- backgroundColor: {
73
- default: "default";
74
- };
75
- textColor: {
76
- default: "default";
77
- };
78
- textAlignment: {
79
- default: "left";
80
- values: readonly ["left", "center", "right", "justify"];
81
- };
82
- };
83
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
84
- };
85
- quote: {
86
- config: {
87
- type: "quote";
88
- content: "inline";
89
- propSchema: {
90
- backgroundColor: {
91
- default: "default";
92
- };
93
- textColor: {
94
- default: "default";
95
- };
96
- textAlignment: {
97
- default: "left";
98
- values: readonly ["left", "center", "right", "justify"];
99
- };
100
- };
101
- };
102
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
103
- type: "quote";
104
- content: "inline";
105
- propSchema: {
106
- backgroundColor: {
107
- default: "default";
108
- };
109
- textColor: {
110
- default: "default";
111
- };
112
- textAlignment: {
113
- default: "left";
114
- values: readonly ["left", "center", "right", "justify"];
115
- };
116
- };
117
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
118
- };
119
- codeBlock: {
120
- config: {
121
- type: "codeBlock";
122
- content: "inline";
123
- propSchema: {
124
- language: {
125
- default: string;
126
- };
127
- };
128
- };
129
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
130
- type: "codeBlock";
131
- content: "inline";
132
- propSchema: {
133
- language: {
134
- default: string;
135
- };
136
- };
137
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
138
- };
139
- toggleListItem: {
140
- config: {
141
- type: "toggleListItem";
142
- content: "inline";
143
- propSchema: {
144
- backgroundColor: {
145
- default: "default";
146
- };
147
- textColor: {
148
- default: "default";
149
- };
150
- textAlignment: {
151
- default: "left";
152
- values: readonly ["left", "center", "right", "justify"];
153
- };
154
- };
155
- };
156
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
157
- type: "toggleListItem";
158
- content: "inline";
159
- propSchema: {
160
- backgroundColor: {
161
- default: "default";
162
- };
163
- textColor: {
164
- default: "default";
165
- };
166
- textAlignment: {
167
- default: "left";
168
- values: readonly ["left", "center", "right", "justify"];
169
- };
170
- };
171
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
172
- };
173
- bulletListItem: {
174
- config: {
175
- type: "bulletListItem";
176
- content: "inline";
177
- propSchema: {
178
- backgroundColor: {
179
- default: "default";
180
- };
181
- textColor: {
182
- default: "default";
183
- };
184
- textAlignment: {
185
- default: "left";
186
- values: readonly ["left", "center", "right", "justify"];
187
- };
188
- };
189
- };
190
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
191
- type: "bulletListItem";
192
- content: "inline";
193
- propSchema: {
194
- backgroundColor: {
195
- default: "default";
196
- };
197
- textColor: {
198
- default: "default";
199
- };
200
- textAlignment: {
201
- default: "left";
202
- values: readonly ["left", "center", "right", "justify"];
203
- };
204
- };
205
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
206
- };
207
- numberedListItem: {
208
- config: {
209
- type: "numberedListItem";
210
- content: "inline";
211
- propSchema: {
212
- start: {
213
- default: undefined;
214
- type: "number";
215
- };
216
- backgroundColor: {
217
- default: "default";
218
- };
219
- textColor: {
220
- default: "default";
221
- };
222
- textAlignment: {
223
- default: "left";
224
- values: readonly ["left", "center", "right", "justify"];
225
- };
226
- };
227
- };
228
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
229
- type: "numberedListItem";
230
- content: "inline";
231
- propSchema: {
232
- start: {
233
- default: undefined;
234
- type: "number";
235
- };
236
- backgroundColor: {
237
- default: "default";
238
- };
239
- textColor: {
240
- default: "default";
241
- };
242
- textAlignment: {
243
- default: "left";
244
- values: readonly ["left", "center", "right", "justify"];
245
- };
246
- };
247
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
248
- };
249
- checkListItem: {
250
- config: {
251
- type: "checkListItem";
252
- content: "inline";
253
- propSchema: {
254
- checked: {
255
- default: false;
256
- };
257
- backgroundColor: {
258
- default: "default";
259
- };
260
- textColor: {
261
- default: "default";
262
- };
263
- textAlignment: {
264
- default: "left";
265
- values: readonly ["left", "center", "right", "justify"];
266
- };
267
- };
268
- };
269
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
270
- type: "checkListItem";
271
- content: "inline";
272
- propSchema: {
273
- checked: {
274
- default: false;
275
- };
276
- backgroundColor: {
277
- default: "default";
278
- };
279
- textColor: {
280
- default: "default";
281
- };
282
- textAlignment: {
283
- default: "left";
284
- values: readonly ["left", "center", "right", "justify"];
285
- };
286
- };
287
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
288
- };
289
- table: {
290
- config: {
291
- type: "table";
292
- content: "table";
293
- propSchema: {
294
- textColor: {
295
- default: "default";
296
- };
297
- };
298
- };
299
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
300
- type: "table";
301
- content: "table";
302
- propSchema: {
303
- textColor: {
304
- default: "default";
305
- };
306
- };
307
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
308
- };
309
- file: {
310
- config: {
311
- type: "file";
312
- propSchema: {
313
- backgroundColor: {
314
- default: "default";
315
- };
316
- name: {
317
- default: "";
318
- };
319
- url: {
320
- default: "";
321
- };
322
- caption: {
323
- default: "";
324
- };
325
- };
326
- content: "none";
327
- isFileBlock: true;
328
- };
329
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
330
- type: "file";
331
- propSchema: {
332
- backgroundColor: {
333
- default: "default";
334
- };
335
- name: {
336
- default: "";
337
- };
338
- url: {
339
- default: "";
340
- };
341
- caption: {
342
- default: "";
343
- };
344
- };
345
- content: "none";
346
- isFileBlock: true;
347
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
348
- };
349
- image: {
350
- config: {
351
- type: "image";
352
- propSchema: {
353
- textAlignment: {
354
- default: "left";
355
- values: readonly ["left", "center", "right", "justify"];
356
- };
357
- backgroundColor: {
358
- default: "default";
359
- };
360
- name: {
361
- default: "";
362
- };
363
- url: {
364
- default: "";
365
- };
366
- caption: {
367
- default: "";
368
- };
369
- showPreview: {
370
- default: true;
371
- };
372
- previewWidth: {
373
- default: undefined;
374
- type: "number";
375
- };
376
- };
377
- content: "none";
378
- isFileBlock: true;
379
- fileBlockAccept: string[];
380
- };
381
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
382
- type: "image";
383
- propSchema: {
384
- textAlignment: {
385
- default: "left";
386
- values: readonly ["left", "center", "right", "justify"];
387
- };
388
- backgroundColor: {
389
- default: "default";
390
- };
391
- name: {
392
- default: "";
393
- };
394
- url: {
395
- default: "";
396
- };
397
- caption: {
398
- default: "";
399
- };
400
- showPreview: {
401
- default: true;
402
- };
403
- previewWidth: {
404
- default: undefined;
405
- type: "number";
406
- };
407
- };
408
- content: "none";
409
- isFileBlock: true;
410
- fileBlockAccept: string[];
411
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
412
- };
413
- video: {
414
- config: {
415
- type: "video";
416
- propSchema: {
417
- textAlignment: {
418
- default: "left";
419
- values: readonly ["left", "center", "right", "justify"];
420
- };
421
- backgroundColor: {
422
- default: "default";
423
- };
424
- name: {
425
- default: "";
426
- };
427
- url: {
428
- default: "";
429
- };
430
- caption: {
431
- default: "";
432
- };
433
- showPreview: {
434
- default: true;
435
- };
436
- previewWidth: {
437
- default: undefined;
438
- type: "number";
439
- };
440
- };
441
- content: "none";
442
- isFileBlock: true;
443
- fileBlockAccept: string[];
444
- };
445
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
446
- type: "video";
447
- propSchema: {
448
- textAlignment: {
449
- default: "left";
450
- values: readonly ["left", "center", "right", "justify"];
451
- };
452
- backgroundColor: {
453
- default: "default";
454
- };
455
- name: {
456
- default: "";
457
- };
458
- url: {
459
- default: "";
460
- };
461
- caption: {
462
- default: "";
463
- };
464
- showPreview: {
465
- default: true;
466
- };
467
- previewWidth: {
468
- default: undefined;
469
- type: "number";
470
- };
471
- };
472
- content: "none";
473
- isFileBlock: true;
474
- fileBlockAccept: string[];
475
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
476
- };
477
- audio: {
478
- config: {
479
- type: "audio";
480
- propSchema: {
481
- backgroundColor: {
482
- default: "default";
483
- };
484
- name: {
485
- default: "";
486
- };
487
- url: {
488
- default: "";
489
- };
490
- caption: {
491
- default: "";
492
- };
493
- showPreview: {
494
- default: true;
495
- };
496
- };
497
- content: "none";
498
- isFileBlock: true;
499
- fileBlockAccept: string[];
500
- };
501
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
502
- type: "audio";
503
- propSchema: {
504
- backgroundColor: {
505
- default: "default";
506
- };
507
- name: {
508
- default: "";
509
- };
510
- url: {
511
- default: "";
512
- };
513
- caption: {
514
- default: "";
515
- };
516
- showPreview: {
517
- default: true;
518
- };
519
- };
520
- content: "none";
521
- isFileBlock: true;
522
- fileBlockAccept: string[];
523
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
524
- };
525
- }> & import("@blocknote/core").BlockSchemaFromSpecs<{
526
- pageBreak: {
527
- config: {
528
- type: "pageBreak";
529
- propSchema: {};
530
- content: "none";
531
- isFileBlock: false;
532
- isSelectable: false;
533
- };
534
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
535
- type: "pageBreak";
536
- propSchema: {};
537
- content: "none";
538
- isFileBlock: false;
539
- isSelectable: false;
540
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
541
- };
542
- }> & import("@blocknote/core").BlockSchemaFromSpecs<{
543
- column: {
544
- config: {
545
- type: "column";
546
- content: "none";
547
- propSchema: {
548
- width: {
549
- default: number;
550
- };
551
- };
552
- };
553
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
554
- type: "column";
555
- content: "none";
556
- propSchema: {
557
- width: {
558
- default: number;
559
- };
560
- };
561
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
562
- };
563
- columnList: {
564
- config: {
565
- type: "columnList";
566
- content: "none";
567
- propSchema: {};
568
- };
569
- implementation: import("@blocknote/core").TiptapBlockImplementation<{
570
- type: "columnList";
571
- content: "none";
572
- propSchema: {};
573
- }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
574
- };
2
+ blockMapping: import("@blocknote/core").BlockMapping<import("@blocknote/core")._DefaultBlockSchema & {
3
+ pageBreak: ReturnType<typeof import("@blocknote/core").createPageBreakBlockConfig>;
4
+ } & import("@blocknote/core").BlockSchemaFromSpecs<{
5
+ column: import("@blocknote/core").LooseBlockSpec<"column", {
6
+ width: {
7
+ default: number;
8
+ };
9
+ }, "none">;
10
+ columnList: import("@blocknote/core").LooseBlockSpec<"columnList", {}, "none">;
575
11
  }>, any, any, import("docx").Table | import("docx").Paragraph | import("docx").Paragraph[] | Promise<import("docx").Table | import("docx").Paragraph | import("docx").Paragraph[]>, import("docx").ParagraphChild>;
576
12
  inlineContentMapping: import("@blocknote/core").InlineContentMapping<import("@blocknote/core").InlineContentSchemaFromSpecs<{
577
13
  text: {
@@ -588,50 +24,59 @@ export declare const docxDefaultSchemaMappings: {
588
24
  type: string;
589
25
  propSchema: "boolean";
590
26
  };
591
- implementation: import("@blocknote/core").StyleImplementation;
27
+ implementation: import("@blocknote/core").StyleImplementation<{
28
+ type: string;
29
+ propSchema: "boolean";
30
+ }>;
592
31
  };
593
32
  italic: {
594
33
  config: {
595
34
  type: string;
596
35
  propSchema: "boolean";
597
36
  };
598
- implementation: import("@blocknote/core").StyleImplementation;
37
+ implementation: import("@blocknote/core").StyleImplementation<{
38
+ type: string;
39
+ propSchema: "boolean";
40
+ }>;
599
41
  };
600
42
  underline: {
601
43
  config: {
602
44
  type: string;
603
45
  propSchema: "boolean";
604
46
  };
605
- implementation: import("@blocknote/core").StyleImplementation;
47
+ implementation: import("@blocknote/core").StyleImplementation<{
48
+ type: string;
49
+ propSchema: "boolean";
50
+ }>;
606
51
  };
607
52
  strike: {
608
53
  config: {
609
54
  type: string;
610
55
  propSchema: "boolean";
611
56
  };
612
- implementation: import("@blocknote/core").StyleImplementation;
613
- };
614
- code: {
615
- config: {
57
+ implementation: import("@blocknote/core").StyleImplementation<{
616
58
  type: string;
617
59
  propSchema: "boolean";
618
- };
619
- implementation: import("@blocknote/core").StyleImplementation;
60
+ }>;
620
61
  };
621
- textColor: {
62
+ code: {
622
63
  config: {
623
64
  type: string;
624
- propSchema: "string";
65
+ propSchema: "boolean";
625
66
  };
626
- implementation: import("@blocknote/core").StyleImplementation;
627
- };
628
- backgroundColor: {
629
- config: {
67
+ implementation: import("@blocknote/core").StyleImplementation<{
630
68
  type: string;
631
- propSchema: "string";
632
- };
633
- implementation: import("@blocknote/core").StyleImplementation;
634
- };
69
+ propSchema: "boolean";
70
+ }>;
71
+ };
72
+ textColor: import("@blocknote/core").StyleSpec<{
73
+ readonly type: "textColor";
74
+ readonly propSchema: "string";
75
+ }>;
76
+ backgroundColor: import("@blocknote/core").StyleSpec<{
77
+ readonly type: "backgroundColor";
78
+ readonly propSchema: "string";
79
+ }>;
635
80
  }>, import("docx").ParagraphChild, import("docx").TextRun>;
636
81
  styleMapping: import("@blocknote/core").StyleMapping<import("@blocknote/core").StyleSchemaFromSpecs<{
637
82
  bold: {
@@ -639,49 +84,58 @@ export declare const docxDefaultSchemaMappings: {
639
84
  type: string;
640
85
  propSchema: "boolean";
641
86
  };
642
- implementation: import("@blocknote/core").StyleImplementation;
87
+ implementation: import("@blocknote/core").StyleImplementation<{
88
+ type: string;
89
+ propSchema: "boolean";
90
+ }>;
643
91
  };
644
92
  italic: {
645
93
  config: {
646
94
  type: string;
647
95
  propSchema: "boolean";
648
96
  };
649
- implementation: import("@blocknote/core").StyleImplementation;
97
+ implementation: import("@blocknote/core").StyleImplementation<{
98
+ type: string;
99
+ propSchema: "boolean";
100
+ }>;
650
101
  };
651
102
  underline: {
652
103
  config: {
653
104
  type: string;
654
105
  propSchema: "boolean";
655
106
  };
656
- implementation: import("@blocknote/core").StyleImplementation;
107
+ implementation: import("@blocknote/core").StyleImplementation<{
108
+ type: string;
109
+ propSchema: "boolean";
110
+ }>;
657
111
  };
658
112
  strike: {
659
113
  config: {
660
114
  type: string;
661
115
  propSchema: "boolean";
662
116
  };
663
- implementation: import("@blocknote/core").StyleImplementation;
664
- };
665
- code: {
666
- config: {
117
+ implementation: import("@blocknote/core").StyleImplementation<{
667
118
  type: string;
668
119
  propSchema: "boolean";
669
- };
670
- implementation: import("@blocknote/core").StyleImplementation;
120
+ }>;
671
121
  };
672
- textColor: {
122
+ code: {
673
123
  config: {
674
124
  type: string;
675
- propSchema: "string";
125
+ propSchema: "boolean";
676
126
  };
677
- implementation: import("@blocknote/core").StyleImplementation;
678
- };
679
- backgroundColor: {
680
- config: {
127
+ implementation: import("@blocknote/core").StyleImplementation<{
681
128
  type: string;
682
- propSchema: "string";
683
- };
684
- implementation: import("@blocknote/core").StyleImplementation;
685
- };
129
+ propSchema: "boolean";
130
+ }>;
131
+ };
132
+ textColor: import("@blocknote/core").StyleSpec<{
133
+ readonly type: "textColor";
134
+ readonly propSchema: "string";
135
+ }>;
136
+ backgroundColor: import("@blocknote/core").StyleSpec<{
137
+ readonly type: "backgroundColor";
138
+ readonly propSchema: "string";
139
+ }>;
686
140
  }>, import("docx").IRunPropertiesOptions>;
687
141
  };