ooxml-core 1.30.1 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automation/index.cjs +5829 -3266
- package/dist/automation/index.mjs +5829 -3266
- package/dist/automation/node.cjs +2 -1
- package/dist/automation/node.d.ts.map +1 -1
- package/dist/automation/node.mjs +2 -1
- package/dist/automation/tools/define.d.ts +2 -0
- package/dist/automation/tools/define.d.ts.map +1 -1
- package/dist/automation/tools/types.d.ts +6 -0
- package/dist/automation/tools/types.d.ts.map +1 -1
- package/dist/collab/index.cjs +35 -4
- package/dist/collab/index.mjs +35 -4
- package/dist/collab/websocket-transport.d.ts +9 -1
- package/dist/collab/websocket-transport.d.ts.map +1 -1
- package/dist/docx/data-binding.d.ts +9 -0
- package/dist/docx/data-binding.d.ts.map +1 -0
- package/dist/docx/document-parts.d.ts +1 -0
- package/dist/docx/document-parts.d.ts.map +1 -1
- package/dist/docx/drawing.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +1383 -609
- package/dist/docx/embedded.mjs +1383 -609
- package/dist/docx/index.cjs +1394 -618
- package/dist/docx/index.mjs +1394 -618
- package/dist/docx/inline-model.d.ts +2 -0
- package/dist/docx/inline-model.d.ts.map +1 -1
- package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
- 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/equation-object.d.ts +1 -1
- package/dist/docx/layout/equation-object.d.ts.map +1 -1
- package/dist/docx/layout/floats.d.ts +1 -1
- package/dist/docx/layout/floats.d.ts.map +1 -1
- package/dist/docx/layout/flow-paragraph.d.ts +4 -0
- package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +452 -203
- package/dist/docx/layout/index.mjs +452 -203
- package/dist/docx/layout/input.d.ts +12 -0
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/nested-frame-profile.d.ts +3 -1
- package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -1
- package/dist/docx/layout/page-cursor.d.ts +11 -2
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-fragments.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-layout.d.ts +5 -0
- package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +4 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/section-flow.d.ts +2 -0
- package/dist/docx/layout/section-flow.d.ts.map +1 -1
- package/dist/docx/layout/table-layout.d.ts +4 -14
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-merged-rows.d.ts +21 -0
- package/dist/docx/layout/table-merged-rows.d.ts.map +1 -0
- package/dist/docx/layout/table-row-split.d.ts +16 -0
- package/dist/docx/layout/table-row-split.d.ts.map +1 -0
- package/dist/docx/layout/wrap.d.ts +2 -0
- package/dist/docx/layout/wrap.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +1397 -623
- package/dist/docx/load/index.mjs +1397 -623
- package/dist/docx/model-paragraph.d.ts +4 -1
- package/dist/docx/model-paragraph.d.ts.map +1 -1
- package/dist/docx/model.d.ts +24 -1
- package/dist/docx/model.d.ts.map +1 -1
- package/dist/docx/paragraph-properties.d.ts.map +1 -1
- package/dist/docx/paragraph-styles.d.ts.map +1 -1
- package/dist/docx/parse-table.d.ts.map +1 -1
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/run-segmentation.d.ts.map +1 -1
- package/dist/docx/save-modified.d.ts +4 -0
- package/dist/docx/save-modified.d.ts.map +1 -0
- package/dist/docx/save.d.ts +2 -2
- package/dist/docx/save.d.ts.map +1 -1
- package/dist/docx/style-formatting-package.d.ts +9 -0
- package/dist/docx/style-formatting-package.d.ts.map +1 -0
- package/dist/docx/style-numbering-package.d.ts +4 -1
- package/dist/docx/style-numbering-package.d.ts.map +1 -1
- package/dist/docx/table-grid.d.ts +35 -0
- package/dist/docx/table-grid.d.ts.map +1 -0
- package/dist/docx/table-structure-cells.d.ts +19 -0
- package/dist/docx/table-structure-cells.d.ts.map +1 -0
- package/dist/docx/table-structure-check.d.ts +12 -0
- package/dist/docx/table-structure-check.d.ts.map +1 -0
- package/dist/docx/table-structure-merge.d.ts +28 -0
- package/dist/docx/table-structure-merge.d.ts.map +1 -0
- package/dist/docx/table-structure.d.ts +30 -0
- package/dist/docx/table-structure.d.ts.map +1 -0
- package/dist/docx/ui/index.cjs +717 -256
- package/dist/docx/ui/index.d.ts +4 -0
- package/dist/docx/ui/index.d.ts.map +1 -1
- package/dist/docx/ui/index.mjs +703 -257
- 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/table-structure-guard.d.ts +2 -0
- package/dist/docx/ui/table-structure-guard.d.ts.map +1 -1
- package/dist/docx/word-content-control-docs.d.ts +5 -0
- package/dist/docx/word-content-control-docs.d.ts.map +1 -0
- package/dist/docx/word-corpus-gaps.d.ts +10 -0
- package/dist/docx/word-corpus-gaps.d.ts.map +1 -0
- package/dist/docx/word-measurer.d.ts +6 -0
- package/dist/docx/word-measurer.d.ts.map +1 -0
- package/dist/docx/word-spacing-docs.d.ts +12 -0
- package/dist/docx/word-spacing-docs.d.ts.map +1 -0
- package/dist/docx/word-table-docs.d.ts +9 -0
- package/dist/docx/word-table-docs.d.ts.map +1 -0
- package/dist/docx/write-drawing.d.ts.map +1 -1
- package/dist/docx/write-fallback.d.ts +5 -0
- package/dist/docx/write-fallback.d.ts.map +1 -0
- package/dist/docx/write-table-properties.d.ts +1 -0
- package/dist/docx/write-table-properties.d.ts.map +1 -1
- package/dist/docx/write-table-structure.d.ts +14 -0
- package/dist/docx/write-table-structure.d.ts.map +1 -0
- package/dist/docx/write-table.d.ts +3 -4
- package/dist/docx/write-table.d.ts.map +1 -1
- package/dist/index.cjs +22 -22
- package/dist/index.mjs +22 -22
- package/dist/math/index.cjs +22 -22
- package/dist/math/index.mjs +22 -22
- package/dist/math/omml-box-grouped.d.ts.map +1 -1
- package/dist/math/omml-box-layout.d.ts +3 -1
- package/dist/math/omml-box-layout.d.ts.map +1 -1
- package/dist/math/omml-box-structures.d.ts.map +1 -1
- package/dist/math/omml-box.d.ts +2 -0
- package/dist/math/omml-box.d.ts.map +1 -1
- package/dist/math/omml-svg.d.ts +6 -2
- package/dist/math/omml-svg.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +1 -0
- package/dist/pptx/automation/index.d.ts +6 -0
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +1 -0
- package/dist/teams/chat-rooms.d.ts.map +1 -1
- package/dist/teams/chat.d.ts +7 -0
- package/dist/teams/chat.d.ts.map +1 -1
- package/dist/teams/files.d.ts +1 -1
- package/dist/teams/files.d.ts.map +1 -1
- package/dist/teams/index.cjs +2735 -1148
- package/dist/teams/index.d.ts +3 -0
- package/dist/teams/index.d.ts.map +1 -1
- package/dist/teams/index.mjs +2710 -1148
- package/dist/teams/message-transfer.d.ts +1 -1
- package/dist/teams/message-transfer.d.ts.map +1 -1
- package/dist/teams/protocol.d.ts +30 -0
- package/dist/teams/protocol.d.ts.map +1 -0
- package/dist/teams/schema.d.ts +59 -0
- package/dist/teams/schema.d.ts.map +1 -0
- package/dist/teams/server-config.d.ts +19 -2
- package/dist/teams/server-config.d.ts.map +1 -1
- package/dist/teams/server-file-storage.d.ts +11 -1
- package/dist/teams/server-file-storage.d.ts.map +1 -1
- package/dist/teams/server-session.d.ts +2 -0
- package/dist/teams/server-session.d.ts.map +1 -1
- package/dist/teams/signaling.d.ts +2 -0
- package/dist/teams/signaling.d.ts.map +1 -1
- package/dist/teams/store.d.ts +9 -0
- package/dist/teams/store.d.ts.map +1 -1
- package/dist/teams/stored-file.d.ts +1 -1
- package/dist/teams/stored-file.d.ts.map +1 -1
- package/dist/teams/sync-transport.d.ts.map +1 -1
- package/dist/teams/validate-members.d.ts +28 -0
- package/dist/teams/validate-members.d.ts.map +1 -0
- package/dist/teams/validate-owned.d.ts +20 -0
- package/dist/teams/validate-owned.d.ts.map +1 -0
- package/dist/teams/validate-update.d.ts +70 -0
- package/dist/teams/validate-update.d.ts.map +1 -0
- package/dist/teams/workspace.d.ts +12 -0
- package/dist/teams/workspace.d.ts.map +1 -1
- package/dist/visio/connector-route-walk.d.ts +2 -0
- package/dist/visio/connector-route-walk.d.ts.map +1 -1
- package/dist/visio/edit-connector-reroute.d.ts.map +1 -1
- package/dist/visio/edit-connector.d.ts +2 -0
- package/dist/visio/edit-connector.d.ts.map +1 -1
- package/dist/visio/edit-delete.d.ts.map +1 -1
- package/dist/visio/edit-duplicate-line.d.ts +40 -0
- package/dist/visio/edit-duplicate-line.d.ts.map +1 -0
- package/dist/visio/edit-duplicate.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts +5 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-geometry.d.ts.map +1 -1
- package/dist/visio/edit-instance-duplicate.d.ts +2 -1
- package/dist/visio/edit-instance-duplicate.d.ts.map +1 -1
- package/dist/visio/edit-master-move.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts +23 -0
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-text.d.ts +12 -0
- package/dist/visio/edit-recalculate-text.d.ts.map +1 -0
- package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
- package/dist/visio/edit-recalculate.d.ts +15 -3
- package/dist/visio/edit-recalculate.d.ts.map +1 -1
- package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
- package/dist/visio/edit-stencil-connector-layout.d.ts +1 -1
- package/dist/visio/edit-stencil-connector-layout.d.ts.map +1 -1
- package/dist/visio/edit-text-scope.d.ts +4 -1
- package/dist/visio/edit-text-scope.d.ts.map +1 -1
- package/dist/visio/formula-analyze.d.ts +18 -0
- package/dist/visio/formula-analyze.d.ts.map +1 -0
- package/dist/visio/formula-bound.d.ts +4 -0
- package/dist/visio/formula-bound.d.ts.map +1 -0
- package/dist/visio/formula-evaluate.d.ts +2 -9
- package/dist/visio/formula-evaluate.d.ts.map +1 -1
- package/dist/visio/formula-extra-functions.d.ts +23 -0
- package/dist/visio/formula-extra-functions.d.ts.map +1 -0
- package/dist/visio/formula-indirect.d.ts +6 -0
- package/dist/visio/formula-indirect.d.ts.map +1 -0
- package/dist/visio/formula-master.d.ts +1 -0
- package/dist/visio/formula-master.d.ts.map +1 -1
- package/dist/visio/formula-operators.d.ts +6 -0
- package/dist/visio/formula-operators.d.ts.map +1 -0
- package/dist/visio/formula-text-functions.d.ts +5 -1
- package/dist/visio/formula-text-functions.d.ts.map +1 -1
- package/dist/visio/formula.d.ts +12 -0
- package/dist/visio/formula.d.ts.map +1 -1
- package/dist/visio/index.cjs +1354 -396
- package/dist/visio/index.mjs +1354 -396
- package/dist/visio/ui/index.cjs +1341 -383
- package/dist/visio/ui/index.mjs +1341 -383
- package/dist/xlsx/collab/apply.d.ts.map +1 -1
- package/dist/xlsx/collab/codec.d.ts +2 -0
- package/dist/xlsx/collab/codec.d.ts.map +1 -1
- package/dist/xlsx/collab/dirty.d.ts +4 -1
- package/dist/xlsx/collab/dirty.d.ts.map +1 -1
- package/dist/xlsx/collab/index.cjs +551 -106
- package/dist/xlsx/collab/index.mjs +551 -106
- package/dist/xlsx/collab/keyed.d.ts +36 -0
- package/dist/xlsx/collab/keyed.d.ts.map +1 -0
- package/dist/xlsx/collab/names.d.ts +2 -0
- package/dist/xlsx/collab/names.d.ts.map +1 -1
- package/dist/xlsx/collab/part-specs.d.ts +13 -0
- package/dist/xlsx/collab/part-specs.d.ts.map +1 -0
- package/dist/xlsx/collab/schema.d.ts +8 -0
- package/dist/xlsx/collab/schema.d.ts.map +1 -1
- package/dist/xlsx/collab/sheet-parts.d.ts +19 -0
- package/dist/xlsx/collab/sheet-parts.d.ts.map +1 -0
- package/dist/xlsx/collab/sheets.d.ts +6 -0
- package/dist/xlsx/collab/sheets.d.ts.map +1 -1
- package/dist/xlsx/collab/write.d.ts +3 -0
- package/dist/xlsx/collab/write.d.ts.map +1 -1
- package/dist/xlsx/edit/clipboard-areas.d.ts +17 -0
- package/dist/xlsx/edit/clipboard-areas.d.ts.map +1 -0
- package/dist/xlsx/edit/custom-views.d.ts +21 -0
- package/dist/xlsx/edit/custom-views.d.ts.map +1 -0
- package/dist/xlsx/edit/data-table.d.ts.map +1 -1
- package/dist/xlsx/edit/history.d.ts +1 -1
- package/dist/xlsx/edit/history.d.ts.map +1 -1
- package/dist/xlsx/edit/index.d.ts +2 -0
- package/dist/xlsx/edit/index.d.ts.map +1 -1
- package/dist/xlsx/edit/paste-selection.d.ts.map +1 -1
- package/dist/xlsx/edit/scenario-merge.d.ts +7 -0
- package/dist/xlsx/edit/scenario-merge.d.ts.map +1 -0
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/shift-data-tables.d.ts +7 -0
- package/dist/xlsx/edit/shift-data-tables.d.ts.map +1 -0
- package/dist/xlsx/edit/shift-scenarios.d.ts +7 -0
- package/dist/xlsx/edit/shift-scenarios.d.ts.map +1 -0
- package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
- package/dist/xlsx/edit/sparkline-grouping.d.ts +10 -0
- package/dist/xlsx/edit/sparkline-grouping.d.ts.map +1 -0
- package/dist/xlsx/edit/types.d.ts +21 -0
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/formula/ets-excel-compare.d.ts +24 -0
- package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-core.d.ts +36 -0
- package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-grid.d.ts +15 -0
- package/dist/xlsx/formula/functions/ets-grid.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init.d.ts +15 -0
- package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-input.d.ts +13 -0
- package/dist/xlsx/formula/functions/ets-input.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-season.d.ts +6 -0
- package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/forecast-ets.d.ts +3 -0
- package/dist/xlsx/formula/functions/forecast-ets.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/statistical.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +4444 -2447
- package/dist/xlsx/index.mjs +4423 -2448
- package/dist/xlsx/layout/form-control-link.d.ts +20 -0
- package/dist/xlsx/layout/form-control-link.d.ts.map +1 -0
- package/dist/xlsx/layout/form-control-state.d.ts +49 -0
- package/dist/xlsx/layout/form-control-state.d.ts.map +1 -0
- package/dist/xlsx/layout/form-control-view.d.ts +11 -0
- package/dist/xlsx/layout/form-control-view.d.ts.map +1 -0
- package/dist/xlsx/layout/header-footer-edit.d.ts +4 -2
- package/dist/xlsx/layout/header-footer-edit.d.ts.map +1 -1
- package/dist/xlsx/layout/header-footer.d.ts +16 -0
- package/dist/xlsx/layout/header-footer.d.ts.map +1 -1
- package/dist/xlsx/layout/index.d.ts +5 -0
- package/dist/xlsx/layout/index.d.ts.map +1 -1
- package/dist/xlsx/layout/ref-evaluator.d.ts +6 -0
- package/dist/xlsx/layout/ref-evaluator.d.ts.map +1 -1
- package/dist/xlsx/layout/shape-paint.d.ts +25 -0
- package/dist/xlsx/layout/shape-paint.d.ts.map +1 -0
- package/dist/xlsx/layout/shape-view.d.ts +15 -0
- package/dist/xlsx/layout/shape-view.d.ts.map +1 -0
- package/dist/xlsx/load/index.cjs +2134 -1103
- package/dist/xlsx/load/index.mjs +2134 -1103
- package/dist/xlsx/model-custom-views.d.ts +33 -0
- package/dist/xlsx/model-custom-views.d.ts.map +1 -0
- package/dist/xlsx/model-shapes.d.ts +78 -0
- package/dist/xlsx/model-shapes.d.ts.map +1 -0
- package/dist/xlsx/model.d.ts +38 -1
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/custom-views.d.ts +5 -0
- package/dist/xlsx/read/custom-views.d.ts.map +1 -0
- package/dist/xlsx/read/drawing.d.ts.map +1 -1
- package/dist/xlsx/read/form-control.d.ts +14 -0
- package/dist/xlsx/read/form-control.d.ts.map +1 -0
- package/dist/xlsx/read/header-footer-images.d.ts +5 -0
- package/dist/xlsx/read/header-footer-images.d.ts.map +1 -0
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/shape.d.ts +5 -0
- package/dist/xlsx/read/shape.d.ts.map +1 -0
- package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
- package/dist/xlsx/read/workbook-part.d.ts +5 -1
- package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/read/worksheet-children.d.ts +3 -0
- package/dist/xlsx/read/worksheet-children.d.ts.map +1 -0
- package/dist/xlsx/read/worksheet.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/what-if.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/what-if.d.ts +0 -1
- package/dist/xlsx/ui/commands/what-if.d.ts.map +1 -1
- package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts +51 -0
- package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts.map +1 -0
- package/dist/xlsx/ui/dialogs/scenario-summary.d.ts +15 -0
- package/dist/xlsx/ui/dialogs/scenario-summary.d.ts.map +1 -0
- package/dist/xlsx/ui/index.cjs +4411 -2195
- package/dist/xlsx/ui/index.d.ts +2 -0
- package/dist/xlsx/ui/index.d.ts.map +1 -1
- package/dist/xlsx/ui/index.mjs +4404 -2194
- package/dist/xlsx/ui/locales/de/grid.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/en/grid.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/es/grid.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/fr/grid.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/zh-CN/grid.d.ts.map +1 -1
- package/dist/xlsx/write/custom-views.d.ts +4 -0
- package/dist/xlsx/write/custom-views.d.ts.map +1 -0
- package/dist/xlsx/write/drawing.d.ts.map +1 -1
- package/dist/xlsx/write/form-control.d.ts +4 -0
- package/dist/xlsx/write/form-control.d.ts.map +1 -0
- package/dist/xlsx/write/sheet-data.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/worksheet.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -543,6 +543,8 @@ function resolveParagraphFormatting(paragraph, catalog) {
|
|
|
543
543
|
"direction",
|
|
544
544
|
"spacingBeforeTwips",
|
|
545
545
|
"spacingAfterTwips",
|
|
546
|
+
"spacingBeforeAuto",
|
|
547
|
+
"spacingAfterAuto",
|
|
546
548
|
"lineSpacingTwips",
|
|
547
549
|
"lineSpacingRule",
|
|
548
550
|
"indentLeftTwips",
|
|
@@ -1769,14 +1771,6 @@ function escapeXmlAttr(value) {
|
|
|
1769
1771
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1770
1772
|
}
|
|
1771
1773
|
|
|
1772
|
-
// docx/expect-defined.ts
|
|
1773
|
-
function expectDefined(value, context) {
|
|
1774
|
-
if (value === void 0 || value === null) {
|
|
1775
|
-
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
1776
|
-
}
|
|
1777
|
-
return value;
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
1774
|
// docx/element-order.ts
|
|
1781
1775
|
function orderChildren(parent, order) {
|
|
1782
1776
|
const elements2 = Array.from(parent.childNodes).filter(isElement);
|
|
@@ -1846,6 +1840,55 @@ function orderParagraphProperties(props) {
|
|
|
1846
1840
|
orderChildren(props, PPR_ORDER);
|
|
1847
1841
|
}
|
|
1848
1842
|
|
|
1843
|
+
// docx/expect-defined.ts
|
|
1844
|
+
function expectDefined(value, context) {
|
|
1845
|
+
if (value === void 0 || value === null) {
|
|
1846
|
+
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
1847
|
+
}
|
|
1848
|
+
return value;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
// docx/table-grid.ts
|
|
1852
|
+
var spanOf = (cell) => Math.max(1, cell.gridSpan ?? 1);
|
|
1853
|
+
function tableGrid(table) {
|
|
1854
|
+
const columns = table.grid?.length ?? sumSpans(table.rows[0]);
|
|
1855
|
+
if (!columns || !table.rows.length) return void 0;
|
|
1856
|
+
const rows2 = [];
|
|
1857
|
+
const cover = [];
|
|
1858
|
+
for (let row2 = 0; row2 < table.rows.length; row2++) {
|
|
1859
|
+
const cells = table.rows[row2] ?? [];
|
|
1860
|
+
if (!cells.length || sumSpans(cells) !== columns) return void 0;
|
|
1861
|
+
const placed2 = [];
|
|
1862
|
+
const line3 = new Array(columns);
|
|
1863
|
+
let col = 0;
|
|
1864
|
+
cells.forEach((cell, index) => {
|
|
1865
|
+
const entry = { cell, row: row2, index, col, span: spanOf(cell) };
|
|
1866
|
+
for (let k = 0; k < entry.span; k++) line3[col + k] = entry;
|
|
1867
|
+
col += entry.span;
|
|
1868
|
+
placed2.push(entry);
|
|
1869
|
+
});
|
|
1870
|
+
rows2.push(placed2);
|
|
1871
|
+
cover.push(line3);
|
|
1872
|
+
}
|
|
1873
|
+
const grid = { columns, rows: rows2, cover };
|
|
1874
|
+
for (const entry of rows2.flat())
|
|
1875
|
+
if (entry.cell.verticalMerge === "continue") {
|
|
1876
|
+
const above2 = entry.row > 0 ? cover[entry.row - 1]?.[entry.col] : void 0;
|
|
1877
|
+
if (!above2 || above2.col !== entry.col || above2.span !== entry.span) return void 0;
|
|
1878
|
+
if (!above2.cell.verticalMerge) return void 0;
|
|
1879
|
+
}
|
|
1880
|
+
return grid;
|
|
1881
|
+
}
|
|
1882
|
+
function sumSpans(cells) {
|
|
1883
|
+
return (cells ?? []).reduce((sum, cell) => sum + spanOf(cell), 0);
|
|
1884
|
+
}
|
|
1885
|
+
function rowSpanOf(grid, entry) {
|
|
1886
|
+
if (entry.cell.verticalMerge !== "restart") return 1;
|
|
1887
|
+
let height = 1;
|
|
1888
|
+
while (grid.cover[entry.row + height]?.[entry.col]?.cell.verticalMerge === "continue") height++;
|
|
1889
|
+
return height;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1849
1892
|
// docx/special-characters.ts
|
|
1850
1893
|
function symbolCharacter(char) {
|
|
1851
1894
|
const code = /^[0-9a-f]{1,6}$/i.test(char) ? Number.parseInt(char, 16) : Number.NaN;
|
|
@@ -16974,6 +17017,10 @@ function parseDirectParagraphProperties(props) {
|
|
|
16974
17017
|
const line3 = signedTwipValue(getW(spacing2, "line"));
|
|
16975
17018
|
if (before !== void 0) paragraph.spacingBeforeTwips = before;
|
|
16976
17019
|
if (after !== void 0) paragraph.spacingAfterTwips = after;
|
|
17020
|
+
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
17021
|
+
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
17022
|
+
if (beforeAuto !== void 0) paragraph.spacingBeforeAuto = beforeAuto;
|
|
17023
|
+
if (afterAuto !== void 0) paragraph.spacingAfterAuto = afterAuto;
|
|
16977
17024
|
if (line3 !== void 0) {
|
|
16978
17025
|
paragraph.lineSpacingTwips = line3;
|
|
16979
17026
|
}
|
|
@@ -18658,8 +18705,8 @@ function justify(fragments, width) {
|
|
|
18658
18705
|
const spaceIndices = fragments.map((f, i) => f.text === " " ? i : -1).filter((i) => i >= 0);
|
|
18659
18706
|
if (!spaceIndices.length || !fragments.length) return fragments;
|
|
18660
18707
|
const natural = fragments.at(-1).xPx + fragments.at(-1).widthPx;
|
|
18661
|
-
const extra =
|
|
18662
|
-
if (extra
|
|
18708
|
+
const extra = (width - natural) / spaceIndices.length;
|
|
18709
|
+
if (extra === 0) return fragments;
|
|
18663
18710
|
let shift = 0;
|
|
18664
18711
|
return fragments.map((fragment, index) => {
|
|
18665
18712
|
const placedFragment = { ...fragment, xPx: fragment.xPx + shift };
|
|
@@ -18703,6 +18750,7 @@ function cachedParagraphLayout(measurer, key, note, compute) {
|
|
|
18703
18750
|
}
|
|
18704
18751
|
|
|
18705
18752
|
// docx/layout/paragraph-layout.ts
|
|
18753
|
+
var SPACE_SHRINK = 0.145;
|
|
18706
18754
|
function layoutParagraph(paragraph, contentWidthPx, measurer, note, lineBox, startToken = 0) {
|
|
18707
18755
|
if (lineBox)
|
|
18708
18756
|
return measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, startToken);
|
|
@@ -18741,6 +18789,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18741
18789
|
let widthOverflowNoted = false;
|
|
18742
18790
|
let placed2 = [];
|
|
18743
18791
|
let lineWidthPx = 0;
|
|
18792
|
+
let lineSpacePx = 0;
|
|
18793
|
+
let jump;
|
|
18744
18794
|
let marginReachPx = 0;
|
|
18745
18795
|
let tokenCursor = startToken;
|
|
18746
18796
|
let firstToken = startToken;
|
|
@@ -18758,7 +18808,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18758
18808
|
boxes[lineIndex] = {
|
|
18759
18809
|
leftInsetPx: box?.leftInsetPx ?? 0,
|
|
18760
18810
|
rightInsetPx: box?.rightInsetPx ?? 0,
|
|
18761
|
-
gapBeforePx: gap
|
|
18811
|
+
gapBeforePx: gap,
|
|
18812
|
+
...box?.hole ? { hole: box.hole } : {}
|
|
18762
18813
|
};
|
|
18763
18814
|
}
|
|
18764
18815
|
return expectDefined(boxes[lineIndex], "line box");
|
|
@@ -18805,7 +18856,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18805
18856
|
while (rendered.length && rendered.at(-1).token.kind === "space") rendered.pop();
|
|
18806
18857
|
const fragments = buildFragments(rendered, paragraph);
|
|
18807
18858
|
const [firstPlaced] = placed2;
|
|
18808
|
-
const start = firstPlaced ? globalOffset(firstPlaced.token) : 0;
|
|
18859
|
+
const start = lines.length === 0 && startToken === 0 ? 0 : firstPlaced ? globalOffset(firstPlaced.token) : 0;
|
|
18809
18860
|
const last = placed2.at(-1)?.token;
|
|
18810
18861
|
const end = last ? globalOffset(last, last.kind === "word" || last.kind === "space" ? last.text.length : 1) : start;
|
|
18811
18862
|
const gapBeforePx = boxFor(lineIndex).gapBeforePx;
|
|
@@ -18821,6 +18872,9 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18821
18872
|
fragment.topPx = baselinePx - extent2.above;
|
|
18822
18873
|
if (token.kind !== "object") fragment.boxHeightPx = extent2.ascent + extent2.descent;
|
|
18823
18874
|
});
|
|
18875
|
+
if (jump) {
|
|
18876
|
+
for (const fragment of fragments.slice(jump.index)) fragment.xPx += jump.shiftPx;
|
|
18877
|
+
}
|
|
18824
18878
|
lines.push({
|
|
18825
18879
|
yPx: 0,
|
|
18826
18880
|
heightPx,
|
|
@@ -18837,6 +18891,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18837
18891
|
if (forcedByBreak === "column") columnBreakAfterLine.add(lineIndex);
|
|
18838
18892
|
placed2 = [];
|
|
18839
18893
|
lineWidthPx = 0;
|
|
18894
|
+
lineSpacePx = 0;
|
|
18895
|
+
jump = void 0;
|
|
18840
18896
|
marginReachPx = 0;
|
|
18841
18897
|
}
|
|
18842
18898
|
for (const [tokenIndex, token] of tokens.entries()) {
|
|
@@ -18886,9 +18942,19 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18886
18942
|
leader = tab.leader === "none" ? void 0 : tab.leader;
|
|
18887
18943
|
}
|
|
18888
18944
|
const lineIndex = lines.length;
|
|
18889
|
-
const
|
|
18890
|
-
const
|
|
18891
|
-
|
|
18945
|
+
const hole = boxFor(lineIndex).hole;
|
|
18946
|
+
const beforeHole = hole && !jump ? hole.startPx - lineStart(lineIndex) : void 0;
|
|
18947
|
+
const limit = Math.max(
|
|
18948
|
+
beforeHole ?? availableWidth(lineIndex) - (jump?.shiftPx ?? 0),
|
|
18949
|
+
marginReachPx
|
|
18950
|
+
);
|
|
18951
|
+
const squeezePx = effectiveAlign === "justify" && token.kind === "word" ? lineSpacePx * SPACE_SHRINK : 0;
|
|
18952
|
+
const fits = lineWidthPx + (token.kind === "tab" ? width : advance) <= limit + squeezePx;
|
|
18953
|
+
const wouldFit = fits || placed2.every((placed3) => paragraph.runs[placed3.token.runIndex]?.synthetic);
|
|
18954
|
+
const pastHole = !fits && hole && !jump && token.kind === "word" ? hole.endPx - lineStart(lineIndex) - lineWidthPx : void 0;
|
|
18955
|
+
if (pastHole !== void 0 && lineWidthPx + pastHole + advance <= availableWidth(lineIndex)) {
|
|
18956
|
+
jump = { index: placed2.length, shiftPx: pastHole };
|
|
18957
|
+
} else if (!wouldFit && token.kind !== "space") {
|
|
18892
18958
|
tokenCursor = tokenIndex;
|
|
18893
18959
|
flushLine(false, void 0);
|
|
18894
18960
|
tokenCursor = tokenIndex + 1;
|
|
@@ -18908,6 +18974,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18908
18974
|
...markerFactor ? { xOffsetPx: -width * markerFactor, advancePx: advance } : {}
|
|
18909
18975
|
});
|
|
18910
18976
|
lineWidthPx += token.kind === "tab" ? width : advance;
|
|
18977
|
+
if (token.kind === "space") lineSpacePx += advance;
|
|
18911
18978
|
}
|
|
18912
18979
|
flushLine(lines.length === 0, void 0);
|
|
18913
18980
|
const lastIndex = lines.length - 1;
|
|
@@ -18918,7 +18985,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18918
18985
|
line3.fragments,
|
|
18919
18986
|
availableWidth(index),
|
|
18920
18987
|
index === lastIndex,
|
|
18921
|
-
|
|
18988
|
+
// A line that runs around a picture is not aligned across it.
|
|
18989
|
+
boxes[index]?.hole ? "left" : effectiveAlign
|
|
18922
18990
|
).map((fragment) => ({ ...fragment, xPx: fragment.xPx + lineStart(index) }))
|
|
18923
18991
|
};
|
|
18924
18992
|
}
|
|
@@ -18970,29 +19038,50 @@ function widowControlEnabled(value) {
|
|
|
18970
19038
|
|
|
18971
19039
|
// docx/layout/nested-frame-profile.ts
|
|
18972
19040
|
var equal = (a, b) => a !== void 0 && b !== void 0 && a.style === b.style && a.color === b.color && Math.abs(a.widthPx - b.widthPx) < 1e-6;
|
|
18973
|
-
function
|
|
19041
|
+
function mergedAway(table, rowIndex, column, side, merges) {
|
|
19042
|
+
if (!merges) return false;
|
|
19043
|
+
const row2 = table.rows[rowIndex];
|
|
19044
|
+
const cell = row2.cells[column];
|
|
19045
|
+
if (side === "top") return cell.verticalMerge === "continue";
|
|
19046
|
+
const below2 = table.rows[rowIndex + 1]?.cells.find(
|
|
19047
|
+
(other) => other.xPx === cell.xPx && other.widthPx === cell.widthPx
|
|
19048
|
+
);
|
|
19049
|
+
return below2?.verticalMerge === "continue";
|
|
19050
|
+
}
|
|
19051
|
+
function nestedFrameProfile(table, tableWidthPx = table.widthPx, merges = false) {
|
|
18974
19052
|
const sides = table.rows.flatMap(
|
|
18975
|
-
(row2) => row2.cells.flatMap(
|
|
18976
|
-
(cell) => ["top", "right", "bottom", "left"].
|
|
19053
|
+
(row2, rowIndex) => row2.cells.flatMap(
|
|
19054
|
+
(cell, column) => ["top", "right", "bottom", "left"].filter(
|
|
19055
|
+
(side) => side !== "top" && side !== "bottom" || !mergedAway(table, rowIndex, column, side, merges)
|
|
19056
|
+
).map((side) => cell.borders?.[side])
|
|
18977
19057
|
)
|
|
18978
19058
|
);
|
|
18979
19059
|
if (sides.every((side) => !side)) return { leftPx: 0, rightPx: 0, bottomPx: 0 };
|
|
18980
19060
|
if (!sides.every((side) => side?.style === "solid" && side.widthPx > 0)) return void 0;
|
|
19061
|
+
const gridKnown = merges && table.rows.every(
|
|
19062
|
+
(row2) => row2.cells.every((cell) => cell.xPx !== void 0 && cell.widthPx !== void 0)
|
|
19063
|
+
);
|
|
18981
19064
|
const first3 = table.rows[0], left = first3.cells[0].borders.left, right = first3.cells.at(-1).borders.right;
|
|
18982
19065
|
for (const [index, row2] of table.rows.entries()) {
|
|
18983
|
-
if (row2.cells.length !== first3.cells.length || !equal(row2.cells[0]?.borders?.left, left) || !equal(row2.cells.at(-1)?.borders?.right, right))
|
|
19066
|
+
if (!gridKnown && row2.cells.length !== first3.cells.length || !equal(row2.cells[0]?.borders?.left, left) || !equal(row2.cells.at(-1)?.borders?.right, right))
|
|
18984
19067
|
return void 0;
|
|
18985
19068
|
for (const [column, cell] of row2.cells.entries()) {
|
|
18986
19069
|
const sourceWidth = cell.widthPx ?? (tableWidthPx === void 0 ? void 0 : tableWidthPx / row2.cells.length);
|
|
18987
19070
|
const paintWidth = sourceWidth === void 0 ? void 0 : sourceWidth + (cell.borders.left.widthPx - cell.borders.right.widthPx) / 2 + (column === row2.cells.length - 1 ? cell.borders.right.widthPx : 0);
|
|
18988
19071
|
if (paintWidth !== void 0 && paintWidth <= 0) return void 0;
|
|
18989
|
-
|
|
19072
|
+
const topAway = mergedAway(table, index, column, "top", merges);
|
|
19073
|
+
const bottomAway = mergedAway(table, index, column, "bottom", merges);
|
|
19074
|
+
const reference = (side) => row2.cells.find((_, at) => !mergedAway(table, index, at, side, merges))?.borders?.[side];
|
|
19075
|
+
if (!topAway && !equal(cell.borders?.top, reference("top")) || !bottomAway && !equal(cell.borders?.bottom, reference("bottom")))
|
|
18990
19076
|
return void 0;
|
|
18991
19077
|
if (column && !equal(row2.cells[column - 1]?.borders?.right, cell.borders?.left))
|
|
18992
19078
|
return void 0;
|
|
18993
19079
|
if (index) {
|
|
18994
|
-
const
|
|
18995
|
-
|
|
19080
|
+
const above2 = table.rows[index - 1];
|
|
19081
|
+
const previous = gridKnown ? above2.cells.find(
|
|
19082
|
+
(other) => other.xPx <= cell.xPx + 1e-6 && cell.xPx < other.xPx + other.widthPx - 1e-6
|
|
19083
|
+
) : above2.cells[column];
|
|
19084
|
+
if (!previous || !gridKnown && (previous.xPx !== cell.xPx || previous.widthPx !== cell.widthPx) || !topAway && !mergedAway(table, index - 1, above2.cells.indexOf(previous), "bottom", merges) && !equal(previous.borders?.bottom, cell.borders?.top))
|
|
18996
19085
|
return void 0;
|
|
18997
19086
|
}
|
|
18998
19087
|
}
|
|
@@ -19047,46 +19136,6 @@ function cellContentBottom(boxes, paddingBottom = 0) {
|
|
|
19047
19136
|
);
|
|
19048
19137
|
}
|
|
19049
19138
|
|
|
19050
|
-
// docx/layout/table-frames.ts
|
|
19051
|
-
function clipTableFrames(tables, start, end, inset = 0) {
|
|
19052
|
-
return tables.flatMap((table) => {
|
|
19053
|
-
const top = Math.max(start, table.yPx);
|
|
19054
|
-
const bottom = Math.min(end, table.yPx + table.heightPx);
|
|
19055
|
-
if (bottom <= top) return [];
|
|
19056
|
-
const rows2 = table.rows.flatMap((row2) => {
|
|
19057
|
-
const rowTop = table.yPx + row2.yPx;
|
|
19058
|
-
const a = Math.max(top, rowTop), b = Math.min(bottom, rowTop + row2.heightPx);
|
|
19059
|
-
if (b <= a) return [];
|
|
19060
|
-
return [
|
|
19061
|
-
{
|
|
19062
|
-
...row2,
|
|
19063
|
-
yPx: a - top,
|
|
19064
|
-
heightPx: b - a,
|
|
19065
|
-
...row2.cellTables ? {
|
|
19066
|
-
cellTables: row2.cellTables.map(
|
|
19067
|
-
(nested) => clipTableFrames(nested, a - rowTop, b - rowTop)
|
|
19068
|
-
)
|
|
19069
|
-
} : {}
|
|
19070
|
-
}
|
|
19071
|
-
];
|
|
19072
|
-
});
|
|
19073
|
-
if (table.fragmentEdges && rows2.length) {
|
|
19074
|
-
const edges = table.fragmentEdges;
|
|
19075
|
-
for (const [row2, side] of [
|
|
19076
|
-
[rows2[0], "top"],
|
|
19077
|
-
[rows2.at(-1), "bottom"]
|
|
19078
|
-
]) {
|
|
19079
|
-
if (row2.geometry)
|
|
19080
|
-
row2.geometry = row2.geometry.map((cell, index) => ({
|
|
19081
|
-
...cell,
|
|
19082
|
-
borders: { ...cell.borders, [side]: edges[side][index] }
|
|
19083
|
-
}));
|
|
19084
|
-
}
|
|
19085
|
-
}
|
|
19086
|
-
return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows: rows2 }];
|
|
19087
|
-
});
|
|
19088
|
-
}
|
|
19089
|
-
|
|
19090
19139
|
// docx/layout/table-cell-layout.ts
|
|
19091
19140
|
function cellParagraphs(cell) {
|
|
19092
19141
|
const walk = (blocks) => blocks.flatMap(
|
|
@@ -19194,92 +19243,47 @@ function stackCellBlocks(cell, width, measurer, note, top, starts, physicalFragm
|
|
|
19194
19243
|
return { heightPx: y, boxes, tables };
|
|
19195
19244
|
}
|
|
19196
19245
|
|
|
19197
|
-
// docx/layout/table-
|
|
19198
|
-
function
|
|
19199
|
-
|
|
19200
|
-
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19211
|
-
|
|
19212
|
-
|
|
19213
|
-
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
|
|
19217
|
-
|
|
19218
|
-
|
|
19219
|
-
...layout.frame ? { frame: layout.frame } : {}
|
|
19220
|
-
});
|
|
19221
|
-
y += layout.contentHeightPx + layout.spacingAfterPx;
|
|
19222
|
-
}
|
|
19223
|
-
return { heightPx: y, boxes };
|
|
19224
|
-
}
|
|
19225
|
-
function layoutRow(row2, tableWidthPx, measurer, note, remaining, startTokens, frameBorders = false, frameLeftBorderPx, physicalFragments = reflowNestedFragments(row2)) {
|
|
19226
|
-
const count = row2.cells.length || 1;
|
|
19227
|
-
let x = 0;
|
|
19228
|
-
const geometry = [];
|
|
19229
|
-
const laidOut = row2.cells.map((cell) => {
|
|
19230
|
-
const continuation = remaining?.[geometry.length];
|
|
19231
|
-
const starts = continuation ? new Map(continuation.map((box) => [box.blockId, box.lines[0]?.firstToken ?? 0])) : startTokens;
|
|
19232
|
-
const widthPx = cell.widthPx ?? tableWidthPx / count;
|
|
19233
|
-
const margins = cell.padding ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
19234
|
-
const leftBorder = frameBorders ? cell.borders?.left?.widthPx ?? 0 : 0;
|
|
19235
|
-
const rightBorder = frameBorders ? cell.borders?.right?.widthPx ?? 0 : 0;
|
|
19236
|
-
const padding = frameBorders ? {
|
|
19237
|
-
top: margins.top + (cell.borders?.top?.widthPx ?? 0),
|
|
19238
|
-
bottom: margins.bottom,
|
|
19239
|
-
left: leftBorder / 2 + Math.max(margins.left, leftBorder / 2),
|
|
19240
|
-
right: Math.max(margins.right, rightBorder / 2) - rightBorder / 2
|
|
19241
|
-
} : margins;
|
|
19242
|
-
const externalRight = frameBorders && geometry.length === row2.cells.length - 1 ? rightBorder : 0;
|
|
19243
|
-
const paintWidth = widthPx + (frameBorders ? (leftBorder - rightBorder) / 2 + externalRight : 0);
|
|
19244
|
-
const frameX = frameBorders ? ((frameLeftBorderPx ?? leftBorder) - leftBorder) / 2 : 0;
|
|
19245
|
-
const content2 = stackCellBlocks(
|
|
19246
|
-
cell,
|
|
19247
|
-
Math.max(1, paintWidth - padding.left - padding.right - externalRight),
|
|
19248
|
-
measurer,
|
|
19249
|
-
note,
|
|
19250
|
-
padding.top,
|
|
19251
|
-
starts,
|
|
19252
|
-
physicalFragments
|
|
19253
|
-
);
|
|
19254
|
-
const heightPx2 = content2.heightPx + padding.bottom;
|
|
19255
|
-
geometry.push({
|
|
19256
|
-
xPx: (cell.xPx ?? x) + frameX,
|
|
19257
|
-
widthPx: paintWidth,
|
|
19258
|
-
...frameBorders ? { borderInsetsReserved: true } : {},
|
|
19259
|
-
paddingLeftPx: padding.left,
|
|
19260
|
-
paddingRightPx: padding.right + externalRight,
|
|
19261
|
-
contentHeightPx: heightPx2,
|
|
19262
|
-
...cell.borders ? { borders: cell.borders } : {},
|
|
19263
|
-
...cell.shading ? { shading: cell.shading } : {},
|
|
19264
|
-
...cell.verticalAlign ? { verticalAlign: cell.verticalAlign } : {}
|
|
19246
|
+
// docx/layout/table-frames.ts
|
|
19247
|
+
function clipTableFrames(tables, start, end, inset = 0) {
|
|
19248
|
+
return tables.flatMap((table) => {
|
|
19249
|
+
const top = Math.max(start, table.yPx);
|
|
19250
|
+
const bottom = Math.min(end, table.yPx + table.heightPx);
|
|
19251
|
+
if (bottom <= top) return [];
|
|
19252
|
+
const rows2 = table.rows.flatMap((row2) => {
|
|
19253
|
+
const rowTop = table.yPx + row2.yPx;
|
|
19254
|
+
const a = Math.max(top, rowTop), b = Math.min(bottom, rowTop + row2.heightPx);
|
|
19255
|
+
if (b <= a) return [];
|
|
19256
|
+
return [
|
|
19257
|
+
{
|
|
19258
|
+
...row2,
|
|
19259
|
+
yPx: a - top,
|
|
19260
|
+
heightPx: b - a,
|
|
19261
|
+
...row2.cellTables ? {
|
|
19262
|
+
cellTables: row2.cellTables.map(
|
|
19263
|
+
(nested) => clipTableFrames(nested, a - rowTop, b - rowTop)
|
|
19264
|
+
)
|
|
19265
|
+
} : {}
|
|
19266
|
+
}
|
|
19267
|
+
];
|
|
19265
19268
|
});
|
|
19266
|
-
|
|
19267
|
-
|
|
19269
|
+
if (table.fragmentEdges && rows2.length) {
|
|
19270
|
+
const edges = table.fragmentEdges;
|
|
19271
|
+
for (const [row2, side] of [
|
|
19272
|
+
[rows2[0], "top"],
|
|
19273
|
+
[rows2.at(-1), "bottom"]
|
|
19274
|
+
]) {
|
|
19275
|
+
if (row2.geometry)
|
|
19276
|
+
row2.geometry = row2.geometry.map((cell, index) => ({
|
|
19277
|
+
...cell,
|
|
19278
|
+
borders: { ...cell.borders, [side]: edges[side][index] }
|
|
19279
|
+
}));
|
|
19280
|
+
}
|
|
19281
|
+
}
|
|
19282
|
+
return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows: rows2 }];
|
|
19268
19283
|
});
|
|
19269
|
-
const content = Math.max(0, ...laidOut.map((cell) => cell.heightPx));
|
|
19270
|
-
const heightPx = row2.heightPx === void 0 ? content : row2.heightRule === "exact" ? row2.heightPx : Math.max(content, row2.heightPx);
|
|
19271
|
-
if (frameBorders) for (const cell of geometry) cell.alignmentHeightPx = heightPx;
|
|
19272
|
-
return {
|
|
19273
|
-
heightPx,
|
|
19274
|
-
cells: laidOut.map((cell) => cell.boxes),
|
|
19275
|
-
geometry,
|
|
19276
|
-
...laidOut.some((cell) => cell.tables.length) ? { cellTables: laidOut.map((cell) => cell.tables) } : {},
|
|
19277
|
-
cellPadding: row2.cells.map((cell) => ({
|
|
19278
|
-
top: cell.padding?.top ?? 0,
|
|
19279
|
-
bottom: cell.padding?.bottom ?? 0
|
|
19280
|
-
}))
|
|
19281
|
-
};
|
|
19282
19284
|
}
|
|
19285
|
+
|
|
19286
|
+
// docx/layout/table-row-split.ts
|
|
19283
19287
|
function splitCellAtHeight(boxes, cutHeightPx, paragraphCuts) {
|
|
19284
19288
|
const before = [];
|
|
19285
19289
|
const after = [];
|
|
@@ -19353,7 +19357,7 @@ function splitRowAtHeight(row2, cutHeightPx, cellCuts, paragraphCuts) {
|
|
|
19353
19357
|
)
|
|
19354
19358
|
)
|
|
19355
19359
|
} : {},
|
|
19356
|
-
geometry: row2.geometry.map((geometry, index) => ({
|
|
19360
|
+
geometry: row2.geometry.map(({ mergeRows: _merge, ...geometry }, index) => ({
|
|
19357
19361
|
...geometry,
|
|
19358
19362
|
contentHeightPx: splits[index].beforeHeightPx,
|
|
19359
19363
|
...row2.borderBottomPx !== void 0 ? { alignmentHeightPx: beforeHeightPx } : {}
|
|
@@ -19362,10 +19366,11 @@ function splitRowAtHeight(row2, cutHeightPx, cellCuts, paragraphCuts) {
|
|
|
19362
19366
|
...row2.borderBottomPx !== void 0 ? { borderBottomPx: row2.borderBottomPx } : {}
|
|
19363
19367
|
};
|
|
19364
19368
|
if (!anyAfter) return { before, after: null };
|
|
19369
|
+
const tail = (split, index) => split.after.length ? row2.trailingPx?.[index] ?? 0 : 0;
|
|
19365
19370
|
const afterHeightPx = Math.max(
|
|
19366
19371
|
0,
|
|
19367
19372
|
...splits.map(
|
|
19368
|
-
(split, index) => cellContentBottom(split.after, row2.cellPadding?.[index]?.bottom ?? 0)
|
|
19373
|
+
(split, index) => cellContentBottom(split.after, row2.cellPadding?.[index]?.bottom ?? 0) + tail(split, index)
|
|
19369
19374
|
)
|
|
19370
19375
|
);
|
|
19371
19376
|
const after = {
|
|
@@ -19381,20 +19386,114 @@ function splitRowAtHeight(row2, cutHeightPx, cellCuts, paragraphCuts) {
|
|
|
19381
19386
|
) : []
|
|
19382
19387
|
)
|
|
19383
19388
|
} : {},
|
|
19384
|
-
geometry: row2.geometry.map((geometry, index) => ({
|
|
19389
|
+
geometry: row2.geometry.map(({ mergeRows: _merge, ...geometry }, index) => ({
|
|
19385
19390
|
...geometry,
|
|
19386
|
-
contentHeightPx: cellContentBottom(
|
|
19387
|
-
splits[index].after,
|
|
19388
|
-
row2.cellPadding?.[index]?.bottom ?? 0
|
|
19389
|
-
),
|
|
19391
|
+
contentHeightPx: cellContentBottom(splits[index].after, row2.cellPadding?.[index]?.bottom ?? 0) + tail(splits[index], index),
|
|
19390
19392
|
...row2.borderBottomPx !== void 0 ? { alignmentHeightPx: afterHeightPx } : {}
|
|
19391
19393
|
})),
|
|
19392
19394
|
...row2.cellPadding ? { cellPadding: row2.cellPadding } : {},
|
|
19395
|
+
...row2.trailingPx ? { trailingPx: row2.trailingPx } : {},
|
|
19393
19396
|
...row2.borderBottomPx !== void 0 ? { borderBottomPx: row2.borderBottomPx } : {}
|
|
19394
19397
|
};
|
|
19395
19398
|
return { before, after };
|
|
19396
19399
|
}
|
|
19397
19400
|
|
|
19401
|
+
// docx/layout/table-layout.ts
|
|
19402
|
+
function stackParagraphs(paragraphs, widthPx, measurer, note, topPx = 0, startTokens) {
|
|
19403
|
+
let y = topPx;
|
|
19404
|
+
const boxes = [];
|
|
19405
|
+
for (const paragraph of paragraphs) {
|
|
19406
|
+
const layout = layoutParagraph(
|
|
19407
|
+
paragraph,
|
|
19408
|
+
widthPx,
|
|
19409
|
+
measurer,
|
|
19410
|
+
note,
|
|
19411
|
+
void 0,
|
|
19412
|
+
startTokens?.get(paragraph.id) ?? 0
|
|
19413
|
+
);
|
|
19414
|
+
y += layout.spacingBeforePx;
|
|
19415
|
+
const top = y;
|
|
19416
|
+
const lines = layout.lines.map((line3) => ({ ...line3 }));
|
|
19417
|
+
boxes.push({
|
|
19418
|
+
kind: "paragraph",
|
|
19419
|
+
blockId: paragraph.id,
|
|
19420
|
+
yPx: top,
|
|
19421
|
+
heightPx: layout.contentHeightPx,
|
|
19422
|
+
lines,
|
|
19423
|
+
...layout.frame ? { frame: layout.frame } : {}
|
|
19424
|
+
});
|
|
19425
|
+
y += layout.contentHeightPx + layout.spacingAfterPx;
|
|
19426
|
+
}
|
|
19427
|
+
return { heightPx: y, boxes };
|
|
19428
|
+
}
|
|
19429
|
+
function layoutRow(row2, tableWidthPx, measurer, note, remaining, startTokens, frameBorders = false, frameLeftBorderPx, physicalFragments = reflowNestedFragments(row2)) {
|
|
19430
|
+
const count = row2.cells.length || 1;
|
|
19431
|
+
let x = 0;
|
|
19432
|
+
const geometry = [];
|
|
19433
|
+
const laidOut = row2.cells.map((cell) => {
|
|
19434
|
+
const continuation = remaining?.[geometry.length];
|
|
19435
|
+
const starts = continuation ? new Map(continuation.map((box) => [box.blockId, box.lines[0]?.firstToken ?? 0])) : startTokens;
|
|
19436
|
+
const widthPx = cell.widthPx ?? tableWidthPx / count;
|
|
19437
|
+
const margins = cell.padding ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
19438
|
+
const leftBorder = frameBorders ? cell.borders?.left?.widthPx ?? 0 : 0;
|
|
19439
|
+
const rightBorder = frameBorders ? cell.borders?.right?.widthPx ?? 0 : 0;
|
|
19440
|
+
const padding = frameBorders ? {
|
|
19441
|
+
top: margins.top + (cell.borders?.top?.widthPx ?? 0),
|
|
19442
|
+
bottom: margins.bottom,
|
|
19443
|
+
left: leftBorder / 2 + Math.max(margins.left, leftBorder / 2),
|
|
19444
|
+
right: Math.max(margins.right, rightBorder / 2) - rightBorder / 2
|
|
19445
|
+
} : margins;
|
|
19446
|
+
const externalRight = frameBorders && geometry.length === row2.cells.length - 1 ? rightBorder : 0;
|
|
19447
|
+
const paintWidth = widthPx + (frameBorders ? (leftBorder - rightBorder) / 2 + externalRight : 0);
|
|
19448
|
+
const frameX = frameBorders ? ((frameLeftBorderPx ?? leftBorder) - leftBorder) / 2 : 0;
|
|
19449
|
+
const content2 = stackCellBlocks(
|
|
19450
|
+
cell,
|
|
19451
|
+
Math.max(1, paintWidth - padding.left - padding.right - externalRight),
|
|
19452
|
+
measurer,
|
|
19453
|
+
note,
|
|
19454
|
+
padding.top,
|
|
19455
|
+
starts,
|
|
19456
|
+
physicalFragments
|
|
19457
|
+
);
|
|
19458
|
+
const heightPx2 = content2.heightPx + padding.bottom;
|
|
19459
|
+
geometry.push({
|
|
19460
|
+
xPx: (cell.xPx ?? x) + frameX,
|
|
19461
|
+
widthPx: paintWidth,
|
|
19462
|
+
...frameBorders ? { borderInsetsReserved: true } : {},
|
|
19463
|
+
paddingLeftPx: padding.left,
|
|
19464
|
+
paddingRightPx: padding.right + externalRight,
|
|
19465
|
+
contentHeightPx: heightPx2,
|
|
19466
|
+
...cell.borders ? { borders: cell.borders } : {},
|
|
19467
|
+
...cell.shading ? { shading: cell.shading } : {},
|
|
19468
|
+
...cell.verticalAlign ? { verticalAlign: cell.verticalAlign } : {},
|
|
19469
|
+
...cell.rowSpan ? { mergeRows: cell.rowSpan } : {}
|
|
19470
|
+
});
|
|
19471
|
+
x = (cell.xPx ?? x) + widthPx;
|
|
19472
|
+
const trailingPx = content2.tables?.length ? 0 : Math.max(0, content2.heightPx - cellContentBottom(content2.boxes));
|
|
19473
|
+
return { heightPx: heightPx2, boxes: content2.boxes, tables: content2.tables ?? [], trailingPx };
|
|
19474
|
+
});
|
|
19475
|
+
const content = Math.max(
|
|
19476
|
+
0,
|
|
19477
|
+
...laidOut.map(
|
|
19478
|
+
(cell, index) => (row2.cells[index]?.rowSpan ?? 1) > 1 && !row2.mergedTextInRow ? 0 : cell.heightPx
|
|
19479
|
+
)
|
|
19480
|
+
);
|
|
19481
|
+
const heightPx = row2.heightPx === void 0 ? content : row2.heightRule === "exact" ? row2.heightPx : Math.max(content, row2.heightPx);
|
|
19482
|
+
if (frameBorders) for (const cell of geometry) cell.alignmentHeightPx = heightPx;
|
|
19483
|
+
const trailing = laidOut.map((cell) => cell.trailingPx);
|
|
19484
|
+
return {
|
|
19485
|
+
heightPx,
|
|
19486
|
+
cells: laidOut.map((cell) => cell.boxes),
|
|
19487
|
+
geometry,
|
|
19488
|
+
...trailing.some((px) => px > 0) ? { trailingPx: trailing } : {},
|
|
19489
|
+
...laidOut.some((cell) => cell.tables.length) ? { cellTables: laidOut.map((cell) => cell.tables) } : {},
|
|
19490
|
+
cellPadding: row2.cells.map((cell) => ({
|
|
19491
|
+
top: cell.padding?.top ?? 0,
|
|
19492
|
+
bottom: cell.padding?.bottom ?? 0
|
|
19493
|
+
}))
|
|
19494
|
+
};
|
|
19495
|
+
}
|
|
19496
|
+
|
|
19398
19497
|
// docx/layout/footnote-split.ts
|
|
19399
19498
|
function splitNote(note, budget) {
|
|
19400
19499
|
if (note.heightPx <= budget + 1e-6) return { before: note };
|
|
@@ -19848,6 +19947,14 @@ var PageCursor = class {
|
|
|
19848
19947
|
get usedColumnHeightPx() {
|
|
19849
19948
|
return this.yPx - this.columnTopPx;
|
|
19850
19949
|
}
|
|
19950
|
+
/**
|
|
19951
|
+
* At the top of a later page or a later column of the section (not the section's first page, nor
|
|
19952
|
+
* a continuous band). Word drops the space before of the paragraph placed here, whether a page
|
|
19953
|
+
* break, a natural overflow, `pageBreakBefore` or a column overflow brought it (spacing-probe.json).
|
|
19954
|
+
*/
|
|
19955
|
+
get atContinuationTop() {
|
|
19956
|
+
return this.atColumnTop && this.columnTopPx === 0 && (this.page.pageInSection > 0 || this.columnIndex > 0);
|
|
19957
|
+
}
|
|
19851
19958
|
get atColumnTop() {
|
|
19852
19959
|
return this.yPx === this.columnTopPx;
|
|
19853
19960
|
}
|
|
@@ -19938,13 +20045,16 @@ var PageCursor = class {
|
|
|
19938
20045
|
this.pushPage();
|
|
19939
20046
|
}
|
|
19940
20047
|
}
|
|
19941
|
-
/**
|
|
19942
|
-
|
|
20048
|
+
/**
|
|
20049
|
+
* Places a box at the current fill position (sets its `yPx`) and advances by `advancePx`. The box
|
|
20050
|
+
* sits `offsetPx` below the fill position when the advance starts with space above it.
|
|
20051
|
+
*/
|
|
20052
|
+
place(box, advancePx, offsetPx = 0) {
|
|
19943
20053
|
if (this.page.sectionIndex !== this.sectionIndex && !this.page.sectionIndices?.includes(this.sectionIndex)) {
|
|
19944
20054
|
(this.page.sectionIndices ??= [this.page.sectionIndex]).push(this.sectionIndex);
|
|
19945
20055
|
this.pageInSection = 1;
|
|
19946
20056
|
}
|
|
19947
|
-
box.yPx = this.yPx;
|
|
20057
|
+
box.yPx = this.yPx + offsetPx;
|
|
19948
20058
|
this.column.blocks.push(box);
|
|
19949
20059
|
this.yPx += advancePx;
|
|
19950
20060
|
const bodyBottom = this.legacyFootnoteColumns ? this.yPx : Math.max(
|
|
@@ -19964,7 +20074,10 @@ var PageCursor = class {
|
|
|
19964
20074
|
|
|
19965
20075
|
// docx/layout/flow-paragraph.ts
|
|
19966
20076
|
function placeParagraph(cursor, placement, note) {
|
|
19967
|
-
const { paragraph,
|
|
20077
|
+
const { paragraph, requiredTogetherPx, reflow } = placement;
|
|
20078
|
+
const spacingAfterPx = placement.spacingAfterPx ?? placement.layout.spacingAfterPx;
|
|
20079
|
+
const dropsSpaceBefore = () => cursor.atContinuationTop && !(paragraph.pageBreakBefore && placement.keepSpaceBeforePageBreak);
|
|
20080
|
+
let spacingBeforePx = dropsSpaceBefore() ? 0 : placement.spacingBeforePx;
|
|
19968
20081
|
const trailingBreakLine = (result) => {
|
|
19969
20082
|
const last = result.lines.at(-1);
|
|
19970
20083
|
if (!placement.trimLeadingColumnBreak || !last || !result.columnBreakAfterLine.has(result.lines.length - 1))
|
|
@@ -19998,6 +20111,7 @@ function placeParagraph(cursor, placement, note) {
|
|
|
19998
20111
|
if (requiredTogetherPx > 0 && requiredTogetherPx <= cursor.columnHeightPx && requiredTogetherPx > cursor.remainingHeightPx() && !cursor.atColumnTop) {
|
|
19999
20112
|
cursor.newColumn();
|
|
20000
20113
|
}
|
|
20114
|
+
if (dropsSpaceBefore()) spacingBeforePx = 0;
|
|
20001
20115
|
const widow = widowControlEnabled(paragraph.widowControl);
|
|
20002
20116
|
let lineCursor = 0;
|
|
20003
20117
|
let nextToken = 0;
|
|
@@ -20026,7 +20140,8 @@ function placeParagraph(cursor, placement, note) {
|
|
|
20026
20140
|
if (!layout.lines.length) {
|
|
20027
20141
|
cursor.place(
|
|
20028
20142
|
{ kind: "paragraph", blockId: paragraph.id, yPx: 0, heightPx: 0, lines: [] },
|
|
20029
|
-
spacingBeforePx +
|
|
20143
|
+
spacingBeforePx + spacingAfterPx,
|
|
20144
|
+
spacingBeforePx
|
|
20030
20145
|
);
|
|
20031
20146
|
return;
|
|
20032
20147
|
}
|
|
@@ -20070,6 +20185,7 @@ function placeParagraph(cursor, placement, note) {
|
|
|
20070
20185
|
if (placedCount === 0) {
|
|
20071
20186
|
if (!cursor.atColumnTop) {
|
|
20072
20187
|
cursor.newColumn();
|
|
20188
|
+
if (firstSegment && dropsSpaceBefore()) spacingBeforePx = 0;
|
|
20073
20189
|
continue;
|
|
20074
20190
|
}
|
|
20075
20191
|
note(
|
|
@@ -20100,8 +20216,8 @@ function placeParagraph(cursor, placement, note) {
|
|
|
20100
20216
|
lines: segmentLines,
|
|
20101
20217
|
...layout.frame ? { frame: layout.frame } : {}
|
|
20102
20218
|
};
|
|
20103
|
-
const advance = (firstSegment ? spacingBeforePx : 0) + segmentHeight + (isFinal ?
|
|
20104
|
-
cursor.place(box, advance);
|
|
20219
|
+
const advance = (firstSegment ? spacingBeforePx : 0) + segmentHeight + (isFinal ? spacingAfterPx : 0);
|
|
20220
|
+
cursor.place(box, advance, firstSegment ? spacingBeforePx : 0);
|
|
20105
20221
|
for (const item of committedNotes) placedNotes.add(item.id);
|
|
20106
20222
|
nextToken = layout.lines[lineCursor + placedCount - 1]?.nextToken ?? nextToken;
|
|
20107
20223
|
lineCursor += placedCount;
|
|
@@ -20507,6 +20623,61 @@ var TableFootnotes = class {
|
|
|
20507
20623
|
}
|
|
20508
20624
|
};
|
|
20509
20625
|
|
|
20626
|
+
// docx/layout/table-merged-rows.ts
|
|
20627
|
+
var MergedRowPlan = class {
|
|
20628
|
+
constructor(rows2) {
|
|
20629
|
+
this.rows = rows2;
|
|
20630
|
+
}
|
|
20631
|
+
rows;
|
|
20632
|
+
legacy = /* @__PURE__ */ new Set();
|
|
20633
|
+
minimum = /* @__PURE__ */ new Map();
|
|
20634
|
+
cache = /* @__PURE__ */ new Map();
|
|
20635
|
+
apply(source) {
|
|
20636
|
+
const minimum = this.minimum.get(source);
|
|
20637
|
+
if (minimum === void 0 && !this.legacy.has(source)) return source;
|
|
20638
|
+
return {
|
|
20639
|
+
...source,
|
|
20640
|
+
...minimum === void 0 ? {} : { heightPx: minimum, heightRule: "atLeast" },
|
|
20641
|
+
...this.legacy.has(source) ? { mergedTextInRow: true } : {}
|
|
20642
|
+
};
|
|
20643
|
+
}
|
|
20644
|
+
/** The row to lay out and place (the source row itself when the plan leaves it alone). */
|
|
20645
|
+
effective(source) {
|
|
20646
|
+
let row2 = this.cache.get(source);
|
|
20647
|
+
if (!row2) {
|
|
20648
|
+
row2 = this.apply(source);
|
|
20649
|
+
this.cache.set(source, row2);
|
|
20650
|
+
}
|
|
20651
|
+
return row2;
|
|
20652
|
+
}
|
|
20653
|
+
/** Plans the rows a merge starting at `index` covers, given the room left for them. */
|
|
20654
|
+
plan(index, layout, availablePx) {
|
|
20655
|
+
const start = this.rows[index];
|
|
20656
|
+
const spans = start?.cells.map((cell) => cell.rowSpan ?? 1) ?? [];
|
|
20657
|
+
const longest = Math.max(1, ...spans);
|
|
20658
|
+
if (!start || longest < 2) return;
|
|
20659
|
+
const covered = this.rows.slice(index, index + longest);
|
|
20660
|
+
const natural = covered.map((row2) => layout(this.apply(row2)));
|
|
20661
|
+
const heights = natural.map((item) => item.heightPx);
|
|
20662
|
+
spans.forEach((span, cell) => {
|
|
20663
|
+
if (span < 2) return;
|
|
20664
|
+
const count = Math.min(span, covered.length);
|
|
20665
|
+
const need = (natural[0]?.geometry[cell]?.contentHeightPx ?? 0) + (natural[count - 1]?.borderBottomPx ?? 0);
|
|
20666
|
+
const have = heights.slice(0, count).reduce((sum, h) => sum + h, 0);
|
|
20667
|
+
if (need > have) heights[count - 1] = (heights[count - 1] ?? 0) + need - have;
|
|
20668
|
+
});
|
|
20669
|
+
if (heights.reduce((sum, h) => sum + h, 0) > availablePx) {
|
|
20670
|
+
this.legacy.add(start);
|
|
20671
|
+
return;
|
|
20672
|
+
}
|
|
20673
|
+
covered.forEach((row2, at) => {
|
|
20674
|
+
const grown = heights[at] - natural[at].heightPx;
|
|
20675
|
+
if (grown > 1e-6 && row2.heightRule !== "exact")
|
|
20676
|
+
this.minimum.set(row2, heights[at] - (natural[at].borderBottomPx ?? 0));
|
|
20677
|
+
});
|
|
20678
|
+
}
|
|
20679
|
+
};
|
|
20680
|
+
|
|
20510
20681
|
// docx/layout/flow-table.ts
|
|
20511
20682
|
function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
20512
20683
|
const firstBodyRow = table.rows.findIndex((row2) => !row2.isHeader);
|
|
@@ -20521,7 +20692,7 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20521
20692
|
const width = (table.widthPx ?? cursor.columnWidthPx) + (activeBorders ? (profile.leftPx + profile.rightPx) / 2 : 0);
|
|
20522
20693
|
return table.alignment === "center" ? Math.max(0, (cursor.columnWidthPx - width) / 2) : table.alignment === "right" ? Math.max(0, cursor.columnWidthPx - width) : table.indentPx ?? 0;
|
|
20523
20694
|
};
|
|
20524
|
-
const profile = nestedFrameProfile(table, table.widthPx ?? cursor.columnWidthPx);
|
|
20695
|
+
const profile = nestedFrameProfile(table, table.widthPx ?? cursor.columnWidthPx, true);
|
|
20525
20696
|
const activeBorders = profile !== void 0 && (profile.leftPx > 0 || profile.rightPx > 0 || profile.bottomPx > 0);
|
|
20526
20697
|
if (!profile && table.rows.some((row2) => row2.cells.some((cell) => cell.borders)))
|
|
20527
20698
|
note(
|
|
@@ -20557,6 +20728,7 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20557
20728
|
};
|
|
20558
20729
|
function flushFragment() {
|
|
20559
20730
|
fragmentHeight += fragmentBorders.restore(fragmentRows.at(-1));
|
|
20731
|
+
alignMergedCells(fragmentRows);
|
|
20560
20732
|
if (!fragmentRows.length) {
|
|
20561
20733
|
footnotes?.holdFragment();
|
|
20562
20734
|
return;
|
|
@@ -20733,7 +20905,16 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20733
20905
|
) : after;
|
|
20734
20906
|
}
|
|
20735
20907
|
}
|
|
20736
|
-
|
|
20908
|
+
const merged = new MergedRowPlan(table.rows);
|
|
20909
|
+
for (const [index, source] of table.rows.entries()) {
|
|
20910
|
+
merged.plan(
|
|
20911
|
+
index,
|
|
20912
|
+
(candidate) => layoutRow2(candidate, cursor.columnWidthPx, measurer, () => {
|
|
20913
|
+
}, void 0, source),
|
|
20914
|
+
cursor.remainingHeightPx() - fragmentHeight
|
|
20915
|
+
);
|
|
20916
|
+
const row2 = merged.effective(source);
|
|
20917
|
+
if (row2 !== source) nativeFragments.set(row2, nativeFragments.get(source) ?? false);
|
|
20737
20918
|
const layout = layoutRow2(row2, cursor.columnWidthPx, measurer, note);
|
|
20738
20919
|
if (layout.heightPx > cursor.remainingHeightPx() && !nativeFragments.get(row2) && row2.cells.some(
|
|
20739
20920
|
(cell) => cell.blocks?.some((block) => block.kind === "table" && block.rows.length > 1)
|
|
@@ -20750,11 +20931,23 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20750
20931
|
placeRow(
|
|
20751
20932
|
row2,
|
|
20752
20933
|
layout,
|
|
20753
|
-
Boolean(row2.cantSplit) || headerRows.includes(
|
|
20934
|
+
Boolean(row2.cantSplit) || headerRows.includes(source) || !!footnotes && row2.heightRule === "exact"
|
|
20754
20935
|
);
|
|
20755
20936
|
}
|
|
20756
20937
|
flushFragment();
|
|
20757
20938
|
}
|
|
20939
|
+
function alignMergedCells(rows2) {
|
|
20940
|
+
rows2.forEach((row2, index) => {
|
|
20941
|
+
for (const geometry of row2.geometry ?? []) {
|
|
20942
|
+
const count = geometry.mergeRows ?? 1;
|
|
20943
|
+
if (count < 2 || !geometry.verticalAlign || geometry.verticalAlign === "top") continue;
|
|
20944
|
+
const last = rows2[index + count - 1];
|
|
20945
|
+
if (!last || rows2.slice(index, index + count).some((item) => item.repeated !== row2.repeated))
|
|
20946
|
+
continue;
|
|
20947
|
+
geometry.alignmentHeightPx = last.yPx + last.heightPx - row2.yPx;
|
|
20948
|
+
}
|
|
20949
|
+
});
|
|
20950
|
+
}
|
|
20758
20951
|
|
|
20759
20952
|
// docx/layout/reference-footnotes.ts
|
|
20760
20953
|
function createReferenceFootnotes(width, measurer, report) {
|
|
@@ -20789,7 +20982,8 @@ function wrapExclusions(pages) {
|
|
|
20789
20982
|
yPx: float.yPx,
|
|
20790
20983
|
widthPx: float.widthPx + SIDE_DISTANCE_PX * 2,
|
|
20791
20984
|
heightPx: float.heightPx,
|
|
20792
|
-
topAndBottom: float.wrap === "topAndBottom"
|
|
20985
|
+
topAndBottom: float.wrap === "topAndBottom",
|
|
20986
|
+
...float.wrapText === "bothSides" ? { bothSides: true } : {}
|
|
20793
20987
|
}));
|
|
20794
20988
|
if (list.length) exclusions.set(page.index, list);
|
|
20795
20989
|
}
|
|
@@ -20810,6 +21004,7 @@ function lineBoxesFor(exclusions, topPx, columnLeftPx, columnWidthPx) {
|
|
|
20810
21004
|
let leftInsetPx = 0;
|
|
20811
21005
|
let rightInsetPx = 0;
|
|
20812
21006
|
let gapBeforePx = 0;
|
|
21007
|
+
const shared = [];
|
|
20813
21008
|
for (const exclusion of exclusions) {
|
|
20814
21009
|
const overlapsLine = exclusion.yPx < top + heightPx && exclusion.yPx + exclusion.heightPx > top;
|
|
20815
21010
|
const start = exclusion.xPx - columnLeftPx;
|
|
@@ -20821,10 +21016,26 @@ function lineBoxesFor(exclusions, topPx, columnLeftPx, columnWidthPx) {
|
|
|
20821
21016
|
gapBeforePx = Math.max(gapBeforePx, exclusion.yPx + exclusion.heightPx - top);
|
|
20822
21017
|
continue;
|
|
20823
21018
|
}
|
|
21019
|
+
if (exclusion.bothSides && Math.min(left, right) >= MIN_SIDE_WIDTH_PX) {
|
|
21020
|
+
shared.push({ start, end });
|
|
21021
|
+
continue;
|
|
21022
|
+
}
|
|
20824
21023
|
if (left >= right) rightInsetPx = Math.max(rightInsetPx, columnWidthPx - start);
|
|
20825
21024
|
else leftInsetPx = Math.max(leftInsetPx, end);
|
|
20826
21025
|
}
|
|
20827
|
-
|
|
21026
|
+
const single = shared.length === 1 && !leftInsetPx && !rightInsetPx ? shared[0] : void 0;
|
|
21027
|
+
if (!single)
|
|
21028
|
+
for (const { start, end } of shared) {
|
|
21029
|
+
if (start >= columnWidthPx - end)
|
|
21030
|
+
rightInsetPx = Math.max(rightInsetPx, columnWidthPx - start);
|
|
21031
|
+
else leftInsetPx = Math.max(leftInsetPx, end);
|
|
21032
|
+
}
|
|
21033
|
+
return {
|
|
21034
|
+
leftInsetPx,
|
|
21035
|
+
rightInsetPx,
|
|
21036
|
+
gapBeforePx,
|
|
21037
|
+
...single ? { hole: { startPx: single.start, endPx: single.end } } : {}
|
|
21038
|
+
};
|
|
20828
21039
|
};
|
|
20829
21040
|
}
|
|
20830
21041
|
|
|
@@ -20986,8 +21197,18 @@ var SectionFlow = class {
|
|
|
20986
21197
|
if (block?.kind !== "paragraph") return 0;
|
|
20987
21198
|
const layout = this.paragraphLayout(index);
|
|
20988
21199
|
const previous = index > 0 ? this.blocks[index - 1] : void 0;
|
|
20989
|
-
if (
|
|
20990
|
-
|
|
21200
|
+
if (index === 0 && !this.section.addParagraphSpacing)
|
|
21201
|
+
return Math.max(0, layout.spacingBeforePx - (this.section.leadingSpacingAfterPx ?? 0));
|
|
21202
|
+
if (previous?.kind !== "paragraph") return layout.spacingBeforePx;
|
|
21203
|
+
if (suppressesSpacing(previous, block)) return 0;
|
|
21204
|
+
if (this.section.addParagraphSpacing) return layout.spacingBeforePx;
|
|
21205
|
+
return Math.max(0, layout.spacingBeforePx - this.paragraphLayout(index - 1).spacingAfterPx);
|
|
21206
|
+
}
|
|
21207
|
+
/** Contextual spacing: no space after a paragraph that is followed by one of its own style. */
|
|
21208
|
+
spacingAfterSuppressed(index) {
|
|
21209
|
+
const block = this.blocks[index];
|
|
21210
|
+
const next = this.blocks[index + 1];
|
|
21211
|
+
return block?.kind === "paragraph" && next?.kind === "paragraph" && suppressesSpacing(block, next);
|
|
20991
21212
|
}
|
|
20992
21213
|
/** Minimum height that must fit before `index` may start, walking a `keepNext` chain. */
|
|
20993
21214
|
requiredKeepHeight(index, depth = 0) {
|
|
@@ -21059,6 +21280,8 @@ var SectionFlow = class {
|
|
|
21059
21280
|
layout,
|
|
21060
21281
|
footnotes,
|
|
21061
21282
|
spacingBeforePx,
|
|
21283
|
+
...this.section.keepSpaceBeforePageBreak ? { keepSpaceBeforePageBreak: true } : {},
|
|
21284
|
+
...this.spacingAfterSuppressed(index) ? { spacingAfterPx: 0 } : {},
|
|
21062
21285
|
...this.section.modernFootnoteSeparator || this.section.legacyFootnoteColumns ? { trimLeadingColumnBreak: true } : {},
|
|
21063
21286
|
requiredTogetherPx,
|
|
21064
21287
|
reflow: (token) => layoutParagraph(
|
|
@@ -21588,7 +21811,8 @@ function paragraphFloats(paragraph, theme) {
|
|
|
21588
21811
|
...placement?.alignV ? { alignV: placement.alignV } : {},
|
|
21589
21812
|
...placement?.offsetYPx !== void 0 ? { offsetYPx: placement.offsetYPx } : {},
|
|
21590
21813
|
...placement?.behindText ? { behindText: true } : {},
|
|
21591
|
-
...placement?.wrap ? { wrap: placement.wrap } : {}
|
|
21814
|
+
...placement?.wrap ? { wrap: placement.wrap } : {},
|
|
21815
|
+
...placement?.wrapText ? { wrapText: placement.wrapText } : {}
|
|
21592
21816
|
});
|
|
21593
21817
|
}
|
|
21594
21818
|
return floats;
|
|
@@ -22416,17 +22640,17 @@ function glyph(text2, size, stretch = 1) {
|
|
|
22416
22640
|
return box;
|
|
22417
22641
|
}
|
|
22418
22642
|
function scripts(base, sub, sup, style) {
|
|
22419
|
-
const raise = Math.max(style.size * 0.
|
|
22420
|
-
const drop = Math.max(style.size * 0.
|
|
22643
|
+
const raise = Math.max(style.size * 0.36, base.ascent - style.size * 0.42);
|
|
22644
|
+
const drop = Math.max(style.size * 0.15, base.descent - style.size * 0.07);
|
|
22421
22645
|
const parts = [{ box: base, x: 0, y: 0 }];
|
|
22422
22646
|
let width = base.width;
|
|
22423
22647
|
if (sup) {
|
|
22424
|
-
const y = -Math.max(raise, sup.descent + style.size * 0.
|
|
22648
|
+
const y = -Math.max(raise, sup.descent + style.size * 0.2);
|
|
22425
22649
|
parts.push({ box: sup, x: base.width + 1, y });
|
|
22426
22650
|
width = Math.max(width, base.width + 1 + sup.width);
|
|
22427
22651
|
}
|
|
22428
22652
|
if (sub) {
|
|
22429
|
-
const y = Math.max(drop, sub.ascent - style.size * 0.
|
|
22653
|
+
const y = Math.max(drop, sub.ascent - style.size * 0.4);
|
|
22430
22654
|
parts.push({ box: sub, x: base.width + 1, y });
|
|
22431
22655
|
width = Math.max(width, base.width + 1 + sub.width);
|
|
22432
22656
|
}
|
|
@@ -22442,8 +22666,8 @@ function nary(node, style, ctx) {
|
|
|
22442
22666
|
const chr = val(child(pr, "m:chr")) || "\u222B";
|
|
22443
22667
|
const big = NARY.has(chr) ? 1.4 : 1.6;
|
|
22444
22668
|
const op = glyph(chr, style.size * big);
|
|
22445
|
-
op.ascent = style.size *
|
|
22446
|
-
op.descent = style.size * (big > 1.5 ? 0.55 : 0.
|
|
22669
|
+
op.ascent = style.size * (big > 1.5 ? 1.17 : 1.15);
|
|
22670
|
+
op.descent = style.size * (big > 1.5 ? 0.55 : 0.6);
|
|
22447
22671
|
const limits = (val(child(pr, "m:limLoc")) || (NARY.has(chr) ? "undOvr" : "subSup")) === "undOvr";
|
|
22448
22672
|
const sub = isOn2(val(child(pr, "m:subHide"))) ? void 0 : ctx.layout(child(node, "m:sub"), ctx.script(style));
|
|
22449
22673
|
const sup = isOn2(val(child(pr, "m:supHide"))) ? void 0 : ctx.layout(child(node, "m:sup"), ctx.script(style));
|
|
@@ -22457,13 +22681,13 @@ function nary(node, style, ctx) {
|
|
|
22457
22681
|
parts.push({
|
|
22458
22682
|
box: sup,
|
|
22459
22683
|
x: (width - sup.width) / 2,
|
|
22460
|
-
y: -(op.ascent + sup.descent + style.size * 0.
|
|
22684
|
+
y: -(op.ascent + sup.descent + style.size * 0.075)
|
|
22461
22685
|
});
|
|
22462
22686
|
if (hasSub)
|
|
22463
22687
|
parts.push({
|
|
22464
22688
|
box: sub,
|
|
22465
22689
|
x: (width - sub.width) / 2,
|
|
22466
|
-
y: op.descent + sub.ascent + style.size * 0.
|
|
22690
|
+
y: op.descent + sub.ascent + style.size * 0.075
|
|
22467
22691
|
});
|
|
22468
22692
|
head = overlay(parts);
|
|
22469
22693
|
head.width = width;
|
|
@@ -22509,7 +22733,7 @@ function matrix(node, style, ctx) {
|
|
|
22509
22733
|
(_, c) => Math.max(0, ...rows2.map((cells) => cells[c]?.width ?? 0))
|
|
22510
22734
|
);
|
|
22511
22735
|
const gapX = style.size * 0.8;
|
|
22512
|
-
const gapY =
|
|
22736
|
+
const gapY = 0;
|
|
22513
22737
|
const result = emptyBox();
|
|
22514
22738
|
let y = 0;
|
|
22515
22739
|
const heights = rows2.map((cells) => ({
|
|
@@ -22559,15 +22783,15 @@ function below(base, mark, style) {
|
|
|
22559
22783
|
// math/omml-box-structures.ts
|
|
22560
22784
|
function fraction(node, style, ctx) {
|
|
22561
22785
|
const type = val(child(child(node, "m:fPr"), "m:type"));
|
|
22562
|
-
const inner = ctx.script({ ...style, level: Math.min(style.level, 0) });
|
|
22563
|
-
const small = style.level === 0 ? { ...style,
|
|
22786
|
+
const inner = ctx.script({ ...style, level: Math.min(style.level, 0), display: false });
|
|
22787
|
+
const small = style.level === 0 && style.display ? { ...style, display: false } : inner;
|
|
22564
22788
|
const num = ctx.layout(child(node, "m:num"), small);
|
|
22565
22789
|
const den = ctx.layout(child(node, "m:den"), small);
|
|
22566
22790
|
if (type === "lin") {
|
|
22567
22791
|
const slash = glyph("/", style.size);
|
|
22568
22792
|
return row([num, slash, den]);
|
|
22569
22793
|
}
|
|
22570
|
-
const gap = style.size * 0.
|
|
22794
|
+
const gap = style.size * 0.15;
|
|
22571
22795
|
const axis = style.size * AXIS;
|
|
22572
22796
|
const width = Math.max(num.width, den.width) + style.size * 0.2;
|
|
22573
22797
|
const bar = type === "noBar" ? [] : [
|
|
@@ -22592,9 +22816,9 @@ function radical(node, style, ctx) {
|
|
|
22592
22816
|
const content = ctx.layout(child(node, "m:e"), style);
|
|
22593
22817
|
const hide = isOn2(val(child(child(node, "m:radPr"), "m:degHide")));
|
|
22594
22818
|
const degree = hide ? void 0 : ctx.layout(child(node, "m:deg"), { ...ctx.script(ctx.script(style)) });
|
|
22595
|
-
const gap = style.size * 0.
|
|
22819
|
+
const gap = style.size * 0.2;
|
|
22596
22820
|
const top = -(content.ascent + gap);
|
|
22597
|
-
const bottom = content.descent + style.size * 0.
|
|
22821
|
+
const bottom = content.descent + style.size * 0.15;
|
|
22598
22822
|
const height = bottom - top;
|
|
22599
22823
|
const sign = style.size * 0.55;
|
|
22600
22824
|
const lead = degree && degree.width ? Math.max(0, degree.width - sign * 0.4) : 0;
|
|
@@ -22795,11 +23019,11 @@ function layoutElement(tag, node, style, atStart) {
|
|
|
22795
23019
|
if (/Pr$/.test(tag) || tag === "m:ctrlPr") return emptyBox();
|
|
22796
23020
|
return layoutStructure(tag, node, style, { layout: layoutChildren, script: scriptStyle });
|
|
22797
23021
|
}
|
|
22798
|
-
function layoutEquation(root, sizePx) {
|
|
22799
|
-
const box = layoutChildren(root, { level: 0, size: sizePx });
|
|
23022
|
+
function layoutEquation(root, sizePx, options2 = {}) {
|
|
23023
|
+
const box = layoutChildren(root, { level: 0, size: sizePx, display: Boolean(options2.display) });
|
|
22800
23024
|
const pad2 = 1;
|
|
22801
|
-
const ascent = Math.max(box.ascent, sizePx * 0.
|
|
22802
|
-
const descent = Math.max(box.descent, sizePx * 0.
|
|
23025
|
+
const ascent = Math.max(box.ascent, sizePx * 0.9);
|
|
23026
|
+
const descent = Math.max(box.descent, sizePx * 0.24);
|
|
22803
23027
|
return {
|
|
22804
23028
|
box: { ...box, prims: shifted(box.prims, pad2, 0), ascent, descent },
|
|
22805
23029
|
widthPx: round2(Math.max(box.width, sizePx * 0.5) + pad2 * 2),
|
|
@@ -22858,17 +23082,17 @@ function primMarkup(prim) {
|
|
|
22858
23082
|
return `<path d="${prim.d}" fill="none" stroke="currentColor" stroke-width="${round2(prim.width)}" stroke-linejoin="round"/>`;
|
|
22859
23083
|
}
|
|
22860
23084
|
}
|
|
22861
|
-
function drawOmmlTree(root, sizePx, label = "") {
|
|
22862
|
-
const { box, widthPx, heightPx, descentPx } = layoutEquation(root, sizePx);
|
|
23085
|
+
function drawOmmlTree(root, sizePx, label = "", options2 = {}) {
|
|
23086
|
+
const { box, widthPx, heightPx, descentPx } = layoutEquation(root, sizePx, options2);
|
|
22863
23087
|
if (!box.prims.length) return void 0;
|
|
22864
23088
|
const body = box.prims.map(primMarkup).join("");
|
|
22865
23089
|
const aria = label ? ` aria-label="${escapeXml2(label).replace(/"/g, """)}"` : "";
|
|
22866
23090
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${widthPx}" height="${heightPx}" viewBox="0 0 ${widthPx} ${heightPx}" role="img"${aria}><g font-family="${FONT_FAMILY}" fill="currentColor" transform="translate(0 ${round2(box.ascent)})">${body}</g></svg>`;
|
|
22867
23091
|
return { svg, widthPx, heightPx, descentPx };
|
|
22868
23092
|
}
|
|
22869
|
-
function drawEquation(omml, sizePx, label = "") {
|
|
23093
|
+
function drawEquation(omml, sizePx, label = "", options2 = {}) {
|
|
22870
23094
|
try {
|
|
22871
|
-
return drawOmmlTree(parseOmml(omml), sizePx, label);
|
|
23095
|
+
return drawOmmlTree(parseOmml(omml), sizePx, label, options2);
|
|
22872
23096
|
} catch {
|
|
22873
23097
|
return void 0;
|
|
22874
23098
|
}
|
|
@@ -22884,11 +23108,11 @@ function latexLabel(omml) {
|
|
|
22884
23108
|
return "Equation";
|
|
22885
23109
|
}
|
|
22886
23110
|
}
|
|
22887
|
-
function equationObject(omml, sizePx) {
|
|
22888
|
-
const key = `${sizePx}|${omml}`;
|
|
23111
|
+
function equationObject(omml, sizePx, display = false) {
|
|
23112
|
+
const key = `${sizePx}|${display}|${omml}`;
|
|
22889
23113
|
const hit = cache.get(key);
|
|
22890
23114
|
if (hit !== void 0) return hit ?? void 0;
|
|
22891
|
-
const drawing = drawEquation(omml, sizePx, latexLabel(omml));
|
|
23115
|
+
const drawing = drawEquation(omml, sizePx, latexLabel(omml), { display });
|
|
22892
23116
|
const object = drawing ? {
|
|
22893
23117
|
partName: "",
|
|
22894
23118
|
contentType: "",
|
|
@@ -22946,6 +23170,7 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
22946
23170
|
return start;
|
|
22947
23171
|
});
|
|
22948
23172
|
});
|
|
23173
|
+
const merges = tableGrid(table);
|
|
22949
23174
|
const cellAt = (rowIndex, gridIndex) => {
|
|
22950
23175
|
const position = gridIndexes[rowIndex]?.indexOf(gridIndex) ?? -1;
|
|
22951
23176
|
return position >= 0 ? table.rows[rowIndex]?.[position] : void 0;
|
|
@@ -22991,10 +23216,13 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
22991
23216
|
const width = gridWidth(start, span) ?? (cell.widthTwips ? twipsToPx2(cell.widthTwips) : void 0);
|
|
22992
23217
|
const xPx = grid ? gridWidth(0, start) : void 0;
|
|
22993
23218
|
const fill = cssHex(visuals.shadingFill);
|
|
23219
|
+
const entry = merges?.rows[rowIndex]?.[cellIndex];
|
|
23220
|
+
const rowSpan = merges && entry ? rowSpanOf(merges, entry) : 1;
|
|
22994
23221
|
return {
|
|
22995
23222
|
paragraphs: cell.paragraphs.map(adaptParagraph),
|
|
22996
23223
|
...cell.gridSpan !== void 0 ? { gridSpan: cell.gridSpan } : {},
|
|
22997
23224
|
...cell.verticalMerge ? { verticalMerge: cell.verticalMerge } : {},
|
|
23225
|
+
...rowSpan > 1 ? { rowSpan } : {},
|
|
22998
23226
|
...cell.sourceBlocks ? {
|
|
22999
23227
|
blocks: cellSourceBlocks(cell).map(
|
|
23000
23228
|
(block) => block.type === "paragraph" ? adaptParagraph(block) : adaptTable(block, model, adaptParagraph, true)
|
|
@@ -23122,6 +23350,7 @@ var TEXT_BOX_NOTE = "Text boxes are shown on the editing surface but are not dra
|
|
|
23122
23350
|
var EQUATION_NOTE = "Equations that cannot be drawn show a marker in Print Layout instead of the typeset equation.";
|
|
23123
23351
|
var NEXT_COLUMN_NOTE = 'A "next column" section break is laid out as a continuous section break.';
|
|
23124
23352
|
var twipsToPx3 = twipsToPixels;
|
|
23353
|
+
var HTML_AUTO_SPACING_TWIPS = twips(280);
|
|
23125
23354
|
function isDisplayEquationParagraph(paragraph) {
|
|
23126
23355
|
return paragraph.runs.some((run) => run.equation?.display) && paragraph.runs.every((run) => run.equation?.display || !run.text && !run.image);
|
|
23127
23356
|
}
|
|
@@ -23141,6 +23370,9 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23141
23370
|
const reviewMode = options2.reviewDisplayMode ?? "all";
|
|
23142
23371
|
const visibleModel = visibleReviewModel(model, reviewMode);
|
|
23143
23372
|
const catalog = model.paragraphStyles;
|
|
23373
|
+
const addParagraphSpacing = model.doNotUseHtmlParagraphAutoSpacing === true;
|
|
23374
|
+
const keepSpaceBeforePageBreak = model.compatibilityMode !== 15;
|
|
23375
|
+
const autoSpaced = (auto, twipsValue) => auto && !addParagraphSpacing ? HTML_AUTO_SPACING_TWIPS : twipsValue;
|
|
23144
23376
|
const noted = /* @__PURE__ */ new Set();
|
|
23145
23377
|
const reportOnce = (message) => {
|
|
23146
23378
|
if (!noted.has(message)) {
|
|
@@ -23166,7 +23398,11 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23166
23398
|
if (isRunHiddenForReview(run, reviewMode))
|
|
23167
23399
|
return { text: run.text, hidden: true, sourceLength: reviewSourceLength(run) };
|
|
23168
23400
|
const { formatting, family, color } = effective(run, paragraphStyleId);
|
|
23169
|
-
const equation = run.equation ? equationObject(
|
|
23401
|
+
const equation = run.equation ? equationObject(
|
|
23402
|
+
run.equation.omml,
|
|
23403
|
+
ptToPx(formatting.fontSize ?? DEFAULT_FONT_SIZE_PT),
|
|
23404
|
+
Boolean(run.equation.display)
|
|
23405
|
+
) : void 0;
|
|
23170
23406
|
if (run.equation && !equation) reportOnce(EQUATION_NOTE);
|
|
23171
23407
|
const name = run.field ? fieldName(run.field.instr) : "";
|
|
23172
23408
|
const noteText = run.noteReference ? noteLabel(run.noteReference.kind, run.noteReference.id) : run.noteMark ? markLabel ?? "" : void 0;
|
|
@@ -23247,7 +23483,9 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23247
23483
|
function adaptParagraphOnly(paragraph, markLabel) {
|
|
23248
23484
|
const resolved = catalog ? resolveParagraphFormatting(paragraph, catalog) : paragraph;
|
|
23249
23485
|
const label = labels.get(paragraph.id);
|
|
23250
|
-
const
|
|
23486
|
+
const levelWins = Boolean(label && paragraph.numbering);
|
|
23487
|
+
const indents = levelWins ? paragraph : resolved;
|
|
23488
|
+
const ownFirstLine = indents.firstLineTwips !== void 0 || indents.hangingTwips !== void 0;
|
|
23251
23489
|
const runs = paragraph.runs.flatMap(
|
|
23252
23490
|
(run) => symbolSegments(run).flatMap((segment2) => {
|
|
23253
23491
|
const adapted = adaptRun(segment2, paragraph.style, markLabel);
|
|
@@ -23279,16 +23517,16 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23279
23517
|
...definedProps({
|
|
23280
23518
|
align: resolved.align ?? (isDisplayEquationParagraph(paragraph) ? "center" : void 0),
|
|
23281
23519
|
direction: resolved.direction,
|
|
23282
|
-
spacingBeforeTwips: resolved.spacingBeforeTwips,
|
|
23283
|
-
spacingAfterTwips: resolved.spacingAfterTwips,
|
|
23520
|
+
spacingBeforeTwips: autoSpaced(resolved.spacingBeforeAuto, resolved.spacingBeforeTwips),
|
|
23521
|
+
spacingAfterTwips: autoSpaced(resolved.spacingAfterAuto, resolved.spacingAfterTwips),
|
|
23284
23522
|
lineSpacingTwips: resolved.lineSpacingTwips,
|
|
23285
23523
|
lineSpacingRule: resolved.lineSpacingRule,
|
|
23286
|
-
indentLeftTwips:
|
|
23524
|
+
indentLeftTwips: indents.indentLeftTwips ?? label?.indentLeftTwips ?? (levelWins ? resolved.indentLeftTwips : void 0),
|
|
23287
23525
|
indentRightTwips: resolved.indentRightTwips,
|
|
23288
23526
|
indentStartTwips: resolved.indentStartTwips,
|
|
23289
23527
|
indentEndTwips: resolved.indentEndTwips,
|
|
23290
|
-
firstLineTwips: ownFirstLine ?
|
|
23291
|
-
hangingTwips: ownFirstLine ?
|
|
23528
|
+
firstLineTwips: ownFirstLine ? indents.firstLineTwips : label?.firstLineTwips,
|
|
23529
|
+
hangingTwips: ownFirstLine ? indents.hangingTwips : label?.hangingTwips,
|
|
23292
23530
|
styleId: paragraph.style
|
|
23293
23531
|
}),
|
|
23294
23532
|
...resolved.pageBreakBefore ? { pageBreakBefore: true } : {},
|
|
@@ -23347,6 +23585,8 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23347
23585
|
marginLeftPx: model.page.marginLeft
|
|
23348
23586
|
},
|
|
23349
23587
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
23588
|
+
...addParagraphSpacing ? { addParagraphSpacing: true } : {},
|
|
23589
|
+
...keepSpaceBeforePageBreak ? { keepSpaceBeforePageBreak: true } : {},
|
|
23350
23590
|
...modernFootnoteSeparator ? { modernFootnoteSeparator: true } : {},
|
|
23351
23591
|
...legacyFootnoteColumns ? { legacyFootnoteColumns: true } : {},
|
|
23352
23592
|
blocks: blocks.filter((block) => !folded.has(block))
|
|
@@ -23413,6 +23653,8 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23413
23653
|
} : {}
|
|
23414
23654
|
}
|
|
23415
23655
|
} : {},
|
|
23656
|
+
...addParagraphSpacing ? { addParagraphSpacing: true } : {},
|
|
23657
|
+
...keepSpaceBeforePageBreak ? { keepSpaceBeforePageBreak: true } : {},
|
|
23416
23658
|
...sectionStart && { break: sectionStart },
|
|
23417
23659
|
...section.verticalAlign ? { verticalAlign: section.verticalAlign } : {},
|
|
23418
23660
|
// Empty text break markers share the preceding line. The mandatory
|
|
@@ -23425,11 +23667,17 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23425
23667
|
})
|
|
23426
23668
|
};
|
|
23427
23669
|
});
|
|
23428
|
-
return {
|
|
23670
|
+
return {
|
|
23671
|
+
sections: result.map((section, index) => {
|
|
23672
|
+
const last = result[index - 1]?.blocks.at(-1);
|
|
23673
|
+
const after = last?.kind === "paragraph" ? last.spacingAfterTwips : void 0;
|
|
23674
|
+
return !addParagraphSpacing && after ? { ...section, leadingSpacingAfterPx: twipsToPx3(after) } : section;
|
|
23675
|
+
})
|
|
23676
|
+
};
|
|
23429
23677
|
}
|
|
23430
23678
|
|
|
23431
23679
|
// docx/layout/floats.ts
|
|
23432
|
-
var FLOAT_WRAP_NOTE = "Text wraps around floating pictures on their largest side
|
|
23680
|
+
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.";
|
|
23433
23681
|
function horizontalArea(float, page, column) {
|
|
23434
23682
|
const contentLeft = page.marginLeftPx;
|
|
23435
23683
|
switch (float.relativeFromH) {
|
|
@@ -23519,7 +23767,8 @@ function positionFloats(input, pages) {
|
|
|
23519
23767
|
contentType: float.contentType,
|
|
23520
23768
|
...float.chart ? { chart: float.chart } : {},
|
|
23521
23769
|
behindText: Boolean(float.behindText),
|
|
23522
|
-
...float.wrap ? { wrap: float.wrap } : {}
|
|
23770
|
+
...float.wrap ? { wrap: float.wrap } : {},
|
|
23771
|
+
...float.wrapText ? { wrapText: float.wrapText } : {}
|
|
23523
23772
|
});
|
|
23524
23773
|
}
|
|
23525
23774
|
}
|