ooxml-core 1.30.0 → 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/{PptxHandler-3OLZT5YW.cjs → PptxHandler-DHQPVTUI.cjs} +2 -2
- package/dist/{PptxHandler-LOFY2PRO.mjs → PptxHandler-E4DDV3FQ.mjs} +1 -1
- package/dist/{PptxHandler-FJHKJEZU.mjs → PptxHandler-KKLAYUGQ.mjs} +2 -2
- package/dist/{PresentationBuilder-LVIVJZIL.cjs → PresentationBuilder-JORMF5CP.cjs} +4 -4
- package/dist/{PresentationBuilder-W5VRPFLM.mjs → PresentationBuilder-Q2Z33LLM.mjs} +2 -2
- package/dist/{PresentationBuilder-23M6WQK3.mjs → PresentationBuilder-YYZYCKTZ.mjs} +1 -1
- 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/{chunk-JZ64GVIB.mjs → chunk-6FXOAMNL.mjs} +1 -1
- package/dist/{chunk-SCK5U362.cjs → chunk-B4LXDHBX.cjs} +19 -1
- package/dist/{chunk-5YZFO55V.mjs → chunk-FFJBOR2Y.mjs} +4 -4
- package/dist/{chunk-SCTM27HK.mjs → chunk-GJDFCP2T.mjs} +20 -2
- package/dist/{chunk-HDHUJM5M.mjs → chunk-KWJYMAEF.mjs} +19 -1
- package/dist/{chunk-HK7DVTEF.mjs → chunk-MKDONWNO.mjs} +1 -1
- package/dist/{chunk-UVYWAI4M.mjs → chunk-WZJ25K7P.mjs} +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 +20 -1
- 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 +6 -5
- package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +1 -1
- package/dist/pptx/cli/index.cjs +19 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/slide-operations.cjs +1 -1
- package/dist/pptx/editor/render/slide-operations.mjs +1 -1
- package/dist/pptx/index.cjs +19 -1
- package/dist/pptx/index.mjs +5 -5
- 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
package/dist/docx/index.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import JSZip from 'jszip';
|
|
|
5
5
|
var NS = {
|
|
6
6
|
/** WordprocessingML main. */
|
|
7
7
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
8
|
+
/** PresentationML main. */
|
|
9
|
+
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
8
10
|
/** SpreadsheetML main. */
|
|
9
11
|
x: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
|
|
10
12
|
/** DrawingML main. */
|
|
@@ -19,6 +21,12 @@ var NS = {
|
|
|
19
21
|
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
20
22
|
/** Office 2007+ diagram drawing (`dsp`). */
|
|
21
23
|
dsp: "http://schemas.microsoft.com/office/drawing/2008/diagram",
|
|
24
|
+
/** DrawingML Word drawing (`wp:inline`, `wp:anchor`). */
|
|
25
|
+
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
26
|
+
/** DrawingML picture. */
|
|
27
|
+
pic: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
28
|
+
/** Word 2010 shapes (`wps`). */
|
|
29
|
+
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
|
22
30
|
/** Relationships (`r:id`, `r:embed`). */
|
|
23
31
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
24
32
|
/** Markup compatibility (`mc:AlternateContent`). */
|
|
@@ -26,7 +34,42 @@ var NS = {
|
|
|
26
34
|
/** OPC relationships part. */
|
|
27
35
|
rels: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
28
36
|
/** OPC content types part. */
|
|
29
|
-
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
37
|
+
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
38
|
+
/** Office Math. */
|
|
39
|
+
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
40
|
+
/** Core properties. */
|
|
41
|
+
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
42
|
+
/** Dublin Core elements. */
|
|
43
|
+
dc: "http://purl.org/dc/elements/1.1/",
|
|
44
|
+
/** Legacy VML. */
|
|
45
|
+
v: "urn:schemas-microsoft-com:vml",
|
|
46
|
+
/** Office VML extensions. */
|
|
47
|
+
o: "urn:schemas-microsoft-com:office:office",
|
|
48
|
+
/** Word VML extensions. */
|
|
49
|
+
w10: "urn:schemas-microsoft-com:office:word",
|
|
50
|
+
/** SpreadsheetML drawing (`xdr:wsDr`, cell anchors). */
|
|
51
|
+
xdr: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
|
|
52
|
+
/** SpreadsheetML 2009 extensions (`x14:conditionalFormatting`, `x14:dataBar`). */
|
|
53
|
+
x14: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
54
|
+
/** SpreadsheetML 2009 attribute extensions (`x14ac:dyDescent`). */
|
|
55
|
+
x14ac: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac",
|
|
56
|
+
/** SpreadsheetML revision ids (`xr:uid`). */
|
|
57
|
+
xr: "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
|
|
58
|
+
/** Excel threaded comments and persons. */
|
|
59
|
+
tc: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
|
|
60
|
+
/** Legacy VML Excel client data (`x:ClientData`). */
|
|
61
|
+
xv: "urn:schemas-microsoft-com:office:excel",
|
|
62
|
+
/** Extended (app) properties. */
|
|
63
|
+
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
|
|
64
|
+
/** Dublin Core terms (`dcterms:created`). */
|
|
65
|
+
dcterms: "http://purl.org/dc/terms/",
|
|
66
|
+
/** Custom document properties (`docProps/custom.xml`). */
|
|
67
|
+
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
|
68
|
+
/** Document property variant types (`vt:lpwstr`, `vt:vector`). */
|
|
69
|
+
vt: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
70
|
+
/** XML itself (`xml:space`). */
|
|
71
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
72
|
+
};
|
|
30
73
|
var DEFAULT_XML_LIMITS = {
|
|
31
74
|
maxDepth: 512,
|
|
32
75
|
maxNodes: 5e6
|
|
@@ -1109,6 +1152,10 @@ function parseFormatting(pPr) {
|
|
|
1109
1152
|
const line3 = signedTwipValue(getW(spacing3, "line"));
|
|
1110
1153
|
if (before !== void 0) result.spacingBeforeTwips = before;
|
|
1111
1154
|
if (after !== void 0) result.spacingAfterTwips = after;
|
|
1155
|
+
const beforeAuto = parseOnOff(getW(spacing3, "beforeAutospacing"));
|
|
1156
|
+
const afterAuto = parseOnOff(getW(spacing3, "afterAutospacing"));
|
|
1157
|
+
if (beforeAuto !== void 0) result.spacingBeforeAuto = beforeAuto;
|
|
1158
|
+
if (afterAuto !== void 0) result.spacingAfterAuto = afterAuto;
|
|
1112
1159
|
if (line3 !== void 0) result.lineSpacingTwips = line3;
|
|
1113
1160
|
const rule = getW(spacing3, "lineRule");
|
|
1114
1161
|
if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
|
|
@@ -1207,6 +1254,8 @@ function resolveParagraphFormatting(paragraph2, catalog) {
|
|
|
1207
1254
|
"direction",
|
|
1208
1255
|
"spacingBeforeTwips",
|
|
1209
1256
|
"spacingAfterTwips",
|
|
1257
|
+
"spacingBeforeAuto",
|
|
1258
|
+
"spacingAfterAuto",
|
|
1210
1259
|
"lineSpacingTwips",
|
|
1211
1260
|
"lineSpacingRule",
|
|
1212
1261
|
"indentLeftTwips",
|
|
@@ -2308,7 +2357,7 @@ function applyPictureEffects(blip, effects) {
|
|
|
2308
2357
|
const node = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
2309
2358
|
if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
|
|
2310
2359
|
throw new Error("Picture effect source does not match its kind");
|
|
2311
|
-
const
|
|
2360
|
+
const set2 = (name2, value) => {
|
|
2312
2361
|
const original = picturePercentage(node.getAttribute(name2));
|
|
2313
2362
|
if (value === void 0) node.removeAttribute(name2);
|
|
2314
2363
|
else if (value !== original) {
|
|
@@ -2321,12 +2370,12 @@ function applyPictureEffects(blip, effects) {
|
|
|
2321
2370
|
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
2322
2371
|
))
|
|
2323
2372
|
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
2324
|
-
|
|
2325
|
-
|
|
2373
|
+
set2("bright", effect.brightness);
|
|
2374
|
+
set2("contrast", effect.contrast);
|
|
2326
2375
|
}
|
|
2327
2376
|
if (effect.kind === "alphaModFix") {
|
|
2328
2377
|
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
2329
|
-
|
|
2378
|
+
set2("amt", effect.amount);
|
|
2330
2379
|
}
|
|
2331
2380
|
return node;
|
|
2332
2381
|
});
|
|
@@ -3697,6 +3746,233 @@ async function openZip(input, limits = {}) {
|
|
|
3697
3746
|
return guardZip(await JSZip.loadAsync(bytes), limits);
|
|
3698
3747
|
}
|
|
3699
3748
|
|
|
3749
|
+
// opc/properties/patch.ts
|
|
3750
|
+
var XMLNS3 = "http://www.w3.org/2000/xmlns/";
|
|
3751
|
+
function tagEnd(xml, from) {
|
|
3752
|
+
let quote = "";
|
|
3753
|
+
for (let i = from + 1; i < xml.length; i++) {
|
|
3754
|
+
const ch = xml[i];
|
|
3755
|
+
if (quote) {
|
|
3756
|
+
if (ch === quote) quote = "";
|
|
3757
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
3758
|
+
else if (ch === ">") return i + 1;
|
|
3759
|
+
}
|
|
3760
|
+
throw new Error("Unterminated tag in property part");
|
|
3761
|
+
}
|
|
3762
|
+
function skipMarkup(xml, at) {
|
|
3763
|
+
if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
|
|
3764
|
+
if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
|
|
3765
|
+
if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
|
|
3766
|
+
return void 0;
|
|
3767
|
+
}
|
|
3768
|
+
function scan(xml) {
|
|
3769
|
+
let i = 0;
|
|
3770
|
+
let rootStart = -1;
|
|
3771
|
+
while (rootStart < 0) {
|
|
3772
|
+
const lt = xml.indexOf("<", i);
|
|
3773
|
+
if (lt < 0) throw new Error("Property part has no root element");
|
|
3774
|
+
const skipped = skipMarkup(xml, lt);
|
|
3775
|
+
if (skipped !== void 0) i = skipped;
|
|
3776
|
+
else rootStart = lt;
|
|
3777
|
+
}
|
|
3778
|
+
const openEnd = tagEnd(xml, rootStart);
|
|
3779
|
+
if (xml[openEnd - 2] === "/") {
|
|
3780
|
+
const root = {
|
|
3781
|
+
start: rootStart,
|
|
3782
|
+
openEnd,
|
|
3783
|
+
closeStart: openEnd,
|
|
3784
|
+
end: openEnd,
|
|
3785
|
+
selfClosing: true
|
|
3786
|
+
};
|
|
3787
|
+
return { root, children: [] };
|
|
3788
|
+
}
|
|
3789
|
+
const children3 = [];
|
|
3790
|
+
let depth = 0;
|
|
3791
|
+
let child7;
|
|
3792
|
+
i = openEnd;
|
|
3793
|
+
for (; ; ) {
|
|
3794
|
+
const lt = xml.indexOf("<", i);
|
|
3795
|
+
if (lt < 0) throw new Error("Property part root is not closed");
|
|
3796
|
+
const skipped = skipMarkup(xml, lt);
|
|
3797
|
+
if (skipped !== void 0) {
|
|
3798
|
+
i = skipped;
|
|
3799
|
+
continue;
|
|
3800
|
+
}
|
|
3801
|
+
const end = tagEnd(xml, lt);
|
|
3802
|
+
i = end;
|
|
3803
|
+
if (xml[lt + 1] === "/") {
|
|
3804
|
+
if (depth === 0) {
|
|
3805
|
+
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
3806
|
+
return { root, children: children3 };
|
|
3807
|
+
}
|
|
3808
|
+
depth--;
|
|
3809
|
+
if (depth === 0 && child7)
|
|
3810
|
+
children3.push({ ...child7, closeStart: lt, end, selfClosing: false });
|
|
3811
|
+
} else if (xml[end - 2] === "/") {
|
|
3812
|
+
if (depth === 0)
|
|
3813
|
+
children3.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
3814
|
+
} else {
|
|
3815
|
+
if (depth === 0) child7 = { start: lt, openEnd: end };
|
|
3816
|
+
depth++;
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
var escapeText = (text2) => text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
3821
|
+
var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
3822
|
+
var PartPatch = class {
|
|
3823
|
+
constructor(xml, rootElement) {
|
|
3824
|
+
this.xml = xml;
|
|
3825
|
+
const { root, children: children3 } = scan(xml);
|
|
3826
|
+
const kids = elements(rootElement);
|
|
3827
|
+
if (kids.length !== children3.length) throw new Error("Property part markup is not supported");
|
|
3828
|
+
kids.forEach((kid, index) => this.spans.set(kid, children3[index]));
|
|
3829
|
+
this.root = root;
|
|
3830
|
+
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
3831
|
+
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
3832
|
+
else if (attribute2.namespaceURI === XMLNS3 || attribute2.name.startsWith("xmlns:"))
|
|
3833
|
+
this.prefixes.set(attribute2.value, attribute2.localName);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
xml;
|
|
3837
|
+
root;
|
|
3838
|
+
spans = /* @__PURE__ */ new Map();
|
|
3839
|
+
edits = [];
|
|
3840
|
+
appended = [];
|
|
3841
|
+
prefixes = /* @__PURE__ */ new Map();
|
|
3842
|
+
defaultNs = null;
|
|
3843
|
+
seq = 0;
|
|
3844
|
+
add(start, end, text2) {
|
|
3845
|
+
this.edits.push({ start, end, text: text2, seq: this.seq++ });
|
|
3846
|
+
}
|
|
3847
|
+
span(element4) {
|
|
3848
|
+
const span = this.spans.get(element4);
|
|
3849
|
+
if (!span) throw new Error("Element is not a child of the patched root");
|
|
3850
|
+
return span;
|
|
3851
|
+
}
|
|
3852
|
+
/** The prefix bound to `ns` on the root, declaring `preferred` for it when none is. */
|
|
3853
|
+
prefix(ns, preferred) {
|
|
3854
|
+
const known = this.prefixes.get(ns);
|
|
3855
|
+
if (known !== void 0) return known;
|
|
3856
|
+
const taken = new Set(this.prefixes.values());
|
|
3857
|
+
let prefix2 = preferred;
|
|
3858
|
+
for (let n2 = 1; taken.has(prefix2); n2++) prefix2 = `${preferred}${n2}`;
|
|
3859
|
+
this.prefixes.set(ns, prefix2);
|
|
3860
|
+
const at = this.root.openEnd - (this.root.selfClosing ? 2 : 1);
|
|
3861
|
+
this.add(at, at, ` xmlns:${prefix2}="${ns}"`);
|
|
3862
|
+
return prefix2;
|
|
3863
|
+
}
|
|
3864
|
+
/** `local` qualified for an element in `ns`: unprefixed in the default namespace. */
|
|
3865
|
+
qualify(ns, local, preferred) {
|
|
3866
|
+
return this.defaultNs === ns && !this.prefixes.has(ns) ? local : `${this.prefix(ns, preferred)}:${local}`;
|
|
3867
|
+
}
|
|
3868
|
+
/** Replaces the element's content, keeping its start tag (and attributes) as written. */
|
|
3869
|
+
setContent(element4, content) {
|
|
3870
|
+
const span = this.span(element4);
|
|
3871
|
+
if (span.selfClosing)
|
|
3872
|
+
this.add(span.openEnd - 2, span.openEnd, `>${content}</${qualifiedName(this.xml, span)}>`);
|
|
3873
|
+
else this.add(span.openEnd, span.closeStart, content);
|
|
3874
|
+
}
|
|
3875
|
+
/** Adds ` name="value"` text to the element's start tag. */
|
|
3876
|
+
addAttribute(element4, attribute2) {
|
|
3877
|
+
const span = this.span(element4);
|
|
3878
|
+
const at = span.openEnd - (span.selfClosing ? 2 : 1);
|
|
3879
|
+
this.add(at, at, attribute2);
|
|
3880
|
+
}
|
|
3881
|
+
remove(element4) {
|
|
3882
|
+
const span = this.span(element4);
|
|
3883
|
+
this.add(span.start, span.end, "");
|
|
3884
|
+
}
|
|
3885
|
+
/** Inserts `markup` before `before`, or as the root's last child. */
|
|
3886
|
+
insert(markup, before) {
|
|
3887
|
+
if (before) {
|
|
3888
|
+
const at = this.span(before).start;
|
|
3889
|
+
this.add(at, at, markup);
|
|
3890
|
+
} else this.appended.push(markup);
|
|
3891
|
+
}
|
|
3892
|
+
toString() {
|
|
3893
|
+
const edits = [...this.edits];
|
|
3894
|
+
if (this.appended.length) {
|
|
3895
|
+
const text2 = this.appended.join("");
|
|
3896
|
+
const root = this.root;
|
|
3897
|
+
if (root.selfClosing) {
|
|
3898
|
+
const name = qualifiedName(this.xml, root);
|
|
3899
|
+
edits.push({
|
|
3900
|
+
start: root.end - 2,
|
|
3901
|
+
end: root.end,
|
|
3902
|
+
text: `>${text2}</${name}>`,
|
|
3903
|
+
seq: this.seq
|
|
3904
|
+
});
|
|
3905
|
+
} else edits.push({ start: root.closeStart, end: root.closeStart, text: text2, seq: this.seq });
|
|
3906
|
+
}
|
|
3907
|
+
edits.sort((a2, b) => a2.start - b.start || a2.end - a2.start - (b.end - b.start) || a2.seq - b.seq);
|
|
3908
|
+
let out = "";
|
|
3909
|
+
let at = 0;
|
|
3910
|
+
for (const edit of edits) {
|
|
3911
|
+
out += this.xml.slice(at, edit.start) + edit.text;
|
|
3912
|
+
at = Math.max(at, edit.end);
|
|
3913
|
+
}
|
|
3914
|
+
return out + this.xml.slice(at);
|
|
3915
|
+
}
|
|
3916
|
+
};
|
|
3917
|
+
|
|
3918
|
+
// opc/properties/core.ts
|
|
3919
|
+
var XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
3920
|
+
var FIELDS = [
|
|
3921
|
+
["title", "dc", false],
|
|
3922
|
+
["subject", "dc", false],
|
|
3923
|
+
["creator", "dc", false],
|
|
3924
|
+
["keywords", "cp", false],
|
|
3925
|
+
["description", "dc", false],
|
|
3926
|
+
["lastModifiedBy", "cp", false],
|
|
3927
|
+
["created", "dcterms", true],
|
|
3928
|
+
["modified", "dcterms", true],
|
|
3929
|
+
["category", "cp", false],
|
|
3930
|
+
["contentStatus", "cp", false],
|
|
3931
|
+
["revision", "cp", false],
|
|
3932
|
+
["language", "dc", false],
|
|
3933
|
+
["identifier", "dc", false],
|
|
3934
|
+
["lastPrinted", "cp", false],
|
|
3935
|
+
["version", "cp", false]
|
|
3936
|
+
];
|
|
3937
|
+
FIELDS.map(([field]) => field);
|
|
3938
|
+
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3939
|
+
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
3940
|
+
function parseCoreProperties(xml) {
|
|
3941
|
+
const out = {};
|
|
3942
|
+
if (!xml) return out;
|
|
3943
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3944
|
+
for (const [field, prefix2] of FIELDS) {
|
|
3945
|
+
const text2 = first(root, field, NS[prefix2])?.textContent ?? "";
|
|
3946
|
+
if (text2 !== "") out[field] = text2;
|
|
3947
|
+
}
|
|
3948
|
+
return out;
|
|
3949
|
+
}
|
|
3950
|
+
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
3951
|
+
function writeCoreProperties(props, sourceXml) {
|
|
3952
|
+
const xml = sourceXml ?? EMPTY_CORE;
|
|
3953
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3954
|
+
const patch = new PartPatch(xml, root);
|
|
3955
|
+
for (const [field, prefix2, isDate] of FIELDS) {
|
|
3956
|
+
const ns = NS[prefix2];
|
|
3957
|
+
const value = props[field];
|
|
3958
|
+
const element4 = first(root, field, ns);
|
|
3959
|
+
if (value === void 0 || value === "") {
|
|
3960
|
+
if (element4 && (element4.textContent ?? "") !== "") patch.remove(element4);
|
|
3961
|
+
continue;
|
|
3962
|
+
}
|
|
3963
|
+
if (element4 && element4.textContent === value) continue;
|
|
3964
|
+
const typed = () => ` ${patch.prefix(XSI, "xsi")}:type="${patch.prefix(NS.dcterms, "dcterms")}:W3CDTF"`;
|
|
3965
|
+
if (element4) {
|
|
3966
|
+
if (isDate && !element4.getAttributeNS(XSI, "type")) patch.addAttribute(element4, typed());
|
|
3967
|
+
patch.setContent(element4, escapeText(value));
|
|
3968
|
+
continue;
|
|
3969
|
+
}
|
|
3970
|
+
const name = patch.qualify(ns, field, prefix2);
|
|
3971
|
+
patch.insert(`<${name}${isDate ? typed() : ""}>${escapeText(value)}</${name}>`);
|
|
3972
|
+
}
|
|
3973
|
+
return patch.toString();
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3700
3976
|
// opc/signature/xml-utils.ts
|
|
3701
3977
|
function escapeXmlAttr(value) {
|
|
3702
3978
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -3729,7 +4005,7 @@ var PREFIX = {
|
|
|
3729
4005
|
};
|
|
3730
4006
|
var CORE_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
3731
4007
|
var CORE_REL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
3732
|
-
function
|
|
4008
|
+
function parseCoreProperties2(xml) {
|
|
3733
4009
|
const root = parseXml2(xml).documentElement;
|
|
3734
4010
|
const result = {};
|
|
3735
4011
|
for (const field of PROPERTY_FIELDS) {
|
|
@@ -3797,265 +4073,18 @@ function dropAddedFolders(zip, source2) {
|
|
|
3797
4073
|
if (entry2.dir && !source2.has(name)) delete zip.files[name];
|
|
3798
4074
|
}
|
|
3799
4075
|
|
|
3800
|
-
// docx/
|
|
3801
|
-
var
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
equation: "equation",
|
|
3812
|
-
citation: "citation",
|
|
3813
|
-
bibliography: "bibliography",
|
|
3814
|
-
docPartObj: "docPartObj",
|
|
3815
|
-
docPartList: "docPartList"
|
|
3816
|
-
};
|
|
3817
|
-
function attrW14(element4, local) {
|
|
3818
|
-
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
3819
|
-
}
|
|
3820
|
-
function glyph(element4) {
|
|
3821
|
-
const code = attrW14(element4, "val");
|
|
3822
|
-
if (!code) return void 0;
|
|
3823
|
-
const font = attrW14(element4, "font");
|
|
3824
|
-
return { code, ...font ? { font } : {} };
|
|
3825
|
-
}
|
|
3826
|
-
function kindOf(child7) {
|
|
3827
|
-
if (child7.namespaceURI === WORD_NS)
|
|
3828
|
-
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
3829
|
-
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
3830
|
-
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
3831
|
-
return "repeatingSection";
|
|
3832
|
-
return void 0;
|
|
3833
|
-
}
|
|
3834
|
-
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
3835
|
-
(child7) => kindOf(child7) !== void 0 || child7.namespaceURI === WORD_NS && child7.localName === "richText" || child7.namespaceURI === WORD_2010_NS && child7.localName === "entityPicker" || child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSectionItem"
|
|
3836
|
-
);
|
|
3837
|
-
function parseKind(sdtPr) {
|
|
3838
|
-
const [type] = typeElements(sdtPr);
|
|
3839
|
-
return (type && kindOf(type)) ?? "richText";
|
|
3840
|
-
}
|
|
3841
|
-
var generated = 0;
|
|
3842
|
-
function parseContentControl(sdt, level4) {
|
|
3843
|
-
const sdtPr = first2(sdt, "sdtPr");
|
|
3844
|
-
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level4, kind: "richText" };
|
|
3845
|
-
const kind = parseKind(sdtPr);
|
|
3846
|
-
const control = {
|
|
3847
|
-
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
3848
|
-
level: level4,
|
|
3849
|
-
kind
|
|
3850
|
-
};
|
|
3851
|
-
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
3852
|
-
if (alias !== void 0) control.alias = alias;
|
|
3853
|
-
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
3854
|
-
if (tag !== void 0) control.tag = tag;
|
|
3855
|
-
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
3856
|
-
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
3857
|
-
control.lock = lock;
|
|
3858
|
-
const showing = first2(sdtPr, "showingPlcHdr");
|
|
3859
|
-
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
3860
|
-
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
3861
|
-
const temporary = first2(sdtPr, "temporary");
|
|
3862
|
-
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
3863
|
-
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
3864
|
-
if (placeholder) control.placeholder = placeholder;
|
|
3865
|
-
if (kind === "text") {
|
|
3866
|
-
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
3867
|
-
if (multi) control.multiLine = true;
|
|
3868
|
-
}
|
|
3869
|
-
if (kind === "checkbox") {
|
|
3870
|
-
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
3871
|
-
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
3872
|
-
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
3873
|
-
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
3874
|
-
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
3875
|
-
if (on) control.checkedGlyph = on;
|
|
3876
|
-
if (off) control.uncheckedGlyph = off;
|
|
3877
|
-
}
|
|
3878
|
-
if (kind === "dropDownList" || kind === "comboBox") {
|
|
3879
|
-
const list2 = first2(sdtPr, kind);
|
|
3880
|
-
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
3881
|
-
const display = getW(item2, "displayText");
|
|
3882
|
-
const value = getW(item2, "value") ?? display ?? "";
|
|
3883
|
-
return { display: display ?? value, value };
|
|
3884
|
-
});
|
|
3885
|
-
}
|
|
3886
|
-
if (kind === "date") {
|
|
3887
|
-
const date = first2(sdtPr, "date");
|
|
3888
|
-
const fullDate = getW(date, "fullDate");
|
|
3889
|
-
if (fullDate) control.fullDate = fullDate;
|
|
3890
|
-
const format = getW(first2(date, "dateFormat"), "val");
|
|
3891
|
-
if (format) control.dateFormat = format;
|
|
3892
|
-
const lid = getW(first2(date, "lid"), "val");
|
|
3893
|
-
if (lid) control.dateLocale = lid;
|
|
3894
|
-
}
|
|
3895
|
-
control.sourceXml = buildXml(sdtPr);
|
|
3896
|
-
const end = first2(sdt, "sdtEndPr");
|
|
3897
|
-
if (end) control.endSourceXml = buildXml(end);
|
|
3898
|
-
return control;
|
|
3899
|
-
}
|
|
3900
|
-
|
|
3901
|
-
// docx/expect-defined.ts
|
|
3902
|
-
function expectDefined(value, context) {
|
|
3903
|
-
if (value === void 0 || value === null) {
|
|
3904
|
-
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
3905
|
-
}
|
|
3906
|
-
return value;
|
|
3907
|
-
}
|
|
3908
|
-
|
|
3909
|
-
// docx/parse-revisions.ts
|
|
3910
|
-
var REVISION_WRAPPERS = {
|
|
3911
|
-
ins: "insert",
|
|
3912
|
-
del: "delete",
|
|
3913
|
-
moveFrom: "moveFrom",
|
|
3914
|
-
moveTo: "moveTo"
|
|
3915
|
-
};
|
|
3916
|
-
var MOVE_RANGES = {
|
|
3917
|
-
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
3918
|
-
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
3919
|
-
moveToRangeStart: { kind: "moveTo", start: true },
|
|
3920
|
-
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
3921
|
-
};
|
|
3922
|
-
function trackMoveRange(item2, moves) {
|
|
3923
|
-
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
3924
|
-
const range2 = MOVE_RANGES[item2.localName ?? ""];
|
|
3925
|
-
if (!range2) return false;
|
|
3926
|
-
const id = getW(item2, "id") ?? "";
|
|
3927
|
-
const open = moves[range2.kind];
|
|
3928
|
-
if (range2.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
3929
|
-
else {
|
|
3930
|
-
const index = open.findIndex((entry2) => entry2.id === id);
|
|
3931
|
-
if (index >= 0) open.splice(index, 1);
|
|
3932
|
-
}
|
|
3933
|
-
return true;
|
|
3934
|
-
}
|
|
3935
|
-
function isCommentReferenceRun(run2) {
|
|
3936
|
-
const content = Array.from(run2.childNodes).filter(
|
|
3937
|
-
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
3938
|
-
);
|
|
3939
|
-
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
3940
|
-
}
|
|
3941
|
-
function revisionFrom(node, kind) {
|
|
3942
|
-
const revision = {
|
|
3943
|
-
kind,
|
|
3944
|
-
author: getW(node, "author") || "Unknown",
|
|
3945
|
-
id: getW(node, "id") ?? "0"
|
|
3946
|
-
};
|
|
3947
|
-
const date = getW(node, "date");
|
|
3948
|
-
if (date) revision.date = date;
|
|
3949
|
-
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
3950
|
-
if (dateUtc) revision.dateUtc = dateUtc;
|
|
3951
|
-
return revision;
|
|
3952
|
-
}
|
|
3953
|
-
function paragraphMarkRevision(pPr) {
|
|
3954
|
-
const rPr = first2(pPr, "rPr");
|
|
3955
|
-
const ins = first2(rPr, "ins");
|
|
3956
|
-
if (ins) return revisionFrom(ins, "insert");
|
|
3957
|
-
const del = first2(rPr, "del");
|
|
3958
|
-
if (del) return revisionFrom(del, "delete");
|
|
3959
|
-
return void 0;
|
|
3960
|
-
}
|
|
3961
|
-
function paragraphFormatRevision(pPr) {
|
|
3962
|
-
const change = first2(pPr, "pPrChange");
|
|
3963
|
-
if (!change) return void 0;
|
|
3964
|
-
const revision = revisionFrom(change, "paragraphChange");
|
|
3965
|
-
const previous = first2(change, "pPr");
|
|
3966
|
-
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
3967
|
-
return revision;
|
|
3968
|
-
}
|
|
3969
|
-
function runFormatRevision(rPr) {
|
|
3970
|
-
const change = first2(rPr, "rPrChange");
|
|
3971
|
-
if (!change) return void 0;
|
|
3972
|
-
const revision = revisionFrom(change, "formatChange");
|
|
3973
|
-
const previous = first2(change, "rPr");
|
|
3974
|
-
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
3975
|
-
return revision;
|
|
3976
|
-
}
|
|
3977
|
-
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
3978
|
-
const runs = [];
|
|
3979
|
-
let hasMove = false;
|
|
3980
|
-
const push = (run2) => {
|
|
3981
|
-
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
3982
|
-
runs.push(run2);
|
|
3983
|
-
};
|
|
3984
|
-
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
3985
|
-
if (named2(item2, "r")) {
|
|
3986
|
-
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
3987
|
-
} else if (named2(item2, "hyperlink")) {
|
|
3988
|
-
const link = resolveLink?.(item2);
|
|
3989
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
3990
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
3991
|
-
if (link) parsed.link = link;
|
|
3992
|
-
push(parsed);
|
|
3993
|
-
}
|
|
3994
|
-
}
|
|
3995
|
-
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
3996
|
-
const kind = expectDefined(
|
|
3997
|
-
REVISION_WRAPPERS[item2.localName],
|
|
3998
|
-
`revision wrapper ${item2.localName}`
|
|
3999
|
-
);
|
|
4000
|
-
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
4001
|
-
const revision = revisionFrom(item2, kind);
|
|
4002
|
-
const range2 = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
4003
|
-
if (range2) revision.move = { name: range2.name, rangeId: range2.id };
|
|
4004
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4005
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
4006
|
-
parsed.revision = revision;
|
|
4007
|
-
push(parsed);
|
|
4008
|
-
}
|
|
4009
|
-
}
|
|
4010
|
-
} else if (trackMoveRange(item2, moves)) {
|
|
4011
|
-
continue;
|
|
4012
|
-
} else if (named2(item2, "commentRangeStart")) {
|
|
4013
|
-
const id = getW(item2, "id");
|
|
4014
|
-
if (id !== void 0) active.push(id);
|
|
4015
|
-
} else if (named2(item2, "commentRangeEnd")) {
|
|
4016
|
-
const id = getW(item2, "id");
|
|
4017
|
-
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
4018
|
-
if (index >= 0) active.splice(index, 1);
|
|
4019
|
-
} else {
|
|
4020
|
-
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
4021
|
-
}
|
|
4022
|
-
}
|
|
4023
|
-
return { runs, hasMove };
|
|
4024
|
-
}
|
|
4025
|
-
|
|
4026
|
-
// docx/parse-content-control.ts
|
|
4027
|
-
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
4028
|
-
const control = parseContentControl(sdt, "inline");
|
|
4029
|
-
const content = sdtContent(sdt);
|
|
4030
|
-
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
4031
|
-
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
4032
|
-
for (const run2 of runs) run2.contentControl ??= control;
|
|
4033
|
-
return runs;
|
|
4034
|
-
}
|
|
4035
|
-
function flatChildren(parent, names, level4 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
4036
|
-
const found = [];
|
|
4037
|
-
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
4038
|
-
if (isSdt(child7)) {
|
|
4039
|
-
const content = sdtContent(child7);
|
|
4040
|
-
if (!content) continue;
|
|
4041
|
-
let control = controls.get(child7);
|
|
4042
|
-
if (!control) {
|
|
4043
|
-
control = parseContentControl(child7, level4);
|
|
4044
|
-
controls.set(child7, control);
|
|
4045
|
-
}
|
|
4046
|
-
found.push(...flatChildren(content, names, level4, { control, sdt: child7 }, controls));
|
|
4047
|
-
} else if (names.some((name) => named2(child7, name)))
|
|
4048
|
-
found.push({
|
|
4049
|
-
element: child7,
|
|
4050
|
-
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
4051
|
-
});
|
|
4052
|
-
}
|
|
4053
|
-
return found;
|
|
4076
|
+
// docx/save-modified.ts
|
|
4077
|
+
var CORE_PATH2 = "docProps/core.xml";
|
|
4078
|
+
async function stampModified(zip, option) {
|
|
4079
|
+
if (!option) return;
|
|
4080
|
+
const file = zip.file(CORE_PATH2);
|
|
4081
|
+
if (!file) return;
|
|
4082
|
+
const source2 = await file.async("string");
|
|
4083
|
+
const props = parseCoreProperties(source2);
|
|
4084
|
+
props.modified = formatW3cdtf(option.at ?? /* @__PURE__ */ new Date());
|
|
4085
|
+
if (option.author) props.lastModifiedBy = option.author;
|
|
4086
|
+
zip.file(CORE_PATH2, writeCoreProperties(props, source2));
|
|
4054
4087
|
}
|
|
4055
|
-
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
4056
|
-
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
4057
|
-
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
4058
|
-
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
4059
4088
|
|
|
4060
4089
|
// docx/element-order.ts
|
|
4061
4090
|
var RPR_ORDER = [
|
|
@@ -4144,6 +4173,720 @@ function orderSectionProperties(sectPr) {
|
|
|
4144
4173
|
orderChildren(sectPr, SECTPR_ORDER);
|
|
4145
4174
|
}
|
|
4146
4175
|
|
|
4176
|
+
// docx/tab-stops.ts
|
|
4177
|
+
function parseTabStops(tabs) {
|
|
4178
|
+
const stops = [];
|
|
4179
|
+
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
4180
|
+
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
4181
|
+
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
4182
|
+
if (!align || pos === void 0) continue;
|
|
4183
|
+
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
4184
|
+
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
4185
|
+
}
|
|
4186
|
+
return stops;
|
|
4187
|
+
}
|
|
4188
|
+
function writeTabStops(doc, props, paragraph2, base) {
|
|
4189
|
+
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
4190
|
+
return;
|
|
4191
|
+
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
4192
|
+
if (!paragraph2.tabStops?.length) return;
|
|
4193
|
+
const tabs = makeW(doc, "tabs");
|
|
4194
|
+
for (const stop of paragraph2.tabStops) {
|
|
4195
|
+
const tab = makeW(doc, "tab");
|
|
4196
|
+
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
4197
|
+
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
4198
|
+
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
4199
|
+
tabs.appendChild(tab);
|
|
4200
|
+
}
|
|
4201
|
+
props.appendChild(tabs);
|
|
4202
|
+
}
|
|
4203
|
+
var PPR_ORDER = [
|
|
4204
|
+
"pStyle",
|
|
4205
|
+
"keepNext",
|
|
4206
|
+
"keepLines",
|
|
4207
|
+
"pageBreakBefore",
|
|
4208
|
+
"framePr",
|
|
4209
|
+
"widowControl",
|
|
4210
|
+
"numPr",
|
|
4211
|
+
"suppressLineNumbers",
|
|
4212
|
+
"pBdr",
|
|
4213
|
+
"shd",
|
|
4214
|
+
"tabs",
|
|
4215
|
+
"suppressAutoHyphens",
|
|
4216
|
+
"kinsoku",
|
|
4217
|
+
"wordWrap",
|
|
4218
|
+
"overflowPunct",
|
|
4219
|
+
"topLinePunct",
|
|
4220
|
+
"autoSpaceDE",
|
|
4221
|
+
"autoSpaceDN",
|
|
4222
|
+
"bidi",
|
|
4223
|
+
"adjustRightInd",
|
|
4224
|
+
"snapToGrid",
|
|
4225
|
+
"spacing",
|
|
4226
|
+
"ind",
|
|
4227
|
+
"contextualSpacing",
|
|
4228
|
+
"mirrorIndents",
|
|
4229
|
+
"suppressOverlap",
|
|
4230
|
+
"jc",
|
|
4231
|
+
"textDirection",
|
|
4232
|
+
"textAlignment",
|
|
4233
|
+
"textboxTightWrap",
|
|
4234
|
+
"outlineLvl",
|
|
4235
|
+
"divId",
|
|
4236
|
+
"cnfStyle",
|
|
4237
|
+
"rPr",
|
|
4238
|
+
"sectPr",
|
|
4239
|
+
"pPrChange"
|
|
4240
|
+
];
|
|
4241
|
+
function orderParagraphProperties(props) {
|
|
4242
|
+
orderChildren(props, PPR_ORDER);
|
|
4243
|
+
}
|
|
4244
|
+
|
|
4245
|
+
// docx/write-paragraph-decoration.ts
|
|
4246
|
+
var SIDES3 = ["top", "left", "bottom", "right", "between"];
|
|
4247
|
+
function wordColor(color) {
|
|
4248
|
+
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
4249
|
+
return hex ? hex.toUpperCase() : "auto";
|
|
4250
|
+
}
|
|
4251
|
+
function borderElement(doc, name, side) {
|
|
4252
|
+
const element4 = makeW(doc, name);
|
|
4253
|
+
const set2 = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
4254
|
+
set2("val", side.style ?? "single");
|
|
4255
|
+
if (side.style !== "none" && side.style !== "nil") {
|
|
4256
|
+
set2("sz", String(side.sizeEighthPoints ?? 4));
|
|
4257
|
+
set2("space", String(side.spacePoints ?? 1));
|
|
4258
|
+
set2("color", wordColor(side.color));
|
|
4259
|
+
if (side.themeColor) set2("themeColor", side.themeColor);
|
|
4260
|
+
}
|
|
4261
|
+
return element4;
|
|
4262
|
+
}
|
|
4263
|
+
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
4264
|
+
function updateShading(doc, props, paragraph2, base) {
|
|
4265
|
+
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
4266
|
+
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
4267
|
+
if (!paragraph2.shadingFill) return;
|
|
4268
|
+
const shd = makeW(doc, "shd");
|
|
4269
|
+
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
4270
|
+
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
4271
|
+
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
4272
|
+
props.appendChild(shd);
|
|
4273
|
+
}
|
|
4274
|
+
function updateBorders(doc, props, paragraph2, base) {
|
|
4275
|
+
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
4276
|
+
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
4277
|
+
const borders = paragraph2.borders;
|
|
4278
|
+
if (!borders) return;
|
|
4279
|
+
const pBdr = makeW(doc, "pBdr");
|
|
4280
|
+
for (const side of SIDES3) {
|
|
4281
|
+
const value = borders[side];
|
|
4282
|
+
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
4283
|
+
}
|
|
4284
|
+
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
4285
|
+
}
|
|
4286
|
+
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
4287
|
+
updateShading(doc, props, paragraph2, base);
|
|
4288
|
+
updateBorders(doc, props, paragraph2, base);
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
// docx/write-paragraph-properties.ts
|
|
4292
|
+
function setAttribute(element4, local, value) {
|
|
4293
|
+
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
4294
|
+
}
|
|
4295
|
+
function setWordValue(element4, local, value) {
|
|
4296
|
+
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
4297
|
+
else setAttribute(element4, local, String(value));
|
|
4298
|
+
}
|
|
4299
|
+
function updateDirection(doc, props, paragraph2, base) {
|
|
4300
|
+
if (base && paragraph2.direction === base.direction) return;
|
|
4301
|
+
let bidi = first2(props, "bidi");
|
|
4302
|
+
if (paragraph2.direction === void 0) {
|
|
4303
|
+
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
4304
|
+
} else {
|
|
4305
|
+
if (!bidi) {
|
|
4306
|
+
bidi = makeW(doc, "bidi");
|
|
4307
|
+
props.appendChild(bidi);
|
|
4308
|
+
}
|
|
4309
|
+
setAttribute(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
function updateSpacing(doc, props, paragraph2, base) {
|
|
4313
|
+
let spacing3 = first2(props, "spacing");
|
|
4314
|
+
if (!spacing3) {
|
|
4315
|
+
spacing3 = makeW(doc, "spacing");
|
|
4316
|
+
props.appendChild(spacing3);
|
|
4317
|
+
}
|
|
4318
|
+
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
4319
|
+
setWordValue(spacing3, "before", paragraph2.spacingBeforeTwips);
|
|
4320
|
+
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
4321
|
+
setWordValue(spacing3, "after", paragraph2.spacingAfterTwips);
|
|
4322
|
+
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
4323
|
+
setWordValue(spacing3, "line", paragraph2.lineSpacingTwips);
|
|
4324
|
+
setWordValue(
|
|
4325
|
+
spacing3,
|
|
4326
|
+
"lineRule",
|
|
4327
|
+
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
4328
|
+
);
|
|
4329
|
+
}
|
|
4330
|
+
if (!spacing3.attributes.length && !spacing3.childNodes.length) props.removeChild(spacing3);
|
|
4331
|
+
}
|
|
4332
|
+
function updateIndent(doc, props, paragraph2, base) {
|
|
4333
|
+
let indent = first2(props, "ind");
|
|
4334
|
+
if (!indent) {
|
|
4335
|
+
indent = makeW(doc, "ind");
|
|
4336
|
+
props.appendChild(indent);
|
|
4337
|
+
}
|
|
4338
|
+
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
4339
|
+
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
4340
|
+
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
4341
|
+
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
4342
|
+
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
4343
|
+
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
4344
|
+
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
4345
|
+
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
4346
|
+
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
4347
|
+
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
4348
|
+
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
4349
|
+
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
4350
|
+
if (!indent.attributes.length) props.removeChild(indent);
|
|
4351
|
+
}
|
|
4352
|
+
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
4353
|
+
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
4354
|
+
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
4355
|
+
if (paragraph2.pageBreakBefore !== void 0) {
|
|
4356
|
+
const element4 = makeW(doc, "pageBreakBefore");
|
|
4357
|
+
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
4358
|
+
props.appendChild(element4);
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
4362
|
+
for (const key of [
|
|
4363
|
+
"keepNext",
|
|
4364
|
+
"keepLines",
|
|
4365
|
+
"widowControl",
|
|
4366
|
+
"contextualSpacing",
|
|
4367
|
+
"suppressLineNumbers"
|
|
4368
|
+
]) {
|
|
4369
|
+
if (base && paragraph2[key] === base[key]) continue;
|
|
4370
|
+
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
4371
|
+
const value = paragraph2[key];
|
|
4372
|
+
if (value === void 0) continue;
|
|
4373
|
+
const element4 = makeW(doc, key);
|
|
4374
|
+
if (!value) setAttribute(element4, "val", "0");
|
|
4375
|
+
props.appendChild(element4);
|
|
4376
|
+
}
|
|
4377
|
+
}
|
|
4378
|
+
function updateDropCap(doc, props, paragraph2, base) {
|
|
4379
|
+
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
4380
|
+
let frame2 = first2(props, "framePr");
|
|
4381
|
+
const cap = paragraph2.dropCap;
|
|
4382
|
+
if (!cap) {
|
|
4383
|
+
if (frame2) props.removeChild(frame2);
|
|
4384
|
+
return;
|
|
4385
|
+
}
|
|
4386
|
+
if (!frame2) {
|
|
4387
|
+
frame2 = makeW(doc, "framePr");
|
|
4388
|
+
props.appendChild(frame2);
|
|
4389
|
+
setAttribute(frame2, "wrap", "around");
|
|
4390
|
+
setAttribute(frame2, "vAnchor", "text");
|
|
4391
|
+
setAttribute(frame2, "hAnchor", "text");
|
|
4392
|
+
}
|
|
4393
|
+
setAttribute(frame2, "dropCap", cap.style);
|
|
4394
|
+
setAttribute(frame2, "lines", String(cap.lines));
|
|
4395
|
+
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
4396
|
+
}
|
|
4397
|
+
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
4398
|
+
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
4399
|
+
updateKeepOptions(doc, props, paragraph2, base);
|
|
4400
|
+
updateDropCap(doc, props, paragraph2, base);
|
|
4401
|
+
updateDirection(doc, props, paragraph2, base);
|
|
4402
|
+
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
4403
|
+
const spacingKeys = [
|
|
4404
|
+
"spacingBeforeTwips",
|
|
4405
|
+
"spacingAfterTwips",
|
|
4406
|
+
"lineSpacingTwips",
|
|
4407
|
+
"lineSpacingRule"
|
|
4408
|
+
];
|
|
4409
|
+
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
4410
|
+
updateSpacing(doc, props, paragraph2, base);
|
|
4411
|
+
const indentKeys = [
|
|
4412
|
+
"indentLeftTwips",
|
|
4413
|
+
"indentRightTwips",
|
|
4414
|
+
"indentStartTwips",
|
|
4415
|
+
"indentEndTwips",
|
|
4416
|
+
"firstLineTwips",
|
|
4417
|
+
"hangingTwips"
|
|
4418
|
+
];
|
|
4419
|
+
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
4420
|
+
updateIndent(doc, props, paragraph2, base);
|
|
4421
|
+
}
|
|
4422
|
+
|
|
4423
|
+
// docx/style-formatting-package.ts
|
|
4424
|
+
var STYLES_PART = "word/styles.xml";
|
|
4425
|
+
var AFTER_PPR = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
4426
|
+
var WRITABLE_STYLE_FORMATTING = [
|
|
4427
|
+
"align",
|
|
4428
|
+
"justification",
|
|
4429
|
+
"direction",
|
|
4430
|
+
"spacingBeforeTwips",
|
|
4431
|
+
"spacingAfterTwips",
|
|
4432
|
+
"lineSpacingTwips",
|
|
4433
|
+
"lineSpacingRule",
|
|
4434
|
+
"indentLeftTwips",
|
|
4435
|
+
"indentRightTwips",
|
|
4436
|
+
"indentStartTwips",
|
|
4437
|
+
"indentEndTwips",
|
|
4438
|
+
"firstLineTwips",
|
|
4439
|
+
"hangingTwips",
|
|
4440
|
+
"pageBreakBefore",
|
|
4441
|
+
"keepNext",
|
|
4442
|
+
"keepLines",
|
|
4443
|
+
"widowControl",
|
|
4444
|
+
"contextualSpacing",
|
|
4445
|
+
"suppressLineNumbers",
|
|
4446
|
+
"borders",
|
|
4447
|
+
"shadingFill"
|
|
4448
|
+
];
|
|
4449
|
+
function unwritableFormatting(formatting) {
|
|
4450
|
+
const rest = { ...formatting };
|
|
4451
|
+
for (const key of WRITABLE_STYLE_FORMATTING) delete rest[key];
|
|
4452
|
+
return rest;
|
|
4453
|
+
}
|
|
4454
|
+
var asParagraph = (formatting) => ({
|
|
4455
|
+
type: "paragraph",
|
|
4456
|
+
id: "style",
|
|
4457
|
+
runs: [],
|
|
4458
|
+
...formatting
|
|
4459
|
+
});
|
|
4460
|
+
function pPrOf(style) {
|
|
4461
|
+
let pPr = first2(style, "pPr");
|
|
4462
|
+
if (pPr) return pPr;
|
|
4463
|
+
pPr = makeW(style.ownerDocument, "pPr");
|
|
4464
|
+
const anchor = Array.from(style.childNodes).find(
|
|
4465
|
+
(node) => node.nodeType === 1 && AFTER_PPR.includes(node.localName)
|
|
4466
|
+
) ?? null;
|
|
4467
|
+
style.insertBefore(pPr, anchor);
|
|
4468
|
+
return pPr;
|
|
4469
|
+
}
|
|
4470
|
+
async function applyStyleFormatting(zip, model, base) {
|
|
4471
|
+
const next = model.paragraphStyles?.styles ?? {};
|
|
4472
|
+
const prior = base.paragraphStyles?.styles ?? {};
|
|
4473
|
+
const changed = Object.keys(next).filter(
|
|
4474
|
+
(id) => JSON.stringify(next[id]?.formatting) !== JSON.stringify(prior[id]?.formatting)
|
|
4475
|
+
);
|
|
4476
|
+
if (!changed.length) return;
|
|
4477
|
+
const file = zip.file(STYLES_PART);
|
|
4478
|
+
if (!file) throw new Error("Cannot edit a style: the package has no styles.xml.");
|
|
4479
|
+
const doc = parseXml2(await file.async("string"));
|
|
4480
|
+
const styles = children2(doc.documentElement, "style");
|
|
4481
|
+
for (const id of changed) {
|
|
4482
|
+
const style = styles.find(
|
|
4483
|
+
(element4) => getW(element4, "type") === "paragraph" && getW(element4, "styleId") === id
|
|
4484
|
+
);
|
|
4485
|
+
if (!style) throw new Error(`Cannot edit style "${id}": it is not in styles.xml.`);
|
|
4486
|
+
const after = asParagraph(next[id].formatting);
|
|
4487
|
+
const before = asParagraph(prior[id]?.formatting ?? {});
|
|
4488
|
+
const pPr = pPrOf(style);
|
|
4489
|
+
if (after.align !== before.align || after.justification !== before.justification || after.direction !== before.direction) {
|
|
4490
|
+
for (const jc of children2(pPr, "jc")) pPr.removeChild(jc);
|
|
4491
|
+
const value = paragraphJustification(after);
|
|
4492
|
+
if (value) {
|
|
4493
|
+
const jc = makeW(doc, "jc");
|
|
4494
|
+
jc.setAttributeNS(WORD_NS, "w:val", value);
|
|
4495
|
+
pPr.appendChild(jc);
|
|
4496
|
+
}
|
|
4497
|
+
}
|
|
4498
|
+
writeParagraphProperties(doc, pPr, after, before);
|
|
4499
|
+
orderParagraphProperties(pPr);
|
|
4500
|
+
}
|
|
4501
|
+
zip.file(STYLES_PART, buildXml(doc));
|
|
4502
|
+
}
|
|
4503
|
+
|
|
4504
|
+
// docx/data-binding.ts
|
|
4505
|
+
function parsePrefixes(text2) {
|
|
4506
|
+
const map = /* @__PURE__ */ new Map();
|
|
4507
|
+
for (const match of (text2 ?? "").matchAll(/xmlns:([\w.-]+)\s*=\s*(?:'([^']*)'|"([^"]*)")/g))
|
|
4508
|
+
map.set(match[1], match[2] ?? match[3] ?? "");
|
|
4509
|
+
return map;
|
|
4510
|
+
}
|
|
4511
|
+
function sourceBindings(sourceXml) {
|
|
4512
|
+
const result = /* @__PURE__ */ new Map();
|
|
4513
|
+
const document = parseXml2(sourceXml);
|
|
4514
|
+
for (const sdt of Array.from(document.getElementsByTagNameNS(WORD_NS, "sdt"))) {
|
|
4515
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
4516
|
+
const element4 = sdtPr && elements(sdtPr).find((node) => node.localName === "dataBinding");
|
|
4517
|
+
const id = getW(first2(sdtPr, "id"), "val");
|
|
4518
|
+
const xpath = element4?.getAttributeNS(WORD_NS, "xpath");
|
|
4519
|
+
const storeItemId = element4?.getAttributeNS(WORD_NS, "storeItemID");
|
|
4520
|
+
if (id && element4 && xpath && storeItemId)
|
|
4521
|
+
result.set(id, {
|
|
4522
|
+
xpath,
|
|
4523
|
+
storeItemId,
|
|
4524
|
+
prefixes: parsePrefixes(element4.getAttributeNS(WORD_NS, "prefixMappings") ?? void 0)
|
|
4525
|
+
});
|
|
4526
|
+
}
|
|
4527
|
+
return result;
|
|
4528
|
+
}
|
|
4529
|
+
function paragraphsOf(blocks) {
|
|
4530
|
+
return blocks.flatMap(
|
|
4531
|
+
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((c2) => c2.paragraphs))
|
|
4532
|
+
);
|
|
4533
|
+
}
|
|
4534
|
+
function boundTexts(model) {
|
|
4535
|
+
const parts = /* @__PURE__ */ new Map();
|
|
4536
|
+
const add4 = (id, text2) => parts.set(id, [...parts.get(id) ?? [], text2]);
|
|
4537
|
+
for (const paragraph2 of paragraphsOf(model.blocks)) {
|
|
4538
|
+
const own2 = paragraph2.contentControl;
|
|
4539
|
+
if (own2?.dataBound) {
|
|
4540
|
+
add4(own2.id, paragraph2.runs.map((run2) => run2.text).join(""));
|
|
4541
|
+
continue;
|
|
4542
|
+
}
|
|
4543
|
+
const inline = /* @__PURE__ */ new Map();
|
|
4544
|
+
for (const run2 of paragraph2.runs) {
|
|
4545
|
+
const control = run2.contentControl;
|
|
4546
|
+
if (!control?.dataBound) continue;
|
|
4547
|
+
if (!inline.has(control.id)) inline.set(control.id, "");
|
|
4548
|
+
if (!control.showingPlaceholder) inline.set(control.id, inline.get(control.id) + run2.text);
|
|
4549
|
+
}
|
|
4550
|
+
for (const [id, text2] of inline) add4(id, text2);
|
|
4551
|
+
}
|
|
4552
|
+
return new Map([...parts].map(([id, texts]) => [id, texts.join("\n")]));
|
|
4553
|
+
}
|
|
4554
|
+
function parseXPath(binding) {
|
|
4555
|
+
const parts = binding.xpath.split("/");
|
|
4556
|
+
if (parts.shift() !== "" || !parts.length) return void 0;
|
|
4557
|
+
if (parts.at(-1) === "text()") parts.pop();
|
|
4558
|
+
const parse = (raw2, attribute3) => {
|
|
4559
|
+
const match = /^(?:([A-Za-z_][\w.-]*):)?([A-Za-z_][\w.-]*)(?:\[(\d+)\])?$/.exec(raw2);
|
|
4560
|
+
if (!match || attribute3 && match[3]) return void 0;
|
|
4561
|
+
const [, prefix2 = "", name = "", index] = match;
|
|
4562
|
+
if (prefix2 && !binding.prefixes.has(prefix2)) return void 0;
|
|
4563
|
+
return { prefix: prefix2, name, index: index ? Number(index) : 1 };
|
|
4564
|
+
};
|
|
4565
|
+
const last = parts.at(-1);
|
|
4566
|
+
const attribute2 = last?.startsWith("@") ? parse(last.slice(1), true) : void 0;
|
|
4567
|
+
if (last?.startsWith("@")) {
|
|
4568
|
+
parts.pop();
|
|
4569
|
+
if (!attribute2) return void 0;
|
|
4570
|
+
}
|
|
4571
|
+
const steps = parts.map((part) => parse(part, false));
|
|
4572
|
+
if (!steps.length || steps.some((step) => !step)) return void 0;
|
|
4573
|
+
return { steps, ...attribute2 ? { attribute: attribute2 } : {} };
|
|
4574
|
+
}
|
|
4575
|
+
var matches = (element4, step, binding) => element4.localName === step.name && (element4.namespaceURI ?? "") === (step.prefix ? binding.prefixes.get(step.prefix) ?? "" : "");
|
|
4576
|
+
function writeValue(root, binding, value) {
|
|
4577
|
+
const path3 = parseXPath(binding);
|
|
4578
|
+
if (!path3) return "unsupported";
|
|
4579
|
+
let node = root;
|
|
4580
|
+
for (const [depth, step] of path3.steps.entries()) {
|
|
4581
|
+
const candidates = depth === 0 ? [root].filter((e) => matches(e, step, binding)) : elements(node).filter((e) => matches(e, step, binding));
|
|
4582
|
+
node = candidates[step.index - 1];
|
|
4583
|
+
if (!node) return false;
|
|
4584
|
+
}
|
|
4585
|
+
if (path3.attribute) {
|
|
4586
|
+
const { prefix: prefix2, name } = path3.attribute;
|
|
4587
|
+
const ns = prefix2 ? binding.prefixes.get(prefix2) : void 0;
|
|
4588
|
+
if (ns) node.setAttributeNS(ns, `${prefix2}:${name}`, value);
|
|
4589
|
+
else node.setAttribute(name, value);
|
|
4590
|
+
return true;
|
|
4591
|
+
}
|
|
4592
|
+
for (const child7 of Array.from(node.childNodes)) node.removeChild(child7);
|
|
4593
|
+
if (value) node.appendChild(node.ownerDocument.createTextNode(value));
|
|
4594
|
+
return true;
|
|
4595
|
+
}
|
|
4596
|
+
async function findItemPart(zip, storeItemId) {
|
|
4597
|
+
const wanted = storeItemId.toLowerCase();
|
|
4598
|
+
for (const name of Object.keys(zip.files)) {
|
|
4599
|
+
const props = /^customXml\/itemProps(\d+)\.xml$/.exec(name);
|
|
4600
|
+
if (!props) continue;
|
|
4601
|
+
const root = parseXml2(await zip.file(name).async("string")).documentElement;
|
|
4602
|
+
const id = Array.from(root.attributes).find((attribute2) => attribute2.localName === "itemID");
|
|
4603
|
+
if ((id?.value ?? "").toLowerCase() === wanted) return `customXml/item${props[1]}.xml`;
|
|
4604
|
+
}
|
|
4605
|
+
return void 0;
|
|
4606
|
+
}
|
|
4607
|
+
async function applyDataBindings(zip, model, base, sourceXml) {
|
|
4608
|
+
const now = boundTexts(model);
|
|
4609
|
+
if (!now.size) return;
|
|
4610
|
+
const before = boundTexts(base);
|
|
4611
|
+
const bindings = sourceBindings(sourceXml);
|
|
4612
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
4613
|
+
for (const [id, text2] of now) {
|
|
4614
|
+
const binding = bindings.get(id);
|
|
4615
|
+
if (!binding || before.get(id) === text2) continue;
|
|
4616
|
+
const part = await findItemPart(zip, binding.storeItemId);
|
|
4617
|
+
const file = part ? zip.file(part) : void 0;
|
|
4618
|
+
if (!part || !file) continue;
|
|
4619
|
+
const document = parsed.get(part) ?? parseXml2(await file.async("string"));
|
|
4620
|
+
parsed.set(part, document);
|
|
4621
|
+
const written = writeValue(document.documentElement, binding, text2);
|
|
4622
|
+
if (written !== true)
|
|
4623
|
+
throw new Error(
|
|
4624
|
+
written === "unsupported" ? `Cannot update the data-bound content control ${id}: the XPath ${binding.xpath} is not supported, so Word would keep showing the old bound value. The original DOCX package remains unchanged.` : `Cannot update the data-bound content control ${id}: the XPath ${binding.xpath} selects no node in ${part}. The original DOCX package remains unchanged.`
|
|
4625
|
+
);
|
|
4626
|
+
}
|
|
4627
|
+
for (const [part, document] of parsed) zip.file(part, buildXml(document));
|
|
4628
|
+
}
|
|
4629
|
+
|
|
4630
|
+
// docx/content-control.ts
|
|
4631
|
+
var WORD_2012_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
4632
|
+
var sdtContent = (sdt) => first2(sdt, "sdtContent");
|
|
4633
|
+
var isSdt = (element4) => named2(element4, "sdt");
|
|
4634
|
+
var TYPE_ELEMENTS = {
|
|
4635
|
+
text: "text",
|
|
4636
|
+
dropDownList: "dropDownList",
|
|
4637
|
+
comboBox: "comboBox",
|
|
4638
|
+
date: "date",
|
|
4639
|
+
picture: "picture",
|
|
4640
|
+
group: "group",
|
|
4641
|
+
equation: "equation",
|
|
4642
|
+
citation: "citation",
|
|
4643
|
+
bibliography: "bibliography",
|
|
4644
|
+
docPartObj: "docPartObj",
|
|
4645
|
+
docPartList: "docPartList"
|
|
4646
|
+
};
|
|
4647
|
+
function attrW14(element4, local) {
|
|
4648
|
+
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
4649
|
+
}
|
|
4650
|
+
function glyph(element4) {
|
|
4651
|
+
const code = attrW14(element4, "val");
|
|
4652
|
+
if (!code) return void 0;
|
|
4653
|
+
const font = attrW14(element4, "font");
|
|
4654
|
+
return { code, ...font ? { font } : {} };
|
|
4655
|
+
}
|
|
4656
|
+
function kindOf(child7) {
|
|
4657
|
+
if (child7.namespaceURI === WORD_NS)
|
|
4658
|
+
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
4659
|
+
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
4660
|
+
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
4661
|
+
return "repeatingSection";
|
|
4662
|
+
return void 0;
|
|
4663
|
+
}
|
|
4664
|
+
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
4665
|
+
(child7) => kindOf(child7) !== void 0 || child7.namespaceURI === WORD_NS && child7.localName === "richText" || child7.namespaceURI === WORD_2010_NS && child7.localName === "entityPicker" || child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSectionItem"
|
|
4666
|
+
);
|
|
4667
|
+
function parseKind(sdtPr) {
|
|
4668
|
+
const [type] = typeElements(sdtPr);
|
|
4669
|
+
return (type && kindOf(type)) ?? "richText";
|
|
4670
|
+
}
|
|
4671
|
+
var generated = 0;
|
|
4672
|
+
function parseContentControl(sdt, level4) {
|
|
4673
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
4674
|
+
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level4, kind: "richText" };
|
|
4675
|
+
const kind = parseKind(sdtPr);
|
|
4676
|
+
const control = {
|
|
4677
|
+
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
4678
|
+
level: level4,
|
|
4679
|
+
kind
|
|
4680
|
+
};
|
|
4681
|
+
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
4682
|
+
if (alias !== void 0) control.alias = alias;
|
|
4683
|
+
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
4684
|
+
if (tag !== void 0) control.tag = tag;
|
|
4685
|
+
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
4686
|
+
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
4687
|
+
control.lock = lock;
|
|
4688
|
+
const showing = first2(sdtPr, "showingPlcHdr");
|
|
4689
|
+
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
4690
|
+
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
4691
|
+
const temporary = first2(sdtPr, "temporary");
|
|
4692
|
+
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
4693
|
+
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
4694
|
+
if (placeholder) control.placeholder = placeholder;
|
|
4695
|
+
if (kind === "text") {
|
|
4696
|
+
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
4697
|
+
if (multi) control.multiLine = true;
|
|
4698
|
+
}
|
|
4699
|
+
if (kind === "checkbox") {
|
|
4700
|
+
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
4701
|
+
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
4702
|
+
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
4703
|
+
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
4704
|
+
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
4705
|
+
if (on) control.checkedGlyph = on;
|
|
4706
|
+
if (off) control.uncheckedGlyph = off;
|
|
4707
|
+
}
|
|
4708
|
+
if (kind === "dropDownList" || kind === "comboBox") {
|
|
4709
|
+
const list2 = first2(sdtPr, kind);
|
|
4710
|
+
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
4711
|
+
const display = getW(item2, "displayText");
|
|
4712
|
+
const value = getW(item2, "value") ?? display ?? "";
|
|
4713
|
+
return { display: display ?? value, value };
|
|
4714
|
+
});
|
|
4715
|
+
}
|
|
4716
|
+
if (kind === "date") {
|
|
4717
|
+
const date = first2(sdtPr, "date");
|
|
4718
|
+
const fullDate = getW(date, "fullDate");
|
|
4719
|
+
if (fullDate) control.fullDate = fullDate;
|
|
4720
|
+
const format = getW(first2(date, "dateFormat"), "val");
|
|
4721
|
+
if (format) control.dateFormat = format;
|
|
4722
|
+
const lid = getW(first2(date, "lid"), "val");
|
|
4723
|
+
if (lid) control.dateLocale = lid;
|
|
4724
|
+
}
|
|
4725
|
+
control.sourceXml = buildXml(sdtPr);
|
|
4726
|
+
const end = first2(sdt, "sdtEndPr");
|
|
4727
|
+
if (end) control.endSourceXml = buildXml(end);
|
|
4728
|
+
return control;
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4731
|
+
// docx/expect-defined.ts
|
|
4732
|
+
function expectDefined(value, context) {
|
|
4733
|
+
if (value === void 0 || value === null) {
|
|
4734
|
+
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
4735
|
+
}
|
|
4736
|
+
return value;
|
|
4737
|
+
}
|
|
4738
|
+
|
|
4739
|
+
// docx/parse-revisions.ts
|
|
4740
|
+
var REVISION_WRAPPERS = {
|
|
4741
|
+
ins: "insert",
|
|
4742
|
+
del: "delete",
|
|
4743
|
+
moveFrom: "moveFrom",
|
|
4744
|
+
moveTo: "moveTo"
|
|
4745
|
+
};
|
|
4746
|
+
var MOVE_RANGES = {
|
|
4747
|
+
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
4748
|
+
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
4749
|
+
moveToRangeStart: { kind: "moveTo", start: true },
|
|
4750
|
+
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
4751
|
+
};
|
|
4752
|
+
function trackMoveRange(item2, moves) {
|
|
4753
|
+
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
4754
|
+
const range2 = MOVE_RANGES[item2.localName ?? ""];
|
|
4755
|
+
if (!range2) return false;
|
|
4756
|
+
const id = getW(item2, "id") ?? "";
|
|
4757
|
+
const open = moves[range2.kind];
|
|
4758
|
+
if (range2.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
4759
|
+
else {
|
|
4760
|
+
const index = open.findIndex((entry2) => entry2.id === id);
|
|
4761
|
+
if (index >= 0) open.splice(index, 1);
|
|
4762
|
+
}
|
|
4763
|
+
return true;
|
|
4764
|
+
}
|
|
4765
|
+
function isCommentReferenceRun(run2) {
|
|
4766
|
+
const content = Array.from(run2.childNodes).filter(
|
|
4767
|
+
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
4768
|
+
);
|
|
4769
|
+
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
4770
|
+
}
|
|
4771
|
+
function revisionFrom(node, kind) {
|
|
4772
|
+
const revision = {
|
|
4773
|
+
kind,
|
|
4774
|
+
author: getW(node, "author") || "Unknown",
|
|
4775
|
+
id: getW(node, "id") ?? "0"
|
|
4776
|
+
};
|
|
4777
|
+
const date = getW(node, "date");
|
|
4778
|
+
if (date) revision.date = date;
|
|
4779
|
+
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
4780
|
+
if (dateUtc) revision.dateUtc = dateUtc;
|
|
4781
|
+
return revision;
|
|
4782
|
+
}
|
|
4783
|
+
function paragraphMarkRevision(pPr) {
|
|
4784
|
+
const rPr = first2(pPr, "rPr");
|
|
4785
|
+
const ins = first2(rPr, "ins");
|
|
4786
|
+
if (ins) return revisionFrom(ins, "insert");
|
|
4787
|
+
const del = first2(rPr, "del");
|
|
4788
|
+
if (del) return revisionFrom(del, "delete");
|
|
4789
|
+
return void 0;
|
|
4790
|
+
}
|
|
4791
|
+
function paragraphFormatRevision(pPr) {
|
|
4792
|
+
const change = first2(pPr, "pPrChange");
|
|
4793
|
+
if (!change) return void 0;
|
|
4794
|
+
const revision = revisionFrom(change, "paragraphChange");
|
|
4795
|
+
const previous = first2(change, "pPr");
|
|
4796
|
+
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
4797
|
+
return revision;
|
|
4798
|
+
}
|
|
4799
|
+
function runFormatRevision(rPr) {
|
|
4800
|
+
const change = first2(rPr, "rPrChange");
|
|
4801
|
+
if (!change) return void 0;
|
|
4802
|
+
const revision = revisionFrom(change, "formatChange");
|
|
4803
|
+
const previous = first2(change, "rPr");
|
|
4804
|
+
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
4805
|
+
return revision;
|
|
4806
|
+
}
|
|
4807
|
+
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
4808
|
+
const runs = [];
|
|
4809
|
+
let hasMove = false;
|
|
4810
|
+
const push = (run2) => {
|
|
4811
|
+
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
4812
|
+
runs.push(run2);
|
|
4813
|
+
};
|
|
4814
|
+
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
4815
|
+
if (named2(item2, "r")) {
|
|
4816
|
+
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
4817
|
+
} else if (named2(item2, "hyperlink")) {
|
|
4818
|
+
const link = resolveLink?.(item2);
|
|
4819
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4820
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
4821
|
+
if (link) parsed.link = link;
|
|
4822
|
+
push(parsed);
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
4826
|
+
const kind = expectDefined(
|
|
4827
|
+
REVISION_WRAPPERS[item2.localName],
|
|
4828
|
+
`revision wrapper ${item2.localName}`
|
|
4829
|
+
);
|
|
4830
|
+
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
4831
|
+
const revision = revisionFrom(item2, kind);
|
|
4832
|
+
const range2 = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
4833
|
+
if (range2) revision.move = { name: range2.name, rangeId: range2.id };
|
|
4834
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4835
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
4836
|
+
parsed.revision = revision;
|
|
4837
|
+
push(parsed);
|
|
4838
|
+
}
|
|
4839
|
+
}
|
|
4840
|
+
} else if (trackMoveRange(item2, moves)) {
|
|
4841
|
+
continue;
|
|
4842
|
+
} else if (named2(item2, "commentRangeStart")) {
|
|
4843
|
+
const id = getW(item2, "id");
|
|
4844
|
+
if (id !== void 0) active.push(id);
|
|
4845
|
+
} else if (named2(item2, "commentRangeEnd")) {
|
|
4846
|
+
const id = getW(item2, "id");
|
|
4847
|
+
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
4848
|
+
if (index >= 0) active.splice(index, 1);
|
|
4849
|
+
} else {
|
|
4850
|
+
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
return { runs, hasMove };
|
|
4854
|
+
}
|
|
4855
|
+
|
|
4856
|
+
// docx/parse-content-control.ts
|
|
4857
|
+
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
4858
|
+
const control = parseContentControl(sdt, "inline");
|
|
4859
|
+
const content = sdtContent(sdt);
|
|
4860
|
+
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
4861
|
+
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
4862
|
+
for (const run2 of runs) run2.contentControl ??= control;
|
|
4863
|
+
return runs;
|
|
4864
|
+
}
|
|
4865
|
+
function flatChildren(parent, names, level4 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
4866
|
+
const found = [];
|
|
4867
|
+
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
4868
|
+
if (isSdt(child7)) {
|
|
4869
|
+
const content = sdtContent(child7);
|
|
4870
|
+
if (!content) continue;
|
|
4871
|
+
let control = controls.get(child7);
|
|
4872
|
+
if (!control) {
|
|
4873
|
+
control = parseContentControl(child7, level4);
|
|
4874
|
+
controls.set(child7, control);
|
|
4875
|
+
}
|
|
4876
|
+
found.push(...flatChildren(content, names, level4, { control, sdt: child7 }, controls));
|
|
4877
|
+
} else if (names.some((name) => named2(child7, name)))
|
|
4878
|
+
found.push({
|
|
4879
|
+
element: child7,
|
|
4880
|
+
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
4881
|
+
});
|
|
4882
|
+
}
|
|
4883
|
+
return found;
|
|
4884
|
+
}
|
|
4885
|
+
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
4886
|
+
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
4887
|
+
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
4888
|
+
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
4889
|
+
|
|
4147
4890
|
// docx/content-control-values.ts
|
|
4148
4891
|
var validLock = (lock) => lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked" ? lock : void 0;
|
|
4149
4892
|
function validId(id) {
|
|
@@ -4369,15 +5112,15 @@ function writeDate(doc, sdtPr, control) {
|
|
|
4369
5112
|
const fullDate = validDate(control.fullDate) ?? (control.fullDate === existing ? existing : void 0);
|
|
4370
5113
|
if (fullDate) date.setAttributeNS(WORD_NS, "w:fullDate", fullDate);
|
|
4371
5114
|
else date.removeAttributeNS(WORD_NS, "fullDate");
|
|
4372
|
-
const
|
|
5115
|
+
const set2 = (local, value, order) => {
|
|
4373
5116
|
for (const old of children2(date, local)) date.removeChild(old);
|
|
4374
5117
|
if (typeof value !== "string") return;
|
|
4375
5118
|
const element4 = makeW(doc, local);
|
|
4376
5119
|
element4.setAttributeNS(WORD_NS, "w:val", value);
|
|
4377
5120
|
date.insertBefore(element4, Array.from(date.childNodes)[order] ?? null);
|
|
4378
5121
|
};
|
|
4379
|
-
|
|
4380
|
-
|
|
5122
|
+
set2("dateFormat", control.dateFormat, 0);
|
|
5123
|
+
set2("lid", control.dateLocale, 1);
|
|
4381
5124
|
}
|
|
4382
5125
|
var writesType = (kind) => NAMED_TYPES.has(kind) || ["richText", "text", "checkbox", "dropDownList", "comboBox", "date"].includes(kind);
|
|
4383
5126
|
function patchContentControl(doc, sdt, control) {
|
|
@@ -4555,13 +5298,13 @@ function rangeKeys(run2) {
|
|
|
4555
5298
|
keys.push(`${revision.kind}:${revision.move.name}`);
|
|
4556
5299
|
return keys;
|
|
4557
5300
|
}
|
|
4558
|
-
function
|
|
5301
|
+
function paragraphsOf2(blocks) {
|
|
4559
5302
|
return blocks.flatMap(
|
|
4560
5303
|
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell2) => cell2.paragraphs))
|
|
4561
5304
|
);
|
|
4562
5305
|
}
|
|
4563
5306
|
function commentContinuations(blocks) {
|
|
4564
|
-
const paragraphs =
|
|
5307
|
+
const paragraphs = paragraphsOf2(blocks);
|
|
4565
5308
|
const first3 = /* @__PURE__ */ new Map();
|
|
4566
5309
|
const last = /* @__PURE__ */ new Map();
|
|
4567
5310
|
const idsByParagraph = paragraphs.map((paragraph2, index) => {
|
|
@@ -4626,7 +5369,7 @@ var COMMENTS_PATH = "word/comments.xml";
|
|
|
4626
5369
|
var COMMENTS_EXTENDED_PATH = "word/commentsExtended.xml";
|
|
4627
5370
|
var W14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
4628
5371
|
var W15_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
4629
|
-
function
|
|
5372
|
+
function setAttribute2(element4, local, value) {
|
|
4630
5373
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
4631
5374
|
}
|
|
4632
5375
|
function paraIdFor(id, index) {
|
|
@@ -4641,10 +5384,10 @@ function buildCommentsDocument(comments) {
|
|
|
4641
5384
|
const root = doc.documentElement;
|
|
4642
5385
|
comments.forEach((comment, index) => {
|
|
4643
5386
|
const el5 = makeW(doc, "comment");
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
if (comment.date)
|
|
4647
|
-
if (comment.initials)
|
|
5387
|
+
setAttribute2(el5, "id", comment.id);
|
|
5388
|
+
setAttribute2(el5, "author", comment.author);
|
|
5389
|
+
if (comment.date) setAttribute2(el5, "date", comment.date);
|
|
5390
|
+
if (comment.initials) setAttribute2(el5, "initials", comment.initials);
|
|
4648
5391
|
const p = makeW(doc, "p");
|
|
4649
5392
|
p.setAttributeNS(W14_NS, "w14:paraId", paraIdFor(comment.id, index));
|
|
4650
5393
|
const r = makeW(doc, "r");
|
|
@@ -4708,15 +5451,15 @@ async function applyComments(zip, comments) {
|
|
|
4708
5451
|
}
|
|
4709
5452
|
function commentRangeStartNode(doc, id) {
|
|
4710
5453
|
const element4 = makeW(doc, "commentRangeStart");
|
|
4711
|
-
|
|
5454
|
+
setAttribute2(element4, "id", id);
|
|
4712
5455
|
return element4;
|
|
4713
5456
|
}
|
|
4714
5457
|
function commentRangeEndNodes(doc, id) {
|
|
4715
5458
|
const end = makeW(doc, "commentRangeEnd");
|
|
4716
|
-
|
|
5459
|
+
setAttribute2(end, "id", id);
|
|
4717
5460
|
const run2 = makeW(doc, "r");
|
|
4718
5461
|
const reference = makeW(doc, "commentReference");
|
|
4719
|
-
|
|
5462
|
+
setAttribute2(reference, "id", id);
|
|
4720
5463
|
run2.appendChild(reference);
|
|
4721
5464
|
return [end, run2];
|
|
4722
5465
|
}
|
|
@@ -4970,10 +5713,10 @@ function buildRowProperties(doc, row, gridAfter) {
|
|
|
4970
5713
|
}
|
|
4971
5714
|
|
|
4972
5715
|
// docx/write-table-margins.ts
|
|
4973
|
-
var
|
|
5716
|
+
var SIDES4 = ["top", "left", "bottom", "right"];
|
|
4974
5717
|
var ORDER2 = ["top", "start", "left", "bottom", "end", "right"];
|
|
4975
5718
|
function patchMarginProperties(doc, host, propertiesTag, marginTag, propertiesOrder, next, base) {
|
|
4976
|
-
const changed =
|
|
5719
|
+
const changed = SIDES4.filter((side) => next?.[side] !== base?.[side]);
|
|
4977
5720
|
if (!changed.length) return;
|
|
4978
5721
|
for (const side of changed) {
|
|
4979
5722
|
const value = next?.[side];
|
|
@@ -5297,14 +6040,21 @@ function unwrapDroppedControls(elements2, next) {
|
|
|
5297
6040
|
});
|
|
5298
6041
|
}
|
|
5299
6042
|
|
|
5300
|
-
// docx/
|
|
6043
|
+
// docx/table-structure-check.ts
|
|
6044
|
+
var only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
6045
|
+
function plainParagraphs(cell2) {
|
|
6046
|
+
for (const paragraph2 of children2(cell2, "p")) {
|
|
6047
|
+
if (!only(paragraph2, ["pPr", "r"])) return false;
|
|
6048
|
+
for (const run2 of children2(paragraph2, "r"))
|
|
6049
|
+
if (!only(run2, ["rPr", "t", "tab", "br", "cr", "noBreakHyphen"])) return false;
|
|
6050
|
+
}
|
|
6051
|
+
return true;
|
|
6052
|
+
}
|
|
5301
6053
|
function canEditTableStructure(table) {
|
|
5302
|
-
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
5303
6054
|
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
5304
6055
|
const grid = first2(table, "tblGrid");
|
|
5305
6056
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
5306
6057
|
const rows2 = children2(table, "tr");
|
|
5307
|
-
if (!rows2.length) return false;
|
|
5308
6058
|
const [firstRow] = rows2;
|
|
5309
6059
|
if (!firstRow) return false;
|
|
5310
6060
|
const width = children2(firstRow, "tc").length;
|
|
@@ -5320,15 +6070,206 @@ function canEditTableStructure(table) {
|
|
|
5320
6070
|
const props = first2(cell2, "tcPr");
|
|
5321
6071
|
if (props && ["gridSpan", "vMerge", "hMerge", "tcPrChange"].some((key) => first2(props, key)))
|
|
5322
6072
|
return false;
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
6073
|
+
if (!plainParagraphs(cell2)) return false;
|
|
6074
|
+
}
|
|
6075
|
+
}
|
|
6076
|
+
return true;
|
|
6077
|
+
}
|
|
6078
|
+
function canRestructureTable(table) {
|
|
6079
|
+
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
6080
|
+
const grid = first2(table, "tblGrid");
|
|
6081
|
+
if (!grid || !only(grid, ["gridCol"])) return false;
|
|
6082
|
+
const rows2 = children2(table, "tr");
|
|
6083
|
+
if (!rows2.length) return false;
|
|
6084
|
+
for (const row of rows2) {
|
|
6085
|
+
if (!only(row, ["trPr", "tc"]) || !children2(row, "tc").length) return false;
|
|
6086
|
+
const rowProps = first2(row, "trPr");
|
|
6087
|
+
if (rowProps && ["gridBefore", "gridAfter", "wBefore", "wAfter", "trPrChange", "ins", "del"].some(
|
|
6088
|
+
(key) => first2(rowProps, key)
|
|
6089
|
+
))
|
|
6090
|
+
return false;
|
|
6091
|
+
for (const cell2 of children2(row, "tc")) {
|
|
6092
|
+
if (!only(cell2, ["tcPr", "p", "tbl"]) || !children2(cell2, "p").length) return false;
|
|
6093
|
+
const props = first2(cell2, "tcPr");
|
|
6094
|
+
if (props && ["hMerge", "tcPrChange", "cellIns", "cellDel", "cellMerge"].some((key) => first2(props, key)))
|
|
6095
|
+
return false;
|
|
6096
|
+
if (!plainParagraphs(cell2)) return false;
|
|
5328
6097
|
}
|
|
5329
6098
|
}
|
|
5330
6099
|
return true;
|
|
5331
6100
|
}
|
|
6101
|
+
|
|
6102
|
+
// docx/write-table-structure.ts
|
|
6103
|
+
var set = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
6104
|
+
function restructured(next, base) {
|
|
6105
|
+
const shape2 = (table) => JSON.stringify([
|
|
6106
|
+
table.grid,
|
|
6107
|
+
table.rows.map(
|
|
6108
|
+
(row) => row.map((cell2) => [
|
|
6109
|
+
cell2.paragraphs.map((p) => p.id),
|
|
6110
|
+
cell2.gridSpan ?? 1,
|
|
6111
|
+
cell2.verticalMerge ?? "",
|
|
6112
|
+
cell2.widthTwips
|
|
6113
|
+
])
|
|
6114
|
+
)
|
|
6115
|
+
]);
|
|
6116
|
+
return shape2(next) !== shape2(base);
|
|
6117
|
+
}
|
|
6118
|
+
function patchCellLayout(doc, tc, cell2, base) {
|
|
6119
|
+
const span = cell2.gridSpan ?? 1;
|
|
6120
|
+
const width = cell2.widthTwips;
|
|
6121
|
+
if (span === (base.gridSpan ?? 1) && width === base.widthTwips && cell2.verticalMerge === base.verticalMerge)
|
|
6122
|
+
return;
|
|
6123
|
+
let props = first2(tc, "tcPr");
|
|
6124
|
+
if (!props) {
|
|
6125
|
+
props = makeW(doc, "tcPr");
|
|
6126
|
+
tc.insertBefore(props, tc.firstChild);
|
|
6127
|
+
}
|
|
6128
|
+
const replace = (name, next) => {
|
|
6129
|
+
for (const old of children2(props, name)) props.removeChild(old);
|
|
6130
|
+
if (next) props.appendChild(next);
|
|
6131
|
+
};
|
|
6132
|
+
if (width !== base.widthTwips) {
|
|
6133
|
+
const old = first2(props, "tcW");
|
|
6134
|
+
if (width === void 0) replace("tcW", void 0);
|
|
6135
|
+
else {
|
|
6136
|
+
const element4 = old ?? makeW(doc, "tcW");
|
|
6137
|
+
set(element4, "w", String(width));
|
|
6138
|
+
set(element4, "type", "dxa");
|
|
6139
|
+
if (!old) props.appendChild(element4);
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
6142
|
+
if (span !== (base.gridSpan ?? 1)) {
|
|
6143
|
+
const element4 = span > 1 ? makeW(doc, "gridSpan") : void 0;
|
|
6144
|
+
if (element4) set(element4, "val", String(span));
|
|
6145
|
+
replace("gridSpan", element4);
|
|
6146
|
+
}
|
|
6147
|
+
if (cell2.verticalMerge !== base.verticalMerge) {
|
|
6148
|
+
const element4 = cell2.verticalMerge ? makeW(doc, "vMerge") : void 0;
|
|
6149
|
+
if (element4 && cell2.verticalMerge === "restart") set(element4, "val", "restart");
|
|
6150
|
+
replace("vMerge", element4);
|
|
6151
|
+
}
|
|
6152
|
+
orderChildren(props, CELL_ORDER);
|
|
6153
|
+
if (!Array.from(props.childNodes).some((node) => node.nodeType === 1) && !props.attributes.length)
|
|
6154
|
+
tc.removeChild(props);
|
|
6155
|
+
}
|
|
6156
|
+
function patchGrid(doc, node, table) {
|
|
6157
|
+
const grid = first2(node, "tblGrid");
|
|
6158
|
+
if (!grid || !table.grid) return;
|
|
6159
|
+
const old = children2(grid, "gridCol");
|
|
6160
|
+
table.grid.forEach((width, index) => {
|
|
6161
|
+
let column = old[index];
|
|
6162
|
+
if (!column) {
|
|
6163
|
+
column = makeW(doc, "gridCol");
|
|
6164
|
+
grid.appendChild(column);
|
|
6165
|
+
}
|
|
6166
|
+
if (column.getAttributeNS(WORD_NS, "w") !== String(width)) set(column, "w", String(width));
|
|
6167
|
+
});
|
|
6168
|
+
for (const extra of old.slice(table.grid.length)) grid.removeChild(extra);
|
|
6169
|
+
}
|
|
6170
|
+
function writeRestructuredTable(doc, table, node, base, writeParagraph, replaceSlots2, writeNested) {
|
|
6171
|
+
if (table.rows.some((row) => !row.length || row.some((cell2) => !cell2.paragraphs.length)))
|
|
6172
|
+
throw new Error("Every table row needs a cell and every cell a paragraph.");
|
|
6173
|
+
const oldRows = flatRows(node).map((entry2) => entry2.element);
|
|
6174
|
+
const oldCells = oldRows.map((tr) => flatCells(tr).map((entry2) => entry2.element));
|
|
6175
|
+
const cellById = /* @__PURE__ */ new Map();
|
|
6176
|
+
const paragraphById = /* @__PURE__ */ new Map();
|
|
6177
|
+
base.rows.forEach(
|
|
6178
|
+
(row, ri) => row.forEach((cell2, ci) => {
|
|
6179
|
+
const tc = oldCells[ri]?.[ci];
|
|
6180
|
+
if (!tc) return;
|
|
6181
|
+
const id = cell2.paragraphs[0]?.id;
|
|
6182
|
+
if (id) cellById.set(id, { tc, model: cell2, row: ri });
|
|
6183
|
+
const flat = flatCellParagraphs(tc);
|
|
6184
|
+
cell2.paragraphs.forEach((model, pi) => {
|
|
6185
|
+
const entry2 = flat[pi];
|
|
6186
|
+
if (entry2) paragraphById.set(model.id, { element: entry2.element, model });
|
|
6187
|
+
});
|
|
6188
|
+
})
|
|
6189
|
+
);
|
|
6190
|
+
const usedRows = /* @__PURE__ */ new Set();
|
|
6191
|
+
const usedCells = /* @__PURE__ */ new Set();
|
|
6192
|
+
const nextRows = table.rows.map((row, rowIndex) => {
|
|
6193
|
+
const sourceRow = row.map((cell2) => cellById.get(cell2.paragraphs[0]?.id ?? "")?.row).find((index) => index !== void 0 && !usedRows.has(index));
|
|
6194
|
+
if (sourceRow !== void 0) usedRows.add(sourceRow);
|
|
6195
|
+
const tr = sourceRow === void 0 ? makeW(doc, "tr") : oldRows[sourceRow] ?? makeW(doc, "tr");
|
|
6196
|
+
patchRowProperties(
|
|
6197
|
+
doc,
|
|
6198
|
+
tr,
|
|
6199
|
+
table.rowProperties?.[rowIndex],
|
|
6200
|
+
sourceRow === void 0 ? void 0 : base.rowProperties?.[sourceRow]
|
|
6201
|
+
);
|
|
6202
|
+
const nextCells = row.map((cell2) => {
|
|
6203
|
+
const source2 = cellById.get(cell2.paragraphs[0]?.id ?? "");
|
|
6204
|
+
const reuse = source2 && source2.row === sourceRow && !usedCells.has(source2.tc) ? source2 : void 0;
|
|
6205
|
+
const tc = reuse?.tc ?? makeW(doc, "tc");
|
|
6206
|
+
if (reuse) {
|
|
6207
|
+
usedCells.add(reuse.tc);
|
|
6208
|
+
patchCellLayout(doc, tc, cell2, reuse.model);
|
|
6209
|
+
patchCellBorders(doc, tc, cell2.borders, reuse.model.borders);
|
|
6210
|
+
patchCellShading(doc, tc, cell2, reuse.model);
|
|
6211
|
+
patchCellMargins(doc, tc, cell2.margins, reuse.model.margins);
|
|
6212
|
+
patchCellVerticalAlignment(doc, tc, cell2.verticalAlign, reuse.model.verticalAlign);
|
|
6213
|
+
} else {
|
|
6214
|
+
const props = buildCellProperties(doc, cell2);
|
|
6215
|
+
if (props) tc.insertBefore(props, tc.firstChild);
|
|
6216
|
+
}
|
|
6217
|
+
const oldParagraphs = reuse ? flatCellParagraphs(tc).map((entry2) => entry2.element) : [];
|
|
6218
|
+
const owned = new Set(oldParagraphs);
|
|
6219
|
+
const nextParagraphs = cell2.paragraphs.map((paragraph2) => {
|
|
6220
|
+
const found = paragraphById.get(paragraph2.id);
|
|
6221
|
+
const element4 = found ? owned.has(found.element) ? found.element : found.element.cloneNode(true) : makeW(doc, "p");
|
|
6222
|
+
return writeParagraph(doc, paragraph2, element4, found?.model);
|
|
6223
|
+
});
|
|
6224
|
+
replaceSlots2(doc, tc, oldParagraphs, nextParagraphs);
|
|
6225
|
+
if (reuse) writeNested(doc, tc, cell2, reuse.model);
|
|
6226
|
+
return tc;
|
|
6227
|
+
});
|
|
6228
|
+
replaceSlots2(doc, tr, sourceRow === void 0 ? [] : oldCells[sourceRow] ?? [], nextCells);
|
|
6229
|
+
return tr;
|
|
6230
|
+
});
|
|
6231
|
+
replaceSlots2(doc, node, oldRows, nextRows);
|
|
6232
|
+
patchTableMargins(doc, table, node, base);
|
|
6233
|
+
patchGrid(doc, node, table);
|
|
6234
|
+
return node;
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6237
|
+
// docx/table-grid.ts
|
|
6238
|
+
var spanOf = (cell2) => Math.max(1, cell2.gridSpan ?? 1);
|
|
6239
|
+
function tableGrid(table) {
|
|
6240
|
+
const columns2 = table.grid?.length ?? sumSpans(table.rows[0]);
|
|
6241
|
+
if (!columns2 || !table.rows.length) return void 0;
|
|
6242
|
+
const rows2 = [];
|
|
6243
|
+
const cover = [];
|
|
6244
|
+
for (let row = 0; row < table.rows.length; row++) {
|
|
6245
|
+
const cells = table.rows[row] ?? [];
|
|
6246
|
+
if (!cells.length || sumSpans(cells) !== columns2) return void 0;
|
|
6247
|
+
const placed = [];
|
|
6248
|
+
const line3 = new Array(columns2);
|
|
6249
|
+
let col = 0;
|
|
6250
|
+
cells.forEach((cell2, index) => {
|
|
6251
|
+
const entry2 = { cell: cell2, row, index, col, span: spanOf(cell2) };
|
|
6252
|
+
for (let k = 0; k < entry2.span; k++) line3[col + k] = entry2;
|
|
6253
|
+
col += entry2.span;
|
|
6254
|
+
placed.push(entry2);
|
|
6255
|
+
});
|
|
6256
|
+
rows2.push(placed);
|
|
6257
|
+
cover.push(line3);
|
|
6258
|
+
}
|
|
6259
|
+
const grid = { columns: columns2, rows: rows2, cover };
|
|
6260
|
+
for (const entry2 of rows2.flat())
|
|
6261
|
+
if (entry2.cell.verticalMerge === "continue") {
|
|
6262
|
+
const above = entry2.row > 0 ? cover[entry2.row - 1]?.[entry2.col] : void 0;
|
|
6263
|
+
if (!above || above.col !== entry2.col || above.span !== entry2.span) return void 0;
|
|
6264
|
+
if (!above.cell.verticalMerge) return void 0;
|
|
6265
|
+
}
|
|
6266
|
+
return grid;
|
|
6267
|
+
}
|
|
6268
|
+
function sumSpans(cells) {
|
|
6269
|
+
return (cells ?? []).reduce((sum, cell2) => sum + spanOf(cell2), 0);
|
|
6270
|
+
}
|
|
6271
|
+
|
|
6272
|
+
// docx/write-table.ts
|
|
5332
6273
|
var layout = (table) => table.rows.map((row) => row.map((cell2) => cell2.paragraphs.map((p) => p.id)));
|
|
5333
6274
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
5334
6275
|
"grid",
|
|
@@ -5346,13 +6287,15 @@ function pick(source2, keys) {
|
|
|
5346
6287
|
for (const key of keys) if (record[key] !== void 0) result[key] = record[key];
|
|
5347
6288
|
return result;
|
|
5348
6289
|
}
|
|
5349
|
-
function assertNoDescriptorEdits(table, base) {
|
|
6290
|
+
function assertNoDescriptorEdits(table, base, layoutEdits = false) {
|
|
5350
6291
|
if (!base) return;
|
|
5351
|
-
|
|
6292
|
+
const tableKeys = layoutEdits ? TABLE_DESCRIPTOR_KEYS.filter((key) => key !== "grid") : TABLE_DESCRIPTOR_KEYS;
|
|
6293
|
+
if (JSON.stringify(pick(table, tableKeys)) !== JSON.stringify(pick(base, tableKeys)))
|
|
5352
6294
|
throw new Error(
|
|
5353
6295
|
"Cannot edit table grid widths, width, alignment, indent, borders, or style; only cell text and row/column structure changes are supported. The original DOCX package remains unchanged."
|
|
5354
6296
|
);
|
|
5355
6297
|
const baseCellById = /* @__PURE__ */ new Map();
|
|
6298
|
+
if (layoutEdits) return;
|
|
5356
6299
|
for (const row of base.rows)
|
|
5357
6300
|
for (const cell2 of row) {
|
|
5358
6301
|
const id = cell2.paragraphs[0]?.id;
|
|
@@ -5377,11 +6320,24 @@ function writeNestedTables(doc, tc, cell2, base, writeParagraph, replaceSlots2)
|
|
|
5377
6320
|
next.forEach((table, index) => {
|
|
5378
6321
|
const node = nodes[index];
|
|
5379
6322
|
if (node && before[index])
|
|
5380
|
-
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2);
|
|
6323
|
+
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2, true);
|
|
5381
6324
|
});
|
|
5382
6325
|
}
|
|
5383
|
-
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
6326
|
+
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2, nested = false) {
|
|
5384
6327
|
if (base && JSON.stringify(table) === JSON.stringify(base)) return node;
|
|
6328
|
+
const baseGrid = base && tableGrid(base);
|
|
6329
|
+
if (base && baseGrid && (nested || !base.structureEditable || table.structureEditable === false) && restructured(table, base) && canRestructureTable(node)) {
|
|
6330
|
+
assertNoDescriptorEdits(table, base, true);
|
|
6331
|
+
return writeRestructuredTable(
|
|
6332
|
+
doc,
|
|
6333
|
+
table,
|
|
6334
|
+
node,
|
|
6335
|
+
base,
|
|
6336
|
+
writeParagraph,
|
|
6337
|
+
replaceSlots2,
|
|
6338
|
+
(d, tc, cell2, before) => writeNestedTables(d, tc, cell2, before, writeParagraph, replaceSlots2)
|
|
6339
|
+
);
|
|
6340
|
+
}
|
|
5385
6341
|
assertNoDescriptorEdits(table, base);
|
|
5386
6342
|
patchTableMargins(doc, table, node, base);
|
|
5387
6343
|
const structural = base && JSON.stringify(layout(table)) !== JSON.stringify(layout(base));
|
|
@@ -5507,13 +6463,13 @@ function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
|
5507
6463
|
|
|
5508
6464
|
// docx/write-footnote-columns.ts
|
|
5509
6465
|
var W15 = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
5510
|
-
var
|
|
6466
|
+
var XMLNS4 = "http://www.w3.org/2000/xmlns/";
|
|
5511
6467
|
var MC2 = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
5512
6468
|
function prefix(doc, preferred, namespace) {
|
|
5513
6469
|
let name = preferred;
|
|
5514
6470
|
for (let suffix = 1; doc.documentElement.lookupNamespaceURI(name) && doc.documentElement.lookupNamespaceURI(name) !== namespace; suffix++)
|
|
5515
6471
|
name = preferred + suffix;
|
|
5516
|
-
doc.documentElement.setAttributeNS(
|
|
6472
|
+
doc.documentElement.setAttributeNS(XMLNS4, "xmlns:" + name, namespace);
|
|
5517
6473
|
return name;
|
|
5518
6474
|
}
|
|
5519
6475
|
function writeFootnoteColumns(doc, section, value) {
|
|
@@ -5536,13 +6492,13 @@ function writeFootnoteColumns(doc, section, value) {
|
|
|
5536
6492
|
}
|
|
5537
6493
|
|
|
5538
6494
|
// docx/page-borders.ts
|
|
5539
|
-
var
|
|
6495
|
+
var SIDES5 = ["top", "left", "bottom", "right"];
|
|
5540
6496
|
var ATTRIBUTES = ["offsetFrom", "display", "zOrder"];
|
|
5541
6497
|
var setW4 = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
5542
6498
|
function parsePageBorders(element4) {
|
|
5543
6499
|
if (!element4) return void 0;
|
|
5544
6500
|
const result = {};
|
|
5545
|
-
for (const side of
|
|
6501
|
+
for (const side of SIDES5) {
|
|
5546
6502
|
const source2 = first2(element4, side);
|
|
5547
6503
|
const value = borderSide(source2);
|
|
5548
6504
|
const art = getW(source2, "art");
|
|
@@ -5580,7 +6536,7 @@ function patchPageBorders(doc, sectPr, next, base, create2) {
|
|
|
5580
6536
|
return;
|
|
5581
6537
|
}
|
|
5582
6538
|
const element4 = create2(doc, sectPr, "pgBorders");
|
|
5583
|
-
for (const side of
|
|
6539
|
+
for (const side of SIDES5) {
|
|
5584
6540
|
if (JSON.stringify(next[side]) === JSON.stringify(base?.[side])) continue;
|
|
5585
6541
|
for (const old of children2(element4, side)) element4.removeChild(old);
|
|
5586
6542
|
const value = next[side];
|
|
@@ -5761,75 +6717,6 @@ function writePageNumbering(doc, sectPr, section) {
|
|
|
5761
6717
|
}
|
|
5762
6718
|
}
|
|
5763
6719
|
|
|
5764
|
-
// docx/tab-stops.ts
|
|
5765
|
-
function parseTabStops(tabs) {
|
|
5766
|
-
const stops = [];
|
|
5767
|
-
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
5768
|
-
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
5769
|
-
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
5770
|
-
if (!align || pos === void 0) continue;
|
|
5771
|
-
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
5772
|
-
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
5773
|
-
}
|
|
5774
|
-
return stops;
|
|
5775
|
-
}
|
|
5776
|
-
function writeTabStops(doc, props, paragraph2, base) {
|
|
5777
|
-
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
5778
|
-
return;
|
|
5779
|
-
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
5780
|
-
if (!paragraph2.tabStops?.length) return;
|
|
5781
|
-
const tabs = makeW(doc, "tabs");
|
|
5782
|
-
for (const stop of paragraph2.tabStops) {
|
|
5783
|
-
const tab = makeW(doc, "tab");
|
|
5784
|
-
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
5785
|
-
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
5786
|
-
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
5787
|
-
tabs.appendChild(tab);
|
|
5788
|
-
}
|
|
5789
|
-
props.appendChild(tabs);
|
|
5790
|
-
}
|
|
5791
|
-
var PPR_ORDER = [
|
|
5792
|
-
"pStyle",
|
|
5793
|
-
"keepNext",
|
|
5794
|
-
"keepLines",
|
|
5795
|
-
"pageBreakBefore",
|
|
5796
|
-
"framePr",
|
|
5797
|
-
"widowControl",
|
|
5798
|
-
"numPr",
|
|
5799
|
-
"suppressLineNumbers",
|
|
5800
|
-
"pBdr",
|
|
5801
|
-
"shd",
|
|
5802
|
-
"tabs",
|
|
5803
|
-
"suppressAutoHyphens",
|
|
5804
|
-
"kinsoku",
|
|
5805
|
-
"wordWrap",
|
|
5806
|
-
"overflowPunct",
|
|
5807
|
-
"topLinePunct",
|
|
5808
|
-
"autoSpaceDE",
|
|
5809
|
-
"autoSpaceDN",
|
|
5810
|
-
"bidi",
|
|
5811
|
-
"adjustRightInd",
|
|
5812
|
-
"snapToGrid",
|
|
5813
|
-
"spacing",
|
|
5814
|
-
"ind",
|
|
5815
|
-
"contextualSpacing",
|
|
5816
|
-
"mirrorIndents",
|
|
5817
|
-
"suppressOverlap",
|
|
5818
|
-
"jc",
|
|
5819
|
-
"textDirection",
|
|
5820
|
-
"textAlignment",
|
|
5821
|
-
"textboxTightWrap",
|
|
5822
|
-
"outlineLvl",
|
|
5823
|
-
"divId",
|
|
5824
|
-
"cnfStyle",
|
|
5825
|
-
"rPr",
|
|
5826
|
-
"sectPr",
|
|
5827
|
-
"pPrChange"
|
|
5828
|
-
];
|
|
5829
|
-
function orderParagraphProperties(props) {
|
|
5830
|
-
orderChildren(props, PPR_ORDER);
|
|
5831
|
-
}
|
|
5832
|
-
|
|
5833
6720
|
// docx/write-sections.ts
|
|
5834
6721
|
var WRITABLE = /* @__PURE__ */ new Set([
|
|
5835
6722
|
"endsAtBlockId",
|
|
@@ -6434,16 +7321,16 @@ function isWordElement(element4, names) {
|
|
|
6434
7321
|
}
|
|
6435
7322
|
var isRevisionWrapperElement = (element4) => isWordElement(element4, REVISION_WRAPPER_NAMES2);
|
|
6436
7323
|
var isCommentAnchorElement = (element4) => isWordElement(element4, COMMENT_ANCHOR_NAMES);
|
|
6437
|
-
function
|
|
7324
|
+
function setAttribute3(element4, local, value) {
|
|
6438
7325
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
6439
7326
|
}
|
|
6440
7327
|
function removeChildren(element4, local) {
|
|
6441
7328
|
for (const child7 of children2(element4, local)) element4.removeChild(child7);
|
|
6442
7329
|
}
|
|
6443
7330
|
function writeRevisionMetadata(element4, revision) {
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
if (revision.date)
|
|
7331
|
+
setAttribute3(element4, "id", revision.id);
|
|
7332
|
+
setAttribute3(element4, "author", revision.author);
|
|
7333
|
+
if (revision.date) setAttribute3(element4, "date", revision.date);
|
|
6447
7334
|
else element4.removeAttributeNS(WORD_NS, "date");
|
|
6448
7335
|
if (revision.dateUtc) element4.setAttributeNS(WORD_DATE_UTC_NS, "w16du:dateUtc", revision.dateUtc);
|
|
6449
7336
|
else element4.removeAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
@@ -6578,184 +7465,6 @@ function restoreAnnotations(markers, before, after) {
|
|
|
6578
7465
|
}
|
|
6579
7466
|
}
|
|
6580
7467
|
|
|
6581
|
-
// docx/write-paragraph-decoration.ts
|
|
6582
|
-
var SIDES5 = ["top", "left", "bottom", "right", "between"];
|
|
6583
|
-
function wordColor(color) {
|
|
6584
|
-
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
6585
|
-
return hex ? hex.toUpperCase() : "auto";
|
|
6586
|
-
}
|
|
6587
|
-
function borderElement(doc, name, side) {
|
|
6588
|
-
const element4 = makeW(doc, name);
|
|
6589
|
-
const set = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
6590
|
-
set("val", side.style ?? "single");
|
|
6591
|
-
if (side.style !== "none" && side.style !== "nil") {
|
|
6592
|
-
set("sz", String(side.sizeEighthPoints ?? 4));
|
|
6593
|
-
set("space", String(side.spacePoints ?? 1));
|
|
6594
|
-
set("color", wordColor(side.color));
|
|
6595
|
-
if (side.themeColor) set("themeColor", side.themeColor);
|
|
6596
|
-
}
|
|
6597
|
-
return element4;
|
|
6598
|
-
}
|
|
6599
|
-
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
6600
|
-
function updateShading(doc, props, paragraph2, base) {
|
|
6601
|
-
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
6602
|
-
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
6603
|
-
if (!paragraph2.shadingFill) return;
|
|
6604
|
-
const shd = makeW(doc, "shd");
|
|
6605
|
-
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
6606
|
-
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
6607
|
-
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
6608
|
-
props.appendChild(shd);
|
|
6609
|
-
}
|
|
6610
|
-
function updateBorders(doc, props, paragraph2, base) {
|
|
6611
|
-
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
6612
|
-
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
6613
|
-
const borders = paragraph2.borders;
|
|
6614
|
-
if (!borders) return;
|
|
6615
|
-
const pBdr = makeW(doc, "pBdr");
|
|
6616
|
-
for (const side of SIDES5) {
|
|
6617
|
-
const value = borders[side];
|
|
6618
|
-
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
6619
|
-
}
|
|
6620
|
-
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
6621
|
-
}
|
|
6622
|
-
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
6623
|
-
updateShading(doc, props, paragraph2, base);
|
|
6624
|
-
updateBorders(doc, props, paragraph2, base);
|
|
6625
|
-
}
|
|
6626
|
-
|
|
6627
|
-
// docx/write-paragraph-properties.ts
|
|
6628
|
-
function setAttribute3(element4, local, value) {
|
|
6629
|
-
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
6630
|
-
}
|
|
6631
|
-
function setWordValue(element4, local, value) {
|
|
6632
|
-
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
6633
|
-
else setAttribute3(element4, local, String(value));
|
|
6634
|
-
}
|
|
6635
|
-
function updateDirection(doc, props, paragraph2, base) {
|
|
6636
|
-
if (base && paragraph2.direction === base.direction) return;
|
|
6637
|
-
let bidi = first2(props, "bidi");
|
|
6638
|
-
if (paragraph2.direction === void 0) {
|
|
6639
|
-
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
6640
|
-
} else {
|
|
6641
|
-
if (!bidi) {
|
|
6642
|
-
bidi = makeW(doc, "bidi");
|
|
6643
|
-
props.appendChild(bidi);
|
|
6644
|
-
}
|
|
6645
|
-
setAttribute3(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
6646
|
-
}
|
|
6647
|
-
}
|
|
6648
|
-
function updateSpacing(doc, props, paragraph2, base) {
|
|
6649
|
-
let spacing3 = first2(props, "spacing");
|
|
6650
|
-
if (!spacing3) {
|
|
6651
|
-
spacing3 = makeW(doc, "spacing");
|
|
6652
|
-
props.appendChild(spacing3);
|
|
6653
|
-
}
|
|
6654
|
-
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
6655
|
-
setWordValue(spacing3, "before", paragraph2.spacingBeforeTwips);
|
|
6656
|
-
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
6657
|
-
setWordValue(spacing3, "after", paragraph2.spacingAfterTwips);
|
|
6658
|
-
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
6659
|
-
setWordValue(spacing3, "line", paragraph2.lineSpacingTwips);
|
|
6660
|
-
setWordValue(
|
|
6661
|
-
spacing3,
|
|
6662
|
-
"lineRule",
|
|
6663
|
-
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
6664
|
-
);
|
|
6665
|
-
}
|
|
6666
|
-
if (!spacing3.attributes.length && !spacing3.childNodes.length) props.removeChild(spacing3);
|
|
6667
|
-
}
|
|
6668
|
-
function updateIndent(doc, props, paragraph2, base) {
|
|
6669
|
-
let indent = first2(props, "ind");
|
|
6670
|
-
if (!indent) {
|
|
6671
|
-
indent = makeW(doc, "ind");
|
|
6672
|
-
props.appendChild(indent);
|
|
6673
|
-
}
|
|
6674
|
-
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
6675
|
-
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
6676
|
-
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
6677
|
-
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
6678
|
-
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
6679
|
-
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
6680
|
-
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
6681
|
-
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
6682
|
-
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
6683
|
-
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
6684
|
-
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
6685
|
-
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
6686
|
-
if (!indent.attributes.length) props.removeChild(indent);
|
|
6687
|
-
}
|
|
6688
|
-
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
6689
|
-
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
6690
|
-
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
6691
|
-
if (paragraph2.pageBreakBefore !== void 0) {
|
|
6692
|
-
const element4 = makeW(doc, "pageBreakBefore");
|
|
6693
|
-
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
6694
|
-
props.appendChild(element4);
|
|
6695
|
-
}
|
|
6696
|
-
}
|
|
6697
|
-
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
6698
|
-
for (const key of [
|
|
6699
|
-
"keepNext",
|
|
6700
|
-
"keepLines",
|
|
6701
|
-
"widowControl",
|
|
6702
|
-
"contextualSpacing",
|
|
6703
|
-
"suppressLineNumbers"
|
|
6704
|
-
]) {
|
|
6705
|
-
if (base && paragraph2[key] === base[key]) continue;
|
|
6706
|
-
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
6707
|
-
const value = paragraph2[key];
|
|
6708
|
-
if (value === void 0) continue;
|
|
6709
|
-
const element4 = makeW(doc, key);
|
|
6710
|
-
if (!value) setAttribute3(element4, "val", "0");
|
|
6711
|
-
props.appendChild(element4);
|
|
6712
|
-
}
|
|
6713
|
-
}
|
|
6714
|
-
function updateDropCap(doc, props, paragraph2, base) {
|
|
6715
|
-
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
6716
|
-
let frame2 = first2(props, "framePr");
|
|
6717
|
-
const cap = paragraph2.dropCap;
|
|
6718
|
-
if (!cap) {
|
|
6719
|
-
if (frame2) props.removeChild(frame2);
|
|
6720
|
-
return;
|
|
6721
|
-
}
|
|
6722
|
-
if (!frame2) {
|
|
6723
|
-
frame2 = makeW(doc, "framePr");
|
|
6724
|
-
props.appendChild(frame2);
|
|
6725
|
-
setAttribute3(frame2, "wrap", "around");
|
|
6726
|
-
setAttribute3(frame2, "vAnchor", "text");
|
|
6727
|
-
setAttribute3(frame2, "hAnchor", "text");
|
|
6728
|
-
}
|
|
6729
|
-
setAttribute3(frame2, "dropCap", cap.style);
|
|
6730
|
-
setAttribute3(frame2, "lines", String(cap.lines));
|
|
6731
|
-
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
6732
|
-
}
|
|
6733
|
-
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
6734
|
-
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
6735
|
-
updateKeepOptions(doc, props, paragraph2, base);
|
|
6736
|
-
updateDropCap(doc, props, paragraph2, base);
|
|
6737
|
-
updateDirection(doc, props, paragraph2, base);
|
|
6738
|
-
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
6739
|
-
const spacingKeys = [
|
|
6740
|
-
"spacingBeforeTwips",
|
|
6741
|
-
"spacingAfterTwips",
|
|
6742
|
-
"lineSpacingTwips",
|
|
6743
|
-
"lineSpacingRule"
|
|
6744
|
-
];
|
|
6745
|
-
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
6746
|
-
updateSpacing(doc, props, paragraph2, base);
|
|
6747
|
-
const indentKeys = [
|
|
6748
|
-
"indentLeftTwips",
|
|
6749
|
-
"indentRightTwips",
|
|
6750
|
-
"indentStartTwips",
|
|
6751
|
-
"indentEndTwips",
|
|
6752
|
-
"firstLineTwips",
|
|
6753
|
-
"hangingTwips"
|
|
6754
|
-
];
|
|
6755
|
-
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
6756
|
-
updateIndent(doc, props, paragraph2, base);
|
|
6757
|
-
}
|
|
6758
|
-
|
|
6759
7468
|
// docx/bookmarks.ts
|
|
6760
7469
|
function paragraphBookmarkNames(node) {
|
|
6761
7470
|
return children2(node, "bookmarkStart").map((el5) => getW(el5, "name")).filter((name) => Boolean(name));
|
|
@@ -8955,10 +9664,10 @@ function writeDrawingRichTextBody(container, body) {
|
|
|
8955
9664
|
const paragraphs = body.paragraphs.length ? body.paragraphs : [{ items: [] }];
|
|
8956
9665
|
for (const paragraph2 of paragraphs) container.appendChild(writeDrawingParagraph(doc, paragraph2));
|
|
8957
9666
|
}
|
|
8958
|
-
function drawingRichTextBodyXml(body,
|
|
8959
|
-
const prefix2 =
|
|
9667
|
+
function drawingRichTextBodyXml(body, qualifiedName2 = "a:txBody", namespace = NS.a) {
|
|
9668
|
+
const prefix2 = qualifiedName2.includes(":") ? qualifiedName2.split(":")[0] : void 0;
|
|
8960
9669
|
const declaration = prefix2 && prefix2 !== "a" ? ` xmlns:${prefix2}="${namespace}"` : "";
|
|
8961
|
-
const doc = parseXml(`<${
|
|
9670
|
+
const doc = parseXml(`<${qualifiedName2}${declaration} xmlns:a="${NS.a}" xmlns:r="${NS.r}"/>`);
|
|
8962
9671
|
writeDrawingRichTextBody(doc.documentElement, body);
|
|
8963
9672
|
return buildXml(doc);
|
|
8964
9673
|
}
|
|
@@ -18257,12 +18966,12 @@ function shapeParagraphs(wsp) {
|
|
|
18257
18966
|
function textIsPlain(wsp) {
|
|
18258
18967
|
const content = child4(child4(wsp, WPS_NS2, "txbx"), W_NS2, "txbxContent");
|
|
18259
18968
|
if (!content) return true;
|
|
18260
|
-
const
|
|
18969
|
+
const only2 = (node, allowed) => elementsOf(node).every(
|
|
18261
18970
|
(item2) => item2.namespaceURI === W_NS2 && allowed.includes(item2.localName)
|
|
18262
18971
|
);
|
|
18263
|
-
return
|
|
18264
|
-
(paragraph2) =>
|
|
18265
|
-
(run2) =>
|
|
18972
|
+
return only2(content, ["p"]) && Array.from(content.getElementsByTagNameNS(W_NS2, "p")).every(
|
|
18973
|
+
(paragraph2) => only2(paragraph2, ["pPr", "r"]) && Array.from(paragraph2.getElementsByTagNameNS(W_NS2, "r")).every(
|
|
18974
|
+
(run2) => only2(run2, ["rPr", "t"])
|
|
18266
18975
|
)
|
|
18267
18976
|
);
|
|
18268
18977
|
}
|
|
@@ -18505,7 +19214,7 @@ function parseAttributes(source2) {
|
|
|
18505
19214
|
}
|
|
18506
19215
|
return attrs2;
|
|
18507
19216
|
}
|
|
18508
|
-
function
|
|
19217
|
+
function tagEnd2(xml, from) {
|
|
18509
19218
|
let quote = "";
|
|
18510
19219
|
for (let i = from; i < xml.length; i++) {
|
|
18511
19220
|
const ch = xml[i];
|
|
@@ -18536,7 +19245,7 @@ function parseOrderedXml(xml) {
|
|
|
18536
19245
|
i = close < 0 ? -1 : xml.indexOf("<", close + 3);
|
|
18537
19246
|
continue;
|
|
18538
19247
|
}
|
|
18539
|
-
const end =
|
|
19248
|
+
const end = tagEnd2(xml, i + 1);
|
|
18540
19249
|
if (end < 0) {
|
|
18541
19250
|
break;
|
|
18542
19251
|
}
|
|
@@ -19116,17 +19825,17 @@ function isShadowedBound(node, constraint) {
|
|
|
19116
19825
|
|
|
19117
19826
|
// diagram/engine/constraint-eval.ts
|
|
19118
19827
|
function relatedNodes(node, relation2, name, ptType) {
|
|
19119
|
-
const
|
|
19828
|
+
const matches2 = (candidate) => (!name || candidate.name === name) && (matchesPointType(candidate.point, ptType) || candidate.presOf.length > 0 && matchesPointType(candidate.presOf[0], ptType));
|
|
19120
19829
|
if (relation2 === "self") {
|
|
19121
19830
|
return name && node.name !== name ? [] : [node];
|
|
19122
19831
|
}
|
|
19123
19832
|
if (relation2 === "ch") {
|
|
19124
|
-
return node.children.filter(
|
|
19833
|
+
return node.children.filter(matches2);
|
|
19125
19834
|
}
|
|
19126
19835
|
const out = [];
|
|
19127
19836
|
const visit = (current) => {
|
|
19128
19837
|
for (const child7 of current.children) {
|
|
19129
|
-
if (
|
|
19838
|
+
if (matches2(child7)) {
|
|
19130
19839
|
out.push(child7);
|
|
19131
19840
|
}
|
|
19132
19841
|
visit(child7);
|
|
@@ -23428,14 +24137,14 @@ function findDiagramShapeIndex(shapes, nodes, nodeId) {
|
|
|
23428
24137
|
const node = nodes.find((n2) => n2.id === nodeId);
|
|
23429
24138
|
if (node?.text) {
|
|
23430
24139
|
const text2 = node.text.trim();
|
|
23431
|
-
const
|
|
24140
|
+
const matches2 = [];
|
|
23432
24141
|
for (let i = 0; i < shapes.length; i++) {
|
|
23433
24142
|
if (shapes[i].text?.trim() === text2) {
|
|
23434
|
-
|
|
24143
|
+
matches2.push(i);
|
|
23435
24144
|
}
|
|
23436
24145
|
}
|
|
23437
|
-
if (
|
|
23438
|
-
return
|
|
24146
|
+
if (matches2.length === 1) {
|
|
24147
|
+
return matches2[0];
|
|
23439
24148
|
}
|
|
23440
24149
|
}
|
|
23441
24150
|
return -1;
|
|
@@ -28396,8 +29105,8 @@ function parseDisplayUnits(context, element4) {
|
|
|
28396
29105
|
|
|
28397
29106
|
// chart/write-util.ts
|
|
28398
29107
|
var INVALID_XML = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
28399
|
-
var
|
|
28400
|
-
var escapeAttribute = (value) =>
|
|
29108
|
+
var escapeText2 = (value) => value.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
29109
|
+
var escapeAttribute = (value) => escapeText2(value).replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
28401
29110
|
function chartNumber(value) {
|
|
28402
29111
|
if (!Number.isFinite(value)) throw new Error(`Chart number ${value} is not finite`);
|
|
28403
29112
|
const text2 = String(value);
|
|
@@ -29077,7 +29786,7 @@ function run(value) {
|
|
|
29077
29786
|
const hasProperties = Object.keys(properties).length > 0;
|
|
29078
29787
|
if (text2 === "\n")
|
|
29079
29788
|
return hasProperties ? `<a:br>${runProperties("rPr", properties)}</a:br>` : "<a:br/>";
|
|
29080
|
-
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${
|
|
29789
|
+
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${escapeText2(text2)}</a:t></a:r>`;
|
|
29081
29790
|
}
|
|
29082
29791
|
function paragraph(value) {
|
|
29083
29792
|
const align = value.align ? ` algn="${escapeAttribute(value.align)}"` : "";
|
|
@@ -29205,7 +29914,7 @@ function chartTextBodyFromXml(xml) {
|
|
|
29205
29914
|
}
|
|
29206
29915
|
|
|
29207
29916
|
// chart/write-text.ts
|
|
29208
|
-
var textElement = (local, value) => `<c:${local}>${
|
|
29917
|
+
var textElement = (local, value) => `<c:${local}>${escapeText2(value)}</c:${local}>`;
|
|
29209
29918
|
function cachePoints(cache) {
|
|
29210
29919
|
return cache.points.map((point, position2) => {
|
|
29211
29920
|
const format = point.formatCode === void 0 ? "" : ` formatCode="${escapeAttribute(point.formatCode)}"`;
|
|
@@ -29335,7 +30044,7 @@ function trendlineLabelXml(context, label) {
|
|
|
29335
30044
|
function trendlineXml(context, trendline) {
|
|
29336
30045
|
return elementXml(
|
|
29337
30046
|
"trendline",
|
|
29338
|
-
(trendline.name === void 0 ? "" : `<c:name>${
|
|
30047
|
+
(trendline.name === void 0 ? "" : `<c:name>${escapeText2(trendline.name)}</c:name>`) + shapePropertiesXml(context, trendline.spPr) + valXml("trendlineType", trendline.trendlineType ?? "linear") + valXml("order", trendline.order) + valXml("period", trendline.period) + valXml("forward", trendline.forward) + valXml("backward", trendline.backward) + valXml("intercept", trendline.intercept) + valXml("dispRSqr", trendline.displayRSquared) + valXml("dispEq", trendline.displayEquation) + trendlineLabelXml(context, trendline.label) + raw(context, trendline.extLst)
|
|
29339
30048
|
);
|
|
29340
30049
|
}
|
|
29341
30050
|
function errorBarsXml(context, bars2) {
|
|
@@ -30080,7 +30789,7 @@ function attributes(entries) {
|
|
|
30080
30789
|
}).join("");
|
|
30081
30790
|
}
|
|
30082
30791
|
var cxElement = (local, content = "", attrs2 = "") => content ? `<cx:${local}${attrs2}>${content}</cx:${local}>` : `<cx:${local}${attrs2}/>`;
|
|
30083
|
-
var cxText = (local, text2, attrs2 = "") => text2 === void 0 ? "" : `<cx:${local}${attrs2}>${
|
|
30792
|
+
var cxText = (local, text2, attrs2 = "") => text2 === void 0 ? "" : `<cx:${local}${attrs2}>${escapeText2(text2)}</cx:${local}>`;
|
|
30084
30793
|
var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
|
|
30085
30794
|
var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
|
|
30086
30795
|
var shapeXml = (context, shape2) => shape2 ? cxElement("spPr", shapePropertiesInnerXml(context, shape2)) : "";
|
|
@@ -30520,7 +31229,7 @@ function realignChartTitleBody(body, text2) {
|
|
|
30520
31229
|
}
|
|
30521
31230
|
|
|
30522
31231
|
// chart/edit/title.ts
|
|
30523
|
-
var chartTitleRichXml = (text2) => `<a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:r><a:rPr lang="en-US"/><a:t>${
|
|
31232
|
+
var chartTitleRichXml = (text2) => `<a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:r><a:rPr lang="en-US"/><a:t>${escapeText2(text2)}</a:t></a:r></a:p>`;
|
|
30524
31233
|
function newChartTitle(text2) {
|
|
30525
31234
|
const rich = chartTextBodyFromXml(chartTitleRichXml(text2));
|
|
30526
31235
|
return { tx: { rich, text: rich.text }, text: rich.text, overlay: false };
|
|
@@ -36604,6 +37313,10 @@ var WRAPS = [
|
|
|
36604
37313
|
function parsePlacement(anchor) {
|
|
36605
37314
|
const wrap2 = WRAPS.find(([local]) => firstNS(anchor, WP_NS2, local))?.[1] ?? "none";
|
|
36606
37315
|
const placement = { wrap: wrap2 };
|
|
37316
|
+
const wrapElement2 = WRAPS.map(([local]) => firstNS(anchor, WP_NS2, local)).find(Boolean);
|
|
37317
|
+
const wrapText = wrapElement2?.getAttribute("wrapText");
|
|
37318
|
+
if (wrapText === "bothSides" || wrapText === "left" || wrapText === "right" || wrapText === "largest")
|
|
37319
|
+
placement.wrapText = wrapText;
|
|
36607
37320
|
if (anchor.getAttribute("behindDoc") === "1") placement.behindText = true;
|
|
36608
37321
|
const positionH = firstNS(anchor, WP_NS2, "positionH");
|
|
36609
37322
|
const relativeFrom = enumValue(
|
|
@@ -37035,6 +37748,34 @@ function chartRun(doc, node, image, base, oldDrawing, oldContainer, allocator) {
|
|
|
37035
37748
|
return void 0;
|
|
37036
37749
|
}
|
|
37037
37750
|
|
|
37751
|
+
// docx/write-fallback.ts
|
|
37752
|
+
var PT_PER_PX2 = 0.75;
|
|
37753
|
+
function setStyleSize(style, name, pt) {
|
|
37754
|
+
const value = `${Math.round(pt * 100) / 100}pt`;
|
|
37755
|
+
const pattern = new RegExp(`(^|;)\\s*${name}\\s*:\\s*[^;]*`, "i");
|
|
37756
|
+
return pattern.test(style) ? style.replace(pattern, (_all, lead) => `${lead}${name}:${value}`) : style;
|
|
37757
|
+
}
|
|
37758
|
+
function patchFallbackSize(content, image, base) {
|
|
37759
|
+
if (!base || image.widthPx === base.widthPx && image.heightPx === base.heightPx) return;
|
|
37760
|
+
const fallback = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Fallback");
|
|
37761
|
+
if (!fallback) return;
|
|
37762
|
+
const stack = [fallback];
|
|
37763
|
+
while (stack.length) {
|
|
37764
|
+
const node = stack.pop();
|
|
37765
|
+
const style = node.getAttribute("style");
|
|
37766
|
+
if (style && /(^|;)\s*width\s*:/i.test(style)) {
|
|
37767
|
+
let next = style;
|
|
37768
|
+
if (image.widthPx !== base.widthPx)
|
|
37769
|
+
next = setStyleSize(next, "width", image.widthPx * PT_PER_PX2);
|
|
37770
|
+
if (image.heightPx !== base.heightPx)
|
|
37771
|
+
next = setStyleSize(next, "height", image.heightPx * PT_PER_PX2);
|
|
37772
|
+
node.setAttribute("style", next);
|
|
37773
|
+
continue;
|
|
37774
|
+
}
|
|
37775
|
+
for (const child7 of Array.from(node.childNodes)) if (isElement(child7)) stack.push(child7);
|
|
37776
|
+
}
|
|
37777
|
+
}
|
|
37778
|
+
|
|
37038
37779
|
// docx/diagram-document.ts
|
|
37039
37780
|
function diagramsIn(blocks) {
|
|
37040
37781
|
const diagrams = [];
|
|
@@ -37752,6 +38493,13 @@ function createImageRun(doc, image, base, old, allocator) {
|
|
|
37752
38493
|
}
|
|
37753
38494
|
if (base && oldDrawing && image.shape?.editable && base.shape?.editable) {
|
|
37754
38495
|
const next = rebuildShapeDrawing(doc, image, oldDrawing);
|
|
38496
|
+
const choice = oldDrawing.parentNode;
|
|
38497
|
+
if (oldContainer?.localName === "AlternateContent" && choice) {
|
|
38498
|
+
choice.replaceChild(next, oldDrawing);
|
|
38499
|
+
patchFallbackSize(oldContainer, image, base);
|
|
38500
|
+
clearNonProperties(node, oldContainer);
|
|
38501
|
+
return node;
|
|
38502
|
+
}
|
|
37755
38503
|
clearNonProperties(node);
|
|
37756
38504
|
node.appendChild(next);
|
|
37757
38505
|
return node;
|
|
@@ -38877,15 +39625,15 @@ function runIsSafe(run2) {
|
|
|
38877
39625
|
const content = Array.from(run2.childNodes).filter(
|
|
38878
39626
|
(child7) => isElement(child7) && !named2(child7, "rPr") && !isCachedPageBreak(child7)
|
|
38879
39627
|
);
|
|
38880
|
-
const
|
|
38881
|
-
if (
|
|
38882
|
-
if (
|
|
38883
|
-
(name) => named2(
|
|
39628
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
39629
|
+
if (only2 && named2(only2, "br") && isModeledBreak(only2)) return true;
|
|
39630
|
+
if (only2 && ["footnoteReference", "endnoteReference", "footnoteRef", "endnoteRef"].some(
|
|
39631
|
+
(name) => named2(only2, name)
|
|
38884
39632
|
))
|
|
38885
39633
|
return true;
|
|
38886
|
-
if (
|
|
38887
|
-
const type = getW(
|
|
38888
|
-
const data = Array.from(
|
|
39634
|
+
if (only2 && named2(only2, "fldChar")) {
|
|
39635
|
+
const type = getW(only2, "fldCharType") ?? "";
|
|
39636
|
+
const data = Array.from(only2.childNodes).filter(
|
|
38889
39637
|
(node) => isElement(node) || Boolean(node.textContent?.trim())
|
|
38890
39638
|
);
|
|
38891
39639
|
if (!data.length) return ["begin", "separate", "end"].includes(type);
|
|
@@ -39017,6 +39765,10 @@ function parseDirectParagraphProperties(props) {
|
|
|
39017
39765
|
const line3 = signedTwipValue2(getW(spacing3, "line"));
|
|
39018
39766
|
if (before !== void 0) paragraph2.spacingBeforeTwips = before;
|
|
39019
39767
|
if (after !== void 0) paragraph2.spacingAfterTwips = after;
|
|
39768
|
+
const beforeAuto = parseOnOff(getW(spacing3, "beforeAutospacing"));
|
|
39769
|
+
const afterAuto = parseOnOff(getW(spacing3, "afterAutospacing"));
|
|
39770
|
+
if (beforeAuto !== void 0) paragraph2.spacingBeforeAuto = beforeAuto;
|
|
39771
|
+
if (afterAuto !== void 0) paragraph2.spacingAfterAuto = afterAuto;
|
|
39020
39772
|
if (line3 !== void 0) {
|
|
39021
39773
|
paragraph2.lineSpacingTwips = line3;
|
|
39022
39774
|
}
|
|
@@ -39048,8 +39800,8 @@ function parseDirectParagraphProperties(props) {
|
|
|
39048
39800
|
|
|
39049
39801
|
// docx/run-segmentation.ts
|
|
39050
39802
|
var basisOf = (run2) => run2.restoredRunPropertiesXml ?? run2.sourceRunPropertiesXml;
|
|
39051
|
-
function keepsUnmodeledProperties(before, after) {
|
|
39052
|
-
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () =>
|
|
39803
|
+
function keepsUnmodeledProperties(before, after, basis = basisOf) {
|
|
39804
|
+
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () => basis(run2)));
|
|
39053
39805
|
const was = owners(before);
|
|
39054
39806
|
const now = owners(after);
|
|
39055
39807
|
const kept = (from, to, shift) => {
|
|
@@ -39083,13 +39835,22 @@ function runsToWriteAnew(paragraph2, base, slots) {
|
|
|
39083
39835
|
return !remaining.length || remaining.every((run2) => run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml);
|
|
39084
39836
|
}))
|
|
39085
39837
|
return none;
|
|
39086
|
-
if (paragraph2.runs.every(
|
|
39087
|
-
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
39088
|
-
))
|
|
39089
|
-
return none;
|
|
39090
39838
|
const sameText = paragraph2.runs.map((run2) => run2.text).join("") === base.runs.map((run2) => run2.text).join("");
|
|
39091
39839
|
const sameBoundaries = paragraph2.runs.length === base.runs.length && paragraph2.runs.every((run2, index) => run2.text === base.runs[index]?.text);
|
|
39092
39840
|
if (sameBoundaries || !sameText && paragraph2.runs.length === base.runs.length) return none;
|
|
39841
|
+
if (paragraph2.runs.every(
|
|
39842
|
+
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
39843
|
+
)) {
|
|
39844
|
+
if (keepsUnmodeledProperties(
|
|
39845
|
+
base.runs,
|
|
39846
|
+
paragraph2.runs,
|
|
39847
|
+
(run2) => run2.sourceRunPropertiesXml ?? run2.restoredRunPropertiesXml
|
|
39848
|
+
))
|
|
39849
|
+
return none;
|
|
39850
|
+
throw new Error(
|
|
39851
|
+
`Cannot edit paragraph ${paragraph2.id}: changing run boundaries could drop unsupported run properties because the merged runs carry different unsupported properties. The original DOCX package remains unchanged.`
|
|
39852
|
+
);
|
|
39853
|
+
}
|
|
39093
39854
|
const object = (run2) => Boolean(run2.image || run2.equation);
|
|
39094
39855
|
if (!paragraph2.runs.some(object) && !base.runs.some(object) && keepsUnmodeledProperties(base.runs, paragraph2.runs))
|
|
39095
39856
|
return new Set(
|
|
@@ -40250,14 +41011,14 @@ async function applyNumberingCatalog(zip, model, binding) {
|
|
|
40250
41011
|
}
|
|
40251
41012
|
|
|
40252
41013
|
// docx/style-numbering-package.ts
|
|
40253
|
-
var
|
|
40254
|
-
var
|
|
41014
|
+
var STYLES_PART2 = "word/styles.xml";
|
|
41015
|
+
var AFTER_PPR2 = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
40255
41016
|
var withoutNumbering = (catalog) => catalog ? {
|
|
40256
41017
|
...catalog,
|
|
40257
41018
|
styles: Object.fromEntries(
|
|
40258
41019
|
Object.entries(catalog.styles).map(([id, style]) => {
|
|
40259
|
-
const { numbering: _numbering, ...rest } = style;
|
|
40260
|
-
return [id, rest];
|
|
41020
|
+
const { numbering: _numbering, formatting, ...rest } = style;
|
|
41021
|
+
return [id, { ...rest, formatting: unwritableFormatting(formatting) }];
|
|
40261
41022
|
})
|
|
40262
41023
|
)
|
|
40263
41024
|
} : void 0;
|
|
@@ -40270,7 +41031,7 @@ function setNumPr(style, numbering) {
|
|
|
40270
41031
|
if (!numbering && !pPr) return;
|
|
40271
41032
|
if (!pPr) {
|
|
40272
41033
|
pPr = makeW(doc, "pPr");
|
|
40273
|
-
const anchor = elementsOf2(style).find((child7) =>
|
|
41034
|
+
const anchor = elementsOf2(style).find((child7) => AFTER_PPR2.includes(child7.localName)) ?? null;
|
|
40274
41035
|
style.insertBefore(pPr, anchor);
|
|
40275
41036
|
}
|
|
40276
41037
|
for (const existing of children2(pPr, "numPr")) pPr.removeChild(existing);
|
|
@@ -40294,7 +41055,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
40294
41055
|
(id) => JSON.stringify(next[id]?.numbering) !== JSON.stringify(prior[id]?.numbering)
|
|
40295
41056
|
);
|
|
40296
41057
|
if (!changed.length) return;
|
|
40297
|
-
const file = zip.file(
|
|
41058
|
+
const file = zip.file(STYLES_PART2);
|
|
40298
41059
|
if (!file) throw new Error("Cannot link styles to a list: the package has no styles.xml.");
|
|
40299
41060
|
const doc = parseXml2(await file.async("string"));
|
|
40300
41061
|
const styles = children2(doc.documentElement, "style");
|
|
@@ -40305,7 +41066,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
40305
41066
|
if (!style) throw new Error(`Cannot link style "${id}" to a list: it is not in styles.xml.`);
|
|
40306
41067
|
setNumPr(style, next[id]?.numbering);
|
|
40307
41068
|
}
|
|
40308
|
-
zip.file(
|
|
41069
|
+
zip.file(STYLES_PART2, buildXml(doc));
|
|
40309
41070
|
}
|
|
40310
41071
|
|
|
40311
41072
|
// docx/write-header-footer.ts
|
|
@@ -41715,7 +42476,7 @@ function headerFooterResults(model) {
|
|
|
41715
42476
|
return void 0;
|
|
41716
42477
|
}
|
|
41717
42478
|
}
|
|
41718
|
-
async function saveDocx(model, pendingMedia) {
|
|
42479
|
+
async function saveDocx(model, pendingMedia, options2) {
|
|
41719
42480
|
const ids = /* @__PURE__ */ new Set();
|
|
41720
42481
|
for (const block of model.blocks) {
|
|
41721
42482
|
if (ids.has(block.id)) throw new Error(`Duplicate document block id: ${block.id}`);
|
|
@@ -41806,6 +42567,7 @@ async function saveDocx(model, pendingMedia) {
|
|
|
41806
42567
|
await applyNumberingCatalog(zip, model, binding);
|
|
41807
42568
|
await applyCoreProperties(zip, model.properties, binding?.base.properties);
|
|
41808
42569
|
if (binding) await applyStyleNumbering(zip, model, binding.base);
|
|
42570
|
+
if (binding) await applyStyleFormatting(zip, model, binding.base);
|
|
41809
42571
|
if (model.compatibilityMode !== binding?.base.compatibilityMode)
|
|
41810
42572
|
await applyCompatibilityMode(zip, model.compatibilityMode);
|
|
41811
42573
|
if (Boolean(model.evenAndOddHeaders) !== Boolean(binding?.base.evenAndOddHeaders))
|
|
@@ -41837,6 +42599,8 @@ async function saveDocx(model, pendingMedia) {
|
|
|
41837
42599
|
}
|
|
41838
42600
|
if (JSON.stringify(model.comments ?? []) !== JSON.stringify(binding?.base.comments ?? []))
|
|
41839
42601
|
await applyComments(zip, model.comments ?? []);
|
|
42602
|
+
if (binding) await applyDataBindings(zip, model, binding.base, binding.context.sourceXml);
|
|
42603
|
+
if (binding) await stampModified(zip, options2?.modified);
|
|
41840
42604
|
dropAddedFolders(zip, sourceEntries);
|
|
41841
42605
|
return zip.generateAsync({ type: "uint8array", compression: "DEFLATE" });
|
|
41842
42606
|
}
|
|
@@ -41892,8 +42656,11 @@ function parseCell(cell2, parseParagraph3, id, control) {
|
|
|
41892
42656
|
const element4 = child7;
|
|
41893
42657
|
if (element4.namespaceURI !== WORD_NS) return [];
|
|
41894
42658
|
if (element4.localName === "p") return [result.paragraphs[paragraphIndex++]];
|
|
41895
|
-
if (element4.localName === "tbl")
|
|
41896
|
-
|
|
42659
|
+
if (element4.localName === "tbl") {
|
|
42660
|
+
const inner = parseTable(element4, `${id}-nested${tableIndex++}`, parseParagraph3);
|
|
42661
|
+
markRestructurable(inner, element4);
|
|
42662
|
+
return [inner];
|
|
42663
|
+
}
|
|
41897
42664
|
return [];
|
|
41898
42665
|
}
|
|
41899
42666
|
);
|
|
@@ -41949,6 +42716,9 @@ function parseRowProperties(row) {
|
|
|
41949
42716
|
if (onOffElement(first2(trPr, "tblHeader"))) result.header = true;
|
|
41950
42717
|
return result;
|
|
41951
42718
|
}
|
|
42719
|
+
function markRestructurable(table, node) {
|
|
42720
|
+
if (canRestructureTable(node) && tableGrid(table)) table.restructurable = true;
|
|
42721
|
+
}
|
|
41952
42722
|
function parseTable(node, id, parseParagraph3) {
|
|
41953
42723
|
const rowEntries = flatRows(node);
|
|
41954
42724
|
const rows2 = rowEntries.map(
|
|
@@ -41989,6 +42759,7 @@ function parseTable(node, id, parseParagraph3) {
|
|
|
41989
42759
|
return properties;
|
|
41990
42760
|
});
|
|
41991
42761
|
if (rowProperties.some((row) => Object.keys(row).length)) table.rowProperties = rowProperties;
|
|
42762
|
+
if (!table.structureEditable) markRestructurable(table, node);
|
|
41992
42763
|
return table;
|
|
41993
42764
|
}
|
|
41994
42765
|
|
|
@@ -42125,23 +42896,23 @@ function parseRun2(node, revision) {
|
|
|
42125
42896
|
let noteSeparator;
|
|
42126
42897
|
let fieldChar;
|
|
42127
42898
|
const fieldCode = content.length > 0 && content.every((child7) => named2(child7, "instrText")) ? content.map((child7) => textContent(child7)).join("") : void 0;
|
|
42128
|
-
const
|
|
42129
|
-
if (
|
|
42130
|
-
if (named2(
|
|
42131
|
-
const kind = classifyBreak(
|
|
42899
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
42900
|
+
if (only2) {
|
|
42901
|
+
if (named2(only2, "br")) {
|
|
42902
|
+
const kind = classifyBreak(only2);
|
|
42132
42903
|
if (kind === "page" || kind === "column") breakKind = kind;
|
|
42133
|
-
} else if (named2(
|
|
42134
|
-
const id = getW(
|
|
42904
|
+
} else if (named2(only2, "footnoteReference")) {
|
|
42905
|
+
const id = getW(only2, "id");
|
|
42135
42906
|
if (id) noteReference = { kind: "footnote", id };
|
|
42136
|
-
} else if (named2(
|
|
42137
|
-
const id = getW(
|
|
42907
|
+
} else if (named2(only2, "endnoteReference")) {
|
|
42908
|
+
const id = getW(only2, "id");
|
|
42138
42909
|
if (id) noteReference = { kind: "endnote", id };
|
|
42139
|
-
} else if (named2(
|
|
42140
|
-
else if (named2(
|
|
42141
|
-
else if (named2(
|
|
42142
|
-
else if (named2(
|
|
42143
|
-
else if (named2(
|
|
42144
|
-
const type = getW(
|
|
42910
|
+
} else if (named2(only2, "footnoteRef")) noteMark = "footnote";
|
|
42911
|
+
else if (named2(only2, "endnoteRef")) noteMark = "endnote";
|
|
42912
|
+
else if (named2(only2, "separator")) noteSeparator = "separator";
|
|
42913
|
+
else if (named2(only2, "continuationSeparator")) noteSeparator = "continuationSeparator";
|
|
42914
|
+
else if (named2(only2, "fldChar")) {
|
|
42915
|
+
const type = getW(only2, "fldCharType");
|
|
42145
42916
|
if (type === "begin" || type === "separate" || type === "end") fieldChar = type;
|
|
42146
42917
|
}
|
|
42147
42918
|
}
|
|
@@ -42163,9 +42934,9 @@ function parseRun2(node, revision) {
|
|
|
42163
42934
|
if (noteSeparator) run2.noteSeparator = noteSeparator;
|
|
42164
42935
|
if (fieldChar) {
|
|
42165
42936
|
run2.fieldChar = fieldChar;
|
|
42166
|
-
const flags = parseFieldFlags(
|
|
42937
|
+
const flags = parseFieldFlags(only2);
|
|
42167
42938
|
if (flags) run2.fieldFlags = flags;
|
|
42168
|
-
const data = fieldChar === "begin" ? first2(
|
|
42939
|
+
const data = fieldChar === "begin" ? first2(only2, "ffData") : void 0;
|
|
42169
42940
|
const formField = data && parseFormField(data);
|
|
42170
42941
|
if (formField) run2.formField = formField;
|
|
42171
42942
|
}
|
|
@@ -42576,6 +43347,7 @@ function parseSettings(xml) {
|
|
|
42576
43347
|
);
|
|
42577
43348
|
return {
|
|
42578
43349
|
...compatibilityMode !== void 0 && Number.isInteger(compatibilityMode) && compatibilityMode > 0 ? { compatibilityMode } : {},
|
|
43350
|
+
...onOffElement(first2(first2(root, "compat"), "doNotUseHTMLParagraphAutoSpacing")) === true ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
42579
43351
|
evenAndOddHeaders: onOffElement(first2(root, "evenAndOddHeaders")) === true,
|
|
42580
43352
|
autoHyphenation: onOffElement(first2(root, "autoHyphenation")) === true,
|
|
42581
43353
|
...footnoteNumFmt ? { footnoteNumFmt } : {},
|
|
@@ -42656,6 +43428,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
42656
43428
|
return {
|
|
42657
43429
|
sections: sections2,
|
|
42658
43430
|
...settings.compatibilityMode !== void 0 ? { compatibilityMode: settings.compatibilityMode } : {},
|
|
43431
|
+
...settings.doNotUseHtmlParagraphAutoSpacing ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
42659
43432
|
...footnotes ? { footnotes } : {},
|
|
42660
43433
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
42661
43434
|
...endnotes ? { endnotes } : {},
|
|
@@ -42898,6 +43671,7 @@ async function readPackage(input) {
|
|
|
42898
43671
|
const parts = await parseDocumentParts(zip, body, blocks, drawings);
|
|
42899
43672
|
model.sections = parts.sections;
|
|
42900
43673
|
if (parts.compatibilityMode !== void 0) model.compatibilityMode = parts.compatibilityMode;
|
|
43674
|
+
if (parts.doNotUseHtmlParagraphAutoSpacing) model.doNotUseHtmlParagraphAutoSpacing = true;
|
|
42901
43675
|
if (parts.footnotes) model.footnotes = parts.footnotes;
|
|
42902
43676
|
if (parts.footnoteSeparators) model.footnoteSeparators = parts.footnoteSeparators;
|
|
42903
43677
|
if (parts.endnotes) model.endnotes = parts.endnotes;
|
|
@@ -42907,14 +43681,16 @@ async function readPackage(input) {
|
|
|
42907
43681
|
if (parts.autoHyphenation) model.autoHyphenation = true;
|
|
42908
43682
|
const coreFile = zip.file("docProps/core.xml");
|
|
42909
43683
|
if (coreFile) {
|
|
42910
|
-
const properties =
|
|
43684
|
+
const properties = parseCoreProperties2(await coreFile.async("string"));
|
|
42911
43685
|
if (properties) model.properties = properties;
|
|
42912
43686
|
}
|
|
42913
43687
|
await readPlaceholderTexts(zip, drawings.rels, model);
|
|
42914
43688
|
const pageColor = parsePageBackground(document.documentElement);
|
|
42915
43689
|
if (pageColor) model.pageColor = pageColor;
|
|
42916
43690
|
model.warnings.push(...parts.warnings);
|
|
42917
|
-
if (blocks.some(
|
|
43691
|
+
if (blocks.some(
|
|
43692
|
+
(block) => block.type === "table" && !block.structureEditable && !block.restructurable
|
|
43693
|
+
))
|
|
42918
43694
|
model.warnings.push(
|
|
42919
43695
|
"Merged, nested, or complex tables can be read, but their row and column structure cannot be edited safely."
|
|
42920
43696
|
);
|
|
@@ -42940,7 +43716,7 @@ async function readPackage(input) {
|
|
|
42940
43716
|
(block) => block.type === "table" && block.rows.some((row) => row.some((cell2) => cell2.nestedTables?.length))
|
|
42941
43717
|
))
|
|
42942
43718
|
model.warnings.push(
|
|
42943
|
-
"Text
|
|
43719
|
+
"Text and structure (rows, columns, merged and split cells) of nested tables are editable; their borders, shading and other formatting are preserved but cannot be changed."
|
|
42944
43720
|
);
|
|
42945
43721
|
const pictureBlocks = documentDrawingBlocks({ ...model, blocks });
|
|
42946
43722
|
await resolveDocumentDiagrams(
|
|
@@ -42978,9 +43754,9 @@ async function loadDocx(input) {
|
|
|
42978
43754
|
return {
|
|
42979
43755
|
model,
|
|
42980
43756
|
media,
|
|
42981
|
-
save: (next = model, pendingMedia) => {
|
|
43757
|
+
save: (next = model, pendingMedia, options2) => {
|
|
42982
43758
|
if (next !== model) remember(next, context);
|
|
42983
|
-
return saveDocx(next, pendingMedia);
|
|
43759
|
+
return saveDocx(next, pendingMedia, options2);
|
|
42984
43760
|
}
|
|
42985
43761
|
};
|
|
42986
43762
|
}
|
|
@@ -43351,7 +44127,7 @@ function reviewDocumentFormatting(model, mode) {
|
|
|
43351
44127
|
}
|
|
43352
44128
|
|
|
43353
44129
|
// docx/revision-commands.ts
|
|
43354
|
-
function
|
|
44130
|
+
function paragraphsOf3(blocks) {
|
|
43355
44131
|
const paragraphs = [];
|
|
43356
44132
|
for (const block of blocks)
|
|
43357
44133
|
if (block.type === "paragraph") paragraphs.push(block);
|
|
@@ -43359,7 +44135,7 @@ function paragraphsOf2(blocks) {
|
|
|
43359
44135
|
return paragraphs;
|
|
43360
44136
|
}
|
|
43361
44137
|
function documentParagraphs2(model) {
|
|
43362
|
-
return documentBlockLists(model).flatMap(
|
|
44138
|
+
return documentBlockLists(model).flatMap(paragraphsOf3);
|
|
43363
44139
|
}
|
|
43364
44140
|
function listRevisions(model) {
|
|
43365
44141
|
const entries = [];
|
|
@@ -44568,13 +45344,13 @@ function resolveCellVisuals(table, cell2, placement, styles) {
|
|
|
44568
45344
|
function visibleText(paragraph2) {
|
|
44569
45345
|
return paragraph2.runs.filter((run2) => !run2.fieldCode && !run2.fieldChar).filter((run2) => run2.revision?.kind !== "delete" && run2.revision?.kind !== "moveFrom").map((run2) => run2.text).join("");
|
|
44570
45346
|
}
|
|
44571
|
-
function
|
|
45347
|
+
function paragraphsOf4(blocks) {
|
|
44572
45348
|
return blocks.flatMap(
|
|
44573
45349
|
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell2) => cell2.paragraphs))
|
|
44574
45350
|
);
|
|
44575
45351
|
}
|
|
44576
45352
|
function documentStats(model) {
|
|
44577
|
-
const paragraphs =
|
|
45353
|
+
const paragraphs = paragraphsOf4(model.blocks);
|
|
44578
45354
|
const text2 = paragraphs.map(visibleText).join("");
|
|
44579
45355
|
const revisions = paragraphs.reduce(
|
|
44580
45356
|
(count, paragraph2) => count + paragraph2.runs.filter((run2) => run2.revision).length + (paragraph2.markRevision ? 1 : 0),
|