ooxml-core 1.50.2 → 1.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/{PptxHandler-PVQW47CY.mjs → PptxHandler-6GRVJRHP.mjs} +2 -2
- package/dist/PptxHandler-E6QYPF7X.mjs +8 -0
- package/dist/PptxHandler-UNQVCIGM.cjs +17 -0
- package/dist/PresentationBuilder-DVDJSV5R.mjs +8 -0
- package/dist/PresentationBuilder-F5UWRF6H.cjs +25 -0
- package/dist/{PresentationBuilder-ZOOVSBPR.mjs → PresentationBuilder-T6YKWPF7.mjs} +2 -2
- package/dist/automation/index.cjs +5806 -4494
- package/dist/automation/index.mjs +5806 -4494
- package/dist/chunk-25IJEN7R.cjs +36 -0
- package/dist/chunk-25JN3ZQM.mjs +58 -0
- package/dist/{chunk-7XYVFUB3.cjs → chunk-2IO523MM.cjs} +1 -0
- package/dist/{chunk-53KMIHYN.mjs → chunk-4LUZHBTT.mjs} +83 -31
- package/dist/chunk-554UZLPS.mjs +237 -0
- package/dist/{chunk-VLKUMQGT.mjs → chunk-63RAF3TS.mjs} +1 -1
- package/dist/{chunk-7UM5IFPR.mjs → chunk-6IUYKP77.mjs} +1 -1
- package/dist/{chunk-VK2G4BGX.mjs → chunk-BIMV5FVL.mjs} +481 -193
- package/dist/{chunk-CODMW5KF.cjs → chunk-CVUMILG3.cjs} +1 -0
- package/dist/{chunk-NBMXEVHL.mjs → chunk-FX6WL42B.mjs} +1 -0
- package/dist/chunk-GI4Y6BBX.mjs +21 -0
- package/dist/{chunk-MX2GFMZS.mjs → chunk-GZL4ERW3.mjs} +1 -1
- package/dist/chunk-HWL2AGLD.cjs +98 -0
- package/dist/chunk-HZAB3YDO.cjs +234 -0
- package/dist/chunk-IDATIFCG.mjs +226 -0
- package/dist/chunk-LO55N7VL.cjs +247 -0
- package/dist/{chunk-FFLU4LUQ.cjs → chunk-LUBPW5NP.cjs} +1629 -1609
- package/dist/chunk-MUNEIE2J.cjs +62 -0
- package/dist/{chunk-ZCKEKP7N.mjs → chunk-RYUADJV6.mjs} +4 -4
- package/dist/chunk-TOBK5FC4.mjs +88 -0
- package/dist/chunk-UV4LMGVZ.mjs +31 -0
- package/dist/{chunk-O3YGBYGZ.mjs → chunk-VRVHM6TJ.mjs} +1 -0
- package/dist/chunk-W7LVJC32.cjs +25 -0
- package/dist/chunk-WAZ7T2BL.cjs +169 -0
- package/dist/{chunk-3OKY56UM.mjs → chunk-YX33WEKS.mjs} +411 -391
- package/dist/docx/auto-number-fields.d.ts +22 -0
- package/dist/docx/auto-number-fields.d.ts.map +1 -0
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/character-styles.d.ts.map +1 -1
- package/dist/docx/clipboard/css.d.ts +21 -0
- package/dist/docx/clipboard/css.d.ts.map +1 -0
- package/dist/docx/clipboard/html-tokens.d.ts +38 -0
- package/dist/docx/clipboard/html-tokens.d.ts.map +1 -0
- package/dist/docx/clipboard/index.d.ts +6 -0
- package/dist/docx/clipboard/index.d.ts.map +1 -0
- package/dist/docx/clipboard/word-fields.d.ts +13 -0
- package/dist/docx/clipboard/word-fields.d.ts.map +1 -0
- package/dist/docx/clipboard/word-fragment.d.ts +14 -0
- package/dist/docx/clipboard/word-fragment.d.ts.map +1 -0
- package/dist/docx/clipboard/word-html.d.ts +22 -0
- package/dist/docx/clipboard/word-html.d.ts.map +1 -0
- package/dist/docx/clipboard/word-list-scan.d.ts +25 -0
- package/dist/docx/clipboard/word-list-scan.d.ts.map +1 -0
- package/dist/docx/clipboard/word-lists.d.ts +13 -0
- package/dist/docx/clipboard/word-lists.d.ts.map +1 -0
- package/dist/docx/clipboard/word-runs.d.ts +18 -0
- package/dist/docx/clipboard/word-runs.d.ts.map +1 -0
- package/dist/docx/clipboard/word-styles.d.ts +35 -0
- package/dist/docx/clipboard/word-styles.d.ts.map +1 -0
- package/dist/docx/compare/build.d.ts +48 -0
- package/dist/docx/compare/build.d.ts.map +1 -0
- package/dist/docx/compare/compare.d.ts +18 -0
- package/dist/docx/compare/compare.d.ts.map +1 -0
- package/dist/docx/compare/context.d.ts +42 -0
- package/dist/docx/compare/context.d.ts.map +1 -0
- package/dist/docx/compare/diff.d.ts +20 -0
- package/dist/docx/compare/diff.d.ts.map +1 -0
- package/dist/docx/compare/index.d.ts +4 -0
- package/dist/docx/compare/index.d.ts.map +1 -0
- package/dist/docx/compare/slide.d.ts +9 -0
- package/dist/docx/compare/slide.d.ts.map +1 -0
- package/dist/docx/compare/spans.d.ts +13 -0
- package/dist/docx/compare/spans.d.ts.map +1 -0
- package/dist/docx/compare/story.d.ts +7 -0
- package/dist/docx/compare/story.d.ts.map +1 -0
- package/dist/docx/compare/table.d.ts +23 -0
- package/dist/docx/compare/table.d.ts.map +1 -0
- package/dist/docx/compare/tokens.d.ts +50 -0
- package/dist/docx/compare/tokens.d.ts.map +1 -0
- package/dist/docx/compare/types.d.ts +51 -0
- package/dist/docx/compare/types.d.ts.map +1 -0
- package/dist/docx/compatibility.d.ts +46 -0
- package/dist/docx/compatibility.d.ts.map +1 -0
- package/dist/docx/computed-fields.d.ts +39 -0
- package/dist/docx/computed-fields.d.ts.map +1 -0
- package/dist/docx/doc-property-field.d.ts +17 -0
- package/dist/docx/doc-property-field.d.ts.map +1 -0
- package/dist/docx/document-parts.d.ts +2 -0
- package/dist/docx/document-parts.d.ts.map +1 -1
- package/dist/docx/drawing-wrap.d.ts +21 -0
- package/dist/docx/drawing-wrap.d.ts.map +1 -0
- package/dist/docx/drawing.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +3965 -2313
- package/dist/docx/embedded.mjs +3965 -2313
- package/dist/docx/field-format.d.ts +45 -0
- package/dist/docx/field-format.d.ts.map +1 -0
- package/dist/docx/field-result-spans.d.ts +62 -0
- package/dist/docx/field-result-spans.d.ts.map +1 -0
- package/dist/docx/field-runs.d.ts.map +1 -1
- package/dist/docx/field-stories.d.ts +9 -0
- package/dist/docx/field-stories.d.ts.map +1 -0
- package/dist/docx/find-stories.d.ts +27 -0
- package/dist/docx/find-stories.d.ts.map +1 -0
- package/dist/docx/highlight.d.ts +19 -0
- package/dist/docx/highlight.d.ts.map +1 -1
- package/dist/docx/hyperlink.d.ts +7 -0
- package/dist/docx/hyperlink.d.ts.map +1 -1
- package/dist/docx/index.cjs +7359 -3476
- package/dist/docx/index.d.ts +13 -1
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +7327 -3476
- package/dist/docx/inline-model.d.ts +21 -0
- package/dist/docx/inline-model.d.ts.map +1 -1
- package/dist/docx/inline-slots.d.ts.map +1 -1
- package/dist/docx/inspect-document.d.ts +21 -0
- package/dist/docx/inspect-document.d.ts.map +1 -0
- package/dist/docx/kinsoku-settings.d.ts +9 -0
- package/dist/docx/kinsoku-settings.d.ts.map +1 -0
- package/dist/docx/layout/adapt-table-floating.d.ts +11 -0
- package/dist/docx/layout/adapt-table-floating.d.ts.map +1 -0
- package/dist/docx/layout/adapt-table.d.ts.map +1 -1
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/computed-field-runs.d.ts +8 -0
- package/dist/docx/layout/computed-field-runs.d.ts.map +1 -0
- package/dist/docx/layout/floats.d.ts +3 -1
- package/dist/docx/layout/floats.d.ts.map +1 -1
- package/dist/docx/layout/flow-floating-table.d.ts +13 -0
- package/dist/docx/layout/flow-floating-table.d.ts.map +1 -0
- package/dist/docx/layout/flow-table.d.ts +1 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +2280 -941
- package/dist/docx/layout/index.mjs +2276 -942
- package/dist/docx/layout/input.d.ts +50 -0
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/layout.d.ts.map +1 -1
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/page-flow.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-tokens.d.ts +6 -0
- package/dist/docx/layout/paragraph-tokens.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +12 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/section-flow.d.ts.map +1 -1
- package/dist/docx/layout/table-autofit-distribute.d.ts +18 -0
- package/dist/docx/layout/table-autofit-distribute.d.ts.map +1 -0
- package/dist/docx/layout/table-autofit-measure.d.ts +15 -0
- package/dist/docx/layout/table-autofit-measure.d.ts.map +1 -0
- package/dist/docx/layout/table-autofit.d.ts +10 -0
- package/dist/docx/layout/table-autofit.d.ts.map +1 -0
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/text-breaks.d.ts +38 -13
- package/dist/docx/layout/text-breaks.d.ts.map +1 -1
- package/dist/docx/layout/wrap.d.ts +1 -1
- package/dist/docx/layout/wrap.d.ts.map +1 -1
- package/dist/docx/list-number-fields.d.ts +25 -0
- package/dist/docx/list-number-fields.d.ts.map +1 -0
- package/dist/docx/load/index.cjs +4355 -2703
- package/dist/docx/load/index.mjs +4355 -2703
- package/dist/docx/model-paragraph.d.ts +12 -1
- package/dist/docx/model-paragraph.d.ts.map +1 -1
- package/dist/docx/model.d.ts +26 -1
- package/dist/docx/model.d.ts.map +1 -1
- package/dist/docx/note-convert.d.ts +45 -0
- package/dist/docx/note-convert.d.ts.map +1 -0
- package/dist/docx/numbering-counters.d.ts +17 -0
- package/dist/docx/numbering-counters.d.ts.map +1 -0
- package/dist/docx/numbering-format.d.ts +11 -2
- package/dist/docx/numbering-format.d.ts.map +1 -1
- package/dist/docx/outline-numbering.d.ts +6 -0
- package/dist/docx/outline-numbering.d.ts.map +1 -0
- package/dist/docx/package-information-save.d.ts +9 -0
- package/dist/docx/package-information-save.d.ts.map +1 -0
- package/dist/docx/package-information.d.ts +43 -0
- package/dist/docx/package-information.d.ts.map +1 -0
- package/dist/docx/package-properties.d.ts +5 -0
- package/dist/docx/package-properties.d.ts.map +1 -0
- package/dist/docx/paragraph-styles.d.ts +2 -0
- package/dist/docx/paragraph-styles.d.ts.map +1 -1
- package/dist/docx/parse-revisions.d.ts +2 -0
- package/dist/docx/parse-revisions.d.ts.map +1 -1
- package/dist/docx/parse-table-floating.d.ts +5 -0
- package/dist/docx/parse-table-floating.d.ts.map +1 -0
- package/dist/docx/parse-table.d.ts.map +1 -1
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/part-relationships.d.ts.map +1 -1
- package/dist/docx/personal-information.d.ts +18 -0
- package/dist/docx/personal-information.d.ts.map +1 -0
- package/dist/docx/picture-crop-edit.d.ts +18 -0
- package/dist/docx/picture-crop-edit.d.ts.map +1 -0
- package/dist/docx/picture-watermark.d.ts +29 -0
- package/dist/docx/picture-watermark.d.ts.map +1 -0
- package/dist/docx/relationship-allocator.d.ts.map +1 -1
- package/dist/docx/remove-document-information.d.ts +8 -0
- package/dist/docx/remove-document-information.d.ts.map +1 -0
- package/dist/docx/revision-commands.d.ts +6 -1
- package/dist/docx/revision-commands.d.ts.map +1 -1
- package/dist/docx/revision-ids.d.ts.map +1 -1
- package/dist/docx/run-language.d.ts +9 -0
- package/dist/docx/run-language.d.ts.map +1 -0
- package/dist/docx/run-properties-snapshot.d.ts +9 -0
- package/dist/docx/run-properties-snapshot.d.ts.map +1 -0
- package/dist/docx/run-style-model.d.ts +4 -0
- package/dist/docx/run-style-model.d.ts.map +1 -1
- package/dist/docx/save-modified.d.ts +2 -1
- package/dist/docx/save-modified.d.ts.map +1 -1
- package/dist/docx/save.d.ts.map +1 -1
- package/dist/docx/style-ref-fields.d.ts +1 -8
- package/dist/docx/style-ref-fields.d.ts.map +1 -1
- package/dist/docx/symbol-field.d.ts +21 -0
- package/dist/docx/symbol-field.d.ts.map +1 -0
- package/dist/docx/table-cell-write.d.ts.map +1 -1
- package/dist/docx/table-defaults.d.ts +2 -0
- package/dist/docx/table-defaults.d.ts.map +1 -1
- package/dist/docx/table-margins.d.ts +18 -0
- package/dist/docx/table-margins.d.ts.map +1 -0
- package/dist/docx/table-model.d.ts +23 -0
- package/dist/docx/table-model.d.ts.map +1 -1
- package/dist/docx/table-structure-check.d.ts.map +1 -1
- package/dist/docx/table-styles.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +787 -435
- package/dist/docx/ui/index.d.ts +1 -0
- package/dist/docx/ui/index.d.ts.map +1 -1
- package/dist/docx/ui/index.mjs +784 -436
- package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
- package/dist/docx/ui/paragraph-attributes.d.ts +6 -0
- package/dist/docx/ui/paragraph-attributes.d.ts.map +1 -1
- package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
- package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
- package/dist/docx/ui/ribbon-legacy-labels.d.ts +1 -1
- package/dist/docx/ui/ribbon-legacy-labels.d.ts.map +1 -1
- package/dist/docx/ui/run-adapter.d.ts.map +1 -1
- package/dist/docx/ui/schema-marks.d.ts +2 -19
- package/dist/docx/ui/schema-marks.d.ts.map +1 -1
- package/dist/docx/ui/track-run-formatting.d.ts.map +1 -1
- package/dist/docx/ui/yjs-document-attributes.d.ts +5 -0
- package/dist/docx/ui/yjs-document-attributes.d.ts.map +1 -1
- package/dist/docx/write-drawing-wrap.d.ts +22 -0
- package/dist/docx/write-drawing-wrap.d.ts.map +1 -0
- package/dist/docx/write-drawing.d.ts.map +1 -1
- package/dist/docx/write-revisions.d.ts +3 -1
- package/dist/docx/write-revisions.d.ts.map +1 -1
- package/dist/docx/write-shape.d.ts.map +1 -1
- package/dist/docx/write-table-properties.d.ts.map +1 -1
- package/dist/docx/write.d.ts.map +1 -1
- package/dist/drawingml/html-text-paste.d.ts +28 -0
- package/dist/drawingml/html-text-paste.d.ts.map +1 -0
- package/dist/drawingml/html-text-style.d.ts +18 -0
- package/dist/drawingml/html-text-style.d.ts.map +1 -0
- package/dist/drawingml/index.cjs +762 -0
- package/dist/drawingml/index.d.ts +1 -0
- package/dist/drawingml/index.d.ts.map +1 -1
- package/dist/drawingml/index.mjs +760 -1
- package/dist/index.cjs +1147 -251
- package/dist/index.mjs +1147 -251
- package/dist/pptx/automation/index.cjs +561 -180
- package/dist/pptx/automation/index.d.ts +4 -4
- package/dist/pptx/automation/index.mjs +6 -5
- package/dist/pptx/chunks/{index-BCy58n13.d.ts → index-8ZfPndYR.d.ts} +2 -2
- package/dist/pptx/chunks/{index-BCy58n13.d.ts.map → index-8ZfPndYR.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-OwiX5IVw.d.ts → index-DVhD9Kd5.d.ts} +4 -4
- package/dist/pptx/chunks/{index-OwiX5IVw.d.ts.map → index-DVhD9Kd5.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-oQHWAO7M.d.ts → index-DsUnUj-V.d.ts} +5 -5
- package/dist/pptx/chunks/{index-oQHWAO7M.d.ts.map → index-DsUnUj-V.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-AZN38e6S.d.ts → index-xB7MDLI7.d.ts} +4 -4
- package/dist/pptx/chunks/{index-AZN38e6S.d.ts.map → index-xB7MDLI7.d.ts.map} +1 -1
- package/dist/pptx/chunks/{presentation-DOaYIW-l.d.ts → presentation-BvnVkFPJ.d.ts} +26 -2
- package/dist/pptx/chunks/{presentation-DOaYIW-l.d.ts.map → presentation-BvnVkFPJ.d.ts.map} +1 -1
- package/dist/pptx/chunks/{text-operations-CYSXno9L.d.ts → text-operations-D7TCPhlv.d.ts} +2 -2
- package/dist/pptx/chunks/{text-operations-CYSXno9L.d.ts.map → text-operations-D7TCPhlv.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +504 -124
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/custom-show-operations.cjs +2 -2
- package/dist/pptx/editor/render/custom-show-operations.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +16 -15
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +3 -2
- package/dist/pptx/editor/render/font-family-update.d.ts +2 -2
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +2 -2
- package/dist/pptx/editor/render/segments-text-edit.cjs +159 -0
- package/dist/pptx/editor/render/segments-text-edit.d.ts +26 -0
- package/dist/pptx/editor/render/segments-text-edit.d.ts.map +1 -0
- package/dist/pptx/editor/render/segments-text-edit.mjs +156 -0
- package/dist/pptx/editor/render/slide-operations.cjs +12 -9
- package/dist/pptx/editor/render/slide-operations.mjs +6 -3
- package/dist/pptx/editor/render/table-cell-edit.cjs +5 -5
- package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-cell-edit.mjs +1 -1
- package/dist/pptx/editor/render/table-cell-merge.cjs +3 -3
- package/dist/pptx/editor/render/table-cell-merge.mjs +1 -1
- package/dist/pptx/editor/render/table-cell-rich-text.cjs +41 -0
- package/dist/pptx/editor/render/table-cell-rich-text.d.ts +50 -0
- package/dist/pptx/editor/render/table-cell-rich-text.d.ts.map +1 -0
- package/dist/pptx/editor/render/table-cell-rich-text.mjs +8 -0
- package/dist/pptx/editor/render/table-cell-source.cjs +23 -0
- package/dist/pptx/editor/render/table-cell-source.d.ts +31 -0
- package/dist/pptx/editor/render/table-cell-source.d.ts.map +1 -0
- package/dist/pptx/editor/render/table-cell-source.mjs +6 -0
- package/dist/pptx/editor/render/table-cells-text-style.cjs +116 -0
- package/dist/pptx/editor/render/table-cells-text-style.d.ts +37 -0
- package/dist/pptx/editor/render/table-cells-text-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/table-cells-text-style.mjs +113 -0
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +40 -94
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +3 -88
- package/dist/pptx/editor/render/table-grid-fill.cjs +30 -0
- package/dist/pptx/editor/render/table-grid-fill.d.ts +34 -0
- package/dist/pptx/editor/render/table-grid-fill.d.ts.map +1 -0
- package/dist/pptx/editor/render/table-grid-fill.mjs +28 -0
- package/dist/pptx/editor/render/table-layout.cjs +6 -6
- package/dist/pptx/editor/render/table-layout.d.ts +2 -2
- package/dist/pptx/editor/render/table-layout.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-layout.mjs +1 -1
- package/dist/pptx/editor/render/table-merge.cjs +5 -5
- package/dist/pptx/editor/render/table-merge.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.d.ts +2 -2
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -2
- package/dist/pptx/editor/render/text-style-scope.d.ts +2 -2
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +2 -2
- package/dist/pptx/index.cjs +519 -201
- package/dist/pptx/index.d.ts +7 -7
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.d.ts +2 -2
- package/dist/teams/index.cjs +35 -25
- package/dist/teams/index.mjs +35 -25
- package/dist/text/complex-breaks.d.ts +24 -0
- package/dist/text/complex-breaks.d.ts.map +1 -0
- package/dist/text/east-asian.d.ts +32 -0
- package/dist/text/east-asian.d.ts.map +1 -0
- package/dist/text/html-tokens.d.ts +45 -0
- package/dist/text/html-tokens.d.ts.map +1 -0
- package/dist/text/index.cjs +477 -62
- package/dist/text/index.d.ts +5 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.mjs +456 -63
- package/dist/text/kinsoku.d.ts +55 -0
- package/dist/text/kinsoku.d.ts.map +1 -0
- package/dist/text/truetype/embedding.d.ts +42 -0
- package/dist/text/truetype/embedding.d.ts.map +1 -0
- package/dist/text/windows-1252.d.ts +10 -0
- package/dist/text/windows-1252.d.ts.map +1 -0
- package/dist/xlsx/collab/index.cjs +10 -6
- package/dist/xlsx/collab/index.mjs +10 -6
- package/dist/xlsx/edit/clipboard-html-parse.d.ts +1 -0
- package/dist/xlsx/edit/clipboard-html-parse.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/text-convert.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +96 -51
- package/dist/xlsx/index.mjs +96 -51
- package/dist/xlsx/load/index.cjs +10 -6
- package/dist/xlsx/load/index.mjs +10 -6
- package/dist/xlsx/ui/index.cjs +97 -52
- package/dist/xlsx/ui/index.mjs +97 -52
- package/package.json +1 -1
- package/dist/PptxHandler-72NTA5ZY.cjs +0 -14
- package/dist/PptxHandler-O4IJ3TKZ.mjs +0 -5
- package/dist/PresentationBuilder-ORM22QGC.mjs +0 -5
- package/dist/PresentationBuilder-T2ETYT3L.cjs +0 -22
- package/dist/chunk-X4RL5AZ7.cjs +0 -120
- package/dist/{chunk-PRGXRAAU.mjs → chunk-4Y76EAKK.mjs} +131 -131
- package/dist/{chunk-EN3KSEW5.cjs → chunk-MMULWQOM.cjs} +131 -131
|
@@ -90,8 +90,8 @@ function parseXml(xml, options2 = {}) {
|
|
|
90
90
|
let parsed;
|
|
91
91
|
try {
|
|
92
92
|
parsed = new DOMParser({
|
|
93
|
-
onError: (
|
|
94
|
-
if (
|
|
93
|
+
onError: (level3, message) => {
|
|
94
|
+
if (level3 !== "warning" || options2.warningsAsErrors) parseError = message;
|
|
95
95
|
}
|
|
96
96
|
}).parseFromString(xml, "application/xml");
|
|
97
97
|
} catch (error) {
|
|
@@ -228,8 +228,8 @@ function universalMeasureToTwips(value) {
|
|
|
228
228
|
}
|
|
229
229
|
function parseSignedTwips(value) {
|
|
230
230
|
if (value === null || value === void 0) return void 0;
|
|
231
|
-
const
|
|
232
|
-
const parsed = SAFE_INTEGER.test(
|
|
231
|
+
const text3 = value.trim();
|
|
232
|
+
const parsed = SAFE_INTEGER.test(text3) ? parseInteger(text3) : universalMeasureToTwips(text3);
|
|
233
233
|
return parsed === void 0 ? void 0 : signedTwips(parsed);
|
|
234
234
|
}
|
|
235
235
|
function parseTwips(value) {
|
|
@@ -238,26 +238,26 @@ function parseTwips(value) {
|
|
|
238
238
|
}
|
|
239
239
|
function parseHalfPoints(value) {
|
|
240
240
|
if (value === null || value === void 0) return void 0;
|
|
241
|
-
const
|
|
242
|
-
if (/^\d+$/.test(
|
|
243
|
-
const parsed = parseInteger(
|
|
241
|
+
const text3 = value.trim();
|
|
242
|
+
if (/^\d+$/.test(text3)) {
|
|
243
|
+
const parsed = parseInteger(text3);
|
|
244
244
|
return parsed === void 0 ? void 0 : halfPoints(parsed);
|
|
245
245
|
}
|
|
246
|
-
const asTwips = UNIVERSAL_MEASURE.test(
|
|
246
|
+
const asTwips = UNIVERSAL_MEASURE.test(text3) ? universalMeasureToTwips(text3) : void 0;
|
|
247
247
|
return asTwips !== void 0 && asTwips >= 0 ? halfPoints(Math.round(asTwips / 10)) : void 0;
|
|
248
248
|
}
|
|
249
249
|
function parseSignedHalfPoints(value) {
|
|
250
250
|
if (value === null || value === void 0) return void 0;
|
|
251
|
-
const
|
|
252
|
-
const integer2 = parseInteger(
|
|
251
|
+
const text3 = value.trim();
|
|
252
|
+
const integer2 = parseInteger(text3);
|
|
253
253
|
if (integer2 !== void 0) return halfPoints(integer2);
|
|
254
|
-
const twips2 = universalMeasureToTwips(
|
|
254
|
+
const twips2 = universalMeasureToTwips(text3);
|
|
255
255
|
return twips2 === void 0 ? void 0 : halfPoints(Math.sign(twips2) * Math.round(Math.abs(twips2) / 10));
|
|
256
256
|
}
|
|
257
257
|
function parseTextScale(value) {
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const parsed = parseUnsignedInteger(
|
|
258
|
+
const text3 = value?.trim();
|
|
259
|
+
if (text3?.endsWith("%") && !/^\d+%$/.test(text3)) return void 0;
|
|
260
|
+
const parsed = parseUnsignedInteger(text3?.endsWith("%") ? text3.slice(0, -1) : text3);
|
|
261
261
|
return parsed !== void 0 && parsed <= 600 ? parsed : void 0;
|
|
262
262
|
}
|
|
263
263
|
function parseEighthPoints(value) {
|
|
@@ -516,6 +516,12 @@ var PAGINATION_KEYS = [
|
|
|
516
516
|
"contextualSpacing",
|
|
517
517
|
"suppressLineNumbers"
|
|
518
518
|
];
|
|
519
|
+
var EAST_ASIAN_TYPOGRAPHY_KEYS = [
|
|
520
|
+
"kinsoku",
|
|
521
|
+
"autoSpaceDE",
|
|
522
|
+
"autoSpaceDN",
|
|
523
|
+
"overflowPunct"
|
|
524
|
+
];
|
|
519
525
|
function parseOutlineLevel(element) {
|
|
520
526
|
const raw = getW(element, "val");
|
|
521
527
|
if (raw === void 0) return void 0;
|
|
@@ -560,6 +566,7 @@ function resolveParagraphFormatting(paragraph, catalog) {
|
|
|
560
566
|
"hangingTwips",
|
|
561
567
|
"pageBreakBefore",
|
|
562
568
|
...PAGINATION_KEYS,
|
|
569
|
+
...EAST_ASIAN_TYPOGRAPHY_KEYS,
|
|
563
570
|
"outlineLevel",
|
|
564
571
|
"borders",
|
|
565
572
|
"shadingFill"
|
|
@@ -592,6 +599,45 @@ function resolveStyleNumbering(styleId, catalog) {
|
|
|
592
599
|
return chain.find((style) => style.numbering)?.numbering;
|
|
593
600
|
}
|
|
594
601
|
|
|
602
|
+
// docx/table-margins.ts
|
|
603
|
+
var SIDES = ["top", "right", "bottom", "left"];
|
|
604
|
+
var BUILT_IN = {
|
|
605
|
+
top: signedTwips(0),
|
|
606
|
+
right: signedTwips(108),
|
|
607
|
+
bottom: signedTwips(0),
|
|
608
|
+
left: signedTwips(108)
|
|
609
|
+
};
|
|
610
|
+
var UNSTYLED = {
|
|
611
|
+
top: signedTwips(0),
|
|
612
|
+
right: signedTwips(10),
|
|
613
|
+
bottom: signedTwips(0),
|
|
614
|
+
left: signedTwips(10)
|
|
615
|
+
};
|
|
616
|
+
function styleChain(id, catalog) {
|
|
617
|
+
const chain = [];
|
|
618
|
+
let style = id ? catalog.styles[id] : void 0;
|
|
619
|
+
while (style && !chain.includes(style)) {
|
|
620
|
+
chain.push(style);
|
|
621
|
+
style = style.basedOn ? catalog.styles[style.basedOn] : void 0;
|
|
622
|
+
}
|
|
623
|
+
return chain;
|
|
624
|
+
}
|
|
625
|
+
function resolveTableCellMargins(table, catalog) {
|
|
626
|
+
if (!catalog) return { ...BUILT_IN, ...table.cellMargins };
|
|
627
|
+
const defaultStyle = Object.values(catalog.styles).find((style) => style.isDefault);
|
|
628
|
+
const layers = [
|
|
629
|
+
table.cellMargins,
|
|
630
|
+
...styleChain(table.style, catalog).map((style) => style.cellMargins),
|
|
631
|
+
...styleChain(defaultStyle?.id, catalog).map((style) => style.cellMargins)
|
|
632
|
+
];
|
|
633
|
+
const result = { ...UNSTYLED };
|
|
634
|
+
for (const side of SIDES) {
|
|
635
|
+
const value = layers.find((layer) => layer?.[side] !== void 0)?.[side];
|
|
636
|
+
if (value !== void 0) result[side] = value;
|
|
637
|
+
}
|
|
638
|
+
return result;
|
|
639
|
+
}
|
|
640
|
+
|
|
595
641
|
// docx/highlight.ts
|
|
596
642
|
var WORD_HIGHLIGHT_TOKENS = [
|
|
597
643
|
"black",
|
|
@@ -624,7 +670,7 @@ function isValidLanguageTag(value) {
|
|
|
624
670
|
}
|
|
625
671
|
|
|
626
672
|
// docx/resolve-table.ts
|
|
627
|
-
function
|
|
673
|
+
function styleChain2(styleId, catalog) {
|
|
628
674
|
if (!styleId || !catalog) return [];
|
|
629
675
|
const chain = [];
|
|
630
676
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -649,7 +695,7 @@ function applicableRegions(look, rowIndex, rowCount, colIndex, colCount) {
|
|
|
649
695
|
return regions;
|
|
650
696
|
}
|
|
651
697
|
function resolveTableStyleFormatting(tableStyleId, catalog, look, rowIndex, rowCount, colIndex, colCount) {
|
|
652
|
-
const chain =
|
|
698
|
+
const chain = styleChain2(tableStyleId, catalog);
|
|
653
699
|
const regions = applicableRegions(look, rowIndex, rowCount, colIndex, colCount);
|
|
654
700
|
const result = {};
|
|
655
701
|
for (const style of chain) {
|
|
@@ -767,8 +813,8 @@ function resolveRunFormatting(run, context = {}) {
|
|
|
767
813
|
if (state) result[key] = true;
|
|
768
814
|
}
|
|
769
815
|
for (const key of OVERRIDE_KEYS) {
|
|
770
|
-
for (const
|
|
771
|
-
const value =
|
|
816
|
+
for (const level3 of levels) {
|
|
817
|
+
const value = level3[key];
|
|
772
818
|
if (value !== void 0) result[key] = value;
|
|
773
819
|
}
|
|
774
820
|
}
|
|
@@ -790,13 +836,13 @@ function hexToRgbChannels(color) {
|
|
|
790
836
|
b: Number.parseInt(normalized.slice(4, 6), 16)
|
|
791
837
|
};
|
|
792
838
|
}
|
|
793
|
-
function percentDivisorFor(
|
|
794
|
-
return
|
|
839
|
+
function percentDivisorFor(text3) {
|
|
840
|
+
return text3.endsWith("%") ? 100 : 1e5;
|
|
795
841
|
}
|
|
796
842
|
function parseOoxmlPercent(value) {
|
|
797
|
-
const
|
|
798
|
-
const divisor = percentDivisorFor(
|
|
799
|
-
const magnitude = Number.parseFloat(divisor === 100 ?
|
|
843
|
+
const text3 = String(value ?? "").trim();
|
|
844
|
+
const divisor = percentDivisorFor(text3);
|
|
845
|
+
const magnitude = Number.parseFloat(divisor === 100 ? text3.slice(0, -1) : text3);
|
|
800
846
|
if (!Number.isFinite(magnitude)) {
|
|
801
847
|
return void 0;
|
|
802
848
|
}
|
|
@@ -1579,10 +1625,10 @@ function parseStandardPictureEffect(node) {
|
|
|
1579
1625
|
|
|
1580
1626
|
// drawingml/picture-effects.ts
|
|
1581
1627
|
function picturePercentage(value) {
|
|
1582
|
-
const
|
|
1583
|
-
if (!
|
|
1584
|
-
const percent =
|
|
1585
|
-
const n2 = Number(percent ?
|
|
1628
|
+
const text3 = String(value ?? "").trim();
|
|
1629
|
+
if (!text3) return void 0;
|
|
1630
|
+
const percent = text3.endsWith("%");
|
|
1631
|
+
const n2 = Number(percent ? text3.slice(0, -1) : text3) / (percent ? 100 : 1e5);
|
|
1586
1632
|
return Number.isFinite(n2) ? n2 : void 0;
|
|
1587
1633
|
}
|
|
1588
1634
|
function readPictureEffect(name2, attribute) {
|
|
@@ -1663,12 +1709,12 @@ function parsePictureLayout(fill) {
|
|
|
1663
1709
|
}
|
|
1664
1710
|
|
|
1665
1711
|
// drawingml/picture-crop.ts
|
|
1666
|
-
var
|
|
1712
|
+
var SIDES2 = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
|
|
1667
1713
|
function parsePictureCrop(blipFill) {
|
|
1668
1714
|
const rect3 = first(blipFill, "srcRect", NS.a);
|
|
1669
1715
|
if (!rect3) return void 0;
|
|
1670
1716
|
const result = {};
|
|
1671
|
-
for (const [attr3, key] of Object.entries(
|
|
1717
|
+
for (const [attr3, key] of Object.entries(SIDES2)) {
|
|
1672
1718
|
const raw = rect3.getAttribute(attr3);
|
|
1673
1719
|
if (raw === null || !raw.trim()) continue;
|
|
1674
1720
|
const percent = raw.endsWith("%");
|
|
@@ -2062,13 +2108,13 @@ function expectDefined(value, context) {
|
|
|
2062
2108
|
|
|
2063
2109
|
// docx/special-characters.ts
|
|
2064
2110
|
function symbolCharacter(char) {
|
|
2065
|
-
const
|
|
2066
|
-
if (!Number.isInteger(
|
|
2067
|
-
return String.fromCodePoint(
|
|
2111
|
+
const code2 = /^[0-9a-f]{1,6}$/i.test(char) ? Number.parseInt(char, 16) : Number.NaN;
|
|
2112
|
+
if (!Number.isInteger(code2) || code2 > 1114111 || code2 >= 55296 && code2 <= 57343) return "";
|
|
2113
|
+
return String.fromCodePoint(code2 < 256 ? 61440 + code2 : code2);
|
|
2068
2114
|
}
|
|
2069
2115
|
function symbolOnly(run) {
|
|
2070
2116
|
const symbol = run.symbol && symbolCharacter(run.symbol.char);
|
|
2071
|
-
return Boolean(symbol && run.text && [...run.text].every((
|
|
2117
|
+
return Boolean(symbol && run.text && [...run.text].every((character2) => character2 === symbol));
|
|
2072
2118
|
}
|
|
2073
2119
|
function symbolSegments(run) {
|
|
2074
2120
|
const symbol = run.symbol && symbolCharacter(run.symbol.char);
|
|
@@ -2076,13 +2122,13 @@ function symbolSegments(run) {
|
|
|
2076
2122
|
const segments = [];
|
|
2077
2123
|
let piece = "";
|
|
2078
2124
|
let symbols = false;
|
|
2079
|
-
for (const
|
|
2080
|
-
const isSymbol =
|
|
2125
|
+
for (const character2 of run.text) {
|
|
2126
|
+
const isSymbol = character2 === symbol;
|
|
2081
2127
|
if (piece && isSymbol !== symbols) {
|
|
2082
2128
|
segments.push({ ...run, text: piece });
|
|
2083
2129
|
piece = "";
|
|
2084
2130
|
}
|
|
2085
|
-
piece +=
|
|
2131
|
+
piece += character2;
|
|
2086
2132
|
symbols = isSymbol;
|
|
2087
2133
|
}
|
|
2088
2134
|
if (piece) segments.push({ ...run, text: piece });
|
|
@@ -2316,15 +2362,15 @@ function operand(value, vars) {
|
|
|
2316
2362
|
const literal = Number(value);
|
|
2317
2363
|
return Number.isFinite(literal) ? literal : vars.get(value) ?? NaN;
|
|
2318
2364
|
}
|
|
2319
|
-
function parseCustomGeometry(
|
|
2320
|
-
const pathList = first(
|
|
2365
|
+
function parseCustomGeometry(custom2, width, height) {
|
|
2366
|
+
const pathList = first(custom2, "pathLst", NS.a);
|
|
2321
2367
|
if (!pathList) return void 0;
|
|
2322
2368
|
const pathNodes = children(pathList, "path", NS.a);
|
|
2323
2369
|
const contextWidth = width;
|
|
2324
2370
|
const contextHeight = height;
|
|
2325
2371
|
const vars = createBuiltinVariables({ w: contextWidth, h: contextHeight });
|
|
2326
2372
|
for (const list of ["avLst", "gdLst"]) {
|
|
2327
|
-
const parent = first(
|
|
2373
|
+
const parent = first(custom2, list, NS.a);
|
|
2328
2374
|
if (!parent) continue;
|
|
2329
2375
|
for (const guide of children(parent, "gd", NS.a)) {
|
|
2330
2376
|
const name2 = guide.getAttribute("name");
|
|
@@ -2456,10 +2502,10 @@ function lerpStops(a, b, t) {
|
|
|
2456
2502
|
};
|
|
2457
2503
|
}
|
|
2458
2504
|
function gradientColorAt(stops, position) {
|
|
2459
|
-
const
|
|
2505
|
+
const first4 = stops[0];
|
|
2460
2506
|
const last = stops[stops.length - 1];
|
|
2461
|
-
if (position <=
|
|
2462
|
-
return { color:
|
|
2507
|
+
if (position <= first4.position) {
|
|
2508
|
+
return { color: first4.color, opacity: first4.opacity ?? 1 };
|
|
2463
2509
|
}
|
|
2464
2510
|
if (position >= last.position) {
|
|
2465
2511
|
return { color: last.color, opacity: last.opacity ?? 1 };
|
|
@@ -2784,8 +2830,8 @@ var Glyph = class {
|
|
|
2784
2830
|
}
|
|
2785
2831
|
/** `M p0 L p1 ... Z` through the points. */
|
|
2786
2832
|
poly(points, close = true) {
|
|
2787
|
-
const [
|
|
2788
|
-
return `M ${this.pt(
|
|
2833
|
+
const [first4, ...rest] = points;
|
|
2834
|
+
return `M ${this.pt(first4)}${rest.map((q) => ` L ${this.pt(q)}`).join("")}${close ? " Z" : ""}`;
|
|
2789
2835
|
}
|
|
2790
2836
|
/** A full circle of radius `r` centred on `(cx, cy)`. */
|
|
2791
2837
|
circle(cx, cy, r) {
|
|
@@ -9342,15 +9388,15 @@ var heart2 = {
|
|
|
9342
9388
|
};
|
|
9343
9389
|
function buildIrregularSeal(name2, points) {
|
|
9344
9390
|
const commands = [];
|
|
9345
|
-
const
|
|
9346
|
-
if (!
|
|
9391
|
+
const first4 = points[0];
|
|
9392
|
+
if (!first4) {
|
|
9347
9393
|
return {
|
|
9348
9394
|
name: name2,
|
|
9349
9395
|
rect: FULL_RECT7,
|
|
9350
9396
|
pathLst: [{ commands: [{ kind: "close" }] }]
|
|
9351
9397
|
};
|
|
9352
9398
|
}
|
|
9353
|
-
commands.push({ kind: "moveTo", x: String(
|
|
9399
|
+
commands.push({ kind: "moveTo", x: String(first4[0]), y: String(first4[1]) });
|
|
9354
9400
|
for (let i = 1; i < points.length; i++) {
|
|
9355
9401
|
const p2 = points[i];
|
|
9356
9402
|
commands.push({ kind: "lnTo", x: String(p2[0]), y: String(p2[1]) });
|
|
@@ -13863,14 +13909,14 @@ var NAMED_FORMAT_COLORS = {
|
|
|
13863
13909
|
yellow: "#FFFF00"
|
|
13864
13910
|
};
|
|
13865
13911
|
var PLACEHOLDER = /[0#?]/u;
|
|
13866
|
-
function parsePattern(
|
|
13912
|
+
function parsePattern(code2) {
|
|
13867
13913
|
let scale = 1;
|
|
13868
13914
|
let scientific = false;
|
|
13869
13915
|
let color;
|
|
13870
13916
|
const chars = [];
|
|
13871
13917
|
let inQuotes = false;
|
|
13872
|
-
for (let i = 0; i <
|
|
13873
|
-
const ch =
|
|
13918
|
+
for (let i = 0; i < code2.length; i += 1) {
|
|
13919
|
+
const ch = code2[i] ?? "";
|
|
13874
13920
|
if (ch === '"') {
|
|
13875
13921
|
inQuotes = !inQuotes;
|
|
13876
13922
|
continue;
|
|
@@ -13880,7 +13926,7 @@ function parsePattern(code) {
|
|
|
13880
13926
|
continue;
|
|
13881
13927
|
}
|
|
13882
13928
|
if (ch === "\\" || ch === "*" || ch === "_") {
|
|
13883
|
-
const next =
|
|
13929
|
+
const next = code2[i + 1];
|
|
13884
13930
|
i += 1;
|
|
13885
13931
|
if (ch === "\\" && next !== void 0) {
|
|
13886
13932
|
chars.push({ ch: next, literal: true });
|
|
@@ -13892,20 +13938,20 @@ function parsePattern(code) {
|
|
|
13892
13938
|
chars.push({ ch, literal: true });
|
|
13893
13939
|
continue;
|
|
13894
13940
|
}
|
|
13895
|
-
if (ch === "E" && (
|
|
13941
|
+
if (ch === "E" && (code2[i + 1] === "+" || code2[i + 1] === "-")) {
|
|
13896
13942
|
scientific = true;
|
|
13897
13943
|
chars.push({ ch: "E", literal: false });
|
|
13898
13944
|
i += 1;
|
|
13899
13945
|
continue;
|
|
13900
13946
|
}
|
|
13901
13947
|
if (ch === "[") {
|
|
13902
|
-
const close =
|
|
13903
|
-
const token =
|
|
13948
|
+
const close = code2.indexOf("]", i);
|
|
13949
|
+
const token = code2.slice(i + 1, close === -1 ? code2.length : close);
|
|
13904
13950
|
const named3 = NAMED_FORMAT_COLORS[token.trim().toLowerCase()];
|
|
13905
13951
|
if (named3 && color === void 0) {
|
|
13906
13952
|
color = named3;
|
|
13907
13953
|
}
|
|
13908
|
-
i = close === -1 ?
|
|
13954
|
+
i = close === -1 ? code2.length : close;
|
|
13909
13955
|
continue;
|
|
13910
13956
|
}
|
|
13911
13957
|
chars.push({ ch, literal: false });
|
|
@@ -14025,19 +14071,19 @@ function applyPattern(value, pattern, forcePositive) {
|
|
|
14025
14071
|
|
|
14026
14072
|
// chart/number-format.ts
|
|
14027
14073
|
var GENERAL = /* @__PURE__ */ new Set(["", "general", "@"]);
|
|
14028
|
-
function sections(
|
|
14074
|
+
function sections(code2) {
|
|
14029
14075
|
const out = [];
|
|
14030
14076
|
let current = "";
|
|
14031
14077
|
let inQuotes = false;
|
|
14032
|
-
for (let i = 0; i <
|
|
14033
|
-
const ch =
|
|
14078
|
+
for (let i = 0; i < code2.length; i += 1) {
|
|
14079
|
+
const ch = code2[i];
|
|
14034
14080
|
if (ch === '"') {
|
|
14035
14081
|
inQuotes = !inQuotes;
|
|
14036
14082
|
current += ch;
|
|
14037
14083
|
continue;
|
|
14038
14084
|
}
|
|
14039
14085
|
if (ch === "\\") {
|
|
14040
|
-
current += ch + (
|
|
14086
|
+
current += ch + (code2[i + 1] ?? "");
|
|
14041
14087
|
i += 1;
|
|
14042
14088
|
continue;
|
|
14043
14089
|
}
|
|
@@ -14067,14 +14113,14 @@ function formatChartNumberWithColor(value, formatCode) {
|
|
|
14067
14113
|
if (!Number.isFinite(value)) {
|
|
14068
14114
|
return void 0;
|
|
14069
14115
|
}
|
|
14070
|
-
const
|
|
14071
|
-
if (GENERAL.has(
|
|
14116
|
+
const code2 = (formatCode ?? "").trim();
|
|
14117
|
+
if (GENERAL.has(code2.toLowerCase())) {
|
|
14072
14118
|
return void 0;
|
|
14073
14119
|
}
|
|
14074
|
-
if (/(?:^|[^\\"])(?:yy|mm?m|dd?|hh|ss)/iu.test(
|
|
14120
|
+
if (/(?:^|[^\\"])(?:yy|mm?m|dd?|hh|ss)/iu.test(code2) && !/[0#?]/u.test(code2)) {
|
|
14075
14121
|
return void 0;
|
|
14076
14122
|
}
|
|
14077
|
-
const { code: section, forcePositive } = sectionFor(value, sections(
|
|
14123
|
+
const { code: section, forcePositive } = sectionFor(value, sections(code2));
|
|
14078
14124
|
const pattern = parsePattern(section);
|
|
14079
14125
|
if (!pattern) {
|
|
14080
14126
|
return void 0;
|
|
@@ -14114,14 +14160,14 @@ function resolveDataLabelFlags(levels) {
|
|
|
14114
14160
|
};
|
|
14115
14161
|
}
|
|
14116
14162
|
function composeDataLabelText(input) {
|
|
14117
|
-
const { flags, value, numberFormat } = input;
|
|
14163
|
+
const { flags, value, numberFormat: numberFormat2 } = input;
|
|
14118
14164
|
const parts = [];
|
|
14119
14165
|
let valueColor;
|
|
14120
14166
|
if (flags.showSeriesName && input.seriesName) parts.push(input.seriesName);
|
|
14121
14167
|
if (flags.showCategory && input.category) parts.push(input.category);
|
|
14122
14168
|
if (flags.showValue) {
|
|
14123
|
-
const formatted = formatChartNumberWithColor(value,
|
|
14124
|
-
parts.push(formatted?.text ?? (input.formatValue ?? String)(value,
|
|
14169
|
+
const formatted = formatChartNumberWithColor(value, numberFormat2);
|
|
14170
|
+
parts.push(formatted?.text ?? (input.formatValue ?? String)(value, numberFormat2));
|
|
14125
14171
|
valueColor = formatted?.color;
|
|
14126
14172
|
}
|
|
14127
14173
|
if (flags.showPercent) {
|
|
@@ -14130,9 +14176,9 @@ function composeDataLabelText(input) {
|
|
|
14130
14176
|
}
|
|
14131
14177
|
if (flags.showBubbleSize && input.bubbleSize !== void 0)
|
|
14132
14178
|
parts.push((input.formatBubbleSize ?? String)(input.bubbleSize));
|
|
14133
|
-
const
|
|
14134
|
-
if (
|
|
14135
|
-
return { text:
|
|
14179
|
+
const text3 = parts.join(flags.separator);
|
|
14180
|
+
if (text3.length === 0) return void 0;
|
|
14181
|
+
return { text: text3, color: parts.length === 1 && flags.showValue ? valueColor : void 0 };
|
|
14136
14182
|
}
|
|
14137
14183
|
|
|
14138
14184
|
// chart/extent.ts
|
|
@@ -14220,10 +14266,10 @@ function squarify(nodes, box) {
|
|
|
14220
14266
|
const result = [];
|
|
14221
14267
|
let rect3 = { ...box };
|
|
14222
14268
|
let remaining = items;
|
|
14223
|
-
for (let
|
|
14269
|
+
for (let first4 = remaining[0]; first4 !== void 0; first4 = remaining[0]) {
|
|
14224
14270
|
const side = Math.min(rect3.w, rect3.h);
|
|
14225
|
-
let row2 = [
|
|
14226
|
-
let rowAreas = [
|
|
14271
|
+
let row2 = [first4];
|
|
14272
|
+
let rowAreas = [first4.area];
|
|
14227
14273
|
let worst = worstAspectRatio(rowAreas, side);
|
|
14228
14274
|
let cursor = 1;
|
|
14229
14275
|
for (let next = remaining[cursor]; next !== void 0; next = remaining[cursor]) {
|
|
@@ -14258,10 +14304,10 @@ function squarify(nodes, box) {
|
|
|
14258
14304
|
|
|
14259
14305
|
// chart/hierarchy.ts
|
|
14260
14306
|
function normalizeLevels(levels, pointCount) {
|
|
14261
|
-
return levels.map((
|
|
14307
|
+
return levels.map((level3) => {
|
|
14262
14308
|
let previous = "";
|
|
14263
14309
|
return Array.from({ length: pointCount }, (_, index) => {
|
|
14264
|
-
const label =
|
|
14310
|
+
const label = level3[index]?.trim() ?? "";
|
|
14265
14311
|
if (label) previous = label;
|
|
14266
14312
|
return label || previous;
|
|
14267
14313
|
});
|
|
@@ -14419,12 +14465,12 @@ function computeSunburstArcs(series, cx, cy, maxR) {
|
|
|
14419
14465
|
});
|
|
14420
14466
|
return out;
|
|
14421
14467
|
}
|
|
14422
|
-
function hierarchyKey(levels,
|
|
14423
|
-
return levels.slice(
|
|
14468
|
+
function hierarchyKey(levels, level3, index) {
|
|
14469
|
+
return levels.slice(level3).map((labels) => labels[index] ?? "").join("\0");
|
|
14424
14470
|
}
|
|
14425
14471
|
function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
14426
|
-
const levels = categoryLevels.filter((
|
|
14427
|
-
const leafCount = Math.max(values.length, ...levels.map((
|
|
14472
|
+
const levels = categoryLevels.filter((level3) => level3.length > 0);
|
|
14473
|
+
const leafCount = Math.max(values.length, ...levels.map((level3) => level3.length), 0);
|
|
14428
14474
|
if (levels.length === 0 || leafCount === 0) return [];
|
|
14429
14475
|
const rawWeights = Array.from({ length: leafCount }, (_, index) => Math.abs(values[index] ?? 0));
|
|
14430
14476
|
const weights = rawWeights.some((value) => value !== 0) ? rawWeights : rawWeights.map(() => 1);
|
|
@@ -14435,15 +14481,15 @@ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
|
14435
14481
|
const rootLabels = levels[levels.length - 1] ?? [];
|
|
14436
14482
|
const rootColors = /* @__PURE__ */ new Map();
|
|
14437
14483
|
const out = [];
|
|
14438
|
-
for (let
|
|
14439
|
-
const ringIndex = levels.length - 1 -
|
|
14484
|
+
for (let level3 = levels.length - 1; level3 >= 0; level3--) {
|
|
14485
|
+
const ringIndex = levels.length - 1 - level3;
|
|
14440
14486
|
const innerRadius = ringWidth * (ringIndex + 0.5);
|
|
14441
14487
|
const outerRadius = ringWidth * (ringIndex + 1.5);
|
|
14442
14488
|
let start = 0;
|
|
14443
14489
|
while (start < leafCount) {
|
|
14444
|
-
const key = hierarchyKey(levels,
|
|
14490
|
+
const key = hierarchyKey(levels, level3, start);
|
|
14445
14491
|
let end = start + 1;
|
|
14446
|
-
while (end < leafCount && hierarchyKey(levels,
|
|
14492
|
+
while (end < leafCount && hierarchyKey(levels, level3, end) === key) end++;
|
|
14447
14493
|
const startAngle = -Math.PI / 2 + (prefix2[start] ?? 0) / total * Math.PI * 2;
|
|
14448
14494
|
const endAngle = -Math.PI / 2 + (prefix2[end] ?? 0) / total * Math.PI * 2;
|
|
14449
14495
|
const rootLabel = rootLabels[start] ?? "";
|
|
@@ -14453,8 +14499,8 @@ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
|
|
|
14453
14499
|
colorIndex: rootColors.get(rootLabel) ?? start,
|
|
14454
14500
|
opacity: Math.max(0.1, 0.9 - ringIndex * 0.1),
|
|
14455
14501
|
level: ringIndex,
|
|
14456
|
-
label: levels[
|
|
14457
|
-
...
|
|
14502
|
+
label: levels[level3]?.[start] ?? "",
|
|
14503
|
+
...level3 === 0 && end === start + 1 ? { pointIndex: start } : {},
|
|
14458
14504
|
...arcLabelPlacement(cx, cy, (innerRadius + outerRadius) / 2, startAngle, endAngle)
|
|
14459
14505
|
});
|
|
14460
14506
|
start = end;
|
|
@@ -15188,15 +15234,15 @@ var KIND_OF_TYPE = {
|
|
|
15188
15234
|
var chartTrendlineKind = (type) => type !== void 0 && Object.hasOwn(KIND_OF_TYPE, type) ? KIND_OF_TYPE[type] : void 0;
|
|
15189
15235
|
|
|
15190
15236
|
// chart/data-cache.ts
|
|
15191
|
-
function chartCacheValues(
|
|
15192
|
-
if (!
|
|
15193
|
-
const numeric =
|
|
15237
|
+
function chartCacheValues(cache3) {
|
|
15238
|
+
if (!cache3) return [];
|
|
15239
|
+
const numeric = cache3.type === "number";
|
|
15194
15240
|
const out = [];
|
|
15195
|
-
for (const point of
|
|
15196
|
-
const
|
|
15197
|
-
out[point.index ?? out.length] = numeric &&
|
|
15241
|
+
for (const point of cache3.points) {
|
|
15242
|
+
const text3 = point.value;
|
|
15243
|
+
out[point.index ?? out.length] = numeric && text3.trim() !== "" && Number.isFinite(Number(text3)) ? Number(text3) : text3;
|
|
15198
15244
|
}
|
|
15199
|
-
const size = Math.max(
|
|
15245
|
+
const size = Math.max(cache3.pointCount ?? 0, out.length);
|
|
15200
15246
|
for (let index = 0; index < size; index++) if (out[index] === void 0) out[index] = "";
|
|
15201
15247
|
return out;
|
|
15202
15248
|
}
|
|
@@ -15428,7 +15474,7 @@ function summaryAnalysis(series) {
|
|
|
15428
15474
|
}
|
|
15429
15475
|
|
|
15430
15476
|
// chart/render/summary-labels.ts
|
|
15431
|
-
function level(options2,
|
|
15477
|
+
function level(options2, custom2) {
|
|
15432
15478
|
const out = {};
|
|
15433
15479
|
if (options2.layout) out.layout = options2.layout;
|
|
15434
15480
|
if (options2.showLeaderLines !== void 0) out.showLeaderLines = options2.showLeaderLines;
|
|
@@ -15442,7 +15488,7 @@ function level(options2, custom) {
|
|
|
15442
15488
|
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
15443
15489
|
if (options2.position) out.position = options2.position;
|
|
15444
15490
|
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
15445
|
-
if (
|
|
15491
|
+
if (custom2?.text !== void 0) out.text = custom2.text;
|
|
15446
15492
|
return out;
|
|
15447
15493
|
}
|
|
15448
15494
|
function shows(levels, point) {
|
|
@@ -15541,9 +15587,9 @@ function stockStyle(group2) {
|
|
|
15541
15587
|
};
|
|
15542
15588
|
}
|
|
15543
15589
|
function extraGroups(chartSpace, firstType) {
|
|
15544
|
-
const [
|
|
15545
|
-
if (!
|
|
15546
|
-
const primary = valueAxisId(chartSpace,
|
|
15590
|
+
const [first4, ...rest] = chartSpace.plotArea.groups;
|
|
15591
|
+
if (!first4 || !["column", "line", "area"].includes(firstType)) return [];
|
|
15592
|
+
const primary = valueAxisId(chartSpace, first4.axisIds);
|
|
15547
15593
|
const out = [];
|
|
15548
15594
|
for (const group2 of rest) {
|
|
15549
15595
|
const stockOverColumns = group2.kind === "stock" && firstType === "column";
|
|
@@ -15717,12 +15763,12 @@ var TEXT_PARTS = [
|
|
|
15717
15763
|
"legend",
|
|
15718
15764
|
"dataLabel"
|
|
15719
15765
|
];
|
|
15720
|
-
function inheritChartText(part, entry,
|
|
15766
|
+
function inheritChartText(part, entry, builtIn2, root) {
|
|
15721
15767
|
if (!root || !TEXT_PARTS.includes(part)) return entry;
|
|
15722
15768
|
const out = { ...entry };
|
|
15723
15769
|
for (const key of TEXT_KEYS) {
|
|
15724
15770
|
delete out[key];
|
|
15725
|
-
const value = root[key] ??
|
|
15771
|
+
const value = root[key] ?? builtIn2?.[key];
|
|
15726
15772
|
if (value !== void 0) Object.assign(out, { [key]: value });
|
|
15727
15773
|
}
|
|
15728
15774
|
if (part === "title" && root.fontSize !== void 0) out.fontSize = root.fontSize * 1.2;
|
|
@@ -16052,11 +16098,11 @@ var TEXT_COLOR = "#595959";
|
|
|
16052
16098
|
var GRID_COLOR = "#D9D9D9";
|
|
16053
16099
|
var AXIS_COLOR = "#BFBFBF";
|
|
16054
16100
|
var FONT_SIZE = 10;
|
|
16055
|
-
function esc(
|
|
16056
|
-
return
|
|
16101
|
+
function esc(text3) {
|
|
16102
|
+
return text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
16057
16103
|
}
|
|
16058
16104
|
var n = (value) => String(Math.round(value * 100) / 100);
|
|
16059
|
-
var textWidth = (
|
|
16105
|
+
var textWidth = (text3, size = FONT_SIZE) => text3.length * size * 0.55;
|
|
16060
16106
|
function text(x, y, content, attrs2 = {}) {
|
|
16061
16107
|
const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
|
|
16062
16108
|
parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
|
|
@@ -16558,8 +16604,8 @@ function excelSerialToDate(serial, date1904 = false) {
|
|
|
16558
16604
|
const epoch = date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, serial < 60 ? 31 : 30);
|
|
16559
16605
|
return new Date(epoch + serial * DAY_MS);
|
|
16560
16606
|
}
|
|
16561
|
-
function addUnit(
|
|
16562
|
-
const next = new Date(
|
|
16607
|
+
function addUnit(date2, amount, unit) {
|
|
16608
|
+
const next = new Date(date2);
|
|
16563
16609
|
if (unit === "days") {
|
|
16564
16610
|
next.setUTCDate(next.getUTCDate() + amount);
|
|
16565
16611
|
} else if (unit === "months") {
|
|
@@ -16571,10 +16617,10 @@ function addUnit(date, amount, unit) {
|
|
|
16571
16617
|
}
|
|
16572
16618
|
function calendarTicks(min, max, date1904, unit, step) {
|
|
16573
16619
|
const result = [];
|
|
16574
|
-
let
|
|
16575
|
-
for (let guard = 0; guard < 1e3 &&
|
|
16576
|
-
result.push(min + (
|
|
16577
|
-
|
|
16620
|
+
let date2 = excelSerialToDate(min, date1904);
|
|
16621
|
+
for (let guard = 0; guard < 1e3 && date2.getTime() <= excelSerialToDate(max, date1904).getTime(); guard++) {
|
|
16622
|
+
result.push(min + (date2.getTime() - excelSerialToDate(min, date1904).getTime()) / DAY_MS);
|
|
16623
|
+
date2 = addUnit(date2, step, unit);
|
|
16578
16624
|
}
|
|
16579
16625
|
return result;
|
|
16580
16626
|
}
|
|
@@ -16610,26 +16656,26 @@ var MONTH_FULL = [
|
|
|
16610
16656
|
];
|
|
16611
16657
|
var WEEKDAY_ABBR = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
16612
16658
|
var WEEKDAY_FULL = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
16613
|
-
function scanDateFormatTokens(
|
|
16659
|
+
function scanDateFormatTokens(code2) {
|
|
16614
16660
|
const tokens = [];
|
|
16615
16661
|
let i = 0;
|
|
16616
|
-
while (i <
|
|
16617
|
-
const ch =
|
|
16662
|
+
while (i < code2.length) {
|
|
16663
|
+
const ch = code2[i];
|
|
16618
16664
|
if (ch === '"') {
|
|
16619
|
-
const close =
|
|
16665
|
+
const close = code2.indexOf('"', i + 1);
|
|
16620
16666
|
tokens.push({
|
|
16621
16667
|
kind: "literal",
|
|
16622
|
-
text: close === -1 ?
|
|
16668
|
+
text: close === -1 ? code2.slice(i + 1) : code2.slice(i + 1, close)
|
|
16623
16669
|
});
|
|
16624
|
-
i = close === -1 ?
|
|
16670
|
+
i = close === -1 ? code2.length : close + 1;
|
|
16625
16671
|
continue;
|
|
16626
16672
|
}
|
|
16627
16673
|
if (ch === "\\") {
|
|
16628
|
-
tokens.push({ kind: "literal", text:
|
|
16674
|
+
tokens.push({ kind: "literal", text: code2[i + 1] ?? "" });
|
|
16629
16675
|
i += 2;
|
|
16630
16676
|
continue;
|
|
16631
16677
|
}
|
|
16632
|
-
const rest =
|
|
16678
|
+
const rest = code2.slice(i);
|
|
16633
16679
|
if (/^am\/pm/iu.test(rest)) {
|
|
16634
16680
|
tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: false });
|
|
16635
16681
|
i += 5;
|
|
@@ -16642,7 +16688,7 @@ function scanDateFormatTokens(code) {
|
|
|
16642
16688
|
}
|
|
16643
16689
|
if (/[ymdhs]/iu.test(ch)) {
|
|
16644
16690
|
let j = i + 1;
|
|
16645
|
-
while (j <
|
|
16691
|
+
while (j < code2.length && code2[j].toLowerCase() === ch.toLowerCase()) {
|
|
16646
16692
|
j += 1;
|
|
16647
16693
|
}
|
|
16648
16694
|
tokens.push({
|
|
@@ -16669,39 +16715,39 @@ function findNonLiteral(tokens, index, step) {
|
|
|
16669
16715
|
function pad(n2, width) {
|
|
16670
16716
|
return String(n2).padStart(width, "0");
|
|
16671
16717
|
}
|
|
16672
|
-
function renderDatePart(part, count,
|
|
16718
|
+
function renderDatePart(part, count, date2, twelveHour) {
|
|
16673
16719
|
switch (part) {
|
|
16674
16720
|
case "year":
|
|
16675
|
-
return count >= 4 ? pad(
|
|
16721
|
+
return count >= 4 ? pad(date2.getUTCFullYear(), 4) : pad(date2.getUTCFullYear() % 100, 2);
|
|
16676
16722
|
case "month":
|
|
16677
16723
|
if (count >= 4) {
|
|
16678
|
-
return MONTH_FULL[
|
|
16724
|
+
return MONTH_FULL[date2.getUTCMonth()] ?? "";
|
|
16679
16725
|
}
|
|
16680
16726
|
if (count === 3) {
|
|
16681
|
-
return MONTH_ABBR[
|
|
16727
|
+
return MONTH_ABBR[date2.getUTCMonth()] ?? "";
|
|
16682
16728
|
}
|
|
16683
|
-
return count >= 2 ? pad(
|
|
16729
|
+
return count >= 2 ? pad(date2.getUTCMonth() + 1, 2) : String(date2.getUTCMonth() + 1);
|
|
16684
16730
|
case "day":
|
|
16685
16731
|
if (count >= 4) {
|
|
16686
|
-
return WEEKDAY_FULL[
|
|
16732
|
+
return WEEKDAY_FULL[date2.getUTCDay()] ?? "";
|
|
16687
16733
|
}
|
|
16688
16734
|
if (count === 3) {
|
|
16689
|
-
return WEEKDAY_ABBR[
|
|
16735
|
+
return WEEKDAY_ABBR[date2.getUTCDay()] ?? "";
|
|
16690
16736
|
}
|
|
16691
|
-
return count >= 2 ? pad(
|
|
16737
|
+
return count >= 2 ? pad(date2.getUTCDate(), 2) : String(date2.getUTCDate());
|
|
16692
16738
|
case "hour": {
|
|
16693
|
-
const h24 =
|
|
16739
|
+
const h24 = date2.getUTCHours();
|
|
16694
16740
|
const h = twelveHour ? h24 % 12 === 0 ? 12 : h24 % 12 : h24;
|
|
16695
16741
|
return count >= 2 ? pad(h, 2) : String(h);
|
|
16696
16742
|
}
|
|
16697
16743
|
case "minute":
|
|
16698
|
-
return count >= 2 ? pad(
|
|
16744
|
+
return count >= 2 ? pad(date2.getUTCMinutes(), 2) : String(date2.getUTCMinutes());
|
|
16699
16745
|
case "second":
|
|
16700
|
-
return count >= 2 ? pad(
|
|
16746
|
+
return count >= 2 ? pad(date2.getUTCSeconds(), 2) : String(date2.getUTCSeconds());
|
|
16701
16747
|
}
|
|
16702
16748
|
}
|
|
16703
|
-
function renderExcelDateFormat(
|
|
16704
|
-
const tokens = scanDateFormatTokens(
|
|
16749
|
+
function renderExcelDateFormat(date2, code2) {
|
|
16750
|
+
const tokens = scanDateFormatTokens(code2);
|
|
16705
16751
|
const hasAmPm = tokens.some((t) => t.kind === "ampm");
|
|
16706
16752
|
let out = "";
|
|
16707
16753
|
for (const [index, token] of tokens.entries()) {
|
|
@@ -16710,28 +16756,28 @@ function renderExcelDateFormat(date, code) {
|
|
|
16710
16756
|
continue;
|
|
16711
16757
|
}
|
|
16712
16758
|
if (token.kind === "ampm") {
|
|
16713
|
-
const hour =
|
|
16714
|
-
out += token.upper ?
|
|
16759
|
+
const hour = date2.getUTCHours(), text3 = token.short ? hour < 12 ? "A" : "P" : hour < 12 ? "AM" : "PM";
|
|
16760
|
+
out += token.upper ? text3 : text3.toLowerCase();
|
|
16715
16761
|
continue;
|
|
16716
16762
|
}
|
|
16717
16763
|
if (token.letter === "m") {
|
|
16718
16764
|
const prev = findNonLiteral(tokens, index, -1), next = findNonLiteral(tokens, index, 1), isMinute = prev?.kind === "letters" && prev.letter === "h" || next?.kind === "letters" && next.letter === "s";
|
|
16719
|
-
out += renderDatePart(isMinute ? "minute" : "month", token.count,
|
|
16765
|
+
out += renderDatePart(isMinute ? "minute" : "month", token.count, date2, hasAmPm);
|
|
16720
16766
|
continue;
|
|
16721
16767
|
}
|
|
16722
16768
|
const part = { y: "year", d: "day", h: "hour", s: "second" };
|
|
16723
|
-
out += renderDatePart(part[token.letter], token.count,
|
|
16769
|
+
out += renderDatePart(part[token.letter], token.count, date2, hasAmPm);
|
|
16724
16770
|
}
|
|
16725
16771
|
return out;
|
|
16726
16772
|
}
|
|
16727
|
-
function formatDate(
|
|
16773
|
+
function formatDate(date2, unit, format) {
|
|
16728
16774
|
if (format && /[ymdhs]/iu.test(format)) {
|
|
16729
|
-
const rendered = renderExcelDateFormat(
|
|
16775
|
+
const rendered = renderExcelDateFormat(date2, format);
|
|
16730
16776
|
if (rendered.length > 0) {
|
|
16731
16777
|
return rendered;
|
|
16732
16778
|
}
|
|
16733
16779
|
}
|
|
16734
|
-
const month =
|
|
16780
|
+
const month = date2.toLocaleString("en-US", { month: "short", timeZone: "UTC" }), year = String(date2.getUTCFullYear()), day = String(date2.getUTCDate());
|
|
16735
16781
|
if (unit === "years") {
|
|
16736
16782
|
return year;
|
|
16737
16783
|
}
|
|
@@ -17035,10 +17081,10 @@ function generateIntervalTicks(range, unit) {
|
|
|
17035
17081
|
return [];
|
|
17036
17082
|
}
|
|
17037
17083
|
const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-12;
|
|
17038
|
-
const
|
|
17084
|
+
const first4 = Math.ceil((range.min - tolerance) / unit);
|
|
17039
17085
|
const last = Math.floor((range.max + tolerance) / unit);
|
|
17040
|
-
const count = Math.min(Math.max(last -
|
|
17041
|
-
return Array.from({ length: count }, (_, index) => (
|
|
17086
|
+
const count = Math.min(Math.max(last - first4 + 1, 0), 2e3);
|
|
17087
|
+
return Array.from({ length: count }, (_, index) => (first4 + index) * unit);
|
|
17042
17088
|
}
|
|
17043
17089
|
function generateAxisTicks(range, axis, defaultIntervals) {
|
|
17044
17090
|
if (range.logScale && range.logBase) {
|
|
@@ -17395,10 +17441,10 @@ function liveLevels(ref, evaluateRef) {
|
|
|
17395
17441
|
return levels;
|
|
17396
17442
|
}
|
|
17397
17443
|
function hierarchyView(chart, model, evaluateRef) {
|
|
17398
|
-
const
|
|
17444
|
+
const first4 = model.series[0];
|
|
17399
17445
|
const live = liveLevels(chart.series[0]?.categoriesRef, evaluateRef);
|
|
17400
17446
|
if (live?.[0]) model.categories = live[0];
|
|
17401
|
-
const count = Math.max(
|
|
17447
|
+
const count = Math.max(first4?.values.length ?? 0, model.categories.length);
|
|
17402
17448
|
const supplied = live ?? chart.hierarchy?.levels ?? [];
|
|
17403
17449
|
const levels = supplied.length > 1 ? normalizeLevels(supplied, count) : [];
|
|
17404
17450
|
model.hierarchy = {
|
|
@@ -17488,7 +17534,7 @@ function categoryTotals(model) {
|
|
|
17488
17534
|
}
|
|
17489
17535
|
|
|
17490
17536
|
// chart/render/chart-view-labels.ts
|
|
17491
|
-
function labelsOf(source, view, categories,
|
|
17537
|
+
function labelsOf(source, view, categories, numberFormat2, resolveColor) {
|
|
17492
17538
|
const { chart, series, points } = source;
|
|
17493
17539
|
if ((series?.deleted ?? chart?.deleted) === true) return void 0;
|
|
17494
17540
|
const percentBase = view.values.reduce(
|
|
@@ -17516,7 +17562,7 @@ function labelsOf(source, view, categories, numberFormat, resolveColor) {
|
|
|
17516
17562
|
seriesName: view.name,
|
|
17517
17563
|
category,
|
|
17518
17564
|
value,
|
|
17519
|
-
numberFormat: point?.numberFormat ?? series?.numberFormat ?? chart?.numberFormat ??
|
|
17565
|
+
numberFormat: point?.numberFormat ?? series?.numberFormat ?? chart?.numberFormat ?? numberFormat2,
|
|
17520
17566
|
percentBase,
|
|
17521
17567
|
bubbleSize: view.sizes?.[i] ?? void 0,
|
|
17522
17568
|
formatValue: (v) => formatAxisValue(v),
|
|
@@ -17628,16 +17674,16 @@ function waterfallView(chart, model, ctx) {
|
|
|
17628
17674
|
model.categories = steps.map((_, i) => labels[i] ?? String(i + 1));
|
|
17629
17675
|
}
|
|
17630
17676
|
function histogramView(chart, model) {
|
|
17631
|
-
const
|
|
17632
|
-
if (!
|
|
17633
|
-
const raw =
|
|
17677
|
+
const first4 = model.series[0];
|
|
17678
|
+
if (!first4) return;
|
|
17679
|
+
const raw = first4.values.map((v) => v ?? Number.NaN);
|
|
17634
17680
|
const options2 = chart.histogram ?? {};
|
|
17635
17681
|
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
17636
|
-
|
|
17682
|
+
first4.values.map((v) => v ?? 0),
|
|
17637
17683
|
model.categories
|
|
17638
17684
|
) : computeHistogramBins(raw, options2, formatAxisValue);
|
|
17639
17685
|
model.categories = bins.map((bin) => bin.label);
|
|
17640
|
-
|
|
17686
|
+
first4.values = bins.map((bin) => bin.value);
|
|
17641
17687
|
model.barGapWidth = 0;
|
|
17642
17688
|
model.barOverlap = 0;
|
|
17643
17689
|
}
|
|
@@ -18545,11 +18591,11 @@ function valueAtSource(values, indices, sourceIndex) {
|
|
|
18545
18591
|
const position = indices.indexOf(sourceIndex);
|
|
18546
18592
|
return position >= 0 ? values[position] : void 0;
|
|
18547
18593
|
}
|
|
18548
|
-
function cachedEntityName(
|
|
18549
|
-
if (!
|
|
18594
|
+
function cachedEntityName(cache3, entityId) {
|
|
18595
|
+
if (!cache3 || typeof cache3 !== "object") {
|
|
18550
18596
|
return void 0;
|
|
18551
18597
|
}
|
|
18552
|
-
const record =
|
|
18598
|
+
const record = cache3;
|
|
18553
18599
|
if (String(record["@_entityId"] ?? "") === entityId && record["@_entityName"] !== void 0) {
|
|
18554
18600
|
return String(record["@_entityName"]);
|
|
18555
18601
|
}
|
|
@@ -18601,13 +18647,13 @@ function buildRegionMapEntries(categories, values, options2, resolveCode) {
|
|
|
18601
18647
|
const value = valueAtSource(values, valueIndices, sourceIndex);
|
|
18602
18648
|
if (value === null || value === void 0 || !Number.isFinite(value)) return [];
|
|
18603
18649
|
const entityId = valueAtSource(entityIds, entityIndices, sourceIndex);
|
|
18604
|
-
const
|
|
18650
|
+
const code2 = resolveRegionEntityCode(entityId, options2, resolveCode) ?? resolveCode(category);
|
|
18605
18651
|
return {
|
|
18606
18652
|
sourceIndex,
|
|
18607
18653
|
label: category || entityId || `Region ${sourceIndex + 1}`,
|
|
18608
18654
|
value,
|
|
18609
18655
|
...entityId ? { entityId } : {},
|
|
18610
|
-
...
|
|
18656
|
+
...code2 ? { code: code2 } : {}
|
|
18611
18657
|
};
|
|
18612
18658
|
});
|
|
18613
18659
|
}
|
|
@@ -18661,12 +18707,12 @@ function resolveValueColorStops(valueColors, valueColorPositions, minVal, maxVal
|
|
|
18661
18707
|
function buildValueColorScale(stops) {
|
|
18662
18708
|
const sorted = [...stops].sort((a, b) => a.position - b.position);
|
|
18663
18709
|
return (t) => {
|
|
18664
|
-
const clamped = Math.max(0, Math.min(1, t)),
|
|
18665
|
-
if (!
|
|
18710
|
+
const clamped = Math.max(0, Math.min(1, t)), first4 = sorted[0];
|
|
18711
|
+
if (!first4) {
|
|
18666
18712
|
return "#94a3b8";
|
|
18667
18713
|
}
|
|
18668
18714
|
if (sorted.length === 1) {
|
|
18669
|
-
return
|
|
18715
|
+
return first4.color;
|
|
18670
18716
|
}
|
|
18671
18717
|
for (let i = 0; i < sorted.length - 1; i++) {
|
|
18672
18718
|
const a = sorted[i], b = sorted[i + 1];
|
|
@@ -18678,8 +18724,8 @@ function buildValueColorScale(stops) {
|
|
|
18678
18724
|
);
|
|
18679
18725
|
}
|
|
18680
18726
|
}
|
|
18681
|
-
const last = sorted[sorted.length - 1] ??
|
|
18682
|
-
return clamped <=
|
|
18727
|
+
const last = sorted[sorted.length - 1] ?? first4;
|
|
18728
|
+
return clamped <= first4.position ? first4.color : last.color;
|
|
18683
18729
|
};
|
|
18684
18730
|
}
|
|
18685
18731
|
|
|
@@ -19072,11 +19118,11 @@ function projectGeoPoint(point, projection = "mercator") {
|
|
|
19072
19118
|
|
|
19073
19119
|
// chart/region-map/geometry.ts
|
|
19074
19120
|
function regionMapGeometry(options2) {
|
|
19075
|
-
const
|
|
19076
|
-
if (!
|
|
19077
|
-
return { regions: WORLD_REGIONS, approximate: true, issues:
|
|
19121
|
+
const cache3 = readGeographyCache(options2?.geographyCacheXml);
|
|
19122
|
+
if (!cache3.regions.length)
|
|
19123
|
+
return { regions: WORLD_REGIONS, approximate: true, issues: cache3.issues, copyright: [] };
|
|
19078
19124
|
const projection = options2?.projectionType ?? "robinson";
|
|
19079
|
-
const projected =
|
|
19125
|
+
const projected = cache3.regions.map((region) => ({
|
|
19080
19126
|
region,
|
|
19081
19127
|
rings: region.rings.map((ring) => ring.map((p2) => projectGeoPoint(p2, projection)))
|
|
19082
19128
|
}));
|
|
@@ -19084,7 +19130,7 @@ function regionMapGeometry(options2) {
|
|
|
19084
19130
|
return {
|
|
19085
19131
|
regions: [],
|
|
19086
19132
|
approximate: false,
|
|
19087
|
-
issues: [...
|
|
19133
|
+
issues: [...cache3.issues, "Unsupported geographic projection."],
|
|
19088
19134
|
copyright: []
|
|
19089
19135
|
};
|
|
19090
19136
|
const all = projected.flatMap((r) => r.rings.flatMap((ring) => ring));
|
|
@@ -19123,8 +19169,8 @@ function regionMapGeometry(options2) {
|
|
|
19123
19169
|
return {
|
|
19124
19170
|
regions,
|
|
19125
19171
|
approximate: false,
|
|
19126
|
-
issues:
|
|
19127
|
-
copyright: [...new Set(
|
|
19172
|
+
issues: cache3.issues,
|
|
19173
|
+
copyright: [...new Set(cache3.regions.flatMap((r) => r.copyright))]
|
|
19128
19174
|
};
|
|
19129
19175
|
}
|
|
19130
19176
|
|
|
@@ -19712,15 +19758,15 @@ function sliceLabels(model, marks, out) {
|
|
|
19712
19758
|
outside: Math.hypot(x - mark.cx, y - mark.cy) > mark.outer
|
|
19713
19759
|
});
|
|
19714
19760
|
}
|
|
19715
|
-
const
|
|
19716
|
-
if (!
|
|
19761
|
+
const first4 = marks[0];
|
|
19762
|
+
if (!first4) return;
|
|
19717
19763
|
const nudges = nudgeOutsideLabels(
|
|
19718
19764
|
items.flatMap(
|
|
19719
19765
|
(item, id) => item.outside && !item.label.layout ? [{ id, x: item.x, y: item.y, w: item.m.w, h: item.m.h }] : []
|
|
19720
19766
|
),
|
|
19721
|
-
{ cx:
|
|
19722
|
-
|
|
19723
|
-
|
|
19767
|
+
{ cx: first4.cx, cy: first4.cy, r: first4.outer },
|
|
19768
|
+
first4.cy - first4.outer,
|
|
19769
|
+
first4.cy + first4.outer
|
|
19724
19770
|
);
|
|
19725
19771
|
for (const [id, item] of items.entries()) {
|
|
19726
19772
|
const { mark, label, m } = item;
|
|
@@ -19868,9 +19914,9 @@ function radarSvg(model, area) {
|
|
|
19868
19914
|
|
|
19869
19915
|
// chart/render/chart-svg-hierarchy.ts
|
|
19870
19916
|
var colorAt = (model, index) => {
|
|
19871
|
-
const
|
|
19872
|
-
const colors =
|
|
19873
|
-
return (colors && colors.length > 0 ? colors[index % colors.length] : void 0) ??
|
|
19917
|
+
const first4 = model.series[0];
|
|
19918
|
+
const colors = first4?.pointColors;
|
|
19919
|
+
return (colors && colors.length > 0 ? colors[index % colors.length] : void 0) ?? first4?.color ?? "#4472C4";
|
|
19874
19920
|
};
|
|
19875
19921
|
var leafValues = (model) => (model.series[0]?.values ?? []).map((v) => v ?? 0);
|
|
19876
19922
|
function treemapSvg(model, area) {
|
|
@@ -20030,17 +20076,17 @@ function chartLegendSvg(model, area, frame2, options2) {
|
|
|
20030
20076
|
}
|
|
20031
20077
|
function legendEntries(model) {
|
|
20032
20078
|
if (model.type === "pie" || model.type === "doughnut") {
|
|
20033
|
-
const
|
|
20079
|
+
const first4 = model.series[0];
|
|
20034
20080
|
return model.categories.map((label, i) => ({
|
|
20035
20081
|
label,
|
|
20036
|
-
color:
|
|
20082
|
+
color: first4?.pointColors?.[i] ?? first4?.color ?? "#4472C4"
|
|
20037
20083
|
}));
|
|
20038
20084
|
}
|
|
20039
20085
|
if ((model.type === "treemap" || model.type === "sunburst") && model.hierarchy) {
|
|
20040
|
-
const
|
|
20086
|
+
const first4 = model.series[0];
|
|
20041
20087
|
return model.hierarchy.branches.map((label, i) => ({
|
|
20042
20088
|
label,
|
|
20043
|
-
color:
|
|
20089
|
+
color: first4?.pointColors?.[i % Math.max(1, first4.pointColors.length)] ?? first4?.color ?? "#4472C4"
|
|
20044
20090
|
}));
|
|
20045
20091
|
}
|
|
20046
20092
|
if (model.type === "waterfall" && model.waterfall)
|
|
@@ -20677,7 +20723,7 @@ function parseDirectParagraphProperties(props) {
|
|
|
20677
20723
|
if (style) paragraph.style = style;
|
|
20678
20724
|
const pageBreakBefore = onOffElement(first2(props, "pageBreakBefore"));
|
|
20679
20725
|
if (pageBreakBefore !== void 0) paragraph.pageBreakBefore = pageBreakBefore;
|
|
20680
|
-
for (const key of PAGINATION_KEYS) {
|
|
20726
|
+
for (const key of [...PAGINATION_KEYS, ...EAST_ASIAN_TYPOGRAPHY_KEYS]) {
|
|
20681
20727
|
const value = onOffElement(first2(props, key));
|
|
20682
20728
|
if (value !== void 0) paragraph[key] = value;
|
|
20683
20729
|
}
|
|
@@ -20746,11 +20792,11 @@ function pictureBulletSizePt(picture, fontSizePt) {
|
|
|
20746
20792
|
|
|
20747
20793
|
// docx/numbering-parse.ts
|
|
20748
20794
|
var own = (map, key) => Object.prototype.hasOwnProperty.call(map, key) ? map[key] : void 0;
|
|
20749
|
-
function resolveNumberingLevel(catalog, numId,
|
|
20795
|
+
function resolveNumberingLevel(catalog, numId, level3) {
|
|
20750
20796
|
const num = own(catalog.nums, numId);
|
|
20751
20797
|
if (!num) return void 0;
|
|
20752
|
-
const override = num.levelOverrides?.[
|
|
20753
|
-
const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[
|
|
20798
|
+
const override = num.levelOverrides?.[level3];
|
|
20799
|
+
const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[level3];
|
|
20754
20800
|
const abstract = sourceAbstract?.startWasOmitted && sourceAbstract.start === 1 ? { ...sourceAbstract, start: 0 } : sourceAbstract;
|
|
20755
20801
|
let base = override?.lvl ?? abstract;
|
|
20756
20802
|
if (!base) return void 0;
|
|
@@ -20770,6 +20816,183 @@ function resolveNumberingLevel(catalog, numId, level2) {
|
|
|
20770
20816
|
return start !== base.start ? { ...base, start } : base;
|
|
20771
20817
|
}
|
|
20772
20818
|
|
|
20819
|
+
// docx/field-result-spans.ts
|
|
20820
|
+
var removed = (run) => run.revision?.kind === "delete" || run.revision?.kind === "moveFrom";
|
|
20821
|
+
function fieldResultSpans(runs, options2 = {}) {
|
|
20822
|
+
const found = [];
|
|
20823
|
+
const open = [];
|
|
20824
|
+
runs.forEach((run, index) => {
|
|
20825
|
+
const top = open.at(-1);
|
|
20826
|
+
if (run.fieldChar === "begin")
|
|
20827
|
+
open.push({ begin: index, code: "", locked: isFieldLocked(run) });
|
|
20828
|
+
else if (run.fieldCode !== void 0 && top && top.separate === void 0) {
|
|
20829
|
+
top.code += run.fieldCode;
|
|
20830
|
+
top.codeRun ??= index;
|
|
20831
|
+
if (top.nameRun === void 0 && /\S/.test(run.fieldCode)) top.nameRun = index;
|
|
20832
|
+
} else if (run.fieldChar === "separate" && top) top.separate = index;
|
|
20833
|
+
else if (run.fieldChar === "end" && top) {
|
|
20834
|
+
open.pop();
|
|
20835
|
+
const instr = top.code.trim();
|
|
20836
|
+
const names = {
|
|
20837
|
+
...top.codeRun !== void 0 ? { code: top.codeRun } : {},
|
|
20838
|
+
...top.nameRun !== void 0 ? { name: top.nameRun } : {}
|
|
20839
|
+
};
|
|
20840
|
+
if (top.separate === void 0) {
|
|
20841
|
+
if (options2.resultless)
|
|
20842
|
+
found.push({
|
|
20843
|
+
from: top.begin,
|
|
20844
|
+
to: index,
|
|
20845
|
+
instr,
|
|
20846
|
+
locked: top.locked,
|
|
20847
|
+
runs: [],
|
|
20848
|
+
...names,
|
|
20849
|
+
insertAt: index,
|
|
20850
|
+
resultless: true
|
|
20851
|
+
});
|
|
20852
|
+
return;
|
|
20853
|
+
}
|
|
20854
|
+
const results = [];
|
|
20855
|
+
let gone = false;
|
|
20856
|
+
for (let at = top.separate + 1; at < index; at++) {
|
|
20857
|
+
const item = runs[at];
|
|
20858
|
+
if (item.field?.instr !== instr || item.fieldChar || item.fieldCode !== void 0) continue;
|
|
20859
|
+
if (removed(item)) gone = true;
|
|
20860
|
+
else results.push(at);
|
|
20861
|
+
}
|
|
20862
|
+
found.push({
|
|
20863
|
+
from: top.begin,
|
|
20864
|
+
to: index,
|
|
20865
|
+
instr,
|
|
20866
|
+
locked: top.locked || results.some((at) => isFieldLocked(runs[at])),
|
|
20867
|
+
runs: results,
|
|
20868
|
+
...names,
|
|
20869
|
+
insertAt: top.separate + 1,
|
|
20870
|
+
...gone && !results.length ? { removed: true } : {}
|
|
20871
|
+
});
|
|
20872
|
+
}
|
|
20873
|
+
});
|
|
20874
|
+
let simple;
|
|
20875
|
+
let identity;
|
|
20876
|
+
runs.forEach((run, index) => {
|
|
20877
|
+
if (!run.field?.simple) {
|
|
20878
|
+
simple = void 0;
|
|
20879
|
+
return;
|
|
20880
|
+
}
|
|
20881
|
+
if (simple && simple.instr === run.field.instr && identity === run.fieldInstanceId) {
|
|
20882
|
+
if (!removed(run)) simple.runs.push(index);
|
|
20883
|
+
simple.to = index;
|
|
20884
|
+
} else {
|
|
20885
|
+
simple = {
|
|
20886
|
+
from: index,
|
|
20887
|
+
to: index,
|
|
20888
|
+
instr: run.field.instr,
|
|
20889
|
+
locked: false,
|
|
20890
|
+
runs: removed(run) ? [] : [index],
|
|
20891
|
+
insertAt: index
|
|
20892
|
+
};
|
|
20893
|
+
identity = run.fieldInstanceId;
|
|
20894
|
+
found.push(simple);
|
|
20895
|
+
}
|
|
20896
|
+
simple.locked ||= isFieldLocked(run);
|
|
20897
|
+
});
|
|
20898
|
+
return found;
|
|
20899
|
+
}
|
|
20900
|
+
var STRUCTURE = [
|
|
20901
|
+
"fieldChar",
|
|
20902
|
+
"fieldCode",
|
|
20903
|
+
"fieldInstanceId",
|
|
20904
|
+
"fieldFlags",
|
|
20905
|
+
"break",
|
|
20906
|
+
"noteReference",
|
|
20907
|
+
"noteMark",
|
|
20908
|
+
"noteSeparator",
|
|
20909
|
+
"equation",
|
|
20910
|
+
"image"
|
|
20911
|
+
];
|
|
20912
|
+
var NOT_FORMATTING = [
|
|
20913
|
+
...STRUCTURE,
|
|
20914
|
+
"text",
|
|
20915
|
+
"field",
|
|
20916
|
+
"revision",
|
|
20917
|
+
"formatRevision",
|
|
20918
|
+
"restoredRunPropertiesXml",
|
|
20919
|
+
"commentIds",
|
|
20920
|
+
"link",
|
|
20921
|
+
"contentControl"
|
|
20922
|
+
];
|
|
20923
|
+
function withFieldCodeFormatting(result, code2, text3) {
|
|
20924
|
+
const formatted = { ...code2 };
|
|
20925
|
+
const own2 = {};
|
|
20926
|
+
for (const key of NOT_FORMATTING) {
|
|
20927
|
+
delete formatted[key];
|
|
20928
|
+
if (result[key] !== void 0) Object.assign(own2, { [key]: result[key] });
|
|
20929
|
+
}
|
|
20930
|
+
return { ...formatted, ...own2, text: text3 };
|
|
20931
|
+
}
|
|
20932
|
+
function sameRun(a, b) {
|
|
20933
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
20934
|
+
return [...keys].every((key) => JSON.stringify(a[key]) === JSON.stringify(b[key]));
|
|
20935
|
+
}
|
|
20936
|
+
function fieldResultRun(code2, instr, text3) {
|
|
20937
|
+
const formatted = { ...code2 };
|
|
20938
|
+
for (const key of STRUCTURE) delete formatted[key];
|
|
20939
|
+
return { ...formatted, text: text3, field: { instr } };
|
|
20940
|
+
}
|
|
20941
|
+
function replaceFieldResult(runs, field, text3, charFormat) {
|
|
20942
|
+
if (field.resultless) return void 0;
|
|
20943
|
+
const current = field.runs.map((at) => runs[at].text).join("") === text3;
|
|
20944
|
+
const next = [...runs];
|
|
20945
|
+
const [first4, ...rest] = field.runs;
|
|
20946
|
+
const name2 = field.name ?? field.code;
|
|
20947
|
+
if (first4 !== void 0) {
|
|
20948
|
+
const formatted = charFormat && name2 !== void 0 ? withFieldCodeFormatting(runs[first4], runs[name2], text3) : void 0;
|
|
20949
|
+
if (current && (!formatted || sameRun(formatted, runs[first4]) && rest.every((at) => !runs[at].text)))
|
|
20950
|
+
return void 0;
|
|
20951
|
+
next[first4] = formatted ?? { ...runs[first4], text: text3 };
|
|
20952
|
+
for (const at of rest) next[at] = { ...runs[at], text: "" };
|
|
20953
|
+
return next;
|
|
20954
|
+
}
|
|
20955
|
+
const code2 = charFormat ? name2 : field.code;
|
|
20956
|
+
if (current || code2 === void 0 || field.removed) return void 0;
|
|
20957
|
+
next.splice(field.insertAt, 0, fieldResultRun(runs[code2], field.instr, text3));
|
|
20958
|
+
return next;
|
|
20959
|
+
}
|
|
20960
|
+
function paragraphWithResults(paragraph, evaluate) {
|
|
20961
|
+
let runs = paragraph.runs;
|
|
20962
|
+
const start = (field) => field.runs[0] ?? field.insertAt;
|
|
20963
|
+
for (const field of fieldResultSpans(runs).sort((a, b) => start(b) - start(a))) {
|
|
20964
|
+
const update = field.locked ? void 0 : evaluate(field, paragraph);
|
|
20965
|
+
if (update)
|
|
20966
|
+
runs = replaceFieldResult(runs, field, update.text, update.charFormat === true) ?? runs;
|
|
20967
|
+
}
|
|
20968
|
+
return runs === paragraph.runs ? paragraph : { ...paragraph, runs: [...runs] };
|
|
20969
|
+
}
|
|
20970
|
+
function tableWithResults(table, evaluate) {
|
|
20971
|
+
let changed = false;
|
|
20972
|
+
const rows2 = table.rows.map(
|
|
20973
|
+
(row2) => row2.map((cell) => {
|
|
20974
|
+
const paragraphs = cell.paragraphs.map((item) => paragraphWithResults(item, evaluate));
|
|
20975
|
+
const sourceBlocks = cell.sourceBlocks?.map(
|
|
20976
|
+
(item) => item.type === "table" ? tableWithResults(item, evaluate) : item
|
|
20977
|
+
);
|
|
20978
|
+
if (paragraphs.every((item, index) => item === cell.paragraphs[index]) && (sourceBlocks ?? []).every((item, index) => item === cell.sourceBlocks[index]))
|
|
20979
|
+
return cell;
|
|
20980
|
+
changed = true;
|
|
20981
|
+
return { ...cell, paragraphs, ...sourceBlocks ? { sourceBlocks } : {} };
|
|
20982
|
+
})
|
|
20983
|
+
);
|
|
20984
|
+
return changed ? { ...table, rows: rows2 } : table;
|
|
20985
|
+
}
|
|
20986
|
+
function withFieldResults(blocks, evaluate) {
|
|
20987
|
+
let changed = false;
|
|
20988
|
+
const next = blocks.map((block) => {
|
|
20989
|
+
const updated = block.type === "paragraph" ? paragraphWithResults(block, evaluate) : tableWithResults(block, evaluate);
|
|
20990
|
+
changed ||= updated !== block;
|
|
20991
|
+
return updated;
|
|
20992
|
+
});
|
|
20993
|
+
return changed ? next : blocks;
|
|
20994
|
+
}
|
|
20995
|
+
|
|
20773
20996
|
// docx/field-instruction.ts
|
|
20774
20997
|
function fieldTokens(instr) {
|
|
20775
20998
|
const tokens = [];
|
|
@@ -20805,19 +21028,19 @@ function fieldTokens(instr) {
|
|
|
20805
21028
|
}
|
|
20806
21029
|
var TEXT_CASES = /* @__PURE__ */ new Set(["upper", "lower", "firstcap", "caps"]);
|
|
20807
21030
|
var isFieldTextCase = (format) => TEXT_CASES.has(format.toLowerCase());
|
|
20808
|
-
function applyFieldTextCase(
|
|
20809
|
-
if (format === "upper") return
|
|
20810
|
-
if (format === "lower") return
|
|
21031
|
+
function applyFieldTextCase(text3, format) {
|
|
21032
|
+
if (format === "upper") return text3.toUpperCase();
|
|
21033
|
+
if (format === "lower") return text3.toLowerCase();
|
|
20811
21034
|
const capitalize = (word) => word.replace(
|
|
20812
21035
|
/^(\P{L}*)(\p{L})/u,
|
|
20813
21036
|
(_match, lead, letter) => `${lead}${letter.toUpperCase()}`
|
|
20814
21037
|
);
|
|
20815
21038
|
if (format === "firstcap")
|
|
20816
|
-
return
|
|
21039
|
+
return text3.replace(
|
|
20817
21040
|
/^(\s*)(\S+)/,
|
|
20818
21041
|
(_match, space, word) => `${space}${capitalize(word)}`
|
|
20819
21042
|
);
|
|
20820
|
-
return
|
|
21043
|
+
return text3.replace(/\S+/g, capitalize);
|
|
20821
21044
|
}
|
|
20822
21045
|
|
|
20823
21046
|
// docx/cell-blocks.ts
|
|
@@ -20857,73 +21080,449 @@ function documentParagraphs(blocks) {
|
|
|
20857
21080
|
return result;
|
|
20858
21081
|
}
|
|
20859
21082
|
|
|
20860
|
-
// docx/numbering-
|
|
20861
|
-
|
|
20862
|
-
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
|
|
20868
|
-
|
|
20869
|
-
"XC",
|
|
20870
|
-
"L",
|
|
20871
|
-
"XL",
|
|
20872
|
-
"X",
|
|
20873
|
-
"IX",
|
|
20874
|
-
"V",
|
|
20875
|
-
"IV",
|
|
20876
|
-
"I"
|
|
20877
|
-
];
|
|
20878
|
-
let remaining = Math.max(1, Math.min(Math.trunc(n2), 3999));
|
|
20879
|
-
let result = "";
|
|
20880
|
-
for (const [i, value] of values.entries()) {
|
|
20881
|
-
while (remaining >= value) {
|
|
20882
|
-
result += numerals[i] ?? "";
|
|
20883
|
-
remaining -= value;
|
|
21083
|
+
// docx/numbering-counters.ts
|
|
21084
|
+
var NumberingCounters = class {
|
|
21085
|
+
counts = /* @__PURE__ */ new Map();
|
|
21086
|
+
started = /* @__PURE__ */ new Map();
|
|
21087
|
+
forNum(numId) {
|
|
21088
|
+
let counts2 = this.counts.get(numId);
|
|
21089
|
+
if (!counts2) {
|
|
21090
|
+
counts2 = /* @__PURE__ */ new Map();
|
|
21091
|
+
this.counts.set(numId, counts2);
|
|
20884
21092
|
}
|
|
21093
|
+
return counts2;
|
|
20885
21094
|
}
|
|
20886
|
-
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20890
|
-
|
|
20891
|
-
|
|
20892
|
-
|
|
20893
|
-
|
|
20894
|
-
|
|
20895
|
-
|
|
20896
|
-
|
|
20897
|
-
|
|
20898
|
-
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
|
|
21095
|
+
startedLevels(numId) {
|
|
21096
|
+
let started = this.started.get(numId);
|
|
21097
|
+
if (!started) {
|
|
21098
|
+
started = /* @__PURE__ */ new Set();
|
|
21099
|
+
this.started.set(numId, started);
|
|
21100
|
+
}
|
|
21101
|
+
return started;
|
|
21102
|
+
}
|
|
21103
|
+
/** Advances one level and resets deeper counters according to their resolved restart rules. */
|
|
21104
|
+
advance(numId, level3, def, catalog) {
|
|
21105
|
+
const counts2 = this.forNum(numId);
|
|
21106
|
+
const started = this.startedLevels(numId);
|
|
21107
|
+
const next = started.has(level3) ? (counts2.get(level3) ?? def.start) + 1 : def.start;
|
|
21108
|
+
counts2.set(level3, next);
|
|
21109
|
+
started.add(level3);
|
|
21110
|
+
for (const deeper of [...started]) {
|
|
21111
|
+
if (deeper <= level3) continue;
|
|
21112
|
+
const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
|
|
21113
|
+
const restart = deeperDef?.lvlRestart;
|
|
21114
|
+
if (restart === 0) continue;
|
|
21115
|
+
const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
|
|
21116
|
+
if (level3 > trigger) continue;
|
|
21117
|
+
counts2.delete(deeper);
|
|
21118
|
+
started.delete(deeper);
|
|
21119
|
+
}
|
|
21120
|
+
for (let ancestor = 0; ancestor < level3; ancestor++) {
|
|
21121
|
+
if (started.has(ancestor)) continue;
|
|
21122
|
+
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
|
|
21123
|
+
if (!ancestorDef) continue;
|
|
21124
|
+
counts2.set(ancestor, ancestorDef.start);
|
|
21125
|
+
started.add(ancestor);
|
|
21126
|
+
}
|
|
21127
|
+
return next;
|
|
21128
|
+
}
|
|
21129
|
+
/** Sets a level's value, as a LISTNUM `\s` start does, restarting the deeper levels. */
|
|
21130
|
+
set(numId, level3, value) {
|
|
21131
|
+
const counts2 = this.forNum(numId);
|
|
21132
|
+
const started = this.startedLevels(numId);
|
|
21133
|
+
counts2.set(level3, value);
|
|
21134
|
+
started.add(level3);
|
|
21135
|
+
for (const deeper of [...started])
|
|
21136
|
+
if (deeper > level3) {
|
|
21137
|
+
counts2.delete(deeper);
|
|
21138
|
+
started.delete(deeper);
|
|
21139
|
+
}
|
|
21140
|
+
}
|
|
21141
|
+
/** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
|
|
21142
|
+
current(numId, level3, start) {
|
|
21143
|
+
return this.forNum(numId).get(level3) ?? start;
|
|
20908
21144
|
}
|
|
20909
21145
|
};
|
|
20910
|
-
function
|
|
20911
|
-
return
|
|
21146
|
+
function substituteLvlText(lvlText, numId, level3, catalog, counters, forceDecimal) {
|
|
21147
|
+
return lvlText.replace(/%([1-9])/g, (match, digit) => {
|
|
21148
|
+
const ancestorLevel = Number(digit) - 1;
|
|
21149
|
+
if (ancestorLevel > level3) return match;
|
|
21150
|
+
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
|
|
21151
|
+
const start = ancestorDef?.start ?? 1;
|
|
21152
|
+
const value = counters.current(numId, ancestorLevel, start);
|
|
21153
|
+
const fmt = forceDecimal ? "decimal" : ancestorDef?.numFmt ?? "decimal";
|
|
21154
|
+
return formatListNumber(fmt, value);
|
|
21155
|
+
});
|
|
20912
21156
|
}
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
|
|
20916
|
-
"
|
|
20917
|
-
"
|
|
20918
|
-
"
|
|
20919
|
-
"
|
|
20920
|
-
"
|
|
20921
|
-
"
|
|
20922
|
-
"
|
|
20923
|
-
"
|
|
20924
|
-
"
|
|
20925
|
-
|
|
20926
|
-
|
|
21157
|
+
|
|
21158
|
+
// docx/outline-numbering.ts
|
|
21159
|
+
var OUTLINE_NUMBERING = [
|
|
21160
|
+
["", "upperRoman", "."],
|
|
21161
|
+
["", "upperLetter", "."],
|
|
21162
|
+
["", "decimal", "."],
|
|
21163
|
+
["", "lowerLetter", ")"],
|
|
21164
|
+
["(", "decimal", ")"],
|
|
21165
|
+
["(", "lowerLetter", ")"],
|
|
21166
|
+
["(", "lowerRoman", ")"],
|
|
21167
|
+
["(", "lowerLetter", ")"],
|
|
21168
|
+
["(", "lowerRoman", ")"]
|
|
21169
|
+
];
|
|
21170
|
+
|
|
21171
|
+
// docx/field-runs.ts
|
|
21172
|
+
function fieldName(instr) {
|
|
21173
|
+
return instr.trim().split(/\s+/)[0]?.toUpperCase() ?? "";
|
|
21174
|
+
}
|
|
21175
|
+
|
|
21176
|
+
// text/date-picture.ts
|
|
21177
|
+
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|EEEE|EEE|HH|H|hh|h|mm|m|ss|s|tt|am\/pm|AM\/PM|A\/P|a\/p|'[^']*'|"[^"]*"/g;
|
|
21178
|
+
var pad2 = (value, length = 2) => String(value).padStart(length, "0");
|
|
21179
|
+
function name(date2, locale, utc, options2) {
|
|
21180
|
+
try {
|
|
21181
|
+
return new Intl.DateTimeFormat(locale, utc ? { ...options2, timeZone: "UTC" } : options2).format(
|
|
21182
|
+
date2
|
|
21183
|
+
);
|
|
21184
|
+
} catch {
|
|
21185
|
+
return new Intl.DateTimeFormat("en-US", utc ? { ...options2, timeZone: "UTC" } : options2).format(
|
|
21186
|
+
date2
|
|
21187
|
+
);
|
|
21188
|
+
}
|
|
21189
|
+
}
|
|
21190
|
+
function formatDatePicture(date2, picture, options2 = {}) {
|
|
21191
|
+
const locale = options2.locale ?? "en-US";
|
|
21192
|
+
const utc = options2.utc ?? false;
|
|
21193
|
+
const year = utc ? date2.getUTCFullYear() : date2.getFullYear();
|
|
21194
|
+
const month = utc ? date2.getUTCMonth() : date2.getMonth();
|
|
21195
|
+
const day = utc ? date2.getUTCDate() : date2.getDate();
|
|
21196
|
+
const hours = utc ? date2.getUTCHours() : date2.getHours();
|
|
21197
|
+
const minutes = utc ? date2.getUTCMinutes() : date2.getMinutes();
|
|
21198
|
+
const seconds = utc ? date2.getUTCSeconds() : date2.getSeconds();
|
|
21199
|
+
const hours12 = hours % 12 || 12;
|
|
21200
|
+
const label = (options3) => name(date2, locale, utc, options3);
|
|
21201
|
+
return picture.replace(TOKENS, (token) => {
|
|
21202
|
+
switch (token) {
|
|
21203
|
+
case "yyyy":
|
|
21204
|
+
return pad2(year, 4);
|
|
21205
|
+
case "yy":
|
|
21206
|
+
return pad2(year % 100);
|
|
21207
|
+
case "MMMM":
|
|
21208
|
+
return label({ month: "long" });
|
|
21209
|
+
case "MMM":
|
|
21210
|
+
return label({ month: "short" });
|
|
21211
|
+
case "MM":
|
|
21212
|
+
return pad2(month + 1);
|
|
21213
|
+
case "M":
|
|
21214
|
+
return String(month + 1);
|
|
21215
|
+
case "dddd":
|
|
21216
|
+
case "EEEE":
|
|
21217
|
+
return label({ weekday: "long" });
|
|
21218
|
+
case "ddd":
|
|
21219
|
+
case "EEE":
|
|
21220
|
+
return label({ weekday: "short" });
|
|
21221
|
+
case "dd":
|
|
21222
|
+
return pad2(day);
|
|
21223
|
+
case "d":
|
|
21224
|
+
return String(day);
|
|
21225
|
+
case "HH":
|
|
21226
|
+
return pad2(hours);
|
|
21227
|
+
case "H":
|
|
21228
|
+
return String(hours);
|
|
21229
|
+
case "hh":
|
|
21230
|
+
return pad2(hours12);
|
|
21231
|
+
case "h":
|
|
21232
|
+
return String(hours12);
|
|
21233
|
+
case "mm":
|
|
21234
|
+
return pad2(minutes);
|
|
21235
|
+
case "m":
|
|
21236
|
+
return String(minutes);
|
|
21237
|
+
case "ss":
|
|
21238
|
+
return pad2(seconds);
|
|
21239
|
+
case "s":
|
|
21240
|
+
return String(seconds);
|
|
21241
|
+
case "tt":
|
|
21242
|
+
case "AM/PM":
|
|
21243
|
+
return hours < 12 ? "AM" : "PM";
|
|
21244
|
+
case "am/pm":
|
|
21245
|
+
return hours < 12 ? "am" : "pm";
|
|
21246
|
+
case "A/P":
|
|
21247
|
+
return hours < 12 ? "A" : "P";
|
|
21248
|
+
case "a/p":
|
|
21249
|
+
return hours < 12 ? "a" : "p";
|
|
21250
|
+
default:
|
|
21251
|
+
return token.slice(1, -1);
|
|
21252
|
+
}
|
|
21253
|
+
});
|
|
21254
|
+
}
|
|
21255
|
+
|
|
21256
|
+
// docx/field-date.ts
|
|
21257
|
+
function datePicture(instr) {
|
|
21258
|
+
const match = /\\@\s*(?:"([^"]*)"|(\S+))/.exec(instr);
|
|
21259
|
+
return match ? match[1] ?? match[2] : void 0;
|
|
21260
|
+
}
|
|
21261
|
+
function formatWordDate(date2, picture, locale = "en-US") {
|
|
21262
|
+
return formatDatePicture(date2, picture, { locale });
|
|
21263
|
+
}
|
|
21264
|
+
function dateFieldResult(name2, instr, now, locale) {
|
|
21265
|
+
const picture = datePicture(instr) ?? (name2 === "DATE" ? "M/d/yyyy" : "h:mm am/pm");
|
|
21266
|
+
return formatWordDate(now, picture, locale);
|
|
21267
|
+
}
|
|
21268
|
+
|
|
21269
|
+
// docx/field-format.ts
|
|
21270
|
+
function numberFormat(argument) {
|
|
21271
|
+
const lower = argument.toLowerCase();
|
|
21272
|
+
const upper = argument[0] !== argument[0].toLowerCase();
|
|
21273
|
+
if (lower === "arabic") return "decimal";
|
|
21274
|
+
if (lower === "roman") return upper ? "upperRoman" : "lowerRoman";
|
|
21275
|
+
if (lower === "alphabetic") return upper ? "upperLetter" : "lowerLetter";
|
|
21276
|
+
if (lower === "cardtext") return "cardinalText";
|
|
21277
|
+
if (lower === "ordtext") return "ordinalText";
|
|
21278
|
+
if (lower === "ordinal") return "ordinal";
|
|
21279
|
+
if (lower === "hex") return "hex";
|
|
21280
|
+
if (lower === "arabicdash") return "arabicDash";
|
|
21281
|
+
return void 0;
|
|
21282
|
+
}
|
|
21283
|
+
function parseFieldInstruction(instr, own2 = {}) {
|
|
21284
|
+
const tokens = fieldTokens(instr);
|
|
21285
|
+
const head2 = tokens[0];
|
|
21286
|
+
if (head2?.kind !== "text") return void 0;
|
|
21287
|
+
const field = {
|
|
21288
|
+
name: head2.value.toUpperCase(),
|
|
21289
|
+
args: [],
|
|
21290
|
+
switches: /* @__PURE__ */ new Map(),
|
|
21291
|
+
format: { steps: [] }
|
|
21292
|
+
};
|
|
21293
|
+
for (let index = 1; index < tokens.length; index++) {
|
|
21294
|
+
const token = tokens[index];
|
|
21295
|
+
if (token.kind === "text") {
|
|
21296
|
+
field.args.push(token.value);
|
|
21297
|
+
continue;
|
|
21298
|
+
}
|
|
21299
|
+
const argument = () => {
|
|
21300
|
+
const next = tokens[index + 1];
|
|
21301
|
+
if (next?.kind !== "text") return void 0;
|
|
21302
|
+
index++;
|
|
21303
|
+
return next.value;
|
|
21304
|
+
};
|
|
21305
|
+
if (token.value === "*") {
|
|
21306
|
+
const format = argument();
|
|
21307
|
+
if (format === void 0) return void 0;
|
|
21308
|
+
const lower = format.toLowerCase();
|
|
21309
|
+
if (lower === "mergeformat") continue;
|
|
21310
|
+
if (lower === "charformat") field.format.charFormat = true;
|
|
21311
|
+
else if (isFieldTextCase(lower)) field.format.steps.push({ kind: "case", textCase: lower });
|
|
21312
|
+
else {
|
|
21313
|
+
const numFmt = numberFormat(format);
|
|
21314
|
+
if (!numFmt) return void 0;
|
|
21315
|
+
field.format.steps.push({ kind: "number", numFmt });
|
|
21316
|
+
}
|
|
21317
|
+
} else if (token.value === "@") {
|
|
21318
|
+
const picture = argument();
|
|
21319
|
+
if (picture === void 0) return void 0;
|
|
21320
|
+
field.format.datePicture = picture;
|
|
21321
|
+
} else if (token.value === "!") continue;
|
|
21322
|
+
else if (own2[token.value] === "arg") {
|
|
21323
|
+
const value = argument();
|
|
21324
|
+
field.switches.set(token.value, value ?? true);
|
|
21325
|
+
} else if (own2[token.value] === "flag") field.switches.set(token.value, true);
|
|
21326
|
+
else return void 0;
|
|
21327
|
+
}
|
|
21328
|
+
return field;
|
|
21329
|
+
}
|
|
21330
|
+
function formatFieldNumber(value, numFmt) {
|
|
21331
|
+
const whole = Math.round(value);
|
|
21332
|
+
if (numFmt === "arabicDash") return `- ${whole} -`;
|
|
21333
|
+
return formatListNumber(numFmt, whole);
|
|
21334
|
+
}
|
|
21335
|
+
function applyFieldFormat(text3, format) {
|
|
21336
|
+
let result = text3;
|
|
21337
|
+
for (const step of format.steps) {
|
|
21338
|
+
if (step.kind === "case") result = applyFieldTextCase(result, step.textCase);
|
|
21339
|
+
else if (/^\s*-?\d+(\.\d+)?\s*$/.test(result))
|
|
21340
|
+
result = formatFieldNumber(Number(result), step.numFmt);
|
|
21341
|
+
}
|
|
21342
|
+
return result;
|
|
21343
|
+
}
|
|
21344
|
+
function fieldDateResult(date2, format) {
|
|
21345
|
+
return format.datePicture === void 0 ? void 0 : applyFieldFormat(formatWordDate(date2, format.datePicture), format);
|
|
21346
|
+
}
|
|
21347
|
+
|
|
21348
|
+
// docx/list-number-fields.ts
|
|
21349
|
+
var DEFAULT_LISTS = ["NumberDefault", "OutlineDefault", "LegalDefault"];
|
|
21350
|
+
var DEFAULT_ID = "\0listnum";
|
|
21351
|
+
var FORMATS = {
|
|
21352
|
+
NumberDefault: [
|
|
21353
|
+
["", "decimal", ")"],
|
|
21354
|
+
["", "lowerLetter", ")"],
|
|
21355
|
+
["", "lowerRoman", ")"],
|
|
21356
|
+
["(", "decimal", ")"],
|
|
21357
|
+
["(", "lowerLetter", ")"],
|
|
21358
|
+
["(", "lowerRoman", ")"],
|
|
21359
|
+
["", "decimal", "."],
|
|
21360
|
+
["", "lowerLetter", "."],
|
|
21361
|
+
["", "lowerRoman", "."]
|
|
21362
|
+
],
|
|
21363
|
+
OutlineDefault: OUTLINE_NUMBERING
|
|
21364
|
+
};
|
|
21365
|
+
var level2 = (index) => ({
|
|
21366
|
+
level: index,
|
|
21367
|
+
start: 1,
|
|
21368
|
+
numFmt: "decimal",
|
|
21369
|
+
lvlText: ""
|
|
21370
|
+
});
|
|
21371
|
+
var DEFAULT_CATALOG = {
|
|
21372
|
+
abstractNums: {
|
|
21373
|
+
[DEFAULT_ID]: {
|
|
21374
|
+
id: DEFAULT_ID,
|
|
21375
|
+
levels: Object.fromEntries([...Array(9).keys()].map((i) => [i, level2(i)]))
|
|
21376
|
+
}
|
|
21377
|
+
},
|
|
21378
|
+
nums: { [DEFAULT_ID]: { id: DEFAULT_ID, abstractNumId: DEFAULT_ID } },
|
|
21379
|
+
warnings: []
|
|
21380
|
+
};
|
|
21381
|
+
var keyOf = (target) => target.kind === "default" ? target.name : `#${target.numId}`;
|
|
21382
|
+
var isListNum = (field) => fieldName(field.instr) === "LISTNUM";
|
|
21383
|
+
var ListNumberFields = class {
|
|
21384
|
+
constructor(counters, catalog) {
|
|
21385
|
+
this.counters = counters;
|
|
21386
|
+
this.catalog = catalog;
|
|
21387
|
+
}
|
|
21388
|
+
counters;
|
|
21389
|
+
catalog;
|
|
21390
|
+
results = /* @__PURE__ */ new Map();
|
|
21391
|
+
context = { kind: "default", name: "NumberDefault" };
|
|
21392
|
+
leadLevels = /* @__PURE__ */ new Map();
|
|
21393
|
+
/** What the LISTNUM starting at run `from` of a paragraph (or with its result there) shows. */
|
|
21394
|
+
result(paragraphId, from) {
|
|
21395
|
+
return this.results.get(paragraphId)?.get(from);
|
|
21396
|
+
}
|
|
21397
|
+
/**
|
|
21398
|
+
* Counts a paragraph's LISTNUM fields, after its own list number (`numbering`, its list and
|
|
21399
|
+
* zero-based level, when it has one).
|
|
21400
|
+
*/
|
|
21401
|
+
paragraph(paragraph, numbering) {
|
|
21402
|
+
if (numbering) this.context = { kind: "num", numId: numbering.numId };
|
|
21403
|
+
if (!paragraph.runs.some((run) => /LISTNUM/i.test(run.fieldCode ?? run.field?.instr ?? "")))
|
|
21404
|
+
return;
|
|
21405
|
+
const fields = fieldResultSpans(paragraph.runs, { resultless: true }).filter(isListNum).sort((a, b) => a.from - b.from);
|
|
21406
|
+
const blank = (from, to) => paragraph.runs.slice(from, to).every((run) => run.fieldCode !== void 0 || !/\S/.test(run.text));
|
|
21407
|
+
const leads = fields.length > 0 && blank(0, fields[0].from);
|
|
21408
|
+
let leading = leads;
|
|
21409
|
+
let previous;
|
|
21410
|
+
let end = -1;
|
|
21411
|
+
const shown = /* @__PURE__ */ new Map();
|
|
21412
|
+
for (const field of fields) {
|
|
21413
|
+
leading &&= blank(end + 1, field.from);
|
|
21414
|
+
end = field.to;
|
|
21415
|
+
const parsed = parseFieldInstruction(field.instr, { l: "arg", s: "arg" });
|
|
21416
|
+
if (!parsed) continue;
|
|
21417
|
+
const name2 = parsed.args[0];
|
|
21418
|
+
const named3 = name2 && DEFAULT_LISTS.find((item) => item.toLowerCase() === name2.toLowerCase());
|
|
21419
|
+
if (name2 && !named3) continue;
|
|
21420
|
+
const target = named3 ? { kind: "default", name: named3 } : numbering ? { kind: "num", numId: numbering.numId } : this.context;
|
|
21421
|
+
if (named3 && !numbering) this.context = target;
|
|
21422
|
+
const given = parsed.switches.get("l");
|
|
21423
|
+
const explicit = typeof given === "string" && /^-?\d+$/.test(given) ? Math.min(9, Math.max(1, Number(given))) : void 0;
|
|
21424
|
+
const own2 = explicit ?? (previous === void 0 ? numbering && !named3 ? numbering.level + 1 : this.leadLevels.get(keyOf(target)) ?? 1 : leads ? Math.min(9, previous + 1) : previous);
|
|
21425
|
+
const start = parsed.switches.get("s");
|
|
21426
|
+
const text3 = this.count(
|
|
21427
|
+
target,
|
|
21428
|
+
own2 - 1,
|
|
21429
|
+
typeof start === "string" && /^\d+$/.test(start) ? Number(start) : void 0
|
|
21430
|
+
);
|
|
21431
|
+
if (text3 === void 0) continue;
|
|
21432
|
+
for (const at of [field.from, ...field.runs]) shown.set(at, text3);
|
|
21433
|
+
if (leading) this.leadLevels.set(keyOf(target), own2);
|
|
21434
|
+
previous = own2;
|
|
21435
|
+
}
|
|
21436
|
+
if (shown.size) this.results.set(paragraph.id, shown);
|
|
21437
|
+
}
|
|
21438
|
+
/** Advances `target` at zero-based level `wanted` (or sets it to `start`) and draws its number. */
|
|
21439
|
+
count(target, wanted, start) {
|
|
21440
|
+
const numId = target.kind === "default" ? DEFAULT_ID : target.numId;
|
|
21441
|
+
const catalog = target.kind === "default" ? DEFAULT_CATALOG : this.catalog;
|
|
21442
|
+
if (!catalog) return void 0;
|
|
21443
|
+
let index = wanted;
|
|
21444
|
+
let def = resolveNumberingLevel(catalog, numId, index);
|
|
21445
|
+
while (!def && index > 0) def = resolveNumberingLevel(catalog, numId, --index);
|
|
21446
|
+
if (!def) return void 0;
|
|
21447
|
+
if (start === void 0) this.counters.advance(numId, index, def, catalog);
|
|
21448
|
+
else this.counters.set(numId, index, start);
|
|
21449
|
+
if (target.kind === "num")
|
|
21450
|
+
return def.numFmt === "bullet" ? displayListLabel(def.lvlText) : substituteLvlText(def.lvlText, numId, index, catalog, this.counters, Boolean(def.isLgl));
|
|
21451
|
+
const value = (at) => this.counters.current(DEFAULT_ID, at, 1);
|
|
21452
|
+
if (target.name === "LegalDefault")
|
|
21453
|
+
return `${[...Array(index + 1).keys()].map(value).join(".")}.`;
|
|
21454
|
+
const [open, numFmt, close] = FORMATS[target.name][index];
|
|
21455
|
+
return `${open}${formatListNumber(numFmt, value(index))}${close}`;
|
|
21456
|
+
}
|
|
21457
|
+
};
|
|
21458
|
+
|
|
21459
|
+
// docx/numbering-text.ts
|
|
21460
|
+
function romanNumeral(n2) {
|
|
21461
|
+
const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
|
|
21462
|
+
const numerals = [
|
|
21463
|
+
"M",
|
|
21464
|
+
"CM",
|
|
21465
|
+
"D",
|
|
21466
|
+
"CD",
|
|
21467
|
+
"C",
|
|
21468
|
+
"XC",
|
|
21469
|
+
"L",
|
|
21470
|
+
"XL",
|
|
21471
|
+
"X",
|
|
21472
|
+
"IX",
|
|
21473
|
+
"V",
|
|
21474
|
+
"IV",
|
|
21475
|
+
"I"
|
|
21476
|
+
];
|
|
21477
|
+
let remaining = Math.max(1, Math.min(Math.trunc(n2), 3999));
|
|
21478
|
+
let result = "";
|
|
21479
|
+
for (const [i, value] of values.entries()) {
|
|
21480
|
+
while (remaining >= value) {
|
|
21481
|
+
result += numerals[i] ?? "";
|
|
21482
|
+
remaining -= value;
|
|
21483
|
+
}
|
|
21484
|
+
}
|
|
21485
|
+
return result;
|
|
21486
|
+
}
|
|
21487
|
+
var LATIN_LOWER = Array.from("abcdefghijklmnopqrstuvwxyz");
|
|
21488
|
+
var MAX_LETTER_LABEL = 64;
|
|
21489
|
+
function letterLabel(n2) {
|
|
21490
|
+
const index = Math.max(0, Math.trunc(n2) - 1);
|
|
21491
|
+
const letter = LATIN_LOWER[index % LATIN_LOWER.length] ?? "a";
|
|
21492
|
+
const repeats = Math.min(Math.floor(index / LATIN_LOWER.length) + 1, MAX_LETTER_LABEL);
|
|
21493
|
+
return letter.repeat(repeats);
|
|
21494
|
+
}
|
|
21495
|
+
var ORDINAL_SUFFIX = (n2) => {
|
|
21496
|
+
const abs = Math.abs(Math.trunc(n2));
|
|
21497
|
+
if (abs % 100 >= 11 && abs % 100 <= 13) return "th";
|
|
21498
|
+
switch (abs % 10) {
|
|
21499
|
+
case 1:
|
|
21500
|
+
return "st";
|
|
21501
|
+
case 2:
|
|
21502
|
+
return "nd";
|
|
21503
|
+
case 3:
|
|
21504
|
+
return "rd";
|
|
21505
|
+
default:
|
|
21506
|
+
return "th";
|
|
21507
|
+
}
|
|
21508
|
+
};
|
|
21509
|
+
function ordinalNumeral(n2) {
|
|
21510
|
+
return `${Math.trunc(n2)}${ORDINAL_SUFFIX(n2)}`;
|
|
21511
|
+
}
|
|
21512
|
+
var ONES = [
|
|
21513
|
+
"",
|
|
21514
|
+
"one",
|
|
21515
|
+
"two",
|
|
21516
|
+
"three",
|
|
21517
|
+
"four",
|
|
21518
|
+
"five",
|
|
21519
|
+
"six",
|
|
21520
|
+
"seven",
|
|
21521
|
+
"eight",
|
|
21522
|
+
"nine",
|
|
21523
|
+
"ten",
|
|
21524
|
+
"eleven",
|
|
21525
|
+
"twelve",
|
|
20927
21526
|
"thirteen",
|
|
20928
21527
|
"fourteen",
|
|
20929
21528
|
"fifteen",
|
|
@@ -21016,108 +21615,57 @@ function resolveParagraphNumbering(paragraph, styleCatalog, numberingCatalog) {
|
|
|
21016
21615
|
const inherited = resolveStyleNumbering(paragraph.style, styleCatalog);
|
|
21017
21616
|
if (!inherited || inherited.numId <= 0) return void 0;
|
|
21018
21617
|
if (numberingCatalog && paragraph.style && styleCatalog.styles[paragraph.style]) {
|
|
21019
|
-
for (let
|
|
21020
|
-
const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId),
|
|
21618
|
+
for (let level3 = 0; level3 < 9; level3++) {
|
|
21619
|
+
const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level3);
|
|
21021
21620
|
if (definition?.paragraphStyleId === paragraph.style)
|
|
21022
|
-
return { numId: inherited.numId, level:
|
|
21621
|
+
return { numId: inherited.numId, level: level3 };
|
|
21023
21622
|
}
|
|
21024
21623
|
}
|
|
21025
21624
|
return inherited;
|
|
21026
21625
|
}
|
|
21027
|
-
|
|
21028
|
-
counts = /* @__PURE__ */ new Map();
|
|
21029
|
-
started = /* @__PURE__ */ new Map();
|
|
21030
|
-
forNum(numId) {
|
|
21031
|
-
let counts = this.counts.get(numId);
|
|
21032
|
-
if (!counts) {
|
|
21033
|
-
counts = /* @__PURE__ */ new Map();
|
|
21034
|
-
this.counts.set(numId, counts);
|
|
21035
|
-
}
|
|
21036
|
-
return counts;
|
|
21037
|
-
}
|
|
21038
|
-
startedLevels(numId) {
|
|
21039
|
-
let started = this.started.get(numId);
|
|
21040
|
-
if (!started) {
|
|
21041
|
-
started = /* @__PURE__ */ new Set();
|
|
21042
|
-
this.started.set(numId, started);
|
|
21043
|
-
}
|
|
21044
|
-
return started;
|
|
21045
|
-
}
|
|
21046
|
-
/** Advances one level and resets deeper counters according to their resolved restart rules. */
|
|
21047
|
-
advance(numId, level2, def, catalog) {
|
|
21048
|
-
const counts = this.forNum(numId);
|
|
21049
|
-
const started = this.startedLevels(numId);
|
|
21050
|
-
const next = started.has(level2) ? (counts.get(level2) ?? def.start) + 1 : def.start;
|
|
21051
|
-
counts.set(level2, next);
|
|
21052
|
-
started.add(level2);
|
|
21053
|
-
for (const deeper of [...started]) {
|
|
21054
|
-
if (deeper <= level2) continue;
|
|
21055
|
-
const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
|
|
21056
|
-
const restart = deeperDef?.lvlRestart;
|
|
21057
|
-
if (restart === 0) continue;
|
|
21058
|
-
const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
|
|
21059
|
-
if (level2 > trigger) continue;
|
|
21060
|
-
counts.delete(deeper);
|
|
21061
|
-
started.delete(deeper);
|
|
21062
|
-
}
|
|
21063
|
-
for (let ancestor = 0; ancestor < level2; ancestor++) {
|
|
21064
|
-
if (started.has(ancestor)) continue;
|
|
21065
|
-
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
|
|
21066
|
-
if (!ancestorDef) continue;
|
|
21067
|
-
counts.set(ancestor, ancestorDef.start);
|
|
21068
|
-
started.add(ancestor);
|
|
21069
|
-
}
|
|
21070
|
-
return next;
|
|
21071
|
-
}
|
|
21072
|
-
/** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
|
|
21073
|
-
current(numId, level2, start) {
|
|
21074
|
-
return this.forNum(numId).get(level2) ?? start;
|
|
21075
|
-
}
|
|
21076
|
-
};
|
|
21077
|
-
function substituteLvlText(lvlText, numId, level2, catalog, counters, forceDecimal) {
|
|
21078
|
-
return lvlText.replace(/%([1-9])/g, (match, digit) => {
|
|
21079
|
-
const ancestorLevel = Number(digit) - 1;
|
|
21080
|
-
if (ancestorLevel > level2) return match;
|
|
21081
|
-
const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
|
|
21082
|
-
const start = ancestorDef?.start ?? 1;
|
|
21083
|
-
const value = counters.current(numId, ancestorLevel, start);
|
|
21084
|
-
const fmt = forceDecimal ? "decimal" : ancestorDef?.numFmt ?? "decimal";
|
|
21085
|
-
return formatListNumber(fmt, value);
|
|
21086
|
-
});
|
|
21087
|
-
}
|
|
21088
|
-
function computeListLabels(model) {
|
|
21626
|
+
function computeListNumbering(model) {
|
|
21089
21627
|
const catalog = model.numberingCatalog;
|
|
21090
21628
|
const labels = /* @__PURE__ */ new Map();
|
|
21091
|
-
if (!catalog) return labels;
|
|
21092
21629
|
const counters = new NumberingCounters();
|
|
21630
|
+
const listNumbers = new ListNumberFields(counters, catalog);
|
|
21093
21631
|
for (const paragraph of documentParagraphs(model.blocks)) {
|
|
21094
|
-
const
|
|
21095
|
-
if (
|
|
21096
|
-
|
|
21097
|
-
|
|
21098
|
-
|
|
21099
|
-
|
|
21100
|
-
if (def.numFmt === "none") continue;
|
|
21101
|
-
counters.advance(numId, level2, def, catalog);
|
|
21102
|
-
const text2 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level2, catalog, counters, Boolean(def.isLgl));
|
|
21103
|
-
const picture = def.pictureBulletId !== void 0 ? catalog.pictureBullets?.[def.pictureBulletId] : void 0;
|
|
21104
|
-
labels.set(paragraph.id, {
|
|
21105
|
-
numId,
|
|
21106
|
-
level: level2,
|
|
21107
|
-
text: text2,
|
|
21108
|
-
suffix: def.suffix ?? "tab",
|
|
21109
|
-
...definedProps({
|
|
21110
|
-
alignment: def.lvlJc,
|
|
21111
|
-
indentLeftTwips: def.indentLeftTwips,
|
|
21112
|
-
hangingTwips: def.hangingTwips,
|
|
21113
|
-
firstLineTwips: def.firstLineTwips,
|
|
21114
|
-
markerFormat: def.markerFormat,
|
|
21115
|
-
tabStopTwips: def.tabStopTwips,
|
|
21116
|
-
picture
|
|
21117
|
-
})
|
|
21118
|
-
});
|
|
21632
|
+
const label = catalog && paragraphLabel(paragraph, model, catalog, counters);
|
|
21633
|
+
if (label) labels.set(paragraph.id, label);
|
|
21634
|
+
listNumbers.paragraph(
|
|
21635
|
+
paragraph,
|
|
21636
|
+
label ? { numId: label.numId, level: label.level } : void 0
|
|
21637
|
+
);
|
|
21119
21638
|
}
|
|
21120
|
-
return labels;
|
|
21639
|
+
return { labels, listNumbers };
|
|
21640
|
+
}
|
|
21641
|
+
function computeListLabels(model) {
|
|
21642
|
+
return computeListNumbering(model).labels;
|
|
21643
|
+
}
|
|
21644
|
+
function paragraphLabel(paragraph, model, catalog, counters) {
|
|
21645
|
+
const numbering = resolveParagraphNumbering(paragraph, model.paragraphStyles, catalog);
|
|
21646
|
+
if (!numbering) return void 0;
|
|
21647
|
+
const numId = String(numbering.numId);
|
|
21648
|
+
const level3 = Math.min(8, Math.max(0, numbering.level));
|
|
21649
|
+
const def = resolveNumberingLevel(catalog, numId, level3);
|
|
21650
|
+
if (!def || def.numFmt === "none") return void 0;
|
|
21651
|
+
counters.advance(numId, level3, def, catalog);
|
|
21652
|
+
const text3 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level3, catalog, counters, Boolean(def.isLgl));
|
|
21653
|
+
const picture = def.pictureBulletId !== void 0 ? catalog.pictureBullets?.[def.pictureBulletId] : void 0;
|
|
21654
|
+
return {
|
|
21655
|
+
numId,
|
|
21656
|
+
level: level3,
|
|
21657
|
+
text: text3,
|
|
21658
|
+
suffix: def.suffix ?? "tab",
|
|
21659
|
+
...definedProps({
|
|
21660
|
+
alignment: def.lvlJc,
|
|
21661
|
+
indentLeftTwips: def.indentLeftTwips,
|
|
21662
|
+
hangingTwips: def.hangingTwips,
|
|
21663
|
+
firstLineTwips: def.firstLineTwips,
|
|
21664
|
+
markerFormat: def.markerFormat,
|
|
21665
|
+
tabStopTwips: def.tabStopTwips,
|
|
21666
|
+
picture
|
|
21667
|
+
})
|
|
21668
|
+
};
|
|
21121
21669
|
}
|
|
21122
21670
|
var SYMBOL_BULLETS = {
|
|
21123
21671
|
"\uF0B7": "\u2022",
|
|
@@ -21130,8 +21678,8 @@ var SYMBOL_BULLETS = {
|
|
|
21130
21678
|
"\uF0E0": "\u27A9",
|
|
21131
21679
|
"\uF0B2": "\u25CB"
|
|
21132
21680
|
};
|
|
21133
|
-
function displayListLabel(
|
|
21134
|
-
return
|
|
21681
|
+
function displayListLabel(text3) {
|
|
21682
|
+
return text3.replace(/[-]/g, (char) => SYMBOL_BULLETS[char] ?? "\u2022");
|
|
21135
21683
|
}
|
|
21136
21684
|
|
|
21137
21685
|
// docx/style-ref.ts
|
|
@@ -21181,10 +21729,10 @@ function styleTarget(model, style) {
|
|
|
21181
21729
|
id: definition.id,
|
|
21182
21730
|
...definition.isDefault ? { isDefault: true } : {}
|
|
21183
21731
|
};
|
|
21184
|
-
const
|
|
21732
|
+
const character2 = (definition) => definition && { kind: "character", id: definition.id };
|
|
21185
21733
|
const named3 = (list) => list.find((definition) => definition.name?.toLowerCase() === key);
|
|
21186
21734
|
const withId = (list) => list.find((definition) => definition.id === name2) ?? list.find((definition) => definition.id.toLowerCase() === key);
|
|
21187
|
-
return paragraph(named3(paragraphs)) ??
|
|
21735
|
+
return paragraph(named3(paragraphs)) ?? character2(named3(characters)) ?? paragraph(withId(paragraphs)) ?? character2(withId(characters));
|
|
21188
21736
|
}
|
|
21189
21737
|
var shownText = (run) => run.vanish || run.revision?.kind === "delete" || run.revision?.kind === "moveFrom" ? "" : run.text;
|
|
21190
21738
|
function characterPortions(paragraph, id, hidden, skip) {
|
|
@@ -21200,11 +21748,11 @@ function characterPortions(paragraph, id, hidden, skip) {
|
|
|
21200
21748
|
open = void 0;
|
|
21201
21749
|
return;
|
|
21202
21750
|
}
|
|
21203
|
-
const
|
|
21751
|
+
const text3 = hidden(run, paragraph) ? "" : run.text;
|
|
21204
21752
|
if (open) {
|
|
21205
|
-
open.text +=
|
|
21753
|
+
open.text += text3;
|
|
21206
21754
|
open.to = index;
|
|
21207
|
-
} else portions.push(open = { text:
|
|
21755
|
+
} else portions.push(open = { text: text3, from: index, to: index });
|
|
21208
21756
|
});
|
|
21209
21757
|
return portions;
|
|
21210
21758
|
}
|
|
@@ -21226,20 +21774,20 @@ function styleRefSource(model) {
|
|
|
21226
21774
|
labels ??= computeListLabels(model);
|
|
21227
21775
|
const label = labels.get(paragraph.id);
|
|
21228
21776
|
if (!label || !model.numberingCatalog) return "0";
|
|
21229
|
-
const
|
|
21230
|
-
if (!
|
|
21231
|
-
let
|
|
21777
|
+
const level3 = resolveNumberingLevel(model.numberingCatalog, label.numId, label.level);
|
|
21778
|
+
if (!level3 || level3.numFmt === "bullet") return null;
|
|
21779
|
+
let text3 = label.text;
|
|
21232
21780
|
if (numberOnly) {
|
|
21233
|
-
const
|
|
21234
|
-
const end =
|
|
21235
|
-
const prefix2 =
|
|
21236
|
-
const suffix = end < 0 ? "" :
|
|
21237
|
-
const inner =
|
|
21781
|
+
const first4 = level3.lvlText.indexOf("%");
|
|
21782
|
+
const end = level3.lvlText.search(/%[1-9](?!.*%[1-9])/);
|
|
21783
|
+
const prefix2 = first4 < 0 ? "" : level3.lvlText.slice(0, first4);
|
|
21784
|
+
const suffix = end < 0 ? "" : level3.lvlText.slice(end + 2);
|
|
21785
|
+
const inner = first4 < 0 || end < 0 ? "" : level3.lvlText.slice(first4, end + 2);
|
|
21238
21786
|
if (/\p{L}/u.test(inner.replace(/%[1-9]/g, ""))) return null;
|
|
21239
|
-
if (prefix2 &&
|
|
21240
|
-
if (suffix &&
|
|
21787
|
+
if (prefix2 && text3.startsWith(prefix2)) text3 = text3.slice(prefix2.length);
|
|
21788
|
+
if (suffix && text3.endsWith(suffix)) text3 = text3.slice(0, -suffix.length);
|
|
21241
21789
|
}
|
|
21242
|
-
return
|
|
21790
|
+
return text3.trim().replace(/\.+$/, "");
|
|
21243
21791
|
};
|
|
21244
21792
|
const portions = (at, reference, target, skip) => {
|
|
21245
21793
|
const paragraph = paragraphs[at];
|
|
@@ -21276,164 +21824,299 @@ function styleRefSource(model) {
|
|
|
21276
21824
|
}
|
|
21277
21825
|
|
|
21278
21826
|
// docx/style-ref-fields.ts
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
const top = open.at(-1);
|
|
21285
|
-
if (run.fieldChar === "begin")
|
|
21286
|
-
open.push({ begin: index, code: "", locked: isFieldLocked(run) });
|
|
21287
|
-
else if (run.fieldCode !== void 0 && top && top.separate === void 0) {
|
|
21288
|
-
top.code += run.fieldCode;
|
|
21289
|
-
top.codeRun ??= index;
|
|
21290
|
-
if (top.nameRun === void 0 && /\S/.test(run.fieldCode)) top.nameRun = index;
|
|
21291
|
-
} else if (run.fieldChar === "separate" && top) top.separate = index;
|
|
21292
|
-
else if (run.fieldChar === "end" && top) {
|
|
21293
|
-
open.pop();
|
|
21294
|
-
if (top.separate === void 0) return;
|
|
21295
|
-
const instr = top.code.trim();
|
|
21296
|
-
const results = [];
|
|
21297
|
-
let gone = false;
|
|
21298
|
-
for (let at = top.separate + 1; at < index; at++) {
|
|
21299
|
-
const item = runs[at];
|
|
21300
|
-
if (item.field?.instr !== instr || item.fieldChar || item.fieldCode !== void 0) continue;
|
|
21301
|
-
if (removed(item)) gone = true;
|
|
21302
|
-
else results.push(at);
|
|
21303
|
-
}
|
|
21304
|
-
found.push({
|
|
21305
|
-
from: top.begin,
|
|
21306
|
-
to: index,
|
|
21307
|
-
instr,
|
|
21308
|
-
locked: top.locked || results.some((at) => isFieldLocked(runs[at])),
|
|
21309
|
-
runs: results,
|
|
21310
|
-
...top.codeRun !== void 0 ? { code: top.codeRun } : {},
|
|
21311
|
-
...top.nameRun !== void 0 ? { name: top.nameRun } : {},
|
|
21312
|
-
insertAt: top.separate + 1,
|
|
21313
|
-
...gone && !results.length ? { removed: true } : {}
|
|
21314
|
-
});
|
|
21315
|
-
}
|
|
21316
|
-
});
|
|
21317
|
-
let simple;
|
|
21318
|
-
let identity;
|
|
21319
|
-
runs.forEach((run, index) => {
|
|
21320
|
-
if (!run.field?.simple) {
|
|
21321
|
-
simple = void 0;
|
|
21322
|
-
return;
|
|
21323
|
-
}
|
|
21324
|
-
if (simple && simple.instr === run.field.instr && identity === run.fieldInstanceId) {
|
|
21325
|
-
if (!removed(run)) simple.runs.push(index);
|
|
21326
|
-
simple.to = index;
|
|
21327
|
-
} else {
|
|
21328
|
-
simple = {
|
|
21329
|
-
from: index,
|
|
21330
|
-
to: index,
|
|
21331
|
-
instr: run.field.instr,
|
|
21332
|
-
locked: false,
|
|
21333
|
-
runs: removed(run) ? [] : [index],
|
|
21334
|
-
insertAt: index
|
|
21335
|
-
};
|
|
21336
|
-
identity = run.fieldInstanceId;
|
|
21337
|
-
found.push(simple);
|
|
21338
|
-
}
|
|
21339
|
-
simple.locked ||= isFieldLocked(run);
|
|
21827
|
+
function withStyleRefResults(blocks, evaluate) {
|
|
21828
|
+
return withFieldResults(blocks, (field, paragraph) => {
|
|
21829
|
+
const reference = parseStyleReference(field.instr);
|
|
21830
|
+
const text3 = reference && evaluate(reference, paragraph, field);
|
|
21831
|
+
return text3 === void 0 ? void 0 : { text: text3, charFormat: reference?.charFormat === true };
|
|
21340
21832
|
});
|
|
21341
|
-
return found;
|
|
21342
21833
|
}
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
"
|
|
21347
|
-
"
|
|
21348
|
-
"
|
|
21349
|
-
|
|
21350
|
-
|
|
21351
|
-
|
|
21352
|
-
|
|
21353
|
-
|
|
21354
|
-
];
|
|
21355
|
-
var NOT_FORMATTING = [
|
|
21356
|
-
...STRUCTURE,
|
|
21357
|
-
"text",
|
|
21358
|
-
"field",
|
|
21359
|
-
"revision",
|
|
21360
|
-
"formatRevision",
|
|
21361
|
-
"restoredRunPropertiesXml",
|
|
21362
|
-
"commentIds",
|
|
21363
|
-
"link",
|
|
21364
|
-
"contentControl"
|
|
21365
|
-
];
|
|
21366
|
-
function withFieldCodeFormatting(result, code, text2) {
|
|
21367
|
-
const formatted = { ...code };
|
|
21368
|
-
const own2 = {};
|
|
21369
|
-
for (const key of NOT_FORMATTING) {
|
|
21370
|
-
delete formatted[key];
|
|
21371
|
-
if (result[key] !== void 0) Object.assign(own2, { [key]: result[key] });
|
|
21372
|
-
}
|
|
21373
|
-
return { ...formatted, ...own2, text: text2 };
|
|
21834
|
+
|
|
21835
|
+
// docx/auto-number-fields.ts
|
|
21836
|
+
var AUTO_NUMBER_FIELDS = /* @__PURE__ */ new Set([
|
|
21837
|
+
"AUTONUM",
|
|
21838
|
+
"AUTONUMLGL",
|
|
21839
|
+
"AUTONUMOUT"
|
|
21840
|
+
]);
|
|
21841
|
+
function counts(paragraph) {
|
|
21842
|
+
return fieldResultSpans(paragraph.runs, { resultless: true }).some(
|
|
21843
|
+
(field) => AUTO_NUMBER_FIELDS.has(fieldName(field.instr))
|
|
21844
|
+
);
|
|
21374
21845
|
}
|
|
21375
|
-
function
|
|
21376
|
-
const
|
|
21377
|
-
const
|
|
21378
|
-
const
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
const
|
|
21382
|
-
|
|
21846
|
+
function autoNumberStates(model) {
|
|
21847
|
+
const states = /* @__PURE__ */ new Map();
|
|
21848
|
+
const headings = new Array(11).fill(0);
|
|
21849
|
+
const bodies = new Array(11).fill(0);
|
|
21850
|
+
let lastHeading = 0;
|
|
21851
|
+
for (const paragraph of documentParagraphs(model.blocks)) {
|
|
21852
|
+
const outline2 = model.paragraphStyles ? resolveParagraphFormatting(paragraph, model.paragraphStyles).outlineLevel : paragraph.outlineLevel;
|
|
21853
|
+
const heading = outline2 !== void 0 && outline2 >= 1 && outline2 <= 9;
|
|
21854
|
+
const level3 = heading ? outline2 : lastHeading + 1;
|
|
21855
|
+
if (!counts(paragraph)) continue;
|
|
21856
|
+
if (heading) lastHeading = outline2;
|
|
21857
|
+
const own2 = heading ? headings : bodies;
|
|
21858
|
+
own2[level3]++;
|
|
21859
|
+
for (let deeper = level3 + 1; deeper <= 10; deeper++) {
|
|
21860
|
+
bodies[deeper] = 0;
|
|
21861
|
+
if (heading) headings[deeper] = 0;
|
|
21862
|
+
}
|
|
21863
|
+
states.set(paragraph.id, {
|
|
21864
|
+
level: level3,
|
|
21865
|
+
heading,
|
|
21866
|
+
counts: [...headings.slice(1, level3), own2[level3]]
|
|
21867
|
+
});
|
|
21868
|
+
}
|
|
21869
|
+
return states;
|
|
21870
|
+
}
|
|
21871
|
+
function autoNumberResult(instr, state) {
|
|
21872
|
+
const field = parseFieldInstruction(instr, { s: "arg", e: "flag" });
|
|
21873
|
+
if (!field || !AUTO_NUMBER_FIELDS.has(field.name)) return void 0;
|
|
21874
|
+
const own2 = state.counts.at(-1);
|
|
21875
|
+
if (field.name === "AUTONUMOUT") {
|
|
21876
|
+
const [open, numFmt, close] = state.heading ? OUTLINE_NUMBERING[state.level - 1] : ["", "decimal", "."];
|
|
21877
|
+
return `${open}${formatListNumber(numFmt, own2)}${close}`;
|
|
21878
|
+
}
|
|
21879
|
+
const given = field.switches.get("s");
|
|
21880
|
+
const separator = typeof given === "string" && given ? [...given][0] : ".";
|
|
21881
|
+
if (field.name === "AUTONUMLGL")
|
|
21882
|
+
return state.counts.join(separator) + (field.switches.has("e") ? "" : separator);
|
|
21883
|
+
return applyFieldFormat(String(own2), field.format) + separator;
|
|
21884
|
+
}
|
|
21885
|
+
|
|
21886
|
+
// docx/doc-property-field.ts
|
|
21887
|
+
var UNKNOWN_PROPERTY = "Error! Unknown document property name.";
|
|
21888
|
+
var NO_PROPERTY_NAME = "Error! No property name supplied.";
|
|
21889
|
+
var text2 = (value) => ({
|
|
21890
|
+
kind: "text",
|
|
21891
|
+
text: value === void 0 ? "" : String(value)
|
|
21892
|
+
});
|
|
21893
|
+
function date(value) {
|
|
21894
|
+
if (value === void 0) return text2(void 0);
|
|
21895
|
+
const parsed = new Date(value);
|
|
21896
|
+
return Number.isNaN(parsed.getTime()) ? { kind: "stale" } : { kind: "date", date: parsed };
|
|
21897
|
+
}
|
|
21898
|
+
function builtIn(name2, core, app) {
|
|
21899
|
+
switch (name2) {
|
|
21900
|
+
case "title":
|
|
21901
|
+
return text2(core.title);
|
|
21902
|
+
case "subject":
|
|
21903
|
+
return text2(core.subject);
|
|
21904
|
+
case "author":
|
|
21905
|
+
return text2(core.creator);
|
|
21906
|
+
case "keywords":
|
|
21907
|
+
return text2(core.keywords);
|
|
21908
|
+
case "comments":
|
|
21909
|
+
return text2(core.description);
|
|
21910
|
+
case "lastsavedby":
|
|
21911
|
+
return text2(core.lastModifiedBy);
|
|
21912
|
+
case "revisionnumber":
|
|
21913
|
+
return text2(core.revision);
|
|
21914
|
+
case "category":
|
|
21915
|
+
return text2(core.category);
|
|
21916
|
+
case "manager":
|
|
21917
|
+
return text2(app.manager);
|
|
21918
|
+
case "company":
|
|
21919
|
+
return text2(app.company);
|
|
21920
|
+
case "hyperlinkbase":
|
|
21921
|
+
return text2(app.hyperlinkBase);
|
|
21922
|
+
case "template":
|
|
21923
|
+
return text2(app.template);
|
|
21924
|
+
case "nameofapplication":
|
|
21925
|
+
return text2(app.application);
|
|
21926
|
+
case "security":
|
|
21927
|
+
return text2(app.docSecurity ?? 0);
|
|
21928
|
+
case "createtime":
|
|
21929
|
+
return date(core.created);
|
|
21930
|
+
case "lastsavedtime":
|
|
21931
|
+
return date(core.modified);
|
|
21932
|
+
case "lastprinted":
|
|
21933
|
+
return date(core.lastPrinted);
|
|
21934
|
+
case "pages":
|
|
21935
|
+
case "words":
|
|
21936
|
+
case "characters":
|
|
21937
|
+
case "characterswithspaces":
|
|
21938
|
+
case "lines":
|
|
21939
|
+
case "paragraphs":
|
|
21940
|
+
case "bytes":
|
|
21941
|
+
case "totaleditingtime":
|
|
21942
|
+
return { kind: "stale" };
|
|
21943
|
+
default:
|
|
21383
21944
|
return void 0;
|
|
21384
|
-
next[first3] = formatted ?? { ...runs[first3], text: text2 };
|
|
21385
|
-
for (const at of rest) next[at] = { ...runs[at], text: "" };
|
|
21386
|
-
return next;
|
|
21387
21945
|
}
|
|
21388
|
-
const code = charFormat ? name2 : field.code;
|
|
21389
|
-
if (current || code === void 0 || field.removed) return void 0;
|
|
21390
|
-
next.splice(field.insertAt, 0, fieldResultRun(runs[code], field.instr, text2));
|
|
21391
|
-
return next;
|
|
21392
21946
|
}
|
|
21393
|
-
function
|
|
21394
|
-
|
|
21395
|
-
|
|
21396
|
-
|
|
21397
|
-
|
|
21398
|
-
|
|
21399
|
-
|
|
21400
|
-
|
|
21401
|
-
|
|
21402
|
-
|
|
21403
|
-
|
|
21404
|
-
|
|
21405
|
-
|
|
21406
|
-
const reference = field.locked ? void 0 : parseStyleReference(field.instr);
|
|
21407
|
-
const text2 = reference && evaluate(reference, paragraph, field);
|
|
21408
|
-
if (text2 !== void 0)
|
|
21409
|
-
runs = replaceResult(runs, field, text2, reference?.charFormat === true) ?? runs;
|
|
21947
|
+
function custom(property) {
|
|
21948
|
+
switch (property.type) {
|
|
21949
|
+
case "lpwstr":
|
|
21950
|
+
return text2(property.value);
|
|
21951
|
+
case "i4":
|
|
21952
|
+
case "r8":
|
|
21953
|
+
return text2(property.value);
|
|
21954
|
+
case "bool":
|
|
21955
|
+
return text2(property.value ? "Y" : "N");
|
|
21956
|
+
case "filetime":
|
|
21957
|
+
return date(property.value);
|
|
21958
|
+
default:
|
|
21959
|
+
return { kind: "stale" };
|
|
21410
21960
|
}
|
|
21411
|
-
return runs === paragraph.runs ? paragraph : { ...paragraph, runs: [...runs] };
|
|
21412
|
-
}
|
|
21413
|
-
function tableWithResults(table, evaluate) {
|
|
21414
|
-
let changed = false;
|
|
21415
|
-
const rows2 = table.rows.map(
|
|
21416
|
-
(row2) => row2.map((cell) => {
|
|
21417
|
-
const paragraphs = cell.paragraphs.map((item) => paragraphWithResults(item, evaluate));
|
|
21418
|
-
const sourceBlocks = cell.sourceBlocks?.map(
|
|
21419
|
-
(item) => item.type === "table" ? tableWithResults(item, evaluate) : item
|
|
21420
|
-
);
|
|
21421
|
-
if (paragraphs.every((item, index) => item === cell.paragraphs[index]) && (sourceBlocks ?? []).every((item, index) => item === cell.sourceBlocks[index]))
|
|
21422
|
-
return cell;
|
|
21423
|
-
changed = true;
|
|
21424
|
-
return { ...cell, paragraphs, ...sourceBlocks ? { sourceBlocks } : {} };
|
|
21425
|
-
})
|
|
21426
|
-
);
|
|
21427
|
-
return changed ? { ...table, rows: rows2 } : table;
|
|
21428
21961
|
}
|
|
21429
|
-
function
|
|
21430
|
-
|
|
21431
|
-
|
|
21432
|
-
|
|
21433
|
-
|
|
21434
|
-
|
|
21962
|
+
function docPropertyResult(instr, properties) {
|
|
21963
|
+
const field = parseFieldInstruction(instr);
|
|
21964
|
+
if (field?.name !== "DOCPROPERTY") return void 0;
|
|
21965
|
+
const name2 = field.args[0];
|
|
21966
|
+
if (name2 === void 0) return NO_PROPERTY_NAME;
|
|
21967
|
+
const key = name2.toLowerCase();
|
|
21968
|
+
const value = builtIn(key, properties.core, properties.app) ?? (() => {
|
|
21969
|
+
const found = properties.custom.find((item) => item.name.toLowerCase() === key);
|
|
21970
|
+
return found && custom(found);
|
|
21971
|
+
})();
|
|
21972
|
+
if (!value) return UNKNOWN_PROPERTY;
|
|
21973
|
+
if (value.kind === "stale") return void 0;
|
|
21974
|
+
if (value.kind === "date") return fieldDateResult(value.date, field.format);
|
|
21975
|
+
return applyFieldFormat(value.text, field.format);
|
|
21976
|
+
}
|
|
21977
|
+
var EDITABLE = [
|
|
21978
|
+
"title",
|
|
21979
|
+
"subject",
|
|
21980
|
+
"creator",
|
|
21981
|
+
"keywords",
|
|
21982
|
+
"description",
|
|
21983
|
+
"lastModifiedBy"
|
|
21984
|
+
];
|
|
21985
|
+
function fieldProperties(model) {
|
|
21986
|
+
const loaded = model.packageProperties;
|
|
21987
|
+
const core = { ...loaded?.core };
|
|
21988
|
+
if (model.properties || !loaded)
|
|
21989
|
+
for (const key of EDITABLE) {
|
|
21990
|
+
const value = model.properties?.[key];
|
|
21991
|
+
if (value === void 0) delete core[key];
|
|
21992
|
+
else core[key] = value;
|
|
21993
|
+
}
|
|
21994
|
+
return { core, app: loaded?.app ?? {}, custom: loaded?.custom ?? [] };
|
|
21995
|
+
}
|
|
21996
|
+
|
|
21997
|
+
// text/windows-1252.ts
|
|
21998
|
+
var WINDOWS_1252_HIGH = {
|
|
21999
|
+
128: 8364,
|
|
22000
|
+
130: 8218,
|
|
22001
|
+
131: 402,
|
|
22002
|
+
132: 8222,
|
|
22003
|
+
133: 8230,
|
|
22004
|
+
134: 8224,
|
|
22005
|
+
135: 8225,
|
|
22006
|
+
136: 710,
|
|
22007
|
+
137: 8240,
|
|
22008
|
+
138: 352,
|
|
22009
|
+
139: 8249,
|
|
22010
|
+
140: 338,
|
|
22011
|
+
142: 381,
|
|
22012
|
+
145: 8216,
|
|
22013
|
+
146: 8217,
|
|
22014
|
+
147: 8220,
|
|
22015
|
+
148: 8221,
|
|
22016
|
+
149: 8226,
|
|
22017
|
+
150: 8211,
|
|
22018
|
+
151: 8212,
|
|
22019
|
+
152: 732,
|
|
22020
|
+
153: 8482,
|
|
22021
|
+
154: 353,
|
|
22022
|
+
155: 8250,
|
|
22023
|
+
156: 339,
|
|
22024
|
+
158: 382,
|
|
22025
|
+
159: 376
|
|
22026
|
+
};
|
|
22027
|
+
var REVERSE = new Map(Object.entries(WINDOWS_1252_HIGH).map(([code2, char]) => [char, +code2]));
|
|
22028
|
+
var windows1252CodePoint = (byte) => WINDOWS_1252_HIGH[byte] ?? byte;
|
|
22029
|
+
var windows1252HighByte = (codePoint) => REVERSE.get(codePoint);
|
|
22030
|
+
|
|
22031
|
+
// docx/symbol-field.ts
|
|
22032
|
+
var SYMBOL_ERROR = "###";
|
|
22033
|
+
var SYMBOL_FONTS = /* @__PURE__ */ new Set([
|
|
22034
|
+
"symbol",
|
|
22035
|
+
"wingdings",
|
|
22036
|
+
"wingdings 2",
|
|
22037
|
+
"wingdings 3",
|
|
22038
|
+
"webdings",
|
|
22039
|
+
"marlett",
|
|
22040
|
+
"mt extra"
|
|
22041
|
+
]);
|
|
22042
|
+
var isSymbolFont = (font) => font !== void 0 && SYMBOL_FONTS.has(font.trim().toLowerCase());
|
|
22043
|
+
function code(argument) {
|
|
22044
|
+
if (/^0x[0-9a-f]+$/i.test(argument)) return Number.parseInt(argument.slice(2), 16);
|
|
22045
|
+
return /^\d+(\.\d*)?$/.test(argument) ? Math.trunc(Number(argument)) : Number.NaN;
|
|
22046
|
+
}
|
|
22047
|
+
function character(value, unicode, font) {
|
|
22048
|
+
if (!Number.isFinite(value) || value <= 0) return void 0;
|
|
22049
|
+
const point = unicode ? value & 65535 : value;
|
|
22050
|
+
if (point === 0) return void 0;
|
|
22051
|
+
if (isSymbolFont(font) && point < 256) return String.fromCharCode(61440 + point);
|
|
22052
|
+
if (unicode || isSymbolFont(font)) return String.fromCharCode(point);
|
|
22053
|
+
if (point < 256) return String.fromCharCode(windows1252CodePoint(point));
|
|
22054
|
+
return windows1252HighByte(point) === void 0 ? void 0 : String.fromCharCode(point);
|
|
22055
|
+
}
|
|
22056
|
+
function symbolFieldResult(instr) {
|
|
22057
|
+
const field = parseFieldInstruction(instr, {
|
|
22058
|
+
f: "arg",
|
|
22059
|
+
s: "arg",
|
|
22060
|
+
u: "flag",
|
|
22061
|
+
a: "flag",
|
|
22062
|
+
j: "flag",
|
|
22063
|
+
h: "flag"
|
|
21435
22064
|
});
|
|
21436
|
-
|
|
22065
|
+
if (field?.name !== "SYMBOL") return void 0;
|
|
22066
|
+
const font = field.switches.get("f");
|
|
22067
|
+
const fontFamily = typeof font === "string" && font.trim() ? font : void 0;
|
|
22068
|
+
const text3 = character(code(field.args[0] ?? ""), field.switches.has("u"), fontFamily);
|
|
22069
|
+
if (text3 === void 0) return { text: SYMBOL_ERROR };
|
|
22070
|
+
const size = field.switches.get("s");
|
|
22071
|
+
const points = typeof size === "string" && /^\d/.test(size) ? Math.trunc(Number.parseFloat(size)) : 0;
|
|
22072
|
+
return {
|
|
22073
|
+
text: text3,
|
|
22074
|
+
...fontFamily ? { fontFamily } : {},
|
|
22075
|
+
...points > 0 ? { fontSizePt: Math.min(points, 1638) } : {},
|
|
22076
|
+
...field.switches.has("h") ? { keepLineSpacing: true } : {}
|
|
22077
|
+
};
|
|
22078
|
+
}
|
|
22079
|
+
|
|
22080
|
+
// docx/computed-fields.ts
|
|
22081
|
+
/* @__PURE__ */ new Set([
|
|
22082
|
+
"DOCPROPERTY",
|
|
22083
|
+
...AUTO_NUMBER_FIELDS,
|
|
22084
|
+
"LISTNUM",
|
|
22085
|
+
"SYMBOL"
|
|
22086
|
+
]);
|
|
22087
|
+
function computedFields(model, options2 = {}) {
|
|
22088
|
+
let properties;
|
|
22089
|
+
let autoNumbers;
|
|
22090
|
+
let listNumbers;
|
|
22091
|
+
return {
|
|
22092
|
+
result(field, paragraph) {
|
|
22093
|
+
const name2 = fieldName(field.instr);
|
|
22094
|
+
if (name2 === "DOCPROPERTY") {
|
|
22095
|
+
const text3 = docPropertyResult(field.instr, properties ??= fieldProperties(model));
|
|
22096
|
+
const error = text3 === UNKNOWN_PROPERTY || text3 === NO_PROPERTY_NAME;
|
|
22097
|
+
return text3 === void 0 || error && !options2.errors ? void 0 : { text: text3 };
|
|
22098
|
+
}
|
|
22099
|
+
if (AUTO_NUMBER_FIELDS.has(name2)) {
|
|
22100
|
+
const state = (autoNumbers ??= autoNumberStates(model)).get(paragraph.id);
|
|
22101
|
+
const text3 = state && autoNumberResult(field.instr, state);
|
|
22102
|
+
return text3 === void 0 ? void 0 : { text: text3 };
|
|
22103
|
+
}
|
|
22104
|
+
if (name2 === "SYMBOL") {
|
|
22105
|
+
const symbol = symbolFieldResult(field.instr);
|
|
22106
|
+
return symbol && {
|
|
22107
|
+
text: symbol.text,
|
|
22108
|
+
...symbol.fontFamily ? { fontFamily: symbol.fontFamily } : {},
|
|
22109
|
+
...symbol.fontSizePt ? { fontSizePt: symbol.fontSizePt } : {}
|
|
22110
|
+
};
|
|
22111
|
+
}
|
|
22112
|
+
if (name2 === "LISTNUM") {
|
|
22113
|
+
listNumbers ??= computeListNumbering(model).listNumbers;
|
|
22114
|
+
const text3 = listNumbers.result(paragraph.id, field.from);
|
|
22115
|
+
return text3 === void 0 ? void 0 : { text: text3 };
|
|
22116
|
+
}
|
|
22117
|
+
return void 0;
|
|
22118
|
+
}
|
|
22119
|
+
};
|
|
21437
22120
|
}
|
|
21438
22121
|
|
|
21439
22122
|
// docx/diagram-theme.ts
|
|
@@ -21513,9 +22196,29 @@ function mapDocumentParagraphs(model, map) {
|
|
|
21513
22196
|
};
|
|
21514
22197
|
}
|
|
21515
22198
|
|
|
21516
|
-
// docx/
|
|
21517
|
-
function
|
|
21518
|
-
|
|
22199
|
+
// docx/compatibility.ts
|
|
22200
|
+
function compatibilityProfile(settings) {
|
|
22201
|
+
const mode = settings.compatibilityMode;
|
|
22202
|
+
return {
|
|
22203
|
+
generation: mode !== void 0 && mode >= 15 ? "modern" : "legacy",
|
|
22204
|
+
...mode !== void 0 ? { mode } : {},
|
|
22205
|
+
doNotUseHtmlParagraphAutoSpacing: settings.doNotUseHtmlParagraphAutoSpacing === true
|
|
22206
|
+
};
|
|
22207
|
+
}
|
|
22208
|
+
function addsParagraphSpacing(profile) {
|
|
22209
|
+
return profile.doNotUseHtmlParagraphAutoSpacing;
|
|
22210
|
+
}
|
|
22211
|
+
function keepsSpaceBeforePageBreak(profile) {
|
|
22212
|
+
return profile.mode !== 15;
|
|
22213
|
+
}
|
|
22214
|
+
function usesModernFootnoteLayout(profile) {
|
|
22215
|
+
return profile.mode === 15;
|
|
22216
|
+
}
|
|
22217
|
+
function attachesFootnotesToBodyColumns(profile) {
|
|
22218
|
+
return profile.mode === 12 || profile.mode === 14;
|
|
22219
|
+
}
|
|
22220
|
+
function autofitOverhangsCellMargins(profile) {
|
|
22221
|
+
return profile.generation === "legacy";
|
|
21519
22222
|
}
|
|
21520
22223
|
|
|
21521
22224
|
// docx/notes.ts
|
|
@@ -21737,100 +22440,7 @@ function reviewDocumentFormatting(model, mode) {
|
|
|
21737
22440
|
});
|
|
21738
22441
|
return { ...prior.value, runs };
|
|
21739
22442
|
});
|
|
21740
|
-
return { model: projected, diagnostics };
|
|
21741
|
-
}
|
|
21742
|
-
|
|
21743
|
-
// text/date-picture.ts
|
|
21744
|
-
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|EEEE|EEE|HH|H|hh|h|mm|m|ss|s|tt|am\/pm|AM\/PM|A\/P|a\/p|'[^']*'|"[^"]*"/g;
|
|
21745
|
-
var pad2 = (value, length = 2) => String(value).padStart(length, "0");
|
|
21746
|
-
function name(date, locale, utc, options2) {
|
|
21747
|
-
try {
|
|
21748
|
-
return new Intl.DateTimeFormat(locale, utc ? { ...options2, timeZone: "UTC" } : options2).format(
|
|
21749
|
-
date
|
|
21750
|
-
);
|
|
21751
|
-
} catch {
|
|
21752
|
-
return new Intl.DateTimeFormat("en-US", utc ? { ...options2, timeZone: "UTC" } : options2).format(
|
|
21753
|
-
date
|
|
21754
|
-
);
|
|
21755
|
-
}
|
|
21756
|
-
}
|
|
21757
|
-
function formatDatePicture(date, picture, options2 = {}) {
|
|
21758
|
-
const locale = options2.locale ?? "en-US";
|
|
21759
|
-
const utc = options2.utc ?? false;
|
|
21760
|
-
const year = utc ? date.getUTCFullYear() : date.getFullYear();
|
|
21761
|
-
const month = utc ? date.getUTCMonth() : date.getMonth();
|
|
21762
|
-
const day = utc ? date.getUTCDate() : date.getDate();
|
|
21763
|
-
const hours = utc ? date.getUTCHours() : date.getHours();
|
|
21764
|
-
const minutes = utc ? date.getUTCMinutes() : date.getMinutes();
|
|
21765
|
-
const seconds = utc ? date.getUTCSeconds() : date.getSeconds();
|
|
21766
|
-
const hours12 = hours % 12 || 12;
|
|
21767
|
-
const label = (options3) => name(date, locale, utc, options3);
|
|
21768
|
-
return picture.replace(TOKENS, (token) => {
|
|
21769
|
-
switch (token) {
|
|
21770
|
-
case "yyyy":
|
|
21771
|
-
return pad2(year, 4);
|
|
21772
|
-
case "yy":
|
|
21773
|
-
return pad2(year % 100);
|
|
21774
|
-
case "MMMM":
|
|
21775
|
-
return label({ month: "long" });
|
|
21776
|
-
case "MMM":
|
|
21777
|
-
return label({ month: "short" });
|
|
21778
|
-
case "MM":
|
|
21779
|
-
return pad2(month + 1);
|
|
21780
|
-
case "M":
|
|
21781
|
-
return String(month + 1);
|
|
21782
|
-
case "dddd":
|
|
21783
|
-
case "EEEE":
|
|
21784
|
-
return label({ weekday: "long" });
|
|
21785
|
-
case "ddd":
|
|
21786
|
-
case "EEE":
|
|
21787
|
-
return label({ weekday: "short" });
|
|
21788
|
-
case "dd":
|
|
21789
|
-
return pad2(day);
|
|
21790
|
-
case "d":
|
|
21791
|
-
return String(day);
|
|
21792
|
-
case "HH":
|
|
21793
|
-
return pad2(hours);
|
|
21794
|
-
case "H":
|
|
21795
|
-
return String(hours);
|
|
21796
|
-
case "hh":
|
|
21797
|
-
return pad2(hours12);
|
|
21798
|
-
case "h":
|
|
21799
|
-
return String(hours12);
|
|
21800
|
-
case "mm":
|
|
21801
|
-
return pad2(minutes);
|
|
21802
|
-
case "m":
|
|
21803
|
-
return String(minutes);
|
|
21804
|
-
case "ss":
|
|
21805
|
-
return pad2(seconds);
|
|
21806
|
-
case "s":
|
|
21807
|
-
return String(seconds);
|
|
21808
|
-
case "tt":
|
|
21809
|
-
case "AM/PM":
|
|
21810
|
-
return hours < 12 ? "AM" : "PM";
|
|
21811
|
-
case "am/pm":
|
|
21812
|
-
return hours < 12 ? "am" : "pm";
|
|
21813
|
-
case "A/P":
|
|
21814
|
-
return hours < 12 ? "A" : "P";
|
|
21815
|
-
case "a/p":
|
|
21816
|
-
return hours < 12 ? "a" : "p";
|
|
21817
|
-
default:
|
|
21818
|
-
return token.slice(1, -1);
|
|
21819
|
-
}
|
|
21820
|
-
});
|
|
21821
|
-
}
|
|
21822
|
-
|
|
21823
|
-
// docx/field-date.ts
|
|
21824
|
-
function datePicture(instr) {
|
|
21825
|
-
const match = /\\@\s*(?:"([^"]*)"|(\S+))/.exec(instr);
|
|
21826
|
-
return match ? match[1] ?? match[2] : void 0;
|
|
21827
|
-
}
|
|
21828
|
-
function formatWordDate(date, picture, locale = "en-US") {
|
|
21829
|
-
return formatDatePicture(date, picture, { locale });
|
|
21830
|
-
}
|
|
21831
|
-
function dateFieldResult(name2, instr, now, locale) {
|
|
21832
|
-
const picture = datePicture(instr) ?? (name2 === "DATE" ? "M/d/yyyy" : "h:mm am/pm");
|
|
21833
|
-
return formatWordDate(now, picture, locale);
|
|
22443
|
+
return { model: projected, diagnostics };
|
|
21834
22444
|
}
|
|
21835
22445
|
|
|
21836
22446
|
// docx/table-visuals.ts
|
|
@@ -21872,7 +22482,7 @@ var DEFAULT_SHAPE_LINE_EMU = 12700;
|
|
|
21872
22482
|
var isLinePreset = (preset) => /^(line|straightConnector1|bentConnector\d|curvedConnector\d)$/.test(preset);
|
|
21873
22483
|
|
|
21874
22484
|
// docx/shape-svg.ts
|
|
21875
|
-
var escapeXml = (
|
|
22485
|
+
var escapeXml = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
21876
22486
|
var round = (value) => Math.round(value * 100) / 100;
|
|
21877
22487
|
function shapeColorCss(color, theme) {
|
|
21878
22488
|
return drawingColorCss(resolveDrawingColor(color, diagramColorTheme(theme)));
|
|
@@ -21952,16 +22562,16 @@ function shapeSvg(spec, widthPx, heightPx, theme) {
|
|
|
21952
22562
|
const lines = spec.text?.some(Boolean) ? wrapShapeText(spec.text, textRect.r - textRect.l - 14) : [];
|
|
21953
22563
|
const color = shapeTextColor(fillPaint(spec.fill, theme));
|
|
21954
22564
|
const lineHeight = FONT_PX * 1.2;
|
|
21955
|
-
const
|
|
21956
|
-
const
|
|
21957
|
-
(line4, index) => `<tspan x="${round((textRect.l + textRect.r) / 2)}" y="${round(
|
|
22565
|
+
const first4 = (textRect.t + textRect.b) / 2 - (lines.length - 1) * lineHeight / 2;
|
|
22566
|
+
const text3 = lines.length ? `<text font-family="Calibri,Arial,sans-serif" font-size="${FONT_PX}" fill="${color}" text-anchor="middle" dominant-baseline="central">${lines.map(
|
|
22567
|
+
(line4, index) => `<tspan x="${round((textRect.l + textRect.r) / 2)}" y="${round(first4 + index * lineHeight)}">${escapeXml(line4)}</tspan>`
|
|
21958
22568
|
).join("")}</text>` : "";
|
|
21959
22569
|
const transform = [
|
|
21960
22570
|
spec.rotation ? `rotate(${spec.rotation} ${round(w / 2)} ${round(h / 2)})` : "",
|
|
21961
22571
|
spec.flipH || spec.flipV ? `translate(${spec.flipH ? w : 0} ${spec.flipV ? h : 0}) scale(${spec.flipH ? -1 : 1} ${spec.flipV ? -1 : 1})` : ""
|
|
21962
22572
|
].filter(Boolean).join(" ");
|
|
21963
22573
|
const label = escapeXml(lookupPresetShape(spec.preset) ? spec.preset : "Shape");
|
|
21964
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${round(w)}" height="${round(h)}" viewBox="0 0 ${round(w)} ${round(h)}" style="overflow:visible" role="img" aria-label="${label}"><g${transform ? ` transform="${escapeXml(transform)}"` : ""}>${paths}${
|
|
22574
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${round(w)}" height="${round(h)}" viewBox="0 0 ${round(w)} ${round(h)}" style="overflow:visible" role="img" aria-label="${label}"><g${transform ? ` transform="${escapeXml(transform)}"` : ""}>${paths}${text3}</g></svg>`;
|
|
21965
22575
|
}
|
|
21966
22576
|
|
|
21967
22577
|
// docx/layout/units.ts
|
|
@@ -21990,9 +22600,9 @@ function createFakeMeasurer(options2 = {}) {
|
|
|
21990
22600
|
const charWidthFactor = options2.charWidthFactor ?? 0.6;
|
|
21991
22601
|
const lineHeightFactor = options2.lineHeightFactor ?? 1.15;
|
|
21992
22602
|
return {
|
|
21993
|
-
widthOf(
|
|
22603
|
+
widthOf(text3, font) {
|
|
21994
22604
|
let width = 0;
|
|
21995
|
-
for (const ch of
|
|
22605
|
+
for (const ch of text3) {
|
|
21996
22606
|
if (ch === " " || ch === "\n") continue;
|
|
21997
22607
|
width += font.sizePx * charWidthFactor * (font.bold ? 1.08 : 1) * (ch === " " ? 0.6 : 1);
|
|
21998
22608
|
}
|
|
@@ -22010,40 +22620,155 @@ function ligatureCss(value) {
|
|
|
22010
22620
|
return `${enabled("standard") ? "common-ligatures" : "no-common-ligatures"} ${enabled("contextual") ? "contextual" : "no-contextual"} ${enabled("historical") ? "historical-ligatures" : "no-historical-ligatures"} ${enabled("discretional") ? "discretionary-ligatures" : "no-discretionary-ligatures"}`;
|
|
22011
22621
|
}
|
|
22012
22622
|
|
|
22013
|
-
//
|
|
22623
|
+
// text/complex-breaks.ts
|
|
22624
|
+
function isComplexBreakChar(ch) {
|
|
22625
|
+
const cp = ch.codePointAt(0) ?? 0;
|
|
22626
|
+
return cp >= 3584 && cp <= 3839 || // Thai, Lao
|
|
22627
|
+
cp >= 4096 && cp <= 4255 || // Myanmar
|
|
22628
|
+
cp >= 6016 && cp <= 6143 || // Khmer
|
|
22629
|
+
cp >= 6624 && cp <= 6655 || // Khmer Symbols
|
|
22630
|
+
cp >= 43488 && cp <= 43519 || // Myanmar Extended-B
|
|
22631
|
+
cp >= 43616 && cp <= 43647;
|
|
22632
|
+
}
|
|
22633
|
+
function isLeadingVowel(cp) {
|
|
22634
|
+
return cp >= 3648 && cp <= 3652 || cp >= 3776 && cp <= 3780;
|
|
22635
|
+
}
|
|
22636
|
+
function isStacker(cp) {
|
|
22637
|
+
return cp === 6098 || cp === 4153;
|
|
22638
|
+
}
|
|
22639
|
+
function complexBreakAllowed(before, after) {
|
|
22640
|
+
if (!before || !after) return false;
|
|
22641
|
+
if (!isComplexBreakChar(before) || !isComplexBreakChar(after)) return false;
|
|
22642
|
+
const last = before.codePointAt(before.length - 1) ?? 0;
|
|
22643
|
+
const lead = before.codePointAt(0) ?? 0;
|
|
22644
|
+
return !(before.length === 1 && isLeadingVowel(lead)) && !isStacker(last);
|
|
22645
|
+
}
|
|
22646
|
+
|
|
22647
|
+
// text/east-asian.ts
|
|
22014
22648
|
function isEastAsianChar(ch) {
|
|
22015
22649
|
const cp = ch.codePointAt(0) ?? 0;
|
|
22016
22650
|
return cp >= 4352 && cp <= 4607 || cp >= 11904 && cp <= 40959 || cp >= 43360 && cp <= 43391 || cp >= 44032 && cp <= 55295 || cp >= 63744 && cp <= 64255 || cp >= 65072 && cp <= 65103 || cp >= 65280 && cp <= 65519 || cp >= 131072 && cp <= 262143;
|
|
22017
22651
|
}
|
|
22018
|
-
|
|
22652
|
+
var EAST_ASIAN_LETTER = /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
22653
|
+
var LETTER = /^\p{L}/u;
|
|
22654
|
+
var DIGIT = /^\p{Nd}/u;
|
|
22655
|
+
function isEastAsianLetter(grapheme) {
|
|
22656
|
+
return EAST_ASIAN_LETTER.test(grapheme);
|
|
22657
|
+
}
|
|
22658
|
+
function westernKind(grapheme) {
|
|
22659
|
+
if (!grapheme || isEastAsianChar(grapheme)) return void 0;
|
|
22660
|
+
if (DIGIT.test(grapheme)) return "digit";
|
|
22661
|
+
return LETTER.test(grapheme) ? "alpha" : void 0;
|
|
22662
|
+
}
|
|
22663
|
+
function eastAsianAutoSpace(before, after) {
|
|
22664
|
+
if (isEastAsianLetter(before)) return westernKind(after);
|
|
22665
|
+
if (isEastAsianLetter(after)) return westernKind(before);
|
|
22666
|
+
return void 0;
|
|
22667
|
+
}
|
|
22668
|
+
var AUTO_SPACE_EM = 0.25;
|
|
22669
|
+
|
|
22670
|
+
// text/kinsoku.ts
|
|
22671
|
+
var JAPANESE = {
|
|
22672
|
+
noStart: "!%),.:;?]}\xA2\xB0\u2019\u201D\u2030\u2032\u2033\u2103\u3001\u3002\u3005\u3009\u300B\u300D\u300F\u3011\u3015\u309B\u309C\u309D\u309E\u30FB\u30FD\u30FE\uFF01\uFF05\uFF09\uFF0C\uFF0E\uFF1A\uFF1B\uFF1F\uFF3D\uFF5D\uFF61\uFF63\uFF64\uFF65\uFF9E\uFF9F\uFFE0",
|
|
22673
|
+
noEnd: "$([\\{\xA3\xA5\u2018\u201C\u3008\u300A\u300C\u300E\u3010\u3014\uFF04\uFF08\uFF3B\uFF5B\uFF62\uFFE1\uFFE5"
|
|
22674
|
+
};
|
|
22675
|
+
var JAPANESE_STRICT_EXTRA = "\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u30FC\uFF67\uFF68\uFF69\uFF6A\uFF6B\uFF6C\uFF6D\uFF6E\uFF6F\uFF70";
|
|
22676
|
+
var DEFAULTS = {
|
|
22677
|
+
ja: JAPANESE,
|
|
22678
|
+
"zh-Hans": {
|
|
22679
|
+
noStart: "!%),.:;>?]}\xA2\xA8\xB0\xB7\u2015\u2016\u2019\u201D\u2026\u2030\u2032\u2033\u203A\u2103\u3001\u3002\u3003\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u301E\uFE36\uFE3A\uFE3E\uFE40\uFE44\uFE5A\uFE5C\uFE5E\uFF01\uFF02\uFF05\uFF07\uFF09\uFF0C\uFF0E\uFF1A\uFF1B\uFF1F\uFF3D\uFF40\uFF5C\uFF5D\uFF5E\uFFE0",
|
|
22680
|
+
noEnd: "$([{\xA3\xA5\xB7\u2018\u201C\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u301D\uFE59\uFE5B\uFE5D\uFF04\uFF08\uFF0E\uFF3B\uFF5B\uFFE1\uFFE5"
|
|
22681
|
+
},
|
|
22682
|
+
"zh-Hant": {
|
|
22683
|
+
noStart: "!),.:;?]}\xA2\xB7\u2019\u201D\u2022\u2025\u2026\u2027\u2032\u3001\u3002\u3009\u300B\u300D\u300F\u3011\u3015\u301E\uFE30\uFE31\uFE33\uFE34\uFE36\uFE38\uFE3A\uFE3C\uFE3E\uFE40\uFE42\uFE44\uFE4F\uFE50\uFE51\uFE52\uFE54\uFE55\uFE56\uFE57\uFE5A\uFE5C\uFE5E\uFF01\uFF09\uFF0C\uFF0E\uFF1A\uFF1B\uFF1F\uFF3D\uFF5C\uFF5D\uFF64",
|
|
22684
|
+
noEnd: "([{\xA3\xA5\u2018\u201C\u2035\u3008\u300A\u300C\u300E\u3010\u3014\u301D\uFE35\uFE37\uFE39\uFE3B\uFE3D\uFE3F\uFE41\uFE43\uFE59\uFE5B\uFE5D\uFF08\uFF5B"
|
|
22685
|
+
},
|
|
22686
|
+
ko: { noStart: "", noEnd: "" }
|
|
22687
|
+
};
|
|
22688
|
+
function kinsokuLanguage(tag) {
|
|
22689
|
+
if (!tag) return void 0;
|
|
22690
|
+
const lower = tag.toLowerCase();
|
|
22691
|
+
const [primary] = lower.split(/[-_]/);
|
|
22692
|
+
if (primary === "ja") return "ja";
|
|
22693
|
+
if (primary === "ko") return "ko";
|
|
22694
|
+
if (primary !== "zh") return void 0;
|
|
22695
|
+
return /-(hant|tw|hk|mo)(-|$)/.test(lower) ? "zh-Hant" : "zh-Hans";
|
|
22696
|
+
}
|
|
22697
|
+
function kinsokuSets(language, settings = {}) {
|
|
22698
|
+
const base = DEFAULTS[language];
|
|
22699
|
+
const custom2 = (override) => override && kinsokuLanguage(override.language) === language ? override.chars : void 0;
|
|
22700
|
+
const strictExtra = settings.strict && language === "ja" ? JAPANESE_STRICT_EXTRA : "";
|
|
22701
|
+
return {
|
|
22702
|
+
noStart: custom2(settings.noLineBreaksBefore) ?? base.noStart + strictExtra,
|
|
22703
|
+
noEnd: custom2(settings.noLineBreaksAfter) ?? base.noEnd
|
|
22704
|
+
};
|
|
22705
|
+
}
|
|
22706
|
+
var first3 = (text3) => String.fromCodePoint(text3.codePointAt(0) ?? 0);
|
|
22707
|
+
function prohibitedAtLineStart(grapheme, sets) {
|
|
22708
|
+
return grapheme.length > 0 && sets.noStart.includes(first3(grapheme));
|
|
22709
|
+
}
|
|
22710
|
+
function prohibitedAtLineEnd(grapheme, sets) {
|
|
22711
|
+
return grapheme.length > 0 && sets.noEnd.includes(first3(grapheme));
|
|
22712
|
+
}
|
|
22713
|
+
var HANGING = {
|
|
22714
|
+
ja: ",.\u2019\u201D\u3001\u3002\u300D\u300F\u3011\uFF09\uFF0C\uFF0E\uFF3D\uFF5D\uFF61\uFF64",
|
|
22715
|
+
"zh-Hans": "!%),.:;>?]}\xA2\xB0\u2019\u201D\u2030\u2032\u2033\u2103\u3001\u3002\u3003\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u301E\uFE5A\uFE5C\uFE5E\uFF01\uFF02\uFF05\uFF07\uFF09\uFF0C\uFF1A\uFF1B\uFF1F\uFF3D\uFF5D\uFFE0",
|
|
22716
|
+
"zh-Hant": "!),.:;?]}\u2019\u201D\u2032\u3001\u3002\u3009\u300B\u300D\u300F\u3011\u3015\u301E\uFE5A\uFE5C\uFE5E\uFF01\uFF09\uFF0C\uFF0E\uFF1A\uFF1B\uFF1F\uFF3D\uFF5D",
|
|
22717
|
+
ko: ""
|
|
22718
|
+
};
|
|
22719
|
+
function hangsAtLineEnd(grapheme, language) {
|
|
22720
|
+
return grapheme.length > 0 && HANGING[language].includes(first3(grapheme));
|
|
22721
|
+
}
|
|
22722
|
+
|
|
22723
|
+
// docx/layout/text-breaks.ts
|
|
22724
|
+
var ZERO_WIDTH_SPACE = "\u200B";
|
|
22725
|
+
function breakAllowedBetween(before, after) {
|
|
22726
|
+
if (!before || !after) return false;
|
|
22727
|
+
if (before === "-" || before.endsWith(ZERO_WIDTH_SPACE)) return true;
|
|
22728
|
+
return isEastAsianChar(before) || isEastAsianChar(after) || complexBreakAllowed(before, after);
|
|
22729
|
+
}
|
|
22730
|
+
function kinsokuForbids(before, after, beforeSets, afterSets) {
|
|
22731
|
+
return afterSets !== void 0 && prohibitedAtLineStart(after, afterSets) || beforeSets !== void 0 && prohibitedAtLineEnd(before, beforeSets);
|
|
22732
|
+
}
|
|
22733
|
+
var graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
22734
|
+
function graphemesOf(text3) {
|
|
22735
|
+
return [...graphemeSegmenter.segment(text3)].map((part) => part.segment);
|
|
22736
|
+
}
|
|
22737
|
+
function tokenizeRun(text3, runIndex, kinsoku) {
|
|
22019
22738
|
const tokens = [];
|
|
22020
22739
|
let word = "";
|
|
22021
22740
|
let wordStart = 0;
|
|
22741
|
+
let glue;
|
|
22742
|
+
let previous = "";
|
|
22022
22743
|
const flushWord = () => {
|
|
22023
|
-
if (word)
|
|
22744
|
+
if (word)
|
|
22745
|
+
tokens.push({
|
|
22746
|
+
kind: "word",
|
|
22747
|
+
text: word,
|
|
22748
|
+
runIndex,
|
|
22749
|
+
sourceStart: wordStart,
|
|
22750
|
+
...glue ? { glue } : {}
|
|
22751
|
+
});
|
|
22024
22752
|
word = "";
|
|
22753
|
+
glue = void 0;
|
|
22025
22754
|
};
|
|
22026
|
-
const chars = [...new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(text2)].map(
|
|
22027
|
-
(part) => part.segment
|
|
22028
|
-
);
|
|
22029
22755
|
let offset = 0;
|
|
22030
|
-
for (const ch of
|
|
22031
|
-
if (ch === "\n") {
|
|
22032
|
-
flushWord();
|
|
22033
|
-
tokens.push({ kind: "lineBreak", runIndex, sourceStart: offset });
|
|
22034
|
-
} else if (ch === " ") {
|
|
22035
|
-
flushWord();
|
|
22036
|
-
tokens.push({ kind: "tab", runIndex, sourceStart: offset });
|
|
22037
|
-
} else if (ch === " ") {
|
|
22756
|
+
for (const ch of graphemesOf(text3)) {
|
|
22757
|
+
if (ch === "\n" || ch === " " || ch === " ") {
|
|
22038
22758
|
flushWord();
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
tokens.push({ kind: "
|
|
22759
|
+
previous = "";
|
|
22760
|
+
if (ch === "\n") tokens.push({ kind: "lineBreak", runIndex, sourceStart: offset });
|
|
22761
|
+
else if (ch === " ") tokens.push({ kind: "tab", runIndex, sourceStart: offset });
|
|
22762
|
+
else tokens.push({ kind: "space", text: ch, runIndex, sourceStart: offset });
|
|
22043
22763
|
} else {
|
|
22764
|
+
if (word && breakAllowedBetween(previous, ch)) {
|
|
22765
|
+
const kept = kinsokuForbids(previous, ch, kinsoku, kinsoku);
|
|
22766
|
+
flushWord();
|
|
22767
|
+
if (kept) glue = "kinsoku";
|
|
22768
|
+
}
|
|
22044
22769
|
if (!word) wordStart = offset;
|
|
22045
22770
|
word += ch;
|
|
22046
|
-
|
|
22771
|
+
previous = ch;
|
|
22047
22772
|
}
|
|
22048
22773
|
offset += ch.length;
|
|
22049
22774
|
}
|
|
@@ -22053,8 +22778,22 @@ function tokenizeRun(text2, runIndex) {
|
|
|
22053
22778
|
function appendBreakMarker(tokens, runIndex, sourceStart, kind) {
|
|
22054
22779
|
tokens.push({ kind: kind === "page" ? "pageBreak" : "columnBreak", runIndex, sourceStart });
|
|
22055
22780
|
}
|
|
22781
|
+
function gluedCarry(tokens, index, placed2) {
|
|
22782
|
+
let carry = 0;
|
|
22783
|
+
for (let current = index; ; current--) {
|
|
22784
|
+
const token = tokens[current];
|
|
22785
|
+
if (token?.kind !== "word" || !token.glue) return carry;
|
|
22786
|
+
const previous = placed2[placed2.length - 1 - carry];
|
|
22787
|
+
if (!previous || previous !== tokens[current - 1]) return carry;
|
|
22788
|
+
carry++;
|
|
22789
|
+
if (carry >= placed2.length) return 0;
|
|
22790
|
+
}
|
|
22791
|
+
}
|
|
22056
22792
|
|
|
22057
22793
|
// docx/layout/result.ts
|
|
22794
|
+
function inFlow(block) {
|
|
22795
|
+
return block.kind !== "table" || !block.floating;
|
|
22796
|
+
}
|
|
22058
22797
|
function cellVerticalOffset(geometry, rowHeightPx) {
|
|
22059
22798
|
const free = Math.max(0, (geometry.alignmentHeightPx ?? rowHeightPx) - geometry.contentHeightPx);
|
|
22060
22799
|
return geometry.verticalAlign === "center" ? free / 2 : geometry.verticalAlign === "bottom" ? free : 0;
|
|
@@ -22104,11 +22843,11 @@ function pageNumbers(model, pages) {
|
|
|
22104
22843
|
);
|
|
22105
22844
|
}
|
|
22106
22845
|
function sectionPageCounts(pages) {
|
|
22107
|
-
const
|
|
22846
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
22108
22847
|
for (const page of pages)
|
|
22109
22848
|
for (const index of page.sectionIndices ?? [page.sectionIndex])
|
|
22110
|
-
|
|
22111
|
-
return
|
|
22849
|
+
counts2.set(index, (counts2.get(index) ?? 0) + 1);
|
|
22850
|
+
return counts2;
|
|
22112
22851
|
}
|
|
22113
22852
|
function headerFooterSlotForPage(model, page, pageNumber) {
|
|
22114
22853
|
const section = model.sections?.[page.sectionIndex];
|
|
@@ -22205,9 +22944,9 @@ function pageStyleRefs(model, pages) {
|
|
|
22205
22944
|
last = pagesOf.get(at)?.at(-1) ?? last;
|
|
22206
22945
|
}
|
|
22207
22946
|
const firstAfter = [];
|
|
22208
|
-
for (let at = count - 1,
|
|
22209
|
-
firstAfter[at] =
|
|
22210
|
-
|
|
22947
|
+
for (let at = count - 1, first4 = pages.length; at >= 0; at--) {
|
|
22948
|
+
firstAfter[at] = first4;
|
|
22949
|
+
first4 = pagesOf.get(at)?.[0] ?? first4;
|
|
22211
22950
|
}
|
|
22212
22951
|
const placed2 = [];
|
|
22213
22952
|
for (const [at, found] of portions) {
|
|
@@ -22278,13 +23017,13 @@ function pageStyleRefs(model, pages) {
|
|
|
22278
23017
|
// docx/layout/tab-stops.ts
|
|
22279
23018
|
function placeTab(positionPx, stops, hangingStopPx, followingPx, beforeDecimalPx) {
|
|
22280
23019
|
const epsilon = 0.5;
|
|
22281
|
-
const
|
|
22282
|
-
if (
|
|
22283
|
-
const distance =
|
|
22284
|
-
const shift =
|
|
23020
|
+
const custom2 = stops.filter((stop) => stop.align !== "clear" && stop.align !== "bar").sort((a, b) => a.posPx - b.posPx).find((stop) => stop.posPx > positionPx + epsilon);
|
|
23021
|
+
if (custom2) {
|
|
23022
|
+
const distance = custom2.posPx - positionPx;
|
|
23023
|
+
const shift = custom2.align === "right" || custom2.align === "end" ? followingPx : custom2.align === "center" ? followingPx / 2 : custom2.align === "decimal" ? beforeDecimalPx : 0;
|
|
22285
23024
|
return {
|
|
22286
23025
|
widthPx: Math.max(0, distance - shift),
|
|
22287
|
-
...
|
|
23026
|
+
...custom2.leader && custom2.leader !== "none" ? { leader: custom2.leader } : {}
|
|
22288
23027
|
};
|
|
22289
23028
|
}
|
|
22290
23029
|
if (hangingStopPx !== void 0 && hangingStopPx > positionPx + epsilon)
|
|
@@ -22315,14 +23054,14 @@ function fontOf(run) {
|
|
|
22315
23054
|
};
|
|
22316
23055
|
}
|
|
22317
23056
|
var graphemes2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
22318
|
-
function runTextWidth(
|
|
23057
|
+
function runTextWidth(text3, run, measurer, font = fontOf(run)) {
|
|
22319
23058
|
let characters = 0;
|
|
22320
23059
|
if (run.characterSpacingPx) {
|
|
22321
|
-
for (const _segment of graphemes2.segment(
|
|
23060
|
+
for (const _segment of graphemes2.segment(text3)) characters++;
|
|
22322
23061
|
}
|
|
22323
23062
|
return Math.max(
|
|
22324
23063
|
0,
|
|
22325
|
-
measurer.widthOf(
|
|
23064
|
+
measurer.widthOf(text3, font) * (run.textScalePercent ?? 100) / 100 + characters * (run.characterSpacingPx ?? 0)
|
|
22326
23065
|
);
|
|
22327
23066
|
}
|
|
22328
23067
|
function resolveIndents(paragraph) {
|
|
@@ -22341,11 +23080,56 @@ function resolveIndents(paragraph) {
|
|
|
22341
23080
|
function sourceLengthOf(run) {
|
|
22342
23081
|
return run.sourceLength ?? (run.object ? 1 : run.text.length || (run.breakAfter ? 1 : 0));
|
|
22343
23082
|
}
|
|
23083
|
+
function runKinsoku(paragraph, run) {
|
|
23084
|
+
if (paragraph.kinsoku === false || !run?.kinsokuLanguage || run.synthetic) return void 0;
|
|
23085
|
+
return kinsokuSets(run.kinsokuLanguage, paragraph.kinsokuSettings);
|
|
23086
|
+
}
|
|
23087
|
+
function glueAcrossRuns(paragraph, tokens, start) {
|
|
23088
|
+
const token = tokens[start];
|
|
23089
|
+
const previous = tokens[start - 1];
|
|
23090
|
+
if (token?.kind !== "word" || previous?.kind !== "word") return;
|
|
23091
|
+
const before = paragraph.runs[previous.runIndex];
|
|
23092
|
+
const after = paragraph.runs[token.runIndex];
|
|
23093
|
+
if (before?.synthetic || before?.marker) return;
|
|
23094
|
+
const last = graphemesOf(previous.text).at(-1) ?? "";
|
|
23095
|
+
const first4 = graphemesOf(token.text)[0] ?? "";
|
|
23096
|
+
if (!breakAllowedBetween(last, first4)) token.glue = "word";
|
|
23097
|
+
else if (kinsokuForbids(last, first4, runKinsoku(paragraph, before), runKinsoku(paragraph, after)))
|
|
23098
|
+
token.glue = "kinsoku";
|
|
23099
|
+
}
|
|
23100
|
+
function applyAutoSpace(paragraph, tokens) {
|
|
23101
|
+
if (paragraph.autoSpaceDE === false && paragraph.autoSpaceDN === false) return;
|
|
23102
|
+
for (let index = 1; index < tokens.length; index++) {
|
|
23103
|
+
const previous = tokens[index - 1];
|
|
23104
|
+
const token = tokens[index];
|
|
23105
|
+
if (previous?.kind !== "word" || token?.kind !== "word") continue;
|
|
23106
|
+
const run = paragraph.runs[previous.runIndex];
|
|
23107
|
+
if (!run || run.synthetic || paragraph.runs[token.runIndex]?.synthetic) continue;
|
|
23108
|
+
const kind = eastAsianAutoSpace(
|
|
23109
|
+
graphemesOf(previous.text).at(-1) ?? "",
|
|
23110
|
+
graphemesOf(token.text)[0] ?? ""
|
|
23111
|
+
);
|
|
23112
|
+
if (!kind || (kind === "alpha" ? paragraph.autoSpaceDE : paragraph.autoSpaceDN) === false)
|
|
23113
|
+
continue;
|
|
23114
|
+
previous.spaceAfterPx = fontOf(run).sizePx * AUTO_SPACE_EM;
|
|
23115
|
+
}
|
|
23116
|
+
}
|
|
23117
|
+
function hangsPastLineEnd(paragraph, tokens, index) {
|
|
23118
|
+
const token = tokens[index];
|
|
23119
|
+
if (token?.kind !== "word" || token.glue !== "kinsoku") return false;
|
|
23120
|
+
if (paragraph.overflowPunct === false || paragraph.align !== "justify") return false;
|
|
23121
|
+
const language = paragraph.runs[token.runIndex]?.kinsokuLanguage;
|
|
23122
|
+
const [mark, ...rest] = graphemesOf(token.text);
|
|
23123
|
+
if (!language || !mark || rest.length || !hangsAtLineEnd(mark, language)) return false;
|
|
23124
|
+
const next = tokens[index + 1];
|
|
23125
|
+
return !(next?.kind === "word" && next.glue);
|
|
23126
|
+
}
|
|
22344
23127
|
function tokenizeParagraph(paragraph) {
|
|
22345
23128
|
const tokens = [];
|
|
22346
23129
|
const runOffsets = [];
|
|
22347
23130
|
let cursor = 0;
|
|
22348
23131
|
paragraph.runs.forEach((run, runIndex) => {
|
|
23132
|
+
const start = tokens.length;
|
|
22349
23133
|
runOffsets.push(cursor);
|
|
22350
23134
|
if (run.hidden) {
|
|
22351
23135
|
if (!run.synthetic) cursor += sourceLengthOf(run);
|
|
@@ -22360,12 +23144,16 @@ function tokenizeParagraph(paragraph) {
|
|
|
22360
23144
|
text: run.text.slice(0, run.marker.length)
|
|
22361
23145
|
});
|
|
22362
23146
|
tokens.push(...tokenizeRun(run.text.slice(run.marker.length), runIndex));
|
|
22363
|
-
} else
|
|
23147
|
+
} else {
|
|
23148
|
+
tokens.push(...tokenizeRun(run.text, runIndex, runKinsoku(paragraph, run)));
|
|
23149
|
+
glueAcrossRuns(paragraph, tokens, start);
|
|
23150
|
+
}
|
|
22364
23151
|
if (run.breakAfter) appendBreakMarker(tokens, runIndex, run.text.length, run.breakAfter);
|
|
22365
23152
|
if (run.synthetic) {
|
|
22366
23153
|
for (const token of tokens) if (token.runIndex === runIndex) token.sourceStart = 0;
|
|
22367
23154
|
} else cursor += sourceLengthOf(run);
|
|
22368
23155
|
});
|
|
23156
|
+
applyAutoSpace(paragraph, tokens);
|
|
22369
23157
|
return { tokens, runOffsets };
|
|
22370
23158
|
}
|
|
22371
23159
|
|
|
@@ -22408,9 +23196,9 @@ function buildFragments(tokensOnLine, paragraph) {
|
|
|
22408
23196
|
let x = 0;
|
|
22409
23197
|
for (const { token, widthPx, leader, xOffsetPx, advancePx } of tokensOnLine) {
|
|
22410
23198
|
const run = paragraph.runs[token.runIndex];
|
|
22411
|
-
const
|
|
23199
|
+
const text3 = token.kind === "word" || token.kind === "space" ? token.text : "";
|
|
22412
23200
|
fragments.push({
|
|
22413
|
-
text:
|
|
23201
|
+
text: text3,
|
|
22414
23202
|
xPx: x + (xOffsetPx ?? 0),
|
|
22415
23203
|
widthPx,
|
|
22416
23204
|
runIndex: token.runIndex,
|
|
@@ -22466,10 +23254,10 @@ function registerParagraphCache(measurer) {
|
|
|
22466
23254
|
sessions.set(measurer, /* @__PURE__ */ new Map());
|
|
22467
23255
|
}
|
|
22468
23256
|
function cachedParagraphLayout(measurer, key, note, compute) {
|
|
22469
|
-
const
|
|
22470
|
-
if (!
|
|
23257
|
+
const cache3 = sessions.get(measurer);
|
|
23258
|
+
if (!cache3) return compute(note);
|
|
22471
23259
|
const { index, signature } = key();
|
|
22472
|
-
const cached =
|
|
23260
|
+
const cached = cache3.get(index);
|
|
22473
23261
|
if (cached?.signature === signature) {
|
|
22474
23262
|
for (const warning of cached.warnings) note(warning);
|
|
22475
23263
|
return structuredClone(cached.result);
|
|
@@ -22479,8 +23267,8 @@ function cachedParagraphLayout(measurer, key, note, compute) {
|
|
|
22479
23267
|
warnings.push(warning);
|
|
22480
23268
|
note(warning);
|
|
22481
23269
|
});
|
|
22482
|
-
if (!
|
|
22483
|
-
|
|
23270
|
+
if (!cache3.has(index) && cache3.size >= 4e3) cache3.delete(cache3.keys().next().value);
|
|
23271
|
+
cache3.set(index, { signature, result: structuredClone(result), warnings });
|
|
22484
23272
|
return result;
|
|
22485
23273
|
}
|
|
22486
23274
|
|
|
@@ -22590,6 +23378,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
22590
23378
|
return { followingPx, beforeDecimalPx: beforeDecimalPx ?? followingPx };
|
|
22591
23379
|
}
|
|
22592
23380
|
const hangingStopPx = firstLineExtraPx < 0 ? leftPx : void 0;
|
|
23381
|
+
const placedTokens = () => placed2.map((entry) => entry.token);
|
|
23382
|
+
const hangingPx = /* @__PURE__ */ new Map();
|
|
22593
23383
|
function flushLine(forceEmpty, forcedByBreak) {
|
|
22594
23384
|
if (!placed2.length && !forceEmpty) return;
|
|
22595
23385
|
const lineIndex = lines.length;
|
|
@@ -22636,8 +23426,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
22636
23426
|
jump = void 0;
|
|
22637
23427
|
marginReachPx = 0;
|
|
22638
23428
|
}
|
|
22639
|
-
for (
|
|
22640
|
-
|
|
23429
|
+
for (let tokenIndex = startToken; tokenIndex < tokens.length; tokenIndex++) {
|
|
23430
|
+
const token = expectDefined(tokens[tokenIndex], "token index");
|
|
22641
23431
|
tokenCursor = tokenIndex + 1;
|
|
22642
23432
|
if (token.kind === "lineBreak") {
|
|
22643
23433
|
if (!placed2.length) firstToken = tokenIndex;
|
|
@@ -22654,6 +23444,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
22654
23444
|
const marker = paragraph.runs[token.runIndex]?.marker;
|
|
22655
23445
|
const markerFactor = marker && token.kind === "word" && tokenIndex === 0 ? marker.alignment === "right" ? 1 : marker.alignment === "center" ? 0.5 : 0 : 0;
|
|
22656
23446
|
const advance = width * (1 - markerFactor);
|
|
23447
|
+
const spacePx = token.kind === "word" ? token.spaceAfterPx ?? 0 : 0;
|
|
22657
23448
|
const positional = token.kind === "tab" && paragraph.runs[token.runIndex]?.positionalTab;
|
|
22658
23449
|
if (positional) {
|
|
22659
23450
|
const { followingPx } = segmentAfter(tokenIndex);
|
|
@@ -22693,9 +23484,19 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
22693
23484
|
const fits = lineWidthPx + (token.kind === "tab" ? width : advance) <= limit + squeezePx;
|
|
22694
23485
|
const wouldFit = fits || placed2.every((placed3) => paragraph.runs[placed3.token.runIndex]?.synthetic);
|
|
22695
23486
|
const pastHole = !fits && hole && !jump && token.kind === "word" ? hole.endPx - lineStart(lineIndex) - lineWidthPx : void 0;
|
|
23487
|
+
const hanging = !wouldFit && !hole && !jump && placed2.length > 0 && hangsPastLineEnd(paragraph, tokens, tokenIndex);
|
|
23488
|
+
if (hanging) hangingPx.set(lineIndex, advance);
|
|
22696
23489
|
if (pastHole !== void 0 && lineWidthPx + pastHole + advance <= availableWidth(lineIndex)) {
|
|
22697
23490
|
jump = { index: placed2.length, shiftPx: pastHole };
|
|
22698
|
-
} else if (!wouldFit && token.kind !== "space") {
|
|
23491
|
+
} else if (!wouldFit && token.kind !== "space" && !hanging) {
|
|
23492
|
+
const carry = jump ? 0 : gluedCarry(tokens, tokenIndex, placedTokens());
|
|
23493
|
+
if (carry) {
|
|
23494
|
+
placed2.splice(placed2.length - carry);
|
|
23495
|
+
tokenCursor = tokenIndex - carry;
|
|
23496
|
+
flushLine(false, void 0);
|
|
23497
|
+
tokenIndex -= carry + 1;
|
|
23498
|
+
continue;
|
|
23499
|
+
}
|
|
22699
23500
|
tokenCursor = tokenIndex;
|
|
22700
23501
|
flushLine(false, void 0);
|
|
22701
23502
|
tokenCursor = tokenIndex + 1;
|
|
@@ -22712,9 +23513,10 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
22712
23513
|
token,
|
|
22713
23514
|
widthPx: width,
|
|
22714
23515
|
...leader ? { leader } : {},
|
|
22715
|
-
...markerFactor ? { xOffsetPx: -width * markerFactor
|
|
23516
|
+
...markerFactor ? { xOffsetPx: -width * markerFactor } : {},
|
|
23517
|
+
...markerFactor || spacePx ? { advancePx: advance + spacePx } : {}
|
|
22716
23518
|
});
|
|
22717
|
-
lineWidthPx += token.kind === "tab" ? width : advance;
|
|
23519
|
+
lineWidthPx += token.kind === "tab" ? width : advance + spacePx;
|
|
22718
23520
|
if (token.kind === "space") lineSpacePx += advance;
|
|
22719
23521
|
}
|
|
22720
23522
|
flushLine(lines.length === 0, void 0);
|
|
@@ -22724,7 +23526,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
22724
23526
|
...line4,
|
|
22725
23527
|
fragments: alignFragments(
|
|
22726
23528
|
line4.fragments,
|
|
22727
|
-
availableWidth(index),
|
|
23529
|
+
availableWidth(index) + (hangingPx.get(index) ?? 0),
|
|
22728
23530
|
index === lastIndex,
|
|
22729
23531
|
// A line that runs around a picture is not aligned across it.
|
|
22730
23532
|
boxes[index]?.hole ? "left" : effectiveAlign
|
|
@@ -22802,9 +23604,9 @@ function nestedFrameProfile(table, tableWidthPx = table.widthPx, merges = false)
|
|
|
22802
23604
|
const gridKnown = merges && table.rows.every(
|
|
22803
23605
|
(row2) => row2.cells.every((cell) => cell.xPx !== void 0 && cell.widthPx !== void 0)
|
|
22804
23606
|
);
|
|
22805
|
-
const
|
|
23607
|
+
const first4 = table.rows[0], left = first4.cells[0].borders.left, right = first4.cells.at(-1).borders.right;
|
|
22806
23608
|
for (const [index, row2] of table.rows.entries()) {
|
|
22807
|
-
if (!gridKnown && row2.cells.length !==
|
|
23609
|
+
if (!gridKnown && row2.cells.length !== first4.cells.length || !equal(row2.cells[0]?.borders?.left, left) || !equal(row2.cells.at(-1)?.borders?.right, right))
|
|
22808
23610
|
return void 0;
|
|
22809
23611
|
for (const [column, cell] of row2.cells.entries()) {
|
|
22810
23612
|
const sourceWidth = cell.widthPx ?? (tableWidthPx === void 0 ? void 0 : tableWidthPx / row2.cells.length);
|
|
@@ -22877,6 +23679,276 @@ function cellContentBottom(boxes, paddingBottom = 0) {
|
|
|
22877
23679
|
);
|
|
22878
23680
|
}
|
|
22879
23681
|
|
|
23682
|
+
// docx/layout/table-autofit-measure.ts
|
|
23683
|
+
var TWIP_PX = 1 / 15;
|
|
23684
|
+
var EMPTY_CONTENT_PX = 6 * TWIP_PX;
|
|
23685
|
+
var ceilTwips = (px) => Math.ceil(px / TWIP_PX - 1e-6) * TWIP_PX;
|
|
23686
|
+
function breaksBetween(previous, next) {
|
|
23687
|
+
if (previous.kind !== "word" || next.kind !== "word") return true;
|
|
23688
|
+
if (previous.runIndex === next.runIndex) return true;
|
|
23689
|
+
const last = [...previous.text].at(-1) ?? "";
|
|
23690
|
+
const firstChar = [...next.text][0] ?? "";
|
|
23691
|
+
return last === "-" || isEastAsianChar(last) || isEastAsianChar(firstChar);
|
|
23692
|
+
}
|
|
23693
|
+
function paragraphRange(paragraph, measurer) {
|
|
23694
|
+
const { leftPx, rightPx, firstLineExtraPx } = resolveIndents(paragraph);
|
|
23695
|
+
const fonts = paragraph.runs.map(fontOf);
|
|
23696
|
+
const { tokens } = tokenizeParagraph(paragraph);
|
|
23697
|
+
const widthOf = (token) => {
|
|
23698
|
+
const run = paragraph.runs[token.runIndex];
|
|
23699
|
+
if (!run) return 0;
|
|
23700
|
+
if (token.kind === "object") return run.object?.widthPx ?? 0;
|
|
23701
|
+
if (token.kind !== "word" && token.kind !== "space") return 0;
|
|
23702
|
+
if (run.marker?.widthPx !== void 0 && token.kind === "word" && token.sourceStart === 0) {
|
|
23703
|
+
if (token.text === run.text.slice(0, run.marker.length)) return run.marker.widthPx;
|
|
23704
|
+
}
|
|
23705
|
+
return runTextWidth(token.text, run, measurer, fonts[token.runIndex]);
|
|
23706
|
+
};
|
|
23707
|
+
const hangingStopPx = firstLineExtraPx < 0 ? leftPx : void 0;
|
|
23708
|
+
let minPx = 0;
|
|
23709
|
+
let maxPx = 0;
|
|
23710
|
+
let line4 = Math.max(0, firstLineExtraPx);
|
|
23711
|
+
let trailingSpace = 0;
|
|
23712
|
+
let chunk = 0;
|
|
23713
|
+
let previous;
|
|
23714
|
+
const endLine = () => {
|
|
23715
|
+
maxPx = Math.max(maxPx, line4 - trailingSpace);
|
|
23716
|
+
line4 = 0;
|
|
23717
|
+
trailingSpace = 0;
|
|
23718
|
+
};
|
|
23719
|
+
for (const token of tokens) {
|
|
23720
|
+
const width = widthOf(token);
|
|
23721
|
+
if (token.kind === "word" || token.kind === "object") {
|
|
23722
|
+
chunk = previous && !breaksBetween(previous, token) ? chunk + width : width;
|
|
23723
|
+
minPx = Math.max(minPx, chunk);
|
|
23724
|
+
line4 += width;
|
|
23725
|
+
trailingSpace = 0;
|
|
23726
|
+
} else if (token.kind === "space") {
|
|
23727
|
+
line4 += width;
|
|
23728
|
+
trailingSpace += width;
|
|
23729
|
+
} else if (token.kind === "tab") {
|
|
23730
|
+
line4 += placeTab(line4, paragraph.tabStops ?? [], hangingStopPx, 0, 0).widthPx;
|
|
23731
|
+
trailingSpace = 0;
|
|
23732
|
+
} else endLine();
|
|
23733
|
+
previous = token.kind === "word" || token.kind === "object" ? token : void 0;
|
|
23734
|
+
}
|
|
23735
|
+
endLine();
|
|
23736
|
+
const indents = leftPx + rightPx;
|
|
23737
|
+
return { minPx: minPx + indents, maxPx: maxPx + indents };
|
|
23738
|
+
}
|
|
23739
|
+
function blocksRange(blocks, measurer, nestedTable) {
|
|
23740
|
+
let minPx = 0;
|
|
23741
|
+
let maxPx = 0;
|
|
23742
|
+
for (const block of blocks) {
|
|
23743
|
+
const range = block.kind === "paragraph" ? paragraphRange(block, measurer) : nestedTable(block);
|
|
23744
|
+
minPx = Math.max(minPx, range.minPx);
|
|
23745
|
+
maxPx = Math.max(maxPx, range.maxPx);
|
|
23746
|
+
}
|
|
23747
|
+
return { minPx, maxPx };
|
|
23748
|
+
}
|
|
23749
|
+
function cellRange(cell, measurer, nestedTable) {
|
|
23750
|
+
const content = blocksRange(cell.blocks ?? cell.paragraphs, measurer, nestedTable);
|
|
23751
|
+
const margins = (cell.padding?.left ?? 0) + (cell.padding?.right ?? 0);
|
|
23752
|
+
const maxPx = content.maxPx > 0 ? content.maxPx : EMPTY_CONTENT_PX;
|
|
23753
|
+
const minPx = content.minPx > 0 ? content.minPx : Math.min(maxPx, EMPTY_CONTENT_PX);
|
|
23754
|
+
return { minPx: ceilTwips(minPx + margins), maxPx: ceilTwips(Math.max(minPx, maxPx) + margins) };
|
|
23755
|
+
}
|
|
23756
|
+
|
|
23757
|
+
// docx/layout/table-autofit-distribute.ts
|
|
23758
|
+
var toTwips = (px) => Math.round(px * 15);
|
|
23759
|
+
function interpolate(from, to, total) {
|
|
23760
|
+
const low = from.reduce((sum, value) => sum + value, 0);
|
|
23761
|
+
const high = to.reduce((sum, value) => sum + value, 0);
|
|
23762
|
+
const k = high > low ? Math.min(1, Math.max(0, (total - low) / (high - low))) : 0;
|
|
23763
|
+
return from.map((value, index) => value + (to[index] - value) * k);
|
|
23764
|
+
}
|
|
23765
|
+
function roundToTotal(widths) {
|
|
23766
|
+
const total = Math.round(widths.reduce((sum, value) => sum + value, 0));
|
|
23767
|
+
const floors = widths.map(Math.floor);
|
|
23768
|
+
let spare = total - floors.reduce((sum, value) => sum + value, 0);
|
|
23769
|
+
const order = widths.map((value, index) => ({ index, rest: value - Math.floor(value) })).sort((a, b) => b.rest - a.rest);
|
|
23770
|
+
for (const { index } of order) {
|
|
23771
|
+
if (spare <= 0) break;
|
|
23772
|
+
floors[index] += 1;
|
|
23773
|
+
spare -= 1;
|
|
23774
|
+
}
|
|
23775
|
+
return floors;
|
|
23776
|
+
}
|
|
23777
|
+
function distributeColumns(columns, target) {
|
|
23778
|
+
if (!columns.length) return [];
|
|
23779
|
+
const available = toTwips(target.availablePx);
|
|
23780
|
+
const tableWidth = target.targetPx !== void 0 ? toTwips(target.targetPx) : void 0;
|
|
23781
|
+
const min = columns.map((column) => toTwips(column.minPx));
|
|
23782
|
+
const contentMax = columns.map((column, index) => Math.max(min[index], toTwips(column.maxPx)));
|
|
23783
|
+
const fractions = columns.map(
|
|
23784
|
+
(column) => column.preferredPx === void 0 ? column.preferredFraction ?? 0 : 0
|
|
23785
|
+
);
|
|
23786
|
+
const fractionSum = Math.min(
|
|
23787
|
+
0.99,
|
|
23788
|
+
fractions.reduce((sum2, value) => sum2 + value, 0)
|
|
23789
|
+
);
|
|
23790
|
+
const percentBase = tableWidth ?? Math.min(
|
|
23791
|
+
available,
|
|
23792
|
+
columns.reduce(
|
|
23793
|
+
(sum2, column, index) => fractions[index] ? sum2 : sum2 + Math.max(contentMax[index], toTwips(column.preferredPx ?? 0)),
|
|
23794
|
+
0
|
|
23795
|
+
) / (1 - fractionSum)
|
|
23796
|
+
);
|
|
23797
|
+
const preferred = columns.map(
|
|
23798
|
+
(column, index) => column.preferredPx !== void 0 ? toTwips(column.preferredPx) : fractions[index] ? fractions[index] * percentBase : void 0
|
|
23799
|
+
);
|
|
23800
|
+
const fixed = preferred.map((value) => value !== void 0);
|
|
23801
|
+
const max = contentMax.map(
|
|
23802
|
+
(value, index) => fixed[index] ? Math.max(min[index], preferred[index]) : value
|
|
23803
|
+
);
|
|
23804
|
+
const sum = (values) => values.reduce((acc, value) => acc + value, 0);
|
|
23805
|
+
const limit = tableWidth ?? available;
|
|
23806
|
+
if (sum(min) >= limit) return roundToTotal(min);
|
|
23807
|
+
if (sum(max) <= limit) {
|
|
23808
|
+
if (tableWidth === void 0) return roundToTotal(max);
|
|
23809
|
+
const grow = fixed.every(Boolean) ? fixed.map(() => true) : fixed.map((value) => !value);
|
|
23810
|
+
const growing = sum(max.filter((_, index) => grow[index]));
|
|
23811
|
+
const extra = tableWidth - sum(max);
|
|
23812
|
+
return roundToTotal(
|
|
23813
|
+
max.map(
|
|
23814
|
+
(value, index) => grow[index] ? value + (growing > 0 ? extra * value / growing : 0) : value
|
|
23815
|
+
)
|
|
23816
|
+
);
|
|
23817
|
+
}
|
|
23818
|
+
const pick = (values, wanted) => values.map((value, index) => fixed[index] === wanted ? value : 0);
|
|
23819
|
+
const fixedMax = sum(pick(max, true));
|
|
23820
|
+
const autoMin = sum(pick(min, false));
|
|
23821
|
+
const widths = fixedMax + autoMin <= limit ? interpolate(pick(min, false), pick(max, false), limit - fixedMax).map(
|
|
23822
|
+
(value, index) => fixed[index] ? max[index] : value
|
|
23823
|
+
) : interpolate(pick(min, true), pick(max, true), limit - autoMin).map(
|
|
23824
|
+
(value, index) => fixed[index] ? value : min[index]
|
|
23825
|
+
);
|
|
23826
|
+
return roundToTotal(widths);
|
|
23827
|
+
}
|
|
23828
|
+
|
|
23829
|
+
// docx/layout/table-autofit.ts
|
|
23830
|
+
var AUTOFIT_SPAN_PREFERRED_NOTE = "AutoFit tables size a merged cell\u2019s preferred width like its content, which has not been measured against Word.";
|
|
23831
|
+
function placedCells(table) {
|
|
23832
|
+
return table.rows.map((row2) => {
|
|
23833
|
+
let start = 0;
|
|
23834
|
+
return row2.cells.map((cell) => {
|
|
23835
|
+
const span = Math.max(1, cell.gridSpan ?? 1);
|
|
23836
|
+
const placed2 = { cell, start, span };
|
|
23837
|
+
start += span;
|
|
23838
|
+
return placed2;
|
|
23839
|
+
});
|
|
23840
|
+
});
|
|
23841
|
+
}
|
|
23842
|
+
function spread(columns, total, weight, apply) {
|
|
23843
|
+
const sum = columns.reduce((acc, column) => acc + weight(column), 0);
|
|
23844
|
+
for (const column of columns)
|
|
23845
|
+
apply(column, sum > 0 ? total * weight(column) / sum : total / columns.length);
|
|
23846
|
+
}
|
|
23847
|
+
function measureColumns(table, count, measurer, note) {
|
|
23848
|
+
const columns = Array.from({ length: count }, () => ({ minPx: 0, maxPx: 0 }));
|
|
23849
|
+
const nested = (inner) => tableRange(inner, measurer, note);
|
|
23850
|
+
const spans = [];
|
|
23851
|
+
for (const row2 of placedCells(table))
|
|
23852
|
+
for (const placed2 of row2) {
|
|
23853
|
+
if (placed2.start >= count) continue;
|
|
23854
|
+
const range = cellRange(placed2.cell, measurer, nested);
|
|
23855
|
+
if (placed2.span > 1) {
|
|
23856
|
+
spans.push({ placed: placed2, range });
|
|
23857
|
+
continue;
|
|
23858
|
+
}
|
|
23859
|
+
const column = columns[placed2.start];
|
|
23860
|
+
column.minPx = Math.max(column.minPx, range.minPx);
|
|
23861
|
+
column.maxPx = Math.max(column.maxPx, range.maxPx);
|
|
23862
|
+
const { preferredWidthPx, preferredFraction } = placed2.cell;
|
|
23863
|
+
if (preferredWidthPx !== void 0)
|
|
23864
|
+
column.preferredPx = Math.max(column.preferredPx ?? 0, preferredWidthPx);
|
|
23865
|
+
else if (preferredFraction !== void 0)
|
|
23866
|
+
column.preferredFraction = Math.max(column.preferredFraction ?? 0, preferredFraction);
|
|
23867
|
+
}
|
|
23868
|
+
spans.sort((a, b) => a.placed.span - b.placed.span);
|
|
23869
|
+
for (const { placed: placed2, range } of spans) {
|
|
23870
|
+
const covered = columns.slice(placed2.start, placed2.start + placed2.span);
|
|
23871
|
+
const preferred = placed2.cell.preferredWidthPx;
|
|
23872
|
+
if (preferred !== void 0) note(AUTOFIT_SPAN_PREFERRED_NOTE);
|
|
23873
|
+
const maxPx = Math.max(range.maxPx, preferred ?? 0);
|
|
23874
|
+
if (range.minPx > covered.reduce((sum, column) => sum + column.minPx, 0))
|
|
23875
|
+
spread(
|
|
23876
|
+
covered,
|
|
23877
|
+
range.minPx,
|
|
23878
|
+
(column) => column.minPx + column.maxPx,
|
|
23879
|
+
(column, share) => {
|
|
23880
|
+
column.minPx = Math.max(column.minPx, share);
|
|
23881
|
+
column.maxPx = Math.max(column.maxPx, column.minPx);
|
|
23882
|
+
}
|
|
23883
|
+
);
|
|
23884
|
+
if (maxPx > covered.reduce((sum, column) => sum + column.maxPx, 0))
|
|
23885
|
+
spread(
|
|
23886
|
+
covered,
|
|
23887
|
+
maxPx,
|
|
23888
|
+
(column) => column.maxPx,
|
|
23889
|
+
(column, share) => {
|
|
23890
|
+
column.maxPx = Math.max(column.maxPx, share);
|
|
23891
|
+
}
|
|
23892
|
+
);
|
|
23893
|
+
}
|
|
23894
|
+
return columns;
|
|
23895
|
+
}
|
|
23896
|
+
function tableRange(table, measurer, note) {
|
|
23897
|
+
if (!table.autofit) {
|
|
23898
|
+
const width = table.widthPx ?? 0;
|
|
23899
|
+
return { minPx: width, maxPx: width };
|
|
23900
|
+
}
|
|
23901
|
+
const columns = measureColumns(table, table.autofit.columns, measurer, note);
|
|
23902
|
+
const sum = (pick) => columns.reduce((acc, column) => acc + pick(column), 0);
|
|
23903
|
+
return {
|
|
23904
|
+
minPx: sum((column) => column.minPx),
|
|
23905
|
+
maxPx: sum((column) => Math.max(column.minPx, column.preferredPx ?? column.maxPx))
|
|
23906
|
+
};
|
|
23907
|
+
}
|
|
23908
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
23909
|
+
function resolveTableAutofit(table, availablePx, measurer, note = () => {
|
|
23910
|
+
}) {
|
|
23911
|
+
const autofit = table.autofit;
|
|
23912
|
+
if (!autofit) return table;
|
|
23913
|
+
const hit = cache.get(table);
|
|
23914
|
+
if (hit && hit.availablePx === availablePx && hit.measurer === measurer) return hit.result;
|
|
23915
|
+
const columns = measureColumns(table, autofit.columns, measurer, note);
|
|
23916
|
+
const first4 = table.rows[0]?.cells[0]?.padding;
|
|
23917
|
+
const last = table.rows[0]?.cells.at(-1)?.padding;
|
|
23918
|
+
const overhang = autofit.legacyMargins ? first4?.left ?? 0 : 0;
|
|
23919
|
+
const reference = autofit.legacyMargins ? availablePx + (first4?.left ?? 0) + (last?.right ?? 0) : availablePx;
|
|
23920
|
+
const widths = distributeColumns(columns, {
|
|
23921
|
+
availablePx: availablePx + overhang - Math.max(0, table.indentPx ?? 0),
|
|
23922
|
+
...autofit.widthPx !== void 0 ? { targetPx: autofit.widthPx } : autofit.widthFraction !== void 0 ? { targetPx: autofit.widthFraction * reference } : {}
|
|
23923
|
+
}).map((twips2) => twips2 * TWIP_PX);
|
|
23924
|
+
const offsets = widths.map(
|
|
23925
|
+
(_, index) => widths.slice(0, index).reduce((sum, width) => sum + width, 0)
|
|
23926
|
+
);
|
|
23927
|
+
const placedRows = placedCells(table);
|
|
23928
|
+
const result = {
|
|
23929
|
+
...table,
|
|
23930
|
+
widthPx: widths.reduce((sum, width) => sum + width, 0),
|
|
23931
|
+
rows: table.rows.map((row2, rowIndex) => {
|
|
23932
|
+
const placed2 = placedRows[rowIndex];
|
|
23933
|
+
return {
|
|
23934
|
+
...row2,
|
|
23935
|
+
cells: row2.cells.map((cell, cellIndex) => {
|
|
23936
|
+
const { start, span } = placed2[cellIndex];
|
|
23937
|
+
if (start >= widths.length) return cell;
|
|
23938
|
+
const end = Math.min(widths.length, start + span);
|
|
23939
|
+
return {
|
|
23940
|
+
...cell,
|
|
23941
|
+
xPx: offsets[start],
|
|
23942
|
+
widthPx: widths.slice(start, end).reduce((sum, width) => sum + width, 0)
|
|
23943
|
+
};
|
|
23944
|
+
})
|
|
23945
|
+
};
|
|
23946
|
+
})
|
|
23947
|
+
};
|
|
23948
|
+
cache.set(table, { availablePx, measurer, result });
|
|
23949
|
+
return result;
|
|
23950
|
+
}
|
|
23951
|
+
|
|
22880
23952
|
// docx/layout/table-cell-layout.ts
|
|
22881
23953
|
function cellParagraphs(cell) {
|
|
22882
23954
|
const walk = (blocks) => blocks.flatMap(
|
|
@@ -22897,14 +23969,15 @@ function stackCellBlocks(cell, width, measurer, note, top, starts, physicalFragm
|
|
|
22897
23969
|
let y = top;
|
|
22898
23970
|
const boxes = [];
|
|
22899
23971
|
const tables = [];
|
|
22900
|
-
for (const
|
|
22901
|
-
if (
|
|
22902
|
-
if (starts && !starts.has(
|
|
22903
|
-
const result = stackParagraphs([
|
|
23972
|
+
for (const source of cell.blocks) {
|
|
23973
|
+
if (source.kind === "paragraph") {
|
|
23974
|
+
if (starts && !starts.has(source.id)) continue;
|
|
23975
|
+
const result = stackParagraphs([source], width, measurer, note, y, starts);
|
|
22904
23976
|
boxes.push(...result.boxes);
|
|
22905
23977
|
y = result.heightPx;
|
|
22906
23978
|
continue;
|
|
22907
23979
|
}
|
|
23980
|
+
const block = resolveTableAutofit(source, width, measurer, note);
|
|
22908
23981
|
const edges = physicalFragments ? nestedFragmentEdges(block) : void 0;
|
|
22909
23982
|
const tableWidth = block.widthPx ?? width;
|
|
22910
23983
|
const profile = nestedFrameProfile(block, tableWidth);
|
|
@@ -23260,15 +24333,15 @@ function splitNote(note, budget) {
|
|
|
23260
24333
|
const bottom = head2.at(-1).yPx + head2.at(-1).heightPx;
|
|
23261
24334
|
before.push({ ...paragraph, heightPx: bottom, lines: head2 });
|
|
23262
24335
|
}
|
|
23263
|
-
const
|
|
24336
|
+
const first4 = tail[0];
|
|
23264
24337
|
if (head2.length)
|
|
23265
24338
|
sourceTokenStarts[paragraph.blockId] = head2.at(-1).nextToken ?? sourceTokenStarts[paragraph.blockId] ?? 0;
|
|
23266
|
-
origin = paragraph.yPx + (
|
|
24339
|
+
origin = paragraph.yPx + (first4?.yPx ?? 0);
|
|
23267
24340
|
after.push({
|
|
23268
24341
|
...paragraph,
|
|
23269
24342
|
yPx: 0,
|
|
23270
|
-
heightPx: Math.max(0, paragraph.heightPx - (
|
|
23271
|
-
lines: tail.map((line4) => ({ ...line4, yPx: line4.yPx - (
|
|
24343
|
+
heightPx: Math.max(0, paragraph.heightPx - (first4?.yPx ?? 0)),
|
|
24344
|
+
lines: tail.map((line4) => ({ ...line4, yPx: line4.yPx - (first4?.yPx ?? 0) }))
|
|
23272
24345
|
});
|
|
23273
24346
|
}
|
|
23274
24347
|
if (!before.length) return { after: note };
|
|
@@ -23347,8 +24420,8 @@ function minimumFootnoteHeight(notes, columns, reflow) {
|
|
|
23347
24420
|
|
|
23348
24421
|
// docx/layout/footnote-flow.ts
|
|
23349
24422
|
function firstLineBottom(note) {
|
|
23350
|
-
const
|
|
23351
|
-
return
|
|
24423
|
+
const first4 = note?.paragraphs[0];
|
|
24424
|
+
return first4 ? first4.yPx + (first4.lines[0]?.yPx ?? 0) + (first4.lines[0]?.heightPx ?? first4.heightPx) : note?.heightPx ?? 0;
|
|
23352
24425
|
}
|
|
23353
24426
|
var FOOTNOTE_SEPARATOR_PX = 12;
|
|
23354
24427
|
var FootnoteFlow = class {
|
|
@@ -23671,9 +24744,7 @@ var PageCursor = class {
|
|
|
23671
24744
|
/** Reject trials that overflow an earlier column, including a kept table row. */
|
|
23672
24745
|
get columnContentFits() {
|
|
23673
24746
|
return this.activeColumns.every(
|
|
23674
|
-
(column) => column.blocks.every(
|
|
23675
|
-
(block) => block.yPx + block.heightPx <= this.columnTopPx + this.columnHeightPx
|
|
23676
|
-
)
|
|
24747
|
+
(column) => column.blocks.filter(inFlow).every((block) => block.yPx + block.heightPx <= this.columnTopPx + this.columnHeightPx)
|
|
23677
24748
|
);
|
|
23678
24749
|
}
|
|
23679
24750
|
endBalance() {
|
|
@@ -23724,7 +24795,7 @@ var PageCursor = class {
|
|
|
23724
24795
|
const bottom = Math.max(
|
|
23725
24796
|
this.yPx,
|
|
23726
24797
|
...this.activeColumns.flatMap(
|
|
23727
|
-
(column) => column.blocks.map((block) => block.yPx + block.heightPx)
|
|
24798
|
+
(column) => column.blocks.filter(inFlow).map((block) => block.yPx + block.heightPx)
|
|
23728
24799
|
)
|
|
23729
24800
|
);
|
|
23730
24801
|
for (const column of this.activeColumns) {
|
|
@@ -23765,7 +24836,7 @@ var PageCursor = class {
|
|
|
23765
24836
|
Math.max(
|
|
23766
24837
|
0,
|
|
23767
24838
|
...this.activeColumns.slice(0, this.columnIndex).flatMap(
|
|
23768
|
-
(column) => column.blocks.map((block) => block.yPx + block.heightPx - this.columnTopPx)
|
|
24839
|
+
(column) => column.blocks.filter(inFlow).map((block) => block.yPx + block.heightPx - this.columnTopPx)
|
|
23769
24840
|
)
|
|
23770
24841
|
)
|
|
23771
24842
|
))
|
|
@@ -23801,7 +24872,7 @@ var PageCursor = class {
|
|
|
23801
24872
|
const bodyBottom = this.legacyFootnoteColumns ? this.yPx : Math.max(
|
|
23802
24873
|
this.yPx,
|
|
23803
24874
|
...this.activeColumns.flatMap(
|
|
23804
|
-
(column) => column.blocks.map((block) => block.yPx + block.heightPx)
|
|
24875
|
+
(column) => column.blocks.filter(inFlow).map((block) => block.yPx + block.heightPx)
|
|
23805
24876
|
)
|
|
23806
24877
|
);
|
|
23807
24878
|
this.footnotes.commit(
|
|
@@ -23938,8 +25009,8 @@ function placeParagraph(cursor, placement, note) {
|
|
|
23938
25009
|
layout.lines.slice(lineCursor, lineCursor + placedCount),
|
|
23939
25010
|
cumulative + (firstSegment ? spacingBeforePx : 0)
|
|
23940
25011
|
);
|
|
23941
|
-
const
|
|
23942
|
-
const origin =
|
|
25012
|
+
const first4 = expectDefined(layout.lines[lineCursor], "first line of paragraph segment");
|
|
25013
|
+
const origin = first4.yPx - (firstSegment ? (first4.gapBeforePx ?? 0) + layout.insetTopPx : 0);
|
|
23943
25014
|
const segmentLines = layout.lines.slice(lineCursor, lineCursor + placedCount).map((line4, index) => ({
|
|
23944
25015
|
...line4,
|
|
23945
25016
|
yPx: line4.yPx - origin,
|
|
@@ -23995,8 +25066,8 @@ var TableParagraphKeeps = class {
|
|
|
23995
25066
|
return Math.max(
|
|
23996
25067
|
0,
|
|
23997
25068
|
...row2.cells.map((cell, index) => {
|
|
23998
|
-
const
|
|
23999
|
-
return
|
|
25069
|
+
const first4 = cell[0];
|
|
25070
|
+
return first4 && this.sources.get(first4.blockId)?.keepLines ? first4.yPx + first4.heightPx + (row2.cellPadding?.[index]?.bottom ?? 0) : 0;
|
|
24000
25071
|
})
|
|
24001
25072
|
);
|
|
24002
25073
|
}
|
|
@@ -24020,13 +25091,13 @@ var TableParagraphKeeps = class {
|
|
|
24020
25091
|
|
|
24021
25092
|
// docx/layout/table-note-stories.ts
|
|
24022
25093
|
function independentNoteStories(cell) {
|
|
24023
|
-
const
|
|
24024
|
-
if (
|
|
25094
|
+
const first4 = cell.blocks?.[0];
|
|
25095
|
+
if (first4?.kind !== "table" || first4.rows.length !== 1 || cell.verticalAlign && cell.verticalAlign !== "top")
|
|
24025
25096
|
return void 0;
|
|
24026
25097
|
if (cell.blocks.slice(1).some((block) => block.kind !== "paragraph" || block.footnotes?.length))
|
|
24027
25098
|
return void 0;
|
|
24028
|
-
const row2 =
|
|
24029
|
-
if (row2.heightPx !== void 0 || row2.cantSplit || row2.isHeader || !nestedFrameProfile(
|
|
25099
|
+
const row2 = first4.rows[0];
|
|
25100
|
+
if (row2.heightPx !== void 0 || row2.cantSplit || row2.isHeader || !nestedFrameProfile(first4, first4.widthPx))
|
|
24030
25101
|
return void 0;
|
|
24031
25102
|
if (row2.cells.some(
|
|
24032
25103
|
(inner) => inner.blocks?.some((block) => block.kind === "table") || cellParagraphs(inner).some(
|
|
@@ -24037,7 +25108,7 @@ function independentNoteStories(cell) {
|
|
|
24037
25108
|
if (!measuredNoteReferences(row2.cells.flatMap(cellParagraphs))) return void 0;
|
|
24038
25109
|
const groups = /* @__PURE__ */ new Map();
|
|
24039
25110
|
row2.cells.forEach((inner, index) => {
|
|
24040
|
-
for (const paragraph of cellParagraphs(inner)) groups.set(paragraph.id,
|
|
25111
|
+
for (const paragraph of cellParagraphs(inner)) groups.set(paragraph.id, first4.id + ":" + index);
|
|
24041
25112
|
});
|
|
24042
25113
|
return groups.size ? groups : void 0;
|
|
24043
25114
|
}
|
|
@@ -24345,82 +25416,269 @@ var TableFootnotes = class {
|
|
|
24345
25416
|
return { layout: candidate, cut };
|
|
24346
25417
|
}
|
|
24347
25418
|
}
|
|
24348
|
-
}
|
|
24349
|
-
this.holdFragment();
|
|
24350
|
-
return void 0;
|
|
24351
|
-
}
|
|
24352
|
-
add(row2, repeated) {
|
|
24353
|
-
if (repeated) return;
|
|
24354
|
-
for (const ref of this.references(row2))
|
|
24355
|
-
if (!this.fragment.has(ref.note.id))
|
|
24356
|
-
this.fragment.set(ref.note.id, { ...ref, bottom: this.height() + ref.bottom });
|
|
24357
|
-
}
|
|
24358
|
-
holdFragment() {
|
|
24359
|
-
this.hold(this.fragment);
|
|
24360
|
-
}
|
|
24361
|
-
flushed() {
|
|
24362
|
-
for (const id of this.fragment.keys()) this.placed.add(id);
|
|
24363
|
-
this.fragment.clear();
|
|
25419
|
+
}
|
|
25420
|
+
this.holdFragment();
|
|
25421
|
+
return void 0;
|
|
25422
|
+
}
|
|
25423
|
+
add(row2, repeated) {
|
|
25424
|
+
if (repeated) return;
|
|
25425
|
+
for (const ref of this.references(row2))
|
|
25426
|
+
if (!this.fragment.has(ref.note.id))
|
|
25427
|
+
this.fragment.set(ref.note.id, { ...ref, bottom: this.height() + ref.bottom });
|
|
25428
|
+
}
|
|
25429
|
+
holdFragment() {
|
|
25430
|
+
this.hold(this.fragment);
|
|
25431
|
+
}
|
|
25432
|
+
flushed() {
|
|
25433
|
+
for (const id of this.fragment.keys()) this.placed.add(id);
|
|
25434
|
+
this.fragment.clear();
|
|
25435
|
+
}
|
|
25436
|
+
};
|
|
25437
|
+
|
|
25438
|
+
// docx/layout/table-merged-rows.ts
|
|
25439
|
+
var MergedRowPlan = class {
|
|
25440
|
+
constructor(rows2) {
|
|
25441
|
+
this.rows = rows2;
|
|
25442
|
+
}
|
|
25443
|
+
rows;
|
|
25444
|
+
legacy = /* @__PURE__ */ new Set();
|
|
25445
|
+
minimum = /* @__PURE__ */ new Map();
|
|
25446
|
+
cache = /* @__PURE__ */ new Map();
|
|
25447
|
+
apply(source) {
|
|
25448
|
+
const minimum = this.minimum.get(source);
|
|
25449
|
+
if (minimum === void 0 && !this.legacy.has(source)) return source;
|
|
25450
|
+
return {
|
|
25451
|
+
...source,
|
|
25452
|
+
...minimum === void 0 ? {} : { heightPx: minimum, heightRule: "atLeast" },
|
|
25453
|
+
...this.legacy.has(source) ? { mergedTextInRow: true } : {}
|
|
25454
|
+
};
|
|
25455
|
+
}
|
|
25456
|
+
/** The row to lay out and place (the source row itself when the plan leaves it alone). */
|
|
25457
|
+
effective(source) {
|
|
25458
|
+
let row2 = this.cache.get(source);
|
|
25459
|
+
if (!row2) {
|
|
25460
|
+
row2 = this.apply(source);
|
|
25461
|
+
this.cache.set(source, row2);
|
|
25462
|
+
}
|
|
25463
|
+
return row2;
|
|
25464
|
+
}
|
|
25465
|
+
/** Plans the rows a merge starting at `index` covers, given the room left for them. */
|
|
25466
|
+
plan(index, layout, availablePx) {
|
|
25467
|
+
const start = this.rows[index];
|
|
25468
|
+
const spans = start?.cells.map((cell) => cell.rowSpan ?? 1) ?? [];
|
|
25469
|
+
const longest = Math.max(1, ...spans);
|
|
25470
|
+
if (!start || longest < 2) return;
|
|
25471
|
+
const covered = this.rows.slice(index, index + longest);
|
|
25472
|
+
const natural = covered.map((row2) => layout(this.apply(row2)));
|
|
25473
|
+
const heights = natural.map((item) => item.heightPx);
|
|
25474
|
+
spans.forEach((span, cell) => {
|
|
25475
|
+
if (span < 2) return;
|
|
25476
|
+
const count = Math.min(span, covered.length);
|
|
25477
|
+
const need = (natural[0]?.geometry[cell]?.contentHeightPx ?? 0) + (natural[count - 1]?.borderBottomPx ?? 0);
|
|
25478
|
+
const have = heights.slice(0, count).reduce((sum, h) => sum + h, 0);
|
|
25479
|
+
if (need > have) heights[count - 1] = (heights[count - 1] ?? 0) + need - have;
|
|
25480
|
+
});
|
|
25481
|
+
if (heights.reduce((sum, h) => sum + h, 0) > availablePx) {
|
|
25482
|
+
this.legacy.add(start);
|
|
25483
|
+
return;
|
|
25484
|
+
}
|
|
25485
|
+
covered.forEach((row2, at) => {
|
|
25486
|
+
const grown = heights[at] - natural[at].heightPx;
|
|
25487
|
+
if (grown > 1e-6 && row2.heightRule !== "exact")
|
|
25488
|
+
this.minimum.set(row2, heights[at] - (natural[at].borderBottomPx ?? 0));
|
|
25489
|
+
});
|
|
25490
|
+
}
|
|
25491
|
+
};
|
|
25492
|
+
|
|
25493
|
+
// docx/layout/floats.ts
|
|
25494
|
+
var FLOAT_WRAP_NOTE = "Text wraps around floating pictures on their largest side, or on both sides of a square, tight or through picture whose wrapText is bothSides (all use the picture\u2019s rectangle, not its outline); lines continuing onto a later page keep their wrapped widths.";
|
|
25495
|
+
function horizontalArea(float, page, column) {
|
|
25496
|
+
const contentLeft = page.marginLeftPx;
|
|
25497
|
+
switch (float.relativeFromH) {
|
|
25498
|
+
case "page":
|
|
25499
|
+
return { start: 0, size: page.widthPx };
|
|
25500
|
+
case "margin":
|
|
25501
|
+
return { start: contentLeft, size: page.widthPx - contentLeft - page.marginRightPx };
|
|
25502
|
+
case "leftMargin":
|
|
25503
|
+
case "insideMargin":
|
|
25504
|
+
return { start: 0, size: contentLeft };
|
|
25505
|
+
case "rightMargin":
|
|
25506
|
+
case "outsideMargin":
|
|
25507
|
+
return { start: page.widthPx - page.marginRightPx, size: page.marginRightPx };
|
|
25508
|
+
default:
|
|
25509
|
+
return { start: contentLeft + column.xPx, size: column.widthPx };
|
|
25510
|
+
}
|
|
25511
|
+
}
|
|
25512
|
+
function verticalArea(float, page, paragraphTopPx, paragraphHeightPx) {
|
|
25513
|
+
switch (float.relativeFromV) {
|
|
25514
|
+
case "page":
|
|
25515
|
+
return { start: 0, size: page.heightPx };
|
|
25516
|
+
case "margin":
|
|
25517
|
+
return {
|
|
25518
|
+
start: page.marginTopPx,
|
|
25519
|
+
size: page.heightPx - page.marginTopPx - page.marginBottomPx
|
|
25520
|
+
};
|
|
25521
|
+
case "topMargin":
|
|
25522
|
+
case "insideMargin":
|
|
25523
|
+
return { start: 0, size: page.marginTopPx };
|
|
25524
|
+
case "bottomMargin":
|
|
25525
|
+
case "outsideMargin":
|
|
25526
|
+
return { start: page.heightPx - page.marginBottomPx, size: page.marginBottomPx };
|
|
25527
|
+
default:
|
|
25528
|
+
return { start: paragraphTopPx, size: paragraphHeightPx };
|
|
25529
|
+
}
|
|
25530
|
+
}
|
|
25531
|
+
function place(area, size, align, offset) {
|
|
25532
|
+
if (align === "center") return area.start + (area.size - size) / 2;
|
|
25533
|
+
if (align === "right" || align === "bottom" || align === "outside")
|
|
25534
|
+
return area.start + area.size - size;
|
|
25535
|
+
if (align) return area.start;
|
|
25536
|
+
return area.start + (offset ?? 0);
|
|
25537
|
+
}
|
|
25538
|
+
function floatPosition(float, page, column, paragraph) {
|
|
25539
|
+
const h = horizontalArea(float, page, column);
|
|
25540
|
+
const v = verticalArea(float, page, paragraph.topPx, paragraph.heightPx);
|
|
25541
|
+
return {
|
|
25542
|
+
xPx: place(h, float.widthPx, float.alignH, float.offsetXPx),
|
|
25543
|
+
yPx: place(v, float.heightPx, float.alignV, float.offsetYPx)
|
|
25544
|
+
};
|
|
25545
|
+
}
|
|
25546
|
+
function floatOrigin(float, page, column, paragraph) {
|
|
25547
|
+
return {
|
|
25548
|
+
xPx: horizontalArea(float, page, column).start,
|
|
25549
|
+
yPx: verticalArea(float, page, paragraph.topPx, paragraph.heightPx).start
|
|
25550
|
+
};
|
|
25551
|
+
}
|
|
25552
|
+
function positionFloats(input, pages) {
|
|
25553
|
+
const floatsById = /* @__PURE__ */ new Map();
|
|
25554
|
+
for (const section of input.sections)
|
|
25555
|
+
for (const block of section.blocks)
|
|
25556
|
+
if (block.kind === "paragraph" && block.floats?.length)
|
|
25557
|
+
floatsById.set(block.id, block.floats);
|
|
25558
|
+
if (!floatsById.size) return false;
|
|
25559
|
+
const placed2 = /* @__PURE__ */ new Set();
|
|
25560
|
+
for (const page of pages) {
|
|
25561
|
+
const boxes = [];
|
|
25562
|
+
for (const column of page.columns)
|
|
25563
|
+
for (const block of column.blocks) {
|
|
25564
|
+
const floats = block.kind === "paragraph" ? floatsById.get(block.blockId) : void 0;
|
|
25565
|
+
if (!floats || placed2.has(block.blockId)) continue;
|
|
25566
|
+
placed2.add(block.blockId);
|
|
25567
|
+
const top = page.marginTopPx + block.yPx;
|
|
25568
|
+
for (const float of floats) {
|
|
25569
|
+
const frame2 = { topPx: top, heightPx: block.heightPx };
|
|
25570
|
+
const position = floatPosition(float, page, column, frame2);
|
|
25571
|
+
const origin = floatOrigin(float, page, column, frame2);
|
|
25572
|
+
boxes.push({
|
|
25573
|
+
blockId: block.blockId,
|
|
25574
|
+
index: float.index ?? floats.indexOf(float),
|
|
25575
|
+
originXPx: origin.xPx,
|
|
25576
|
+
originYPx: origin.yPx,
|
|
25577
|
+
...position,
|
|
25578
|
+
widthPx: float.widthPx,
|
|
25579
|
+
heightPx: float.heightPx,
|
|
25580
|
+
partName: float.partName,
|
|
25581
|
+
...float.pictureFill ? { pictureFill: float.pictureFill } : {},
|
|
25582
|
+
contentType: float.contentType,
|
|
25583
|
+
...float.chart ? { chart: float.chart } : {},
|
|
25584
|
+
behindText: Boolean(float.behindText),
|
|
25585
|
+
...float.wrap ? { wrap: float.wrap } : {},
|
|
25586
|
+
...float.wrapText ? { wrapText: float.wrapText } : {}
|
|
25587
|
+
});
|
|
25588
|
+
}
|
|
25589
|
+
}
|
|
25590
|
+
if (boxes.length) page.floats = boxes;
|
|
24364
25591
|
}
|
|
24365
|
-
|
|
25592
|
+
return true;
|
|
25593
|
+
}
|
|
24366
25594
|
|
|
24367
|
-
// docx/layout/
|
|
24368
|
-
var
|
|
24369
|
-
|
|
24370
|
-
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
|
|
24381
|
-
...minimum === void 0 ? {} : { heightPx: minimum, heightRule: "atLeast" },
|
|
24382
|
-
...this.legacy.has(source) ? { mergedTextInRow: true } : {}
|
|
24383
|
-
};
|
|
24384
|
-
}
|
|
24385
|
-
/** The row to lay out and place (the source row itself when the plan leaves it alone). */
|
|
24386
|
-
effective(source) {
|
|
24387
|
-
let row2 = this.cache.get(source);
|
|
24388
|
-
if (!row2) {
|
|
24389
|
-
row2 = this.apply(source);
|
|
24390
|
-
this.cache.set(source, row2);
|
|
24391
|
-
}
|
|
24392
|
-
return row2;
|
|
25595
|
+
// docx/layout/flow-floating-table.ts
|
|
25596
|
+
var FLOATING_TABLE_NOTE = "Floating tables are placed whole on the page where they occur and text wraps around their rectangle; narrow gaps beside them stay empty.";
|
|
25597
|
+
var FLOATING_TABLE_IN_FLOW_NOTE = "Floating tables that do not fit on their page, hold footnote references or merge cells vertically are laid out in the text flow.";
|
|
25598
|
+
function floatable(table) {
|
|
25599
|
+
return table.rows.every(
|
|
25600
|
+
(row2) => row2.cells.every(
|
|
25601
|
+
(cell) => !cell.verticalMerge && !(cell.rowSpan && cell.rowSpan > 1) && cellParagraphs(cell).every((paragraph) => !paragraph.footnotes?.length)
|
|
25602
|
+
)
|
|
25603
|
+
);
|
|
25604
|
+
}
|
|
25605
|
+
function placeFloatingTable(cursor, table, measurer, note) {
|
|
25606
|
+
if (!floatable(table)) {
|
|
25607
|
+
note(FLOATING_TABLE_IN_FLOW_NOTE);
|
|
25608
|
+
return false;
|
|
24393
25609
|
}
|
|
24394
|
-
|
|
24395
|
-
|
|
24396
|
-
|
|
24397
|
-
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
const
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
|
|
24406
|
-
|
|
24407
|
-
|
|
24408
|
-
|
|
24409
|
-
});
|
|
24410
|
-
if (heights.reduce((sum, h) => sum + h, 0) > availablePx) {
|
|
24411
|
-
this.legacy.add(start);
|
|
24412
|
-
return;
|
|
24413
|
-
}
|
|
24414
|
-
covered.forEach((row2, at) => {
|
|
24415
|
-
const grown = heights[at] - natural[at].heightPx;
|
|
24416
|
-
if (grown > 1e-6 && row2.heightRule !== "exact")
|
|
24417
|
-
this.minimum.set(row2, heights[at] - (natural[at].borderBottomPx ?? 0));
|
|
25610
|
+
const widthPx = table.widthPx ?? cursor.columnWidthPx;
|
|
25611
|
+
const profile = nestedFrameProfile(table, widthPx, true);
|
|
25612
|
+
const borders = new TableFragmentBorders();
|
|
25613
|
+
const rows2 = [];
|
|
25614
|
+
let heightPx = 0;
|
|
25615
|
+
for (const row2 of table.rows) {
|
|
25616
|
+
const layout = layoutBorderedRow(row2, widthPx, measurer, note, profile);
|
|
25617
|
+
heightPx += borders.remove(rows2.at(-1));
|
|
25618
|
+
rows2.push({
|
|
25619
|
+
yPx: heightPx,
|
|
25620
|
+
heightPx: layout.heightPx,
|
|
25621
|
+
repeated: false,
|
|
25622
|
+
cells: layout.cells,
|
|
25623
|
+
geometry: layout.geometry,
|
|
25624
|
+
...layout.cellTables ? { cellTables: layout.cellTables } : {}
|
|
24418
25625
|
});
|
|
25626
|
+
heightPx += layout.heightPx;
|
|
25627
|
+
borders.record(layout.borderBottomPx);
|
|
25628
|
+
}
|
|
25629
|
+
heightPx += borders.restore(rows2.at(-1));
|
|
25630
|
+
if (!profile) {
|
|
25631
|
+
const edge = (row2, side) => Math.max(0, ...(row2?.cells ?? []).map((cell) => cell.borders?.[side]?.widthPx ?? 0));
|
|
25632
|
+
heightPx += edge(table.rows[0], "top") + edge(table.rows.at(-1), "bottom");
|
|
25633
|
+
}
|
|
25634
|
+
const page = cursor.page;
|
|
25635
|
+
const column = cursor.column;
|
|
25636
|
+
const frame2 = table.floating;
|
|
25637
|
+
const position = floatPosition(
|
|
25638
|
+
{
|
|
25639
|
+
widthPx,
|
|
25640
|
+
heightPx,
|
|
25641
|
+
relativeFromH: frame2.relativeFromH,
|
|
25642
|
+
...frame2.alignH ? { alignH: frame2.alignH } : {},
|
|
25643
|
+
offsetXPx: frame2.offsetXPx,
|
|
25644
|
+
relativeFromV: frame2.relativeFromV,
|
|
25645
|
+
...frame2.alignV ? { alignV: frame2.alignV } : {},
|
|
25646
|
+
offsetYPx: frame2.offsetYPx
|
|
25647
|
+
},
|
|
25648
|
+
page,
|
|
25649
|
+
column,
|
|
25650
|
+
{ topPx: page.marginTopPx + cursor.y, heightPx }
|
|
25651
|
+
);
|
|
25652
|
+
const topPx = position.yPx;
|
|
25653
|
+
if (topPx < 0 || topPx + heightPx > page.heightPx - page.marginBottomPx) {
|
|
25654
|
+
note(FLOATING_TABLE_IN_FLOW_NOTE);
|
|
25655
|
+
return false;
|
|
24419
25656
|
}
|
|
24420
|
-
|
|
25657
|
+
note(FLOATING_TABLE_NOTE);
|
|
25658
|
+
const box = {
|
|
25659
|
+
kind: "table",
|
|
25660
|
+
blockId: table.id,
|
|
25661
|
+
xPx: position.xPx - page.marginLeftPx - column.xPx,
|
|
25662
|
+
widthPx,
|
|
25663
|
+
yPx: 0,
|
|
25664
|
+
heightPx,
|
|
25665
|
+
rows: rows2,
|
|
25666
|
+
floating: {
|
|
25667
|
+
topPx: frame2.distance.topPx,
|
|
25668
|
+
rightPx: frame2.distance.rightPx,
|
|
25669
|
+
bottomPx: frame2.distance.bottomPx,
|
|
25670
|
+
leftPx: frame2.distance.leftPx
|
|
25671
|
+
}
|
|
25672
|
+
};
|
|
25673
|
+
cursor.place(box, 0, topPx - page.marginTopPx - cursor.y);
|
|
25674
|
+
return true;
|
|
25675
|
+
}
|
|
24421
25676
|
|
|
24422
25677
|
// docx/layout/flow-table.ts
|
|
24423
|
-
function placeTable(cursor,
|
|
25678
|
+
function placeTable(cursor, source, measurer, note, resolveFootnotes) {
|
|
25679
|
+
const table = resolveTableAutofit(source, cursor.columnWidthPx, measurer, note);
|
|
25680
|
+
if (table.floating && placeFloatingTable(cursor, { ...table, floating: table.floating }, measurer, note))
|
|
25681
|
+
return;
|
|
24424
25682
|
const firstBodyRow = table.rows.findIndex((row2) => !row2.isHeader);
|
|
24425
25683
|
const headerRows = table.rows.slice(0, firstBodyRow < 0 ? table.rows.length : firstBodyRow);
|
|
24426
25684
|
const nativeFragments = new Map(table.rows.map((row2) => [row2, reflowNestedFragments(row2)]));
|
|
@@ -24647,15 +25905,15 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
24647
25905
|
}
|
|
24648
25906
|
}
|
|
24649
25907
|
const merged = new MergedRowPlan(table.rows);
|
|
24650
|
-
for (const [index,
|
|
25908
|
+
for (const [index, source2] of table.rows.entries()) {
|
|
24651
25909
|
merged.plan(
|
|
24652
25910
|
index,
|
|
24653
25911
|
(candidate) => layoutRow2(candidate, cursor.columnWidthPx, measurer, () => {
|
|
24654
|
-
}, void 0,
|
|
25912
|
+
}, void 0, source2),
|
|
24655
25913
|
cursor.remainingHeightPx() - fragmentHeight
|
|
24656
25914
|
);
|
|
24657
|
-
const row2 = merged.effective(
|
|
24658
|
-
if (row2 !==
|
|
25915
|
+
const row2 = merged.effective(source2);
|
|
25916
|
+
if (row2 !== source2) nativeFragments.set(row2, nativeFragments.get(source2) ?? false);
|
|
24659
25917
|
const layout = layoutRow2(row2, cursor.columnWidthPx, measurer, note);
|
|
24660
25918
|
if (layout.heightPx > cursor.remainingHeightPx() && !nativeFragments.get(row2) && row2.cells.some(
|
|
24661
25919
|
(cell) => cell.blocks?.some((block) => block.kind === "table" && block.rows.length > 1)
|
|
@@ -24672,7 +25930,7 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
24672
25930
|
placeRow(
|
|
24673
25931
|
row2,
|
|
24674
25932
|
layout,
|
|
24675
|
-
Boolean(row2.cantSplit) || headerRows.includes(
|
|
25933
|
+
Boolean(row2.cantSplit) || headerRows.includes(source2) || !!footnotes && row2.heightRule === "exact"
|
|
24676
25934
|
);
|
|
24677
25935
|
}
|
|
24678
25936
|
flushFragment();
|
|
@@ -24692,7 +25950,7 @@ function alignMergedCells(rows2) {
|
|
|
24692
25950
|
|
|
24693
25951
|
// docx/layout/reference-footnotes.ts
|
|
24694
25952
|
function createReferenceFootnotes(width, measurer, report) {
|
|
24695
|
-
const
|
|
25953
|
+
const cache3 = /* @__PURE__ */ new Map();
|
|
24696
25954
|
return (paragraph, lines, includeUnanchored) => {
|
|
24697
25955
|
const selected = new Set(
|
|
24698
25956
|
lines.flatMap(
|
|
@@ -24702,11 +25960,11 @@ function createReferenceFootnotes(width, measurer, report) {
|
|
|
24702
25960
|
const anchored = new Set(paragraph.runs.map((run) => run.footnoteReferenceId));
|
|
24703
25961
|
return (paragraph.footnotes ?? []).filter((note) => selected.has(note.id) || includeUnanchored && !anchored.has(note.id)).map((note) => {
|
|
24704
25962
|
const key = `${note.id}:${width()}`;
|
|
24705
|
-
const prior =
|
|
25963
|
+
const prior = cache3.get(key);
|
|
24706
25964
|
if (prior) return prior;
|
|
24707
25965
|
const stacked = stackParagraphs(note.paragraphs, width(), measurer, report);
|
|
24708
25966
|
const box = { id: note.id, yPx: 0, heightPx: stacked.heightPx, paragraphs: stacked.boxes };
|
|
24709
|
-
|
|
25967
|
+
cache3.set(key, box);
|
|
24710
25968
|
return box;
|
|
24711
25969
|
});
|
|
24712
25970
|
};
|
|
@@ -24726,6 +25984,19 @@ function wrapExclusions(pages) {
|
|
|
24726
25984
|
topAndBottom: float.wrap === "topAndBottom",
|
|
24727
25985
|
...float.wrapText === "bothSides" ? { bothSides: true } : {}
|
|
24728
25986
|
}));
|
|
25987
|
+
for (const column of page.columns)
|
|
25988
|
+
for (const block of column.blocks) {
|
|
25989
|
+
if (block.kind !== "table" || !block.floating) continue;
|
|
25990
|
+
const distance = block.floating;
|
|
25991
|
+
list.push({
|
|
25992
|
+
xPx: page.marginLeftPx + column.xPx + (block.xPx ?? 0) - distance.leftPx,
|
|
25993
|
+
yPx: page.marginTopPx + block.yPx - distance.topPx,
|
|
25994
|
+
widthPx: (block.widthPx ?? 0) + distance.leftPx + distance.rightPx,
|
|
25995
|
+
heightPx: block.heightPx + distance.topPx + distance.bottomPx,
|
|
25996
|
+
topAndBottom: false,
|
|
25997
|
+
bothSides: true
|
|
25998
|
+
});
|
|
25999
|
+
}
|
|
24729
26000
|
if (list.length) exclusions.set(page.index, list);
|
|
24730
26001
|
}
|
|
24731
26002
|
return exclusions;
|
|
@@ -24926,7 +26197,11 @@ var SectionFlow = class {
|
|
|
24926
26197
|
const key = `${index}:${this.cursor.columnWidthPx}`;
|
|
24927
26198
|
let cached = this.firstRowHeightCache.get(key);
|
|
24928
26199
|
if (cached === void 0) {
|
|
24929
|
-
const table =
|
|
26200
|
+
const table = resolveTableAutofit(
|
|
26201
|
+
this.blocks[index],
|
|
26202
|
+
this.cursor.columnWidthPx,
|
|
26203
|
+
this.measurer
|
|
26204
|
+
);
|
|
24930
26205
|
const [firstRow] = table.rows;
|
|
24931
26206
|
cached = firstRow ? layoutRow(firstRow, this.cursor.columnWidthPx, this.measurer, this.note).heightPx : 0;
|
|
24932
26207
|
this.firstRowHeightCache.set(key, cached);
|
|
@@ -24955,7 +26230,7 @@ var SectionFlow = class {
|
|
|
24955
26230
|
requiredKeepHeight(index, depth = 0) {
|
|
24956
26231
|
if (index >= this.blocks.length || depth > 64) return 0;
|
|
24957
26232
|
const block = expectDefined(this.blocks[index], "keep-chain block index");
|
|
24958
|
-
if (block.kind === "table") return this.firstRowHeight(index);
|
|
26233
|
+
if (block.kind === "table") return block.floating ? 0 : this.firstRowHeight(index);
|
|
24959
26234
|
const layout = this.paragraphLayout(index);
|
|
24960
26235
|
const before = this.spacingBeforeFor(index);
|
|
24961
26236
|
const own2 = before + (block.keepLines ? layout.contentHeightPx + layout.spacingAfterPx : layout.lines[0]?.heightPx ?? 0);
|
|
@@ -25114,7 +26389,9 @@ function alignVertically(pages, section, note) {
|
|
|
25114
26389
|
const available = page.heightPx - page.marginTopPx - page.marginBottomPx - footnoteHeight;
|
|
25115
26390
|
const used = Math.max(
|
|
25116
26391
|
0,
|
|
25117
|
-
...page.columns.flatMap(
|
|
26392
|
+
...page.columns.flatMap(
|
|
26393
|
+
(column) => column.blocks.filter(inFlow).map((block) => block.yPx + block.heightPx)
|
|
26394
|
+
)
|
|
25118
26395
|
);
|
|
25119
26396
|
const shift = (available - used) / (align === "center" ? 2 : 1);
|
|
25120
26397
|
if (shift <= 0) continue;
|
|
@@ -25128,7 +26405,7 @@ function layoutSections(input, measurer, exclusions) {
|
|
|
25128
26405
|
let previousFlow;
|
|
25129
26406
|
input.sections.forEach((section, index) => {
|
|
25130
26407
|
insertParityBlank(pages, section);
|
|
25131
|
-
const
|
|
26408
|
+
const first4 = pages.length;
|
|
25132
26409
|
const previous = input.sections[index - 1];
|
|
25133
26410
|
const page = pages.at(-1);
|
|
25134
26411
|
let continueAt;
|
|
@@ -25180,7 +26457,7 @@ function layoutSections(input, measurer, exclusions) {
|
|
|
25180
26457
|
}
|
|
25181
26458
|
}
|
|
25182
26459
|
previousFlow = flow;
|
|
25183
|
-
alignVertically(pages.slice(
|
|
26460
|
+
alignVertically(pages.slice(first4), section, note);
|
|
25184
26461
|
});
|
|
25185
26462
|
return { pages, approximations: [...approximations] };
|
|
25186
26463
|
}
|
|
@@ -25439,21 +26716,21 @@ function detectFontScript(codePoint) {
|
|
|
25439
26716
|
}
|
|
25440
26717
|
return "latin";
|
|
25441
26718
|
}
|
|
25442
|
-
function segmentByScript(
|
|
25443
|
-
if (!
|
|
26719
|
+
function segmentByScript(text3) {
|
|
26720
|
+
if (!text3) {
|
|
25444
26721
|
return [];
|
|
25445
26722
|
}
|
|
25446
26723
|
const runs = [];
|
|
25447
26724
|
let currentScript = null;
|
|
25448
26725
|
let currentStart = 0;
|
|
25449
26726
|
let currentText = "";
|
|
25450
|
-
for (let i = 0; i <
|
|
25451
|
-
const codePoint =
|
|
26727
|
+
for (let i = 0; i < text3.length; i++) {
|
|
26728
|
+
const codePoint = text3.codePointAt(i);
|
|
25452
26729
|
if (codePoint === void 0) {
|
|
25453
26730
|
continue;
|
|
25454
26731
|
}
|
|
25455
26732
|
const charLength = codePoint > 65535 ? 2 : 1;
|
|
25456
|
-
const char =
|
|
26733
|
+
const char = text3.substring(i, i + charLength);
|
|
25457
26734
|
const isNeutral = codePoint <= 127 && !/[a-zA-Z0-9]/u.test(char);
|
|
25458
26735
|
const script = isNeutral ? currentScript ?? "latin" : detectFontScript(codePoint);
|
|
25459
26736
|
if (script !== currentScript && currentScript !== null) {
|
|
@@ -25494,9 +26771,9 @@ function resolveFontForScript(script, fonts) {
|
|
|
25494
26771
|
}
|
|
25495
26772
|
|
|
25496
26773
|
// text/script-fonts.ts
|
|
25497
|
-
function segmentByFont(
|
|
26774
|
+
function segmentByFont(text3, fonts) {
|
|
25498
26775
|
const result = [];
|
|
25499
|
-
for (const run of segmentByScript(
|
|
26776
|
+
for (const run of segmentByScript(text3)) {
|
|
25500
26777
|
const fontFamily = resolveFontForScript(run.script, fonts) ?? fonts.latin;
|
|
25501
26778
|
const previous = result.at(-1);
|
|
25502
26779
|
if (previous?.fontFamily === fontFamily) previous.text += run.text;
|
|
@@ -25595,13 +26872,13 @@ function mergeSiblings(nodes) {
|
|
|
25595
26872
|
}
|
|
25596
26873
|
}
|
|
25597
26874
|
if (!isGroupedByTag(entries.map(([key]) => key))) {
|
|
25598
|
-
const
|
|
26875
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
25599
26876
|
for (const [key] of entries) {
|
|
25600
|
-
|
|
26877
|
+
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
25601
26878
|
}
|
|
25602
26879
|
const ordered = /* @__PURE__ */ Object.create(null);
|
|
25603
26880
|
for (const [position, [key, value]] of entries.entries()) {
|
|
25604
|
-
ordered[(
|
|
26881
|
+
ordered[(counts2.get(key) ?? 0) > 1 ? orderedXmlKey(key, position) : key] = value;
|
|
25605
26882
|
}
|
|
25606
26883
|
return ordered;
|
|
25607
26884
|
}
|
|
@@ -25914,16 +27191,16 @@ function escapeChar(ch) {
|
|
|
25914
27191
|
}
|
|
25915
27192
|
return REVERSE_ESCAPE[ch] ?? ch;
|
|
25916
27193
|
}
|
|
25917
|
-
function escapeMathText(
|
|
25918
|
-
return Array.from(
|
|
27194
|
+
function escapeMathText(text3) {
|
|
27195
|
+
return Array.from(text3).map(escapeChar).join("");
|
|
25919
27196
|
}
|
|
25920
27197
|
var TEXT_ARGUMENT_ESCAPES = {
|
|
25921
27198
|
"\\": "\\backslash ",
|
|
25922
27199
|
"{": "\\{",
|
|
25923
27200
|
"}": "\\}"
|
|
25924
27201
|
};
|
|
25925
|
-
function escapeTextArgument(
|
|
25926
|
-
return
|
|
27202
|
+
function escapeTextArgument(text3) {
|
|
27203
|
+
return text3.replace(/[\\{}]/gu, (ch) => TEXT_ARGUMENT_ESCAPES[ch] ?? ch);
|
|
25927
27204
|
}
|
|
25928
27205
|
function isSingleAtom(container) {
|
|
25929
27206
|
const sole = soleChild(container);
|
|
@@ -25933,11 +27210,11 @@ function isSingleAtom(container) {
|
|
|
25933
27210
|
if (sole.tag !== "m:r") {
|
|
25934
27211
|
return true;
|
|
25935
27212
|
}
|
|
25936
|
-
const
|
|
27213
|
+
const text3 = readRunText(sole.node);
|
|
25937
27214
|
if (isOn(childNode(childNode(sole.node, "m:rPr"), "m:nor"))) {
|
|
25938
27215
|
return true;
|
|
25939
27216
|
}
|
|
25940
|
-
return Array.from(
|
|
27217
|
+
return Array.from(text3).length === 1;
|
|
25941
27218
|
}
|
|
25942
27219
|
function collectText(node) {
|
|
25943
27220
|
if (node === null || node === void 0) {
|
|
@@ -26072,14 +27349,14 @@ function scriptBase(node) {
|
|
|
26072
27349
|
return isSingleAtom(childNode(node, "m:e")) || base.length <= 1 ? base : `{${base}}`;
|
|
26073
27350
|
}
|
|
26074
27351
|
function runToLatex(node) {
|
|
26075
|
-
const
|
|
26076
|
-
if (
|
|
27352
|
+
const text3 = readRunText(node);
|
|
27353
|
+
if (text3.length === 0) {
|
|
26077
27354
|
return "";
|
|
26078
27355
|
}
|
|
26079
27356
|
if (isOn(childNode(childNode(node, "m:rPr"), "m:nor"))) {
|
|
26080
|
-
return `\\text{${escapeTextArgument(
|
|
27357
|
+
return `\\text{${escapeTextArgument(text3)}}`;
|
|
26081
27358
|
}
|
|
26082
|
-
return escapeMathText(
|
|
27359
|
+
return escapeMathText(text3);
|
|
26083
27360
|
}
|
|
26084
27361
|
function fractionToLatex(node) {
|
|
26085
27362
|
const type = attrVal(childNode(childNode(node, "m:fPr"), "m:type"));
|
|
@@ -26261,8 +27538,8 @@ function attr2(node, name2) {
|
|
|
26261
27538
|
function val(node) {
|
|
26262
27539
|
return attr2(node, "val");
|
|
26263
27540
|
}
|
|
26264
|
-
function escapeXml2(
|
|
26265
|
-
return
|
|
27541
|
+
function escapeXml2(text3) {
|
|
27542
|
+
return text3.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">");
|
|
26266
27543
|
}
|
|
26267
27544
|
function readText(node) {
|
|
26268
27545
|
const textNode = node["m:t"];
|
|
@@ -26362,8 +27639,8 @@ function glyphEm(ch, bold) {
|
|
|
26362
27639
|
return bold ? em * 1.08 : em;
|
|
26363
27640
|
}
|
|
26364
27641
|
var isOn2 = (value) => value === "1" || value === "on" || value === "true";
|
|
26365
|
-
function glyph(
|
|
26366
|
-
const width = Array.from(
|
|
27642
|
+
function glyph(text3, size, stretch = 1) {
|
|
27643
|
+
const width = Array.from(text3).reduce((sum, ch) => sum + glyphEm(ch, false), 0) * size;
|
|
26367
27644
|
const box = emptyBox();
|
|
26368
27645
|
box.width = width;
|
|
26369
27646
|
box.ascent = size * 0.78 * stretch;
|
|
@@ -26372,7 +27649,7 @@ function glyph(text2, size, stretch = 1) {
|
|
|
26372
27649
|
kind: "text",
|
|
26373
27650
|
x: 0,
|
|
26374
27651
|
y: 0,
|
|
26375
|
-
text:
|
|
27652
|
+
text: text3,
|
|
26376
27653
|
size,
|
|
26377
27654
|
italic: false,
|
|
26378
27655
|
bold: false,
|
|
@@ -26686,12 +27963,12 @@ function layoutStructure(tag, node, style, ctx) {
|
|
|
26686
27963
|
var isOn3 = (value) => value === "1" || value === "on" || value === "true";
|
|
26687
27964
|
var isUnaryContext = (ch) => isRelation(ch) || isBinary(ch) || /[([{,;:]/.test(ch);
|
|
26688
27965
|
function lastCharOf(node) {
|
|
26689
|
-
const
|
|
26690
|
-
return
|
|
27966
|
+
const text3 = readText(node);
|
|
27967
|
+
return text3 ? Array.from(text3).at(-1) ?? "" : "";
|
|
26691
27968
|
}
|
|
26692
27969
|
function layoutRun(node, style, atStart) {
|
|
26693
|
-
const
|
|
26694
|
-
if (!
|
|
27970
|
+
const text3 = readText(node);
|
|
27971
|
+
if (!text3) return emptyBox();
|
|
26695
27972
|
const rPr = child(node, "m:rPr");
|
|
26696
27973
|
const sty = val(child(rPr, "m:sty"));
|
|
26697
27974
|
const plain2 = style.plain || isOn3(val(child(rPr, "m:nor"))) || sty === "p" || sty === "b";
|
|
@@ -26699,7 +27976,7 @@ function layoutRun(node, style, atStart) {
|
|
|
26699
27976
|
const boxes = [];
|
|
26700
27977
|
let index = 0;
|
|
26701
27978
|
let previous = atStart ? "(" : "x";
|
|
26702
|
-
for (const raw of Array.from(
|
|
27979
|
+
for (const raw of Array.from(text3)) {
|
|
26703
27980
|
const ch = raw === "-" ? "\u2212" : raw;
|
|
26704
27981
|
const italic = !plain2 && /[A-Za-zα-ω]/.test(ch);
|
|
26705
27982
|
const unary = index === 0 ? atStart : isUnaryContext(previous);
|
|
@@ -26792,8 +28069,8 @@ function ommlFromElement(element) {
|
|
|
26792
28069
|
if (attribute.namespaceURI === "http://www.w3.org/2000/xmlns/") continue;
|
|
26793
28070
|
body[`@_${attribute.localName}`] = attribute.value;
|
|
26794
28071
|
}
|
|
26795
|
-
const
|
|
26796
|
-
if (
|
|
28072
|
+
const text3 = Array.from(node.childNodes).filter((child2) => child2.nodeType === 3 || child2.nodeType === 4).map((child2) => child2.nodeValue ?? "").join("");
|
|
28073
|
+
if (text3 && (!elements(node).length || text3.trim())) body["#text"] = text3;
|
|
26797
28074
|
return { [name2]: body };
|
|
26798
28075
|
};
|
|
26799
28076
|
return visit(element, 1);
|
|
@@ -26841,7 +28118,7 @@ function drawEquation(omml, sizePx, label = "", options2 = {}) {
|
|
|
26841
28118
|
}
|
|
26842
28119
|
|
|
26843
28120
|
// docx/layout/equation-object.ts
|
|
26844
|
-
var
|
|
28121
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
26845
28122
|
var CACHE_LIMIT = 256;
|
|
26846
28123
|
function latexLabel(omml) {
|
|
26847
28124
|
try {
|
|
@@ -26852,7 +28129,7 @@ function latexLabel(omml) {
|
|
|
26852
28129
|
}
|
|
26853
28130
|
function equationObject(omml, sizePx, display = false) {
|
|
26854
28131
|
const key = `${sizePx}|${display}|${omml}`;
|
|
26855
|
-
const hit =
|
|
28132
|
+
const hit = cache2.get(key);
|
|
26856
28133
|
if (hit !== void 0) return hit ?? void 0;
|
|
26857
28134
|
const drawing = drawEquation(omml, sizePx, latexLabel(omml), { display });
|
|
26858
28135
|
const object = drawing ? {
|
|
@@ -26863,19 +28140,55 @@ function equationObject(omml, sizePx, display = false) {
|
|
|
26863
28140
|
descentPx: drawing.descentPx,
|
|
26864
28141
|
chart: { svg: drawing.svg, label: "Equation" }
|
|
26865
28142
|
} : null;
|
|
26866
|
-
if (
|
|
26867
|
-
|
|
28143
|
+
if (cache2.size >= CACHE_LIMIT) cache2.delete(cache2.keys().next().value);
|
|
28144
|
+
cache2.set(key, object);
|
|
26868
28145
|
return object ?? void 0;
|
|
26869
28146
|
}
|
|
26870
28147
|
|
|
28148
|
+
// docx/run-language.ts
|
|
28149
|
+
function resolveEastAsiaLanguage(run, context = {}) {
|
|
28150
|
+
if (run.eastAsiaLanguage !== void 0) return run.eastAsiaLanguage;
|
|
28151
|
+
const catalog = context.runCatalog;
|
|
28152
|
+
if (!catalog) return void 0;
|
|
28153
|
+
const chainLanguage = (styleId) => {
|
|
28154
|
+
const visited = /* @__PURE__ */ new Set();
|
|
28155
|
+
for (let current = styleId; current && !visited.has(current); ) {
|
|
28156
|
+
visited.add(current);
|
|
28157
|
+
const style = catalog.styles[current];
|
|
28158
|
+
if (!style) return void 0;
|
|
28159
|
+
if (style.eastAsiaLanguage !== void 0) return style.eastAsiaLanguage;
|
|
28160
|
+
current = style.basedOn;
|
|
28161
|
+
}
|
|
28162
|
+
return void 0;
|
|
28163
|
+
};
|
|
28164
|
+
const paragraphStyle = context.paragraphStyleId || (context.paragraphCatalog ? Object.values(context.paragraphCatalog.styles).find((style) => style.isDefault)?.id : void 0);
|
|
28165
|
+
return chainLanguage(run.style) ?? chainLanguage(paragraphStyle) ?? catalog.docDefaultsEastAsiaLanguage;
|
|
28166
|
+
}
|
|
28167
|
+
|
|
28168
|
+
// docx/layout/adapt-table-floating.ts
|
|
28169
|
+
function floatingFrame(position) {
|
|
28170
|
+
const px = (twips2) => twips2 === void 0 ? 0 : twipsToPixels(twips2);
|
|
28171
|
+
const relativeFromH = position.horizontalAnchor === "page" || position.horizontalAnchor === "margin" ? position.horizontalAnchor : "column";
|
|
28172
|
+
const relativeFromV = position.verticalAnchor === "page" ? "page" : position.verticalAnchor === "text" || position.yAlign === "inline" ? "paragraph" : "margin";
|
|
28173
|
+
const alignV = position.yAlign === "inline" ? void 0 : position.yAlign;
|
|
28174
|
+
return {
|
|
28175
|
+
relativeFromH,
|
|
28176
|
+
...position.xAlign ? { alignH: position.xAlign } : {},
|
|
28177
|
+
offsetXPx: px(position.xTwips),
|
|
28178
|
+
relativeFromV,
|
|
28179
|
+
...alignV ? { alignV } : {},
|
|
28180
|
+
offsetYPx: position.yAlign === "inline" ? 0 : px(position.yTwips),
|
|
28181
|
+
distance: {
|
|
28182
|
+
topPx: px(position.topFromTextTwips),
|
|
28183
|
+
rightPx: px(position.rightFromTextTwips),
|
|
28184
|
+
bottomPx: px(position.bottomFromTextTwips),
|
|
28185
|
+
leftPx: px(position.leftFromTextTwips)
|
|
28186
|
+
}
|
|
28187
|
+
};
|
|
28188
|
+
}
|
|
28189
|
+
|
|
26871
28190
|
// docx/layout/adapt-table.ts
|
|
26872
28191
|
var twipsToPx2 = twipsToPixels;
|
|
26873
|
-
var DEFAULT_PADDING_TWIPS = {
|
|
26874
|
-
top: twips(0),
|
|
26875
|
-
right: twips(108),
|
|
26876
|
-
bottom: twips(0),
|
|
26877
|
-
left: twips(108)
|
|
26878
|
-
};
|
|
26879
28192
|
function cssHex(value) {
|
|
26880
28193
|
const hex = value?.replace(/^#/, "");
|
|
26881
28194
|
return hex && /^[0-9a-f]{6}$/i.test(hex) ? `#${hex}` : void 0;
|
|
@@ -26913,6 +28226,7 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
26913
28226
|
});
|
|
26914
28227
|
});
|
|
26915
28228
|
const merges = tableGrid(table);
|
|
28229
|
+
const tableMargins = resolveTableCellMargins(table, model.tableStyles);
|
|
26916
28230
|
const cellAt = (rowIndex, gridIndex) => {
|
|
26917
28231
|
const position = gridIndexes[rowIndex]?.indexOf(gridIndex) ?? -1;
|
|
26918
28232
|
return position >= 0 ? table.rows[rowIndex]?.[position] : void 0;
|
|
@@ -26923,6 +28237,18 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
26923
28237
|
...grid ? { widthPx: grid.reduce((sum, width) => sum + width, 0) } : {},
|
|
26924
28238
|
...table.indentTwips ? { indentPx: twipsToPx2(table.indentTwips) } : {},
|
|
26925
28239
|
...table.alignment ? { alignment: table.alignment } : {},
|
|
28240
|
+
...table.layout === "autofit" ? {
|
|
28241
|
+
autofit: {
|
|
28242
|
+
columns: Math.max(
|
|
28243
|
+
columnCount,
|
|
28244
|
+
...table.rows.map((row2) => row2.reduce((sum, cell) => sum + (cell.gridSpan ?? 1), 0))
|
|
28245
|
+
),
|
|
28246
|
+
...table.widthTwips ? { widthPx: twipsToPx2(table.widthTwips) } : {},
|
|
28247
|
+
...table.widthPercent ? { widthFraction: table.widthPercent } : {},
|
|
28248
|
+
...autofitOverhangsCellMargins(compatibilityProfile(model)) ? { legacyMargins: true } : {}
|
|
28249
|
+
}
|
|
28250
|
+
} : {},
|
|
28251
|
+
...table.floating && !_nested ? { floating: floatingFrame(table.floating) } : {},
|
|
26926
28252
|
rows: table.rows.map((row2, rowIndex) => ({
|
|
26927
28253
|
...rowLayout(table.rowProperties?.[rowIndex]),
|
|
26928
28254
|
cells: row2.map((cell, cellIndex) => {
|
|
@@ -26948,7 +28274,7 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
26948
28274
|
}
|
|
26949
28275
|
if (cell.verticalMerge === "continue") delete borders.top;
|
|
26950
28276
|
if (cellAt(rowIndex + 1, start)?.verticalMerge === "continue") delete borders.bottom;
|
|
26951
|
-
const margins = { ...
|
|
28277
|
+
const margins = { ...tableMargins, ...cell.margins };
|
|
26952
28278
|
const padding = {
|
|
26953
28279
|
top: twipsToPx2(margins.top),
|
|
26954
28280
|
right: twipsToPx2(margins.right),
|
|
@@ -26972,6 +28298,8 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
26972
28298
|
} : {},
|
|
26973
28299
|
...width !== void 0 ? { widthPx: width } : {},
|
|
26974
28300
|
...grid && xPx !== void 0 ? { xPx } : {},
|
|
28301
|
+
...cell.widthTwips ? { preferredWidthPx: twipsToPx2(cell.widthTwips) } : {},
|
|
28302
|
+
...cell.widthPercent ? { preferredFraction: cell.widthPercent } : {},
|
|
26975
28303
|
padding,
|
|
26976
28304
|
...Object.keys(borders).length ? { borders } : {},
|
|
26977
28305
|
...fill ? { shading: fill } : {},
|
|
@@ -27112,8 +28440,9 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27112
28440
|
const reviewMode = options2.reviewDisplayMode ?? "all";
|
|
27113
28441
|
const visibleModel = visibleReviewModel(model, reviewMode);
|
|
27114
28442
|
const catalog = model.paragraphStyles;
|
|
27115
|
-
const
|
|
27116
|
-
const
|
|
28443
|
+
const compatibility = compatibilityProfile(model);
|
|
28444
|
+
const addParagraphSpacing = addsParagraphSpacing(compatibility);
|
|
28445
|
+
const keepSpaceBeforePageBreak = keepsSpaceBeforePageBreak(compatibility);
|
|
27117
28446
|
const autoSpaced = (auto, twipsValue) => auto && !addParagraphSpacing ? HTML_AUTO_SPACING_TWIPS : twipsValue;
|
|
27118
28447
|
const noted = /* @__PURE__ */ new Set();
|
|
27119
28448
|
const reportOnce = (message) => {
|
|
@@ -27150,7 +28479,7 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27150
28479
|
const noteText = run.noteReference ? noteLabel(run.noteReference.kind, run.noteReference.id) : run.noteMark ? markLabel ?? "" : void 0;
|
|
27151
28480
|
const formText = formFieldDisplayText(run);
|
|
27152
28481
|
const shaded = model.formFieldShading !== false && (formText !== void 0 || name2 === "FORMTEXT");
|
|
27153
|
-
const
|
|
28482
|
+
const text3 = noteText ?? formText ?? (run.field && !isFieldLocked(run) && (name2 === "DATE" || name2 === "TIME") ? dateFieldResult(name2, run.field.instr, now) : run.equation ? equation ? "" : "[Equation]" : run.text);
|
|
27154
28483
|
const script = formatting.verticalAlign === "superscript" || noteText !== void 0 && formatting.verticalAlign === void 0 ? "super" : formatting.verticalAlign === "subscript" ? "sub" : void 0;
|
|
27155
28484
|
const image = run.image;
|
|
27156
28485
|
if (image?.unsupported === "Text box") reportOnce(TEXT_BOX_NOTE);
|
|
@@ -27160,19 +28489,22 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27160
28489
|
widthPx: 192,
|
|
27161
28490
|
heightPx: 1,
|
|
27162
28491
|
noteSeparator: run.noteSeparator
|
|
27163
|
-
} :
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
|
|
27171
|
-
|
|
28492
|
+
} : (
|
|
28493
|
+
// A picture watermark floats behind the page text and takes no room in the header.
|
|
28494
|
+
image && !image.anchored && !image.pictureWatermark ? {
|
|
28495
|
+
partName: image.partName,
|
|
28496
|
+
...image.pictureFill ? { pictureFill: image.pictureFill } : {},
|
|
28497
|
+
contentType: image.contentType,
|
|
28498
|
+
widthPx: image.widthPx,
|
|
28499
|
+
heightPx: image.heightPx,
|
|
28500
|
+
...image.chart ? { chart: docxChartPaint(image.chart, image.widthPx, image.heightPx, theme) } : {},
|
|
28501
|
+
...image.shape ? shapeChart(image.shape, image.widthPx, image.heightPx, theme) : {}
|
|
28502
|
+
} : void 0
|
|
28503
|
+
));
|
|
27172
28504
|
return {
|
|
27173
28505
|
sourceLength: reviewSourceLength(run),
|
|
27174
28506
|
// Hidden text (`w:vanish`) takes no space when printed, as in Word by default.
|
|
27175
|
-
text: image || formatting.vanish ? "" : formatting.caps ?
|
|
28507
|
+
text: image || formatting.vanish ? "" : formatting.caps ? text3.toUpperCase() : text3,
|
|
27176
28508
|
...run.noteReference?.kind === "footnote" ? { footnoteReferenceId: run.noteReference.id } : {},
|
|
27177
28509
|
...object ? { object } : {},
|
|
27178
28510
|
...definedProps({
|
|
@@ -27192,17 +28524,26 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27192
28524
|
...formatting.underline ? { underline: true } : {},
|
|
27193
28525
|
...formatting.strike || formatting.doubleStrike ? { strike: true } : {},
|
|
27194
28526
|
...run.break ? { breakAfter: run.break } : {},
|
|
27195
|
-
...script ? { script } : {}
|
|
28527
|
+
...script ? { script } : {},
|
|
28528
|
+
...definedProps({
|
|
28529
|
+
kinsokuLanguage: kinsokuLanguage(
|
|
28530
|
+
resolveEastAsiaLanguage(run, {
|
|
28531
|
+
runCatalog: model.characterStyles,
|
|
28532
|
+
paragraphCatalog: catalog,
|
|
28533
|
+
paragraphStyleId
|
|
28534
|
+
})
|
|
28535
|
+
)
|
|
28536
|
+
})
|
|
27196
28537
|
};
|
|
27197
28538
|
}
|
|
27198
28539
|
const labels = computeListLabels(model);
|
|
27199
28540
|
function labelRun(paragraph, label) {
|
|
27200
|
-
const
|
|
28541
|
+
const first4 = adaptRun(paragraph.runs[0] ?? { text: "" }, paragraph.style);
|
|
27201
28542
|
const marker = label.markerFormat;
|
|
27202
28543
|
const suffix = label.suffix === "tab" ? " " : label.suffix === "space" ? " " : "";
|
|
27203
28544
|
const pictureWidthPx = label.picture ? pictureBulletSizePt(
|
|
27204
28545
|
label.picture,
|
|
27205
|
-
marker?.fontSizeHalfPoints ? marker.fontSizeHalfPoints / 2 :
|
|
28546
|
+
marker?.fontSizeHalfPoints ? marker.fontSizeHalfPoints / 2 : first4.fontSizePt ?? 11
|
|
27206
28547
|
).widthPt * 4 / 3 : void 0;
|
|
27207
28548
|
return {
|
|
27208
28549
|
text: `${displayListLabel(label.text)}${suffix}`,
|
|
@@ -27213,12 +28554,12 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27213
28554
|
...pictureWidthPx !== void 0 ? { widthPx: pictureWidthPx } : {}
|
|
27214
28555
|
},
|
|
27215
28556
|
...definedProps({
|
|
27216
|
-
bold: marker?.bold ??
|
|
27217
|
-
italic: marker?.italic ??
|
|
27218
|
-
fontFamily: marker?.fontFamily ??
|
|
27219
|
-
fontSizePt: marker?.fontSizeHalfPoints ? marker.fontSizeHalfPoints / 2 :
|
|
28557
|
+
bold: marker?.bold ?? first4.bold,
|
|
28558
|
+
italic: marker?.italic ?? first4.italic,
|
|
28559
|
+
fontFamily: marker?.fontFamily ?? first4.fontFamily,
|
|
28560
|
+
fontSizePt: marker?.fontSizeHalfPoints ? marker.fontSizeHalfPoints / 2 : first4.fontSizePt
|
|
27220
28561
|
}),
|
|
27221
|
-
...marker?.color ||
|
|
28562
|
+
...marker?.color || first4.color ? { color: marker?.color ?? first4.color } : {}
|
|
27222
28563
|
};
|
|
27223
28564
|
}
|
|
27224
28565
|
const betweenBorders = /* @__PURE__ */ new Map();
|
|
@@ -27284,7 +28625,12 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27284
28625
|
...resolved.keepNext ? { keepNext: true } : {},
|
|
27285
28626
|
...resolved.keepLines ? { keepLines: true } : {},
|
|
27286
28627
|
...resolved.widowControl === false ? { widowControl: false } : {},
|
|
27287
|
-
...resolved.contextualSpacing ? { contextualSpacing: true } : {}
|
|
28628
|
+
...resolved.contextualSpacing ? { contextualSpacing: true } : {},
|
|
28629
|
+
...resolved.kinsoku === false ? { kinsoku: false } : {},
|
|
28630
|
+
...resolved.autoSpaceDE === false ? { autoSpaceDE: false } : {},
|
|
28631
|
+
...resolved.autoSpaceDN === false ? { autoSpaceDN: false } : {},
|
|
28632
|
+
...resolved.overflowPunct === false ? { overflowPunct: false } : {},
|
|
28633
|
+
...model.kinsoku ? { kinsokuSettings: model.kinsoku } : {}
|
|
27288
28634
|
};
|
|
27289
28635
|
}
|
|
27290
28636
|
function adaptBlock(block) {
|
|
@@ -27317,8 +28663,8 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27317
28663
|
])
|
|
27318
28664
|
) : void 0;
|
|
27319
28665
|
const sections2 = model.sections;
|
|
27320
|
-
const modernFootnoteSeparator =
|
|
27321
|
-
const legacyFootnoteColumns =
|
|
28666
|
+
const modernFootnoteSeparator = usesModernFootnoteLayout(compatibility);
|
|
28667
|
+
const legacyFootnoteColumns = attachesFootnotesToBodyColumns(compatibility);
|
|
27322
28668
|
if (!modernFootnoteSeparator && !legacyFootnoteColumns && model.sections?.some((section) => section.footnoteColumns !== void 0))
|
|
27323
28669
|
reportOnce(
|
|
27324
28670
|
"Footnote column settings are preserved, but this compatibility mode has not been verified against native Word; Print Layout uses the existing page-wide fallback."
|
|
@@ -27427,112 +28773,100 @@ function adaptDocumentModel(model, note = () => {
|
|
|
27427
28773
|
};
|
|
27428
28774
|
}
|
|
27429
28775
|
|
|
27430
|
-
// docx/layout/
|
|
27431
|
-
|
|
27432
|
-
|
|
27433
|
-
const
|
|
27434
|
-
|
|
27435
|
-
|
|
27436
|
-
|
|
27437
|
-
|
|
27438
|
-
return { start: contentLeft, size: page.widthPx - contentLeft - page.marginRightPx };
|
|
27439
|
-
case "leftMargin":
|
|
27440
|
-
case "insideMargin":
|
|
27441
|
-
return { start: 0, size: contentLeft };
|
|
27442
|
-
case "rightMargin":
|
|
27443
|
-
case "outsideMargin":
|
|
27444
|
-
return { start: page.widthPx - page.marginRightPx, size: page.marginRightPx };
|
|
27445
|
-
default:
|
|
27446
|
-
return { start: contentLeft + column.xPx, size: column.widthPx };
|
|
28776
|
+
// docx/layout/computed-field-runs.ts
|
|
28777
|
+
function patches(paragraph, fields) {
|
|
28778
|
+
if (!paragraph.runs.some((run) => run.field || run.fieldChar)) return [];
|
|
28779
|
+
const starts = [];
|
|
28780
|
+
let offset = 0;
|
|
28781
|
+
for (const run of paragraph.runs) {
|
|
28782
|
+
starts.push(offset);
|
|
28783
|
+
offset += reviewSourceLength(run);
|
|
27447
28784
|
}
|
|
27448
|
-
|
|
27449
|
-
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
|
|
27463
|
-
return { start: page.heightPx - page.marginBottomPx, size: page.marginBottomPx };
|
|
27464
|
-
default:
|
|
27465
|
-
return { start: paragraphTopPx, size: paragraphHeightPx };
|
|
28785
|
+
const stretch = (at) => ({
|
|
28786
|
+
from: starts[at],
|
|
28787
|
+
to: starts[at] + reviewSourceLength(paragraph.runs[at]),
|
|
28788
|
+
source: paragraph.runs[at].text
|
|
28789
|
+
});
|
|
28790
|
+
const found = [];
|
|
28791
|
+
for (const field of fieldResultSpans(paragraph.runs, { resultless: true })) {
|
|
28792
|
+
if (field.locked) continue;
|
|
28793
|
+
const result = fields.result(field, paragraph);
|
|
28794
|
+
if (!result) continue;
|
|
28795
|
+
if (field.resultless) found.push({ ...stretch(field.to), result });
|
|
28796
|
+
else
|
|
28797
|
+
field.runs.forEach(
|
|
28798
|
+
(at, index) => found.push({ ...stretch(at), result: index === 0 ? result : void 0 })
|
|
28799
|
+
);
|
|
27466
28800
|
}
|
|
28801
|
+
return found;
|
|
27467
28802
|
}
|
|
27468
|
-
function
|
|
27469
|
-
|
|
27470
|
-
|
|
27471
|
-
|
|
27472
|
-
|
|
27473
|
-
return area.start + (offset ?? 0);
|
|
27474
|
-
}
|
|
27475
|
-
function floatPosition(float, page, column, paragraph) {
|
|
27476
|
-
const h = horizontalArea(float, page, column);
|
|
27477
|
-
const v = verticalArea(float, page, paragraph.topPx, paragraph.heightPx);
|
|
28803
|
+
function patched(run, patch, first4) {
|
|
28804
|
+
const { result } = patch;
|
|
28805
|
+
const sourceLength = run.sourceLength ?? run.text.length;
|
|
28806
|
+
const text3 = first4 && result ? result.text : "";
|
|
28807
|
+
const caps = run.text !== patch.source && run.text === patch.source.toUpperCase();
|
|
27478
28808
|
return {
|
|
27479
|
-
|
|
27480
|
-
|
|
28809
|
+
...run,
|
|
28810
|
+
text: caps ? text3.toUpperCase() : text3,
|
|
28811
|
+
sourceLength,
|
|
28812
|
+
...first4 && result?.fontFamily ? { fontFamily: result.fontFamily } : {},
|
|
28813
|
+
...first4 && result?.fontSizePt ? { fontSizePt: result.fontSizePt } : {}
|
|
27481
28814
|
};
|
|
27482
28815
|
}
|
|
27483
|
-
function
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
|
|
28816
|
+
function paragraphWithResults2(paragraph, model, fields) {
|
|
28817
|
+
const list = model ? patches(model, fields) : [];
|
|
28818
|
+
if (!list.length) return paragraph;
|
|
28819
|
+
let offset = 0;
|
|
28820
|
+
let changed = false;
|
|
28821
|
+
const runs = paragraph.runs.map((run) => {
|
|
28822
|
+
if (run.synthetic) return run;
|
|
28823
|
+
const from = offset;
|
|
28824
|
+
offset += run.sourceLength ?? run.text.length;
|
|
28825
|
+
const patch = list.find((item) => from >= item.from && from < item.to);
|
|
28826
|
+
if (!patch || run.hidden || run.object || run.text === "" && patch.source !== "") return run;
|
|
28827
|
+
changed = true;
|
|
28828
|
+
return patched(run, patch, from === patch.from);
|
|
28829
|
+
});
|
|
28830
|
+
return changed ? { ...paragraph, runs } : paragraph;
|
|
28831
|
+
}
|
|
28832
|
+
function withComputedFieldRuns(input, model) {
|
|
28833
|
+
const fields = computedFields(model);
|
|
28834
|
+
const paragraphs = new Map(documentParagraphs(model.blocks).map((item) => [item.id, item]));
|
|
28835
|
+
const block = (item) => {
|
|
28836
|
+
if (item.kind === "paragraph")
|
|
28837
|
+
return paragraphWithResults2(item, paragraphs.get(item.id), fields);
|
|
28838
|
+
let changed2 = false;
|
|
28839
|
+
const rows2 = item.rows.map((row2) => {
|
|
28840
|
+
const cells = row2.cells.map((cell) => {
|
|
28841
|
+
const next = cell.paragraphs.map((paragraph) => block(paragraph));
|
|
28842
|
+
const blocks = cell.blocks?.map(block);
|
|
28843
|
+
if (next.every((paragraph, index) => paragraph === cell.paragraphs[index]) && (blocks ?? []).every((child2, index) => child2 === cell.blocks[index]))
|
|
28844
|
+
return cell;
|
|
28845
|
+
changed2 = true;
|
|
28846
|
+
return { ...cell, paragraphs: next, ...blocks ? { blocks } : {} };
|
|
28847
|
+
});
|
|
28848
|
+
return cells.every((cell, index) => cell === row2.cells[index]) ? row2 : { ...row2, cells };
|
|
28849
|
+
});
|
|
28850
|
+
return changed2 ? { ...item, rows: rows2 } : item;
|
|
27487
28851
|
};
|
|
27488
|
-
|
|
27489
|
-
|
|
27490
|
-
|
|
27491
|
-
|
|
27492
|
-
|
|
27493
|
-
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
const placed2 = /* @__PURE__ */ new Set();
|
|
27497
|
-
for (const page of pages) {
|
|
27498
|
-
const boxes = [];
|
|
27499
|
-
for (const column of page.columns)
|
|
27500
|
-
for (const block of column.blocks) {
|
|
27501
|
-
const floats = block.kind === "paragraph" ? floatsById.get(block.blockId) : void 0;
|
|
27502
|
-
if (!floats || placed2.has(block.blockId)) continue;
|
|
27503
|
-
placed2.add(block.blockId);
|
|
27504
|
-
const top = page.marginTopPx + block.yPx;
|
|
27505
|
-
for (const float of floats) {
|
|
27506
|
-
const frame2 = { topPx: top, heightPx: block.heightPx };
|
|
27507
|
-
const position = floatPosition(float, page, column, frame2);
|
|
27508
|
-
const origin = floatOrigin(float, page, column, frame2);
|
|
27509
|
-
boxes.push({
|
|
27510
|
-
blockId: block.blockId,
|
|
27511
|
-
index: float.index ?? floats.indexOf(float),
|
|
27512
|
-
originXPx: origin.xPx,
|
|
27513
|
-
originYPx: origin.yPx,
|
|
27514
|
-
...position,
|
|
27515
|
-
widthPx: float.widthPx,
|
|
27516
|
-
heightPx: float.heightPx,
|
|
27517
|
-
partName: float.partName,
|
|
27518
|
-
...float.pictureFill ? { pictureFill: float.pictureFill } : {},
|
|
27519
|
-
contentType: float.contentType,
|
|
27520
|
-
...float.chart ? { chart: float.chart } : {},
|
|
27521
|
-
behindText: Boolean(float.behindText),
|
|
27522
|
-
...float.wrap ? { wrap: float.wrap } : {},
|
|
27523
|
-
...float.wrapText ? { wrapText: float.wrapText } : {}
|
|
27524
|
-
});
|
|
27525
|
-
}
|
|
27526
|
-
}
|
|
27527
|
-
if (boxes.length) page.floats = boxes;
|
|
27528
|
-
}
|
|
27529
|
-
return true;
|
|
28852
|
+
let changed = false;
|
|
28853
|
+
const sections2 = input.sections.map((section) => {
|
|
28854
|
+
const blocks = section.blocks.map(block);
|
|
28855
|
+
if (blocks.every((item, index) => item === section.blocks[index])) return section;
|
|
28856
|
+
changed = true;
|
|
28857
|
+
return { ...section, blocks };
|
|
28858
|
+
});
|
|
28859
|
+
return changed ? { ...input, sections: sections2 } : input;
|
|
27530
28860
|
}
|
|
27531
28861
|
|
|
27532
28862
|
// docx/layout/layout.ts
|
|
27533
28863
|
function layoutDocument(input, measurer) {
|
|
27534
28864
|
let result = layoutSections(input, measurer);
|
|
27535
|
-
|
|
28865
|
+
const pictures = positionFloats(input, result.pages);
|
|
28866
|
+
const tables = input.sections.some(
|
|
28867
|
+
(section) => section.blocks.some((block) => block.kind === "table" && block.floating)
|
|
28868
|
+
);
|
|
28869
|
+
if (!pictures && !tables) return result;
|
|
27536
28870
|
let exclusions = wrapExclusions(result.pages);
|
|
27537
28871
|
for (let pass = 0; exclusions.size && pass < 3; pass++) {
|
|
27538
28872
|
result = layoutSections(input, measurer, exclusions);
|
|
@@ -27541,15 +28875,15 @@ function layoutDocument(input, measurer) {
|
|
|
27541
28875
|
if (sameExclusions(next, exclusions)) break;
|
|
27542
28876
|
exclusions = next;
|
|
27543
28877
|
}
|
|
27544
|
-
|
|
28878
|
+
const notes = pictures ? [...result.approximations, FLOAT_WRAP_NOTE] : result.approximations;
|
|
28879
|
+
return { ...result, approximations: [...new Set(notes)] };
|
|
27545
28880
|
}
|
|
27546
28881
|
function layoutDocumentModel(model, measurer, options2 = {}, layout = layoutDocument) {
|
|
27547
28882
|
const projected = reviewDocumentFormatting(model, options2.reviewDisplayMode ?? "all");
|
|
27548
28883
|
const approximations = reviewFormattingWarnings(projected.diagnostics);
|
|
27549
|
-
const input =
|
|
27550
|
-
projected.model,
|
|
27551
|
-
|
|
27552
|
-
options2
|
|
28884
|
+
const input = withComputedFieldRuns(
|
|
28885
|
+
adaptDocumentModel(projected.model, (message) => approximations.push(message), options2),
|
|
28886
|
+
projected.model
|
|
27553
28887
|
);
|
|
27554
28888
|
const result = layout(input, measurer);
|
|
27555
28889
|
return {
|
|
@@ -27609,7 +28943,7 @@ function collectDocxWebfontRuns(model) {
|
|
|
27609
28943
|
text: ""
|
|
27610
28944
|
});
|
|
27611
28945
|
};
|
|
27612
|
-
const emit = (
|
|
28946
|
+
const emit = (text3, formatting, family) => {
|
|
27613
28947
|
const latin = family || DEFAULT_FONT_FAMILY;
|
|
27614
28948
|
const eaRole = formatting.fontTheme?.eastAsia;
|
|
27615
28949
|
const csRole = formatting.fontTheme?.cs;
|
|
@@ -27621,7 +28955,7 @@ function collectDocxWebfontRuns(model) {
|
|
|
27621
28955
|
complexScript: formatting.fontFamilyComplexScript || csRole && theme?.fonts[csRole]?.complexScript || latin,
|
|
27622
28956
|
symbol: latin
|
|
27623
28957
|
};
|
|
27624
|
-
for (const piece of segmentByFont(
|
|
28958
|
+
for (const piece of segmentByFont(text3, fonts))
|
|
27625
28959
|
push({ family: piece.fontFamily, bold, italic, text: piece.text });
|
|
27626
28960
|
};
|
|
27627
28961
|
const paragraphRuns = (paragraph, tableStyleRun) => {
|
|
@@ -27723,9 +29057,9 @@ function describePages(pages, indexOf) {
|
|
|
27723
29057
|
const firstBlock = [];
|
|
27724
29058
|
const startsBlock = [];
|
|
27725
29059
|
for (const page of pages) {
|
|
27726
|
-
const
|
|
27727
|
-
firstBlock.push(
|
|
27728
|
-
const line4 =
|
|
29060
|
+
const first4 = paragraphBoxes(page)[0];
|
|
29061
|
+
firstBlock.push(first4 ? indexOf.get(first4.blockId) : void 0);
|
|
29062
|
+
const line4 = first4?.kind === "paragraph" ? first4.lines[0] : void 0;
|
|
27729
29063
|
startsBlock.push(line4 !== void 0 && line4.sourceStart === 0);
|
|
27730
29064
|
}
|
|
27731
29065
|
return { firstBlock, startsBlock };
|
|
@@ -27793,8 +29127,8 @@ function layoutDocumentIncremental(input, measurer, memory) {
|
|
|
27793
29127
|
const delta = oldCount - blocks.length;
|
|
27794
29128
|
let page = 0;
|
|
27795
29129
|
for (let index = previous.firstBlock.length - 1; index > 0; index--) {
|
|
27796
|
-
const
|
|
27797
|
-
if (
|
|
29130
|
+
const first4 = previous.firstBlock[index];
|
|
29131
|
+
if (first4 !== void 0 && previous.startsBlock[index] && first4 <= prefix2 - LOOKAHEAD_BLOCKS) {
|
|
27798
29132
|
page = index;
|
|
27799
29133
|
break;
|
|
27800
29134
|
}
|
|
@@ -27855,7 +29189,7 @@ function layoutDocumentIncremental(input, measurer, memory) {
|
|
|
27855
29189
|
// docx/layout/layout-session.ts
|
|
27856
29190
|
function createLayoutSession(measurer, options2 = {}) {
|
|
27857
29191
|
const sessionMeasurer = {
|
|
27858
|
-
widthOf: (
|
|
29192
|
+
widthOf: (text3, font) => measurer.widthOf(text3, font),
|
|
27859
29193
|
lineHeightOf: (font) => measurer.lineHeightOf(font),
|
|
27860
29194
|
...measurer.ascentOf ? { ascentOf: measurer.ascentOf.bind(measurer) } : {}
|
|
27861
29195
|
};
|
|
@@ -27870,4 +29204,4 @@ function createLayoutSession(measurer, options2 = {}) {
|
|
|
27870
29204
|
};
|
|
27871
29205
|
}
|
|
27872
29206
|
|
|
27873
|
-
export { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE_PT, DEFAULT_TAB_STOP_PX, FLOAT_WRAP_NOTE, NO_TWIPS, PageCursor, SINGLE_LINE_SPACING_UNITS, adaptDocumentModel, adjustForWidowOrphan, appendBreakMarker, cellVerticalOffset, collectDocxWebfontRuns, createFakeMeasurer, createLayoutSession, cssFontStack, fieldDisplayText, floatOrigin, floatPosition, fontMetrics, headerFooterForPage, headerFooterSlotForPage, isEastAsianChar, layoutDocument, layoutDocumentModel, layoutParagraph, layoutRow, layoutSections, ligatureCss, pageNumberValues, pageNumbers, pageStyleRefs, paragraphFloats, placeParagraph, placeTab, placeTable, positionFloats, ptToPx, pxToTwips, reviewSourceLength, sectionPageCounts, splitRowAtHeight, suppressesSpacing, tokenizeRun, twipsToPx, widowControlEnabled };
|
|
29207
|
+
export { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE_PT, DEFAULT_TAB_STOP_PX, FLOAT_WRAP_NOTE, NO_TWIPS, PageCursor, SINGLE_LINE_SPACING_UNITS, adaptDocumentModel, adjustForWidowOrphan, appendBreakMarker, breakAllowedBetween, cellVerticalOffset, collectDocxWebfontRuns, createFakeMeasurer, createLayoutSession, cssFontStack, fieldDisplayText, floatOrigin, floatPosition, fontMetrics, gluedCarry, graphemesOf, headerFooterForPage, headerFooterSlotForPage, inFlow, isEastAsianChar, kinsokuForbids, layoutDocument, layoutDocumentModel, layoutParagraph, layoutRow, layoutSections, ligatureCss, pageNumberValues, pageNumbers, pageStyleRefs, paragraphFloats, placeParagraph, placeTab, placeTable, positionFloats, ptToPx, pxToTwips, reviewSourceLength, sectionPageCounts, splitRowAtHeight, suppressesSpacing, tokenizeRun, twipsToPx, widowControlEnabled };
|