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
|
@@ -541,6 +541,8 @@ function resolveParagraphFormatting(paragraph, catalog) {
|
|
|
541
541
|
"direction",
|
|
542
542
|
"spacingBeforeTwips",
|
|
543
543
|
"spacingAfterTwips",
|
|
544
|
+
"spacingBeforeAuto",
|
|
545
|
+
"spacingAfterAuto",
|
|
544
546
|
"lineSpacingTwips",
|
|
545
547
|
"lineSpacingRule",
|
|
546
548
|
"indentLeftTwips",
|
|
@@ -1767,14 +1769,6 @@ function escapeXmlAttr(value) {
|
|
|
1767
1769
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1768
1770
|
}
|
|
1769
1771
|
|
|
1770
|
-
// docx/expect-defined.ts
|
|
1771
|
-
function expectDefined(value, context) {
|
|
1772
|
-
if (value === void 0 || value === null) {
|
|
1773
|
-
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
1774
|
-
}
|
|
1775
|
-
return value;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
1772
|
// docx/element-order.ts
|
|
1779
1773
|
function orderChildren(parent, order) {
|
|
1780
1774
|
const elements2 = Array.from(parent.childNodes).filter(isElement);
|
|
@@ -1844,6 +1838,55 @@ function orderParagraphProperties(props) {
|
|
|
1844
1838
|
orderChildren(props, PPR_ORDER);
|
|
1845
1839
|
}
|
|
1846
1840
|
|
|
1841
|
+
// docx/expect-defined.ts
|
|
1842
|
+
function expectDefined(value, context) {
|
|
1843
|
+
if (value === void 0 || value === null) {
|
|
1844
|
+
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
1845
|
+
}
|
|
1846
|
+
return value;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
// docx/table-grid.ts
|
|
1850
|
+
var spanOf = (cell) => Math.max(1, cell.gridSpan ?? 1);
|
|
1851
|
+
function tableGrid(table) {
|
|
1852
|
+
const columns = table.grid?.length ?? sumSpans(table.rows[0]);
|
|
1853
|
+
if (!columns || !table.rows.length) return void 0;
|
|
1854
|
+
const rows2 = [];
|
|
1855
|
+
const cover = [];
|
|
1856
|
+
for (let row2 = 0; row2 < table.rows.length; row2++) {
|
|
1857
|
+
const cells = table.rows[row2] ?? [];
|
|
1858
|
+
if (!cells.length || sumSpans(cells) !== columns) return void 0;
|
|
1859
|
+
const placed2 = [];
|
|
1860
|
+
const line3 = new Array(columns);
|
|
1861
|
+
let col = 0;
|
|
1862
|
+
cells.forEach((cell, index) => {
|
|
1863
|
+
const entry = { cell, row: row2, index, col, span: spanOf(cell) };
|
|
1864
|
+
for (let k = 0; k < entry.span; k++) line3[col + k] = entry;
|
|
1865
|
+
col += entry.span;
|
|
1866
|
+
placed2.push(entry);
|
|
1867
|
+
});
|
|
1868
|
+
rows2.push(placed2);
|
|
1869
|
+
cover.push(line3);
|
|
1870
|
+
}
|
|
1871
|
+
const grid = { columns, rows: rows2, cover };
|
|
1872
|
+
for (const entry of rows2.flat())
|
|
1873
|
+
if (entry.cell.verticalMerge === "continue") {
|
|
1874
|
+
const above2 = entry.row > 0 ? cover[entry.row - 1]?.[entry.col] : void 0;
|
|
1875
|
+
if (!above2 || above2.col !== entry.col || above2.span !== entry.span) return void 0;
|
|
1876
|
+
if (!above2.cell.verticalMerge) return void 0;
|
|
1877
|
+
}
|
|
1878
|
+
return grid;
|
|
1879
|
+
}
|
|
1880
|
+
function sumSpans(cells) {
|
|
1881
|
+
return (cells ?? []).reduce((sum, cell) => sum + spanOf(cell), 0);
|
|
1882
|
+
}
|
|
1883
|
+
function rowSpanOf(grid, entry) {
|
|
1884
|
+
if (entry.cell.verticalMerge !== "restart") return 1;
|
|
1885
|
+
let height = 1;
|
|
1886
|
+
while (grid.cover[entry.row + height]?.[entry.col]?.cell.verticalMerge === "continue") height++;
|
|
1887
|
+
return height;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1847
1890
|
// docx/special-characters.ts
|
|
1848
1891
|
function symbolCharacter(char) {
|
|
1849
1892
|
const code = /^[0-9a-f]{1,6}$/i.test(char) ? Number.parseInt(char, 16) : Number.NaN;
|
|
@@ -16972,6 +17015,10 @@ function parseDirectParagraphProperties(props) {
|
|
|
16972
17015
|
const line3 = signedTwipValue(getW(spacing2, "line"));
|
|
16973
17016
|
if (before !== void 0) paragraph.spacingBeforeTwips = before;
|
|
16974
17017
|
if (after !== void 0) paragraph.spacingAfterTwips = after;
|
|
17018
|
+
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
17019
|
+
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
17020
|
+
if (beforeAuto !== void 0) paragraph.spacingBeforeAuto = beforeAuto;
|
|
17021
|
+
if (afterAuto !== void 0) paragraph.spacingAfterAuto = afterAuto;
|
|
16975
17022
|
if (line3 !== void 0) {
|
|
16976
17023
|
paragraph.lineSpacingTwips = line3;
|
|
16977
17024
|
}
|
|
@@ -18656,8 +18703,8 @@ function justify(fragments, width) {
|
|
|
18656
18703
|
const spaceIndices = fragments.map((f, i) => f.text === " " ? i : -1).filter((i) => i >= 0);
|
|
18657
18704
|
if (!spaceIndices.length || !fragments.length) return fragments;
|
|
18658
18705
|
const natural = fragments.at(-1).xPx + fragments.at(-1).widthPx;
|
|
18659
|
-
const extra =
|
|
18660
|
-
if (extra
|
|
18706
|
+
const extra = (width - natural) / spaceIndices.length;
|
|
18707
|
+
if (extra === 0) return fragments;
|
|
18661
18708
|
let shift = 0;
|
|
18662
18709
|
return fragments.map((fragment, index) => {
|
|
18663
18710
|
const placedFragment = { ...fragment, xPx: fragment.xPx + shift };
|
|
@@ -18701,6 +18748,7 @@ function cachedParagraphLayout(measurer, key, note, compute) {
|
|
|
18701
18748
|
}
|
|
18702
18749
|
|
|
18703
18750
|
// docx/layout/paragraph-layout.ts
|
|
18751
|
+
var SPACE_SHRINK = 0.145;
|
|
18704
18752
|
function layoutParagraph(paragraph, contentWidthPx, measurer, note, lineBox, startToken = 0) {
|
|
18705
18753
|
if (lineBox)
|
|
18706
18754
|
return measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, startToken);
|
|
@@ -18739,6 +18787,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18739
18787
|
let widthOverflowNoted = false;
|
|
18740
18788
|
let placed2 = [];
|
|
18741
18789
|
let lineWidthPx = 0;
|
|
18790
|
+
let lineSpacePx = 0;
|
|
18791
|
+
let jump;
|
|
18742
18792
|
let marginReachPx = 0;
|
|
18743
18793
|
let tokenCursor = startToken;
|
|
18744
18794
|
let firstToken = startToken;
|
|
@@ -18756,7 +18806,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18756
18806
|
boxes[lineIndex] = {
|
|
18757
18807
|
leftInsetPx: box?.leftInsetPx ?? 0,
|
|
18758
18808
|
rightInsetPx: box?.rightInsetPx ?? 0,
|
|
18759
|
-
gapBeforePx: gap
|
|
18809
|
+
gapBeforePx: gap,
|
|
18810
|
+
...box?.hole ? { hole: box.hole } : {}
|
|
18760
18811
|
};
|
|
18761
18812
|
}
|
|
18762
18813
|
return expectDefined(boxes[lineIndex], "line box");
|
|
@@ -18803,7 +18854,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18803
18854
|
while (rendered.length && rendered.at(-1).token.kind === "space") rendered.pop();
|
|
18804
18855
|
const fragments = buildFragments(rendered, paragraph);
|
|
18805
18856
|
const [firstPlaced] = placed2;
|
|
18806
|
-
const start = firstPlaced ? globalOffset(firstPlaced.token) : 0;
|
|
18857
|
+
const start = lines.length === 0 && startToken === 0 ? 0 : firstPlaced ? globalOffset(firstPlaced.token) : 0;
|
|
18807
18858
|
const last = placed2.at(-1)?.token;
|
|
18808
18859
|
const end = last ? globalOffset(last, last.kind === "word" || last.kind === "space" ? last.text.length : 1) : start;
|
|
18809
18860
|
const gapBeforePx = boxFor(lineIndex).gapBeforePx;
|
|
@@ -18819,6 +18870,9 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18819
18870
|
fragment.topPx = baselinePx - extent2.above;
|
|
18820
18871
|
if (token.kind !== "object") fragment.boxHeightPx = extent2.ascent + extent2.descent;
|
|
18821
18872
|
});
|
|
18873
|
+
if (jump) {
|
|
18874
|
+
for (const fragment of fragments.slice(jump.index)) fragment.xPx += jump.shiftPx;
|
|
18875
|
+
}
|
|
18822
18876
|
lines.push({
|
|
18823
18877
|
yPx: 0,
|
|
18824
18878
|
heightPx,
|
|
@@ -18835,6 +18889,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18835
18889
|
if (forcedByBreak === "column") columnBreakAfterLine.add(lineIndex);
|
|
18836
18890
|
placed2 = [];
|
|
18837
18891
|
lineWidthPx = 0;
|
|
18892
|
+
lineSpacePx = 0;
|
|
18893
|
+
jump = void 0;
|
|
18838
18894
|
marginReachPx = 0;
|
|
18839
18895
|
}
|
|
18840
18896
|
for (const [tokenIndex, token] of tokens.entries()) {
|
|
@@ -18884,9 +18940,19 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18884
18940
|
leader = tab.leader === "none" ? void 0 : tab.leader;
|
|
18885
18941
|
}
|
|
18886
18942
|
const lineIndex = lines.length;
|
|
18887
|
-
const
|
|
18888
|
-
const
|
|
18889
|
-
|
|
18943
|
+
const hole = boxFor(lineIndex).hole;
|
|
18944
|
+
const beforeHole = hole && !jump ? hole.startPx - lineStart(lineIndex) : void 0;
|
|
18945
|
+
const limit = Math.max(
|
|
18946
|
+
beforeHole ?? availableWidth(lineIndex) - (jump?.shiftPx ?? 0),
|
|
18947
|
+
marginReachPx
|
|
18948
|
+
);
|
|
18949
|
+
const squeezePx = effectiveAlign === "justify" && token.kind === "word" ? lineSpacePx * SPACE_SHRINK : 0;
|
|
18950
|
+
const fits = lineWidthPx + (token.kind === "tab" ? width : advance) <= limit + squeezePx;
|
|
18951
|
+
const wouldFit = fits || placed2.every((placed3) => paragraph.runs[placed3.token.runIndex]?.synthetic);
|
|
18952
|
+
const pastHole = !fits && hole && !jump && token.kind === "word" ? hole.endPx - lineStart(lineIndex) - lineWidthPx : void 0;
|
|
18953
|
+
if (pastHole !== void 0 && lineWidthPx + pastHole + advance <= availableWidth(lineIndex)) {
|
|
18954
|
+
jump = { index: placed2.length, shiftPx: pastHole };
|
|
18955
|
+
} else if (!wouldFit && token.kind !== "space") {
|
|
18890
18956
|
tokenCursor = tokenIndex;
|
|
18891
18957
|
flushLine(false, void 0);
|
|
18892
18958
|
tokenCursor = tokenIndex + 1;
|
|
@@ -18906,6 +18972,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18906
18972
|
...markerFactor ? { xOffsetPx: -width * markerFactor, advancePx: advance } : {}
|
|
18907
18973
|
});
|
|
18908
18974
|
lineWidthPx += token.kind === "tab" ? width : advance;
|
|
18975
|
+
if (token.kind === "space") lineSpacePx += advance;
|
|
18909
18976
|
}
|
|
18910
18977
|
flushLine(lines.length === 0, void 0);
|
|
18911
18978
|
const lastIndex = lines.length - 1;
|
|
@@ -18916,7 +18983,8 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
|
|
|
18916
18983
|
line3.fragments,
|
|
18917
18984
|
availableWidth(index),
|
|
18918
18985
|
index === lastIndex,
|
|
18919
|
-
|
|
18986
|
+
// A line that runs around a picture is not aligned across it.
|
|
18987
|
+
boxes[index]?.hole ? "left" : effectiveAlign
|
|
18920
18988
|
).map((fragment) => ({ ...fragment, xPx: fragment.xPx + lineStart(index) }))
|
|
18921
18989
|
};
|
|
18922
18990
|
}
|
|
@@ -18968,29 +19036,50 @@ function widowControlEnabled(value) {
|
|
|
18968
19036
|
|
|
18969
19037
|
// docx/layout/nested-frame-profile.ts
|
|
18970
19038
|
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;
|
|
18971
|
-
function
|
|
19039
|
+
function mergedAway(table, rowIndex, column, side, merges) {
|
|
19040
|
+
if (!merges) return false;
|
|
19041
|
+
const row2 = table.rows[rowIndex];
|
|
19042
|
+
const cell = row2.cells[column];
|
|
19043
|
+
if (side === "top") return cell.verticalMerge === "continue";
|
|
19044
|
+
const below2 = table.rows[rowIndex + 1]?.cells.find(
|
|
19045
|
+
(other) => other.xPx === cell.xPx && other.widthPx === cell.widthPx
|
|
19046
|
+
);
|
|
19047
|
+
return below2?.verticalMerge === "continue";
|
|
19048
|
+
}
|
|
19049
|
+
function nestedFrameProfile(table, tableWidthPx = table.widthPx, merges = false) {
|
|
18972
19050
|
const sides = table.rows.flatMap(
|
|
18973
|
-
(row2) => row2.cells.flatMap(
|
|
18974
|
-
(cell) => ["top", "right", "bottom", "left"].
|
|
19051
|
+
(row2, rowIndex) => row2.cells.flatMap(
|
|
19052
|
+
(cell, column) => ["top", "right", "bottom", "left"].filter(
|
|
19053
|
+
(side) => side !== "top" && side !== "bottom" || !mergedAway(table, rowIndex, column, side, merges)
|
|
19054
|
+
).map((side) => cell.borders?.[side])
|
|
18975
19055
|
)
|
|
18976
19056
|
);
|
|
18977
19057
|
if (sides.every((side) => !side)) return { leftPx: 0, rightPx: 0, bottomPx: 0 };
|
|
18978
19058
|
if (!sides.every((side) => side?.style === "solid" && side.widthPx > 0)) return void 0;
|
|
19059
|
+
const gridKnown = merges && table.rows.every(
|
|
19060
|
+
(row2) => row2.cells.every((cell) => cell.xPx !== void 0 && cell.widthPx !== void 0)
|
|
19061
|
+
);
|
|
18979
19062
|
const first3 = table.rows[0], left = first3.cells[0].borders.left, right = first3.cells.at(-1).borders.right;
|
|
18980
19063
|
for (const [index, row2] of table.rows.entries()) {
|
|
18981
|
-
if (row2.cells.length !== first3.cells.length || !equal(row2.cells[0]?.borders?.left, left) || !equal(row2.cells.at(-1)?.borders?.right, right))
|
|
19064
|
+
if (!gridKnown && row2.cells.length !== first3.cells.length || !equal(row2.cells[0]?.borders?.left, left) || !equal(row2.cells.at(-1)?.borders?.right, right))
|
|
18982
19065
|
return void 0;
|
|
18983
19066
|
for (const [column, cell] of row2.cells.entries()) {
|
|
18984
19067
|
const sourceWidth = cell.widthPx ?? (tableWidthPx === void 0 ? void 0 : tableWidthPx / row2.cells.length);
|
|
18985
19068
|
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);
|
|
18986
19069
|
if (paintWidth !== void 0 && paintWidth <= 0) return void 0;
|
|
18987
|
-
|
|
19070
|
+
const topAway = mergedAway(table, index, column, "top", merges);
|
|
19071
|
+
const bottomAway = mergedAway(table, index, column, "bottom", merges);
|
|
19072
|
+
const reference = (side) => row2.cells.find((_, at) => !mergedAway(table, index, at, side, merges))?.borders?.[side];
|
|
19073
|
+
if (!topAway && !equal(cell.borders?.top, reference("top")) || !bottomAway && !equal(cell.borders?.bottom, reference("bottom")))
|
|
18988
19074
|
return void 0;
|
|
18989
19075
|
if (column && !equal(row2.cells[column - 1]?.borders?.right, cell.borders?.left))
|
|
18990
19076
|
return void 0;
|
|
18991
19077
|
if (index) {
|
|
18992
|
-
const
|
|
18993
|
-
|
|
19078
|
+
const above2 = table.rows[index - 1];
|
|
19079
|
+
const previous = gridKnown ? above2.cells.find(
|
|
19080
|
+
(other) => other.xPx <= cell.xPx + 1e-6 && cell.xPx < other.xPx + other.widthPx - 1e-6
|
|
19081
|
+
) : above2.cells[column];
|
|
19082
|
+
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))
|
|
18994
19083
|
return void 0;
|
|
18995
19084
|
}
|
|
18996
19085
|
}
|
|
@@ -19045,46 +19134,6 @@ function cellContentBottom(boxes, paddingBottom = 0) {
|
|
|
19045
19134
|
);
|
|
19046
19135
|
}
|
|
19047
19136
|
|
|
19048
|
-
// docx/layout/table-frames.ts
|
|
19049
|
-
function clipTableFrames(tables, start, end, inset = 0) {
|
|
19050
|
-
return tables.flatMap((table) => {
|
|
19051
|
-
const top = Math.max(start, table.yPx);
|
|
19052
|
-
const bottom = Math.min(end, table.yPx + table.heightPx);
|
|
19053
|
-
if (bottom <= top) return [];
|
|
19054
|
-
const rows2 = table.rows.flatMap((row2) => {
|
|
19055
|
-
const rowTop = table.yPx + row2.yPx;
|
|
19056
|
-
const a = Math.max(top, rowTop), b = Math.min(bottom, rowTop + row2.heightPx);
|
|
19057
|
-
if (b <= a) return [];
|
|
19058
|
-
return [
|
|
19059
|
-
{
|
|
19060
|
-
...row2,
|
|
19061
|
-
yPx: a - top,
|
|
19062
|
-
heightPx: b - a,
|
|
19063
|
-
...row2.cellTables ? {
|
|
19064
|
-
cellTables: row2.cellTables.map(
|
|
19065
|
-
(nested) => clipTableFrames(nested, a - rowTop, b - rowTop)
|
|
19066
|
-
)
|
|
19067
|
-
} : {}
|
|
19068
|
-
}
|
|
19069
|
-
];
|
|
19070
|
-
});
|
|
19071
|
-
if (table.fragmentEdges && rows2.length) {
|
|
19072
|
-
const edges = table.fragmentEdges;
|
|
19073
|
-
for (const [row2, side] of [
|
|
19074
|
-
[rows2[0], "top"],
|
|
19075
|
-
[rows2.at(-1), "bottom"]
|
|
19076
|
-
]) {
|
|
19077
|
-
if (row2.geometry)
|
|
19078
|
-
row2.geometry = row2.geometry.map((cell, index) => ({
|
|
19079
|
-
...cell,
|
|
19080
|
-
borders: { ...cell.borders, [side]: edges[side][index] }
|
|
19081
|
-
}));
|
|
19082
|
-
}
|
|
19083
|
-
}
|
|
19084
|
-
return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows: rows2 }];
|
|
19085
|
-
});
|
|
19086
|
-
}
|
|
19087
|
-
|
|
19088
19137
|
// docx/layout/table-cell-layout.ts
|
|
19089
19138
|
function cellParagraphs(cell) {
|
|
19090
19139
|
const walk = (blocks) => blocks.flatMap(
|
|
@@ -19192,92 +19241,47 @@ function stackCellBlocks(cell, width, measurer, note, top, starts, physicalFragm
|
|
|
19192
19241
|
return { heightPx: y, boxes, tables };
|
|
19193
19242
|
}
|
|
19194
19243
|
|
|
19195
|
-
// docx/layout/table-
|
|
19196
|
-
function
|
|
19197
|
-
|
|
19198
|
-
|
|
19199
|
-
|
|
19200
|
-
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19211
|
-
|
|
19212
|
-
|
|
19213
|
-
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
|
|
19217
|
-
...layout.frame ? { frame: layout.frame } : {}
|
|
19218
|
-
});
|
|
19219
|
-
y += layout.contentHeightPx + layout.spacingAfterPx;
|
|
19220
|
-
}
|
|
19221
|
-
return { heightPx: y, boxes };
|
|
19222
|
-
}
|
|
19223
|
-
function layoutRow(row2, tableWidthPx, measurer, note, remaining, startTokens, frameBorders = false, frameLeftBorderPx, physicalFragments = reflowNestedFragments(row2)) {
|
|
19224
|
-
const count = row2.cells.length || 1;
|
|
19225
|
-
let x = 0;
|
|
19226
|
-
const geometry = [];
|
|
19227
|
-
const laidOut = row2.cells.map((cell) => {
|
|
19228
|
-
const continuation = remaining?.[geometry.length];
|
|
19229
|
-
const starts = continuation ? new Map(continuation.map((box) => [box.blockId, box.lines[0]?.firstToken ?? 0])) : startTokens;
|
|
19230
|
-
const widthPx = cell.widthPx ?? tableWidthPx / count;
|
|
19231
|
-
const margins = cell.padding ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
19232
|
-
const leftBorder = frameBorders ? cell.borders?.left?.widthPx ?? 0 : 0;
|
|
19233
|
-
const rightBorder = frameBorders ? cell.borders?.right?.widthPx ?? 0 : 0;
|
|
19234
|
-
const padding = frameBorders ? {
|
|
19235
|
-
top: margins.top + (cell.borders?.top?.widthPx ?? 0),
|
|
19236
|
-
bottom: margins.bottom,
|
|
19237
|
-
left: leftBorder / 2 + Math.max(margins.left, leftBorder / 2),
|
|
19238
|
-
right: Math.max(margins.right, rightBorder / 2) - rightBorder / 2
|
|
19239
|
-
} : margins;
|
|
19240
|
-
const externalRight = frameBorders && geometry.length === row2.cells.length - 1 ? rightBorder : 0;
|
|
19241
|
-
const paintWidth = widthPx + (frameBorders ? (leftBorder - rightBorder) / 2 + externalRight : 0);
|
|
19242
|
-
const frameX = frameBorders ? ((frameLeftBorderPx ?? leftBorder) - leftBorder) / 2 : 0;
|
|
19243
|
-
const content2 = stackCellBlocks(
|
|
19244
|
-
cell,
|
|
19245
|
-
Math.max(1, paintWidth - padding.left - padding.right - externalRight),
|
|
19246
|
-
measurer,
|
|
19247
|
-
note,
|
|
19248
|
-
padding.top,
|
|
19249
|
-
starts,
|
|
19250
|
-
physicalFragments
|
|
19251
|
-
);
|
|
19252
|
-
const heightPx2 = content2.heightPx + padding.bottom;
|
|
19253
|
-
geometry.push({
|
|
19254
|
-
xPx: (cell.xPx ?? x) + frameX,
|
|
19255
|
-
widthPx: paintWidth,
|
|
19256
|
-
...frameBorders ? { borderInsetsReserved: true } : {},
|
|
19257
|
-
paddingLeftPx: padding.left,
|
|
19258
|
-
paddingRightPx: padding.right + externalRight,
|
|
19259
|
-
contentHeightPx: heightPx2,
|
|
19260
|
-
...cell.borders ? { borders: cell.borders } : {},
|
|
19261
|
-
...cell.shading ? { shading: cell.shading } : {},
|
|
19262
|
-
...cell.verticalAlign ? { verticalAlign: cell.verticalAlign } : {}
|
|
19244
|
+
// docx/layout/table-frames.ts
|
|
19245
|
+
function clipTableFrames(tables, start, end, inset = 0) {
|
|
19246
|
+
return tables.flatMap((table) => {
|
|
19247
|
+
const top = Math.max(start, table.yPx);
|
|
19248
|
+
const bottom = Math.min(end, table.yPx + table.heightPx);
|
|
19249
|
+
if (bottom <= top) return [];
|
|
19250
|
+
const rows2 = table.rows.flatMap((row2) => {
|
|
19251
|
+
const rowTop = table.yPx + row2.yPx;
|
|
19252
|
+
const a = Math.max(top, rowTop), b = Math.min(bottom, rowTop + row2.heightPx);
|
|
19253
|
+
if (b <= a) return [];
|
|
19254
|
+
return [
|
|
19255
|
+
{
|
|
19256
|
+
...row2,
|
|
19257
|
+
yPx: a - top,
|
|
19258
|
+
heightPx: b - a,
|
|
19259
|
+
...row2.cellTables ? {
|
|
19260
|
+
cellTables: row2.cellTables.map(
|
|
19261
|
+
(nested) => clipTableFrames(nested, a - rowTop, b - rowTop)
|
|
19262
|
+
)
|
|
19263
|
+
} : {}
|
|
19264
|
+
}
|
|
19265
|
+
];
|
|
19263
19266
|
});
|
|
19264
|
-
|
|
19265
|
-
|
|
19267
|
+
if (table.fragmentEdges && rows2.length) {
|
|
19268
|
+
const edges = table.fragmentEdges;
|
|
19269
|
+
for (const [row2, side] of [
|
|
19270
|
+
[rows2[0], "top"],
|
|
19271
|
+
[rows2.at(-1), "bottom"]
|
|
19272
|
+
]) {
|
|
19273
|
+
if (row2.geometry)
|
|
19274
|
+
row2.geometry = row2.geometry.map((cell, index) => ({
|
|
19275
|
+
...cell,
|
|
19276
|
+
borders: { ...cell.borders, [side]: edges[side][index] }
|
|
19277
|
+
}));
|
|
19278
|
+
}
|
|
19279
|
+
}
|
|
19280
|
+
return [{ ...table, yPx: top - start + inset, heightPx: bottom - top, rows: rows2 }];
|
|
19266
19281
|
});
|
|
19267
|
-
const content = Math.max(0, ...laidOut.map((cell) => cell.heightPx));
|
|
19268
|
-
const heightPx = row2.heightPx === void 0 ? content : row2.heightRule === "exact" ? row2.heightPx : Math.max(content, row2.heightPx);
|
|
19269
|
-
if (frameBorders) for (const cell of geometry) cell.alignmentHeightPx = heightPx;
|
|
19270
|
-
return {
|
|
19271
|
-
heightPx,
|
|
19272
|
-
cells: laidOut.map((cell) => cell.boxes),
|
|
19273
|
-
geometry,
|
|
19274
|
-
...laidOut.some((cell) => cell.tables.length) ? { cellTables: laidOut.map((cell) => cell.tables) } : {},
|
|
19275
|
-
cellPadding: row2.cells.map((cell) => ({
|
|
19276
|
-
top: cell.padding?.top ?? 0,
|
|
19277
|
-
bottom: cell.padding?.bottom ?? 0
|
|
19278
|
-
}))
|
|
19279
|
-
};
|
|
19280
19282
|
}
|
|
19283
|
+
|
|
19284
|
+
// docx/layout/table-row-split.ts
|
|
19281
19285
|
function splitCellAtHeight(boxes, cutHeightPx, paragraphCuts) {
|
|
19282
19286
|
const before = [];
|
|
19283
19287
|
const after = [];
|
|
@@ -19351,7 +19355,7 @@ function splitRowAtHeight(row2, cutHeightPx, cellCuts, paragraphCuts) {
|
|
|
19351
19355
|
)
|
|
19352
19356
|
)
|
|
19353
19357
|
} : {},
|
|
19354
|
-
geometry: row2.geometry.map((geometry, index) => ({
|
|
19358
|
+
geometry: row2.geometry.map(({ mergeRows: _merge, ...geometry }, index) => ({
|
|
19355
19359
|
...geometry,
|
|
19356
19360
|
contentHeightPx: splits[index].beforeHeightPx,
|
|
19357
19361
|
...row2.borderBottomPx !== void 0 ? { alignmentHeightPx: beforeHeightPx } : {}
|
|
@@ -19360,10 +19364,11 @@ function splitRowAtHeight(row2, cutHeightPx, cellCuts, paragraphCuts) {
|
|
|
19360
19364
|
...row2.borderBottomPx !== void 0 ? { borderBottomPx: row2.borderBottomPx } : {}
|
|
19361
19365
|
};
|
|
19362
19366
|
if (!anyAfter) return { before, after: null };
|
|
19367
|
+
const tail = (split, index) => split.after.length ? row2.trailingPx?.[index] ?? 0 : 0;
|
|
19363
19368
|
const afterHeightPx = Math.max(
|
|
19364
19369
|
0,
|
|
19365
19370
|
...splits.map(
|
|
19366
|
-
(split, index) => cellContentBottom(split.after, row2.cellPadding?.[index]?.bottom ?? 0)
|
|
19371
|
+
(split, index) => cellContentBottom(split.after, row2.cellPadding?.[index]?.bottom ?? 0) + tail(split, index)
|
|
19367
19372
|
)
|
|
19368
19373
|
);
|
|
19369
19374
|
const after = {
|
|
@@ -19379,20 +19384,114 @@ function splitRowAtHeight(row2, cutHeightPx, cellCuts, paragraphCuts) {
|
|
|
19379
19384
|
) : []
|
|
19380
19385
|
)
|
|
19381
19386
|
} : {},
|
|
19382
|
-
geometry: row2.geometry.map((geometry, index) => ({
|
|
19387
|
+
geometry: row2.geometry.map(({ mergeRows: _merge, ...geometry }, index) => ({
|
|
19383
19388
|
...geometry,
|
|
19384
|
-
contentHeightPx: cellContentBottom(
|
|
19385
|
-
splits[index].after,
|
|
19386
|
-
row2.cellPadding?.[index]?.bottom ?? 0
|
|
19387
|
-
),
|
|
19389
|
+
contentHeightPx: cellContentBottom(splits[index].after, row2.cellPadding?.[index]?.bottom ?? 0) + tail(splits[index], index),
|
|
19388
19390
|
...row2.borderBottomPx !== void 0 ? { alignmentHeightPx: afterHeightPx } : {}
|
|
19389
19391
|
})),
|
|
19390
19392
|
...row2.cellPadding ? { cellPadding: row2.cellPadding } : {},
|
|
19393
|
+
...row2.trailingPx ? { trailingPx: row2.trailingPx } : {},
|
|
19391
19394
|
...row2.borderBottomPx !== void 0 ? { borderBottomPx: row2.borderBottomPx } : {}
|
|
19392
19395
|
};
|
|
19393
19396
|
return { before, after };
|
|
19394
19397
|
}
|
|
19395
19398
|
|
|
19399
|
+
// docx/layout/table-layout.ts
|
|
19400
|
+
function stackParagraphs(paragraphs, widthPx, measurer, note, topPx = 0, startTokens) {
|
|
19401
|
+
let y = topPx;
|
|
19402
|
+
const boxes = [];
|
|
19403
|
+
for (const paragraph of paragraphs) {
|
|
19404
|
+
const layout = layoutParagraph(
|
|
19405
|
+
paragraph,
|
|
19406
|
+
widthPx,
|
|
19407
|
+
measurer,
|
|
19408
|
+
note,
|
|
19409
|
+
void 0,
|
|
19410
|
+
startTokens?.get(paragraph.id) ?? 0
|
|
19411
|
+
);
|
|
19412
|
+
y += layout.spacingBeforePx;
|
|
19413
|
+
const top = y;
|
|
19414
|
+
const lines = layout.lines.map((line3) => ({ ...line3 }));
|
|
19415
|
+
boxes.push({
|
|
19416
|
+
kind: "paragraph",
|
|
19417
|
+
blockId: paragraph.id,
|
|
19418
|
+
yPx: top,
|
|
19419
|
+
heightPx: layout.contentHeightPx,
|
|
19420
|
+
lines,
|
|
19421
|
+
...layout.frame ? { frame: layout.frame } : {}
|
|
19422
|
+
});
|
|
19423
|
+
y += layout.contentHeightPx + layout.spacingAfterPx;
|
|
19424
|
+
}
|
|
19425
|
+
return { heightPx: y, boxes };
|
|
19426
|
+
}
|
|
19427
|
+
function layoutRow(row2, tableWidthPx, measurer, note, remaining, startTokens, frameBorders = false, frameLeftBorderPx, physicalFragments = reflowNestedFragments(row2)) {
|
|
19428
|
+
const count = row2.cells.length || 1;
|
|
19429
|
+
let x = 0;
|
|
19430
|
+
const geometry = [];
|
|
19431
|
+
const laidOut = row2.cells.map((cell) => {
|
|
19432
|
+
const continuation = remaining?.[geometry.length];
|
|
19433
|
+
const starts = continuation ? new Map(continuation.map((box) => [box.blockId, box.lines[0]?.firstToken ?? 0])) : startTokens;
|
|
19434
|
+
const widthPx = cell.widthPx ?? tableWidthPx / count;
|
|
19435
|
+
const margins = cell.padding ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
19436
|
+
const leftBorder = frameBorders ? cell.borders?.left?.widthPx ?? 0 : 0;
|
|
19437
|
+
const rightBorder = frameBorders ? cell.borders?.right?.widthPx ?? 0 : 0;
|
|
19438
|
+
const padding = frameBorders ? {
|
|
19439
|
+
top: margins.top + (cell.borders?.top?.widthPx ?? 0),
|
|
19440
|
+
bottom: margins.bottom,
|
|
19441
|
+
left: leftBorder / 2 + Math.max(margins.left, leftBorder / 2),
|
|
19442
|
+
right: Math.max(margins.right, rightBorder / 2) - rightBorder / 2
|
|
19443
|
+
} : margins;
|
|
19444
|
+
const externalRight = frameBorders && geometry.length === row2.cells.length - 1 ? rightBorder : 0;
|
|
19445
|
+
const paintWidth = widthPx + (frameBorders ? (leftBorder - rightBorder) / 2 + externalRight : 0);
|
|
19446
|
+
const frameX = frameBorders ? ((frameLeftBorderPx ?? leftBorder) - leftBorder) / 2 : 0;
|
|
19447
|
+
const content2 = stackCellBlocks(
|
|
19448
|
+
cell,
|
|
19449
|
+
Math.max(1, paintWidth - padding.left - padding.right - externalRight),
|
|
19450
|
+
measurer,
|
|
19451
|
+
note,
|
|
19452
|
+
padding.top,
|
|
19453
|
+
starts,
|
|
19454
|
+
physicalFragments
|
|
19455
|
+
);
|
|
19456
|
+
const heightPx2 = content2.heightPx + padding.bottom;
|
|
19457
|
+
geometry.push({
|
|
19458
|
+
xPx: (cell.xPx ?? x) + frameX,
|
|
19459
|
+
widthPx: paintWidth,
|
|
19460
|
+
...frameBorders ? { borderInsetsReserved: true } : {},
|
|
19461
|
+
paddingLeftPx: padding.left,
|
|
19462
|
+
paddingRightPx: padding.right + externalRight,
|
|
19463
|
+
contentHeightPx: heightPx2,
|
|
19464
|
+
...cell.borders ? { borders: cell.borders } : {},
|
|
19465
|
+
...cell.shading ? { shading: cell.shading } : {},
|
|
19466
|
+
...cell.verticalAlign ? { verticalAlign: cell.verticalAlign } : {},
|
|
19467
|
+
...cell.rowSpan ? { mergeRows: cell.rowSpan } : {}
|
|
19468
|
+
});
|
|
19469
|
+
x = (cell.xPx ?? x) + widthPx;
|
|
19470
|
+
const trailingPx = content2.tables?.length ? 0 : Math.max(0, content2.heightPx - cellContentBottom(content2.boxes));
|
|
19471
|
+
return { heightPx: heightPx2, boxes: content2.boxes, tables: content2.tables ?? [], trailingPx };
|
|
19472
|
+
});
|
|
19473
|
+
const content = Math.max(
|
|
19474
|
+
0,
|
|
19475
|
+
...laidOut.map(
|
|
19476
|
+
(cell, index) => (row2.cells[index]?.rowSpan ?? 1) > 1 && !row2.mergedTextInRow ? 0 : cell.heightPx
|
|
19477
|
+
)
|
|
19478
|
+
);
|
|
19479
|
+
const heightPx = row2.heightPx === void 0 ? content : row2.heightRule === "exact" ? row2.heightPx : Math.max(content, row2.heightPx);
|
|
19480
|
+
if (frameBorders) for (const cell of geometry) cell.alignmentHeightPx = heightPx;
|
|
19481
|
+
const trailing = laidOut.map((cell) => cell.trailingPx);
|
|
19482
|
+
return {
|
|
19483
|
+
heightPx,
|
|
19484
|
+
cells: laidOut.map((cell) => cell.boxes),
|
|
19485
|
+
geometry,
|
|
19486
|
+
...trailing.some((px) => px > 0) ? { trailingPx: trailing } : {},
|
|
19487
|
+
...laidOut.some((cell) => cell.tables.length) ? { cellTables: laidOut.map((cell) => cell.tables) } : {},
|
|
19488
|
+
cellPadding: row2.cells.map((cell) => ({
|
|
19489
|
+
top: cell.padding?.top ?? 0,
|
|
19490
|
+
bottom: cell.padding?.bottom ?? 0
|
|
19491
|
+
}))
|
|
19492
|
+
};
|
|
19493
|
+
}
|
|
19494
|
+
|
|
19396
19495
|
// docx/layout/footnote-split.ts
|
|
19397
19496
|
function splitNote(note, budget) {
|
|
19398
19497
|
if (note.heightPx <= budget + 1e-6) return { before: note };
|
|
@@ -19846,6 +19945,14 @@ var PageCursor = class {
|
|
|
19846
19945
|
get usedColumnHeightPx() {
|
|
19847
19946
|
return this.yPx - this.columnTopPx;
|
|
19848
19947
|
}
|
|
19948
|
+
/**
|
|
19949
|
+
* At the top of a later page or a later column of the section (not the section's first page, nor
|
|
19950
|
+
* a continuous band). Word drops the space before of the paragraph placed here, whether a page
|
|
19951
|
+
* break, a natural overflow, `pageBreakBefore` or a column overflow brought it (spacing-probe.json).
|
|
19952
|
+
*/
|
|
19953
|
+
get atContinuationTop() {
|
|
19954
|
+
return this.atColumnTop && this.columnTopPx === 0 && (this.page.pageInSection > 0 || this.columnIndex > 0);
|
|
19955
|
+
}
|
|
19849
19956
|
get atColumnTop() {
|
|
19850
19957
|
return this.yPx === this.columnTopPx;
|
|
19851
19958
|
}
|
|
@@ -19936,13 +20043,16 @@ var PageCursor = class {
|
|
|
19936
20043
|
this.pushPage();
|
|
19937
20044
|
}
|
|
19938
20045
|
}
|
|
19939
|
-
/**
|
|
19940
|
-
|
|
20046
|
+
/**
|
|
20047
|
+
* Places a box at the current fill position (sets its `yPx`) and advances by `advancePx`. The box
|
|
20048
|
+
* sits `offsetPx` below the fill position when the advance starts with space above it.
|
|
20049
|
+
*/
|
|
20050
|
+
place(box, advancePx, offsetPx = 0) {
|
|
19941
20051
|
if (this.page.sectionIndex !== this.sectionIndex && !this.page.sectionIndices?.includes(this.sectionIndex)) {
|
|
19942
20052
|
(this.page.sectionIndices ??= [this.page.sectionIndex]).push(this.sectionIndex);
|
|
19943
20053
|
this.pageInSection = 1;
|
|
19944
20054
|
}
|
|
19945
|
-
box.yPx = this.yPx;
|
|
20055
|
+
box.yPx = this.yPx + offsetPx;
|
|
19946
20056
|
this.column.blocks.push(box);
|
|
19947
20057
|
this.yPx += advancePx;
|
|
19948
20058
|
const bodyBottom = this.legacyFootnoteColumns ? this.yPx : Math.max(
|
|
@@ -19962,7 +20072,10 @@ var PageCursor = class {
|
|
|
19962
20072
|
|
|
19963
20073
|
// docx/layout/flow-paragraph.ts
|
|
19964
20074
|
function placeParagraph(cursor, placement, note) {
|
|
19965
|
-
const { paragraph,
|
|
20075
|
+
const { paragraph, requiredTogetherPx, reflow } = placement;
|
|
20076
|
+
const spacingAfterPx = placement.spacingAfterPx ?? placement.layout.spacingAfterPx;
|
|
20077
|
+
const dropsSpaceBefore = () => cursor.atContinuationTop && !(paragraph.pageBreakBefore && placement.keepSpaceBeforePageBreak);
|
|
20078
|
+
let spacingBeforePx = dropsSpaceBefore() ? 0 : placement.spacingBeforePx;
|
|
19966
20079
|
const trailingBreakLine = (result) => {
|
|
19967
20080
|
const last = result.lines.at(-1);
|
|
19968
20081
|
if (!placement.trimLeadingColumnBreak || !last || !result.columnBreakAfterLine.has(result.lines.length - 1))
|
|
@@ -19996,6 +20109,7 @@ function placeParagraph(cursor, placement, note) {
|
|
|
19996
20109
|
if (requiredTogetherPx > 0 && requiredTogetherPx <= cursor.columnHeightPx && requiredTogetherPx > cursor.remainingHeightPx() && !cursor.atColumnTop) {
|
|
19997
20110
|
cursor.newColumn();
|
|
19998
20111
|
}
|
|
20112
|
+
if (dropsSpaceBefore()) spacingBeforePx = 0;
|
|
19999
20113
|
const widow = widowControlEnabled(paragraph.widowControl);
|
|
20000
20114
|
let lineCursor = 0;
|
|
20001
20115
|
let nextToken = 0;
|
|
@@ -20024,7 +20138,8 @@ function placeParagraph(cursor, placement, note) {
|
|
|
20024
20138
|
if (!layout.lines.length) {
|
|
20025
20139
|
cursor.place(
|
|
20026
20140
|
{ kind: "paragraph", blockId: paragraph.id, yPx: 0, heightPx: 0, lines: [] },
|
|
20027
|
-
spacingBeforePx +
|
|
20141
|
+
spacingBeforePx + spacingAfterPx,
|
|
20142
|
+
spacingBeforePx
|
|
20028
20143
|
);
|
|
20029
20144
|
return;
|
|
20030
20145
|
}
|
|
@@ -20068,6 +20183,7 @@ function placeParagraph(cursor, placement, note) {
|
|
|
20068
20183
|
if (placedCount === 0) {
|
|
20069
20184
|
if (!cursor.atColumnTop) {
|
|
20070
20185
|
cursor.newColumn();
|
|
20186
|
+
if (firstSegment && dropsSpaceBefore()) spacingBeforePx = 0;
|
|
20071
20187
|
continue;
|
|
20072
20188
|
}
|
|
20073
20189
|
note(
|
|
@@ -20098,8 +20214,8 @@ function placeParagraph(cursor, placement, note) {
|
|
|
20098
20214
|
lines: segmentLines,
|
|
20099
20215
|
...layout.frame ? { frame: layout.frame } : {}
|
|
20100
20216
|
};
|
|
20101
|
-
const advance = (firstSegment ? spacingBeforePx : 0) + segmentHeight + (isFinal ?
|
|
20102
|
-
cursor.place(box, advance);
|
|
20217
|
+
const advance = (firstSegment ? spacingBeforePx : 0) + segmentHeight + (isFinal ? spacingAfterPx : 0);
|
|
20218
|
+
cursor.place(box, advance, firstSegment ? spacingBeforePx : 0);
|
|
20103
20219
|
for (const item of committedNotes) placedNotes.add(item.id);
|
|
20104
20220
|
nextToken = layout.lines[lineCursor + placedCount - 1]?.nextToken ?? nextToken;
|
|
20105
20221
|
lineCursor += placedCount;
|
|
@@ -20505,6 +20621,61 @@ var TableFootnotes = class {
|
|
|
20505
20621
|
}
|
|
20506
20622
|
};
|
|
20507
20623
|
|
|
20624
|
+
// docx/layout/table-merged-rows.ts
|
|
20625
|
+
var MergedRowPlan = class {
|
|
20626
|
+
constructor(rows2) {
|
|
20627
|
+
this.rows = rows2;
|
|
20628
|
+
}
|
|
20629
|
+
rows;
|
|
20630
|
+
legacy = /* @__PURE__ */ new Set();
|
|
20631
|
+
minimum = /* @__PURE__ */ new Map();
|
|
20632
|
+
cache = /* @__PURE__ */ new Map();
|
|
20633
|
+
apply(source) {
|
|
20634
|
+
const minimum = this.minimum.get(source);
|
|
20635
|
+
if (minimum === void 0 && !this.legacy.has(source)) return source;
|
|
20636
|
+
return {
|
|
20637
|
+
...source,
|
|
20638
|
+
...minimum === void 0 ? {} : { heightPx: minimum, heightRule: "atLeast" },
|
|
20639
|
+
...this.legacy.has(source) ? { mergedTextInRow: true } : {}
|
|
20640
|
+
};
|
|
20641
|
+
}
|
|
20642
|
+
/** The row to lay out and place (the source row itself when the plan leaves it alone). */
|
|
20643
|
+
effective(source) {
|
|
20644
|
+
let row2 = this.cache.get(source);
|
|
20645
|
+
if (!row2) {
|
|
20646
|
+
row2 = this.apply(source);
|
|
20647
|
+
this.cache.set(source, row2);
|
|
20648
|
+
}
|
|
20649
|
+
return row2;
|
|
20650
|
+
}
|
|
20651
|
+
/** Plans the rows a merge starting at `index` covers, given the room left for them. */
|
|
20652
|
+
plan(index, layout, availablePx) {
|
|
20653
|
+
const start = this.rows[index];
|
|
20654
|
+
const spans = start?.cells.map((cell) => cell.rowSpan ?? 1) ?? [];
|
|
20655
|
+
const longest = Math.max(1, ...spans);
|
|
20656
|
+
if (!start || longest < 2) return;
|
|
20657
|
+
const covered = this.rows.slice(index, index + longest);
|
|
20658
|
+
const natural = covered.map((row2) => layout(this.apply(row2)));
|
|
20659
|
+
const heights = natural.map((item) => item.heightPx);
|
|
20660
|
+
spans.forEach((span, cell) => {
|
|
20661
|
+
if (span < 2) return;
|
|
20662
|
+
const count = Math.min(span, covered.length);
|
|
20663
|
+
const need = (natural[0]?.geometry[cell]?.contentHeightPx ?? 0) + (natural[count - 1]?.borderBottomPx ?? 0);
|
|
20664
|
+
const have = heights.slice(0, count).reduce((sum, h) => sum + h, 0);
|
|
20665
|
+
if (need > have) heights[count - 1] = (heights[count - 1] ?? 0) + need - have;
|
|
20666
|
+
});
|
|
20667
|
+
if (heights.reduce((sum, h) => sum + h, 0) > availablePx) {
|
|
20668
|
+
this.legacy.add(start);
|
|
20669
|
+
return;
|
|
20670
|
+
}
|
|
20671
|
+
covered.forEach((row2, at) => {
|
|
20672
|
+
const grown = heights[at] - natural[at].heightPx;
|
|
20673
|
+
if (grown > 1e-6 && row2.heightRule !== "exact")
|
|
20674
|
+
this.minimum.set(row2, heights[at] - (natural[at].borderBottomPx ?? 0));
|
|
20675
|
+
});
|
|
20676
|
+
}
|
|
20677
|
+
};
|
|
20678
|
+
|
|
20508
20679
|
// docx/layout/flow-table.ts
|
|
20509
20680
|
function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
20510
20681
|
const firstBodyRow = table.rows.findIndex((row2) => !row2.isHeader);
|
|
@@ -20519,7 +20690,7 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20519
20690
|
const width = (table.widthPx ?? cursor.columnWidthPx) + (activeBorders ? (profile.leftPx + profile.rightPx) / 2 : 0);
|
|
20520
20691
|
return table.alignment === "center" ? Math.max(0, (cursor.columnWidthPx - width) / 2) : table.alignment === "right" ? Math.max(0, cursor.columnWidthPx - width) : table.indentPx ?? 0;
|
|
20521
20692
|
};
|
|
20522
|
-
const profile = nestedFrameProfile(table, table.widthPx ?? cursor.columnWidthPx);
|
|
20693
|
+
const profile = nestedFrameProfile(table, table.widthPx ?? cursor.columnWidthPx, true);
|
|
20523
20694
|
const activeBorders = profile !== void 0 && (profile.leftPx > 0 || profile.rightPx > 0 || profile.bottomPx > 0);
|
|
20524
20695
|
if (!profile && table.rows.some((row2) => row2.cells.some((cell) => cell.borders)))
|
|
20525
20696
|
note(
|
|
@@ -20555,6 +20726,7 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20555
20726
|
};
|
|
20556
20727
|
function flushFragment() {
|
|
20557
20728
|
fragmentHeight += fragmentBorders.restore(fragmentRows.at(-1));
|
|
20729
|
+
alignMergedCells(fragmentRows);
|
|
20558
20730
|
if (!fragmentRows.length) {
|
|
20559
20731
|
footnotes?.holdFragment();
|
|
20560
20732
|
return;
|
|
@@ -20731,7 +20903,16 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20731
20903
|
) : after;
|
|
20732
20904
|
}
|
|
20733
20905
|
}
|
|
20734
|
-
|
|
20906
|
+
const merged = new MergedRowPlan(table.rows);
|
|
20907
|
+
for (const [index, source] of table.rows.entries()) {
|
|
20908
|
+
merged.plan(
|
|
20909
|
+
index,
|
|
20910
|
+
(candidate) => layoutRow2(candidate, cursor.columnWidthPx, measurer, () => {
|
|
20911
|
+
}, void 0, source),
|
|
20912
|
+
cursor.remainingHeightPx() - fragmentHeight
|
|
20913
|
+
);
|
|
20914
|
+
const row2 = merged.effective(source);
|
|
20915
|
+
if (row2 !== source) nativeFragments.set(row2, nativeFragments.get(source) ?? false);
|
|
20735
20916
|
const layout = layoutRow2(row2, cursor.columnWidthPx, measurer, note);
|
|
20736
20917
|
if (layout.heightPx > cursor.remainingHeightPx() && !nativeFragments.get(row2) && row2.cells.some(
|
|
20737
20918
|
(cell) => cell.blocks?.some((block) => block.kind === "table" && block.rows.length > 1)
|
|
@@ -20748,11 +20929,23 @@ function placeTable(cursor, table, measurer, note, resolveFootnotes) {
|
|
|
20748
20929
|
placeRow(
|
|
20749
20930
|
row2,
|
|
20750
20931
|
layout,
|
|
20751
|
-
Boolean(row2.cantSplit) || headerRows.includes(
|
|
20932
|
+
Boolean(row2.cantSplit) || headerRows.includes(source) || !!footnotes && row2.heightRule === "exact"
|
|
20752
20933
|
);
|
|
20753
20934
|
}
|
|
20754
20935
|
flushFragment();
|
|
20755
20936
|
}
|
|
20937
|
+
function alignMergedCells(rows2) {
|
|
20938
|
+
rows2.forEach((row2, index) => {
|
|
20939
|
+
for (const geometry of row2.geometry ?? []) {
|
|
20940
|
+
const count = geometry.mergeRows ?? 1;
|
|
20941
|
+
if (count < 2 || !geometry.verticalAlign || geometry.verticalAlign === "top") continue;
|
|
20942
|
+
const last = rows2[index + count - 1];
|
|
20943
|
+
if (!last || rows2.slice(index, index + count).some((item) => item.repeated !== row2.repeated))
|
|
20944
|
+
continue;
|
|
20945
|
+
geometry.alignmentHeightPx = last.yPx + last.heightPx - row2.yPx;
|
|
20946
|
+
}
|
|
20947
|
+
});
|
|
20948
|
+
}
|
|
20756
20949
|
|
|
20757
20950
|
// docx/layout/reference-footnotes.ts
|
|
20758
20951
|
function createReferenceFootnotes(width, measurer, report) {
|
|
@@ -20787,7 +20980,8 @@ function wrapExclusions(pages) {
|
|
|
20787
20980
|
yPx: float.yPx,
|
|
20788
20981
|
widthPx: float.widthPx + SIDE_DISTANCE_PX * 2,
|
|
20789
20982
|
heightPx: float.heightPx,
|
|
20790
|
-
topAndBottom: float.wrap === "topAndBottom"
|
|
20983
|
+
topAndBottom: float.wrap === "topAndBottom",
|
|
20984
|
+
...float.wrapText === "bothSides" ? { bothSides: true } : {}
|
|
20791
20985
|
}));
|
|
20792
20986
|
if (list.length) exclusions.set(page.index, list);
|
|
20793
20987
|
}
|
|
@@ -20808,6 +21002,7 @@ function lineBoxesFor(exclusions, topPx, columnLeftPx, columnWidthPx) {
|
|
|
20808
21002
|
let leftInsetPx = 0;
|
|
20809
21003
|
let rightInsetPx = 0;
|
|
20810
21004
|
let gapBeforePx = 0;
|
|
21005
|
+
const shared = [];
|
|
20811
21006
|
for (const exclusion of exclusions) {
|
|
20812
21007
|
const overlapsLine = exclusion.yPx < top + heightPx && exclusion.yPx + exclusion.heightPx > top;
|
|
20813
21008
|
const start = exclusion.xPx - columnLeftPx;
|
|
@@ -20819,10 +21014,26 @@ function lineBoxesFor(exclusions, topPx, columnLeftPx, columnWidthPx) {
|
|
|
20819
21014
|
gapBeforePx = Math.max(gapBeforePx, exclusion.yPx + exclusion.heightPx - top);
|
|
20820
21015
|
continue;
|
|
20821
21016
|
}
|
|
21017
|
+
if (exclusion.bothSides && Math.min(left, right) >= MIN_SIDE_WIDTH_PX) {
|
|
21018
|
+
shared.push({ start, end });
|
|
21019
|
+
continue;
|
|
21020
|
+
}
|
|
20822
21021
|
if (left >= right) rightInsetPx = Math.max(rightInsetPx, columnWidthPx - start);
|
|
20823
21022
|
else leftInsetPx = Math.max(leftInsetPx, end);
|
|
20824
21023
|
}
|
|
20825
|
-
|
|
21024
|
+
const single = shared.length === 1 && !leftInsetPx && !rightInsetPx ? shared[0] : void 0;
|
|
21025
|
+
if (!single)
|
|
21026
|
+
for (const { start, end } of shared) {
|
|
21027
|
+
if (start >= columnWidthPx - end)
|
|
21028
|
+
rightInsetPx = Math.max(rightInsetPx, columnWidthPx - start);
|
|
21029
|
+
else leftInsetPx = Math.max(leftInsetPx, end);
|
|
21030
|
+
}
|
|
21031
|
+
return {
|
|
21032
|
+
leftInsetPx,
|
|
21033
|
+
rightInsetPx,
|
|
21034
|
+
gapBeforePx,
|
|
21035
|
+
...single ? { hole: { startPx: single.start, endPx: single.end } } : {}
|
|
21036
|
+
};
|
|
20826
21037
|
};
|
|
20827
21038
|
}
|
|
20828
21039
|
|
|
@@ -20984,8 +21195,18 @@ var SectionFlow = class {
|
|
|
20984
21195
|
if (block?.kind !== "paragraph") return 0;
|
|
20985
21196
|
const layout = this.paragraphLayout(index);
|
|
20986
21197
|
const previous = index > 0 ? this.blocks[index - 1] : void 0;
|
|
20987
|
-
if (
|
|
20988
|
-
|
|
21198
|
+
if (index === 0 && !this.section.addParagraphSpacing)
|
|
21199
|
+
return Math.max(0, layout.spacingBeforePx - (this.section.leadingSpacingAfterPx ?? 0));
|
|
21200
|
+
if (previous?.kind !== "paragraph") return layout.spacingBeforePx;
|
|
21201
|
+
if (suppressesSpacing(previous, block)) return 0;
|
|
21202
|
+
if (this.section.addParagraphSpacing) return layout.spacingBeforePx;
|
|
21203
|
+
return Math.max(0, layout.spacingBeforePx - this.paragraphLayout(index - 1).spacingAfterPx);
|
|
21204
|
+
}
|
|
21205
|
+
/** Contextual spacing: no space after a paragraph that is followed by one of its own style. */
|
|
21206
|
+
spacingAfterSuppressed(index) {
|
|
21207
|
+
const block = this.blocks[index];
|
|
21208
|
+
const next = this.blocks[index + 1];
|
|
21209
|
+
return block?.kind === "paragraph" && next?.kind === "paragraph" && suppressesSpacing(block, next);
|
|
20989
21210
|
}
|
|
20990
21211
|
/** Minimum height that must fit before `index` may start, walking a `keepNext` chain. */
|
|
20991
21212
|
requiredKeepHeight(index, depth = 0) {
|
|
@@ -21057,6 +21278,8 @@ var SectionFlow = class {
|
|
|
21057
21278
|
layout,
|
|
21058
21279
|
footnotes,
|
|
21059
21280
|
spacingBeforePx,
|
|
21281
|
+
...this.section.keepSpaceBeforePageBreak ? { keepSpaceBeforePageBreak: true } : {},
|
|
21282
|
+
...this.spacingAfterSuppressed(index) ? { spacingAfterPx: 0 } : {},
|
|
21060
21283
|
...this.section.modernFootnoteSeparator || this.section.legacyFootnoteColumns ? { trimLeadingColumnBreak: true } : {},
|
|
21061
21284
|
requiredTogetherPx,
|
|
21062
21285
|
reflow: (token) => layoutParagraph(
|
|
@@ -21586,7 +21809,8 @@ function paragraphFloats(paragraph, theme) {
|
|
|
21586
21809
|
...placement?.alignV ? { alignV: placement.alignV } : {},
|
|
21587
21810
|
...placement?.offsetYPx !== void 0 ? { offsetYPx: placement.offsetYPx } : {},
|
|
21588
21811
|
...placement?.behindText ? { behindText: true } : {},
|
|
21589
|
-
...placement?.wrap ? { wrap: placement.wrap } : {}
|
|
21812
|
+
...placement?.wrap ? { wrap: placement.wrap } : {},
|
|
21813
|
+
...placement?.wrapText ? { wrapText: placement.wrapText } : {}
|
|
21590
21814
|
});
|
|
21591
21815
|
}
|
|
21592
21816
|
return floats;
|
|
@@ -22414,17 +22638,17 @@ function glyph(text2, size, stretch = 1) {
|
|
|
22414
22638
|
return box;
|
|
22415
22639
|
}
|
|
22416
22640
|
function scripts(base, sub, sup, style) {
|
|
22417
|
-
const raise = Math.max(style.size * 0.
|
|
22418
|
-
const drop = Math.max(style.size * 0.
|
|
22641
|
+
const raise = Math.max(style.size * 0.36, base.ascent - style.size * 0.42);
|
|
22642
|
+
const drop = Math.max(style.size * 0.15, base.descent - style.size * 0.07);
|
|
22419
22643
|
const parts = [{ box: base, x: 0, y: 0 }];
|
|
22420
22644
|
let width = base.width;
|
|
22421
22645
|
if (sup) {
|
|
22422
|
-
const y = -Math.max(raise, sup.descent + style.size * 0.
|
|
22646
|
+
const y = -Math.max(raise, sup.descent + style.size * 0.2);
|
|
22423
22647
|
parts.push({ box: sup, x: base.width + 1, y });
|
|
22424
22648
|
width = Math.max(width, base.width + 1 + sup.width);
|
|
22425
22649
|
}
|
|
22426
22650
|
if (sub) {
|
|
22427
|
-
const y = Math.max(drop, sub.ascent - style.size * 0.
|
|
22651
|
+
const y = Math.max(drop, sub.ascent - style.size * 0.4);
|
|
22428
22652
|
parts.push({ box: sub, x: base.width + 1, y });
|
|
22429
22653
|
width = Math.max(width, base.width + 1 + sub.width);
|
|
22430
22654
|
}
|
|
@@ -22440,8 +22664,8 @@ function nary(node, style, ctx) {
|
|
|
22440
22664
|
const chr = val(child(pr, "m:chr")) || "\u222B";
|
|
22441
22665
|
const big = NARY.has(chr) ? 1.4 : 1.6;
|
|
22442
22666
|
const op = glyph(chr, style.size * big);
|
|
22443
|
-
op.ascent = style.size *
|
|
22444
|
-
op.descent = style.size * (big > 1.5 ? 0.55 : 0.
|
|
22667
|
+
op.ascent = style.size * (big > 1.5 ? 1.17 : 1.15);
|
|
22668
|
+
op.descent = style.size * (big > 1.5 ? 0.55 : 0.6);
|
|
22445
22669
|
const limits = (val(child(pr, "m:limLoc")) || (NARY.has(chr) ? "undOvr" : "subSup")) === "undOvr";
|
|
22446
22670
|
const sub = isOn2(val(child(pr, "m:subHide"))) ? void 0 : ctx.layout(child(node, "m:sub"), ctx.script(style));
|
|
22447
22671
|
const sup = isOn2(val(child(pr, "m:supHide"))) ? void 0 : ctx.layout(child(node, "m:sup"), ctx.script(style));
|
|
@@ -22455,13 +22679,13 @@ function nary(node, style, ctx) {
|
|
|
22455
22679
|
parts.push({
|
|
22456
22680
|
box: sup,
|
|
22457
22681
|
x: (width - sup.width) / 2,
|
|
22458
|
-
y: -(op.ascent + sup.descent + style.size * 0.
|
|
22682
|
+
y: -(op.ascent + sup.descent + style.size * 0.075)
|
|
22459
22683
|
});
|
|
22460
22684
|
if (hasSub)
|
|
22461
22685
|
parts.push({
|
|
22462
22686
|
box: sub,
|
|
22463
22687
|
x: (width - sub.width) / 2,
|
|
22464
|
-
y: op.descent + sub.ascent + style.size * 0.
|
|
22688
|
+
y: op.descent + sub.ascent + style.size * 0.075
|
|
22465
22689
|
});
|
|
22466
22690
|
head = overlay(parts);
|
|
22467
22691
|
head.width = width;
|
|
@@ -22507,7 +22731,7 @@ function matrix(node, style, ctx) {
|
|
|
22507
22731
|
(_, c) => Math.max(0, ...rows2.map((cells) => cells[c]?.width ?? 0))
|
|
22508
22732
|
);
|
|
22509
22733
|
const gapX = style.size * 0.8;
|
|
22510
|
-
const gapY =
|
|
22734
|
+
const gapY = 0;
|
|
22511
22735
|
const result = emptyBox();
|
|
22512
22736
|
let y = 0;
|
|
22513
22737
|
const heights = rows2.map((cells) => ({
|
|
@@ -22557,15 +22781,15 @@ function below(base, mark, style) {
|
|
|
22557
22781
|
// math/omml-box-structures.ts
|
|
22558
22782
|
function fraction(node, style, ctx) {
|
|
22559
22783
|
const type = val(child(child(node, "m:fPr"), "m:type"));
|
|
22560
|
-
const inner = ctx.script({ ...style, level: Math.min(style.level, 0) });
|
|
22561
|
-
const small = style.level === 0 ? { ...style,
|
|
22784
|
+
const inner = ctx.script({ ...style, level: Math.min(style.level, 0), display: false });
|
|
22785
|
+
const small = style.level === 0 && style.display ? { ...style, display: false } : inner;
|
|
22562
22786
|
const num = ctx.layout(child(node, "m:num"), small);
|
|
22563
22787
|
const den = ctx.layout(child(node, "m:den"), small);
|
|
22564
22788
|
if (type === "lin") {
|
|
22565
22789
|
const slash = glyph("/", style.size);
|
|
22566
22790
|
return row([num, slash, den]);
|
|
22567
22791
|
}
|
|
22568
|
-
const gap = style.size * 0.
|
|
22792
|
+
const gap = style.size * 0.15;
|
|
22569
22793
|
const axis = style.size * AXIS;
|
|
22570
22794
|
const width = Math.max(num.width, den.width) + style.size * 0.2;
|
|
22571
22795
|
const bar = type === "noBar" ? [] : [
|
|
@@ -22590,9 +22814,9 @@ function radical(node, style, ctx) {
|
|
|
22590
22814
|
const content = ctx.layout(child(node, "m:e"), style);
|
|
22591
22815
|
const hide = isOn2(val(child(child(node, "m:radPr"), "m:degHide")));
|
|
22592
22816
|
const degree = hide ? void 0 : ctx.layout(child(node, "m:deg"), { ...ctx.script(ctx.script(style)) });
|
|
22593
|
-
const gap = style.size * 0.
|
|
22817
|
+
const gap = style.size * 0.2;
|
|
22594
22818
|
const top = -(content.ascent + gap);
|
|
22595
|
-
const bottom = content.descent + style.size * 0.
|
|
22819
|
+
const bottom = content.descent + style.size * 0.15;
|
|
22596
22820
|
const height = bottom - top;
|
|
22597
22821
|
const sign = style.size * 0.55;
|
|
22598
22822
|
const lead = degree && degree.width ? Math.max(0, degree.width - sign * 0.4) : 0;
|
|
@@ -22793,11 +23017,11 @@ function layoutElement(tag, node, style, atStart) {
|
|
|
22793
23017
|
if (/Pr$/.test(tag) || tag === "m:ctrlPr") return emptyBox();
|
|
22794
23018
|
return layoutStructure(tag, node, style, { layout: layoutChildren, script: scriptStyle });
|
|
22795
23019
|
}
|
|
22796
|
-
function layoutEquation(root, sizePx) {
|
|
22797
|
-
const box = layoutChildren(root, { level: 0, size: sizePx });
|
|
23020
|
+
function layoutEquation(root, sizePx, options2 = {}) {
|
|
23021
|
+
const box = layoutChildren(root, { level: 0, size: sizePx, display: Boolean(options2.display) });
|
|
22798
23022
|
const pad2 = 1;
|
|
22799
|
-
const ascent = Math.max(box.ascent, sizePx * 0.
|
|
22800
|
-
const descent = Math.max(box.descent, sizePx * 0.
|
|
23023
|
+
const ascent = Math.max(box.ascent, sizePx * 0.9);
|
|
23024
|
+
const descent = Math.max(box.descent, sizePx * 0.24);
|
|
22801
23025
|
return {
|
|
22802
23026
|
box: { ...box, prims: shifted(box.prims, pad2, 0), ascent, descent },
|
|
22803
23027
|
widthPx: round2(Math.max(box.width, sizePx * 0.5) + pad2 * 2),
|
|
@@ -22856,17 +23080,17 @@ function primMarkup(prim) {
|
|
|
22856
23080
|
return `<path d="${prim.d}" fill="none" stroke="currentColor" stroke-width="${round2(prim.width)}" stroke-linejoin="round"/>`;
|
|
22857
23081
|
}
|
|
22858
23082
|
}
|
|
22859
|
-
function drawOmmlTree(root, sizePx, label = "") {
|
|
22860
|
-
const { box, widthPx, heightPx, descentPx } = layoutEquation(root, sizePx);
|
|
23083
|
+
function drawOmmlTree(root, sizePx, label = "", options2 = {}) {
|
|
23084
|
+
const { box, widthPx, heightPx, descentPx } = layoutEquation(root, sizePx, options2);
|
|
22861
23085
|
if (!box.prims.length) return void 0;
|
|
22862
23086
|
const body = box.prims.map(primMarkup).join("");
|
|
22863
23087
|
const aria = label ? ` aria-label="${escapeXml2(label).replace(/"/g, """)}"` : "";
|
|
22864
23088
|
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>`;
|
|
22865
23089
|
return { svg, widthPx, heightPx, descentPx };
|
|
22866
23090
|
}
|
|
22867
|
-
function drawEquation(omml, sizePx, label = "") {
|
|
23091
|
+
function drawEquation(omml, sizePx, label = "", options2 = {}) {
|
|
22868
23092
|
try {
|
|
22869
|
-
return drawOmmlTree(parseOmml(omml), sizePx, label);
|
|
23093
|
+
return drawOmmlTree(parseOmml(omml), sizePx, label, options2);
|
|
22870
23094
|
} catch {
|
|
22871
23095
|
return void 0;
|
|
22872
23096
|
}
|
|
@@ -22882,11 +23106,11 @@ function latexLabel(omml) {
|
|
|
22882
23106
|
return "Equation";
|
|
22883
23107
|
}
|
|
22884
23108
|
}
|
|
22885
|
-
function equationObject(omml, sizePx) {
|
|
22886
|
-
const key = `${sizePx}|${omml}`;
|
|
23109
|
+
function equationObject(omml, sizePx, display = false) {
|
|
23110
|
+
const key = `${sizePx}|${display}|${omml}`;
|
|
22887
23111
|
const hit = cache.get(key);
|
|
22888
23112
|
if (hit !== void 0) return hit ?? void 0;
|
|
22889
|
-
const drawing = drawEquation(omml, sizePx, latexLabel(omml));
|
|
23113
|
+
const drawing = drawEquation(omml, sizePx, latexLabel(omml), { display });
|
|
22890
23114
|
const object = drawing ? {
|
|
22891
23115
|
partName: "",
|
|
22892
23116
|
contentType: "",
|
|
@@ -22944,6 +23168,7 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
22944
23168
|
return start;
|
|
22945
23169
|
});
|
|
22946
23170
|
});
|
|
23171
|
+
const merges = tableGrid(table);
|
|
22947
23172
|
const cellAt = (rowIndex, gridIndex) => {
|
|
22948
23173
|
const position = gridIndexes[rowIndex]?.indexOf(gridIndex) ?? -1;
|
|
22949
23174
|
return position >= 0 ? table.rows[rowIndex]?.[position] : void 0;
|
|
@@ -22989,10 +23214,13 @@ function adaptTable(table, model, adaptParagraph, _nested = false) {
|
|
|
22989
23214
|
const width = gridWidth(start, span) ?? (cell.widthTwips ? twipsToPx2(cell.widthTwips) : void 0);
|
|
22990
23215
|
const xPx = grid ? gridWidth(0, start) : void 0;
|
|
22991
23216
|
const fill = cssHex(visuals.shadingFill);
|
|
23217
|
+
const entry = merges?.rows[rowIndex]?.[cellIndex];
|
|
23218
|
+
const rowSpan = merges && entry ? rowSpanOf(merges, entry) : 1;
|
|
22992
23219
|
return {
|
|
22993
23220
|
paragraphs: cell.paragraphs.map(adaptParagraph),
|
|
22994
23221
|
...cell.gridSpan !== void 0 ? { gridSpan: cell.gridSpan } : {},
|
|
22995
23222
|
...cell.verticalMerge ? { verticalMerge: cell.verticalMerge } : {},
|
|
23223
|
+
...rowSpan > 1 ? { rowSpan } : {},
|
|
22996
23224
|
...cell.sourceBlocks ? {
|
|
22997
23225
|
blocks: cellSourceBlocks(cell).map(
|
|
22998
23226
|
(block) => block.type === "paragraph" ? adaptParagraph(block) : adaptTable(block, model, adaptParagraph, true)
|
|
@@ -23120,6 +23348,7 @@ var TEXT_BOX_NOTE = "Text boxes are shown on the editing surface but are not dra
|
|
|
23120
23348
|
var EQUATION_NOTE = "Equations that cannot be drawn show a marker in Print Layout instead of the typeset equation.";
|
|
23121
23349
|
var NEXT_COLUMN_NOTE = 'A "next column" section break is laid out as a continuous section break.';
|
|
23122
23350
|
var twipsToPx3 = twipsToPixels;
|
|
23351
|
+
var HTML_AUTO_SPACING_TWIPS = twips(280);
|
|
23123
23352
|
function isDisplayEquationParagraph(paragraph) {
|
|
23124
23353
|
return paragraph.runs.some((run) => run.equation?.display) && paragraph.runs.every((run) => run.equation?.display || !run.text && !run.image);
|
|
23125
23354
|
}
|
|
@@ -23139,6 +23368,9 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23139
23368
|
const reviewMode = options2.reviewDisplayMode ?? "all";
|
|
23140
23369
|
const visibleModel = visibleReviewModel(model, reviewMode);
|
|
23141
23370
|
const catalog = model.paragraphStyles;
|
|
23371
|
+
const addParagraphSpacing = model.doNotUseHtmlParagraphAutoSpacing === true;
|
|
23372
|
+
const keepSpaceBeforePageBreak = model.compatibilityMode !== 15;
|
|
23373
|
+
const autoSpaced = (auto, twipsValue) => auto && !addParagraphSpacing ? HTML_AUTO_SPACING_TWIPS : twipsValue;
|
|
23142
23374
|
const noted = /* @__PURE__ */ new Set();
|
|
23143
23375
|
const reportOnce = (message) => {
|
|
23144
23376
|
if (!noted.has(message)) {
|
|
@@ -23164,7 +23396,11 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23164
23396
|
if (isRunHiddenForReview(run, reviewMode))
|
|
23165
23397
|
return { text: run.text, hidden: true, sourceLength: reviewSourceLength(run) };
|
|
23166
23398
|
const { formatting, family, color } = effective(run, paragraphStyleId);
|
|
23167
|
-
const equation = run.equation ? equationObject(
|
|
23399
|
+
const equation = run.equation ? equationObject(
|
|
23400
|
+
run.equation.omml,
|
|
23401
|
+
ptToPx(formatting.fontSize ?? DEFAULT_FONT_SIZE_PT),
|
|
23402
|
+
Boolean(run.equation.display)
|
|
23403
|
+
) : void 0;
|
|
23168
23404
|
if (run.equation && !equation) reportOnce(EQUATION_NOTE);
|
|
23169
23405
|
const name = run.field ? fieldName(run.field.instr) : "";
|
|
23170
23406
|
const noteText = run.noteReference ? noteLabel(run.noteReference.kind, run.noteReference.id) : run.noteMark ? markLabel ?? "" : void 0;
|
|
@@ -23245,7 +23481,9 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23245
23481
|
function adaptParagraphOnly(paragraph, markLabel) {
|
|
23246
23482
|
const resolved = catalog ? resolveParagraphFormatting(paragraph, catalog) : paragraph;
|
|
23247
23483
|
const label = labels.get(paragraph.id);
|
|
23248
|
-
const
|
|
23484
|
+
const levelWins = Boolean(label && paragraph.numbering);
|
|
23485
|
+
const indents = levelWins ? paragraph : resolved;
|
|
23486
|
+
const ownFirstLine = indents.firstLineTwips !== void 0 || indents.hangingTwips !== void 0;
|
|
23249
23487
|
const runs = paragraph.runs.flatMap(
|
|
23250
23488
|
(run) => symbolSegments(run).flatMap((segment2) => {
|
|
23251
23489
|
const adapted = adaptRun(segment2, paragraph.style, markLabel);
|
|
@@ -23277,16 +23515,16 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23277
23515
|
...definedProps({
|
|
23278
23516
|
align: resolved.align ?? (isDisplayEquationParagraph(paragraph) ? "center" : void 0),
|
|
23279
23517
|
direction: resolved.direction,
|
|
23280
|
-
spacingBeforeTwips: resolved.spacingBeforeTwips,
|
|
23281
|
-
spacingAfterTwips: resolved.spacingAfterTwips,
|
|
23518
|
+
spacingBeforeTwips: autoSpaced(resolved.spacingBeforeAuto, resolved.spacingBeforeTwips),
|
|
23519
|
+
spacingAfterTwips: autoSpaced(resolved.spacingAfterAuto, resolved.spacingAfterTwips),
|
|
23282
23520
|
lineSpacingTwips: resolved.lineSpacingTwips,
|
|
23283
23521
|
lineSpacingRule: resolved.lineSpacingRule,
|
|
23284
|
-
indentLeftTwips:
|
|
23522
|
+
indentLeftTwips: indents.indentLeftTwips ?? label?.indentLeftTwips ?? (levelWins ? resolved.indentLeftTwips : void 0),
|
|
23285
23523
|
indentRightTwips: resolved.indentRightTwips,
|
|
23286
23524
|
indentStartTwips: resolved.indentStartTwips,
|
|
23287
23525
|
indentEndTwips: resolved.indentEndTwips,
|
|
23288
|
-
firstLineTwips: ownFirstLine ?
|
|
23289
|
-
hangingTwips: ownFirstLine ?
|
|
23526
|
+
firstLineTwips: ownFirstLine ? indents.firstLineTwips : label?.firstLineTwips,
|
|
23527
|
+
hangingTwips: ownFirstLine ? indents.hangingTwips : label?.hangingTwips,
|
|
23290
23528
|
styleId: paragraph.style
|
|
23291
23529
|
}),
|
|
23292
23530
|
...resolved.pageBreakBefore ? { pageBreakBefore: true } : {},
|
|
@@ -23345,6 +23583,8 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23345
23583
|
marginLeftPx: model.page.marginLeft
|
|
23346
23584
|
},
|
|
23347
23585
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
23586
|
+
...addParagraphSpacing ? { addParagraphSpacing: true } : {},
|
|
23587
|
+
...keepSpaceBeforePageBreak ? { keepSpaceBeforePageBreak: true } : {},
|
|
23348
23588
|
...modernFootnoteSeparator ? { modernFootnoteSeparator: true } : {},
|
|
23349
23589
|
...legacyFootnoteColumns ? { legacyFootnoteColumns: true } : {},
|
|
23350
23590
|
blocks: blocks.filter((block) => !folded.has(block))
|
|
@@ -23411,6 +23651,8 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23411
23651
|
} : {}
|
|
23412
23652
|
}
|
|
23413
23653
|
} : {},
|
|
23654
|
+
...addParagraphSpacing ? { addParagraphSpacing: true } : {},
|
|
23655
|
+
...keepSpaceBeforePageBreak ? { keepSpaceBeforePageBreak: true } : {},
|
|
23414
23656
|
...sectionStart && { break: sectionStart },
|
|
23415
23657
|
...section.verticalAlign ? { verticalAlign: section.verticalAlign } : {},
|
|
23416
23658
|
// Empty text break markers share the preceding line. The mandatory
|
|
@@ -23423,11 +23665,17 @@ function adaptDocumentModel(model, note = () => {
|
|
|
23423
23665
|
})
|
|
23424
23666
|
};
|
|
23425
23667
|
});
|
|
23426
|
-
return {
|
|
23668
|
+
return {
|
|
23669
|
+
sections: result.map((section, index) => {
|
|
23670
|
+
const last = result[index - 1]?.blocks.at(-1);
|
|
23671
|
+
const after = last?.kind === "paragraph" ? last.spacingAfterTwips : void 0;
|
|
23672
|
+
return !addParagraphSpacing && after ? { ...section, leadingSpacingAfterPx: twipsToPx3(after) } : section;
|
|
23673
|
+
})
|
|
23674
|
+
};
|
|
23427
23675
|
}
|
|
23428
23676
|
|
|
23429
23677
|
// docx/layout/floats.ts
|
|
23430
|
-
var FLOAT_WRAP_NOTE = "Text wraps around floating pictures on their largest side
|
|
23678
|
+
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.";
|
|
23431
23679
|
function horizontalArea(float, page, column) {
|
|
23432
23680
|
const contentLeft = page.marginLeftPx;
|
|
23433
23681
|
switch (float.relativeFromH) {
|
|
@@ -23517,7 +23765,8 @@ function positionFloats(input, pages) {
|
|
|
23517
23765
|
contentType: float.contentType,
|
|
23518
23766
|
...float.chart ? { chart: float.chart } : {},
|
|
23519
23767
|
behindText: Boolean(float.behindText),
|
|
23520
|
-
...float.wrap ? { wrap: float.wrap } : {}
|
|
23768
|
+
...float.wrap ? { wrap: float.wrap } : {},
|
|
23769
|
+
...float.wrapText ? { wrapText: float.wrapText } : {}
|
|
23521
23770
|
});
|
|
23522
23771
|
}
|
|
23523
23772
|
}
|