@cj-tech-master/excelts 9.5.4 → 9.5.5
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/modules/archive/compression/streaming-compress.browser.js +29 -0
- package/dist/browser/modules/archive/compression/streaming-compress.js +9 -0
- package/dist/browser/modules/archive/compression/worker-pool/pool.browser.js +26 -1
- package/dist/browser/modules/archive/fs/archive-file.d.ts +8 -5
- package/dist/browser/modules/archive/fs/archive-file.js +78 -16
- package/dist/browser/modules/archive/unzip/stream.browser.js +43 -2
- package/dist/browser/modules/excel/chart/chart-ex-builder.js +7 -2
- package/dist/browser/modules/excel/chart/chart-ex-renderer.js +4 -9
- package/dist/browser/modules/excel/chart/chart-ex-types.d.ts +0 -12
- package/dist/browser/modules/excel/chart/chart.d.ts +1 -5
- package/dist/browser/modules/excel/chart/chart.js +1 -7
- package/dist/browser/modules/excel/chart/types.d.ts +0 -6
- package/dist/browser/modules/excel/stream/workbook-reader.browser.js +25 -1
- package/dist/browser/modules/excel/stream/workbook-reader.js +9 -0
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +40 -0
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +228 -13
- package/dist/browser/modules/excel/utils/string-buf.d.ts +5 -26
- package/dist/browser/modules/excel/utils/string-buf.js +4 -81
- package/dist/browser/modules/excel/workbook.browser.js +135 -25
- package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.js +6 -20
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +19 -9
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +32 -8
- package/dist/browser/modules/excel/xlsx/xlsx.d.ts +10 -2
- package/dist/browser/modules/excel/xlsx/xlsx.js +9 -1
- package/dist/browser/modules/pdf/excel-bridge.d.ts +30 -1
- package/dist/browser/modules/pdf/excel-bridge.js +32 -0
- package/dist/browser/modules/pdf/font/metrics.d.ts +3 -52
- package/dist/browser/modules/pdf/font/metrics.js +3 -237
- package/dist/browser/modules/pdf/index.d.ts +1 -1
- package/dist/browser/modules/pdf/index.js +1 -1
- package/dist/browser/modules/pdf/render-layout-to-pdf.d.ts +66 -0
- package/dist/browser/modules/pdf/render-layout-to-pdf.js +647 -0
- package/dist/browser/modules/pdf/word-bridge.d.ts +80 -12
- package/dist/browser/modules/pdf/word-bridge.js +122 -274
- package/dist/browser/modules/stream/index.base.d.ts +2 -0
- package/dist/browser/modules/stream/index.base.js +2 -1
- package/dist/browser/modules/stream/internal/sink-adapter.d.ts +65 -0
- package/dist/browser/modules/stream/internal/sink-adapter.js +198 -0
- package/dist/browser/modules/stream/pull-stream.d.ts +19 -2
- package/dist/browser/modules/stream/pull-stream.js +51 -5
- package/dist/browser/modules/stream/types.d.ts +13 -1
- package/dist/browser/modules/word/advanced/diff.d.ts +61 -0
- package/dist/browser/modules/word/advanced/diff.js +167 -0
- package/dist/browser/modules/word/advanced/drawing-shapes.d.ts +269 -0
- package/dist/browser/modules/word/advanced/drawing-shapes.js +268 -0
- package/dist/browser/modules/word/advanced/field-engine.d.ts +43 -0
- package/dist/browser/modules/word/advanced/field-engine.js +1225 -0
- package/dist/browser/modules/word/advanced/glossary.d.ts +86 -0
- package/dist/browser/modules/word/advanced/glossary.js +79 -0
- package/dist/browser/modules/word/advanced/math-convert.d.ts +30 -0
- package/dist/browser/modules/word/advanced/math-convert.js +595 -0
- package/dist/browser/modules/word/advanced/ole-objects.d.ts +115 -0
- package/dist/browser/modules/word/advanced/ole-objects.js +271 -0
- package/dist/browser/modules/word/advanced/style-map.d.ts +105 -0
- package/dist/browser/modules/word/advanced/style-map.js +322 -0
- package/dist/browser/modules/word/advanced/validation.d.ts +56 -0
- package/dist/browser/modules/word/advanced/validation.js +1065 -0
- package/dist/browser/modules/word/advanced/vba-project.d.ts +91 -0
- package/dist/browser/modules/word/advanced/vba-project.js +265 -0
- package/dist/browser/modules/word/bridge/excel-bridge.d.ts +127 -0
- package/dist/browser/modules/word/bridge/excel-bridge.js +980 -0
- package/dist/browser/modules/word/builder/document-handle.d.ts +151 -0
- package/dist/browser/modules/word/builder/document-handle.js +664 -0
- package/dist/browser/modules/word/builder/paragraph-builders.d.ts +61 -0
- package/dist/browser/modules/word/builder/paragraph-builders.js +90 -0
- package/dist/browser/modules/word/builder/run-builders.d.ts +374 -0
- package/dist/browser/modules/word/builder/run-builders.js +600 -0
- package/dist/browser/modules/word/builder/table-builders.d.ts +23 -0
- package/dist/browser/modules/word/builder/table-builders.js +45 -0
- package/dist/browser/modules/word/constants.d.ts +39 -1
- package/dist/browser/modules/word/constants.js +109 -1
- package/dist/browser/modules/word/convert/conversion-ir.d.ts +210 -0
- package/dist/browser/modules/word/convert/conversion-ir.js +31 -0
- package/dist/browser/modules/word/convert/docx-to-semantic.d.ts +39 -0
- package/dist/browser/modules/word/convert/docx-to-semantic.js +499 -0
- package/dist/browser/modules/word/convert/flat-opc.d.ts +44 -0
- package/dist/browser/modules/word/convert/flat-opc.js +385 -0
- package/dist/browser/modules/word/convert/html/html-import.d.ts +50 -0
- package/dist/browser/modules/word/convert/html/html-import.js +1907 -0
- package/dist/{types/modules/word → browser/modules/word/convert/html}/html-renderer.d.ts +14 -1
- package/dist/{esm/modules/word → browser/modules/word/convert/html}/html-renderer.js +420 -69
- package/dist/browser/modules/word/convert/html/html.d.ts +15 -0
- package/dist/browser/modules/word/convert/html/html.js +15 -0
- package/dist/browser/modules/word/convert/markdown/markdown-import.d.ts +68 -0
- package/dist/browser/modules/word/convert/markdown/markdown-import.js +1325 -0
- package/dist/browser/modules/word/convert/markdown/markdown-renderer.d.ts +25 -0
- package/dist/browser/modules/word/convert/markdown/markdown-renderer.js +634 -0
- package/dist/browser/modules/word/convert/markdown/markdown.d.ts +15 -0
- package/dist/browser/modules/word/convert/markdown/markdown.js +15 -0
- package/dist/browser/modules/word/convert/odt/odt.d.ts +41 -0
- package/dist/browser/modules/word/convert/odt/odt.js +1932 -0
- package/dist/browser/modules/word/{color-utils.d.ts → core/color-utils.d.ts} +8 -1
- package/dist/browser/modules/word/core/color-utils.js +43 -0
- package/dist/browser/modules/word/core/internal-utils.d.ts +90 -0
- package/dist/browser/modules/word/core/internal-utils.js +209 -0
- package/dist/browser/modules/word/core/mapper.d.ts +44 -0
- package/dist/browser/modules/word/core/mapper.js +427 -0
- package/dist/browser/modules/word/core/opc-paths.d.ts +33 -0
- package/dist/browser/modules/word/core/opc-paths.js +48 -0
- package/dist/browser/modules/word/core/text-utils.d.ts +38 -0
- package/dist/browser/modules/word/core/text-utils.js +202 -0
- package/dist/browser/modules/word/core/walker.d.ts +119 -0
- package/dist/browser/modules/word/core/walker.js +570 -0
- package/dist/browser/modules/word/crypto.d.ts +14 -9
- package/dist/browser/modules/word/crypto.js +13 -7
- package/dist/browser/modules/word/document-io.d.ts +59 -27
- package/dist/browser/modules/word/document-io.js +80 -197
- package/dist/browser/modules/word/errors.d.ts +44 -1
- package/dist/browser/modules/word/errors.js +54 -2
- package/dist/browser/modules/word/excel.d.ts +14 -0
- package/dist/browser/modules/word/excel.js +13 -0
- package/dist/browser/modules/word/font/font-embed.d.ts +112 -0
- package/dist/browser/modules/word/font/font-embed.js +646 -0
- package/dist/{esm/modules/word → browser/modules/word/font}/font-obfuscation.js +4 -9
- package/dist/browser/modules/word/font/hyphenation.d.ts +65 -0
- package/dist/browser/modules/word/font/hyphenation.js +4210 -0
- package/dist/browser/modules/word/font/text-shaping.d.ts +58 -0
- package/dist/browser/modules/word/font/text-shaping.js +635 -0
- package/dist/browser/modules/word/html.d.ts +7 -6
- package/dist/browser/modules/word/html.js +6 -5
- package/dist/browser/modules/word/incremental-edit.d.ts +123 -0
- package/dist/browser/modules/word/incremental-edit.js +361 -0
- package/dist/browser/modules/word/index.base.d.ts +194 -10
- package/dist/browser/modules/word/index.base.js +138 -29
- package/dist/browser/modules/word/layout/layout-constants.d.ts +17 -0
- package/dist/browser/modules/word/layout/layout-constants.js +17 -0
- package/dist/browser/modules/word/layout/layout-full.d.ts +53 -0
- package/dist/browser/modules/word/layout/layout-full.js +1696 -0
- package/dist/browser/modules/word/layout/layout-model.d.ts +344 -0
- package/dist/browser/modules/word/layout/layout-model.js +16 -0
- package/dist/browser/modules/word/layout/layout.d.ts +63 -0
- package/dist/browser/modules/word/layout/layout.js +1167 -0
- package/dist/browser/modules/word/layout/render-page.d.ts +57 -0
- package/dist/browser/modules/word/layout/render-page.js +1238 -0
- package/dist/browser/modules/word/markdown.d.ts +14 -0
- package/dist/browser/modules/word/markdown.js +13 -0
- package/dist/browser/modules/word/patcher.d.ts +62 -0
- package/dist/browser/modules/word/patcher.js +537 -0
- package/dist/browser/modules/word/query/compat.d.ts +25 -0
- package/dist/browser/modules/word/query/compat.js +58 -0
- package/dist/browser/modules/word/query/data-binding.d.ts +22 -0
- package/dist/browser/modules/word/query/data-binding.js +392 -0
- package/dist/browser/modules/word/query/form-fields.d.ts +41 -0
- package/dist/browser/modules/word/query/form-fields.js +268 -0
- package/dist/browser/modules/word/query/format-search.d.ts +99 -0
- package/dist/browser/modules/word/query/format-search.js +329 -0
- package/dist/browser/modules/word/query/mail-merge.d.ts +25 -0
- package/dist/browser/modules/word/query/mail-merge.js +111 -0
- package/dist/browser/modules/word/query/merge.d.ts +50 -0
- package/dist/browser/modules/word/query/merge.js +617 -0
- package/dist/browser/modules/word/query/replace.d.ts +47 -0
- package/dist/browser/modules/word/query/replace.js +301 -0
- package/dist/browser/modules/word/query/revisions.d.ts +67 -0
- package/dist/browser/modules/word/query/revisions.js +879 -0
- package/dist/browser/modules/word/query/search.d.ts +129 -0
- package/dist/browser/modules/word/query/search.js +346 -0
- package/dist/browser/modules/word/query/split.d.ts +44 -0
- package/dist/browser/modules/word/query/split.js +135 -0
- package/dist/browser/modules/word/query/style-resolve.d.ts +104 -0
- package/dist/browser/modules/word/query/style-resolve.js +368 -0
- package/dist/browser/modules/word/reader/chart-parser.d.ts +20 -0
- package/dist/browser/modules/word/reader/chart-parser.js +810 -0
- package/dist/browser/modules/word/reader/comments-parser.d.ts +26 -0
- package/dist/browser/modules/word/reader/comments-parser.js +92 -0
- package/dist/browser/modules/word/reader/doc-props-parsers.d.ts +15 -0
- package/dist/browser/modules/word/reader/doc-props-parsers.js +190 -0
- package/dist/browser/modules/word/reader/docx-reader.d.ts +27 -0
- package/dist/browser/modules/word/reader/docx-reader.js +2557 -0
- package/dist/browser/modules/word/reader/drawing-helpers.d.ts +27 -0
- package/dist/browser/modules/word/reader/drawing-helpers.js +84 -0
- package/dist/browser/modules/word/reader/form-field-parser.d.ts +21 -0
- package/dist/browser/modules/word/reader/form-field-parser.js +82 -0
- package/dist/browser/modules/word/reader/image-parsers.d.ts +11 -0
- package/dist/browser/modules/word/reader/image-parsers.js +291 -0
- package/dist/browser/modules/word/reader/math-parser.d.ts +12 -0
- package/dist/browser/modules/word/reader/math-parser.js +422 -0
- package/dist/browser/modules/word/reader/metadata-parsers.d.ts +17 -0
- package/dist/browser/modules/word/reader/metadata-parsers.js +87 -0
- package/dist/browser/modules/word/reader/numbering-parser.d.ts +13 -0
- package/dist/browser/modules/word/reader/numbering-parser.js +166 -0
- package/dist/browser/modules/word/reader/paragraph-section-parsers.d.ts +12 -0
- package/dist/browser/modules/word/reader/paragraph-section-parsers.js +503 -0
- package/dist/browser/modules/word/reader/parse-utils.d.ts +91 -0
- package/dist/browser/modules/word/reader/parse-utils.js +249 -0
- package/dist/browser/modules/word/reader/properties-parsers.d.ts +21 -0
- package/dist/browser/modules/word/reader/properties-parsers.js +332 -0
- package/dist/browser/modules/word/reader/reader-context.d.ts +69 -0
- package/dist/browser/modules/word/reader/reader-context.js +61 -0
- package/dist/browser/modules/word/reader/sdt-helpers.d.ts +29 -0
- package/dist/browser/modules/word/reader/sdt-helpers.js +111 -0
- package/dist/browser/modules/word/reader/settings-parser.d.ts +8 -0
- package/dist/browser/modules/word/reader/settings-parser.js +263 -0
- package/dist/browser/modules/word/reader/styles-parser.d.ts +12 -0
- package/dist/browser/modules/word/reader/styles-parser.js +147 -0
- package/dist/browser/modules/word/reader/table-properties-parsers.d.ts +12 -0
- package/dist/browser/modules/word/reader/table-properties-parsers.js +234 -0
- package/dist/browser/modules/word/reader/theme-parser.d.ts +8 -0
- package/dist/browser/modules/word/reader/theme-parser.js +167 -0
- package/dist/browser/modules/word/reader/watermark-parser.d.ts +15 -0
- package/dist/browser/modules/word/reader/watermark-parser.js +110 -0
- package/dist/browser/modules/word/security/cfb-reader.d.ts +37 -0
- package/dist/browser/modules/word/security/cfb-reader.js +410 -0
- package/dist/browser/modules/word/{digital-signatures.d.ts → security/digital-signatures.d.ts} +19 -11
- package/dist/browser/modules/word/{digital-signatures.js → security/digital-signatures.js} +34 -34
- package/dist/browser/modules/word/security/document-protection.d.ts +93 -0
- package/dist/browser/modules/word/security/document-protection.js +201 -0
- package/dist/{types/modules/word → browser/modules/word/security}/encryption.d.ts +51 -4
- package/dist/browser/modules/word/security/encryption.js +602 -0
- package/dist/browser/modules/word/security/policy.d.ts +80 -0
- package/dist/browser/modules/word/security/policy.js +102 -0
- package/dist/browser/modules/word/template/template-chart.d.ts +56 -0
- package/dist/browser/modules/word/template/template-chart.js +167 -0
- package/dist/browser/modules/word/template/template-datasource.d.ts +154 -0
- package/dist/browser/modules/word/template/template-datasource.js +541 -0
- package/dist/browser/modules/word/template/template-engine.d.ts +121 -0
- package/dist/browser/modules/word/template/template-engine.js +1435 -0
- package/dist/browser/modules/word/types.d.ts +224 -25
- package/dist/browser/modules/word/units.d.ts +26 -0
- package/dist/browser/modules/word/units.js +43 -14
- package/dist/browser/modules/word/{writers → writer}/chart-writer.js +164 -23
- package/dist/browser/modules/word/writer/checkbox-writer.d.ts +17 -0
- package/dist/browser/modules/word/writer/checkbox-writer.js +79 -0
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/comment-writer.d.ts +2 -1
- package/dist/browser/modules/word/{writers → writer}/comment-writer.js +8 -6
- package/dist/browser/modules/word/writer/common-parts.d.ts +57 -0
- package/dist/browser/modules/word/writer/common-parts.js +101 -0
- package/dist/{types/modules/word → browser/modules/word/writer}/content-types.d.ts +2 -2
- package/dist/{esm/modules/word → browser/modules/word/writer}/content-types.js +14 -6
- package/dist/browser/modules/word/writer/document-writer.d.ts +24 -0
- package/dist/browser/modules/word/writer/document-writer.js +473 -0
- package/dist/browser/modules/word/writer/docx-packager.d.ts +35 -0
- package/dist/browser/modules/word/writer/docx-packager.js +1515 -0
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/footnote-writer.d.ts +3 -2
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/footnote-writer.js +13 -10
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/header-footer-writer.d.ts +3 -2
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/header-footer-writer.js +39 -21
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/image-writer.d.ts +1 -1
- package/dist/browser/modules/word/{writers → writer}/image-writer.js +11 -7
- package/dist/browser/modules/word/writer/math-writer.d.ts +20 -0
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/math-writer.js +21 -1
- package/dist/browser/modules/word/{writers → writer}/numbering-writer.d.ts +1 -1
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/numbering-writer.js +11 -4
- package/dist/browser/modules/word/{writers → writer}/paragraph-writer.d.ts +2 -1
- package/dist/browser/modules/word/{writers → writer}/paragraph-writer.js +73 -38
- package/dist/browser/modules/word/{writers → writer}/parts-writer.d.ts +3 -3
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/parts-writer.js +91 -12
- package/dist/browser/modules/word/writer/reference-scanners.d.ts +42 -0
- package/dist/browser/modules/word/writer/reference-scanners.js +111 -0
- package/dist/browser/modules/word/writer/relationships.d.ts +52 -0
- package/dist/browser/modules/word/writer/relationships.js +117 -0
- package/dist/browser/modules/word/writer/render-context.d.ts +124 -0
- package/dist/browser/modules/word/writer/render-context.js +46 -0
- package/dist/browser/modules/word/{writers → writer}/run-writer.d.ts +10 -1
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/run-writer.js +126 -24
- package/dist/browser/modules/word/writer/sdt-writer.d.ts +25 -0
- package/dist/browser/modules/word/writer/sdt-writer.js +189 -0
- package/dist/browser/modules/word/writer/stream-buf.d.ts +37 -0
- package/dist/browser/modules/word/writer/stream-buf.js +73 -0
- package/dist/browser/modules/word/writer/streaming-writer.d.ts +344 -0
- package/dist/browser/modules/word/writer/streaming-writer.js +1382 -0
- package/dist/browser/modules/word/writer/string-buf.d.ts +8 -0
- package/dist/browser/modules/word/writer/string-buf.js +7 -0
- package/dist/browser/modules/word/{writers → writer}/styles-writer.js +32 -1
- package/dist/browser/modules/word/{writers → writer}/table-writer.d.ts +2 -1
- package/dist/browser/modules/word/{writers → writer}/table-writer.js +94 -11
- package/dist/browser/modules/xml/types.d.ts +22 -0
- package/dist/browser/utils/crypto.browser.d.ts +3 -1
- package/dist/browser/utils/crypto.browser.js +3 -1
- package/dist/browser/utils/crypto.d.ts +4 -1
- package/dist/browser/utils/crypto.js +4 -1
- package/dist/browser/utils/font-metrics.d.ts +63 -0
- package/dist/browser/utils/font-metrics.js +293 -0
- package/dist/browser/utils/string-buf.d.ts +42 -0
- package/dist/browser/utils/string-buf.js +89 -0
- package/dist/browser/utils/theme-colors.d.ts +55 -0
- package/dist/browser/utils/theme-colors.js +120 -0
- package/dist/cjs/modules/archive/compression/streaming-compress.browser.js +29 -0
- package/dist/cjs/modules/archive/compression/streaming-compress.js +9 -0
- package/dist/cjs/modules/archive/compression/worker-pool/pool.browser.js +26 -1
- package/dist/cjs/modules/archive/fs/archive-file.js +78 -16
- package/dist/cjs/modules/archive/unzip/stream.browser.js +43 -2
- package/dist/cjs/modules/excel/chart/chart-ex-builder.js +7 -2
- package/dist/cjs/modules/excel/chart/chart-ex-renderer.js +4 -9
- package/dist/cjs/modules/excel/chart/chart.js +1 -7
- package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +25 -1
- package/dist/cjs/modules/excel/stream/workbook-reader.js +9 -0
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +228 -13
- package/dist/cjs/modules/excel/utils/string-buf.js +5 -81
- package/dist/cjs/modules/excel/workbook.browser.js +135 -25
- package/dist/cjs/modules/excel/xlsx/xform/chart/chart-space-xform.js +6 -20
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +32 -8
- package/dist/cjs/modules/excel/xlsx/xlsx.js +9 -1
- package/dist/cjs/modules/pdf/excel-bridge.js +33 -0
- package/dist/cjs/modules/pdf/font/metrics.js +11 -244
- package/dist/cjs/modules/pdf/index.js +2 -1
- package/dist/cjs/modules/pdf/render-layout-to-pdf.js +651 -0
- package/dist/cjs/modules/pdf/word-bridge.js +155 -274
- package/dist/cjs/modules/stream/index.base.js +4 -2
- package/dist/cjs/modules/stream/internal/sink-adapter.js +202 -0
- package/dist/cjs/modules/stream/pull-stream.js +51 -5
- package/dist/cjs/modules/word/advanced/diff.js +170 -0
- package/dist/cjs/modules/word/advanced/drawing-shapes.js +279 -0
- package/dist/cjs/modules/word/advanced/field-engine.js +1229 -0
- package/dist/cjs/modules/word/advanced/glossary.js +87 -0
- package/dist/cjs/modules/word/advanced/math-convert.js +599 -0
- package/dist/cjs/modules/word/advanced/ole-objects.js +277 -0
- package/dist/cjs/modules/word/advanced/style-map.js +329 -0
- package/dist/cjs/modules/word/advanced/validation.js +1068 -0
- package/dist/cjs/modules/word/advanced/vba-project.js +274 -0
- package/dist/cjs/modules/word/bridge/excel-bridge.js +1020 -0
- package/dist/cjs/modules/word/builder/document-handle.js +667 -0
- package/dist/cjs/modules/word/builder/paragraph-builders.js +109 -0
- package/dist/cjs/modules/word/builder/run-builders.js +676 -0
- package/dist/cjs/modules/word/builder/table-builders.js +53 -0
- package/dist/cjs/modules/word/constants.js +111 -2
- package/dist/cjs/modules/word/convert/conversion-ir.js +34 -0
- package/dist/cjs/modules/word/convert/docx-to-semantic.js +502 -0
- package/dist/cjs/modules/word/convert/flat-opc.js +390 -0
- package/dist/cjs/modules/word/convert/html/html-import.js +1910 -0
- package/dist/cjs/modules/word/{html-renderer.js → convert/html/html-renderer.js} +420 -69
- package/dist/cjs/modules/word/convert/html/html.js +20 -0
- package/dist/cjs/modules/word/convert/markdown/markdown-import.js +1329 -0
- package/dist/cjs/modules/word/convert/markdown/markdown-renderer.js +637 -0
- package/dist/cjs/modules/word/convert/markdown/markdown.js +21 -0
- package/dist/cjs/modules/word/convert/odt/odt.js +1936 -0
- package/dist/cjs/modules/word/core/color-utils.js +47 -0
- package/dist/cjs/modules/word/core/internal-utils.js +219 -0
- package/dist/cjs/modules/word/core/mapper.js +430 -0
- package/dist/cjs/modules/word/core/opc-paths.js +53 -0
- package/dist/cjs/modules/word/core/text-utils.js +210 -0
- package/dist/cjs/modules/word/core/walker.js +577 -0
- package/dist/cjs/modules/word/crypto.js +19 -8
- package/dist/cjs/modules/word/document-io.js +117 -197
- package/dist/cjs/modules/word/errors.js +59 -13
- package/dist/cjs/modules/word/excel.js +22 -0
- package/dist/cjs/modules/word/font/font-embed.js +652 -0
- package/dist/cjs/modules/word/{font-obfuscation.js → font/font-obfuscation.js} +4 -9
- package/dist/cjs/modules/word/font/hyphenation.js +4216 -0
- package/dist/cjs/modules/word/font/text-shaping.js +640 -0
- package/dist/cjs/modules/word/html.js +9 -7
- package/dist/cjs/modules/word/incremental-edit.js +366 -0
- package/dist/cjs/modules/word/index.base.js +370 -137
- package/dist/cjs/modules/word/layout/layout-constants.js +20 -0
- package/dist/cjs/modules/word/layout/layout-full.js +1699 -0
- package/dist/cjs/modules/word/layout/layout-model.js +17 -0
- package/dist/cjs/modules/word/layout/layout.js +1170 -0
- package/dist/cjs/modules/word/layout/render-page.js +1243 -0
- package/dist/cjs/modules/word/markdown.js +19 -0
- package/dist/cjs/modules/word/patcher.js +539 -0
- package/dist/cjs/modules/word/query/compat.js +61 -0
- package/dist/cjs/modules/word/query/data-binding.js +395 -0
- package/dist/cjs/modules/word/query/form-fields.js +272 -0
- package/dist/cjs/modules/word/query/format-search.js +334 -0
- package/dist/cjs/modules/word/query/mail-merge.js +114 -0
- package/dist/cjs/modules/word/query/merge.js +620 -0
- package/dist/cjs/modules/word/query/replace.js +304 -0
- package/dist/cjs/modules/word/query/revisions.js +885 -0
- package/dist/cjs/modules/word/query/search.js +361 -0
- package/dist/cjs/modules/word/query/split.js +138 -0
- package/dist/cjs/modules/word/query/style-resolve.js +374 -0
- package/dist/cjs/modules/word/reader/chart-parser.js +814 -0
- package/dist/cjs/modules/word/reader/comments-parser.js +96 -0
- package/dist/cjs/modules/word/reader/doc-props-parsers.js +194 -0
- package/dist/cjs/modules/word/reader/docx-reader.js +2560 -0
- package/dist/cjs/modules/word/reader/drawing-helpers.js +90 -0
- package/dist/cjs/modules/word/reader/form-field-parser.js +85 -0
- package/dist/cjs/modules/word/reader/image-parsers.js +293 -0
- package/dist/cjs/modules/word/reader/math-parser.js +424 -0
- package/dist/cjs/modules/word/reader/metadata-parsers.js +93 -0
- package/dist/cjs/modules/word/reader/numbering-parser.js +168 -0
- package/dist/cjs/modules/word/reader/paragraph-section-parsers.js +505 -0
- package/dist/cjs/modules/word/reader/parse-utils.js +271 -0
- package/dist/cjs/modules/word/reader/properties-parsers.js +338 -0
- package/dist/cjs/modules/word/reader/reader-context.js +66 -0
- package/dist/cjs/modules/word/reader/sdt-helpers.js +114 -0
- package/dist/cjs/modules/word/reader/settings-parser.js +265 -0
- package/dist/cjs/modules/word/reader/styles-parser.js +149 -0
- package/dist/cjs/modules/word/reader/table-properties-parsers.js +237 -0
- package/dist/cjs/modules/word/reader/theme-parser.js +169 -0
- package/dist/cjs/modules/word/reader/watermark-parser.js +113 -0
- package/dist/cjs/modules/word/security/cfb-reader.js +414 -0
- package/dist/cjs/modules/word/{digital-signatures.js → security/digital-signatures.js} +34 -34
- package/dist/cjs/modules/word/security/document-protection.js +208 -0
- package/dist/cjs/modules/word/security/encryption.js +612 -0
- package/dist/cjs/modules/word/security/policy.js +106 -0
- package/dist/cjs/modules/word/template/template-chart.js +170 -0
- package/dist/cjs/modules/word/template/template-datasource.js +549 -0
- package/dist/cjs/modules/word/template/template-engine.js +1430 -0
- package/dist/cjs/modules/word/units.js +44 -14
- package/dist/cjs/modules/word/{writers → writer}/chart-writer.js +163 -22
- package/dist/cjs/modules/word/writer/checkbox-writer.js +82 -0
- package/dist/cjs/modules/word/{writers → writer}/comment-writer.js +8 -6
- package/dist/cjs/modules/word/writer/common-parts.js +104 -0
- package/dist/cjs/modules/word/{content-types.js → writer/content-types.js} +14 -6
- package/dist/cjs/modules/word/writer/document-writer.js +478 -0
- package/dist/cjs/modules/word/writer/docx-packager.js +1551 -0
- package/dist/cjs/modules/word/{writers → writer}/footnote-writer.js +13 -10
- package/dist/cjs/modules/word/{writers → writer}/header-footer-writer.js +38 -20
- package/dist/cjs/modules/word/{writers → writer}/image-writer.js +11 -7
- package/dist/cjs/modules/word/{writers → writer}/math-writer.js +21 -1
- package/dist/cjs/modules/word/{writers → writer}/numbering-writer.js +11 -4
- package/dist/cjs/modules/word/{writers → writer}/paragraph-writer.js +72 -37
- package/dist/cjs/modules/word/{writers → writer}/parts-writer.js +91 -12
- package/dist/cjs/modules/word/writer/reference-scanners.js +120 -0
- package/dist/cjs/modules/word/writer/relationships.js +124 -0
- package/dist/cjs/modules/word/writer/render-context.js +51 -0
- package/dist/cjs/modules/word/{writers → writer}/run-writer.js +127 -24
- package/dist/cjs/modules/word/writer/sdt-writer.js +192 -0
- package/dist/cjs/modules/word/writer/stream-buf.js +76 -0
- package/dist/cjs/modules/word/writer/streaming-writer.js +1387 -0
- package/dist/cjs/modules/word/writer/string-buf.js +11 -0
- package/dist/cjs/modules/word/{writers → writer}/styles-writer.js +32 -1
- package/dist/cjs/modules/word/{writers → writer}/table-writer.js +94 -11
- package/dist/cjs/utils/crypto.browser.js +3 -1
- package/dist/cjs/utils/crypto.js +4 -1
- package/dist/cjs/utils/font-metrics.js +303 -0
- package/dist/cjs/utils/string-buf.js +92 -0
- package/dist/cjs/utils/theme-colors.js +126 -0
- package/dist/esm/modules/archive/compression/streaming-compress.browser.js +29 -0
- package/dist/esm/modules/archive/compression/streaming-compress.js +9 -0
- package/dist/esm/modules/archive/compression/worker-pool/pool.browser.js +26 -1
- package/dist/esm/modules/archive/fs/archive-file.js +78 -16
- package/dist/esm/modules/archive/unzip/stream.browser.js +43 -2
- package/dist/esm/modules/excel/chart/chart-ex-builder.js +7 -2
- package/dist/esm/modules/excel/chart/chart-ex-renderer.js +4 -9
- package/dist/esm/modules/excel/chart/chart.js +1 -7
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +25 -1
- package/dist/esm/modules/excel/stream/workbook-reader.js +9 -0
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +228 -13
- package/dist/esm/modules/excel/utils/string-buf.js +4 -81
- package/dist/esm/modules/excel/workbook.browser.js +135 -25
- package/dist/esm/modules/excel/xlsx/xform/chart/chart-space-xform.js +6 -20
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +32 -8
- package/dist/esm/modules/excel/xlsx/xlsx.js +9 -1
- package/dist/esm/modules/pdf/excel-bridge.js +32 -0
- package/dist/esm/modules/pdf/font/metrics.js +3 -237
- package/dist/esm/modules/pdf/index.js +1 -1
- package/dist/esm/modules/pdf/render-layout-to-pdf.js +647 -0
- package/dist/esm/modules/pdf/word-bridge.js +122 -274
- package/dist/esm/modules/stream/index.base.js +2 -1
- package/dist/esm/modules/stream/internal/sink-adapter.js +198 -0
- package/dist/esm/modules/stream/pull-stream.js +51 -5
- package/dist/esm/modules/word/advanced/diff.js +167 -0
- package/dist/esm/modules/word/advanced/drawing-shapes.js +268 -0
- package/dist/esm/modules/word/advanced/field-engine.js +1225 -0
- package/dist/esm/modules/word/advanced/glossary.js +79 -0
- package/dist/esm/modules/word/advanced/math-convert.js +595 -0
- package/dist/esm/modules/word/advanced/ole-objects.js +271 -0
- package/dist/esm/modules/word/advanced/style-map.js +322 -0
- package/dist/esm/modules/word/advanced/validation.js +1065 -0
- package/dist/esm/modules/word/advanced/vba-project.js +265 -0
- package/dist/esm/modules/word/bridge/excel-bridge.js +980 -0
- package/dist/esm/modules/word/builder/document-handle.js +664 -0
- package/dist/esm/modules/word/builder/paragraph-builders.js +90 -0
- package/dist/esm/modules/word/builder/run-builders.js +600 -0
- package/dist/esm/modules/word/builder/table-builders.js +45 -0
- package/dist/esm/modules/word/constants.js +109 -1
- package/dist/esm/modules/word/convert/conversion-ir.js +31 -0
- package/dist/esm/modules/word/convert/docx-to-semantic.js +499 -0
- package/dist/esm/modules/word/convert/flat-opc.js +385 -0
- package/dist/esm/modules/word/convert/html/html-import.js +1907 -0
- package/dist/{browser/modules/word → esm/modules/word/convert/html}/html-renderer.js +420 -69
- package/dist/esm/modules/word/convert/html/html.js +15 -0
- package/dist/esm/modules/word/convert/markdown/markdown-import.js +1325 -0
- package/dist/esm/modules/word/convert/markdown/markdown-renderer.js +634 -0
- package/dist/esm/modules/word/convert/markdown/markdown.js +15 -0
- package/dist/esm/modules/word/convert/odt/odt.js +1932 -0
- package/dist/esm/modules/word/core/color-utils.js +43 -0
- package/dist/esm/modules/word/core/internal-utils.js +209 -0
- package/dist/esm/modules/word/core/mapper.js +427 -0
- package/dist/esm/modules/word/core/opc-paths.js +48 -0
- package/dist/esm/modules/word/core/text-utils.js +202 -0
- package/dist/esm/modules/word/core/walker.js +570 -0
- package/dist/esm/modules/word/crypto.js +13 -7
- package/dist/esm/modules/word/document-io.js +80 -197
- package/dist/esm/modules/word/errors.js +54 -2
- package/dist/esm/modules/word/excel.js +13 -0
- package/dist/esm/modules/word/font/font-embed.js +646 -0
- package/dist/{browser/modules/word → esm/modules/word/font}/font-obfuscation.js +4 -9
- package/dist/esm/modules/word/font/hyphenation.js +4210 -0
- package/dist/esm/modules/word/font/text-shaping.js +635 -0
- package/dist/esm/modules/word/html.js +6 -5
- package/dist/esm/modules/word/incremental-edit.js +361 -0
- package/dist/esm/modules/word/index.base.js +138 -29
- package/dist/esm/modules/word/layout/layout-constants.js +17 -0
- package/dist/esm/modules/word/layout/layout-full.js +1696 -0
- package/dist/esm/modules/word/layout/layout-model.js +16 -0
- package/dist/esm/modules/word/layout/layout.js +1167 -0
- package/dist/esm/modules/word/layout/render-page.js +1238 -0
- package/dist/esm/modules/word/markdown.js +13 -0
- package/dist/esm/modules/word/patcher.js +537 -0
- package/dist/esm/modules/word/query/compat.js +58 -0
- package/dist/esm/modules/word/query/data-binding.js +392 -0
- package/dist/esm/modules/word/query/form-fields.js +268 -0
- package/dist/esm/modules/word/query/format-search.js +329 -0
- package/dist/esm/modules/word/query/mail-merge.js +111 -0
- package/dist/esm/modules/word/query/merge.js +617 -0
- package/dist/esm/modules/word/query/replace.js +301 -0
- package/dist/esm/modules/word/query/revisions.js +879 -0
- package/dist/esm/modules/word/query/search.js +346 -0
- package/dist/esm/modules/word/query/split.js +135 -0
- package/dist/esm/modules/word/query/style-resolve.js +368 -0
- package/dist/esm/modules/word/reader/chart-parser.js +810 -0
- package/dist/esm/modules/word/reader/comments-parser.js +92 -0
- package/dist/esm/modules/word/reader/doc-props-parsers.js +190 -0
- package/dist/esm/modules/word/reader/docx-reader.js +2557 -0
- package/dist/esm/modules/word/reader/drawing-helpers.js +84 -0
- package/dist/esm/modules/word/reader/form-field-parser.js +82 -0
- package/dist/esm/modules/word/reader/image-parsers.js +291 -0
- package/dist/esm/modules/word/reader/math-parser.js +422 -0
- package/dist/esm/modules/word/reader/metadata-parsers.js +87 -0
- package/dist/esm/modules/word/reader/numbering-parser.js +166 -0
- package/dist/esm/modules/word/reader/paragraph-section-parsers.js +503 -0
- package/dist/esm/modules/word/reader/parse-utils.js +249 -0
- package/dist/esm/modules/word/reader/properties-parsers.js +332 -0
- package/dist/esm/modules/word/reader/reader-context.js +61 -0
- package/dist/esm/modules/word/reader/sdt-helpers.js +111 -0
- package/dist/esm/modules/word/reader/settings-parser.js +263 -0
- package/dist/esm/modules/word/reader/styles-parser.js +147 -0
- package/dist/esm/modules/word/reader/table-properties-parsers.js +234 -0
- package/dist/esm/modules/word/reader/theme-parser.js +167 -0
- package/dist/esm/modules/word/reader/watermark-parser.js +110 -0
- package/dist/esm/modules/word/security/cfb-reader.js +410 -0
- package/dist/esm/modules/word/{digital-signatures.js → security/digital-signatures.js} +34 -34
- package/dist/esm/modules/word/security/document-protection.js +201 -0
- package/dist/esm/modules/word/security/encryption.js +602 -0
- package/dist/esm/modules/word/security/policy.js +102 -0
- package/dist/esm/modules/word/template/template-chart.js +167 -0
- package/dist/esm/modules/word/template/template-datasource.js +541 -0
- package/dist/esm/modules/word/template/template-engine.js +1435 -0
- package/dist/esm/modules/word/units.js +43 -14
- package/dist/esm/modules/word/{writers → writer}/chart-writer.js +164 -23
- package/dist/esm/modules/word/writer/checkbox-writer.js +79 -0
- package/dist/esm/modules/word/{writers → writer}/comment-writer.js +8 -6
- package/dist/esm/modules/word/writer/common-parts.js +101 -0
- package/dist/{browser/modules/word → esm/modules/word/writer}/content-types.js +14 -6
- package/dist/esm/modules/word/writer/document-writer.js +473 -0
- package/dist/esm/modules/word/writer/docx-packager.js +1515 -0
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/footnote-writer.js +13 -10
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/header-footer-writer.js +39 -21
- package/dist/esm/modules/word/{writers → writer}/image-writer.js +11 -7
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/math-writer.js +21 -1
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/numbering-writer.js +11 -4
- package/dist/esm/modules/word/{writers → writer}/paragraph-writer.js +73 -38
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/parts-writer.js +91 -12
- package/dist/esm/modules/word/writer/reference-scanners.js +111 -0
- package/dist/esm/modules/word/writer/relationships.js +117 -0
- package/dist/esm/modules/word/writer/render-context.js +46 -0
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/run-writer.js +126 -24
- package/dist/esm/modules/word/writer/sdt-writer.js +189 -0
- package/dist/esm/modules/word/writer/stream-buf.js +73 -0
- package/dist/esm/modules/word/writer/streaming-writer.js +1382 -0
- package/dist/esm/modules/word/writer/string-buf.js +7 -0
- package/dist/esm/modules/word/{writers → writer}/styles-writer.js +32 -1
- package/dist/esm/modules/word/{writers → writer}/table-writer.js +94 -11
- package/dist/esm/utils/crypto.browser.js +3 -1
- package/dist/esm/utils/crypto.js +4 -1
- package/dist/esm/utils/font-metrics.js +293 -0
- package/dist/esm/utils/string-buf.js +89 -0
- package/dist/esm/utils/theme-colors.js +120 -0
- package/dist/iife/excelts.iife.js +70692 -70337
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +57 -57
- package/dist/types/modules/archive/fs/archive-file.d.ts +8 -5
- package/dist/types/modules/excel/chart/chart-ex-types.d.ts +0 -12
- package/dist/types/modules/excel/chart/chart.d.ts +1 -5
- package/dist/types/modules/excel/chart/types.d.ts +0 -6
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +40 -0
- package/dist/types/modules/excel/utils/string-buf.d.ts +5 -26
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +19 -9
- package/dist/types/modules/excel/xlsx/xlsx.d.ts +10 -2
- package/dist/types/modules/pdf/excel-bridge.d.ts +30 -1
- package/dist/types/modules/pdf/font/metrics.d.ts +3 -52
- package/dist/types/modules/pdf/index.d.ts +1 -1
- package/dist/types/modules/pdf/render-layout-to-pdf.d.ts +66 -0
- package/dist/types/modules/pdf/word-bridge.d.ts +80 -12
- package/dist/types/modules/stream/index.base.d.ts +2 -0
- package/dist/types/modules/stream/internal/sink-adapter.d.ts +65 -0
- package/dist/types/modules/stream/pull-stream.d.ts +19 -2
- package/dist/types/modules/stream/types.d.ts +13 -1
- package/dist/types/modules/word/advanced/diff.d.ts +61 -0
- package/dist/types/modules/word/advanced/drawing-shapes.d.ts +269 -0
- package/dist/types/modules/word/advanced/field-engine.d.ts +43 -0
- package/dist/types/modules/word/advanced/glossary.d.ts +86 -0
- package/dist/types/modules/word/advanced/math-convert.d.ts +30 -0
- package/dist/types/modules/word/advanced/ole-objects.d.ts +115 -0
- package/dist/types/modules/word/advanced/style-map.d.ts +105 -0
- package/dist/types/modules/word/advanced/validation.d.ts +56 -0
- package/dist/types/modules/word/advanced/vba-project.d.ts +91 -0
- package/dist/types/modules/word/bridge/excel-bridge.d.ts +127 -0
- package/dist/types/modules/word/builder/document-handle.d.ts +151 -0
- package/dist/types/modules/word/builder/paragraph-builders.d.ts +61 -0
- package/dist/types/modules/word/builder/run-builders.d.ts +374 -0
- package/dist/types/modules/word/builder/table-builders.d.ts +23 -0
- package/dist/types/modules/word/constants.d.ts +39 -1
- package/dist/types/modules/word/convert/conversion-ir.d.ts +210 -0
- package/dist/types/modules/word/convert/docx-to-semantic.d.ts +39 -0
- package/dist/types/modules/word/convert/flat-opc.d.ts +44 -0
- package/dist/types/modules/word/convert/html/html-import.d.ts +50 -0
- package/dist/{browser/modules/word → types/modules/word/convert/html}/html-renderer.d.ts +14 -1
- package/dist/types/modules/word/convert/html/html.d.ts +15 -0
- package/dist/types/modules/word/convert/markdown/markdown-import.d.ts +68 -0
- package/dist/types/modules/word/convert/markdown/markdown-renderer.d.ts +25 -0
- package/dist/types/modules/word/convert/markdown/markdown.d.ts +15 -0
- package/dist/types/modules/word/convert/odt/odt.d.ts +41 -0
- package/dist/types/modules/word/{color-utils.d.ts → core/color-utils.d.ts} +8 -1
- package/dist/types/modules/word/core/internal-utils.d.ts +90 -0
- package/dist/types/modules/word/core/mapper.d.ts +44 -0
- package/dist/types/modules/word/core/opc-paths.d.ts +33 -0
- package/dist/types/modules/word/core/text-utils.d.ts +38 -0
- package/dist/types/modules/word/core/walker.d.ts +119 -0
- package/dist/types/modules/word/crypto.d.ts +14 -9
- package/dist/types/modules/word/document-io.d.ts +59 -27
- package/dist/types/modules/word/errors.d.ts +44 -1
- package/dist/types/modules/word/excel.d.ts +14 -0
- package/dist/types/modules/word/font/font-embed.d.ts +112 -0
- package/dist/types/modules/word/font/hyphenation.d.ts +65 -0
- package/dist/types/modules/word/font/text-shaping.d.ts +58 -0
- package/dist/types/modules/word/html.d.ts +7 -6
- package/dist/types/modules/word/incremental-edit.d.ts +123 -0
- package/dist/types/modules/word/index.base.d.ts +194 -10
- package/dist/types/modules/word/layout/layout-constants.d.ts +17 -0
- package/dist/types/modules/word/layout/layout-full.d.ts +53 -0
- package/dist/types/modules/word/layout/layout-model.d.ts +344 -0
- package/dist/types/modules/word/layout/layout.d.ts +63 -0
- package/dist/types/modules/word/layout/render-page.d.ts +57 -0
- package/dist/types/modules/word/markdown.d.ts +14 -0
- package/dist/types/modules/word/patcher.d.ts +62 -0
- package/dist/types/modules/word/query/compat.d.ts +25 -0
- package/dist/types/modules/word/query/data-binding.d.ts +22 -0
- package/dist/types/modules/word/query/form-fields.d.ts +41 -0
- package/dist/types/modules/word/query/format-search.d.ts +99 -0
- package/dist/types/modules/word/query/mail-merge.d.ts +25 -0
- package/dist/types/modules/word/query/merge.d.ts +50 -0
- package/dist/types/modules/word/query/replace.d.ts +47 -0
- package/dist/types/modules/word/query/revisions.d.ts +67 -0
- package/dist/types/modules/word/query/search.d.ts +129 -0
- package/dist/types/modules/word/query/split.d.ts +44 -0
- package/dist/types/modules/word/query/style-resolve.d.ts +104 -0
- package/dist/types/modules/word/reader/chart-parser.d.ts +20 -0
- package/dist/types/modules/word/reader/comments-parser.d.ts +26 -0
- package/dist/types/modules/word/reader/doc-props-parsers.d.ts +15 -0
- package/dist/types/modules/word/reader/docx-reader.d.ts +27 -0
- package/dist/types/modules/word/reader/drawing-helpers.d.ts +27 -0
- package/dist/types/modules/word/reader/form-field-parser.d.ts +21 -0
- package/dist/types/modules/word/reader/image-parsers.d.ts +11 -0
- package/dist/types/modules/word/reader/math-parser.d.ts +12 -0
- package/dist/types/modules/word/reader/metadata-parsers.d.ts +17 -0
- package/dist/types/modules/word/reader/numbering-parser.d.ts +13 -0
- package/dist/types/modules/word/reader/paragraph-section-parsers.d.ts +12 -0
- package/dist/types/modules/word/reader/parse-utils.d.ts +91 -0
- package/dist/types/modules/word/reader/properties-parsers.d.ts +21 -0
- package/dist/types/modules/word/reader/reader-context.d.ts +69 -0
- package/dist/types/modules/word/reader/sdt-helpers.d.ts +29 -0
- package/dist/types/modules/word/reader/settings-parser.d.ts +8 -0
- package/dist/types/modules/word/reader/styles-parser.d.ts +12 -0
- package/dist/types/modules/word/reader/table-properties-parsers.d.ts +12 -0
- package/dist/types/modules/word/reader/theme-parser.d.ts +8 -0
- package/dist/types/modules/word/reader/watermark-parser.d.ts +15 -0
- package/dist/types/modules/word/security/cfb-reader.d.ts +37 -0
- package/dist/types/modules/word/{digital-signatures.d.ts → security/digital-signatures.d.ts} +19 -11
- package/dist/types/modules/word/security/document-protection.d.ts +93 -0
- package/dist/{browser/modules/word → types/modules/word/security}/encryption.d.ts +51 -4
- package/dist/types/modules/word/security/policy.d.ts +80 -0
- package/dist/types/modules/word/template/template-chart.d.ts +56 -0
- package/dist/types/modules/word/template/template-datasource.d.ts +154 -0
- package/dist/types/modules/word/template/template-engine.d.ts +121 -0
- package/dist/types/modules/word/types.d.ts +224 -25
- package/dist/types/modules/word/units.d.ts +26 -0
- package/dist/types/modules/word/writer/checkbox-writer.d.ts +17 -0
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/comment-writer.d.ts +2 -1
- package/dist/types/modules/word/writer/common-parts.d.ts +57 -0
- package/dist/{browser/modules/word → types/modules/word/writer}/content-types.d.ts +2 -2
- package/dist/types/modules/word/writer/document-writer.d.ts +24 -0
- package/dist/types/modules/word/writer/docx-packager.d.ts +35 -0
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/footnote-writer.d.ts +3 -2
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/header-footer-writer.d.ts +3 -2
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/image-writer.d.ts +1 -1
- package/dist/types/modules/word/writer/math-writer.d.ts +20 -0
- package/dist/types/modules/word/{writers → writer}/numbering-writer.d.ts +1 -1
- package/dist/types/modules/word/{writers → writer}/paragraph-writer.d.ts +2 -1
- package/dist/types/modules/word/{writers → writer}/parts-writer.d.ts +3 -3
- package/dist/types/modules/word/writer/reference-scanners.d.ts +42 -0
- package/dist/types/modules/word/writer/relationships.d.ts +52 -0
- package/dist/types/modules/word/writer/render-context.d.ts +124 -0
- package/dist/types/modules/word/{writers → writer}/run-writer.d.ts +10 -1
- package/dist/types/modules/word/writer/sdt-writer.d.ts +25 -0
- package/dist/types/modules/word/writer/stream-buf.d.ts +37 -0
- package/dist/types/modules/word/writer/streaming-writer.d.ts +344 -0
- package/dist/types/modules/word/writer/string-buf.d.ts +8 -0
- package/dist/types/modules/word/{writers → writer}/table-writer.d.ts +2 -1
- package/dist/types/modules/xml/types.d.ts +22 -0
- package/dist/types/utils/crypto.browser.d.ts +3 -1
- package/dist/types/utils/crypto.d.ts +4 -1
- package/dist/types/utils/font-metrics.d.ts +63 -0
- package/dist/types/utils/string-buf.d.ts +42 -0
- package/dist/types/utils/theme-colors.d.ts +55 -0
- package/package.json +121 -39
- package/dist/browser/modules/word/color-utils.js +0 -94
- package/dist/browser/modules/word/document.d.ts +0 -657
- package/dist/browser/modules/word/document.js +0 -1533
- package/dist/browser/modules/word/docx-packager.d.ts +0 -14
- package/dist/browser/modules/word/docx-packager.js +0 -822
- package/dist/browser/modules/word/docx-reader.d.ts +0 -11
- package/dist/browser/modules/word/docx-reader.js +0 -4929
- package/dist/browser/modules/word/encryption.js +0 -274
- package/dist/browser/modules/word/internal-utils.d.ts +0 -23
- package/dist/browser/modules/word/internal-utils.js +0 -54
- package/dist/browser/modules/word/namespaces.d.ts +0 -159
- package/dist/browser/modules/word/namespaces.js +0 -189
- package/dist/browser/modules/word/relationships.d.ts +0 -30
- package/dist/browser/modules/word/relationships.js +0 -48
- package/dist/browser/modules/word/writers/checkbox-writer.d.ts +0 -9
- package/dist/browser/modules/word/writers/checkbox-writer.js +0 -42
- package/dist/browser/modules/word/writers/document-writer.d.ts +0 -16
- package/dist/browser/modules/word/writers/document-writer.js +0 -461
- package/dist/browser/modules/word/writers/math-writer.d.ts +0 -9
- package/dist/cjs/modules/word/color-utils.js +0 -97
- package/dist/cjs/modules/word/document.js +0 -1645
- package/dist/cjs/modules/word/docx-packager.js +0 -825
- package/dist/cjs/modules/word/docx-reader.js +0 -4932
- package/dist/cjs/modules/word/encryption.js +0 -282
- package/dist/cjs/modules/word/internal-utils.js +0 -59
- package/dist/cjs/modules/word/namespaces.js +0 -192
- package/dist/cjs/modules/word/relationships.js +0 -55
- package/dist/cjs/modules/word/writers/checkbox-writer.js +0 -45
- package/dist/cjs/modules/word/writers/document-writer.js +0 -465
- package/dist/esm/modules/word/color-utils.js +0 -94
- package/dist/esm/modules/word/document.js +0 -1533
- package/dist/esm/modules/word/docx-packager.js +0 -822
- package/dist/esm/modules/word/docx-reader.js +0 -4929
- package/dist/esm/modules/word/encryption.js +0 -274
- package/dist/esm/modules/word/internal-utils.js +0 -54
- package/dist/esm/modules/word/namespaces.js +0 -189
- package/dist/esm/modules/word/relationships.js +0 -48
- package/dist/esm/modules/word/writers/checkbox-writer.js +0 -42
- package/dist/esm/modules/word/writers/document-writer.js +0 -461
- package/dist/types/modules/word/document.d.ts +0 -657
- package/dist/types/modules/word/docx-packager.d.ts +0 -14
- package/dist/types/modules/word/docx-reader.d.ts +0 -11
- package/dist/types/modules/word/internal-utils.d.ts +0 -23
- package/dist/types/modules/word/namespaces.d.ts +0 -159
- package/dist/types/modules/word/relationships.d.ts +0 -30
- package/dist/types/modules/word/writers/checkbox-writer.d.ts +0 -9
- package/dist/types/modules/word/writers/document-writer.d.ts +0 -16
- package/dist/types/modules/word/writers/math-writer.d.ts +0 -9
- /package/dist/browser/modules/word/{font-obfuscation.d.ts → font/font-obfuscation.d.ts} +0 -0
- /package/dist/browser/modules/word/{writers → writer}/chart-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/section-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/section-writer.js +0 -0
- /package/dist/browser/modules/word/{writers → writer}/styles-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/textbox-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/textbox-writer.js +0 -0
- /package/dist/browser/modules/word/{writers → writer}/toc-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/toc-writer.js +0 -0
- /package/dist/cjs/modules/word/{writers → writer}/section-writer.js +0 -0
- /package/dist/cjs/modules/word/{writers → writer}/textbox-writer.js +0 -0
- /package/dist/cjs/modules/word/{writers → writer}/toc-writer.js +0 -0
- /package/dist/esm/modules/word/{writers → writer}/section-writer.js +0 -0
- /package/dist/esm/modules/word/{writers → writer}/textbox-writer.js +0 -0
- /package/dist/esm/modules/word/{writers → writer}/toc-writer.js +0 -0
- /package/dist/types/modules/word/{font-obfuscation.d.ts → font/font-obfuscation.d.ts} +0 -0
- /package/dist/types/modules/word/{writers → writer}/chart-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/section-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/styles-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/textbox-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/toc-writer.d.ts +0 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenDoPE Data Binding API
|
|
3
|
+
*
|
|
4
|
+
* Resolve data bindings in a document by evaluating XPath expressions
|
|
5
|
+
* against CustomXML parts and populating the SDT content with values.
|
|
6
|
+
*/
|
|
7
|
+
import { parseXml } from "../../xml/dom.js";
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Public API
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Resolve data bindings in a document by evaluating XPath expressions
|
|
13
|
+
* against CustomXML parts and populating the SDT content with values.
|
|
14
|
+
*
|
|
15
|
+
* Supports:
|
|
16
|
+
* - Simple value binding: SDT text is replaced with XPath evaluation result
|
|
17
|
+
* - Repeating sections: SDT with `repeatingSection` is duplicated per data row
|
|
18
|
+
* - Conditional display: SDT is removed if XPath returns empty/false
|
|
19
|
+
*
|
|
20
|
+
* @param doc - The document to process (returns a new modified copy).
|
|
21
|
+
* @param data - Optional override data map (storeItemId → XML string). If not
|
|
22
|
+
* provided, uses the document's embedded CustomXML parts.
|
|
23
|
+
* @returns A new document with bindings resolved.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveDataBindings(doc, data) {
|
|
26
|
+
// Build a map of storeItemId → parsed XML content
|
|
27
|
+
const xmlStore = new Map();
|
|
28
|
+
if (data) {
|
|
29
|
+
for (const [key, value] of data) {
|
|
30
|
+
xmlStore.set(key.toLowerCase(), value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (doc.customXmlParts) {
|
|
34
|
+
for (const part of doc.customXmlParts) {
|
|
35
|
+
xmlStore.set(part.itemId.toLowerCase(), part.xmlContent);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (xmlStore.size === 0) {
|
|
39
|
+
return doc;
|
|
40
|
+
}
|
|
41
|
+
const newBody = doc.body.map(block => resolveBlockBinding(block, xmlStore));
|
|
42
|
+
return { ...doc, body: newBody };
|
|
43
|
+
}
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// Internal helpers
|
|
46
|
+
// =============================================================================
|
|
47
|
+
function resolveBlockBinding(block, xmlStore) {
|
|
48
|
+
if (block.type === "sdt") {
|
|
49
|
+
return resolveSdtBinding(block, xmlStore);
|
|
50
|
+
}
|
|
51
|
+
if (block.type === "table") {
|
|
52
|
+
return {
|
|
53
|
+
...block,
|
|
54
|
+
rows: block.rows.map(r => ({
|
|
55
|
+
...r,
|
|
56
|
+
cells: r.cells.map(c => ({
|
|
57
|
+
...c,
|
|
58
|
+
content: c.content.map(inner => resolveBlockBinding(inner, xmlStore))
|
|
59
|
+
}))
|
|
60
|
+
}))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return block;
|
|
64
|
+
}
|
|
65
|
+
function resolveSdtBinding(sdt, xmlStore) {
|
|
66
|
+
const binding = sdt.properties?.dataBinding;
|
|
67
|
+
if (!binding) {
|
|
68
|
+
// No binding — recurse into content for nested SDTs/tables
|
|
69
|
+
return {
|
|
70
|
+
...sdt,
|
|
71
|
+
content: sdt.content.map(c => {
|
|
72
|
+
if ("type" in c && c.type === "table") {
|
|
73
|
+
return resolveBlockBinding(c, xmlStore);
|
|
74
|
+
}
|
|
75
|
+
return c;
|
|
76
|
+
})
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Resolve the value from CustomXML using simple XPath evaluation
|
|
80
|
+
const value = evaluateSimpleXPath(binding, xmlStore);
|
|
81
|
+
if (sdt.properties?.repeatingSection) {
|
|
82
|
+
// Repeating section: value should be a collection
|
|
83
|
+
// Each child in the data produces a copy of the repeatingSection item template
|
|
84
|
+
const values = evaluateRepeatingXPath(binding, xmlStore);
|
|
85
|
+
if (values.length === 0) {
|
|
86
|
+
// Remove the SDT entirely if no data
|
|
87
|
+
return { type: "paragraph", children: [] };
|
|
88
|
+
}
|
|
89
|
+
// Return the SDT with repeated content, with inner bindings resolved per item
|
|
90
|
+
const repeatedContent = [];
|
|
91
|
+
const template = sdt.content;
|
|
92
|
+
// Build parent xpath for resolving child element values
|
|
93
|
+
const parentXpath = binding.xpath;
|
|
94
|
+
const storeId = binding.storeItemId.replace(/[{}]/g, "").toLowerCase();
|
|
95
|
+
const xmlContent = xmlStore.get(storeId) ?? xmlStore.get(`{${storeId}}`);
|
|
96
|
+
for (let itemIdx = 0; itemIdx < values.length; itemIdx++) {
|
|
97
|
+
// Clone template content for each item
|
|
98
|
+
for (const item of template) {
|
|
99
|
+
const cloned = structuredClone(item);
|
|
100
|
+
// Resolve inner SDT bindings within this repeated item
|
|
101
|
+
if (xmlContent) {
|
|
102
|
+
resolveInnerBindings(cloned, parentXpath, itemIdx + 1, xmlStore);
|
|
103
|
+
}
|
|
104
|
+
repeatedContent.push(cloned);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { ...sdt, content: repeatedContent };
|
|
108
|
+
}
|
|
109
|
+
if (value === null) {
|
|
110
|
+
// Condition not met — remove SDT (return empty paragraph)
|
|
111
|
+
return { type: "paragraph", children: [] };
|
|
112
|
+
}
|
|
113
|
+
// Simple binding — replace text content of the SDT
|
|
114
|
+
const textRun = {
|
|
115
|
+
content: [{ type: "text", text: value }]
|
|
116
|
+
};
|
|
117
|
+
const textPara = { type: "paragraph", children: [textRun] };
|
|
118
|
+
return { ...sdt, content: [textPara] };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Evaluate an XPath expression against CustomXML stored as a string.
|
|
122
|
+
*
|
|
123
|
+
* Supports the XPath 1.0 subset that real-world OpenDoPE-style bindings
|
|
124
|
+
* exercise:
|
|
125
|
+
* - Absolute paths: `/root/child/grandchild`
|
|
126
|
+
* - Namespace prefixes (matched by local name): `/ns0:root/ns0:child`
|
|
127
|
+
* - Position predicates: `/root/item[1]`, `/root/item[last()]`
|
|
128
|
+
* - Attribute access: `/root/element/@attr`
|
|
129
|
+
* - Text content extraction from leaf nodes (CDATA-aware,
|
|
130
|
+
* entity-decoded by the XML parser)
|
|
131
|
+
*
|
|
132
|
+
* Does NOT support: axes (ancestor::, following::), functions
|
|
133
|
+
* (count(), string()), arithmetic, union (|), or complex predicates.
|
|
134
|
+
*
|
|
135
|
+
* Implemented on top of the project's XML DOM parser. The previous
|
|
136
|
+
* regex-based scanner was unsafe — it returned entity-encoded text
|
|
137
|
+
* verbatim and could be confused by CDATA, comments, attributes
|
|
138
|
+
* containing `>`, etc.
|
|
139
|
+
*
|
|
140
|
+
* @returns The text content of the matched element/attribute, or null if
|
|
141
|
+
* not found. Returns the empty string for an element that exists
|
|
142
|
+
* but has no text — callers that need to distinguish empty from
|
|
143
|
+
* missing must compare to `null` explicitly.
|
|
144
|
+
*/
|
|
145
|
+
function evaluateSimpleXPath(binding, xmlStore) {
|
|
146
|
+
const root = loadStoreRoot(binding, xmlStore);
|
|
147
|
+
if (!root) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const xpath = binding.xpath;
|
|
151
|
+
// Attribute access: /path/to/element/@attr
|
|
152
|
+
const attrMatch = xpath.match(/^(.+)\/@([a-zA-Z0-9_:-]+)$/);
|
|
153
|
+
if (attrMatch) {
|
|
154
|
+
const elementPath = attrMatch[1];
|
|
155
|
+
const attrName = attrMatch[2];
|
|
156
|
+
const localAttr = stripPrefix(attrName);
|
|
157
|
+
const el = findElementByPath(root, elementPath);
|
|
158
|
+
if (!el) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
// Match attribute by local name, ignoring any prefix in the source.
|
|
162
|
+
for (const [name, value] of Object.entries(el.attributes)) {
|
|
163
|
+
if (stripPrefix(name) === localAttr) {
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
const el = findElementByPath(root, xpath);
|
|
170
|
+
if (!el) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return collectTextContent(el);
|
|
174
|
+
}
|
|
175
|
+
function parsePathSegment(raw) {
|
|
176
|
+
let seg = stripPrefix(raw);
|
|
177
|
+
let position = 0;
|
|
178
|
+
const predMatch = seg.match(/\[(\d+|last\(\))\]$/);
|
|
179
|
+
if (predMatch) {
|
|
180
|
+
seg = seg.substring(0, seg.indexOf("["));
|
|
181
|
+
if (predMatch[1] === "last()") {
|
|
182
|
+
position = -1;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
position = parseInt(predMatch[1], 10);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return { localName: seg, position };
|
|
189
|
+
}
|
|
190
|
+
function stripPrefix(name) {
|
|
191
|
+
const i = name.indexOf(":");
|
|
192
|
+
return i >= 0 ? name.substring(i + 1) : name;
|
|
193
|
+
}
|
|
194
|
+
function elementLocal(el) {
|
|
195
|
+
return el.local ?? stripPrefix(el.name);
|
|
196
|
+
}
|
|
197
|
+
function loadStoreRoot(binding, xmlStore) {
|
|
198
|
+
const storeId = binding.storeItemId.replace(/[{}]/g, "").toLowerCase();
|
|
199
|
+
const xmlContent = xmlStore.get(storeId) ?? xmlStore.get(`{${storeId}}`);
|
|
200
|
+
if (!xmlContent) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return parseXml(xmlContent).root;
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
// Malformed CustomXML store. Treat as empty rather than throwing —
|
|
208
|
+
// resolveDataBindings is best-effort by design.
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** Direct-child elements of `el` filtered by local name. */
|
|
213
|
+
function directChildren(el, localName) {
|
|
214
|
+
const out = [];
|
|
215
|
+
for (const child of el.children) {
|
|
216
|
+
if (child.type === "element" && elementLocal(child) === localName) {
|
|
217
|
+
out.push(child);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
/** Resolve a path of segments against `root`. The first segment is matched
|
|
223
|
+
* against `root` itself (XPath absolute paths begin with the document root). */
|
|
224
|
+
function findElementByPath(root, xpath) {
|
|
225
|
+
const segments = xpath
|
|
226
|
+
.split("/")
|
|
227
|
+
.filter(s => s.length > 0)
|
|
228
|
+
.map(parsePathSegment);
|
|
229
|
+
if (segments.length === 0) {
|
|
230
|
+
return root;
|
|
231
|
+
}
|
|
232
|
+
// First segment must match the document root by local name.
|
|
233
|
+
const first = segments[0];
|
|
234
|
+
if (elementLocal(root) !== first.localName) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
let current = root;
|
|
238
|
+
for (let i = 1; i < segments.length; i++) {
|
|
239
|
+
if (!current) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const seg = segments[i];
|
|
243
|
+
const matches = directChildren(current, seg.localName);
|
|
244
|
+
if (matches.length === 0) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
if (seg.position === -1) {
|
|
248
|
+
current = matches[matches.length - 1];
|
|
249
|
+
}
|
|
250
|
+
else if (seg.position > 0) {
|
|
251
|
+
current = matches[seg.position - 1] ?? null;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
current = matches[0];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return current;
|
|
258
|
+
}
|
|
259
|
+
/** Concatenate descendant text and CDATA content. */
|
|
260
|
+
function collectTextContent(el) {
|
|
261
|
+
let out = "";
|
|
262
|
+
const walk = (node) => {
|
|
263
|
+
if (node.type === "text" || node.type === "cdata") {
|
|
264
|
+
out += node.value;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (node.type === "element") {
|
|
268
|
+
for (const child of node.children) {
|
|
269
|
+
walk(child);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
for (const child of el.children) {
|
|
274
|
+
walk(child);
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
function evaluateRepeatingXPath(binding, xmlStore) {
|
|
279
|
+
const root = loadStoreRoot(binding, xmlStore);
|
|
280
|
+
if (!root) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
const segments = binding.xpath
|
|
284
|
+
.split("/")
|
|
285
|
+
.filter(s => s.length > 0)
|
|
286
|
+
.map(parsePathSegment);
|
|
287
|
+
if (segments.length === 0) {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
// Walk to the parent of the last segment, then count occurrences of the
|
|
291
|
+
// last segment's local name as direct children.
|
|
292
|
+
const parentSegments = segments.slice(0, -1);
|
|
293
|
+
const last = segments[segments.length - 1];
|
|
294
|
+
// Resolve the parent path. If only the root segment was provided we
|
|
295
|
+
// treat root as parent; if the parent has its own segments we walk
|
|
296
|
+
// them through findElementByPath against the root using a synthesised
|
|
297
|
+
// path.
|
|
298
|
+
let parent;
|
|
299
|
+
if (parentSegments.length === 0) {
|
|
300
|
+
parent = elementLocal(root) === last.localName ? null : root;
|
|
301
|
+
// Special case: `/root` itself as the repeating xpath — treat as one item.
|
|
302
|
+
if (elementLocal(root) === last.localName) {
|
|
303
|
+
return ["0"];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
const parentPath = "/" +
|
|
308
|
+
parentSegments
|
|
309
|
+
.map(s => s.position > 0
|
|
310
|
+
? `${s.localName}[${s.position}]`
|
|
311
|
+
: s.position === -1
|
|
312
|
+
? `${s.localName}[last()]`
|
|
313
|
+
: s.localName)
|
|
314
|
+
.join("/");
|
|
315
|
+
parent = findElementByPath(root, parentPath);
|
|
316
|
+
}
|
|
317
|
+
if (!parent) {
|
|
318
|
+
return [];
|
|
319
|
+
}
|
|
320
|
+
const count = directChildren(parent, last.localName).length;
|
|
321
|
+
return Array.from({ length: count }, (_, i) => String(i));
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Resolve inner SDT data bindings within a repeated section item.
|
|
325
|
+
* Rewrites XPath in inner bindings to reference the specific item index,
|
|
326
|
+
* then evaluates and replaces the SDT text content.
|
|
327
|
+
*/
|
|
328
|
+
function resolveInnerBindings(content, parentXpath, itemPosition, xmlStore) {
|
|
329
|
+
if (!content || typeof content !== "object") {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const obj = content;
|
|
333
|
+
// If this is an SDT with a dataBinding, resolve it in context of the repeated item
|
|
334
|
+
if (obj.type === "sdt" &&
|
|
335
|
+
typeof obj.properties === "object" &&
|
|
336
|
+
obj.properties !== null &&
|
|
337
|
+
obj.properties.dataBinding) {
|
|
338
|
+
const innerBinding = obj.properties.dataBinding;
|
|
339
|
+
// Rewrite the xpath: if its leading path-segment sequence equals
|
|
340
|
+
// `parentXpath`, insert a position predicate at the parent boundary.
|
|
341
|
+
// The previous implementation used a plain string `startsWith` check,
|
|
342
|
+
// which produced false positives when `parentXpath` was a prefix of a
|
|
343
|
+
// sibling's name (e.g. `/root/items` is a string prefix of
|
|
344
|
+
// `/root/items_total/count` even though `/root/items` is not a parent
|
|
345
|
+
// path at the segment level).
|
|
346
|
+
let resolvedXpath = innerBinding.xpath;
|
|
347
|
+
if (xpathStartsWithSegments(resolvedXpath, parentXpath)) {
|
|
348
|
+
resolvedXpath = `${parentXpath}[${itemPosition}]${resolvedXpath.slice(parentXpath.length)}`;
|
|
349
|
+
}
|
|
350
|
+
const modifiedBinding = {
|
|
351
|
+
...innerBinding,
|
|
352
|
+
xpath: resolvedXpath
|
|
353
|
+
};
|
|
354
|
+
const value = evaluateSimpleXPath(modifiedBinding, xmlStore);
|
|
355
|
+
if (value !== null) {
|
|
356
|
+
const textRun = { content: [{ type: "text", text: value }] };
|
|
357
|
+
const textPara = { type: "paragraph", children: [textRun] };
|
|
358
|
+
obj.content = [textPara];
|
|
359
|
+
}
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
// Recurse into arrays and object properties
|
|
363
|
+
if (Array.isArray(content)) {
|
|
364
|
+
for (const item of content) {
|
|
365
|
+
resolveInnerBindings(item, parentXpath, itemPosition, xmlStore);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
for (const key of Object.keys(obj)) {
|
|
370
|
+
const val = obj[key];
|
|
371
|
+
if (val && typeof val === "object") {
|
|
372
|
+
resolveInnerBindings(val, parentXpath, itemPosition, xmlStore);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Test whether `xpath` starts with `prefix` *as a sequence of path
|
|
379
|
+
* segments* — i.e. the next character after `prefix` is `/`, `[`, or end
|
|
380
|
+
* of string. Plain string `startsWith` mismatches sibling names (e.g.
|
|
381
|
+
* `/root/items` vs. `/root/items_total`).
|
|
382
|
+
*/
|
|
383
|
+
function xpathStartsWithSegments(xpath, prefix) {
|
|
384
|
+
if (!xpath.startsWith(prefix)) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
if (xpath.length === prefix.length) {
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
const next = xpath.charAt(prefix.length);
|
|
391
|
+
return next === "/" || next === "[";
|
|
392
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Field Data API
|
|
3
|
+
*
|
|
4
|
+
* Extract and fill form field values in a document.
|
|
5
|
+
*/
|
|
6
|
+
import { isHyperlink, isRun } from "../core/text-utils.js";
|
|
7
|
+
import { walkDocument } from "../core/walker.js";
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Public API
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Extract all form field values from a document.
|
|
13
|
+
*
|
|
14
|
+
* Traverses the document body (paragraphs, tables, headers, footers)
|
|
15
|
+
* and collects all legacy form field data.
|
|
16
|
+
*
|
|
17
|
+
* @param doc - The document to extract from.
|
|
18
|
+
* @returns Array of form field entries with their current values.
|
|
19
|
+
*/
|
|
20
|
+
export function extractFormFields(doc) {
|
|
21
|
+
const results = [];
|
|
22
|
+
const visitor = {
|
|
23
|
+
enterRun(run) {
|
|
24
|
+
if (!run.content) {
|
|
25
|
+
return "continue";
|
|
26
|
+
}
|
|
27
|
+
for (const rc of run.content) {
|
|
28
|
+
if (rc.type === "field" && rc.formField) {
|
|
29
|
+
const ff = rc.formField;
|
|
30
|
+
let value;
|
|
31
|
+
if (ff.type === "text") {
|
|
32
|
+
value = ff.default ?? "";
|
|
33
|
+
}
|
|
34
|
+
else if (ff.type === "checkBox") {
|
|
35
|
+
value = ff.checked ?? ff.default ?? false;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// dropdown
|
|
39
|
+
value = ff.default ?? 0;
|
|
40
|
+
}
|
|
41
|
+
results.push({
|
|
42
|
+
name: ff.name ?? "",
|
|
43
|
+
type: ff.type,
|
|
44
|
+
value,
|
|
45
|
+
entries: ff.type === "dropDown" ? ff.entries : undefined
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return "continue";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
walkDocument(doc, visitor, {
|
|
53
|
+
includeHeaders: true,
|
|
54
|
+
includeFooters: true,
|
|
55
|
+
includeFootnotes: false,
|
|
56
|
+
includeEndnotes: false,
|
|
57
|
+
includeComments: false
|
|
58
|
+
});
|
|
59
|
+
return results;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fill form field values throughout a document.
|
|
63
|
+
*
|
|
64
|
+
* The body, headers, footers, footnotes, endnotes and comments are all
|
|
65
|
+
* processed so a form field placed inside a header (a common case) still
|
|
66
|
+
* gets filled. Inside paragraphs the visitor descends into hyperlinks and
|
|
67
|
+
* track-change wrappers so a form field referenced from a tracked
|
|
68
|
+
* insertion is also reachable.
|
|
69
|
+
*
|
|
70
|
+
* @param doc - The document to fill (returns a new copy with filled values).
|
|
71
|
+
* @param values - Map of field name → new value.
|
|
72
|
+
* @returns A new document with form fields populated.
|
|
73
|
+
*/
|
|
74
|
+
export function fillFormFields(doc, values) {
|
|
75
|
+
const newBody = doc.body.map(block => fillFieldsInBlock(block, values));
|
|
76
|
+
const newHeaders = doc.headers
|
|
77
|
+
? new Map(Array.from(doc.headers, ([k, h]) => [
|
|
78
|
+
k,
|
|
79
|
+
{
|
|
80
|
+
...h,
|
|
81
|
+
content: {
|
|
82
|
+
...h.content,
|
|
83
|
+
children: h.content.children.map(c => fillFieldsInBlock(c, values))
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]))
|
|
87
|
+
: undefined;
|
|
88
|
+
const newFooters = doc.footers
|
|
89
|
+
? new Map(Array.from(doc.footers, ([k, f]) => [
|
|
90
|
+
k,
|
|
91
|
+
{
|
|
92
|
+
...f,
|
|
93
|
+
content: {
|
|
94
|
+
...f.content,
|
|
95
|
+
children: f.content.children.map(c => fillFieldsInBlock(c, values))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]))
|
|
99
|
+
: undefined;
|
|
100
|
+
const newFootnotes = doc.footnotes
|
|
101
|
+
? doc.footnotes.map(fn => ({
|
|
102
|
+
...fn,
|
|
103
|
+
content: fn.content.map(p => fillFieldsInParagraph(p, values))
|
|
104
|
+
}))
|
|
105
|
+
: undefined;
|
|
106
|
+
const newEndnotes = doc.endnotes
|
|
107
|
+
? doc.endnotes.map(en => ({
|
|
108
|
+
...en,
|
|
109
|
+
content: en.content.map(p => fillFieldsInParagraph(p, values))
|
|
110
|
+
}))
|
|
111
|
+
: undefined;
|
|
112
|
+
const newComments = doc.comments
|
|
113
|
+
? doc.comments.map(cm => ({
|
|
114
|
+
...cm,
|
|
115
|
+
content: cm.content.map(p => fillFieldsInParagraph(p, values))
|
|
116
|
+
}))
|
|
117
|
+
: undefined;
|
|
118
|
+
return {
|
|
119
|
+
...doc,
|
|
120
|
+
body: newBody,
|
|
121
|
+
...(newHeaders ? { headers: newHeaders } : {}),
|
|
122
|
+
...(newFooters ? { footers: newFooters } : {}),
|
|
123
|
+
...(newFootnotes ? { footnotes: newFootnotes } : {}),
|
|
124
|
+
...(newEndnotes ? { endnotes: newEndnotes } : {}),
|
|
125
|
+
...(newComments ? { comments: newComments } : {})
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// =============================================================================
|
|
129
|
+
// Internal helpers
|
|
130
|
+
// =============================================================================
|
|
131
|
+
function fillFieldsInBlock(block, values) {
|
|
132
|
+
if (block.type === "paragraph") {
|
|
133
|
+
return fillFieldsInParagraph(block, values);
|
|
134
|
+
}
|
|
135
|
+
if (block.type === "table") {
|
|
136
|
+
return {
|
|
137
|
+
...block,
|
|
138
|
+
rows: block.rows.map(r => ({
|
|
139
|
+
...r,
|
|
140
|
+
cells: r.cells.map(c => ({
|
|
141
|
+
...c,
|
|
142
|
+
content: c.content.map(inner => fillFieldsInBlock(inner, values))
|
|
143
|
+
}))
|
|
144
|
+
}))
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (block.type === "sdt") {
|
|
148
|
+
return {
|
|
149
|
+
...block,
|
|
150
|
+
content: block.content.map(c => {
|
|
151
|
+
if ("type" in c && (c.type === "paragraph" || c.type === "table")) {
|
|
152
|
+
return fillFieldsInBlock(c, values);
|
|
153
|
+
}
|
|
154
|
+
if (c &&
|
|
155
|
+
typeof c === "object" &&
|
|
156
|
+
!("type" in c) &&
|
|
157
|
+
"content" in c &&
|
|
158
|
+
Array.isArray(c.content)) {
|
|
159
|
+
// Inline (run-only) SDT child — fill any field run-content nodes
|
|
160
|
+
// it carries directly.
|
|
161
|
+
return fillFieldsInRun(c, values);
|
|
162
|
+
}
|
|
163
|
+
return c;
|
|
164
|
+
})
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (block.type === "textBox") {
|
|
168
|
+
return {
|
|
169
|
+
...block,
|
|
170
|
+
content: block.content.map(p => fillFieldsInParagraph(p, values))
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (block.type === "drawingShape") {
|
|
174
|
+
if (!block.textContent || block.textContent.length === 0) {
|
|
175
|
+
return block;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
...block,
|
|
179
|
+
textContent: block.textContent.map(p => fillFieldsInParagraph(p, values))
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (block.type === "tableOfContents") {
|
|
183
|
+
if (!block.cachedParagraphs || block.cachedParagraphs.length === 0) {
|
|
184
|
+
return block;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
...block,
|
|
188
|
+
cachedParagraphs: block.cachedParagraphs.map(p => fillFieldsInParagraph(p, values))
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return block;
|
|
192
|
+
}
|
|
193
|
+
function fillFieldsInParagraph(para, values) {
|
|
194
|
+
let modified = false;
|
|
195
|
+
const newChildren = para.children.map(child => {
|
|
196
|
+
// Hyperlink: descend into its run children.
|
|
197
|
+
if (isHyperlink(child)) {
|
|
198
|
+
let hlModified = false;
|
|
199
|
+
const newRuns = child.children.map(r => {
|
|
200
|
+
const filled = fillFieldsInRun(r, values);
|
|
201
|
+
if (filled !== r) {
|
|
202
|
+
hlModified = true;
|
|
203
|
+
}
|
|
204
|
+
return filled;
|
|
205
|
+
});
|
|
206
|
+
if (hlModified) {
|
|
207
|
+
modified = true;
|
|
208
|
+
return { ...child, children: newRuns };
|
|
209
|
+
}
|
|
210
|
+
return child;
|
|
211
|
+
}
|
|
212
|
+
// Track-change wrappers around a run.
|
|
213
|
+
if ("type" in child &&
|
|
214
|
+
(child.type === "insertedRun" ||
|
|
215
|
+
child.type === "movedToRun")) {
|
|
216
|
+
const wrapper = child;
|
|
217
|
+
const filled = fillFieldsInRun(wrapper.run, values);
|
|
218
|
+
if (filled !== wrapper.run) {
|
|
219
|
+
modified = true;
|
|
220
|
+
return { ...wrapper, run: filled };
|
|
221
|
+
}
|
|
222
|
+
return child;
|
|
223
|
+
}
|
|
224
|
+
if (!isRun(child)) {
|
|
225
|
+
return child;
|
|
226
|
+
}
|
|
227
|
+
const filled = fillFieldsInRun(child, values);
|
|
228
|
+
if (filled !== child) {
|
|
229
|
+
modified = true;
|
|
230
|
+
}
|
|
231
|
+
return filled;
|
|
232
|
+
});
|
|
233
|
+
return modified ? { ...para, children: newChildren } : para;
|
|
234
|
+
}
|
|
235
|
+
function fillFieldsInRun(run, values) {
|
|
236
|
+
if (!run.content) {
|
|
237
|
+
return run;
|
|
238
|
+
}
|
|
239
|
+
let runModified = false;
|
|
240
|
+
const newContent = run.content.map(rc => {
|
|
241
|
+
if (rc.type !== "field" || !rc.formField) {
|
|
242
|
+
return rc;
|
|
243
|
+
}
|
|
244
|
+
const ff = rc.formField;
|
|
245
|
+
const name = ff.name ?? "";
|
|
246
|
+
if (!values.has(name)) {
|
|
247
|
+
return rc;
|
|
248
|
+
}
|
|
249
|
+
const newVal = values.get(name);
|
|
250
|
+
runModified = true;
|
|
251
|
+
let newFF;
|
|
252
|
+
if (ff.type === "text") {
|
|
253
|
+
newFF = { ...ff, default: String(newVal) };
|
|
254
|
+
}
|
|
255
|
+
else if (ff.type === "checkBox") {
|
|
256
|
+
newFF = { ...ff, checked: Boolean(newVal) };
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// dropdown: value is the selected index
|
|
260
|
+
newFF = {
|
|
261
|
+
...ff,
|
|
262
|
+
default: typeof newVal === "number" ? newVal : parseInt(String(newVal), 10) || 0
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return { ...rc, formField: newFF };
|
|
266
|
+
});
|
|
267
|
+
return runModified ? { ...run, content: newContent } : run;
|
|
268
|
+
}
|