@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOCX Module - Markdown Converters (Subpath Entry)
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the Markdown converter API at `excelts/word/markdown`. This file
|
|
5
|
+
* is referenced by `package.json#exports["./word/markdown"]`; it forwards to
|
|
6
|
+
* the implementation under `./convert/markdown`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { renderToMarkdown, markdownToDocx, markdownToDocxBody } from "excelts/word/markdown";
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { renderToMarkdown, markdownToDocx, markdownToDocxBody } from "./convert/markdown/markdown.js";
|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOCX Module - Patcher
|
|
3
|
+
*
|
|
4
|
+
* Internal logic for replacing placeholders (e.g. `{{name}}`) in a DocxDocument
|
|
5
|
+
* with text, paragraphs, tables, or images. Used by `patchDocument` and
|
|
6
|
+
* `patchTemplate` in document-io.ts.
|
|
7
|
+
*
|
|
8
|
+
* Public API is exposed through document-io.ts; this file contains the
|
|
9
|
+
* pure patch logic (no IO).
|
|
10
|
+
*
|
|
11
|
+
* Container coverage: the patcher walks every container that may carry
|
|
12
|
+
* paragraphs — body, headers/footers, footnotes/endnotes, table cells
|
|
13
|
+
* (including nested tables), structured-document tags (block & inline),
|
|
14
|
+
* text boxes, drawing shape text bodies, and the cached paragraphs of a
|
|
15
|
+
* Table of Contents. Anything paragraph-shaped is run through
|
|
16
|
+
* `patchParagraph`, so a placeholder is matched the same way regardless
|
|
17
|
+
* of which container holds it.
|
|
18
|
+
*/
|
|
19
|
+
import {} from "./core/internal-utils.js";
|
|
20
|
+
import { isHyperlink, isRun } from "./core/text-utils.js";
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Public API
|
|
23
|
+
// =============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Apply patches to a parsed document model.
|
|
26
|
+
*
|
|
27
|
+
* Returns a NEW {@link DocxDocument} with a fresh `body` array and a new
|
|
28
|
+
* `images` array. However, the inner content reachable from
|
|
29
|
+
* `headers` / `footers` / `footnotes` / `endnotes` and from non-replaced
|
|
30
|
+
* paragraphs/tables is mutated in place: text replacements rewrite the
|
|
31
|
+
* existing `Paragraph.children[].content[].text`, table rows/cells are
|
|
32
|
+
* patched in place, etc.
|
|
33
|
+
*
|
|
34
|
+
* **Practical consequence**: do not keep using the input `doc` after calling
|
|
35
|
+
* this function — its inner state has been modified. Always use the return
|
|
36
|
+
* value. Concurrent use of the input `doc` from another thread/path is not
|
|
37
|
+
* supported.
|
|
38
|
+
*
|
|
39
|
+
* @param doc - The document model. Internal arrays/objects will be mutated.
|
|
40
|
+
* @param patches - Patches to apply.
|
|
41
|
+
* @returns A new {@link DocxDocument} reference with patches applied.
|
|
42
|
+
*/
|
|
43
|
+
export function applyPatchesToDocument(doc, patches) {
|
|
44
|
+
// Build a canonical fileName → rId map so two image patches that point to
|
|
45
|
+
// the same fileName always emit the same r:embed. Without this, the first
|
|
46
|
+
// patch wins doc.images de-duplication below but a later patch with a
|
|
47
|
+
// different rId would still write its own rId into the body, producing a
|
|
48
|
+
// dangling reference and a blank image in Word.
|
|
49
|
+
const imageFileNameToRId = new Map();
|
|
50
|
+
if (doc.images) {
|
|
51
|
+
for (const img of doc.images) {
|
|
52
|
+
if (img.rId) {
|
|
53
|
+
imageFileNameToRId.set(img.fileName, img.rId);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Normalize image patches: assign each unique fileName a single rId
|
|
58
|
+
// (preferring an existing one in doc.images, otherwise the first patch's
|
|
59
|
+
// rId, otherwise a stable generated id). Rewrite all subsequent patches
|
|
60
|
+
// that share the fileName to use the same rId. The body-render path below
|
|
61
|
+
// reads `image.rId` directly from these normalized patches, so generated
|
|
62
|
+
// ids and existing ones flow through the same code path.
|
|
63
|
+
const normalizedPatches = patches.map(patch => {
|
|
64
|
+
if (patch.content.type !== "image") {
|
|
65
|
+
return patch;
|
|
66
|
+
}
|
|
67
|
+
const img = patch.content.image;
|
|
68
|
+
let rId = imageFileNameToRId.get(img.fileName);
|
|
69
|
+
if (!rId) {
|
|
70
|
+
rId = img.rId ?? `rId_img_${img.fileName}`;
|
|
71
|
+
imageFileNameToRId.set(img.fileName, rId);
|
|
72
|
+
}
|
|
73
|
+
if (img.rId === rId) {
|
|
74
|
+
return patch;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
...patch,
|
|
78
|
+
content: {
|
|
79
|
+
...patch.content,
|
|
80
|
+
image: { ...img, rId }
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
// Build lookup map for quick placeholder matching
|
|
85
|
+
const patchMap = new Map();
|
|
86
|
+
for (const patch of normalizedPatches) {
|
|
87
|
+
patchMap.set(patch.placeholder, patch);
|
|
88
|
+
}
|
|
89
|
+
// Process body content (top-level)
|
|
90
|
+
const newBody = patchBlockList(doc.body, patchMap);
|
|
91
|
+
// Patch headers
|
|
92
|
+
if (doc.headers) {
|
|
93
|
+
for (const [, headerDef] of doc.headers) {
|
|
94
|
+
patchHeaderFooterContent(headerDef.content, patchMap);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Patch footers
|
|
98
|
+
if (doc.footers) {
|
|
99
|
+
for (const [, footerDef] of doc.footers) {
|
|
100
|
+
patchHeaderFooterContent(footerDef.content, patchMap);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Patch footnotes (text-only — structural patches don't make sense in notes)
|
|
104
|
+
if (doc.footnotes) {
|
|
105
|
+
for (const note of doc.footnotes) {
|
|
106
|
+
if (note.id <= 0) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
for (const para of note.content) {
|
|
110
|
+
patchTextInParagraph(para, patchMap);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Patch endnotes
|
|
115
|
+
if (doc.endnotes) {
|
|
116
|
+
for (const note of doc.endnotes) {
|
|
117
|
+
if (note.id <= 0) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
for (const para of note.content) {
|
|
121
|
+
patchTextInParagraph(para, patchMap);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Add any new images from patches. Patches were already normalized so
|
|
126
|
+
// that two patches sharing a fileName carry the same rId; this loop just
|
|
127
|
+
// unions the unique images.
|
|
128
|
+
const images = doc.images ? [...doc.images] : [];
|
|
129
|
+
for (const patch of normalizedPatches) {
|
|
130
|
+
if (patch.content.type === "image") {
|
|
131
|
+
const imgContent = patch.content;
|
|
132
|
+
const existing = images.find(i => i.fileName === imgContent.image.fileName);
|
|
133
|
+
if (!existing) {
|
|
134
|
+
images.push(imgContent.image);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
...doc,
|
|
140
|
+
body: newBody,
|
|
141
|
+
images: images.length > 0 ? images : undefined
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// =============================================================================
|
|
145
|
+
// Internal helpers
|
|
146
|
+
// =============================================================================
|
|
147
|
+
/**
|
|
148
|
+
* Iterate every visible Run in a paragraph (in document order), descending
|
|
149
|
+
* into hyperlinks and into the wrapper around `insertedRun` / `movedToRun`
|
|
150
|
+
* track-change markers. `deletedRun` / `movedFromRun` are intentionally
|
|
151
|
+
* skipped: by the OOXML conventions used elsewhere in this codebase
|
|
152
|
+
* (search.ts, replace.ts, extractParagraphText) those wrappers do not
|
|
153
|
+
* contribute to the document's visible text, so a `{{name}}` placeholder
|
|
154
|
+
* sitting inside a pending deletion must not be replaced.
|
|
155
|
+
*/
|
|
156
|
+
function forEachVisibleRun(para, fn) {
|
|
157
|
+
const visit = (children) => {
|
|
158
|
+
for (const child of children) {
|
|
159
|
+
if (isHyperlink(child)) {
|
|
160
|
+
visit(child.children);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if ("type" in child) {
|
|
164
|
+
// Track-change wrappers: descend into the wrapped run only when
|
|
165
|
+
// the wrapper represents visible text (insert / move-to). Pending
|
|
166
|
+
// deletions and move-from sources, bookmarks, and comment range
|
|
167
|
+
// markers contribute no visible text and are skipped.
|
|
168
|
+
const t = child.type;
|
|
169
|
+
if (t === "insertedRun" || t === "movedToRun") {
|
|
170
|
+
const inner = child.run;
|
|
171
|
+
if (inner) {
|
|
172
|
+
fn(inner);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
// No `type` discriminator → the only paragraph child shape that
|
|
178
|
+
// matches is a Run.
|
|
179
|
+
if (isRun(child)) {
|
|
180
|
+
fn(child);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
visit(para.children);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Extract concatenated plain text from a paragraph's runs, ignoring tabs,
|
|
188
|
+
* breaks, hyphens, fields, and any non-text run content.
|
|
189
|
+
*
|
|
190
|
+
* Intentionally **not** the same as `extractParagraphText` from
|
|
191
|
+
* `core/text-utils`: that helper expands `tab` → "\t", `break` → "\n",
|
|
192
|
+
* `noBreakHyphen` → "-", etc., which would corrupt placeholder matching.
|
|
193
|
+
* A placeholder like `{{name}}` should only match against the literal text
|
|
194
|
+
* the author wrote, not against synthetic characters injected by formatting
|
|
195
|
+
* elements.
|
|
196
|
+
*
|
|
197
|
+
* Visits hyperlinks and tracked-insert/move-to wrappers so that a
|
|
198
|
+
* placeholder embedded in a hyperlink display text or a pending revision
|
|
199
|
+
* is still found.
|
|
200
|
+
*/
|
|
201
|
+
function paragraphText(para) {
|
|
202
|
+
let t = "";
|
|
203
|
+
forEachVisibleRun(para, run => {
|
|
204
|
+
for (const c of run.content) {
|
|
205
|
+
if (c.type === "text") {
|
|
206
|
+
t += c.text;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return t;
|
|
211
|
+
}
|
|
212
|
+
/** Replace text within a single paragraph (mutates run-text in place). */
|
|
213
|
+
function replaceInParagraph(para, search, replacement) {
|
|
214
|
+
// Pass 1: in-segment replacement (the placeholder lives wholly inside
|
|
215
|
+
// one text node).
|
|
216
|
+
forEachVisibleRun(para, run => {
|
|
217
|
+
for (const c of run.content) {
|
|
218
|
+
if (c.type !== "text") {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const tc = c;
|
|
222
|
+
if (tc.text.includes(search)) {
|
|
223
|
+
tc.text = tc.text.replaceAll(search, replacement);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
// Pass 2: cross-run / cross-segment fallback. If after pass 1 the
|
|
228
|
+
// concatenated paragraph text still contains the search string, the
|
|
229
|
+
// placeholder must have straddled multiple text nodes. Concatenate the
|
|
230
|
+
// whole paragraph, do the replacement, then write the new text into the
|
|
231
|
+
// FIRST visible text node and clear the rest. This is the same strategy
|
|
232
|
+
// the original implementation used; we just delegate text-node iteration
|
|
233
|
+
// to forEachVisibleRun so hyperlinked / tracked-insert runs participate.
|
|
234
|
+
const fullText = paragraphText(para);
|
|
235
|
+
if (!fullText.includes(search)) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const newText = fullText.replaceAll(search, replacement);
|
|
239
|
+
let placed = false;
|
|
240
|
+
forEachVisibleRun(para, run => {
|
|
241
|
+
for (const c of run.content) {
|
|
242
|
+
if (c.type !== "text") {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
const tc = c;
|
|
246
|
+
if (!placed) {
|
|
247
|
+
tc.text = newText;
|
|
248
|
+
placed = true;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
tc.text = "";
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/** Patch a paragraph — returns replacement content or null to remove. */
|
|
257
|
+
function patchParagraph(para, patchMap) {
|
|
258
|
+
let text = paragraphText(para);
|
|
259
|
+
// First pass: apply all text replacements (can have multiple in same paragraph)
|
|
260
|
+
for (const [placeholder, patch] of patchMap) {
|
|
261
|
+
if (patch.content.type !== "text") {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (!text.includes(placeholder)) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
replaceInParagraph(para, placeholder, patch.content.text);
|
|
268
|
+
text = paragraphText(para); // Re-read after replacement
|
|
269
|
+
}
|
|
270
|
+
// Second pass: structural replacements (paragraph/table/image replace entire paragraph)
|
|
271
|
+
text = paragraphText(para);
|
|
272
|
+
for (const [placeholder, patch] of patchMap) {
|
|
273
|
+
if (patch.content.type === "text") {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (!text.includes(placeholder)) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
switch (patch.content.type) {
|
|
280
|
+
case "paragraph": {
|
|
281
|
+
return patch.content.children;
|
|
282
|
+
}
|
|
283
|
+
case "table": {
|
|
284
|
+
return patch.content.table;
|
|
285
|
+
}
|
|
286
|
+
case "image": {
|
|
287
|
+
// The patch was normalized in applyPatchesToDocument so image.rId
|
|
288
|
+
// is guaranteed populated and consistent with other patches that
|
|
289
|
+
// share the same fileName. Read it directly — never re-derive it
|
|
290
|
+
// here, or rId generation could drift between the body reference
|
|
291
|
+
// and the registered relationship.
|
|
292
|
+
const img = patch.content.image;
|
|
293
|
+
const rId = img.rId;
|
|
294
|
+
const imgContent = {
|
|
295
|
+
type: "image",
|
|
296
|
+
rId,
|
|
297
|
+
width: patch.content.width,
|
|
298
|
+
height: patch.content.height,
|
|
299
|
+
altText: img.fileName,
|
|
300
|
+
name: img.fileName
|
|
301
|
+
};
|
|
302
|
+
const newPara = {
|
|
303
|
+
type: "paragraph",
|
|
304
|
+
properties: para.properties,
|
|
305
|
+
children: [{ content: [imgContent] }]
|
|
306
|
+
};
|
|
307
|
+
return newPara;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return para;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Patch a list of body content blocks, recursing into every container that
|
|
315
|
+
* may hold paragraphs. Returns a new array (paragraphs that get replaced
|
|
316
|
+
* by `paragraph` patches expand into multiple blocks) but mutates inner
|
|
317
|
+
* tables/SDTs/text-boxes/etc. in place.
|
|
318
|
+
*/
|
|
319
|
+
function patchBlockList(blocks, patchMap) {
|
|
320
|
+
const out = [];
|
|
321
|
+
for (const block of blocks) {
|
|
322
|
+
const replaced = patchBlock(block, patchMap);
|
|
323
|
+
if (replaced === null) {
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
if (Array.isArray(replaced)) {
|
|
327
|
+
out.push(...replaced);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
out.push(replaced);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return out;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Patch a single block. Paragraphs may resolve to a single block, an array
|
|
337
|
+
* of blocks (when the placeholder maps to `{ type: "paragraph", ... }`),
|
|
338
|
+
* or null (currently unused — paragraphs always resolve to at least
|
|
339
|
+
* themselves). Tables / SDTs / text-boxes / drawing shapes / TOCs are
|
|
340
|
+
* mutated in place and the same reference is returned.
|
|
341
|
+
*/
|
|
342
|
+
function patchBlock(block, patchMap) {
|
|
343
|
+
switch (block.type) {
|
|
344
|
+
case "paragraph":
|
|
345
|
+
return patchParagraph(block, patchMap);
|
|
346
|
+
case "table":
|
|
347
|
+
patchTable(block, patchMap);
|
|
348
|
+
return block;
|
|
349
|
+
case "sdt":
|
|
350
|
+
patchSdt(block, patchMap);
|
|
351
|
+
return block;
|
|
352
|
+
case "textBox":
|
|
353
|
+
patchTextBox(block, patchMap);
|
|
354
|
+
return block;
|
|
355
|
+
case "drawingShape":
|
|
356
|
+
patchDrawingShape(block, patchMap);
|
|
357
|
+
return block;
|
|
358
|
+
case "tableOfContents":
|
|
359
|
+
patchTableOfContents(block, patchMap);
|
|
360
|
+
return block;
|
|
361
|
+
default:
|
|
362
|
+
return block;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/** Patch text and structural placeholders inside table cells recursively. */
|
|
366
|
+
function patchTable(table, patchMap) {
|
|
367
|
+
for (const row of table.rows) {
|
|
368
|
+
for (const cell of row.cells) {
|
|
369
|
+
// TableCell.content is `(Paragraph | Table)[]`. patchBlockList may
|
|
370
|
+
// expand a single paragraph into multiple paragraphs (for paragraph
|
|
371
|
+
// patches) but never into types outside the cell-content union, so
|
|
372
|
+
// the result is structurally compatible.
|
|
373
|
+
const newContent = patchBlockList(cell.content, patchMap);
|
|
374
|
+
cell.content = newContent;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Patch the children of a structured document tag.
|
|
380
|
+
*
|
|
381
|
+
* SDT.content is `(Paragraph | Run | Table)[]`. Two cases:
|
|
382
|
+
* - Block SDTs hold paragraphs/tables → patch each through patchBlock.
|
|
383
|
+
* - Inline SDTs hold raw runs (a content control wrapping one or more
|
|
384
|
+
* runs inside a paragraph). Wrap them in a synthetic paragraph so
|
|
385
|
+
* placeholder matching works the same as in any other paragraph,
|
|
386
|
+
* then write the (possibly mutated) runs back. We never structurally
|
|
387
|
+
* replace a synthetic paragraph — paragraph/table/image patches on
|
|
388
|
+
* inline SDTs would corrupt the surrounding paragraph, so they are
|
|
389
|
+
* ignored for the inline-run case (text patches still apply).
|
|
390
|
+
*/
|
|
391
|
+
function patchSdt(sdt, patchMap) {
|
|
392
|
+
const newChildren = [];
|
|
393
|
+
// Buffer of consecutive inline runs so a placeholder split across runs
|
|
394
|
+
// inside an inline SDT still gets stitched correctly.
|
|
395
|
+
let runBuffer = [];
|
|
396
|
+
const flushRunBuffer = () => {
|
|
397
|
+
if (runBuffer.length === 0) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const synthetic = {
|
|
401
|
+
type: "paragraph",
|
|
402
|
+
children: runBuffer
|
|
403
|
+
};
|
|
404
|
+
// Apply text patches only — structural patches on inline runs would
|
|
405
|
+
// require splitting the enclosing paragraph, which we can't do here.
|
|
406
|
+
const text = paragraphText(synthetic);
|
|
407
|
+
for (const [placeholder, patch] of patchMap) {
|
|
408
|
+
if (patch.content.type !== "text") {
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (!text.includes(placeholder)) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
replaceInParagraph(synthetic, placeholder, patch.content.text);
|
|
415
|
+
}
|
|
416
|
+
// Push the (possibly-mutated) runs back into the SDT content stream.
|
|
417
|
+
for (const r of runBuffer) {
|
|
418
|
+
newChildren.push(r);
|
|
419
|
+
}
|
|
420
|
+
runBuffer = [];
|
|
421
|
+
};
|
|
422
|
+
for (const child of sdt.content) {
|
|
423
|
+
if (child && typeof child === "object" && "type" in child) {
|
|
424
|
+
const typed = child;
|
|
425
|
+
if (typed.type === "paragraph") {
|
|
426
|
+
flushRunBuffer();
|
|
427
|
+
const result = patchParagraph(child, patchMap);
|
|
428
|
+
if (result === null) {
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (Array.isArray(result)) {
|
|
432
|
+
// paragraph[] → keep all paragraph items, drop any non-paragraph
|
|
433
|
+
// (defensive: PatchContent.paragraph carries Paragraph[], so this
|
|
434
|
+
// branch only ever yields paragraphs in practice).
|
|
435
|
+
for (const item of result) {
|
|
436
|
+
if (item.type === "paragraph") {
|
|
437
|
+
newChildren.push(item);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
else if (result.type === "paragraph") {
|
|
442
|
+
newChildren.push(result);
|
|
443
|
+
}
|
|
444
|
+
else if (result.type === "table") {
|
|
445
|
+
newChildren.push(result);
|
|
446
|
+
}
|
|
447
|
+
// Other replacement types (image-as-paragraph is already a
|
|
448
|
+
// paragraph) cannot appear here.
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
if (typed.type === "table") {
|
|
452
|
+
flushRunBuffer();
|
|
453
|
+
patchTable(child, patchMap);
|
|
454
|
+
newChildren.push(child);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// Inline run (no `type` discriminator on Run — it's the default shape).
|
|
459
|
+
if (child &&
|
|
460
|
+
typeof child === "object" &&
|
|
461
|
+
!("type" in child) &&
|
|
462
|
+
"content" in child &&
|
|
463
|
+
Array.isArray(child.content)) {
|
|
464
|
+
runBuffer.push(child);
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
// Anything else: pass through unchanged.
|
|
468
|
+
newChildren.push(child);
|
|
469
|
+
}
|
|
470
|
+
flushRunBuffer();
|
|
471
|
+
sdt.content = newChildren;
|
|
472
|
+
}
|
|
473
|
+
/** Patch text and structural placeholders inside a text box's paragraphs. */
|
|
474
|
+
function patchTextBox(textBox, patchMap) {
|
|
475
|
+
const newContent = patchBlockList(textBox.content, patchMap);
|
|
476
|
+
// TextBox.content is `Paragraph[]`. Discard any non-paragraph items
|
|
477
|
+
// produced by structural patches (defensive — paragraph patches yield
|
|
478
|
+
// paragraphs, table/image patches don't make sense inside a textBox).
|
|
479
|
+
const paragraphs = [];
|
|
480
|
+
for (const block of newContent) {
|
|
481
|
+
if (block.type === "paragraph") {
|
|
482
|
+
paragraphs.push(block);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
textBox.content = paragraphs;
|
|
486
|
+
}
|
|
487
|
+
/** Patch text and structural placeholders inside a drawing shape's text body. */
|
|
488
|
+
function patchDrawingShape(shape, patchMap) {
|
|
489
|
+
if (!shape.textContent || shape.textContent.length === 0) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const newContent = patchBlockList(shape.textContent, patchMap);
|
|
493
|
+
const paragraphs = [];
|
|
494
|
+
for (const block of newContent) {
|
|
495
|
+
if (block.type === "paragraph") {
|
|
496
|
+
paragraphs.push(block);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
shape.textContent = paragraphs;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Patch placeholders inside a TOC's cached paragraphs. The TOC field
|
|
503
|
+
* caches the rendered text Word displays before the field is updated;
|
|
504
|
+
* users authoring TOCs as templates may legitimately put placeholders in
|
|
505
|
+
* the cached entries (e.g. document title shown as the TOC heading).
|
|
506
|
+
*/
|
|
507
|
+
function patchTableOfContents(toc, patchMap) {
|
|
508
|
+
if (!toc.cachedParagraphs || toc.cachedParagraphs.length === 0) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
const newContent = patchBlockList(toc.cachedParagraphs, patchMap);
|
|
512
|
+
const paragraphs = [];
|
|
513
|
+
for (const block of newContent) {
|
|
514
|
+
if (block.type === "paragraph") {
|
|
515
|
+
paragraphs.push(block);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
toc.cachedParagraphs = paragraphs;
|
|
519
|
+
}
|
|
520
|
+
/** Patch content in header/footer — supports all patch types like body paragraphs. */
|
|
521
|
+
function patchHeaderFooterContent(content, patchMap) {
|
|
522
|
+
const newChildren = patchBlockList(content.children, patchMap);
|
|
523
|
+
// HeaderFooterContent.children is `(Paragraph | Table)[]`.
|
|
524
|
+
content.children = newChildren;
|
|
525
|
+
}
|
|
526
|
+
/** Patch text-only placeholders inside a single paragraph (footnotes/endnotes). */
|
|
527
|
+
function patchTextInParagraph(para, patchMap) {
|
|
528
|
+
const text = paragraphText(para);
|
|
529
|
+
for (const [placeholder, patch] of patchMap) {
|
|
530
|
+
if (!text.includes(placeholder)) {
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (patch.content.type === "text") {
|
|
534
|
+
replaceInParagraph(para, placeholder, patch.content.text);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility Mode API
|
|
3
|
+
*
|
|
4
|
+
* Get and set the Word compatibility mode of a document.
|
|
5
|
+
*/
|
|
6
|
+
import {} from "../core/internal-utils.js";
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Public API
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Get the compatibility mode of a document.
|
|
12
|
+
*
|
|
13
|
+
* Looks at the `compatSetting` named "compatibilityMode" in document settings.
|
|
14
|
+
* Returns 15 (Word 2013+) by default if not found.
|
|
15
|
+
*
|
|
16
|
+
* @param doc - The document to inspect.
|
|
17
|
+
* @returns The compatibility mode version number.
|
|
18
|
+
*/
|
|
19
|
+
export function getCompatibilityMode(doc) {
|
|
20
|
+
if (!doc.settings?.compatSettings) {
|
|
21
|
+
return 15;
|
|
22
|
+
}
|
|
23
|
+
const modeSetting = doc.settings.compatSettings.find(s => s.name === "compatibilityMode");
|
|
24
|
+
if (!modeSetting?.val) {
|
|
25
|
+
return 15;
|
|
26
|
+
}
|
|
27
|
+
const n = parseInt(modeSetting.val, 10);
|
|
28
|
+
if (n === 11 || n === 12 || n === 14 || n === 15) {
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
return 15;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set the compatibility mode of a document (mutates settings in place).
|
|
35
|
+
*
|
|
36
|
+
* @param doc - The document to modify (mutated in place).
|
|
37
|
+
* @param mode - The target compatibility mode (11=Word 2003, 12=Word 2007, 14=Word 2010, 15=Word 2013+).
|
|
38
|
+
*/
|
|
39
|
+
export function setCompatibilityMode(doc, mode) {
|
|
40
|
+
const settings = doc.settings ? { ...doc.settings } : {};
|
|
41
|
+
const compatSettings = settings.compatSettings
|
|
42
|
+
? [...settings.compatSettings]
|
|
43
|
+
: [];
|
|
44
|
+
const idx = compatSettings.findIndex(s => s.name === "compatibilityMode");
|
|
45
|
+
const entry = {
|
|
46
|
+
name: "compatibilityMode",
|
|
47
|
+
uri: "http://schemas.microsoft.com/office/word",
|
|
48
|
+
val: String(mode)
|
|
49
|
+
};
|
|
50
|
+
if (idx >= 0) {
|
|
51
|
+
compatSettings[idx] = entry;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
compatSettings.push(entry);
|
|
55
|
+
}
|
|
56
|
+
settings.compatSettings = compatSettings;
|
|
57
|
+
doc.settings = settings;
|
|
58
|
+
}
|