@cj-tech-master/excelts 9.4.2 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.browser.d.ts +8 -5
- package/dist/browser/index.browser.js +19 -1
- package/dist/browser/index.d.ts +4 -2
- package/dist/browser/index.js +9 -1
- package/dist/browser/modules/excel/chart/cache-populator.d.ts +49 -0
- package/dist/browser/modules/excel/chart/cache-populator.js +1171 -0
- package/dist/browser/modules/excel/chart/chart-api.d.ts +92 -0
- package/dist/browser/modules/excel/chart/chart-api.js +364 -0
- package/dist/browser/modules/excel/chart/chart-builder.d.ts +48 -0
- package/dist/browser/modules/excel/chart/chart-builder.js +2432 -0
- package/dist/browser/modules/excel/chart/chart-ex-builder.d.ts +36 -0
- package/dist/browser/modules/excel/chart/chart-ex-builder.js +903 -0
- package/dist/browser/modules/excel/chart/chart-ex-parser.d.ts +8 -0
- package/dist/browser/modules/excel/chart/chart-ex-parser.js +1205 -0
- package/dist/browser/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
- package/dist/browser/modules/excel/chart/chart-ex-renderer.js +5352 -0
- package/dist/browser/modules/excel/chart/chart-ex-types.d.ts +531 -0
- package/dist/browser/modules/excel/chart/chart-ex-types.js +11 -0
- package/dist/browser/modules/excel/chart/chart-images.d.ts +78 -0
- package/dist/browser/modules/excel/chart/chart-images.js +363 -0
- package/dist/browser/modules/excel/chart/chart-presets.d.ts +392 -0
- package/dist/browser/modules/excel/chart/chart-presets.js +179 -0
- package/dist/browser/modules/excel/chart/chart-renderer.d.ts +550 -0
- package/dist/browser/modules/excel/chart/chart-renderer.js +6440 -0
- package/dist/browser/modules/excel/chart/chart-sidecar.d.ts +21 -0
- package/dist/browser/modules/excel/chart/chart-sidecar.js +427 -0
- package/dist/browser/modules/excel/chart/chart-utils.d.ts +306 -0
- package/dist/browser/modules/excel/chart/chart-utils.js +821 -0
- package/dist/browser/modules/excel/chart/chart.d.ts +504 -0
- package/dist/browser/modules/excel/chart/chart.js +1320 -0
- package/dist/browser/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
- package/dist/browser/modules/excel/chart/glyph-rasterizer.js +658 -0
- package/dist/browser/modules/excel/chart/index.d.ts +54 -0
- package/dist/browser/modules/excel/chart/index.js +46 -0
- package/dist/browser/modules/excel/chart/install.d.ts +44 -0
- package/dist/browser/modules/excel/chart/install.js +91 -0
- package/dist/browser/modules/excel/chart/shape-properties.d.ts +156 -0
- package/dist/browser/modules/excel/chart/shape-properties.js +1557 -0
- package/dist/browser/modules/excel/chart/stroke-font.d.ts +36 -0
- package/dist/browser/modules/excel/chart/stroke-font.js +1556 -0
- package/dist/browser/modules/excel/chart/topojson.d.ts +98 -0
- package/dist/browser/modules/excel/chart/topojson.js +236 -0
- package/dist/browser/modules/excel/chart/types.d.ts +2559 -0
- package/dist/browser/modules/excel/chart/types.js +8 -0
- package/dist/browser/modules/excel/chart-host-registry.d.ts +157 -0
- package/dist/browser/modules/excel/chart-host-registry.js +90 -0
- package/dist/browser/modules/excel/chartsheet.d.ts +102 -0
- package/dist/browser/modules/excel/chartsheet.js +196 -0
- package/dist/browser/modules/excel/defined-names.d.ts +35 -0
- package/dist/browser/modules/excel/defined-names.js +44 -4
- package/dist/browser/modules/excel/errors.d.ts +6 -0
- package/dist/browser/modules/excel/errors.js +9 -0
- package/dist/browser/modules/excel/form-control.d.ts +6 -0
- package/dist/browser/modules/excel/form-control.js +17 -0
- package/dist/browser/modules/excel/image.js +12 -2
- package/dist/browser/modules/excel/pivot-chart.d.ts +7 -0
- package/dist/browser/modules/excel/pivot-chart.js +53 -0
- package/dist/browser/modules/excel/pivot-table.d.ts +55 -0
- package/dist/browser/modules/excel/pivot-table.js +35 -0
- package/dist/browser/modules/excel/range.js +5 -1
- package/dist/browser/modules/excel/sparkline/index.d.ts +7 -0
- package/dist/browser/modules/excel/sparkline/index.js +7 -0
- package/dist/browser/modules/excel/sparkline/sparkline.d.ts +206 -0
- package/dist/browser/modules/excel/sparkline/sparkline.js +750 -0
- package/dist/browser/modules/excel/stream/worksheet-writer.js +3 -2
- package/dist/browser/modules/excel/table.js +42 -6
- package/dist/browser/modules/excel/types.d.ts +72 -0
- package/dist/browser/modules/excel/utils/address.d.ts +18 -0
- package/dist/browser/modules/excel/utils/address.js +28 -0
- package/dist/browser/modules/excel/utils/drawing-utils.js +11 -6
- package/dist/browser/modules/excel/utils/guid.d.ts +15 -0
- package/dist/browser/modules/excel/utils/guid.js +35 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +74 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.js +206 -9
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-table.js +177 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/context.js +191 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/index.js +102 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/reporter.js +61 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/types.js +12 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
- package/dist/browser/modules/excel/workbook.browser.d.ts +248 -30
- package/dist/browser/modules/excel/workbook.browser.js +966 -31
- package/dist/browser/modules/excel/workbook.d.ts +43 -0
- package/dist/browser/modules/excel/workbook.js +48 -0
- package/dist/browser/modules/excel/worksheet.d.ts +157 -3
- package/dist/browser/modules/excel/worksheet.js +394 -35
- package/dist/browser/modules/excel/xlsx/rel-type.d.ts +40 -0
- package/dist/browser/modules/excel/xlsx/rel-type.js +41 -1
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
- package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
- package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
- package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
- package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
- package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
- package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
- package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
- package/dist/browser/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
- package/dist/browser/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
- package/dist/browser/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
- package/dist/browser/modules/excel/xlsx/xform/xsd-values.js +101 -0
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +4422 -78
- package/dist/browser/modules/pdf/builder/document-builder.d.ts +74 -0
- package/dist/browser/modules/pdf/builder/document-builder.js +507 -2
- package/dist/browser/modules/pdf/builder/pdf-editor.js +48 -3
- package/dist/browser/modules/pdf/excel-bridge.d.ts +69 -0
- package/dist/browser/modules/pdf/excel-bridge.js +683 -12
- package/dist/browser/modules/pdf/font/font-manager.d.ts +25 -0
- package/dist/browser/modules/pdf/font/font-manager.js +39 -0
- package/dist/browser/modules/pdf/index.d.ts +5 -2
- package/dist/browser/modules/pdf/index.js +3 -1
- package/dist/browser/modules/pdf/render/chart-surface.d.ts +33 -0
- package/dist/browser/modules/pdf/render/chart-surface.js +200 -0
- package/dist/browser/modules/pdf/render/layout-engine.d.ts +22 -1
- package/dist/browser/modules/pdf/render/layout-engine.js +436 -56
- package/dist/browser/modules/pdf/render/page-renderer.js +169 -28
- package/dist/browser/modules/pdf/render/pdf-exporter.js +117 -7
- package/dist/browser/modules/pdf/types.d.ts +227 -23
- package/dist/browser/modules/pdf/types.js +4 -0
- package/dist/browser/modules/pdf/word-bridge.d.ts +47 -0
- package/dist/browser/modules/pdf/word-bridge.js +304 -0
- package/dist/browser/modules/word/constants.d.ts +179 -0
- package/dist/browser/modules/word/constants.js +231 -0
- package/dist/browser/modules/word/content-types.d.ts +27 -0
- package/dist/browser/modules/word/content-types.js +53 -0
- package/dist/browser/modules/word/digital-signatures.d.ts +87 -0
- package/dist/browser/modules/word/digital-signatures.js +134 -0
- package/dist/browser/modules/word/document.d.ts +728 -0
- package/dist/browser/modules/word/document.js +1795 -0
- package/dist/browser/modules/word/docx-packager.d.ts +14 -0
- package/dist/browser/modules/word/docx-packager.js +822 -0
- package/dist/browser/modules/word/docx-reader.d.ts +11 -0
- package/dist/browser/modules/word/docx-reader.js +4929 -0
- package/dist/browser/modules/word/encryption.d.ts +102 -0
- package/dist/browser/modules/word/encryption.js +274 -0
- package/dist/browser/modules/word/errors.d.ts +49 -0
- package/dist/browser/modules/word/errors.js +68 -0
- package/dist/browser/modules/word/font-obfuscation.d.ts +31 -0
- package/dist/browser/modules/word/font-obfuscation.js +83 -0
- package/dist/browser/modules/word/html-renderer.d.ts +38 -0
- package/dist/browser/modules/word/html-renderer.js +782 -0
- package/dist/browser/modules/word/index.base.d.ts +19 -0
- package/dist/browser/modules/word/index.base.js +51 -0
- package/dist/browser/modules/word/index.browser.d.ts +4 -0
- package/dist/browser/modules/word/index.browser.js +4 -0
- package/dist/browser/modules/word/index.d.ts +4 -0
- package/dist/browser/modules/word/index.js +4 -0
- package/dist/browser/modules/word/internal-utils.d.ts +23 -0
- package/dist/browser/modules/word/internal-utils.js +54 -0
- package/dist/browser/modules/word/relationships.d.ts +31 -0
- package/dist/browser/modules/word/relationships.js +56 -0
- package/dist/browser/modules/word/types.d.ts +2325 -0
- package/dist/browser/modules/word/types.js +10 -0
- package/dist/browser/modules/word/units.d.ts +49 -0
- package/dist/browser/modules/word/units.js +111 -0
- package/dist/browser/modules/word/writers/chart-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/chart-writer.js +385 -0
- package/dist/browser/modules/word/writers/checkbox-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/checkbox-writer.js +42 -0
- package/dist/browser/modules/word/writers/comment-writer.d.ts +15 -0
- package/dist/browser/modules/word/writers/comment-writer.js +70 -0
- package/dist/browser/modules/word/writers/document-writer.d.ts +16 -0
- package/dist/browser/modules/word/writers/document-writer.js +461 -0
- package/dist/browser/modules/word/writers/footnote-writer.d.ts +11 -0
- package/dist/browser/modules/word/writers/footnote-writer.js +72 -0
- package/dist/browser/modules/word/writers/header-footer-writer.d.ts +13 -0
- package/dist/browser/modules/word/writers/header-footer-writer.js +129 -0
- package/dist/browser/modules/word/writers/image-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/image-writer.js +185 -0
- package/dist/browser/modules/word/writers/math-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/math-writer.js +428 -0
- package/dist/browser/modules/word/writers/numbering-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/numbering-writer.js +125 -0
- package/dist/browser/modules/word/writers/paragraph-writer.d.ts +13 -0
- package/dist/browser/modules/word/writers/paragraph-writer.js +516 -0
- package/dist/browser/modules/word/writers/parts-writer.d.ts +26 -0
- package/dist/browser/modules/word/writers/parts-writer.js +660 -0
- package/dist/browser/modules/word/writers/run-writer.d.ts +15 -0
- package/dist/browser/modules/word/writers/run-writer.js +649 -0
- package/dist/browser/modules/word/writers/section-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/section-writer.js +238 -0
- package/dist/browser/modules/word/writers/styles-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/styles-writer.js +242 -0
- package/dist/browser/modules/word/writers/table-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/table-writer.js +503 -0
- package/dist/browser/modules/word/writers/textbox-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/textbox-writer.js +53 -0
- package/dist/browser/modules/word/writers/toc-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/toc-writer.js +79 -0
- package/dist/browser/modules/xml/encode.d.ts +56 -7
- package/dist/browser/modules/xml/encode.js +157 -11
- package/dist/cjs/index.js +13 -2
- package/dist/cjs/modules/excel/chart/cache-populator.js +1178 -0
- package/dist/cjs/modules/excel/chart/chart-api.js +371 -0
- package/dist/cjs/modules/excel/chart/chart-builder.js +2440 -0
- package/dist/cjs/modules/excel/chart/chart-ex-builder.js +907 -0
- package/dist/cjs/modules/excel/chart/chart-ex-parser.js +1208 -0
- package/dist/cjs/modules/excel/chart/chart-ex-renderer.js +5364 -0
- package/dist/cjs/modules/excel/chart/chart-ex-types.js +12 -0
- package/dist/cjs/modules/excel/chart/chart-images.js +366 -0
- package/dist/cjs/modules/excel/chart/chart-presets.js +184 -0
- package/dist/cjs/modules/excel/chart/chart-renderer.js +6450 -0
- package/dist/cjs/modules/excel/chart/chart-sidecar.js +433 -0
- package/dist/cjs/modules/excel/chart/chart-utils.js +845 -0
- package/dist/cjs/modules/excel/chart/chart.js +1324 -0
- package/dist/cjs/modules/excel/chart/glyph-rasterizer.js +664 -0
- package/dist/cjs/modules/excel/chart/index.js +101 -0
- package/dist/cjs/modules/excel/chart/install.js +95 -0
- package/dist/cjs/modules/excel/chart/shape-properties.js +1577 -0
- package/dist/cjs/modules/excel/chart/stroke-font.js +1559 -0
- package/dist/cjs/modules/excel/chart/topojson.js +239 -0
- package/dist/cjs/modules/excel/chart/types.js +9 -0
- package/dist/cjs/modules/excel/chart-host-registry.js +96 -0
- package/dist/cjs/modules/excel/chartsheet.js +199 -0
- package/dist/cjs/modules/excel/defined-names.js +44 -4
- package/dist/cjs/modules/excel/errors.js +11 -1
- package/dist/cjs/modules/excel/form-control.js +17 -0
- package/dist/cjs/modules/excel/image.js +12 -2
- package/dist/cjs/modules/excel/pivot-chart.js +56 -0
- package/dist/cjs/modules/excel/pivot-table.js +35 -0
- package/dist/cjs/modules/excel/range.js +5 -1
- package/dist/cjs/modules/excel/sparkline/index.js +23 -0
- package/dist/cjs/modules/excel/sparkline/sparkline.js +756 -0
- package/dist/cjs/modules/excel/stream/worksheet-writer.js +3 -2
- package/dist/cjs/modules/excel/table.js +42 -6
- package/dist/cjs/modules/excel/utils/address.js +29 -0
- package/dist/cjs/modules/excel/utils/drawing-utils.js +11 -6
- package/dist/cjs/modules/excel/utils/guid.js +38 -0
- package/dist/cjs/modules/excel/utils/ooxml-paths.js +246 -9
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +103 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart.js +2128 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-chartsheet.js +29 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-content-types.js +184 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-drawing.js +270 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-pivot.js +107 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-relationships.js +188 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-structure.js +60 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-styles.js +92 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-table.js +180 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-workbook.js +166 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-worksheet.js +572 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/context.js +196 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/index.js +105 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/path-utils.js +168 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/reporter.js +66 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/types.js +13 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/xml-utils.js +110 -0
- package/dist/cjs/modules/excel/workbook.browser.js +973 -38
- package/dist/cjs/modules/excel/workbook.js +48 -0
- package/dist/cjs/modules/excel/worksheet.js +393 -34
- package/dist/cjs/modules/excel/xlsx/rel-type.js +41 -1
- package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
- package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
- package/dist/cjs/modules/excel/xlsx/xform/chart/chart-space-xform.js +6003 -0
- package/dist/cjs/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +219 -0
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +149 -10
- package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
- package/dist/cjs/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +228 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
- package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
- package/dist/cjs/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +444 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +195 -19
- package/dist/cjs/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
- package/dist/cjs/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
- package/dist/cjs/modules/excel/xlsx/xform/xsd-values.js +106 -0
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +4420 -76
- package/dist/cjs/modules/pdf/builder/document-builder.js +506 -1
- package/dist/cjs/modules/pdf/builder/pdf-editor.js +48 -3
- package/dist/cjs/modules/pdf/excel-bridge.js +684 -12
- package/dist/cjs/modules/pdf/font/font-manager.js +39 -0
- package/dist/cjs/modules/pdf/index.js +5 -1
- package/dist/cjs/modules/pdf/render/chart-surface.js +203 -0
- package/dist/cjs/modules/pdf/render/layout-engine.js +437 -56
- package/dist/cjs/modules/pdf/render/page-renderer.js +169 -28
- package/dist/cjs/modules/pdf/render/pdf-exporter.js +115 -5
- package/dist/cjs/modules/pdf/types.js +5 -0
- package/dist/cjs/modules/pdf/word-bridge.js +307 -0
- package/dist/cjs/modules/word/constants.js +234 -0
- package/dist/cjs/modules/word/content-types.js +57 -0
- package/dist/cjs/modules/word/digital-signatures.js +140 -0
- package/dist/cjs/modules/word/document.js +1909 -0
- package/dist/cjs/modules/word/docx-packager.js +825 -0
- package/dist/cjs/modules/word/docx-reader.js +4932 -0
- package/dist/cjs/modules/word/encryption.js +282 -0
- package/dist/cjs/modules/word/errors.js +88 -0
- package/dist/cjs/modules/word/font-obfuscation.js +88 -0
- package/dist/cjs/modules/word/html-renderer.js +785 -0
- package/dist/cjs/modules/word/index.base.js +199 -0
- package/dist/cjs/modules/word/index.browser.js +20 -0
- package/dist/cjs/modules/word/index.js +20 -0
- package/dist/cjs/modules/word/internal-utils.js +59 -0
- package/dist/cjs/modules/word/relationships.js +60 -0
- package/dist/cjs/modules/word/types.js +11 -0
- package/dist/cjs/modules/word/units.js +135 -0
- package/dist/cjs/modules/word/writers/chart-writer.js +388 -0
- package/dist/cjs/modules/word/writers/checkbox-writer.js +45 -0
- package/dist/cjs/modules/word/writers/comment-writer.js +74 -0
- package/dist/cjs/modules/word/writers/document-writer.js +465 -0
- package/dist/cjs/modules/word/writers/footnote-writer.js +76 -0
- package/dist/cjs/modules/word/writers/header-footer-writer.js +134 -0
- package/dist/cjs/modules/word/writers/image-writer.js +188 -0
- package/dist/cjs/modules/word/writers/math-writer.js +431 -0
- package/dist/cjs/modules/word/writers/numbering-writer.js +128 -0
- package/dist/cjs/modules/word/writers/paragraph-writer.js +521 -0
- package/dist/cjs/modules/word/writers/parts-writer.js +671 -0
- package/dist/cjs/modules/word/writers/run-writer.js +655 -0
- package/dist/cjs/modules/word/writers/section-writer.js +241 -0
- package/dist/cjs/modules/word/writers/styles-writer.js +245 -0
- package/dist/cjs/modules/word/writers/table-writer.js +506 -0
- package/dist/cjs/modules/word/writers/textbox-writer.js +56 -0
- package/dist/cjs/modules/word/writers/toc-writer.js +82 -0
- package/dist/cjs/modules/xml/encode.js +158 -11
- package/dist/esm/index.browser.js +20 -2
- package/dist/esm/index.js +9 -1
- package/dist/esm/modules/excel/chart/cache-populator.js +1171 -0
- package/dist/esm/modules/excel/chart/chart-api.js +364 -0
- package/dist/esm/modules/excel/chart/chart-builder.js +2432 -0
- package/dist/esm/modules/excel/chart/chart-ex-builder.js +903 -0
- package/dist/esm/modules/excel/chart/chart-ex-parser.js +1205 -0
- package/dist/esm/modules/excel/chart/chart-ex-renderer.js +5352 -0
- package/dist/esm/modules/excel/chart/chart-ex-types.js +11 -0
- package/dist/esm/modules/excel/chart/chart-images.js +363 -0
- package/dist/esm/modules/excel/chart/chart-presets.js +179 -0
- package/dist/esm/modules/excel/chart/chart-renderer.js +6440 -0
- package/dist/esm/modules/excel/chart/chart-sidecar.js +427 -0
- package/dist/esm/modules/excel/chart/chart-utils.js +821 -0
- package/dist/esm/modules/excel/chart/chart.js +1320 -0
- package/dist/esm/modules/excel/chart/glyph-rasterizer.js +658 -0
- package/dist/esm/modules/excel/chart/index.js +46 -0
- package/dist/esm/modules/excel/chart/install.js +91 -0
- package/dist/esm/modules/excel/chart/shape-properties.js +1557 -0
- package/dist/esm/modules/excel/chart/stroke-font.js +1556 -0
- package/dist/esm/modules/excel/chart/topojson.js +236 -0
- package/dist/esm/modules/excel/chart/types.js +8 -0
- package/dist/esm/modules/excel/chart-host-registry.js +90 -0
- package/dist/esm/modules/excel/chartsheet.js +196 -0
- package/dist/esm/modules/excel/defined-names.js +44 -4
- package/dist/esm/modules/excel/errors.js +9 -0
- package/dist/esm/modules/excel/form-control.js +17 -0
- package/dist/esm/modules/excel/image.js +12 -2
- package/dist/esm/modules/excel/pivot-chart.js +53 -0
- package/dist/esm/modules/excel/pivot-table.js +35 -0
- package/dist/esm/modules/excel/range.js +5 -1
- package/dist/esm/modules/excel/sparkline/index.js +7 -0
- package/dist/esm/modules/excel/sparkline/sparkline.js +750 -0
- package/dist/esm/modules/excel/stream/worksheet-writer.js +3 -2
- package/dist/esm/modules/excel/table.js +42 -6
- package/dist/esm/modules/excel/utils/address.js +28 -0
- package/dist/esm/modules/excel/utils/drawing-utils.js +11 -6
- package/dist/esm/modules/excel/utils/guid.js +35 -0
- package/dist/esm/modules/excel/utils/ooxml-paths.js +206 -9
- package/dist/esm/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-table.js +177 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/context.js +191 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/index.js +102 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/reporter.js +61 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/types.js +12 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
- package/dist/esm/modules/excel/workbook.browser.js +969 -34
- package/dist/esm/modules/excel/workbook.js +48 -0
- package/dist/esm/modules/excel/worksheet.js +394 -35
- package/dist/esm/modules/excel/xlsx/rel-type.js +41 -1
- package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
- package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
- package/dist/esm/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
- package/dist/esm/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
- package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
- package/dist/esm/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
- package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
- package/dist/esm/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
- package/dist/esm/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
- package/dist/esm/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
- package/dist/esm/modules/excel/xlsx/xform/xsd-values.js +101 -0
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +4422 -78
- package/dist/esm/modules/pdf/builder/document-builder.js +507 -2
- package/dist/esm/modules/pdf/builder/pdf-editor.js +48 -3
- package/dist/esm/modules/pdf/excel-bridge.js +683 -12
- package/dist/esm/modules/pdf/font/font-manager.js +39 -0
- package/dist/esm/modules/pdf/index.js +3 -1
- package/dist/esm/modules/pdf/render/chart-surface.js +200 -0
- package/dist/esm/modules/pdf/render/layout-engine.js +436 -56
- package/dist/esm/modules/pdf/render/page-renderer.js +169 -28
- package/dist/esm/modules/pdf/render/pdf-exporter.js +117 -7
- package/dist/esm/modules/pdf/types.js +4 -0
- package/dist/esm/modules/pdf/word-bridge.js +304 -0
- package/dist/esm/modules/word/constants.js +231 -0
- package/dist/esm/modules/word/content-types.js +53 -0
- package/dist/esm/modules/word/digital-signatures.js +134 -0
- package/dist/esm/modules/word/document.js +1795 -0
- package/dist/esm/modules/word/docx-packager.js +822 -0
- package/dist/esm/modules/word/docx-reader.js +4929 -0
- package/dist/esm/modules/word/encryption.js +274 -0
- package/dist/esm/modules/word/errors.js +68 -0
- package/dist/esm/modules/word/font-obfuscation.js +83 -0
- package/dist/esm/modules/word/html-renderer.js +782 -0
- package/dist/esm/modules/word/index.base.js +51 -0
- package/dist/esm/modules/word/index.browser.js +4 -0
- package/dist/esm/modules/word/index.js +4 -0
- package/dist/esm/modules/word/internal-utils.js +54 -0
- package/dist/esm/modules/word/relationships.js +56 -0
- package/dist/esm/modules/word/types.js +10 -0
- package/dist/esm/modules/word/units.js +111 -0
- package/dist/esm/modules/word/writers/chart-writer.js +385 -0
- package/dist/esm/modules/word/writers/checkbox-writer.js +42 -0
- package/dist/esm/modules/word/writers/comment-writer.js +70 -0
- package/dist/esm/modules/word/writers/document-writer.js +461 -0
- package/dist/esm/modules/word/writers/footnote-writer.js +72 -0
- package/dist/esm/modules/word/writers/header-footer-writer.js +129 -0
- package/dist/esm/modules/word/writers/image-writer.js +185 -0
- package/dist/esm/modules/word/writers/math-writer.js +428 -0
- package/dist/esm/modules/word/writers/numbering-writer.js +125 -0
- package/dist/esm/modules/word/writers/paragraph-writer.js +516 -0
- package/dist/esm/modules/word/writers/parts-writer.js +660 -0
- package/dist/esm/modules/word/writers/run-writer.js +649 -0
- package/dist/esm/modules/word/writers/section-writer.js +238 -0
- package/dist/esm/modules/word/writers/styles-writer.js +242 -0
- package/dist/esm/modules/word/writers/table-writer.js +503 -0
- package/dist/esm/modules/word/writers/textbox-writer.js +53 -0
- package/dist/esm/modules/word/writers/toc-writer.js +79 -0
- package/dist/esm/modules/xml/encode.js +157 -11
- package/dist/iife/excelts.iife.js +11789 -687
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +52 -44
- package/dist/types/index.browser.d.ts +8 -5
- package/dist/types/index.d.ts +4 -2
- package/dist/types/modules/excel/chart/cache-populator.d.ts +49 -0
- package/dist/types/modules/excel/chart/chart-api.d.ts +92 -0
- package/dist/types/modules/excel/chart/chart-builder.d.ts +48 -0
- package/dist/types/modules/excel/chart/chart-ex-builder.d.ts +36 -0
- package/dist/types/modules/excel/chart/chart-ex-parser.d.ts +8 -0
- package/dist/types/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
- package/dist/types/modules/excel/chart/chart-ex-types.d.ts +531 -0
- package/dist/types/modules/excel/chart/chart-images.d.ts +78 -0
- package/dist/types/modules/excel/chart/chart-presets.d.ts +392 -0
- package/dist/types/modules/excel/chart/chart-renderer.d.ts +550 -0
- package/dist/types/modules/excel/chart/chart-sidecar.d.ts +21 -0
- package/dist/types/modules/excel/chart/chart-utils.d.ts +306 -0
- package/dist/types/modules/excel/chart/chart.d.ts +504 -0
- package/dist/types/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
- package/dist/types/modules/excel/chart/index.d.ts +54 -0
- package/dist/types/modules/excel/chart/install.d.ts +44 -0
- package/dist/types/modules/excel/chart/shape-properties.d.ts +156 -0
- package/dist/types/modules/excel/chart/stroke-font.d.ts +36 -0
- package/dist/types/modules/excel/chart/topojson.d.ts +98 -0
- package/dist/types/modules/excel/chart/types.d.ts +2559 -0
- package/dist/types/modules/excel/chart-host-registry.d.ts +157 -0
- package/dist/types/modules/excel/chartsheet.d.ts +102 -0
- package/dist/types/modules/excel/defined-names.d.ts +35 -0
- package/dist/types/modules/excel/errors.d.ts +6 -0
- package/dist/types/modules/excel/form-control.d.ts +6 -0
- package/dist/types/modules/excel/pivot-chart.d.ts +7 -0
- package/dist/types/modules/excel/pivot-table.d.ts +55 -0
- package/dist/types/modules/excel/sparkline/index.d.ts +7 -0
- package/dist/types/modules/excel/sparkline/sparkline.d.ts +206 -0
- package/dist/types/modules/excel/types.d.ts +72 -0
- package/dist/types/modules/excel/utils/address.d.ts +18 -0
- package/dist/types/modules/excel/utils/guid.d.ts +15 -0
- package/dist/types/modules/excel/utils/ooxml-paths.d.ts +74 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
- package/dist/types/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
- package/dist/types/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
- package/dist/types/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
- package/dist/types/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
- package/dist/types/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
- package/dist/types/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
- package/dist/types/modules/excel/workbook.browser.d.ts +248 -30
- package/dist/types/modules/excel/workbook.d.ts +43 -0
- package/dist/types/modules/excel/worksheet.d.ts +157 -3
- package/dist/types/modules/excel/xlsx/rel-type.d.ts +40 -0
- package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
- package/dist/types/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
- package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
- package/dist/types/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
- package/dist/types/modules/pdf/builder/document-builder.d.ts +74 -0
- package/dist/types/modules/pdf/excel-bridge.d.ts +69 -0
- package/dist/types/modules/pdf/font/font-manager.d.ts +25 -0
- package/dist/types/modules/pdf/index.d.ts +5 -2
- package/dist/types/modules/pdf/render/chart-surface.d.ts +33 -0
- package/dist/types/modules/pdf/render/layout-engine.d.ts +22 -1
- package/dist/types/modules/pdf/types.d.ts +227 -23
- package/dist/types/modules/pdf/word-bridge.d.ts +47 -0
- package/dist/types/modules/word/constants.d.ts +179 -0
- package/dist/types/modules/word/content-types.d.ts +27 -0
- package/dist/types/modules/word/digital-signatures.d.ts +87 -0
- package/dist/types/modules/word/document.d.ts +728 -0
- package/dist/types/modules/word/docx-packager.d.ts +14 -0
- package/dist/types/modules/word/docx-reader.d.ts +11 -0
- package/dist/types/modules/word/encryption.d.ts +102 -0
- package/dist/types/modules/word/errors.d.ts +49 -0
- package/dist/types/modules/word/font-obfuscation.d.ts +31 -0
- package/dist/types/modules/word/html-renderer.d.ts +38 -0
- package/dist/types/modules/word/index.base.d.ts +19 -0
- package/dist/types/modules/word/index.browser.d.ts +4 -0
- package/dist/types/modules/word/index.d.ts +4 -0
- package/dist/types/modules/word/internal-utils.d.ts +23 -0
- package/dist/types/modules/word/relationships.d.ts +31 -0
- package/dist/types/modules/word/types.d.ts +2325 -0
- package/dist/types/modules/word/units.d.ts +49 -0
- package/dist/types/modules/word/writers/chart-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/checkbox-writer.d.ts +9 -0
- package/dist/types/modules/word/writers/comment-writer.d.ts +15 -0
- package/dist/types/modules/word/writers/document-writer.d.ts +16 -0
- package/dist/types/modules/word/writers/footnote-writer.d.ts +11 -0
- package/dist/types/modules/word/writers/header-footer-writer.d.ts +13 -0
- package/dist/types/modules/word/writers/image-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/math-writer.d.ts +9 -0
- package/dist/types/modules/word/writers/numbering-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/paragraph-writer.d.ts +13 -0
- package/dist/types/modules/word/writers/parts-writer.d.ts +26 -0
- package/dist/types/modules/word/writers/run-writer.d.ts +15 -0
- package/dist/types/modules/word/writers/section-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/styles-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/table-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/textbox-writer.d.ts +9 -0
- package/dist/types/modules/word/writers/toc-writer.d.ts +9 -0
- package/dist/types/modules/xml/encode.d.ts +56 -7
- package/package.json +29 -11
- package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +0 -48
- package/dist/browser/modules/excel/utils/ooxml-validator.js +0 -493
- package/dist/browser/modules/excel/utils/passthrough-manager.d.ts +0 -77
- package/dist/browser/modules/excel/utils/passthrough-manager.js +0 -129
- package/dist/cjs/modules/excel/utils/ooxml-validator.js +0 -499
- package/dist/cjs/modules/excel/utils/passthrough-manager.js +0 -133
- package/dist/esm/modules/excel/utils/ooxml-validator.js +0 -493
- package/dist/esm/modules/excel/utils/passthrough-manager.js +0 -129
- package/dist/types/modules/excel/utils/ooxml-validator.d.ts +0 -48
- package/dist/types/modules/excel/utils/passthrough-manager.d.ts +0 -77
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOCX Module - Packager
|
|
3
|
+
*
|
|
4
|
+
* Assembles a DocxDocument model into a DOCX ZIP package using the
|
|
5
|
+
* archive and XML modules. Supports all parts including comments,
|
|
6
|
+
* custom properties, document background, hyperlink relationships,
|
|
7
|
+
* and per-header/footer relationship files.
|
|
8
|
+
*/
|
|
9
|
+
import { zip } from "../archive/create-archive.js";
|
|
10
|
+
import { XmlWriter } from "../xml/writer.js";
|
|
11
|
+
import { ContentType, RelType, PartPath, STD_DOC_ATTRIBUTES } from "./constants.js";
|
|
12
|
+
import { ContentTypesManager } from "./content-types.js";
|
|
13
|
+
import { RelationshipManager } from "./relationships.js";
|
|
14
|
+
import { renderChartPart } from "./writers/chart-writer.js";
|
|
15
|
+
import { renderComments, renderCommentsExtended } from "./writers/comment-writer.js";
|
|
16
|
+
import { renderDocument, CHART_RID_REGISTRY } from "./writers/document-writer.js";
|
|
17
|
+
import { renderFootnotes, renderEndnotes } from "./writers/footnote-writer.js";
|
|
18
|
+
import { renderHeader, renderFooter, renderWatermarkHeader } from "./writers/header-footer-writer.js";
|
|
19
|
+
import { renderNumbering } from "./writers/numbering-writer.js";
|
|
20
|
+
import { renderSettings, renderFontTable, renderCoreProperties, renderAppProperties, renderCustomProperties, renderWebSettings, renderPeople, renderTheme } from "./writers/parts-writer.js";
|
|
21
|
+
import { renderStyles } from "./writers/styles-writer.js";
|
|
22
|
+
/** Render XML to string using XmlWriter. */
|
|
23
|
+
function renderXml(renderFn) {
|
|
24
|
+
const writer = new XmlWriter();
|
|
25
|
+
renderFn(writer);
|
|
26
|
+
return writer.xml;
|
|
27
|
+
}
|
|
28
|
+
/** Get the .rels path for a given part path. */
|
|
29
|
+
function getPartRelsPath(partPath) {
|
|
30
|
+
const lastSlash = partPath.lastIndexOf("/");
|
|
31
|
+
const dir = lastSlash >= 0 ? partPath.substring(0, lastSlash) : "";
|
|
32
|
+
const name = lastSlash >= 0 ? partPath.substring(lastSlash + 1) : partPath;
|
|
33
|
+
return dir ? `${dir}/_rels/${name}.rels` : `_rels/${name}.rels`;
|
|
34
|
+
}
|
|
35
|
+
/** Scan a Run for image rIds. */
|
|
36
|
+
function scanRunForImages(run, out) {
|
|
37
|
+
for (const rc of run.content) {
|
|
38
|
+
if (rc.type === "image" && rc.rId) {
|
|
39
|
+
out.add(rc.rId);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Scan ParagraphChild[] for hyperlinks with URL (no rId yet). */
|
|
44
|
+
function scanChildrenForHyperlinks(children, out) {
|
|
45
|
+
for (const child of children) {
|
|
46
|
+
if ("type" in child && child.type === "hyperlink") {
|
|
47
|
+
const h = child;
|
|
48
|
+
if (h.url && !h.rId) {
|
|
49
|
+
out.push(h);
|
|
50
|
+
}
|
|
51
|
+
// Also scan hyperlink children (runs) for images — handled elsewhere
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Scan ParagraphChild[] for image rIds. */
|
|
56
|
+
function scanChildrenForImages(children, out) {
|
|
57
|
+
for (const child of children) {
|
|
58
|
+
if ("type" in child) {
|
|
59
|
+
if (child.type === "hyperlink") {
|
|
60
|
+
const h = child;
|
|
61
|
+
for (const r of h.children) {
|
|
62
|
+
scanRunForImages(r, out);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// It's a Run (no type field)
|
|
68
|
+
scanRunForImages(child, out);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Recursively collect hyperlinks with URL from body content. */
|
|
73
|
+
function collectHyperlinks(body) {
|
|
74
|
+
const links = [];
|
|
75
|
+
function fromParagraph(p) {
|
|
76
|
+
scanChildrenForHyperlinks(p.children, links);
|
|
77
|
+
}
|
|
78
|
+
function fromTable(t) {
|
|
79
|
+
for (const row of t.rows) {
|
|
80
|
+
for (const cell of row.cells) {
|
|
81
|
+
for (const c of cell.content) {
|
|
82
|
+
if (c.type === "paragraph") {
|
|
83
|
+
fromParagraph(c);
|
|
84
|
+
}
|
|
85
|
+
else if (c.type === "table") {
|
|
86
|
+
fromTable(c);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function fromSdt(sdt) {
|
|
93
|
+
for (const c of sdt.content) {
|
|
94
|
+
if ("type" in c && c.type === "paragraph") {
|
|
95
|
+
fromParagraph(c);
|
|
96
|
+
}
|
|
97
|
+
else if ("type" in c && c.type === "table") {
|
|
98
|
+
fromTable(c);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (const content of body) {
|
|
103
|
+
if (content.type === "paragraph") {
|
|
104
|
+
fromParagraph(content);
|
|
105
|
+
}
|
|
106
|
+
else if (content.type === "table") {
|
|
107
|
+
fromTable(content);
|
|
108
|
+
}
|
|
109
|
+
else if (content.type === "sdt") {
|
|
110
|
+
fromSdt(content);
|
|
111
|
+
}
|
|
112
|
+
else if (content.type === "tableOfContents") {
|
|
113
|
+
// Scan TOC cached paragraphs
|
|
114
|
+
const toc = content;
|
|
115
|
+
if (toc.cachedParagraphs) {
|
|
116
|
+
for (const p of toc.cachedParagraphs) {
|
|
117
|
+
fromParagraph(p);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return links;
|
|
123
|
+
}
|
|
124
|
+
/** Infer a content type for an opaque part based on its file extension. */
|
|
125
|
+
function inferContentType(ext) {
|
|
126
|
+
const map = {
|
|
127
|
+
xml: "application/xml",
|
|
128
|
+
rels: "application/vnd.openxmlformats-package.relationships+xml",
|
|
129
|
+
png: "image/png",
|
|
130
|
+
jpeg: "image/jpeg",
|
|
131
|
+
jpg: "image/jpeg",
|
|
132
|
+
gif: "image/gif",
|
|
133
|
+
bmp: "image/bmp",
|
|
134
|
+
tiff: "image/tiff",
|
|
135
|
+
tif: "image/tiff",
|
|
136
|
+
svg: "image/svg+xml",
|
|
137
|
+
webp: "image/webp",
|
|
138
|
+
emf: "image/x-emf",
|
|
139
|
+
wmf: "image/x-wmf",
|
|
140
|
+
odttf: "application/vnd.openxmlformats-officedocument.obfuscatedFont",
|
|
141
|
+
ttf: "application/x-font-ttf",
|
|
142
|
+
otf: "application/x-font-otf",
|
|
143
|
+
bin: "application/vnd.openxmlformats-officedocument.oleObject",
|
|
144
|
+
vml: "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
145
|
+
};
|
|
146
|
+
return map[ext];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Generic walker: visit all paragraphs within a block list, recursing into
|
|
150
|
+
* tables (including nested tables) and SDTs. This is shared by image/hyperlink
|
|
151
|
+
* collection helpers to ensure consistent coverage.
|
|
152
|
+
*/
|
|
153
|
+
function walkParagraphs(blocks, onParagraph) {
|
|
154
|
+
for (const block of blocks) {
|
|
155
|
+
if (!("type" in block)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (block.type === "paragraph") {
|
|
159
|
+
onParagraph(block);
|
|
160
|
+
}
|
|
161
|
+
else if (block.type === "table") {
|
|
162
|
+
for (const row of block.rows) {
|
|
163
|
+
for (const cell of row.cells) {
|
|
164
|
+
walkParagraphs(cell.content, onParagraph);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (block.type === "sdt") {
|
|
169
|
+
const sdt = block;
|
|
170
|
+
// SDT content may include Paragraph | Run | Table — only the first and last here
|
|
171
|
+
const filtered = sdt.content.filter(c => "type" in c && (c.type === "paragraph" || c.type === "table"));
|
|
172
|
+
walkParagraphs(filtered, onParagraph);
|
|
173
|
+
}
|
|
174
|
+
else if (block.type === "tableOfContents") {
|
|
175
|
+
const toc = block;
|
|
176
|
+
if (toc.cachedParagraphs) {
|
|
177
|
+
walkParagraphs(toc.cachedParagraphs, onParagraph);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Collect all image rIds referenced in header/footer content. */
|
|
183
|
+
function collectImageRidsFromContent(content) {
|
|
184
|
+
const rIds = new Set();
|
|
185
|
+
walkParagraphs(content.children, p => {
|
|
186
|
+
scanChildrenForImages(p.children, rIds);
|
|
187
|
+
});
|
|
188
|
+
return rIds;
|
|
189
|
+
}
|
|
190
|
+
/** Collect hyperlinks from header/footer content. */
|
|
191
|
+
function collectHyperlinksFromHeaderFooter(content) {
|
|
192
|
+
const links = [];
|
|
193
|
+
walkParagraphs(content.children, p => {
|
|
194
|
+
scanChildrenForHyperlinks(p.children, links);
|
|
195
|
+
});
|
|
196
|
+
return links;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Package a DocxDocument model into a DOCX ZIP file.
|
|
200
|
+
* Returns the ZIP bytes as Uint8Array.
|
|
201
|
+
*/
|
|
202
|
+
export async function packageDocx(doc, compressionLevel) {
|
|
203
|
+
const archive = zip({ level: compressionLevel ?? 6 });
|
|
204
|
+
// Managers
|
|
205
|
+
const contentTypes = new ContentTypesManager();
|
|
206
|
+
const packageRels = new RelationshipManager();
|
|
207
|
+
const documentRels = new RelationshipManager();
|
|
208
|
+
// --- Package relationships ---
|
|
209
|
+
packageRels.add(RelType.OfficeDocument, "word/document.xml");
|
|
210
|
+
packageRels.add(RelType.CoreProperties, "docProps/core.xml");
|
|
211
|
+
packageRels.add(RelType.ExtendedProperties, "docProps/app.xml");
|
|
212
|
+
// Custom properties
|
|
213
|
+
const hasCustomProps = doc.customProperties && doc.customProperties.length > 0;
|
|
214
|
+
if (hasCustomProps) {
|
|
215
|
+
packageRels.add(RelType.CustomProperties, "docProps/custom.xml");
|
|
216
|
+
}
|
|
217
|
+
// --- Document relationships ---
|
|
218
|
+
documentRels.add(RelType.Styles, "styles.xml");
|
|
219
|
+
documentRels.add(RelType.Settings, "settings.xml");
|
|
220
|
+
documentRels.add(RelType.FontTable, "fontTable.xml");
|
|
221
|
+
documentRels.add(RelType.Theme, "theme/theme1.xml");
|
|
222
|
+
// Numbering
|
|
223
|
+
const hasNumbering = (doc.abstractNumberings && doc.abstractNumberings.length > 0) ||
|
|
224
|
+
(doc.numberingInstances && doc.numberingInstances.length > 0);
|
|
225
|
+
if (hasNumbering) {
|
|
226
|
+
documentRels.add(RelType.Numbering, "numbering.xml");
|
|
227
|
+
}
|
|
228
|
+
// Footnotes & Endnotes
|
|
229
|
+
const hasFootnotes = doc.footnotes && doc.footnotes.length > 0;
|
|
230
|
+
const hasEndnotes = doc.endnotes && doc.endnotes.length > 0;
|
|
231
|
+
if (hasFootnotes) {
|
|
232
|
+
documentRels.add(RelType.Footnotes, "footnotes.xml");
|
|
233
|
+
}
|
|
234
|
+
if (hasEndnotes) {
|
|
235
|
+
documentRels.add(RelType.Endnotes, "endnotes.xml");
|
|
236
|
+
}
|
|
237
|
+
// Comments
|
|
238
|
+
const hasComments = doc.comments && doc.comments.length > 0;
|
|
239
|
+
if (hasComments) {
|
|
240
|
+
documentRels.add(RelType.Comments, "comments.xml");
|
|
241
|
+
}
|
|
242
|
+
// Images
|
|
243
|
+
const imageExtensions = new Set();
|
|
244
|
+
const imageRidMap = new Map(); // old rId -> new rId
|
|
245
|
+
const imageByRid = new Map(); // O(1) lookup by rId (original or new)
|
|
246
|
+
const svgRidMap = new Map(); // SVG fileName -> svgRId
|
|
247
|
+
const svgFallbacks = [];
|
|
248
|
+
if (doc.images) {
|
|
249
|
+
// Pre-build lookup index
|
|
250
|
+
for (const img of doc.images) {
|
|
251
|
+
if (img.rId) {
|
|
252
|
+
imageByRid.set(img.rId, img);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
for (const img of doc.images) {
|
|
256
|
+
const oldRid = img.rId;
|
|
257
|
+
if (img.mediaType === "svg" && img.fallbackData) {
|
|
258
|
+
// SVG with fallback: register PNG fallback as main image, SVG as separate
|
|
259
|
+
const baseName = img.fileName.replace(/\.[^.]+$/, "");
|
|
260
|
+
const fallbackFileName = `${baseName}_fallback.png`;
|
|
261
|
+
// Register PNG fallback as the main rId
|
|
262
|
+
const fbRId = documentRels.add(RelType.Image, `media/${fallbackFileName}`);
|
|
263
|
+
img.rId = fbRId;
|
|
264
|
+
if (oldRid) {
|
|
265
|
+
imageRidMap.set(oldRid, fbRId);
|
|
266
|
+
}
|
|
267
|
+
imageExtensions.add("png");
|
|
268
|
+
// Register SVG as separate image
|
|
269
|
+
const svgRId = documentRels.add(RelType.Image, `media/${img.fileName}`);
|
|
270
|
+
svgRidMap.set(img.fileName, svgRId);
|
|
271
|
+
const ext = img.fileName.split(".").pop()?.toLowerCase();
|
|
272
|
+
if (ext) {
|
|
273
|
+
imageExtensions.add(ext);
|
|
274
|
+
}
|
|
275
|
+
svgFallbacks.push({ fallbackFileName, data: img.fallbackData });
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
const rId = documentRels.add(RelType.Image, `media/${img.fileName}`);
|
|
279
|
+
img.rId = rId;
|
|
280
|
+
if (oldRid) {
|
|
281
|
+
imageRidMap.set(oldRid, rId);
|
|
282
|
+
}
|
|
283
|
+
const ext = img.fileName.split(".").pop()?.toLowerCase();
|
|
284
|
+
if (ext) {
|
|
285
|
+
imageExtensions.add(ext);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Update FloatingImage rIds to match new image rIds
|
|
291
|
+
if (imageRidMap.size > 0) {
|
|
292
|
+
for (const content of doc.body) {
|
|
293
|
+
if (content.type === "floatingImage") {
|
|
294
|
+
const fi = content;
|
|
295
|
+
if (fi.rId && imageRidMap.has(fi.rId)) {
|
|
296
|
+
// Already mapped — the image's rId was updated in-place above
|
|
297
|
+
// but floatingImage still has the old rId; update it
|
|
298
|
+
}
|
|
299
|
+
// FloatingImage references images by rId; find the matching new rId
|
|
300
|
+
if (fi.rId) {
|
|
301
|
+
const img = imageByRid.get(fi.rId);
|
|
302
|
+
if (!img) {
|
|
303
|
+
// Old rId — look up in map
|
|
304
|
+
const newRid = imageRidMap.get(fi.rId);
|
|
305
|
+
if (newRid) {
|
|
306
|
+
fi.rId = newRid;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// Assign svgRId to inline and floating images that reference SVG files
|
|
314
|
+
if (svgRidMap.size > 0 && doc.images) {
|
|
315
|
+
const assignSvgRId = (rId, target) => {
|
|
316
|
+
const img = doc.images.find(i => i.rId === rId || imageRidMap.get(rId) === i.rId);
|
|
317
|
+
if (img && img.mediaType === "svg" && img.fallbackData) {
|
|
318
|
+
const svgRId = svgRidMap.get(img.fileName);
|
|
319
|
+
if (svgRId) {
|
|
320
|
+
target.svgRId = svgRId;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
for (const content of doc.body) {
|
|
325
|
+
if (content.type === "floatingImage") {
|
|
326
|
+
assignSvgRId(content.rId, content);
|
|
327
|
+
}
|
|
328
|
+
else if (content.type === "paragraph") {
|
|
329
|
+
for (const child of content.children ?? []) {
|
|
330
|
+
if ("content" in child && Array.isArray(child.content)) {
|
|
331
|
+
for (const c of child.content) {
|
|
332
|
+
if (c.type === "image" && c.rId) {
|
|
333
|
+
assignSvgRId(c.rId, c);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// Hyperlinks (external)
|
|
342
|
+
const hyperlinks = collectHyperlinks(doc.body);
|
|
343
|
+
for (const link of hyperlinks) {
|
|
344
|
+
if (link.url) {
|
|
345
|
+
const rId = documentRels.add(RelType.Hyperlink, link.url, "External");
|
|
346
|
+
link.rId = rId;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Process altChunk body items: register relationship and prepare data part
|
|
350
|
+
const altChunks = [];
|
|
351
|
+
collectAltChunks(doc.body, altChunks);
|
|
352
|
+
altChunks.forEach((chunk, i) => {
|
|
353
|
+
const fileName = chunk.fileName ?? `afchunk${i + 1}.html`;
|
|
354
|
+
// Register relationship for the alt chunk
|
|
355
|
+
const rId = documentRels.add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk", fileName);
|
|
356
|
+
chunk.rId = rId;
|
|
357
|
+
// Register content type
|
|
358
|
+
const ct = chunk.contentType ?? "text/html";
|
|
359
|
+
contentTypes.addOverride(`/word/${fileName}`, ct);
|
|
360
|
+
// Write data to archive
|
|
361
|
+
if (chunk.data) {
|
|
362
|
+
archive.add(`word/${fileName}`, chunk.data);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
// Headers
|
|
366
|
+
let headerIndex = 1;
|
|
367
|
+
const headerRelManagers = new Map();
|
|
368
|
+
if (doc.headers) {
|
|
369
|
+
for (const [key, headerDef] of doc.headers) {
|
|
370
|
+
const rId = documentRels.add(RelType.Header, `header${headerIndex}.xml`);
|
|
371
|
+
headerDef.rId = rId;
|
|
372
|
+
// Create per-header relationship manager for images and hyperlinks
|
|
373
|
+
const hRels = new RelationshipManager();
|
|
374
|
+
const imgRids = collectImageRidsFromContent(headerDef.content);
|
|
375
|
+
if (imgRids.size > 0 && doc.images) {
|
|
376
|
+
for (const oldRid of imgRids) {
|
|
377
|
+
// O(1) lookup: direct or via remap
|
|
378
|
+
const img = imageByRid.get(oldRid) ?? imageByRid.get(imageRidMap.get(oldRid) ?? "");
|
|
379
|
+
if (img) {
|
|
380
|
+
hRels.addWithId(oldRid, RelType.Image, `media/${img.fileName}`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// Hyperlinks in header
|
|
385
|
+
const hLinks = collectHyperlinksFromHeaderFooter(headerDef.content);
|
|
386
|
+
for (const link of hLinks) {
|
|
387
|
+
if (link.url) {
|
|
388
|
+
const linkRId = hRels.add(RelType.Hyperlink, link.url, "External");
|
|
389
|
+
link.rId = linkRId;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (hRels.count > 0) {
|
|
393
|
+
headerRelManagers.set(key, hRels);
|
|
394
|
+
}
|
|
395
|
+
headerIndex++;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
// Footers
|
|
399
|
+
let footerIndex = 1;
|
|
400
|
+
const footerRelManagers = new Map();
|
|
401
|
+
if (doc.footers) {
|
|
402
|
+
for (const [key, footerDef] of doc.footers) {
|
|
403
|
+
const rId = documentRels.add(RelType.Footer, `footer${footerIndex}.xml`);
|
|
404
|
+
footerDef.rId = rId;
|
|
405
|
+
// Create per-footer relationship manager for images and hyperlinks
|
|
406
|
+
const fRels = new RelationshipManager();
|
|
407
|
+
const imgRids = collectImageRidsFromContent(footerDef.content);
|
|
408
|
+
if (imgRids.size > 0 && doc.images) {
|
|
409
|
+
for (const oldRid of imgRids) {
|
|
410
|
+
const img = imageByRid.get(oldRid) ?? imageByRid.get(imageRidMap.get(oldRid) ?? "");
|
|
411
|
+
if (img) {
|
|
412
|
+
fRels.addWithId(oldRid, RelType.Image, `media/${img.fileName}`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
// Hyperlinks in footer
|
|
417
|
+
const fLinks = collectHyperlinksFromHeaderFooter(footerDef.content);
|
|
418
|
+
for (const link of fLinks) {
|
|
419
|
+
if (link.url) {
|
|
420
|
+
const linkRId = fRels.add(RelType.Hyperlink, link.url, "External");
|
|
421
|
+
link.rId = linkRId;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
if (fRels.count > 0) {
|
|
425
|
+
footerRelManagers.set(key, fRels);
|
|
426
|
+
}
|
|
427
|
+
footerIndex++;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// Watermark header (auto-generated if doc.watermark is set)
|
|
431
|
+
let watermarkHeaderIndex;
|
|
432
|
+
let watermarkHeaderRels;
|
|
433
|
+
let watermarkHeaderRId;
|
|
434
|
+
if (doc.watermark) {
|
|
435
|
+
// Use next header index
|
|
436
|
+
const wmHdrIdx = headerIndex;
|
|
437
|
+
watermarkHeaderRId = documentRels.add(RelType.Header, `header${wmHdrIdx}.xml`);
|
|
438
|
+
watermarkHeaderIndex = wmHdrIdx;
|
|
439
|
+
// If image watermark, add image relationship in header .rels
|
|
440
|
+
if (doc.watermark.type === "image") {
|
|
441
|
+
const wmRels = new RelationshipManager();
|
|
442
|
+
const wmRId = doc.watermark.rId;
|
|
443
|
+
const img = imageByRid.get(wmRId) ?? imageByRid.get(imageRidMap.get(wmRId) ?? "");
|
|
444
|
+
if (img) {
|
|
445
|
+
wmRels.addWithId(wmRId, RelType.Image, `media/${img.fileName}`);
|
|
446
|
+
}
|
|
447
|
+
watermarkHeaderRels = wmRels;
|
|
448
|
+
}
|
|
449
|
+
headerIndex++;
|
|
450
|
+
}
|
|
451
|
+
// --- Content Types ---
|
|
452
|
+
contentTypes.addImageDefaults(imageExtensions);
|
|
453
|
+
contentTypes.addOverride(PartPath.Document, ContentType.Document);
|
|
454
|
+
contentTypes.addOverride(PartPath.Styles, ContentType.Styles);
|
|
455
|
+
contentTypes.addOverride(PartPath.Settings, ContentType.Settings);
|
|
456
|
+
contentTypes.addOverride(PartPath.FontTable, ContentType.FontTable);
|
|
457
|
+
contentTypes.addOverride(PartPath.Theme, ContentType.Theme);
|
|
458
|
+
if (hasNumbering) {
|
|
459
|
+
contentTypes.addOverride(PartPath.Numbering, ContentType.Numbering);
|
|
460
|
+
}
|
|
461
|
+
if (hasFootnotes) {
|
|
462
|
+
contentTypes.addOverride(PartPath.Footnotes, ContentType.Footnotes);
|
|
463
|
+
}
|
|
464
|
+
if (hasEndnotes) {
|
|
465
|
+
contentTypes.addOverride(PartPath.Endnotes, ContentType.Endnotes);
|
|
466
|
+
}
|
|
467
|
+
if (hasComments) {
|
|
468
|
+
contentTypes.addOverride(PartPath.Comments, ContentType.Comments);
|
|
469
|
+
}
|
|
470
|
+
headerIndex = 1;
|
|
471
|
+
if (doc.headers) {
|
|
472
|
+
for (const [,] of doc.headers) {
|
|
473
|
+
contentTypes.addOverride(PartPath.header(headerIndex), ContentType.Header);
|
|
474
|
+
headerIndex++;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
footerIndex = 1;
|
|
478
|
+
if (doc.footers) {
|
|
479
|
+
for (const [,] of doc.footers) {
|
|
480
|
+
contentTypes.addOverride(PartPath.footer(footerIndex), ContentType.Footer);
|
|
481
|
+
footerIndex++;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (watermarkHeaderIndex !== undefined) {
|
|
485
|
+
contentTypes.addOverride(PartPath.header(watermarkHeaderIndex), ContentType.Header);
|
|
486
|
+
}
|
|
487
|
+
contentTypes.addOverride(PartPath.CoreProps, ContentType.CoreProperties);
|
|
488
|
+
contentTypes.addOverride(PartPath.AppProps, ContentType.ExtendedProperties);
|
|
489
|
+
if (hasCustomProps) {
|
|
490
|
+
contentTypes.addOverride(PartPath.CustomProps, ContentType.CustomProperties);
|
|
491
|
+
}
|
|
492
|
+
// --- Generate & add parts to archive ---
|
|
493
|
+
// Note: [Content_Types].xml and _rels/.rels are serialized LAST so that any
|
|
494
|
+
// relationships/content types registered during content rendering (e.g.
|
|
495
|
+
// thumbnails, chart parts, alt chunks) are included.
|
|
496
|
+
// word/_rels/document.xml.rels
|
|
497
|
+
archive.add(PartPath.DocumentRels, renderXml(xml => documentRels.render(xml)));
|
|
498
|
+
// Build an effective doc that includes the auto-generated watermark header
|
|
499
|
+
// reference in section properties (without mutating the caller's doc).
|
|
500
|
+
let effectiveDoc = doc;
|
|
501
|
+
if (watermarkHeaderIndex !== undefined && watermarkHeaderRId) {
|
|
502
|
+
const existingHeaders = doc.sectionProperties?.headers
|
|
503
|
+
? [...doc.sectionProperties.headers]
|
|
504
|
+
: [];
|
|
505
|
+
existingHeaders.push({
|
|
506
|
+
type: "default",
|
|
507
|
+
rId: watermarkHeaderRId
|
|
508
|
+
});
|
|
509
|
+
effectiveDoc = {
|
|
510
|
+
...doc,
|
|
511
|
+
sectionProperties: {
|
|
512
|
+
...doc.sectionProperties,
|
|
513
|
+
headers: existingHeaders
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
// Collect charts and register relationships BEFORE rendering document.xml
|
|
518
|
+
const charts = [];
|
|
519
|
+
collectCharts(doc.body, charts);
|
|
520
|
+
if (doc.headers) {
|
|
521
|
+
for (const [, h] of doc.headers) {
|
|
522
|
+
collectChartsFromHeaderFooter(h.content, charts);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (doc.footers) {
|
|
526
|
+
for (const [, f] of doc.footers) {
|
|
527
|
+
collectChartsFromHeaderFooter(f.content, charts);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const chartRIds = [];
|
|
531
|
+
charts.forEach(chartContent => {
|
|
532
|
+
const num = chartRIds.length + 1;
|
|
533
|
+
const rId = documentRels.add(RelType.Chart, `charts/chart${num}.xml`);
|
|
534
|
+
chartRIds.push(rId);
|
|
535
|
+
// Store rId in registry so renderChartDrawing can look it up
|
|
536
|
+
CHART_RID_REGISTRY.set(chartContent, rId);
|
|
537
|
+
});
|
|
538
|
+
// word/document.xml
|
|
539
|
+
archive.add(PartPath.Document, renderXml(xml => renderDocument(xml, effectiveDoc)));
|
|
540
|
+
// word/styles.xml
|
|
541
|
+
archive.add(PartPath.Styles, renderXml(xml => renderStyles(xml, doc.docDefaults, doc.styles)));
|
|
542
|
+
// word/settings.xml
|
|
543
|
+
archive.add(PartPath.Settings, renderXml(xml => renderSettings(xml, doc.settings)));
|
|
544
|
+
// word/fontTable.xml
|
|
545
|
+
archive.add(PartPath.FontTable, renderXml(xml => renderFontTable(xml, doc.fonts)));
|
|
546
|
+
// word/fonts/*.odttf (embedded fonts)
|
|
547
|
+
if (doc.embeddedFonts && doc.embeddedFonts.length > 0) {
|
|
548
|
+
const fontTableRels = new RelationshipManager();
|
|
549
|
+
const usedRIds = new Set();
|
|
550
|
+
// Collect rIds referenced in fontTable
|
|
551
|
+
if (doc.fonts) {
|
|
552
|
+
for (const font of doc.fonts) {
|
|
553
|
+
if (font.embedRegular) {
|
|
554
|
+
usedRIds.add(font.embedRegular);
|
|
555
|
+
}
|
|
556
|
+
if (font.embedBold) {
|
|
557
|
+
usedRIds.add(font.embedBold);
|
|
558
|
+
}
|
|
559
|
+
if (font.embedItalic) {
|
|
560
|
+
usedRIds.add(font.embedItalic);
|
|
561
|
+
}
|
|
562
|
+
if (font.embedBoldItalic) {
|
|
563
|
+
usedRIds.add(font.embedBoldItalic);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
for (const ef of doc.embeddedFonts) {
|
|
568
|
+
const partPath = `word/fonts/${ef.fileName}`;
|
|
569
|
+
archive.add(partPath, ef.data);
|
|
570
|
+
// Register relationship from fontTable.xml
|
|
571
|
+
if (usedRIds.has(ef.rId)) {
|
|
572
|
+
fontTableRels.addWithId(ef.rId, RelType.Font, `fonts/${ef.fileName}`);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
// Add anyway so the embedded font isn't orphaned
|
|
576
|
+
fontTableRels.addWithId(ef.rId, RelType.Font, `fonts/${ef.fileName}`);
|
|
577
|
+
}
|
|
578
|
+
// Register content type for .odttf / .ttf
|
|
579
|
+
const ext = ef.fileName.split(".").pop()?.toLowerCase();
|
|
580
|
+
if (ext === "odttf") {
|
|
581
|
+
contentTypes.addDefault("odttf", ContentType.ObfuscatedFont);
|
|
582
|
+
}
|
|
583
|
+
else if (ext === "ttf") {
|
|
584
|
+
contentTypes.addDefault("ttf", "application/x-font-ttf");
|
|
585
|
+
}
|
|
586
|
+
else if (ext === "otf") {
|
|
587
|
+
contentTypes.addDefault("otf", "application/x-font-otf");
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
// Write fontTable.xml.rels
|
|
591
|
+
archive.add("word/_rels/fontTable.xml.rels", renderXml(xml => fontTableRels.render(xml)));
|
|
592
|
+
}
|
|
593
|
+
// Custom XML parts (for SDT data binding)
|
|
594
|
+
if (doc.customXmlParts && doc.customXmlParts.length > 0) {
|
|
595
|
+
doc.customXmlParts.forEach((part, i) => {
|
|
596
|
+
const num = i + 1;
|
|
597
|
+
const itemPath = `word/customXml/item${num}.xml`;
|
|
598
|
+
const propsPath = `word/customXml/itemProps${num}.xml`;
|
|
599
|
+
// Write the XML content
|
|
600
|
+
archive.add(itemPath, part.xmlContent);
|
|
601
|
+
// Write itemProps*.xml
|
|
602
|
+
const propsXml = renderXml(xml => {
|
|
603
|
+
xml.openXml(STD_DOC_ATTRIBUTES);
|
|
604
|
+
xml.openNode("ds:datastoreItem", {
|
|
605
|
+
"ds:itemID": `{${part.itemId}}`,
|
|
606
|
+
"xmlns:ds": "http://schemas.openxmlformats.org/officeDocument/2006/customXml"
|
|
607
|
+
});
|
|
608
|
+
if (part.schemaReferences && part.schemaReferences.length > 0) {
|
|
609
|
+
xml.openNode("ds:schemaRefs");
|
|
610
|
+
for (const uri of part.schemaReferences) {
|
|
611
|
+
xml.leafNode("ds:schemaRef", { "ds:uri": uri });
|
|
612
|
+
}
|
|
613
|
+
xml.closeNode();
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
xml.leafNode("ds:schemaRefs");
|
|
617
|
+
}
|
|
618
|
+
xml.closeNode();
|
|
619
|
+
});
|
|
620
|
+
archive.add(propsPath, propsXml);
|
|
621
|
+
// Write item rels (links itemN.xml → itemPropsN.xml)
|
|
622
|
+
const itemRels = new RelationshipManager();
|
|
623
|
+
itemRels.add(RelType.CustomXmlProps, `itemProps${num}.xml`);
|
|
624
|
+
archive.add(`word/customXml/_rels/item${num}.xml.rels`, renderXml(xml => itemRels.render(xml)));
|
|
625
|
+
// Register content types
|
|
626
|
+
contentTypes.addOverride(`/word/customXml/itemProps${num}.xml`, "application/vnd.openxmlformats-officedocument.customXmlProperties+xml");
|
|
627
|
+
// Add to document rels
|
|
628
|
+
documentRels.add(RelType.CustomXml, `customXml/item${num}.xml`);
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
// word/theme/theme1.xml
|
|
632
|
+
archive.add(PartPath.Theme, renderXml(xml => renderTheme(xml, doc.theme)));
|
|
633
|
+
// word/numbering.xml
|
|
634
|
+
if (hasNumbering) {
|
|
635
|
+
archive.add(PartPath.Numbering, renderXml(xml => renderNumbering(xml, doc.abstractNumberings, doc.numberingInstances, doc.numPicBullets)));
|
|
636
|
+
}
|
|
637
|
+
// word/footnotes.xml
|
|
638
|
+
if (hasFootnotes) {
|
|
639
|
+
archive.add(PartPath.Footnotes, renderXml(xml => renderFootnotes(xml, doc.footnotes)));
|
|
640
|
+
}
|
|
641
|
+
// word/endnotes.xml
|
|
642
|
+
if (hasEndnotes) {
|
|
643
|
+
archive.add(PartPath.Endnotes, renderXml(xml => renderEndnotes(xml, doc.endnotes)));
|
|
644
|
+
}
|
|
645
|
+
// word/comments.xml
|
|
646
|
+
if (hasComments) {
|
|
647
|
+
archive.add(PartPath.Comments, renderXml(xml => renderComments(xml, doc.comments)));
|
|
648
|
+
// word/commentsExtended.xml (for done/parentId)
|
|
649
|
+
const hasExtended = doc.comments.some(c => c.done !== undefined || c.parentId !== undefined);
|
|
650
|
+
if (hasExtended) {
|
|
651
|
+
const extXml = renderXml(xml => renderCommentsExtended(xml, doc.comments));
|
|
652
|
+
archive.add(PartPath.CommentsExtended, extXml);
|
|
653
|
+
documentRels.add(RelType.CommentsExtended, "commentsExtended.xml");
|
|
654
|
+
contentTypes.addOverride(`/${PartPath.CommentsExtended}`, ContentType.CommentsExtended);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// Headers
|
|
658
|
+
headerIndex = 1;
|
|
659
|
+
if (doc.headers) {
|
|
660
|
+
let hIdx = 0;
|
|
661
|
+
const keys = [...doc.headers.keys()];
|
|
662
|
+
for (const [, headerDef] of doc.headers) {
|
|
663
|
+
archive.add(PartPath.header(headerIndex), renderXml(xml => renderHeader(xml, headerDef.content)));
|
|
664
|
+
// Header .rels file
|
|
665
|
+
const hKey = keys[hIdx];
|
|
666
|
+
const hRels = headerRelManagers.get(hKey);
|
|
667
|
+
if (hRels && hRels.count > 0) {
|
|
668
|
+
archive.add(`word/_rels/header${headerIndex}.xml.rels`, renderXml(xml => hRels.render(xml)));
|
|
669
|
+
}
|
|
670
|
+
headerIndex++;
|
|
671
|
+
hIdx++;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// Footers
|
|
675
|
+
footerIndex = 1;
|
|
676
|
+
if (doc.footers) {
|
|
677
|
+
let fIdx = 0;
|
|
678
|
+
const keys = [...doc.footers.keys()];
|
|
679
|
+
for (const [, footerDef] of doc.footers) {
|
|
680
|
+
archive.add(PartPath.footer(footerIndex), renderXml(xml => renderFooter(xml, footerDef.content)));
|
|
681
|
+
// Footer .rels file
|
|
682
|
+
const fKey = keys[fIdx];
|
|
683
|
+
const fRels = footerRelManagers.get(fKey);
|
|
684
|
+
if (fRels && fRels.count > 0) {
|
|
685
|
+
archive.add(`word/_rels/footer${footerIndex}.xml.rels`, renderXml(xml => fRels.render(xml)));
|
|
686
|
+
}
|
|
687
|
+
footerIndex++;
|
|
688
|
+
fIdx++;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
// Watermark header
|
|
692
|
+
if (watermarkHeaderIndex !== undefined && doc.watermark) {
|
|
693
|
+
archive.add(PartPath.header(watermarkHeaderIndex), renderXml(xml => renderWatermarkHeader(xml, doc.watermark)));
|
|
694
|
+
if (watermarkHeaderRels && watermarkHeaderRels.count > 0) {
|
|
695
|
+
archive.add(`word/_rels/header${watermarkHeaderIndex}.xml.rels`, renderXml(xml => watermarkHeaderRels.render(xml)));
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
// Media / images
|
|
699
|
+
if (doc.images) {
|
|
700
|
+
for (const img of doc.images) {
|
|
701
|
+
archive.add(PartPath.media(img.fileName), img.data);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
// SVG fallback PNG files
|
|
705
|
+
for (const fb of svgFallbacks) {
|
|
706
|
+
archive.add(PartPath.media(fb.fallbackFileName), fb.data);
|
|
707
|
+
}
|
|
708
|
+
// docProps/core.xml
|
|
709
|
+
archive.add(PartPath.CoreProps, renderXml(xml => renderCoreProperties(xml, doc.coreProperties)));
|
|
710
|
+
// docProps/app.xml
|
|
711
|
+
archive.add(PartPath.AppProps, renderXml(xml => renderAppProperties(xml, doc.appProperties)));
|
|
712
|
+
// docProps/custom.xml
|
|
713
|
+
if (hasCustomProps) {
|
|
714
|
+
archive.add(PartPath.CustomProps, renderXml(xml => renderCustomProperties(xml, doc.customProperties)));
|
|
715
|
+
}
|
|
716
|
+
// word/webSettings.xml
|
|
717
|
+
if (doc.webSettings) {
|
|
718
|
+
archive.add(PartPath.WebSettings, renderXml(xml => renderWebSettings(xml, doc.webSettings)));
|
|
719
|
+
documentRels.add(RelType.WebSettings, "webSettings.xml");
|
|
720
|
+
contentTypes.addOverride(`/${PartPath.WebSettings}`, ContentType.WebSettings);
|
|
721
|
+
}
|
|
722
|
+
// word/people.xml
|
|
723
|
+
if (doc.people && doc.people.length > 0) {
|
|
724
|
+
archive.add(PartPath.People, renderXml(xml => renderPeople(xml, doc.people)));
|
|
725
|
+
documentRels.add(RelType.People, "people.xml");
|
|
726
|
+
contentTypes.addOverride(`/${PartPath.People}`, ContentType.People);
|
|
727
|
+
}
|
|
728
|
+
// docProps/thumbnail
|
|
729
|
+
if (doc.thumbnail) {
|
|
730
|
+
const ext = doc.thumbnail.contentType === "image/jpeg"
|
|
731
|
+
? "jpeg"
|
|
732
|
+
: doc.thumbnail.contentType === "image/png"
|
|
733
|
+
? "png"
|
|
734
|
+
: "wmf";
|
|
735
|
+
const thumbPath = `docProps/thumbnail.${ext}`;
|
|
736
|
+
archive.add(thumbPath, doc.thumbnail.data);
|
|
737
|
+
// Package rels: target is relative to package root (docProps/thumbnail.jpeg)
|
|
738
|
+
packageRels.add("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail", thumbPath);
|
|
739
|
+
contentTypes.addDefault(ext, doc.thumbnail.contentType);
|
|
740
|
+
}
|
|
741
|
+
// Write opaque (unrecognized) parts for round-trip preservation
|
|
742
|
+
if (doc.opaqueParts) {
|
|
743
|
+
for (const part of doc.opaqueParts) {
|
|
744
|
+
archive.add(part.path, part.data);
|
|
745
|
+
// Register content type: explicit > inferred by extension > skip
|
|
746
|
+
const ext = part.path.split(".").pop()?.toLowerCase();
|
|
747
|
+
if (part.contentType) {
|
|
748
|
+
contentTypes.addOverride(`/${part.path}`, part.contentType);
|
|
749
|
+
}
|
|
750
|
+
else if (ext) {
|
|
751
|
+
// Infer from common extensions so [Content_Types].xml isn't incomplete
|
|
752
|
+
const inferred = inferContentType(ext);
|
|
753
|
+
if (inferred) {
|
|
754
|
+
contentTypes.addOverride(`/${part.path}`, inferred);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
// Write part relationships if any
|
|
758
|
+
if (part.relationships && part.relationships.length > 0) {
|
|
759
|
+
const partRels = new RelationshipManager();
|
|
760
|
+
for (const rel of part.relationships) {
|
|
761
|
+
partRels.addWithId(rel.id, rel.type, rel.target, rel.targetMode);
|
|
762
|
+
}
|
|
763
|
+
const relsPath = getPartRelsPath(part.path);
|
|
764
|
+
archive.add(relsPath, renderXml(xml => partRels.render(xml)));
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
// Write chart parts (rIds already registered earlier)
|
|
769
|
+
charts.forEach((chartContent, i) => {
|
|
770
|
+
const num = i + 1;
|
|
771
|
+
const chartPath = `word/charts/chart${num}.xml`;
|
|
772
|
+
// Register chart part
|
|
773
|
+
archive.add(chartPath, renderXml(xml => renderChartPart(xml, chartContent.chart)));
|
|
774
|
+
// Register content type
|
|
775
|
+
contentTypes.addOverride(`/word/charts/chart${num}.xml`, ContentType.Chart);
|
|
776
|
+
});
|
|
777
|
+
// LAST: Write [Content_Types].xml and _rels/.rels after all parts have registered
|
|
778
|
+
// their content types and relationships.
|
|
779
|
+
archive.add(PartPath.ContentTypes, renderXml(xml => contentTypes.render(xml)));
|
|
780
|
+
archive.add(PartPath.PackageRels, renderXml(xml => packageRels.render(xml)));
|
|
781
|
+
return archive.bytes();
|
|
782
|
+
}
|
|
783
|
+
/** Recursively collect altChunks from body content. */
|
|
784
|
+
function collectAltChunks(body, out) {
|
|
785
|
+
for (const item of body) {
|
|
786
|
+
if ("type" in item && item.type === "altChunk") {
|
|
787
|
+
out.push(item);
|
|
788
|
+
}
|
|
789
|
+
else if ("type" in item && item.type === "table") {
|
|
790
|
+
for (const row of item.rows) {
|
|
791
|
+
for (const cell of row.cells) {
|
|
792
|
+
collectAltChunks(cell.content, out);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
else if ("type" in item && item.type === "sdt") {
|
|
797
|
+
collectAltChunks(item.content, out);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
/** Recursively collect chart contents from body content. */
|
|
802
|
+
function collectCharts(body, out) {
|
|
803
|
+
for (const item of body) {
|
|
804
|
+
if ("type" in item && item.type === "chart") {
|
|
805
|
+
out.push(item);
|
|
806
|
+
}
|
|
807
|
+
else if ("type" in item && item.type === "table") {
|
|
808
|
+
for (const row of item.rows) {
|
|
809
|
+
for (const cell of row.cells) {
|
|
810
|
+
collectCharts(cell.content, out);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
else if ("type" in item && item.type === "sdt") {
|
|
815
|
+
collectCharts(item.content, out);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
/** Collect charts from header/footer content. */
|
|
820
|
+
function collectChartsFromHeaderFooter(content, out) {
|
|
821
|
+
collectCharts(content.children, out);
|
|
822
|
+
}
|