@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,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Search & Query API (read-only helpers)
|
|
3
|
+
*
|
|
4
|
+
* Functions for searching, counting, and extracting text from a DocxDocument.
|
|
5
|
+
*/
|
|
6
|
+
import type { DocxDocument, Paragraph, Table, Hyperlink, BookmarkStart, CommentDef, ImageDef, SectionProperties } from "../types.js";
|
|
7
|
+
/** Result of a text search in a document. */
|
|
8
|
+
export interface SearchResult {
|
|
9
|
+
/**
|
|
10
|
+
* The paragraph's visit order across the entire document, counting
|
|
11
|
+
* paragraphs reachable from the body (including those nested in tables,
|
|
12
|
+
* SDTs, text boxes, headers, footers, footnotes, endnotes and TOC
|
|
13
|
+
* caches) in walk order.
|
|
14
|
+
*
|
|
15
|
+
* This is **not** an index into `doc.body`: nested paragraphs are
|
|
16
|
+
* counted too. Use it as a stable ordinal for ordering results, not
|
|
17
|
+
* for direct array access.
|
|
18
|
+
*/
|
|
19
|
+
readonly paragraphIndex: number;
|
|
20
|
+
/** The matched text. */
|
|
21
|
+
readonly match: string;
|
|
22
|
+
/** Character offset within the paragraph's concatenated text. */
|
|
23
|
+
readonly offset: number;
|
|
24
|
+
}
|
|
25
|
+
/** A heading extracted from a document. */
|
|
26
|
+
export interface DocumentHeading {
|
|
27
|
+
/** Heading level (1-9). */
|
|
28
|
+
readonly level: number;
|
|
29
|
+
/** Plain text of the heading. */
|
|
30
|
+
readonly text: string;
|
|
31
|
+
/** Index into doc.body where the paragraph resides. */
|
|
32
|
+
readonly paragraphIndex: number;
|
|
33
|
+
/** Style ID used (e.g. "Heading1"). */
|
|
34
|
+
readonly style?: string;
|
|
35
|
+
}
|
|
36
|
+
/** A section definition found in the document. */
|
|
37
|
+
export interface DocumentSection {
|
|
38
|
+
/** The section properties. */
|
|
39
|
+
readonly properties: SectionProperties;
|
|
40
|
+
/** Index of the paragraph containing this section break (or -1 for the final section). */
|
|
41
|
+
readonly paragraphIndex: number;
|
|
42
|
+
/** Whether this is the final section (from doc.sectionProperties). */
|
|
43
|
+
readonly isFinal: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Extract concatenated plain text from a paragraph's runs. */
|
|
46
|
+
export declare function paragraphText(para: Paragraph): string;
|
|
47
|
+
/**
|
|
48
|
+
* Count all top-level paragraphs in the document body.
|
|
49
|
+
*/
|
|
50
|
+
export declare function paragraphCount(doc: DocxDocument): number;
|
|
51
|
+
/**
|
|
52
|
+
* Count words across all paragraphs in the document body.
|
|
53
|
+
* Uses simple whitespace splitting; for East Asian text, each CJK character
|
|
54
|
+
* is counted as one "word" to approximate meaningful unit count.
|
|
55
|
+
*/
|
|
56
|
+
export declare function countWords(doc: DocxDocument): number;
|
|
57
|
+
/**
|
|
58
|
+
* Extract the heading outline from a document.
|
|
59
|
+
*
|
|
60
|
+
* Matches paragraphs whose style is `Heading1` through `Heading9` (case-insensitive),
|
|
61
|
+
* or whose `outlineLevel` property is set (0-8).
|
|
62
|
+
*/
|
|
63
|
+
export declare function getHeadings(doc: DocxDocument): DocumentHeading[];
|
|
64
|
+
/**
|
|
65
|
+
* Find a bookmark by name.
|
|
66
|
+
*
|
|
67
|
+
* @returns The bookmark start marker + its location, or `undefined` if not found.
|
|
68
|
+
*/
|
|
69
|
+
export declare function findBookmark(doc: DocxDocument, name: string): {
|
|
70
|
+
bookmark: BookmarkStart;
|
|
71
|
+
paragraphIndex: number;
|
|
72
|
+
childIndex: number;
|
|
73
|
+
} | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Find a comment by its ID.
|
|
76
|
+
*/
|
|
77
|
+
export declare function findComment(doc: DocxDocument, id: number): CommentDef | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* List all images registered in the document.
|
|
80
|
+
*/
|
|
81
|
+
export declare function listImages(doc: DocxDocument): readonly ImageDef[];
|
|
82
|
+
/**
|
|
83
|
+
* List all tables in the document.
|
|
84
|
+
*
|
|
85
|
+
* By default this returns **all** tables in the document body (including
|
|
86
|
+
* tables nested inside other tables, SDTs, text boxes, and TOC cached
|
|
87
|
+
* paragraphs). For top-level only behavior pass `{ topLevelOnly: true }`.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* listTables(doc) // all tables (consistent with tableCount)
|
|
91
|
+
* listTables(doc, { topLevelOnly: true }) // direct children of body only
|
|
92
|
+
*/
|
|
93
|
+
export declare function listTables(doc: DocxDocument, options?: {
|
|
94
|
+
readonly topLevelOnly?: boolean;
|
|
95
|
+
}): readonly Table[];
|
|
96
|
+
/**
|
|
97
|
+
* Collect all hyperlinks in the document body.
|
|
98
|
+
*/
|
|
99
|
+
export declare function listHyperlinks(doc: DocxDocument): readonly Hyperlink[];
|
|
100
|
+
/**
|
|
101
|
+
* Get the total number of tables (top-level) and nested tables.
|
|
102
|
+
*/
|
|
103
|
+
export declare function tableCount(doc: DocxDocument): number;
|
|
104
|
+
/**
|
|
105
|
+
* List all sections in a document.
|
|
106
|
+
*
|
|
107
|
+
* Sections are defined by section breaks within paragraph properties
|
|
108
|
+
* and the final section at the document level.
|
|
109
|
+
*
|
|
110
|
+
* @param doc - The document to inspect.
|
|
111
|
+
* @returns Array of section definitions in document order.
|
|
112
|
+
*/
|
|
113
|
+
export declare function listSections(doc: DocxDocument): DocumentSection[];
|
|
114
|
+
/**
|
|
115
|
+
* Extract plain text from the entire document: body, headers, footers,
|
|
116
|
+
* footnotes, and endnotes.
|
|
117
|
+
*
|
|
118
|
+
* Paragraphs are separated by `\n`. Tables render as tab-separated cell text.
|
|
119
|
+
*/
|
|
120
|
+
export declare function extractText(doc: DocxDocument): string;
|
|
121
|
+
/**
|
|
122
|
+
* Search for text occurrences across the entire document: body, tables, SDTs,
|
|
123
|
+
* headers, footers, footnotes, and endnotes.
|
|
124
|
+
*
|
|
125
|
+
* @param doc - The document model to search.
|
|
126
|
+
* @param query - String or RegExp to search for.
|
|
127
|
+
* @returns Array of search results.
|
|
128
|
+
*/
|
|
129
|
+
export declare function searchText(doc: DocxDocument, query: string | RegExp): SearchResult[];
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Search & Query API (read-only helpers)
|
|
3
|
+
*
|
|
4
|
+
* Functions for searching, counting, and extracting text from a DocxDocument.
|
|
5
|
+
*/
|
|
6
|
+
import { extractParagraphText } from "../core/text-utils.js";
|
|
7
|
+
import { walkDocument } from "../core/walker.js";
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Helpers
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/** Extract concatenated plain text from a paragraph's runs. */
|
|
12
|
+
export function paragraphText(para) {
|
|
13
|
+
return extractParagraphText(para);
|
|
14
|
+
}
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Public API
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Count all top-level paragraphs in the document body.
|
|
20
|
+
*/
|
|
21
|
+
export function paragraphCount(doc) {
|
|
22
|
+
let count = 0;
|
|
23
|
+
for (const block of doc.body) {
|
|
24
|
+
if (block.type === "paragraph") {
|
|
25
|
+
count++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return count;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Count words across all paragraphs in the document body.
|
|
32
|
+
* Uses simple whitespace splitting; for East Asian text, each CJK character
|
|
33
|
+
* is counted as one "word" to approximate meaningful unit count.
|
|
34
|
+
*/
|
|
35
|
+
export function countWords(doc) {
|
|
36
|
+
let count = 0;
|
|
37
|
+
const cjkRe = /[\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/g;
|
|
38
|
+
const visitor = {
|
|
39
|
+
enterParagraph(para) {
|
|
40
|
+
const text = paragraphText(para);
|
|
41
|
+
const cjkCount = (text.match(cjkRe) ?? []).length;
|
|
42
|
+
const latin = text.replace(cjkRe, " ").trim();
|
|
43
|
+
const latinCount = latin ? latin.split(/\s+/).length : 0;
|
|
44
|
+
count += cjkCount + latinCount;
|
|
45
|
+
return "skip";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
walkDocument(doc, visitor, {
|
|
49
|
+
includeHeaders: false,
|
|
50
|
+
includeFooters: false,
|
|
51
|
+
includeFootnotes: false,
|
|
52
|
+
includeEndnotes: false,
|
|
53
|
+
includeComments: false
|
|
54
|
+
});
|
|
55
|
+
return count;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extract the heading outline from a document.
|
|
59
|
+
*
|
|
60
|
+
* Matches paragraphs whose style is `Heading1` through `Heading9` (case-insensitive),
|
|
61
|
+
* or whose `outlineLevel` property is set (0-8).
|
|
62
|
+
*/
|
|
63
|
+
export function getHeadings(doc) {
|
|
64
|
+
const out = [];
|
|
65
|
+
doc.body.forEach((block, i) => {
|
|
66
|
+
if (block.type !== "paragraph") {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const style = block.properties?.style;
|
|
70
|
+
const styleMatch = style ? /^Heading\s*(\d)$/i.exec(style) : null;
|
|
71
|
+
let level;
|
|
72
|
+
if (styleMatch) {
|
|
73
|
+
level = parseInt(styleMatch[1], 10);
|
|
74
|
+
}
|
|
75
|
+
else if (block.properties?.outlineLevel !== undefined && block.properties.outlineLevel < 9) {
|
|
76
|
+
level = block.properties.outlineLevel + 1;
|
|
77
|
+
}
|
|
78
|
+
if (level !== undefined && level >= 1 && level <= 9) {
|
|
79
|
+
out.push({
|
|
80
|
+
level,
|
|
81
|
+
text: paragraphText(block),
|
|
82
|
+
paragraphIndex: i,
|
|
83
|
+
style
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Find a bookmark by name.
|
|
91
|
+
*
|
|
92
|
+
* @returns The bookmark start marker + its location, or `undefined` if not found.
|
|
93
|
+
*/
|
|
94
|
+
export function findBookmark(doc, name) {
|
|
95
|
+
for (let i = 0; i < doc.body.length; i++) {
|
|
96
|
+
const block = doc.body[i];
|
|
97
|
+
if (block.type !== "paragraph") {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
for (let j = 0; j < block.children.length; j++) {
|
|
101
|
+
const ch = block.children[j];
|
|
102
|
+
if ("type" in ch && ch.type === "bookmarkStart" && ch.name === name) {
|
|
103
|
+
return { bookmark: ch, paragraphIndex: i, childIndex: j };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Find a comment by its ID.
|
|
111
|
+
*/
|
|
112
|
+
export function findComment(doc, id) {
|
|
113
|
+
return doc.comments?.find(c => c.id === id);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* List all images registered in the document.
|
|
117
|
+
*/
|
|
118
|
+
export function listImages(doc) {
|
|
119
|
+
return doc.images ?? [];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* List all tables in the document.
|
|
123
|
+
*
|
|
124
|
+
* By default this returns **all** tables in the document body (including
|
|
125
|
+
* tables nested inside other tables, SDTs, text boxes, and TOC cached
|
|
126
|
+
* paragraphs). For top-level only behavior pass `{ topLevelOnly: true }`.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* listTables(doc) // all tables (consistent with tableCount)
|
|
130
|
+
* listTables(doc, { topLevelOnly: true }) // direct children of body only
|
|
131
|
+
*/
|
|
132
|
+
export function listTables(doc, options) {
|
|
133
|
+
if (options?.topLevelOnly) {
|
|
134
|
+
return doc.body.filter((b) => b.type === "table");
|
|
135
|
+
}
|
|
136
|
+
const out = [];
|
|
137
|
+
walkDocument(doc, {
|
|
138
|
+
enterTable(t) {
|
|
139
|
+
out.push(t);
|
|
140
|
+
return "continue";
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
includeHeaders: false,
|
|
144
|
+
includeFooters: false,
|
|
145
|
+
includeFootnotes: false,
|
|
146
|
+
includeEndnotes: false
|
|
147
|
+
});
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Collect all hyperlinks in the document body.
|
|
152
|
+
*/
|
|
153
|
+
export function listHyperlinks(doc) {
|
|
154
|
+
const out = [];
|
|
155
|
+
walkDocument(doc, {
|
|
156
|
+
enterHyperlink(hl) {
|
|
157
|
+
out.push(hl);
|
|
158
|
+
return "continue";
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
includeHeaders: false,
|
|
162
|
+
includeFooters: false,
|
|
163
|
+
includeFootnotes: false,
|
|
164
|
+
includeEndnotes: false
|
|
165
|
+
});
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the total number of tables (top-level) and nested tables.
|
|
170
|
+
*/
|
|
171
|
+
export function tableCount(doc) {
|
|
172
|
+
let count = 0;
|
|
173
|
+
const visitor = {
|
|
174
|
+
enterTable() {
|
|
175
|
+
count++;
|
|
176
|
+
return "continue";
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
walkDocument(doc, visitor, {
|
|
180
|
+
includeHeaders: false,
|
|
181
|
+
includeFooters: false,
|
|
182
|
+
includeFootnotes: false,
|
|
183
|
+
includeEndnotes: false,
|
|
184
|
+
includeComments: false
|
|
185
|
+
});
|
|
186
|
+
return count;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* List all sections in a document.
|
|
190
|
+
*
|
|
191
|
+
* Sections are defined by section breaks within paragraph properties
|
|
192
|
+
* and the final section at the document level.
|
|
193
|
+
*
|
|
194
|
+
* @param doc - The document to inspect.
|
|
195
|
+
* @returns Array of section definitions in document order.
|
|
196
|
+
*/
|
|
197
|
+
export function listSections(doc) {
|
|
198
|
+
const sections = [];
|
|
199
|
+
for (let i = 0; i < doc.body.length; i++) {
|
|
200
|
+
const block = doc.body[i];
|
|
201
|
+
if (block.type === "paragraph" && block.properties?.sectionProperties) {
|
|
202
|
+
sections.push({
|
|
203
|
+
properties: block.properties.sectionProperties,
|
|
204
|
+
paragraphIndex: i,
|
|
205
|
+
isFinal: false
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Add final section
|
|
210
|
+
if (doc.sectionProperties) {
|
|
211
|
+
sections.push({
|
|
212
|
+
properties: doc.sectionProperties,
|
|
213
|
+
paragraphIndex: -1,
|
|
214
|
+
isFinal: true
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return sections;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Extract plain text from the entire document: body, headers, footers,
|
|
221
|
+
* footnotes, and endnotes.
|
|
222
|
+
*
|
|
223
|
+
* Paragraphs are separated by `\n`. Tables render as tab-separated cell text.
|
|
224
|
+
*/
|
|
225
|
+
export function extractText(doc) {
|
|
226
|
+
const lines = [];
|
|
227
|
+
const stack = [];
|
|
228
|
+
const visitor = {
|
|
229
|
+
enterTable() {
|
|
230
|
+
stack.push({ rowCellTexts: [], cellLines: [], tableLines: [] });
|
|
231
|
+
return "continue";
|
|
232
|
+
},
|
|
233
|
+
leaveTable() {
|
|
234
|
+
const frame = stack.pop();
|
|
235
|
+
// Contribute this table's collected lines to parent context
|
|
236
|
+
if (stack.length > 0) {
|
|
237
|
+
// Inside an outer cell — add table lines to the outer cell
|
|
238
|
+
const parent = stack[stack.length - 1];
|
|
239
|
+
for (const line of frame.tableLines) {
|
|
240
|
+
parent.cellLines.push(line);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// Top-level: add directly to output lines
|
|
245
|
+
for (const line of frame.tableLines) {
|
|
246
|
+
lines.push(line);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
enterTableRow() {
|
|
251
|
+
if (stack.length > 0) {
|
|
252
|
+
stack[stack.length - 1].rowCellTexts = [];
|
|
253
|
+
}
|
|
254
|
+
return "continue";
|
|
255
|
+
},
|
|
256
|
+
leaveTableRow() {
|
|
257
|
+
if (stack.length > 0) {
|
|
258
|
+
const frame = stack[stack.length - 1];
|
|
259
|
+
frame.tableLines.push(frame.rowCellTexts.join("\t"));
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
enterTableCell() {
|
|
263
|
+
if (stack.length > 0) {
|
|
264
|
+
stack[stack.length - 1].cellLines = [];
|
|
265
|
+
}
|
|
266
|
+
return "continue";
|
|
267
|
+
},
|
|
268
|
+
leaveTableCell() {
|
|
269
|
+
if (stack.length > 0) {
|
|
270
|
+
const frame = stack[stack.length - 1];
|
|
271
|
+
frame.rowCellTexts.push(frame.cellLines.join(" "));
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
enterParagraph(para) {
|
|
275
|
+
const text = paragraphText(para);
|
|
276
|
+
if (stack.length > 0) {
|
|
277
|
+
stack[stack.length - 1].cellLines.push(text);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
lines.push(text);
|
|
281
|
+
}
|
|
282
|
+
return "skip";
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
walkDocument(doc, visitor, {
|
|
286
|
+
includeHeaders: true,
|
|
287
|
+
includeFooters: true,
|
|
288
|
+
includeFootnotes: true,
|
|
289
|
+
includeEndnotes: true,
|
|
290
|
+
includeComments: false
|
|
291
|
+
});
|
|
292
|
+
return lines.join("\n");
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Search for text occurrences across the entire document: body, tables, SDTs,
|
|
296
|
+
* headers, footers, footnotes, and endnotes.
|
|
297
|
+
*
|
|
298
|
+
* @param doc - The document model to search.
|
|
299
|
+
* @param query - String or RegExp to search for.
|
|
300
|
+
* @returns Array of search results.
|
|
301
|
+
*/
|
|
302
|
+
export function searchText(doc, query) {
|
|
303
|
+
const results = [];
|
|
304
|
+
let idx = 0;
|
|
305
|
+
const visitor = {
|
|
306
|
+
enterParagraph(para) {
|
|
307
|
+
const text = paragraphText(para);
|
|
308
|
+
if (typeof query === "string") {
|
|
309
|
+
// Empty query would loop forever; treat it as "no match".
|
|
310
|
+
if (query.length === 0) {
|
|
311
|
+
idx++;
|
|
312
|
+
return "skip";
|
|
313
|
+
}
|
|
314
|
+
let pos = text.indexOf(query);
|
|
315
|
+
while (pos !== -1) {
|
|
316
|
+
results.push({ paragraphIndex: idx, match: query, offset: pos });
|
|
317
|
+
pos = text.indexOf(query, pos + query.length);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
// Strip the sticky flag — it would constrain matching to lastIndex
|
|
322
|
+
// and silently miss occurrences elsewhere in the paragraph text.
|
|
323
|
+
const baseFlags = query.flags.replace(/y/g, "");
|
|
324
|
+
const re = new RegExp(query.source, baseFlags.includes("g") ? baseFlags : baseFlags + "g");
|
|
325
|
+
let m;
|
|
326
|
+
while ((m = re.exec(text)) !== null) {
|
|
327
|
+
results.push({ paragraphIndex: idx, match: m[0], offset: m.index });
|
|
328
|
+
// Advance past zero-width matches to prevent infinite loops.
|
|
329
|
+
if (m[0].length === 0) {
|
|
330
|
+
re.lastIndex++;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
idx++;
|
|
335
|
+
return "skip";
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
walkDocument(doc, visitor, {
|
|
339
|
+
includeHeaders: true,
|
|
340
|
+
includeFooters: true,
|
|
341
|
+
includeFootnotes: true,
|
|
342
|
+
includeEndnotes: true,
|
|
343
|
+
includeComments: false
|
|
344
|
+
});
|
|
345
|
+
return results;
|
|
346
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Split API
|
|
3
|
+
*
|
|
4
|
+
* Split a single DocxDocument into multiple documents based on
|
|
5
|
+
* sections, page breaks, or heading levels.
|
|
6
|
+
*/
|
|
7
|
+
import type { DocxDocument } from "../types.js";
|
|
8
|
+
/** Options for splitting a document. */
|
|
9
|
+
export interface SplitOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Split criteria.
|
|
12
|
+
*
|
|
13
|
+
* - `"section"` — split at every section break (paragraph with `sectionProperties`).
|
|
14
|
+
* - `"pageBreak"` — split at every explicit page break (run with `breakType: "page"`).
|
|
15
|
+
* - `"heading"` — split at every Heading 1 paragraph (or `headingLevel`).
|
|
16
|
+
*
|
|
17
|
+
* Default: `"section"`.
|
|
18
|
+
*/
|
|
19
|
+
readonly by?: "section" | "pageBreak" | "heading";
|
|
20
|
+
/**
|
|
21
|
+
* Heading level to split on (only used when `by: "heading"`).
|
|
22
|
+
* Default: 1 (Heading 1).
|
|
23
|
+
*/
|
|
24
|
+
readonly headingLevel?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Whether each split document keeps the original document's
|
|
27
|
+
* styles, numbering, settings, fonts, etc.
|
|
28
|
+
* Default: true.
|
|
29
|
+
*/
|
|
30
|
+
readonly preserveSharedParts?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Split a DocxDocument into multiple documents.
|
|
34
|
+
*
|
|
35
|
+
* Each resulting document is a complete, valid DocxDocument with body content
|
|
36
|
+
* from one segment of the original. Headers, footers, footnotes, endnotes,
|
|
37
|
+
* comments, styles, numbering, and settings are preserved in each split unless
|
|
38
|
+
* `preserveSharedParts: false` is specified.
|
|
39
|
+
*
|
|
40
|
+
* @param doc - The document to split.
|
|
41
|
+
* @param options - Split criteria.
|
|
42
|
+
* @returns Array of split documents (at least 1).
|
|
43
|
+
*/
|
|
44
|
+
export declare function splitDocument(doc: DocxDocument, options?: SplitOptions): DocxDocument[];
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Split API
|
|
3
|
+
*
|
|
4
|
+
* Split a single DocxDocument into multiple documents based on
|
|
5
|
+
* sections, page breaks, or heading levels.
|
|
6
|
+
*/
|
|
7
|
+
import { isRun } from "../core/text-utils.js";
|
|
8
|
+
/**
|
|
9
|
+
* Split a DocxDocument into multiple documents.
|
|
10
|
+
*
|
|
11
|
+
* Each resulting document is a complete, valid DocxDocument with body content
|
|
12
|
+
* from one segment of the original. Headers, footers, footnotes, endnotes,
|
|
13
|
+
* comments, styles, numbering, and settings are preserved in each split unless
|
|
14
|
+
* `preserveSharedParts: false` is specified.
|
|
15
|
+
*
|
|
16
|
+
* @param doc - The document to split.
|
|
17
|
+
* @param options - Split criteria.
|
|
18
|
+
* @returns Array of split documents (at least 1).
|
|
19
|
+
*/
|
|
20
|
+
export function splitDocument(doc, options) {
|
|
21
|
+
const opts = {
|
|
22
|
+
by: options?.by ?? "section",
|
|
23
|
+
headingLevel: options?.headingLevel ?? 1,
|
|
24
|
+
preserveSharedParts: options?.preserveSharedParts ?? true
|
|
25
|
+
};
|
|
26
|
+
const segments = splitBody(doc.body, opts);
|
|
27
|
+
if (segments.length === 0) {
|
|
28
|
+
return [doc];
|
|
29
|
+
}
|
|
30
|
+
return segments.map(segment => buildSplitDoc(doc, segment, opts));
|
|
31
|
+
}
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// Internal
|
|
34
|
+
// =============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Split the body into segments based on the split criteria.
|
|
37
|
+
* Returns an array of segments; each segment is an array of body content blocks.
|
|
38
|
+
*/
|
|
39
|
+
function splitBody(body, opts) {
|
|
40
|
+
const segments = [];
|
|
41
|
+
let current = [];
|
|
42
|
+
for (const block of body) {
|
|
43
|
+
if (shouldSplitBefore(block, opts)) {
|
|
44
|
+
// Heading-based split or pageBreakBefore: start a new segment BEFORE this block
|
|
45
|
+
if (current.length > 0) {
|
|
46
|
+
segments.push(current);
|
|
47
|
+
}
|
|
48
|
+
current = [block];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
current.push(block);
|
|
52
|
+
if (shouldSplitAfter(block, opts)) {
|
|
53
|
+
segments.push(current);
|
|
54
|
+
current = [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (current.length > 0) {
|
|
59
|
+
segments.push(current);
|
|
60
|
+
}
|
|
61
|
+
return segments;
|
|
62
|
+
}
|
|
63
|
+
function shouldSplitBefore(block, opts) {
|
|
64
|
+
if (block.type !== "paragraph") {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (opts.by === "heading") {
|
|
68
|
+
return isHeadingLevel(block, opts.headingLevel);
|
|
69
|
+
}
|
|
70
|
+
if (opts.by === "pageBreak") {
|
|
71
|
+
// pageBreakBefore semantically means "this paragraph starts on a new page".
|
|
72
|
+
// Only the explicit run page break stays as an "after" split.
|
|
73
|
+
return block.properties?.pageBreakBefore === true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
function shouldSplitAfter(block, opts) {
|
|
78
|
+
if (block.type !== "paragraph") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (opts.by === "section") {
|
|
82
|
+
return block.properties?.sectionProperties !== undefined;
|
|
83
|
+
}
|
|
84
|
+
if (opts.by === "pageBreak") {
|
|
85
|
+
return paragraphHasExplicitPageBreakRun(block);
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
function isHeadingLevel(para, level) {
|
|
90
|
+
const props = para.properties;
|
|
91
|
+
// outlineLevel mirrors getHeadings()'s detection: outlineLevel 0 == H1,
|
|
92
|
+
// outlineLevel 1 == H2, etc. Levels >= 9 mean "body text" and should not
|
|
93
|
+
// qualify as headings.
|
|
94
|
+
if (props?.outlineLevel !== undefined && props.outlineLevel < 9) {
|
|
95
|
+
if (props.outlineLevel + 1 === level) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const style = props?.style;
|
|
100
|
+
if (!style) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
// Common heading style IDs: "Heading1", "heading 1", "Heading%i", etc.
|
|
104
|
+
const target = String(level);
|
|
105
|
+
const normalized = style.replace(/\s+/g, "").toLowerCase();
|
|
106
|
+
return (normalized === `heading${target}` ||
|
|
107
|
+
normalized === `h${target}` ||
|
|
108
|
+
normalized === `title${target}`);
|
|
109
|
+
}
|
|
110
|
+
function paragraphHasExplicitPageBreakRun(para) {
|
|
111
|
+
for (const child of para.children) {
|
|
112
|
+
if (isRun(child)) {
|
|
113
|
+
for (const c of child.content) {
|
|
114
|
+
if (c.type === "break" && c.breakType === "page") {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
function buildSplitDoc(source, segment, opts) {
|
|
123
|
+
if (!opts.preserveSharedParts) {
|
|
124
|
+
// Minimal split: just body + docType
|
|
125
|
+
return {
|
|
126
|
+
docType: source.docType,
|
|
127
|
+
body: segment
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// Full split: preserve all shared parts
|
|
131
|
+
return {
|
|
132
|
+
...source,
|
|
133
|
+
body: segment
|
|
134
|
+
};
|
|
135
|
+
}
|