ooxml-core 1.30.1 → 1.32.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-KKLAYUGQ.mjs → PptxHandler-QY5VL3CY.mjs} +2 -2
- package/dist/PptxHandler-SJ5ZUIUX.mjs +4 -0
- package/dist/{PptxHandler-DHQPVTUI.cjs → PptxHandler-TESZUH66.cjs} +3 -3
- package/dist/{PresentationBuilder-YYZYCKTZ.mjs → PresentationBuilder-3CH5TR4W.mjs} +2 -2
- package/dist/{PresentationBuilder-JORMF5CP.cjs → PresentationBuilder-5NFBUP7Y.cjs} +5 -5
- package/dist/{PresentationBuilder-Q2Z33LLM.mjs → PresentationBuilder-S6HXHKEJ.mjs} +2 -2
- package/dist/automation/index.cjs +6446 -3410
- package/dist/automation/index.mjs +6446 -3410
- 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-GJDFCP2T.mjs → chunk-3H5UAJB3.mjs} +258 -155
- package/dist/{chunk-MKDONWNO.mjs → chunk-4R65YYAD.mjs} +32 -14
- package/dist/{chunk-KWJYMAEF.mjs → chunk-IOTGRLJH.mjs} +255 -152
- package/dist/{chunk-6FXOAMNL.mjs → chunk-N6424WKA.mjs} +1 -1
- package/dist/{chunk-WZJ25K7P.mjs → chunk-NAWLWKOJ.mjs} +1 -1
- package/dist/{chunk-DJ3CDTMX.mjs → chunk-O7SVHLD7.mjs} +23 -5
- package/dist/{chunk-CZXM4ZJH.cjs → chunk-Q6NM64J2.cjs} +23 -4
- package/dist/{chunk-FFJBOR2Y.mjs → chunk-UYMSFJQZ.mjs} +76 -4
- package/dist/{chunk-B4LXDHBX.cjs → chunk-X6VNUBES.cjs} +1419 -1316
- 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/diagram/index.cjs +8 -4
- package/dist/diagram/index.mjs +8 -4
- 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 +1391 -613
- package/dist/docx/embedded.mjs +1391 -613
- package/dist/docx/index.cjs +1402 -622
- package/dist/docx/index.mjs +1402 -622
- 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 +460 -207
- package/dist/docx/layout/index.mjs +460 -207
- 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 +1405 -627
- package/dist/docx/load/index.mjs +1405 -627
- 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 +725 -260
- 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 +711 -261
- 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/geometry/index.cjs +16 -12
- package/dist/geometry/index.mjs +16 -12
- package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
- package/dist/index.cjs +38 -34
- package/dist/index.mjs +38 -34
- 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 +295 -157
- package/dist/pptx/automation/index.d.ts +9 -3
- 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 → index-D-FdgqrP.d.ts} +102 -3
- package/dist/pptx/chunks/index-D-FdgqrP.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BQDcu_0a.d.ts → index-DKybuHPT.d.ts} +51 -3
- package/dist/pptx/chunks/{index-BQDcu_0a.d.ts.map → index-DKybuHPT.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-CBV1oHN7.d.ts → index-DnWlmYCy.d.ts} +2 -2
- package/dist/pptx/chunks/{index-CBV1oHN7.d.ts.map → index-DnWlmYCy.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +294 -157
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +8 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +1 -1
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/index.cjs +380 -171
- package/dist/pptx/index.d.ts +4 -4
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/teams/chat-rooms.d.ts.map +1 -1
- package/dist/teams/chat-view.d.ts +10 -1
- package/dist/teams/chat-view.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 +3471 -1223
- package/dist/teams/index.d.ts +4 -0
- package/dist/teams/index.d.ts.map +1 -1
- package/dist/teams/index.mjs +3435 -1223
- package/dist/teams/message-transfer.d.ts +1 -1
- package/dist/teams/message-transfer.d.ts.map +1 -1
- package/dist/teams/presence-controller.d.ts +18 -3
- package/dist/teams/presence-controller.d.ts.map +1 -1
- package/dist/teams/presence-meetings.d.ts +21 -0
- package/dist/teams/presence-meetings.d.ts.map +1 -0
- package/dist/teams/presence.d.ts +40 -2
- package/dist/teams/presence.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 +14 -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/view.d.ts +5 -0
- package/dist/teams/view.d.ts.map +1 -1
- package/dist/teams/workspace.d.ts +17 -2
- 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 +1359 -396
- package/dist/visio/index.mjs +1359 -396
- package/dist/visio/ui/index.cjs +1346 -383
- package/dist/visio/ui/index.mjs +1346 -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-drift-compare.d.ts +19 -0
- package/dist/xlsx/formula/ets-drift-compare.d.ts.map +1 -0
- package/dist/xlsx/formula/ets-excel-compare.d.ts +36 -0
- package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -0
- package/dist/xlsx/formula/ets-init-compare.d.ts +24 -0
- package/dist/xlsx/formula/ets-init-compare.d.ts.map +1 -0
- package/dist/xlsx/formula/ets-init-maps.d.ts +21 -0
- package/dist/xlsx/formula/ets-init-maps.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-chain.d.ts +11 -0
- package/dist/xlsx/formula/functions/ets-init-chain.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-four.d.ts +3 -0
- package/dist/xlsx/formula/functions/ets-init-four.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-short.d.ts +17 -0
- package/dist/xlsx/formula/functions/ets-init-short.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-states.d.ts +5 -0
- package/dist/xlsx/formula/functions/ets-init-states.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-three.d.ts +23 -0
- package/dist/xlsx/formula/functions/ets-init-three.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts +13 -0
- package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init.d.ts +33 -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-search-map.d.ts +24 -0
- package/dist/xlsx/formula/functions/ets-search-map.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-search.d.ts +17 -0
- package/dist/xlsx/formula/functions/ets-search.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/ets-validate.d.ts +16 -0
- package/dist/xlsx/formula/functions/ets-validate.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 +5118 -2648
- package/dist/xlsx/index.mjs +5097 -2649
- 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 +2667 -1163
- package/dist/xlsx/load/index.mjs +2667 -1163
- 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 +5088 -2399
- 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 +5081 -2398
- 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/PptxHandler-E4DDV3FQ.mjs +0 -4
- package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +0 -1
package/dist/docx/index.cjs
CHANGED
|
@@ -11,6 +11,8 @@ var JSZip__default = /*#__PURE__*/_interopDefault(JSZip);
|
|
|
11
11
|
var NS = {
|
|
12
12
|
/** WordprocessingML main. */
|
|
13
13
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
14
|
+
/** PresentationML main. */
|
|
15
|
+
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
14
16
|
/** SpreadsheetML main. */
|
|
15
17
|
x: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
|
|
16
18
|
/** DrawingML main. */
|
|
@@ -25,6 +27,12 @@ var NS = {
|
|
|
25
27
|
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
26
28
|
/** Office 2007+ diagram drawing (`dsp`). */
|
|
27
29
|
dsp: "http://schemas.microsoft.com/office/drawing/2008/diagram",
|
|
30
|
+
/** DrawingML Word drawing (`wp:inline`, `wp:anchor`). */
|
|
31
|
+
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
32
|
+
/** DrawingML picture. */
|
|
33
|
+
pic: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
34
|
+
/** Word 2010 shapes (`wps`). */
|
|
35
|
+
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
|
28
36
|
/** Relationships (`r:id`, `r:embed`). */
|
|
29
37
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
30
38
|
/** Markup compatibility (`mc:AlternateContent`). */
|
|
@@ -32,7 +40,42 @@ var NS = {
|
|
|
32
40
|
/** OPC relationships part. */
|
|
33
41
|
rels: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
34
42
|
/** OPC content types part. */
|
|
35
|
-
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
43
|
+
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
44
|
+
/** Office Math. */
|
|
45
|
+
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
46
|
+
/** Core properties. */
|
|
47
|
+
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
48
|
+
/** Dublin Core elements. */
|
|
49
|
+
dc: "http://purl.org/dc/elements/1.1/",
|
|
50
|
+
/** Legacy VML. */
|
|
51
|
+
v: "urn:schemas-microsoft-com:vml",
|
|
52
|
+
/** Office VML extensions. */
|
|
53
|
+
o: "urn:schemas-microsoft-com:office:office",
|
|
54
|
+
/** Word VML extensions. */
|
|
55
|
+
w10: "urn:schemas-microsoft-com:office:word",
|
|
56
|
+
/** SpreadsheetML drawing (`xdr:wsDr`, cell anchors). */
|
|
57
|
+
xdr: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
|
|
58
|
+
/** SpreadsheetML 2009 extensions (`x14:conditionalFormatting`, `x14:dataBar`). */
|
|
59
|
+
x14: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
60
|
+
/** SpreadsheetML 2009 attribute extensions (`x14ac:dyDescent`). */
|
|
61
|
+
x14ac: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac",
|
|
62
|
+
/** SpreadsheetML revision ids (`xr:uid`). */
|
|
63
|
+
xr: "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
|
|
64
|
+
/** Excel threaded comments and persons. */
|
|
65
|
+
tc: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
|
|
66
|
+
/** Legacy VML Excel client data (`x:ClientData`). */
|
|
67
|
+
xv: "urn:schemas-microsoft-com:office:excel",
|
|
68
|
+
/** Extended (app) properties. */
|
|
69
|
+
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
|
|
70
|
+
/** Dublin Core terms (`dcterms:created`). */
|
|
71
|
+
dcterms: "http://purl.org/dc/terms/",
|
|
72
|
+
/** Custom document properties (`docProps/custom.xml`). */
|
|
73
|
+
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
|
74
|
+
/** Document property variant types (`vt:lpwstr`, `vt:vector`). */
|
|
75
|
+
vt: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
76
|
+
/** XML itself (`xml:space`). */
|
|
77
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
78
|
+
};
|
|
36
79
|
var DEFAULT_XML_LIMITS = {
|
|
37
80
|
maxDepth: 512,
|
|
38
81
|
maxNodes: 5e6
|
|
@@ -1115,6 +1158,10 @@ function parseFormatting(pPr) {
|
|
|
1115
1158
|
const line3 = signedTwipValue(getW(spacing3, "line"));
|
|
1116
1159
|
if (before !== void 0) result.spacingBeforeTwips = before;
|
|
1117
1160
|
if (after !== void 0) result.spacingAfterTwips = after;
|
|
1161
|
+
const beforeAuto = parseOnOff(getW(spacing3, "beforeAutospacing"));
|
|
1162
|
+
const afterAuto = parseOnOff(getW(spacing3, "afterAutospacing"));
|
|
1163
|
+
if (beforeAuto !== void 0) result.spacingBeforeAuto = beforeAuto;
|
|
1164
|
+
if (afterAuto !== void 0) result.spacingAfterAuto = afterAuto;
|
|
1118
1165
|
if (line3 !== void 0) result.lineSpacingTwips = line3;
|
|
1119
1166
|
const rule = getW(spacing3, "lineRule");
|
|
1120
1167
|
if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
|
|
@@ -1213,6 +1260,8 @@ function resolveParagraphFormatting(paragraph2, catalog) {
|
|
|
1213
1260
|
"direction",
|
|
1214
1261
|
"spacingBeforeTwips",
|
|
1215
1262
|
"spacingAfterTwips",
|
|
1263
|
+
"spacingBeforeAuto",
|
|
1264
|
+
"spacingAfterAuto",
|
|
1216
1265
|
"lineSpacingTwips",
|
|
1217
1266
|
"lineSpacingRule",
|
|
1218
1267
|
"indentLeftTwips",
|
|
@@ -2314,7 +2363,7 @@ function applyPictureEffects(blip, effects) {
|
|
|
2314
2363
|
const node = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
2315
2364
|
if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
|
|
2316
2365
|
throw new Error("Picture effect source does not match its kind");
|
|
2317
|
-
const
|
|
2366
|
+
const set2 = (name2, value) => {
|
|
2318
2367
|
const original = picturePercentage(node.getAttribute(name2));
|
|
2319
2368
|
if (value === void 0) node.removeAttribute(name2);
|
|
2320
2369
|
else if (value !== original) {
|
|
@@ -2327,12 +2376,12 @@ function applyPictureEffects(blip, effects) {
|
|
|
2327
2376
|
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
2328
2377
|
))
|
|
2329
2378
|
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
2330
|
-
|
|
2331
|
-
|
|
2379
|
+
set2("bright", effect.brightness);
|
|
2380
|
+
set2("contrast", effect.contrast);
|
|
2332
2381
|
}
|
|
2333
2382
|
if (effect.kind === "alphaModFix") {
|
|
2334
2383
|
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
2335
|
-
|
|
2384
|
+
set2("amt", effect.amount);
|
|
2336
2385
|
}
|
|
2337
2386
|
return node;
|
|
2338
2387
|
});
|
|
@@ -3703,6 +3752,233 @@ async function openZip(input, limits = {}) {
|
|
|
3703
3752
|
return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
|
|
3704
3753
|
}
|
|
3705
3754
|
|
|
3755
|
+
// opc/properties/patch.ts
|
|
3756
|
+
var XMLNS3 = "http://www.w3.org/2000/xmlns/";
|
|
3757
|
+
function tagEnd(xml, from) {
|
|
3758
|
+
let quote = "";
|
|
3759
|
+
for (let i = from + 1; i < xml.length; i++) {
|
|
3760
|
+
const ch = xml[i];
|
|
3761
|
+
if (quote) {
|
|
3762
|
+
if (ch === quote) quote = "";
|
|
3763
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
3764
|
+
else if (ch === ">") return i + 1;
|
|
3765
|
+
}
|
|
3766
|
+
throw new Error("Unterminated tag in property part");
|
|
3767
|
+
}
|
|
3768
|
+
function skipMarkup(xml, at) {
|
|
3769
|
+
if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
|
|
3770
|
+
if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
|
|
3771
|
+
if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
|
|
3772
|
+
return void 0;
|
|
3773
|
+
}
|
|
3774
|
+
function scan(xml) {
|
|
3775
|
+
let i = 0;
|
|
3776
|
+
let rootStart = -1;
|
|
3777
|
+
while (rootStart < 0) {
|
|
3778
|
+
const lt = xml.indexOf("<", i);
|
|
3779
|
+
if (lt < 0) throw new Error("Property part has no root element");
|
|
3780
|
+
const skipped = skipMarkup(xml, lt);
|
|
3781
|
+
if (skipped !== void 0) i = skipped;
|
|
3782
|
+
else rootStart = lt;
|
|
3783
|
+
}
|
|
3784
|
+
const openEnd = tagEnd(xml, rootStart);
|
|
3785
|
+
if (xml[openEnd - 2] === "/") {
|
|
3786
|
+
const root = {
|
|
3787
|
+
start: rootStart,
|
|
3788
|
+
openEnd,
|
|
3789
|
+
closeStart: openEnd,
|
|
3790
|
+
end: openEnd,
|
|
3791
|
+
selfClosing: true
|
|
3792
|
+
};
|
|
3793
|
+
return { root, children: [] };
|
|
3794
|
+
}
|
|
3795
|
+
const children3 = [];
|
|
3796
|
+
let depth = 0;
|
|
3797
|
+
let child7;
|
|
3798
|
+
i = openEnd;
|
|
3799
|
+
for (; ; ) {
|
|
3800
|
+
const lt = xml.indexOf("<", i);
|
|
3801
|
+
if (lt < 0) throw new Error("Property part root is not closed");
|
|
3802
|
+
const skipped = skipMarkup(xml, lt);
|
|
3803
|
+
if (skipped !== void 0) {
|
|
3804
|
+
i = skipped;
|
|
3805
|
+
continue;
|
|
3806
|
+
}
|
|
3807
|
+
const end = tagEnd(xml, lt);
|
|
3808
|
+
i = end;
|
|
3809
|
+
if (xml[lt + 1] === "/") {
|
|
3810
|
+
if (depth === 0) {
|
|
3811
|
+
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
3812
|
+
return { root, children: children3 };
|
|
3813
|
+
}
|
|
3814
|
+
depth--;
|
|
3815
|
+
if (depth === 0 && child7)
|
|
3816
|
+
children3.push({ ...child7, closeStart: lt, end, selfClosing: false });
|
|
3817
|
+
} else if (xml[end - 2] === "/") {
|
|
3818
|
+
if (depth === 0)
|
|
3819
|
+
children3.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
3820
|
+
} else {
|
|
3821
|
+
if (depth === 0) child7 = { start: lt, openEnd: end };
|
|
3822
|
+
depth++;
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
var escapeText = (text2) => text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
3827
|
+
var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
3828
|
+
var PartPatch = class {
|
|
3829
|
+
constructor(xml, rootElement) {
|
|
3830
|
+
this.xml = xml;
|
|
3831
|
+
const { root, children: children3 } = scan(xml);
|
|
3832
|
+
const kids = elements(rootElement);
|
|
3833
|
+
if (kids.length !== children3.length) throw new Error("Property part markup is not supported");
|
|
3834
|
+
kids.forEach((kid, index) => this.spans.set(kid, children3[index]));
|
|
3835
|
+
this.root = root;
|
|
3836
|
+
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
3837
|
+
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
3838
|
+
else if (attribute2.namespaceURI === XMLNS3 || attribute2.name.startsWith("xmlns:"))
|
|
3839
|
+
this.prefixes.set(attribute2.value, attribute2.localName);
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
xml;
|
|
3843
|
+
root;
|
|
3844
|
+
spans = /* @__PURE__ */ new Map();
|
|
3845
|
+
edits = [];
|
|
3846
|
+
appended = [];
|
|
3847
|
+
prefixes = /* @__PURE__ */ new Map();
|
|
3848
|
+
defaultNs = null;
|
|
3849
|
+
seq = 0;
|
|
3850
|
+
add(start, end, text2) {
|
|
3851
|
+
this.edits.push({ start, end, text: text2, seq: this.seq++ });
|
|
3852
|
+
}
|
|
3853
|
+
span(element4) {
|
|
3854
|
+
const span = this.spans.get(element4);
|
|
3855
|
+
if (!span) throw new Error("Element is not a child of the patched root");
|
|
3856
|
+
return span;
|
|
3857
|
+
}
|
|
3858
|
+
/** The prefix bound to `ns` on the root, declaring `preferred` for it when none is. */
|
|
3859
|
+
prefix(ns, preferred) {
|
|
3860
|
+
const known = this.prefixes.get(ns);
|
|
3861
|
+
if (known !== void 0) return known;
|
|
3862
|
+
const taken = new Set(this.prefixes.values());
|
|
3863
|
+
let prefix2 = preferred;
|
|
3864
|
+
for (let n2 = 1; taken.has(prefix2); n2++) prefix2 = `${preferred}${n2}`;
|
|
3865
|
+
this.prefixes.set(ns, prefix2);
|
|
3866
|
+
const at = this.root.openEnd - (this.root.selfClosing ? 2 : 1);
|
|
3867
|
+
this.add(at, at, ` xmlns:${prefix2}="${ns}"`);
|
|
3868
|
+
return prefix2;
|
|
3869
|
+
}
|
|
3870
|
+
/** `local` qualified for an element in `ns`: unprefixed in the default namespace. */
|
|
3871
|
+
qualify(ns, local, preferred) {
|
|
3872
|
+
return this.defaultNs === ns && !this.prefixes.has(ns) ? local : `${this.prefix(ns, preferred)}:${local}`;
|
|
3873
|
+
}
|
|
3874
|
+
/** Replaces the element's content, keeping its start tag (and attributes) as written. */
|
|
3875
|
+
setContent(element4, content) {
|
|
3876
|
+
const span = this.span(element4);
|
|
3877
|
+
if (span.selfClosing)
|
|
3878
|
+
this.add(span.openEnd - 2, span.openEnd, `>${content}</${qualifiedName(this.xml, span)}>`);
|
|
3879
|
+
else this.add(span.openEnd, span.closeStart, content);
|
|
3880
|
+
}
|
|
3881
|
+
/** Adds ` name="value"` text to the element's start tag. */
|
|
3882
|
+
addAttribute(element4, attribute2) {
|
|
3883
|
+
const span = this.span(element4);
|
|
3884
|
+
const at = span.openEnd - (span.selfClosing ? 2 : 1);
|
|
3885
|
+
this.add(at, at, attribute2);
|
|
3886
|
+
}
|
|
3887
|
+
remove(element4) {
|
|
3888
|
+
const span = this.span(element4);
|
|
3889
|
+
this.add(span.start, span.end, "");
|
|
3890
|
+
}
|
|
3891
|
+
/** Inserts `markup` before `before`, or as the root's last child. */
|
|
3892
|
+
insert(markup, before) {
|
|
3893
|
+
if (before) {
|
|
3894
|
+
const at = this.span(before).start;
|
|
3895
|
+
this.add(at, at, markup);
|
|
3896
|
+
} else this.appended.push(markup);
|
|
3897
|
+
}
|
|
3898
|
+
toString() {
|
|
3899
|
+
const edits = [...this.edits];
|
|
3900
|
+
if (this.appended.length) {
|
|
3901
|
+
const text2 = this.appended.join("");
|
|
3902
|
+
const root = this.root;
|
|
3903
|
+
if (root.selfClosing) {
|
|
3904
|
+
const name = qualifiedName(this.xml, root);
|
|
3905
|
+
edits.push({
|
|
3906
|
+
start: root.end - 2,
|
|
3907
|
+
end: root.end,
|
|
3908
|
+
text: `>${text2}</${name}>`,
|
|
3909
|
+
seq: this.seq
|
|
3910
|
+
});
|
|
3911
|
+
} else edits.push({ start: root.closeStart, end: root.closeStart, text: text2, seq: this.seq });
|
|
3912
|
+
}
|
|
3913
|
+
edits.sort((a2, b) => a2.start - b.start || a2.end - a2.start - (b.end - b.start) || a2.seq - b.seq);
|
|
3914
|
+
let out = "";
|
|
3915
|
+
let at = 0;
|
|
3916
|
+
for (const edit of edits) {
|
|
3917
|
+
out += this.xml.slice(at, edit.start) + edit.text;
|
|
3918
|
+
at = Math.max(at, edit.end);
|
|
3919
|
+
}
|
|
3920
|
+
return out + this.xml.slice(at);
|
|
3921
|
+
}
|
|
3922
|
+
};
|
|
3923
|
+
|
|
3924
|
+
// opc/properties/core.ts
|
|
3925
|
+
var XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
3926
|
+
var FIELDS = [
|
|
3927
|
+
["title", "dc", false],
|
|
3928
|
+
["subject", "dc", false],
|
|
3929
|
+
["creator", "dc", false],
|
|
3930
|
+
["keywords", "cp", false],
|
|
3931
|
+
["description", "dc", false],
|
|
3932
|
+
["lastModifiedBy", "cp", false],
|
|
3933
|
+
["created", "dcterms", true],
|
|
3934
|
+
["modified", "dcterms", true],
|
|
3935
|
+
["category", "cp", false],
|
|
3936
|
+
["contentStatus", "cp", false],
|
|
3937
|
+
["revision", "cp", false],
|
|
3938
|
+
["language", "dc", false],
|
|
3939
|
+
["identifier", "dc", false],
|
|
3940
|
+
["lastPrinted", "cp", false],
|
|
3941
|
+
["version", "cp", false]
|
|
3942
|
+
];
|
|
3943
|
+
FIELDS.map(([field]) => field);
|
|
3944
|
+
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3945
|
+
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
3946
|
+
function parseCoreProperties(xml) {
|
|
3947
|
+
const out = {};
|
|
3948
|
+
if (!xml) return out;
|
|
3949
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3950
|
+
for (const [field, prefix2] of FIELDS) {
|
|
3951
|
+
const text2 = first(root, field, NS[prefix2])?.textContent ?? "";
|
|
3952
|
+
if (text2 !== "") out[field] = text2;
|
|
3953
|
+
}
|
|
3954
|
+
return out;
|
|
3955
|
+
}
|
|
3956
|
+
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
3957
|
+
function writeCoreProperties(props, sourceXml) {
|
|
3958
|
+
const xml = sourceXml ?? EMPTY_CORE;
|
|
3959
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3960
|
+
const patch = new PartPatch(xml, root);
|
|
3961
|
+
for (const [field, prefix2, isDate] of FIELDS) {
|
|
3962
|
+
const ns = NS[prefix2];
|
|
3963
|
+
const value = props[field];
|
|
3964
|
+
const element4 = first(root, field, ns);
|
|
3965
|
+
if (value === void 0 || value === "") {
|
|
3966
|
+
if (element4 && (element4.textContent ?? "") !== "") patch.remove(element4);
|
|
3967
|
+
continue;
|
|
3968
|
+
}
|
|
3969
|
+
if (element4 && element4.textContent === value) continue;
|
|
3970
|
+
const typed = () => ` ${patch.prefix(XSI, "xsi")}:type="${patch.prefix(NS.dcterms, "dcterms")}:W3CDTF"`;
|
|
3971
|
+
if (element4) {
|
|
3972
|
+
if (isDate && !element4.getAttributeNS(XSI, "type")) patch.addAttribute(element4, typed());
|
|
3973
|
+
patch.setContent(element4, escapeText(value));
|
|
3974
|
+
continue;
|
|
3975
|
+
}
|
|
3976
|
+
const name = patch.qualify(ns, field, prefix2);
|
|
3977
|
+
patch.insert(`<${name}${isDate ? typed() : ""}>${escapeText(value)}</${name}>`);
|
|
3978
|
+
}
|
|
3979
|
+
return patch.toString();
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3706
3982
|
// opc/signature/xml-utils.ts
|
|
3707
3983
|
function escapeXmlAttr(value) {
|
|
3708
3984
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -3735,7 +4011,7 @@ var PREFIX = {
|
|
|
3735
4011
|
};
|
|
3736
4012
|
var CORE_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
3737
4013
|
var CORE_REL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
3738
|
-
function
|
|
4014
|
+
function parseCoreProperties2(xml) {
|
|
3739
4015
|
const root = parseXml2(xml).documentElement;
|
|
3740
4016
|
const result = {};
|
|
3741
4017
|
for (const field of PROPERTY_FIELDS) {
|
|
@@ -3803,265 +4079,18 @@ function dropAddedFolders(zip, source2) {
|
|
|
3803
4079
|
if (entry2.dir && !source2.has(name)) delete zip.files[name];
|
|
3804
4080
|
}
|
|
3805
4081
|
|
|
3806
|
-
// docx/
|
|
3807
|
-
var
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
equation: "equation",
|
|
3818
|
-
citation: "citation",
|
|
3819
|
-
bibliography: "bibliography",
|
|
3820
|
-
docPartObj: "docPartObj",
|
|
3821
|
-
docPartList: "docPartList"
|
|
3822
|
-
};
|
|
3823
|
-
function attrW14(element4, local) {
|
|
3824
|
-
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
3825
|
-
}
|
|
3826
|
-
function glyph(element4) {
|
|
3827
|
-
const code = attrW14(element4, "val");
|
|
3828
|
-
if (!code) return void 0;
|
|
3829
|
-
const font = attrW14(element4, "font");
|
|
3830
|
-
return { code, ...font ? { font } : {} };
|
|
3831
|
-
}
|
|
3832
|
-
function kindOf(child7) {
|
|
3833
|
-
if (child7.namespaceURI === WORD_NS)
|
|
3834
|
-
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
3835
|
-
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
3836
|
-
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
3837
|
-
return "repeatingSection";
|
|
3838
|
-
return void 0;
|
|
3839
|
-
}
|
|
3840
|
-
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
3841
|
-
(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"
|
|
3842
|
-
);
|
|
3843
|
-
function parseKind(sdtPr) {
|
|
3844
|
-
const [type] = typeElements(sdtPr);
|
|
3845
|
-
return (type && kindOf(type)) ?? "richText";
|
|
3846
|
-
}
|
|
3847
|
-
var generated = 0;
|
|
3848
|
-
function parseContentControl(sdt, level4) {
|
|
3849
|
-
const sdtPr = first2(sdt, "sdtPr");
|
|
3850
|
-
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level4, kind: "richText" };
|
|
3851
|
-
const kind = parseKind(sdtPr);
|
|
3852
|
-
const control = {
|
|
3853
|
-
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
3854
|
-
level: level4,
|
|
3855
|
-
kind
|
|
3856
|
-
};
|
|
3857
|
-
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
3858
|
-
if (alias !== void 0) control.alias = alias;
|
|
3859
|
-
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
3860
|
-
if (tag !== void 0) control.tag = tag;
|
|
3861
|
-
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
3862
|
-
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
3863
|
-
control.lock = lock;
|
|
3864
|
-
const showing = first2(sdtPr, "showingPlcHdr");
|
|
3865
|
-
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
3866
|
-
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
3867
|
-
const temporary = first2(sdtPr, "temporary");
|
|
3868
|
-
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
3869
|
-
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
3870
|
-
if (placeholder) control.placeholder = placeholder;
|
|
3871
|
-
if (kind === "text") {
|
|
3872
|
-
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
3873
|
-
if (multi) control.multiLine = true;
|
|
3874
|
-
}
|
|
3875
|
-
if (kind === "checkbox") {
|
|
3876
|
-
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
3877
|
-
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
3878
|
-
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
3879
|
-
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
3880
|
-
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
3881
|
-
if (on) control.checkedGlyph = on;
|
|
3882
|
-
if (off) control.uncheckedGlyph = off;
|
|
3883
|
-
}
|
|
3884
|
-
if (kind === "dropDownList" || kind === "comboBox") {
|
|
3885
|
-
const list2 = first2(sdtPr, kind);
|
|
3886
|
-
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
3887
|
-
const display = getW(item2, "displayText");
|
|
3888
|
-
const value = getW(item2, "value") ?? display ?? "";
|
|
3889
|
-
return { display: display ?? value, value };
|
|
3890
|
-
});
|
|
3891
|
-
}
|
|
3892
|
-
if (kind === "date") {
|
|
3893
|
-
const date = first2(sdtPr, "date");
|
|
3894
|
-
const fullDate = getW(date, "fullDate");
|
|
3895
|
-
if (fullDate) control.fullDate = fullDate;
|
|
3896
|
-
const format = getW(first2(date, "dateFormat"), "val");
|
|
3897
|
-
if (format) control.dateFormat = format;
|
|
3898
|
-
const lid = getW(first2(date, "lid"), "val");
|
|
3899
|
-
if (lid) control.dateLocale = lid;
|
|
3900
|
-
}
|
|
3901
|
-
control.sourceXml = buildXml(sdtPr);
|
|
3902
|
-
const end = first2(sdt, "sdtEndPr");
|
|
3903
|
-
if (end) control.endSourceXml = buildXml(end);
|
|
3904
|
-
return control;
|
|
3905
|
-
}
|
|
3906
|
-
|
|
3907
|
-
// docx/expect-defined.ts
|
|
3908
|
-
function expectDefined(value, context) {
|
|
3909
|
-
if (value === void 0 || value === null) {
|
|
3910
|
-
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
3911
|
-
}
|
|
3912
|
-
return value;
|
|
3913
|
-
}
|
|
3914
|
-
|
|
3915
|
-
// docx/parse-revisions.ts
|
|
3916
|
-
var REVISION_WRAPPERS = {
|
|
3917
|
-
ins: "insert",
|
|
3918
|
-
del: "delete",
|
|
3919
|
-
moveFrom: "moveFrom",
|
|
3920
|
-
moveTo: "moveTo"
|
|
3921
|
-
};
|
|
3922
|
-
var MOVE_RANGES = {
|
|
3923
|
-
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
3924
|
-
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
3925
|
-
moveToRangeStart: { kind: "moveTo", start: true },
|
|
3926
|
-
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
3927
|
-
};
|
|
3928
|
-
function trackMoveRange(item2, moves) {
|
|
3929
|
-
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
3930
|
-
const range2 = MOVE_RANGES[item2.localName ?? ""];
|
|
3931
|
-
if (!range2) return false;
|
|
3932
|
-
const id = getW(item2, "id") ?? "";
|
|
3933
|
-
const open = moves[range2.kind];
|
|
3934
|
-
if (range2.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
3935
|
-
else {
|
|
3936
|
-
const index = open.findIndex((entry2) => entry2.id === id);
|
|
3937
|
-
if (index >= 0) open.splice(index, 1);
|
|
3938
|
-
}
|
|
3939
|
-
return true;
|
|
3940
|
-
}
|
|
3941
|
-
function isCommentReferenceRun(run2) {
|
|
3942
|
-
const content = Array.from(run2.childNodes).filter(
|
|
3943
|
-
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
3944
|
-
);
|
|
3945
|
-
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
3946
|
-
}
|
|
3947
|
-
function revisionFrom(node, kind) {
|
|
3948
|
-
const revision = {
|
|
3949
|
-
kind,
|
|
3950
|
-
author: getW(node, "author") || "Unknown",
|
|
3951
|
-
id: getW(node, "id") ?? "0"
|
|
3952
|
-
};
|
|
3953
|
-
const date = getW(node, "date");
|
|
3954
|
-
if (date) revision.date = date;
|
|
3955
|
-
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
3956
|
-
if (dateUtc) revision.dateUtc = dateUtc;
|
|
3957
|
-
return revision;
|
|
3958
|
-
}
|
|
3959
|
-
function paragraphMarkRevision(pPr) {
|
|
3960
|
-
const rPr = first2(pPr, "rPr");
|
|
3961
|
-
const ins = first2(rPr, "ins");
|
|
3962
|
-
if (ins) return revisionFrom(ins, "insert");
|
|
3963
|
-
const del = first2(rPr, "del");
|
|
3964
|
-
if (del) return revisionFrom(del, "delete");
|
|
3965
|
-
return void 0;
|
|
3966
|
-
}
|
|
3967
|
-
function paragraphFormatRevision(pPr) {
|
|
3968
|
-
const change = first2(pPr, "pPrChange");
|
|
3969
|
-
if (!change) return void 0;
|
|
3970
|
-
const revision = revisionFrom(change, "paragraphChange");
|
|
3971
|
-
const previous = first2(change, "pPr");
|
|
3972
|
-
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
3973
|
-
return revision;
|
|
3974
|
-
}
|
|
3975
|
-
function runFormatRevision(rPr) {
|
|
3976
|
-
const change = first2(rPr, "rPrChange");
|
|
3977
|
-
if (!change) return void 0;
|
|
3978
|
-
const revision = revisionFrom(change, "formatChange");
|
|
3979
|
-
const previous = first2(change, "rPr");
|
|
3980
|
-
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
3981
|
-
return revision;
|
|
3982
|
-
}
|
|
3983
|
-
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
3984
|
-
const runs = [];
|
|
3985
|
-
let hasMove = false;
|
|
3986
|
-
const push = (run2) => {
|
|
3987
|
-
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
3988
|
-
runs.push(run2);
|
|
3989
|
-
};
|
|
3990
|
-
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
3991
|
-
if (named2(item2, "r")) {
|
|
3992
|
-
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
3993
|
-
} else if (named2(item2, "hyperlink")) {
|
|
3994
|
-
const link = resolveLink?.(item2);
|
|
3995
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
3996
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
3997
|
-
if (link) parsed.link = link;
|
|
3998
|
-
push(parsed);
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
4002
|
-
const kind = expectDefined(
|
|
4003
|
-
REVISION_WRAPPERS[item2.localName],
|
|
4004
|
-
`revision wrapper ${item2.localName}`
|
|
4005
|
-
);
|
|
4006
|
-
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
4007
|
-
const revision = revisionFrom(item2, kind);
|
|
4008
|
-
const range2 = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
4009
|
-
if (range2) revision.move = { name: range2.name, rangeId: range2.id };
|
|
4010
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4011
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
4012
|
-
parsed.revision = revision;
|
|
4013
|
-
push(parsed);
|
|
4014
|
-
}
|
|
4015
|
-
}
|
|
4016
|
-
} else if (trackMoveRange(item2, moves)) {
|
|
4017
|
-
continue;
|
|
4018
|
-
} else if (named2(item2, "commentRangeStart")) {
|
|
4019
|
-
const id = getW(item2, "id");
|
|
4020
|
-
if (id !== void 0) active.push(id);
|
|
4021
|
-
} else if (named2(item2, "commentRangeEnd")) {
|
|
4022
|
-
const id = getW(item2, "id");
|
|
4023
|
-
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
4024
|
-
if (index >= 0) active.splice(index, 1);
|
|
4025
|
-
} else {
|
|
4026
|
-
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
return { runs, hasMove };
|
|
4030
|
-
}
|
|
4031
|
-
|
|
4032
|
-
// docx/parse-content-control.ts
|
|
4033
|
-
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
4034
|
-
const control = parseContentControl(sdt, "inline");
|
|
4035
|
-
const content = sdtContent(sdt);
|
|
4036
|
-
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
4037
|
-
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
4038
|
-
for (const run2 of runs) run2.contentControl ??= control;
|
|
4039
|
-
return runs;
|
|
4040
|
-
}
|
|
4041
|
-
function flatChildren(parent, names, level4 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
4042
|
-
const found = [];
|
|
4043
|
-
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
4044
|
-
if (isSdt(child7)) {
|
|
4045
|
-
const content = sdtContent(child7);
|
|
4046
|
-
if (!content) continue;
|
|
4047
|
-
let control = controls.get(child7);
|
|
4048
|
-
if (!control) {
|
|
4049
|
-
control = parseContentControl(child7, level4);
|
|
4050
|
-
controls.set(child7, control);
|
|
4051
|
-
}
|
|
4052
|
-
found.push(...flatChildren(content, names, level4, { control, sdt: child7 }, controls));
|
|
4053
|
-
} else if (names.some((name) => named2(child7, name)))
|
|
4054
|
-
found.push({
|
|
4055
|
-
element: child7,
|
|
4056
|
-
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
4057
|
-
});
|
|
4058
|
-
}
|
|
4059
|
-
return found;
|
|
4082
|
+
// docx/save-modified.ts
|
|
4083
|
+
var CORE_PATH2 = "docProps/core.xml";
|
|
4084
|
+
async function stampModified(zip, option) {
|
|
4085
|
+
if (!option) return;
|
|
4086
|
+
const file = zip.file(CORE_PATH2);
|
|
4087
|
+
if (!file) return;
|
|
4088
|
+
const source2 = await file.async("string");
|
|
4089
|
+
const props = parseCoreProperties(source2);
|
|
4090
|
+
props.modified = formatW3cdtf(option.at ?? /* @__PURE__ */ new Date());
|
|
4091
|
+
if (option.author) props.lastModifiedBy = option.author;
|
|
4092
|
+
zip.file(CORE_PATH2, writeCoreProperties(props, source2));
|
|
4060
4093
|
}
|
|
4061
|
-
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
4062
|
-
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
4063
|
-
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
4064
|
-
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
4065
4094
|
|
|
4066
4095
|
// docx/element-order.ts
|
|
4067
4096
|
var RPR_ORDER = [
|
|
@@ -4150,6 +4179,720 @@ function orderSectionProperties(sectPr) {
|
|
|
4150
4179
|
orderChildren(sectPr, SECTPR_ORDER);
|
|
4151
4180
|
}
|
|
4152
4181
|
|
|
4182
|
+
// docx/tab-stops.ts
|
|
4183
|
+
function parseTabStops(tabs) {
|
|
4184
|
+
const stops = [];
|
|
4185
|
+
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
4186
|
+
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
4187
|
+
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
4188
|
+
if (!align || pos === void 0) continue;
|
|
4189
|
+
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
4190
|
+
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
4191
|
+
}
|
|
4192
|
+
return stops;
|
|
4193
|
+
}
|
|
4194
|
+
function writeTabStops(doc, props, paragraph2, base) {
|
|
4195
|
+
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
4196
|
+
return;
|
|
4197
|
+
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
4198
|
+
if (!paragraph2.tabStops?.length) return;
|
|
4199
|
+
const tabs = makeW(doc, "tabs");
|
|
4200
|
+
for (const stop of paragraph2.tabStops) {
|
|
4201
|
+
const tab = makeW(doc, "tab");
|
|
4202
|
+
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
4203
|
+
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
4204
|
+
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
4205
|
+
tabs.appendChild(tab);
|
|
4206
|
+
}
|
|
4207
|
+
props.appendChild(tabs);
|
|
4208
|
+
}
|
|
4209
|
+
var PPR_ORDER = [
|
|
4210
|
+
"pStyle",
|
|
4211
|
+
"keepNext",
|
|
4212
|
+
"keepLines",
|
|
4213
|
+
"pageBreakBefore",
|
|
4214
|
+
"framePr",
|
|
4215
|
+
"widowControl",
|
|
4216
|
+
"numPr",
|
|
4217
|
+
"suppressLineNumbers",
|
|
4218
|
+
"pBdr",
|
|
4219
|
+
"shd",
|
|
4220
|
+
"tabs",
|
|
4221
|
+
"suppressAutoHyphens",
|
|
4222
|
+
"kinsoku",
|
|
4223
|
+
"wordWrap",
|
|
4224
|
+
"overflowPunct",
|
|
4225
|
+
"topLinePunct",
|
|
4226
|
+
"autoSpaceDE",
|
|
4227
|
+
"autoSpaceDN",
|
|
4228
|
+
"bidi",
|
|
4229
|
+
"adjustRightInd",
|
|
4230
|
+
"snapToGrid",
|
|
4231
|
+
"spacing",
|
|
4232
|
+
"ind",
|
|
4233
|
+
"contextualSpacing",
|
|
4234
|
+
"mirrorIndents",
|
|
4235
|
+
"suppressOverlap",
|
|
4236
|
+
"jc",
|
|
4237
|
+
"textDirection",
|
|
4238
|
+
"textAlignment",
|
|
4239
|
+
"textboxTightWrap",
|
|
4240
|
+
"outlineLvl",
|
|
4241
|
+
"divId",
|
|
4242
|
+
"cnfStyle",
|
|
4243
|
+
"rPr",
|
|
4244
|
+
"sectPr",
|
|
4245
|
+
"pPrChange"
|
|
4246
|
+
];
|
|
4247
|
+
function orderParagraphProperties(props) {
|
|
4248
|
+
orderChildren(props, PPR_ORDER);
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
// docx/write-paragraph-decoration.ts
|
|
4252
|
+
var SIDES3 = ["top", "left", "bottom", "right", "between"];
|
|
4253
|
+
function wordColor(color) {
|
|
4254
|
+
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
4255
|
+
return hex ? hex.toUpperCase() : "auto";
|
|
4256
|
+
}
|
|
4257
|
+
function borderElement(doc, name, side) {
|
|
4258
|
+
const element4 = makeW(doc, name);
|
|
4259
|
+
const set2 = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
4260
|
+
set2("val", side.style ?? "single");
|
|
4261
|
+
if (side.style !== "none" && side.style !== "nil") {
|
|
4262
|
+
set2("sz", String(side.sizeEighthPoints ?? 4));
|
|
4263
|
+
set2("space", String(side.spacePoints ?? 1));
|
|
4264
|
+
set2("color", wordColor(side.color));
|
|
4265
|
+
if (side.themeColor) set2("themeColor", side.themeColor);
|
|
4266
|
+
}
|
|
4267
|
+
return element4;
|
|
4268
|
+
}
|
|
4269
|
+
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
4270
|
+
function updateShading(doc, props, paragraph2, base) {
|
|
4271
|
+
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
4272
|
+
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
4273
|
+
if (!paragraph2.shadingFill) return;
|
|
4274
|
+
const shd = makeW(doc, "shd");
|
|
4275
|
+
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
4276
|
+
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
4277
|
+
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
4278
|
+
props.appendChild(shd);
|
|
4279
|
+
}
|
|
4280
|
+
function updateBorders(doc, props, paragraph2, base) {
|
|
4281
|
+
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
4282
|
+
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
4283
|
+
const borders = paragraph2.borders;
|
|
4284
|
+
if (!borders) return;
|
|
4285
|
+
const pBdr = makeW(doc, "pBdr");
|
|
4286
|
+
for (const side of SIDES3) {
|
|
4287
|
+
const value = borders[side];
|
|
4288
|
+
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
4289
|
+
}
|
|
4290
|
+
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
4291
|
+
}
|
|
4292
|
+
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
4293
|
+
updateShading(doc, props, paragraph2, base);
|
|
4294
|
+
updateBorders(doc, props, paragraph2, base);
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
// docx/write-paragraph-properties.ts
|
|
4298
|
+
function setAttribute(element4, local, value) {
|
|
4299
|
+
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
4300
|
+
}
|
|
4301
|
+
function setWordValue(element4, local, value) {
|
|
4302
|
+
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
4303
|
+
else setAttribute(element4, local, String(value));
|
|
4304
|
+
}
|
|
4305
|
+
function updateDirection(doc, props, paragraph2, base) {
|
|
4306
|
+
if (base && paragraph2.direction === base.direction) return;
|
|
4307
|
+
let bidi = first2(props, "bidi");
|
|
4308
|
+
if (paragraph2.direction === void 0) {
|
|
4309
|
+
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
4310
|
+
} else {
|
|
4311
|
+
if (!bidi) {
|
|
4312
|
+
bidi = makeW(doc, "bidi");
|
|
4313
|
+
props.appendChild(bidi);
|
|
4314
|
+
}
|
|
4315
|
+
setAttribute(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
4316
|
+
}
|
|
4317
|
+
}
|
|
4318
|
+
function updateSpacing(doc, props, paragraph2, base) {
|
|
4319
|
+
let spacing3 = first2(props, "spacing");
|
|
4320
|
+
if (!spacing3) {
|
|
4321
|
+
spacing3 = makeW(doc, "spacing");
|
|
4322
|
+
props.appendChild(spacing3);
|
|
4323
|
+
}
|
|
4324
|
+
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
4325
|
+
setWordValue(spacing3, "before", paragraph2.spacingBeforeTwips);
|
|
4326
|
+
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
4327
|
+
setWordValue(spacing3, "after", paragraph2.spacingAfterTwips);
|
|
4328
|
+
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
4329
|
+
setWordValue(spacing3, "line", paragraph2.lineSpacingTwips);
|
|
4330
|
+
setWordValue(
|
|
4331
|
+
spacing3,
|
|
4332
|
+
"lineRule",
|
|
4333
|
+
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
4334
|
+
);
|
|
4335
|
+
}
|
|
4336
|
+
if (!spacing3.attributes.length && !spacing3.childNodes.length) props.removeChild(spacing3);
|
|
4337
|
+
}
|
|
4338
|
+
function updateIndent(doc, props, paragraph2, base) {
|
|
4339
|
+
let indent = first2(props, "ind");
|
|
4340
|
+
if (!indent) {
|
|
4341
|
+
indent = makeW(doc, "ind");
|
|
4342
|
+
props.appendChild(indent);
|
|
4343
|
+
}
|
|
4344
|
+
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
4345
|
+
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
4346
|
+
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
4347
|
+
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
4348
|
+
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
4349
|
+
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
4350
|
+
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
4351
|
+
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
4352
|
+
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
4353
|
+
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
4354
|
+
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
4355
|
+
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
4356
|
+
if (!indent.attributes.length) props.removeChild(indent);
|
|
4357
|
+
}
|
|
4358
|
+
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
4359
|
+
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
4360
|
+
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
4361
|
+
if (paragraph2.pageBreakBefore !== void 0) {
|
|
4362
|
+
const element4 = makeW(doc, "pageBreakBefore");
|
|
4363
|
+
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
4364
|
+
props.appendChild(element4);
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
4368
|
+
for (const key of [
|
|
4369
|
+
"keepNext",
|
|
4370
|
+
"keepLines",
|
|
4371
|
+
"widowControl",
|
|
4372
|
+
"contextualSpacing",
|
|
4373
|
+
"suppressLineNumbers"
|
|
4374
|
+
]) {
|
|
4375
|
+
if (base && paragraph2[key] === base[key]) continue;
|
|
4376
|
+
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
4377
|
+
const value = paragraph2[key];
|
|
4378
|
+
if (value === void 0) continue;
|
|
4379
|
+
const element4 = makeW(doc, key);
|
|
4380
|
+
if (!value) setAttribute(element4, "val", "0");
|
|
4381
|
+
props.appendChild(element4);
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
function updateDropCap(doc, props, paragraph2, base) {
|
|
4385
|
+
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
4386
|
+
let frame2 = first2(props, "framePr");
|
|
4387
|
+
const cap = paragraph2.dropCap;
|
|
4388
|
+
if (!cap) {
|
|
4389
|
+
if (frame2) props.removeChild(frame2);
|
|
4390
|
+
return;
|
|
4391
|
+
}
|
|
4392
|
+
if (!frame2) {
|
|
4393
|
+
frame2 = makeW(doc, "framePr");
|
|
4394
|
+
props.appendChild(frame2);
|
|
4395
|
+
setAttribute(frame2, "wrap", "around");
|
|
4396
|
+
setAttribute(frame2, "vAnchor", "text");
|
|
4397
|
+
setAttribute(frame2, "hAnchor", "text");
|
|
4398
|
+
}
|
|
4399
|
+
setAttribute(frame2, "dropCap", cap.style);
|
|
4400
|
+
setAttribute(frame2, "lines", String(cap.lines));
|
|
4401
|
+
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
4402
|
+
}
|
|
4403
|
+
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
4404
|
+
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
4405
|
+
updateKeepOptions(doc, props, paragraph2, base);
|
|
4406
|
+
updateDropCap(doc, props, paragraph2, base);
|
|
4407
|
+
updateDirection(doc, props, paragraph2, base);
|
|
4408
|
+
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
4409
|
+
const spacingKeys = [
|
|
4410
|
+
"spacingBeforeTwips",
|
|
4411
|
+
"spacingAfterTwips",
|
|
4412
|
+
"lineSpacingTwips",
|
|
4413
|
+
"lineSpacingRule"
|
|
4414
|
+
];
|
|
4415
|
+
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
4416
|
+
updateSpacing(doc, props, paragraph2, base);
|
|
4417
|
+
const indentKeys = [
|
|
4418
|
+
"indentLeftTwips",
|
|
4419
|
+
"indentRightTwips",
|
|
4420
|
+
"indentStartTwips",
|
|
4421
|
+
"indentEndTwips",
|
|
4422
|
+
"firstLineTwips",
|
|
4423
|
+
"hangingTwips"
|
|
4424
|
+
];
|
|
4425
|
+
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
4426
|
+
updateIndent(doc, props, paragraph2, base);
|
|
4427
|
+
}
|
|
4428
|
+
|
|
4429
|
+
// docx/style-formatting-package.ts
|
|
4430
|
+
var STYLES_PART = "word/styles.xml";
|
|
4431
|
+
var AFTER_PPR = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
4432
|
+
var WRITABLE_STYLE_FORMATTING = [
|
|
4433
|
+
"align",
|
|
4434
|
+
"justification",
|
|
4435
|
+
"direction",
|
|
4436
|
+
"spacingBeforeTwips",
|
|
4437
|
+
"spacingAfterTwips",
|
|
4438
|
+
"lineSpacingTwips",
|
|
4439
|
+
"lineSpacingRule",
|
|
4440
|
+
"indentLeftTwips",
|
|
4441
|
+
"indentRightTwips",
|
|
4442
|
+
"indentStartTwips",
|
|
4443
|
+
"indentEndTwips",
|
|
4444
|
+
"firstLineTwips",
|
|
4445
|
+
"hangingTwips",
|
|
4446
|
+
"pageBreakBefore",
|
|
4447
|
+
"keepNext",
|
|
4448
|
+
"keepLines",
|
|
4449
|
+
"widowControl",
|
|
4450
|
+
"contextualSpacing",
|
|
4451
|
+
"suppressLineNumbers",
|
|
4452
|
+
"borders",
|
|
4453
|
+
"shadingFill"
|
|
4454
|
+
];
|
|
4455
|
+
function unwritableFormatting(formatting) {
|
|
4456
|
+
const rest = { ...formatting };
|
|
4457
|
+
for (const key of WRITABLE_STYLE_FORMATTING) delete rest[key];
|
|
4458
|
+
return rest;
|
|
4459
|
+
}
|
|
4460
|
+
var asParagraph = (formatting) => ({
|
|
4461
|
+
type: "paragraph",
|
|
4462
|
+
id: "style",
|
|
4463
|
+
runs: [],
|
|
4464
|
+
...formatting
|
|
4465
|
+
});
|
|
4466
|
+
function pPrOf(style) {
|
|
4467
|
+
let pPr = first2(style, "pPr");
|
|
4468
|
+
if (pPr) return pPr;
|
|
4469
|
+
pPr = makeW(style.ownerDocument, "pPr");
|
|
4470
|
+
const anchor = Array.from(style.childNodes).find(
|
|
4471
|
+
(node) => node.nodeType === 1 && AFTER_PPR.includes(node.localName)
|
|
4472
|
+
) ?? null;
|
|
4473
|
+
style.insertBefore(pPr, anchor);
|
|
4474
|
+
return pPr;
|
|
4475
|
+
}
|
|
4476
|
+
async function applyStyleFormatting(zip, model, base) {
|
|
4477
|
+
const next = model.paragraphStyles?.styles ?? {};
|
|
4478
|
+
const prior = base.paragraphStyles?.styles ?? {};
|
|
4479
|
+
const changed = Object.keys(next).filter(
|
|
4480
|
+
(id) => JSON.stringify(next[id]?.formatting) !== JSON.stringify(prior[id]?.formatting)
|
|
4481
|
+
);
|
|
4482
|
+
if (!changed.length) return;
|
|
4483
|
+
const file = zip.file(STYLES_PART);
|
|
4484
|
+
if (!file) throw new Error("Cannot edit a style: the package has no styles.xml.");
|
|
4485
|
+
const doc = parseXml2(await file.async("string"));
|
|
4486
|
+
const styles = children2(doc.documentElement, "style");
|
|
4487
|
+
for (const id of changed) {
|
|
4488
|
+
const style = styles.find(
|
|
4489
|
+
(element4) => getW(element4, "type") === "paragraph" && getW(element4, "styleId") === id
|
|
4490
|
+
);
|
|
4491
|
+
if (!style) throw new Error(`Cannot edit style "${id}": it is not in styles.xml.`);
|
|
4492
|
+
const after = asParagraph(next[id].formatting);
|
|
4493
|
+
const before = asParagraph(prior[id]?.formatting ?? {});
|
|
4494
|
+
const pPr = pPrOf(style);
|
|
4495
|
+
if (after.align !== before.align || after.justification !== before.justification || after.direction !== before.direction) {
|
|
4496
|
+
for (const jc of children2(pPr, "jc")) pPr.removeChild(jc);
|
|
4497
|
+
const value = paragraphJustification(after);
|
|
4498
|
+
if (value) {
|
|
4499
|
+
const jc = makeW(doc, "jc");
|
|
4500
|
+
jc.setAttributeNS(WORD_NS, "w:val", value);
|
|
4501
|
+
pPr.appendChild(jc);
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
writeParagraphProperties(doc, pPr, after, before);
|
|
4505
|
+
orderParagraphProperties(pPr);
|
|
4506
|
+
}
|
|
4507
|
+
zip.file(STYLES_PART, buildXml(doc));
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
// docx/data-binding.ts
|
|
4511
|
+
function parsePrefixes(text2) {
|
|
4512
|
+
const map = /* @__PURE__ */ new Map();
|
|
4513
|
+
for (const match of (text2 ?? "").matchAll(/xmlns:([\w.-]+)\s*=\s*(?:'([^']*)'|"([^"]*)")/g))
|
|
4514
|
+
map.set(match[1], match[2] ?? match[3] ?? "");
|
|
4515
|
+
return map;
|
|
4516
|
+
}
|
|
4517
|
+
function sourceBindings(sourceXml) {
|
|
4518
|
+
const result = /* @__PURE__ */ new Map();
|
|
4519
|
+
const document = parseXml2(sourceXml);
|
|
4520
|
+
for (const sdt of Array.from(document.getElementsByTagNameNS(WORD_NS, "sdt"))) {
|
|
4521
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
4522
|
+
const element4 = sdtPr && elements(sdtPr).find((node) => node.localName === "dataBinding");
|
|
4523
|
+
const id = getW(first2(sdtPr, "id"), "val");
|
|
4524
|
+
const xpath = element4?.getAttributeNS(WORD_NS, "xpath");
|
|
4525
|
+
const storeItemId = element4?.getAttributeNS(WORD_NS, "storeItemID");
|
|
4526
|
+
if (id && element4 && xpath && storeItemId)
|
|
4527
|
+
result.set(id, {
|
|
4528
|
+
xpath,
|
|
4529
|
+
storeItemId,
|
|
4530
|
+
prefixes: parsePrefixes(element4.getAttributeNS(WORD_NS, "prefixMappings") ?? void 0)
|
|
4531
|
+
});
|
|
4532
|
+
}
|
|
4533
|
+
return result;
|
|
4534
|
+
}
|
|
4535
|
+
function paragraphsOf(blocks) {
|
|
4536
|
+
return blocks.flatMap(
|
|
4537
|
+
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((c2) => c2.paragraphs))
|
|
4538
|
+
);
|
|
4539
|
+
}
|
|
4540
|
+
function boundTexts(model) {
|
|
4541
|
+
const parts = /* @__PURE__ */ new Map();
|
|
4542
|
+
const add4 = (id, text2) => parts.set(id, [...parts.get(id) ?? [], text2]);
|
|
4543
|
+
for (const paragraph2 of paragraphsOf(model.blocks)) {
|
|
4544
|
+
const own2 = paragraph2.contentControl;
|
|
4545
|
+
if (own2?.dataBound) {
|
|
4546
|
+
add4(own2.id, paragraph2.runs.map((run2) => run2.text).join(""));
|
|
4547
|
+
continue;
|
|
4548
|
+
}
|
|
4549
|
+
const inline = /* @__PURE__ */ new Map();
|
|
4550
|
+
for (const run2 of paragraph2.runs) {
|
|
4551
|
+
const control = run2.contentControl;
|
|
4552
|
+
if (!control?.dataBound) continue;
|
|
4553
|
+
if (!inline.has(control.id)) inline.set(control.id, "");
|
|
4554
|
+
if (!control.showingPlaceholder) inline.set(control.id, inline.get(control.id) + run2.text);
|
|
4555
|
+
}
|
|
4556
|
+
for (const [id, text2] of inline) add4(id, text2);
|
|
4557
|
+
}
|
|
4558
|
+
return new Map([...parts].map(([id, texts]) => [id, texts.join("\n")]));
|
|
4559
|
+
}
|
|
4560
|
+
function parseXPath(binding) {
|
|
4561
|
+
const parts = binding.xpath.split("/");
|
|
4562
|
+
if (parts.shift() !== "" || !parts.length) return void 0;
|
|
4563
|
+
if (parts.at(-1) === "text()") parts.pop();
|
|
4564
|
+
const parse = (raw2, attribute3) => {
|
|
4565
|
+
const match = /^(?:([A-Za-z_][\w.-]*):)?([A-Za-z_][\w.-]*)(?:\[(\d+)\])?$/.exec(raw2);
|
|
4566
|
+
if (!match || attribute3 && match[3]) return void 0;
|
|
4567
|
+
const [, prefix2 = "", name = "", index] = match;
|
|
4568
|
+
if (prefix2 && !binding.prefixes.has(prefix2)) return void 0;
|
|
4569
|
+
return { prefix: prefix2, name, index: index ? Number(index) : 1 };
|
|
4570
|
+
};
|
|
4571
|
+
const last = parts.at(-1);
|
|
4572
|
+
const attribute2 = last?.startsWith("@") ? parse(last.slice(1), true) : void 0;
|
|
4573
|
+
if (last?.startsWith("@")) {
|
|
4574
|
+
parts.pop();
|
|
4575
|
+
if (!attribute2) return void 0;
|
|
4576
|
+
}
|
|
4577
|
+
const steps = parts.map((part) => parse(part, false));
|
|
4578
|
+
if (!steps.length || steps.some((step) => !step)) return void 0;
|
|
4579
|
+
return { steps, ...attribute2 ? { attribute: attribute2 } : {} };
|
|
4580
|
+
}
|
|
4581
|
+
var matches = (element4, step, binding) => element4.localName === step.name && (element4.namespaceURI ?? "") === (step.prefix ? binding.prefixes.get(step.prefix) ?? "" : "");
|
|
4582
|
+
function writeValue(root, binding, value) {
|
|
4583
|
+
const path3 = parseXPath(binding);
|
|
4584
|
+
if (!path3) return "unsupported";
|
|
4585
|
+
let node = root;
|
|
4586
|
+
for (const [depth, step] of path3.steps.entries()) {
|
|
4587
|
+
const candidates = depth === 0 ? [root].filter((e) => matches(e, step, binding)) : elements(node).filter((e) => matches(e, step, binding));
|
|
4588
|
+
node = candidates[step.index - 1];
|
|
4589
|
+
if (!node) return false;
|
|
4590
|
+
}
|
|
4591
|
+
if (path3.attribute) {
|
|
4592
|
+
const { prefix: prefix2, name } = path3.attribute;
|
|
4593
|
+
const ns = prefix2 ? binding.prefixes.get(prefix2) : void 0;
|
|
4594
|
+
if (ns) node.setAttributeNS(ns, `${prefix2}:${name}`, value);
|
|
4595
|
+
else node.setAttribute(name, value);
|
|
4596
|
+
return true;
|
|
4597
|
+
}
|
|
4598
|
+
for (const child7 of Array.from(node.childNodes)) node.removeChild(child7);
|
|
4599
|
+
if (value) node.appendChild(node.ownerDocument.createTextNode(value));
|
|
4600
|
+
return true;
|
|
4601
|
+
}
|
|
4602
|
+
async function findItemPart(zip, storeItemId) {
|
|
4603
|
+
const wanted = storeItemId.toLowerCase();
|
|
4604
|
+
for (const name of Object.keys(zip.files)) {
|
|
4605
|
+
const props = /^customXml\/itemProps(\d+)\.xml$/.exec(name);
|
|
4606
|
+
if (!props) continue;
|
|
4607
|
+
const root = parseXml2(await zip.file(name).async("string")).documentElement;
|
|
4608
|
+
const id = Array.from(root.attributes).find((attribute2) => attribute2.localName === "itemID");
|
|
4609
|
+
if ((id?.value ?? "").toLowerCase() === wanted) return `customXml/item${props[1]}.xml`;
|
|
4610
|
+
}
|
|
4611
|
+
return void 0;
|
|
4612
|
+
}
|
|
4613
|
+
async function applyDataBindings(zip, model, base, sourceXml) {
|
|
4614
|
+
const now = boundTexts(model);
|
|
4615
|
+
if (!now.size) return;
|
|
4616
|
+
const before = boundTexts(base);
|
|
4617
|
+
const bindings = sourceBindings(sourceXml);
|
|
4618
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
4619
|
+
for (const [id, text2] of now) {
|
|
4620
|
+
const binding = bindings.get(id);
|
|
4621
|
+
if (!binding || before.get(id) === text2) continue;
|
|
4622
|
+
const part = await findItemPart(zip, binding.storeItemId);
|
|
4623
|
+
const file = part ? zip.file(part) : void 0;
|
|
4624
|
+
if (!part || !file) continue;
|
|
4625
|
+
const document = parsed.get(part) ?? parseXml2(await file.async("string"));
|
|
4626
|
+
parsed.set(part, document);
|
|
4627
|
+
const written = writeValue(document.documentElement, binding, text2);
|
|
4628
|
+
if (written !== true)
|
|
4629
|
+
throw new Error(
|
|
4630
|
+
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.`
|
|
4631
|
+
);
|
|
4632
|
+
}
|
|
4633
|
+
for (const [part, document] of parsed) zip.file(part, buildXml(document));
|
|
4634
|
+
}
|
|
4635
|
+
|
|
4636
|
+
// docx/content-control.ts
|
|
4637
|
+
var WORD_2012_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
4638
|
+
var sdtContent = (sdt) => first2(sdt, "sdtContent");
|
|
4639
|
+
var isSdt = (element4) => named2(element4, "sdt");
|
|
4640
|
+
var TYPE_ELEMENTS = {
|
|
4641
|
+
text: "text",
|
|
4642
|
+
dropDownList: "dropDownList",
|
|
4643
|
+
comboBox: "comboBox",
|
|
4644
|
+
date: "date",
|
|
4645
|
+
picture: "picture",
|
|
4646
|
+
group: "group",
|
|
4647
|
+
equation: "equation",
|
|
4648
|
+
citation: "citation",
|
|
4649
|
+
bibliography: "bibliography",
|
|
4650
|
+
docPartObj: "docPartObj",
|
|
4651
|
+
docPartList: "docPartList"
|
|
4652
|
+
};
|
|
4653
|
+
function attrW14(element4, local) {
|
|
4654
|
+
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
4655
|
+
}
|
|
4656
|
+
function glyph(element4) {
|
|
4657
|
+
const code = attrW14(element4, "val");
|
|
4658
|
+
if (!code) return void 0;
|
|
4659
|
+
const font = attrW14(element4, "font");
|
|
4660
|
+
return { code, ...font ? { font } : {} };
|
|
4661
|
+
}
|
|
4662
|
+
function kindOf(child7) {
|
|
4663
|
+
if (child7.namespaceURI === WORD_NS)
|
|
4664
|
+
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
4665
|
+
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
4666
|
+
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
4667
|
+
return "repeatingSection";
|
|
4668
|
+
return void 0;
|
|
4669
|
+
}
|
|
4670
|
+
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
4671
|
+
(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"
|
|
4672
|
+
);
|
|
4673
|
+
function parseKind(sdtPr) {
|
|
4674
|
+
const [type] = typeElements(sdtPr);
|
|
4675
|
+
return (type && kindOf(type)) ?? "richText";
|
|
4676
|
+
}
|
|
4677
|
+
var generated = 0;
|
|
4678
|
+
function parseContentControl(sdt, level4) {
|
|
4679
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
4680
|
+
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level4, kind: "richText" };
|
|
4681
|
+
const kind = parseKind(sdtPr);
|
|
4682
|
+
const control = {
|
|
4683
|
+
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
4684
|
+
level: level4,
|
|
4685
|
+
kind
|
|
4686
|
+
};
|
|
4687
|
+
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
4688
|
+
if (alias !== void 0) control.alias = alias;
|
|
4689
|
+
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
4690
|
+
if (tag !== void 0) control.tag = tag;
|
|
4691
|
+
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
4692
|
+
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
4693
|
+
control.lock = lock;
|
|
4694
|
+
const showing = first2(sdtPr, "showingPlcHdr");
|
|
4695
|
+
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
4696
|
+
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
4697
|
+
const temporary = first2(sdtPr, "temporary");
|
|
4698
|
+
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
4699
|
+
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
4700
|
+
if (placeholder) control.placeholder = placeholder;
|
|
4701
|
+
if (kind === "text") {
|
|
4702
|
+
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
4703
|
+
if (multi) control.multiLine = true;
|
|
4704
|
+
}
|
|
4705
|
+
if (kind === "checkbox") {
|
|
4706
|
+
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
4707
|
+
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
4708
|
+
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
4709
|
+
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
4710
|
+
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
4711
|
+
if (on) control.checkedGlyph = on;
|
|
4712
|
+
if (off) control.uncheckedGlyph = off;
|
|
4713
|
+
}
|
|
4714
|
+
if (kind === "dropDownList" || kind === "comboBox") {
|
|
4715
|
+
const list2 = first2(sdtPr, kind);
|
|
4716
|
+
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
4717
|
+
const display = getW(item2, "displayText");
|
|
4718
|
+
const value = getW(item2, "value") ?? display ?? "";
|
|
4719
|
+
return { display: display ?? value, value };
|
|
4720
|
+
});
|
|
4721
|
+
}
|
|
4722
|
+
if (kind === "date") {
|
|
4723
|
+
const date = first2(sdtPr, "date");
|
|
4724
|
+
const fullDate = getW(date, "fullDate");
|
|
4725
|
+
if (fullDate) control.fullDate = fullDate;
|
|
4726
|
+
const format = getW(first2(date, "dateFormat"), "val");
|
|
4727
|
+
if (format) control.dateFormat = format;
|
|
4728
|
+
const lid = getW(first2(date, "lid"), "val");
|
|
4729
|
+
if (lid) control.dateLocale = lid;
|
|
4730
|
+
}
|
|
4731
|
+
control.sourceXml = buildXml(sdtPr);
|
|
4732
|
+
const end = first2(sdt, "sdtEndPr");
|
|
4733
|
+
if (end) control.endSourceXml = buildXml(end);
|
|
4734
|
+
return control;
|
|
4735
|
+
}
|
|
4736
|
+
|
|
4737
|
+
// docx/expect-defined.ts
|
|
4738
|
+
function expectDefined(value, context) {
|
|
4739
|
+
if (value === void 0 || value === null) {
|
|
4740
|
+
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
4741
|
+
}
|
|
4742
|
+
return value;
|
|
4743
|
+
}
|
|
4744
|
+
|
|
4745
|
+
// docx/parse-revisions.ts
|
|
4746
|
+
var REVISION_WRAPPERS = {
|
|
4747
|
+
ins: "insert",
|
|
4748
|
+
del: "delete",
|
|
4749
|
+
moveFrom: "moveFrom",
|
|
4750
|
+
moveTo: "moveTo"
|
|
4751
|
+
};
|
|
4752
|
+
var MOVE_RANGES = {
|
|
4753
|
+
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
4754
|
+
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
4755
|
+
moveToRangeStart: { kind: "moveTo", start: true },
|
|
4756
|
+
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
4757
|
+
};
|
|
4758
|
+
function trackMoveRange(item2, moves) {
|
|
4759
|
+
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
4760
|
+
const range2 = MOVE_RANGES[item2.localName ?? ""];
|
|
4761
|
+
if (!range2) return false;
|
|
4762
|
+
const id = getW(item2, "id") ?? "";
|
|
4763
|
+
const open = moves[range2.kind];
|
|
4764
|
+
if (range2.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
4765
|
+
else {
|
|
4766
|
+
const index = open.findIndex((entry2) => entry2.id === id);
|
|
4767
|
+
if (index >= 0) open.splice(index, 1);
|
|
4768
|
+
}
|
|
4769
|
+
return true;
|
|
4770
|
+
}
|
|
4771
|
+
function isCommentReferenceRun(run2) {
|
|
4772
|
+
const content = Array.from(run2.childNodes).filter(
|
|
4773
|
+
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
4774
|
+
);
|
|
4775
|
+
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
4776
|
+
}
|
|
4777
|
+
function revisionFrom(node, kind) {
|
|
4778
|
+
const revision = {
|
|
4779
|
+
kind,
|
|
4780
|
+
author: getW(node, "author") || "Unknown",
|
|
4781
|
+
id: getW(node, "id") ?? "0"
|
|
4782
|
+
};
|
|
4783
|
+
const date = getW(node, "date");
|
|
4784
|
+
if (date) revision.date = date;
|
|
4785
|
+
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
4786
|
+
if (dateUtc) revision.dateUtc = dateUtc;
|
|
4787
|
+
return revision;
|
|
4788
|
+
}
|
|
4789
|
+
function paragraphMarkRevision(pPr) {
|
|
4790
|
+
const rPr = first2(pPr, "rPr");
|
|
4791
|
+
const ins = first2(rPr, "ins");
|
|
4792
|
+
if (ins) return revisionFrom(ins, "insert");
|
|
4793
|
+
const del = first2(rPr, "del");
|
|
4794
|
+
if (del) return revisionFrom(del, "delete");
|
|
4795
|
+
return void 0;
|
|
4796
|
+
}
|
|
4797
|
+
function paragraphFormatRevision(pPr) {
|
|
4798
|
+
const change = first2(pPr, "pPrChange");
|
|
4799
|
+
if (!change) return void 0;
|
|
4800
|
+
const revision = revisionFrom(change, "paragraphChange");
|
|
4801
|
+
const previous = first2(change, "pPr");
|
|
4802
|
+
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
4803
|
+
return revision;
|
|
4804
|
+
}
|
|
4805
|
+
function runFormatRevision(rPr) {
|
|
4806
|
+
const change = first2(rPr, "rPrChange");
|
|
4807
|
+
if (!change) return void 0;
|
|
4808
|
+
const revision = revisionFrom(change, "formatChange");
|
|
4809
|
+
const previous = first2(change, "rPr");
|
|
4810
|
+
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
4811
|
+
return revision;
|
|
4812
|
+
}
|
|
4813
|
+
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
4814
|
+
const runs = [];
|
|
4815
|
+
let hasMove = false;
|
|
4816
|
+
const push = (run2) => {
|
|
4817
|
+
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
4818
|
+
runs.push(run2);
|
|
4819
|
+
};
|
|
4820
|
+
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
4821
|
+
if (named2(item2, "r")) {
|
|
4822
|
+
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
4823
|
+
} else if (named2(item2, "hyperlink")) {
|
|
4824
|
+
const link = resolveLink?.(item2);
|
|
4825
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4826
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
4827
|
+
if (link) parsed.link = link;
|
|
4828
|
+
push(parsed);
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
4832
|
+
const kind = expectDefined(
|
|
4833
|
+
REVISION_WRAPPERS[item2.localName],
|
|
4834
|
+
`revision wrapper ${item2.localName}`
|
|
4835
|
+
);
|
|
4836
|
+
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
4837
|
+
const revision = revisionFrom(item2, kind);
|
|
4838
|
+
const range2 = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
4839
|
+
if (range2) revision.move = { name: range2.name, rangeId: range2.id };
|
|
4840
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4841
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
4842
|
+
parsed.revision = revision;
|
|
4843
|
+
push(parsed);
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
} else if (trackMoveRange(item2, moves)) {
|
|
4847
|
+
continue;
|
|
4848
|
+
} else if (named2(item2, "commentRangeStart")) {
|
|
4849
|
+
const id = getW(item2, "id");
|
|
4850
|
+
if (id !== void 0) active.push(id);
|
|
4851
|
+
} else if (named2(item2, "commentRangeEnd")) {
|
|
4852
|
+
const id = getW(item2, "id");
|
|
4853
|
+
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
4854
|
+
if (index >= 0) active.splice(index, 1);
|
|
4855
|
+
} else {
|
|
4856
|
+
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
return { runs, hasMove };
|
|
4860
|
+
}
|
|
4861
|
+
|
|
4862
|
+
// docx/parse-content-control.ts
|
|
4863
|
+
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
4864
|
+
const control = parseContentControl(sdt, "inline");
|
|
4865
|
+
const content = sdtContent(sdt);
|
|
4866
|
+
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
4867
|
+
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
4868
|
+
for (const run2 of runs) run2.contentControl ??= control;
|
|
4869
|
+
return runs;
|
|
4870
|
+
}
|
|
4871
|
+
function flatChildren(parent, names, level4 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
4872
|
+
const found = [];
|
|
4873
|
+
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
4874
|
+
if (isSdt(child7)) {
|
|
4875
|
+
const content = sdtContent(child7);
|
|
4876
|
+
if (!content) continue;
|
|
4877
|
+
let control = controls.get(child7);
|
|
4878
|
+
if (!control) {
|
|
4879
|
+
control = parseContentControl(child7, level4);
|
|
4880
|
+
controls.set(child7, control);
|
|
4881
|
+
}
|
|
4882
|
+
found.push(...flatChildren(content, names, level4, { control, sdt: child7 }, controls));
|
|
4883
|
+
} else if (names.some((name) => named2(child7, name)))
|
|
4884
|
+
found.push({
|
|
4885
|
+
element: child7,
|
|
4886
|
+
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
4887
|
+
});
|
|
4888
|
+
}
|
|
4889
|
+
return found;
|
|
4890
|
+
}
|
|
4891
|
+
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
4892
|
+
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
4893
|
+
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
4894
|
+
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
4895
|
+
|
|
4153
4896
|
// docx/content-control-values.ts
|
|
4154
4897
|
var validLock = (lock) => lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked" ? lock : void 0;
|
|
4155
4898
|
function validId(id) {
|
|
@@ -4375,15 +5118,15 @@ function writeDate(doc, sdtPr, control) {
|
|
|
4375
5118
|
const fullDate = validDate(control.fullDate) ?? (control.fullDate === existing ? existing : void 0);
|
|
4376
5119
|
if (fullDate) date.setAttributeNS(WORD_NS, "w:fullDate", fullDate);
|
|
4377
5120
|
else date.removeAttributeNS(WORD_NS, "fullDate");
|
|
4378
|
-
const
|
|
5121
|
+
const set2 = (local, value, order) => {
|
|
4379
5122
|
for (const old of children2(date, local)) date.removeChild(old);
|
|
4380
5123
|
if (typeof value !== "string") return;
|
|
4381
5124
|
const element4 = makeW(doc, local);
|
|
4382
5125
|
element4.setAttributeNS(WORD_NS, "w:val", value);
|
|
4383
5126
|
date.insertBefore(element4, Array.from(date.childNodes)[order] ?? null);
|
|
4384
5127
|
};
|
|
4385
|
-
|
|
4386
|
-
|
|
5128
|
+
set2("dateFormat", control.dateFormat, 0);
|
|
5129
|
+
set2("lid", control.dateLocale, 1);
|
|
4387
5130
|
}
|
|
4388
5131
|
var writesType = (kind) => NAMED_TYPES.has(kind) || ["richText", "text", "checkbox", "dropDownList", "comboBox", "date"].includes(kind);
|
|
4389
5132
|
function patchContentControl(doc, sdt, control) {
|
|
@@ -4561,13 +5304,13 @@ function rangeKeys(run2) {
|
|
|
4561
5304
|
keys.push(`${revision.kind}:${revision.move.name}`);
|
|
4562
5305
|
return keys;
|
|
4563
5306
|
}
|
|
4564
|
-
function
|
|
5307
|
+
function paragraphsOf2(blocks) {
|
|
4565
5308
|
return blocks.flatMap(
|
|
4566
5309
|
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell2) => cell2.paragraphs))
|
|
4567
5310
|
);
|
|
4568
5311
|
}
|
|
4569
5312
|
function commentContinuations(blocks) {
|
|
4570
|
-
const paragraphs =
|
|
5313
|
+
const paragraphs = paragraphsOf2(blocks);
|
|
4571
5314
|
const first3 = /* @__PURE__ */ new Map();
|
|
4572
5315
|
const last = /* @__PURE__ */ new Map();
|
|
4573
5316
|
const idsByParagraph = paragraphs.map((paragraph2, index) => {
|
|
@@ -4632,7 +5375,7 @@ var COMMENTS_PATH = "word/comments.xml";
|
|
|
4632
5375
|
var COMMENTS_EXTENDED_PATH = "word/commentsExtended.xml";
|
|
4633
5376
|
var W14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
4634
5377
|
var W15_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
4635
|
-
function
|
|
5378
|
+
function setAttribute2(element4, local, value) {
|
|
4636
5379
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
4637
5380
|
}
|
|
4638
5381
|
function paraIdFor(id, index) {
|
|
@@ -4647,10 +5390,10 @@ function buildCommentsDocument(comments) {
|
|
|
4647
5390
|
const root = doc.documentElement;
|
|
4648
5391
|
comments.forEach((comment, index) => {
|
|
4649
5392
|
const el5 = makeW(doc, "comment");
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
if (comment.date)
|
|
4653
|
-
if (comment.initials)
|
|
5393
|
+
setAttribute2(el5, "id", comment.id);
|
|
5394
|
+
setAttribute2(el5, "author", comment.author);
|
|
5395
|
+
if (comment.date) setAttribute2(el5, "date", comment.date);
|
|
5396
|
+
if (comment.initials) setAttribute2(el5, "initials", comment.initials);
|
|
4654
5397
|
const p = makeW(doc, "p");
|
|
4655
5398
|
p.setAttributeNS(W14_NS, "w14:paraId", paraIdFor(comment.id, index));
|
|
4656
5399
|
const r = makeW(doc, "r");
|
|
@@ -4714,15 +5457,15 @@ async function applyComments(zip, comments) {
|
|
|
4714
5457
|
}
|
|
4715
5458
|
function commentRangeStartNode(doc, id) {
|
|
4716
5459
|
const element4 = makeW(doc, "commentRangeStart");
|
|
4717
|
-
|
|
5460
|
+
setAttribute2(element4, "id", id);
|
|
4718
5461
|
return element4;
|
|
4719
5462
|
}
|
|
4720
5463
|
function commentRangeEndNodes(doc, id) {
|
|
4721
5464
|
const end = makeW(doc, "commentRangeEnd");
|
|
4722
|
-
|
|
5465
|
+
setAttribute2(end, "id", id);
|
|
4723
5466
|
const run2 = makeW(doc, "r");
|
|
4724
5467
|
const reference = makeW(doc, "commentReference");
|
|
4725
|
-
|
|
5468
|
+
setAttribute2(reference, "id", id);
|
|
4726
5469
|
run2.appendChild(reference);
|
|
4727
5470
|
return [end, run2];
|
|
4728
5471
|
}
|
|
@@ -4976,10 +5719,10 @@ function buildRowProperties(doc, row, gridAfter) {
|
|
|
4976
5719
|
}
|
|
4977
5720
|
|
|
4978
5721
|
// docx/write-table-margins.ts
|
|
4979
|
-
var
|
|
5722
|
+
var SIDES4 = ["top", "left", "bottom", "right"];
|
|
4980
5723
|
var ORDER2 = ["top", "start", "left", "bottom", "end", "right"];
|
|
4981
5724
|
function patchMarginProperties(doc, host, propertiesTag, marginTag, propertiesOrder, next, base) {
|
|
4982
|
-
const changed =
|
|
5725
|
+
const changed = SIDES4.filter((side) => next?.[side] !== base?.[side]);
|
|
4983
5726
|
if (!changed.length) return;
|
|
4984
5727
|
for (const side of changed) {
|
|
4985
5728
|
const value = next?.[side];
|
|
@@ -5303,14 +6046,21 @@ function unwrapDroppedControls(elements2, next) {
|
|
|
5303
6046
|
});
|
|
5304
6047
|
}
|
|
5305
6048
|
|
|
5306
|
-
// docx/
|
|
6049
|
+
// docx/table-structure-check.ts
|
|
6050
|
+
var only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
6051
|
+
function plainParagraphs(cell2) {
|
|
6052
|
+
for (const paragraph2 of children2(cell2, "p")) {
|
|
6053
|
+
if (!only(paragraph2, ["pPr", "r"])) return false;
|
|
6054
|
+
for (const run2 of children2(paragraph2, "r"))
|
|
6055
|
+
if (!only(run2, ["rPr", "t", "tab", "br", "cr", "noBreakHyphen"])) return false;
|
|
6056
|
+
}
|
|
6057
|
+
return true;
|
|
6058
|
+
}
|
|
5307
6059
|
function canEditTableStructure(table) {
|
|
5308
|
-
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
5309
6060
|
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
5310
6061
|
const grid = first2(table, "tblGrid");
|
|
5311
6062
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
5312
6063
|
const rows2 = children2(table, "tr");
|
|
5313
|
-
if (!rows2.length) return false;
|
|
5314
6064
|
const [firstRow] = rows2;
|
|
5315
6065
|
if (!firstRow) return false;
|
|
5316
6066
|
const width = children2(firstRow, "tc").length;
|
|
@@ -5326,15 +6076,206 @@ function canEditTableStructure(table) {
|
|
|
5326
6076
|
const props = first2(cell2, "tcPr");
|
|
5327
6077
|
if (props && ["gridSpan", "vMerge", "hMerge", "tcPrChange"].some((key) => first2(props, key)))
|
|
5328
6078
|
return false;
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
6079
|
+
if (!plainParagraphs(cell2)) return false;
|
|
6080
|
+
}
|
|
6081
|
+
}
|
|
6082
|
+
return true;
|
|
6083
|
+
}
|
|
6084
|
+
function canRestructureTable(table) {
|
|
6085
|
+
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
6086
|
+
const grid = first2(table, "tblGrid");
|
|
6087
|
+
if (!grid || !only(grid, ["gridCol"])) return false;
|
|
6088
|
+
const rows2 = children2(table, "tr");
|
|
6089
|
+
if (!rows2.length) return false;
|
|
6090
|
+
for (const row of rows2) {
|
|
6091
|
+
if (!only(row, ["trPr", "tc"]) || !children2(row, "tc").length) return false;
|
|
6092
|
+
const rowProps = first2(row, "trPr");
|
|
6093
|
+
if (rowProps && ["gridBefore", "gridAfter", "wBefore", "wAfter", "trPrChange", "ins", "del"].some(
|
|
6094
|
+
(key) => first2(rowProps, key)
|
|
6095
|
+
))
|
|
6096
|
+
return false;
|
|
6097
|
+
for (const cell2 of children2(row, "tc")) {
|
|
6098
|
+
if (!only(cell2, ["tcPr", "p", "tbl"]) || !children2(cell2, "p").length) return false;
|
|
6099
|
+
const props = first2(cell2, "tcPr");
|
|
6100
|
+
if (props && ["hMerge", "tcPrChange", "cellIns", "cellDel", "cellMerge"].some((key) => first2(props, key)))
|
|
6101
|
+
return false;
|
|
6102
|
+
if (!plainParagraphs(cell2)) return false;
|
|
5334
6103
|
}
|
|
5335
6104
|
}
|
|
5336
6105
|
return true;
|
|
5337
6106
|
}
|
|
6107
|
+
|
|
6108
|
+
// docx/write-table-structure.ts
|
|
6109
|
+
var set = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
6110
|
+
function restructured(next, base) {
|
|
6111
|
+
const shape2 = (table) => JSON.stringify([
|
|
6112
|
+
table.grid,
|
|
6113
|
+
table.rows.map(
|
|
6114
|
+
(row) => row.map((cell2) => [
|
|
6115
|
+
cell2.paragraphs.map((p) => p.id),
|
|
6116
|
+
cell2.gridSpan ?? 1,
|
|
6117
|
+
cell2.verticalMerge ?? "",
|
|
6118
|
+
cell2.widthTwips
|
|
6119
|
+
])
|
|
6120
|
+
)
|
|
6121
|
+
]);
|
|
6122
|
+
return shape2(next) !== shape2(base);
|
|
6123
|
+
}
|
|
6124
|
+
function patchCellLayout(doc, tc, cell2, base) {
|
|
6125
|
+
const span = cell2.gridSpan ?? 1;
|
|
6126
|
+
const width = cell2.widthTwips;
|
|
6127
|
+
if (span === (base.gridSpan ?? 1) && width === base.widthTwips && cell2.verticalMerge === base.verticalMerge)
|
|
6128
|
+
return;
|
|
6129
|
+
let props = first2(tc, "tcPr");
|
|
6130
|
+
if (!props) {
|
|
6131
|
+
props = makeW(doc, "tcPr");
|
|
6132
|
+
tc.insertBefore(props, tc.firstChild);
|
|
6133
|
+
}
|
|
6134
|
+
const replace = (name, next) => {
|
|
6135
|
+
for (const old of children2(props, name)) props.removeChild(old);
|
|
6136
|
+
if (next) props.appendChild(next);
|
|
6137
|
+
};
|
|
6138
|
+
if (width !== base.widthTwips) {
|
|
6139
|
+
const old = first2(props, "tcW");
|
|
6140
|
+
if (width === void 0) replace("tcW", void 0);
|
|
6141
|
+
else {
|
|
6142
|
+
const element4 = old ?? makeW(doc, "tcW");
|
|
6143
|
+
set(element4, "w", String(width));
|
|
6144
|
+
set(element4, "type", "dxa");
|
|
6145
|
+
if (!old) props.appendChild(element4);
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
if (span !== (base.gridSpan ?? 1)) {
|
|
6149
|
+
const element4 = span > 1 ? makeW(doc, "gridSpan") : void 0;
|
|
6150
|
+
if (element4) set(element4, "val", String(span));
|
|
6151
|
+
replace("gridSpan", element4);
|
|
6152
|
+
}
|
|
6153
|
+
if (cell2.verticalMerge !== base.verticalMerge) {
|
|
6154
|
+
const element4 = cell2.verticalMerge ? makeW(doc, "vMerge") : void 0;
|
|
6155
|
+
if (element4 && cell2.verticalMerge === "restart") set(element4, "val", "restart");
|
|
6156
|
+
replace("vMerge", element4);
|
|
6157
|
+
}
|
|
6158
|
+
orderChildren(props, CELL_ORDER);
|
|
6159
|
+
if (!Array.from(props.childNodes).some((node) => node.nodeType === 1) && !props.attributes.length)
|
|
6160
|
+
tc.removeChild(props);
|
|
6161
|
+
}
|
|
6162
|
+
function patchGrid(doc, node, table) {
|
|
6163
|
+
const grid = first2(node, "tblGrid");
|
|
6164
|
+
if (!grid || !table.grid) return;
|
|
6165
|
+
const old = children2(grid, "gridCol");
|
|
6166
|
+
table.grid.forEach((width, index) => {
|
|
6167
|
+
let column = old[index];
|
|
6168
|
+
if (!column) {
|
|
6169
|
+
column = makeW(doc, "gridCol");
|
|
6170
|
+
grid.appendChild(column);
|
|
6171
|
+
}
|
|
6172
|
+
if (column.getAttributeNS(WORD_NS, "w") !== String(width)) set(column, "w", String(width));
|
|
6173
|
+
});
|
|
6174
|
+
for (const extra of old.slice(table.grid.length)) grid.removeChild(extra);
|
|
6175
|
+
}
|
|
6176
|
+
function writeRestructuredTable(doc, table, node, base, writeParagraph, replaceSlots2, writeNested) {
|
|
6177
|
+
if (table.rows.some((row) => !row.length || row.some((cell2) => !cell2.paragraphs.length)))
|
|
6178
|
+
throw new Error("Every table row needs a cell and every cell a paragraph.");
|
|
6179
|
+
const oldRows = flatRows(node).map((entry2) => entry2.element);
|
|
6180
|
+
const oldCells = oldRows.map((tr) => flatCells(tr).map((entry2) => entry2.element));
|
|
6181
|
+
const cellById = /* @__PURE__ */ new Map();
|
|
6182
|
+
const paragraphById = /* @__PURE__ */ new Map();
|
|
6183
|
+
base.rows.forEach(
|
|
6184
|
+
(row, ri) => row.forEach((cell2, ci) => {
|
|
6185
|
+
const tc = oldCells[ri]?.[ci];
|
|
6186
|
+
if (!tc) return;
|
|
6187
|
+
const id = cell2.paragraphs[0]?.id;
|
|
6188
|
+
if (id) cellById.set(id, { tc, model: cell2, row: ri });
|
|
6189
|
+
const flat = flatCellParagraphs(tc);
|
|
6190
|
+
cell2.paragraphs.forEach((model, pi) => {
|
|
6191
|
+
const entry2 = flat[pi];
|
|
6192
|
+
if (entry2) paragraphById.set(model.id, { element: entry2.element, model });
|
|
6193
|
+
});
|
|
6194
|
+
})
|
|
6195
|
+
);
|
|
6196
|
+
const usedRows = /* @__PURE__ */ new Set();
|
|
6197
|
+
const usedCells = /* @__PURE__ */ new Set();
|
|
6198
|
+
const nextRows = table.rows.map((row, rowIndex) => {
|
|
6199
|
+
const sourceRow = row.map((cell2) => cellById.get(cell2.paragraphs[0]?.id ?? "")?.row).find((index) => index !== void 0 && !usedRows.has(index));
|
|
6200
|
+
if (sourceRow !== void 0) usedRows.add(sourceRow);
|
|
6201
|
+
const tr = sourceRow === void 0 ? makeW(doc, "tr") : oldRows[sourceRow] ?? makeW(doc, "tr");
|
|
6202
|
+
patchRowProperties(
|
|
6203
|
+
doc,
|
|
6204
|
+
tr,
|
|
6205
|
+
table.rowProperties?.[rowIndex],
|
|
6206
|
+
sourceRow === void 0 ? void 0 : base.rowProperties?.[sourceRow]
|
|
6207
|
+
);
|
|
6208
|
+
const nextCells = row.map((cell2) => {
|
|
6209
|
+
const source2 = cellById.get(cell2.paragraphs[0]?.id ?? "");
|
|
6210
|
+
const reuse = source2 && source2.row === sourceRow && !usedCells.has(source2.tc) ? source2 : void 0;
|
|
6211
|
+
const tc = reuse?.tc ?? makeW(doc, "tc");
|
|
6212
|
+
if (reuse) {
|
|
6213
|
+
usedCells.add(reuse.tc);
|
|
6214
|
+
patchCellLayout(doc, tc, cell2, reuse.model);
|
|
6215
|
+
patchCellBorders(doc, tc, cell2.borders, reuse.model.borders);
|
|
6216
|
+
patchCellShading(doc, tc, cell2, reuse.model);
|
|
6217
|
+
patchCellMargins(doc, tc, cell2.margins, reuse.model.margins);
|
|
6218
|
+
patchCellVerticalAlignment(doc, tc, cell2.verticalAlign, reuse.model.verticalAlign);
|
|
6219
|
+
} else {
|
|
6220
|
+
const props = buildCellProperties(doc, cell2);
|
|
6221
|
+
if (props) tc.insertBefore(props, tc.firstChild);
|
|
6222
|
+
}
|
|
6223
|
+
const oldParagraphs = reuse ? flatCellParagraphs(tc).map((entry2) => entry2.element) : [];
|
|
6224
|
+
const owned = new Set(oldParagraphs);
|
|
6225
|
+
const nextParagraphs = cell2.paragraphs.map((paragraph2) => {
|
|
6226
|
+
const found = paragraphById.get(paragraph2.id);
|
|
6227
|
+
const element4 = found ? owned.has(found.element) ? found.element : found.element.cloneNode(true) : makeW(doc, "p");
|
|
6228
|
+
return writeParagraph(doc, paragraph2, element4, found?.model);
|
|
6229
|
+
});
|
|
6230
|
+
replaceSlots2(doc, tc, oldParagraphs, nextParagraphs);
|
|
6231
|
+
if (reuse) writeNested(doc, tc, cell2, reuse.model);
|
|
6232
|
+
return tc;
|
|
6233
|
+
});
|
|
6234
|
+
replaceSlots2(doc, tr, sourceRow === void 0 ? [] : oldCells[sourceRow] ?? [], nextCells);
|
|
6235
|
+
return tr;
|
|
6236
|
+
});
|
|
6237
|
+
replaceSlots2(doc, node, oldRows, nextRows);
|
|
6238
|
+
patchTableMargins(doc, table, node, base);
|
|
6239
|
+
patchGrid(doc, node, table);
|
|
6240
|
+
return node;
|
|
6241
|
+
}
|
|
6242
|
+
|
|
6243
|
+
// docx/table-grid.ts
|
|
6244
|
+
var spanOf = (cell2) => Math.max(1, cell2.gridSpan ?? 1);
|
|
6245
|
+
function tableGrid(table) {
|
|
6246
|
+
const columns2 = table.grid?.length ?? sumSpans(table.rows[0]);
|
|
6247
|
+
if (!columns2 || !table.rows.length) return void 0;
|
|
6248
|
+
const rows2 = [];
|
|
6249
|
+
const cover = [];
|
|
6250
|
+
for (let row = 0; row < table.rows.length; row++) {
|
|
6251
|
+
const cells = table.rows[row] ?? [];
|
|
6252
|
+
if (!cells.length || sumSpans(cells) !== columns2) return void 0;
|
|
6253
|
+
const placed = [];
|
|
6254
|
+
const line3 = new Array(columns2);
|
|
6255
|
+
let col = 0;
|
|
6256
|
+
cells.forEach((cell2, index) => {
|
|
6257
|
+
const entry2 = { cell: cell2, row, index, col, span: spanOf(cell2) };
|
|
6258
|
+
for (let k = 0; k < entry2.span; k++) line3[col + k] = entry2;
|
|
6259
|
+
col += entry2.span;
|
|
6260
|
+
placed.push(entry2);
|
|
6261
|
+
});
|
|
6262
|
+
rows2.push(placed);
|
|
6263
|
+
cover.push(line3);
|
|
6264
|
+
}
|
|
6265
|
+
const grid = { columns: columns2, rows: rows2, cover };
|
|
6266
|
+
for (const entry2 of rows2.flat())
|
|
6267
|
+
if (entry2.cell.verticalMerge === "continue") {
|
|
6268
|
+
const above = entry2.row > 0 ? cover[entry2.row - 1]?.[entry2.col] : void 0;
|
|
6269
|
+
if (!above || above.col !== entry2.col || above.span !== entry2.span) return void 0;
|
|
6270
|
+
if (!above.cell.verticalMerge) return void 0;
|
|
6271
|
+
}
|
|
6272
|
+
return grid;
|
|
6273
|
+
}
|
|
6274
|
+
function sumSpans(cells) {
|
|
6275
|
+
return (cells ?? []).reduce((sum, cell2) => sum + spanOf(cell2), 0);
|
|
6276
|
+
}
|
|
6277
|
+
|
|
6278
|
+
// docx/write-table.ts
|
|
5338
6279
|
var layout = (table) => table.rows.map((row) => row.map((cell2) => cell2.paragraphs.map((p) => p.id)));
|
|
5339
6280
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
5340
6281
|
"grid",
|
|
@@ -5352,13 +6293,15 @@ function pick(source2, keys) {
|
|
|
5352
6293
|
for (const key of keys) if (record[key] !== void 0) result[key] = record[key];
|
|
5353
6294
|
return result;
|
|
5354
6295
|
}
|
|
5355
|
-
function assertNoDescriptorEdits(table, base) {
|
|
6296
|
+
function assertNoDescriptorEdits(table, base, layoutEdits = false) {
|
|
5356
6297
|
if (!base) return;
|
|
5357
|
-
|
|
6298
|
+
const tableKeys = layoutEdits ? TABLE_DESCRIPTOR_KEYS.filter((key) => key !== "grid") : TABLE_DESCRIPTOR_KEYS;
|
|
6299
|
+
if (JSON.stringify(pick(table, tableKeys)) !== JSON.stringify(pick(base, tableKeys)))
|
|
5358
6300
|
throw new Error(
|
|
5359
6301
|
"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."
|
|
5360
6302
|
);
|
|
5361
6303
|
const baseCellById = /* @__PURE__ */ new Map();
|
|
6304
|
+
if (layoutEdits) return;
|
|
5362
6305
|
for (const row of base.rows)
|
|
5363
6306
|
for (const cell2 of row) {
|
|
5364
6307
|
const id = cell2.paragraphs[0]?.id;
|
|
@@ -5383,11 +6326,24 @@ function writeNestedTables(doc, tc, cell2, base, writeParagraph, replaceSlots2)
|
|
|
5383
6326
|
next.forEach((table, index) => {
|
|
5384
6327
|
const node = nodes[index];
|
|
5385
6328
|
if (node && before[index])
|
|
5386
|
-
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2);
|
|
6329
|
+
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2, true);
|
|
5387
6330
|
});
|
|
5388
6331
|
}
|
|
5389
|
-
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
6332
|
+
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2, nested = false) {
|
|
5390
6333
|
if (base && JSON.stringify(table) === JSON.stringify(base)) return node;
|
|
6334
|
+
const baseGrid = base && tableGrid(base);
|
|
6335
|
+
if (base && baseGrid && (nested || !base.structureEditable || table.structureEditable === false) && restructured(table, base) && canRestructureTable(node)) {
|
|
6336
|
+
assertNoDescriptorEdits(table, base, true);
|
|
6337
|
+
return writeRestructuredTable(
|
|
6338
|
+
doc,
|
|
6339
|
+
table,
|
|
6340
|
+
node,
|
|
6341
|
+
base,
|
|
6342
|
+
writeParagraph,
|
|
6343
|
+
replaceSlots2,
|
|
6344
|
+
(d, tc, cell2, before) => writeNestedTables(d, tc, cell2, before, writeParagraph, replaceSlots2)
|
|
6345
|
+
);
|
|
6346
|
+
}
|
|
5391
6347
|
assertNoDescriptorEdits(table, base);
|
|
5392
6348
|
patchTableMargins(doc, table, node, base);
|
|
5393
6349
|
const structural = base && JSON.stringify(layout(table)) !== JSON.stringify(layout(base));
|
|
@@ -5513,13 +6469,13 @@ function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
|
5513
6469
|
|
|
5514
6470
|
// docx/write-footnote-columns.ts
|
|
5515
6471
|
var W15 = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
5516
|
-
var
|
|
6472
|
+
var XMLNS4 = "http://www.w3.org/2000/xmlns/";
|
|
5517
6473
|
var MC2 = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
5518
6474
|
function prefix(doc, preferred, namespace) {
|
|
5519
6475
|
let name = preferred;
|
|
5520
6476
|
for (let suffix = 1; doc.documentElement.lookupNamespaceURI(name) && doc.documentElement.lookupNamespaceURI(name) !== namespace; suffix++)
|
|
5521
6477
|
name = preferred + suffix;
|
|
5522
|
-
doc.documentElement.setAttributeNS(
|
|
6478
|
+
doc.documentElement.setAttributeNS(XMLNS4, "xmlns:" + name, namespace);
|
|
5523
6479
|
return name;
|
|
5524
6480
|
}
|
|
5525
6481
|
function writeFootnoteColumns(doc, section, value) {
|
|
@@ -5542,13 +6498,13 @@ function writeFootnoteColumns(doc, section, value) {
|
|
|
5542
6498
|
}
|
|
5543
6499
|
|
|
5544
6500
|
// docx/page-borders.ts
|
|
5545
|
-
var
|
|
6501
|
+
var SIDES5 = ["top", "left", "bottom", "right"];
|
|
5546
6502
|
var ATTRIBUTES = ["offsetFrom", "display", "zOrder"];
|
|
5547
6503
|
var setW4 = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
5548
6504
|
function parsePageBorders(element4) {
|
|
5549
6505
|
if (!element4) return void 0;
|
|
5550
6506
|
const result = {};
|
|
5551
|
-
for (const side of
|
|
6507
|
+
for (const side of SIDES5) {
|
|
5552
6508
|
const source2 = first2(element4, side);
|
|
5553
6509
|
const value = borderSide(source2);
|
|
5554
6510
|
const art = getW(source2, "art");
|
|
@@ -5586,7 +6542,7 @@ function patchPageBorders(doc, sectPr, next, base, create2) {
|
|
|
5586
6542
|
return;
|
|
5587
6543
|
}
|
|
5588
6544
|
const element4 = create2(doc, sectPr, "pgBorders");
|
|
5589
|
-
for (const side of
|
|
6545
|
+
for (const side of SIDES5) {
|
|
5590
6546
|
if (JSON.stringify(next[side]) === JSON.stringify(base?.[side])) continue;
|
|
5591
6547
|
for (const old of children2(element4, side)) element4.removeChild(old);
|
|
5592
6548
|
const value = next[side];
|
|
@@ -5767,75 +6723,6 @@ function writePageNumbering(doc, sectPr, section) {
|
|
|
5767
6723
|
}
|
|
5768
6724
|
}
|
|
5769
6725
|
|
|
5770
|
-
// docx/tab-stops.ts
|
|
5771
|
-
function parseTabStops(tabs) {
|
|
5772
|
-
const stops = [];
|
|
5773
|
-
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
5774
|
-
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
5775
|
-
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
5776
|
-
if (!align || pos === void 0) continue;
|
|
5777
|
-
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
5778
|
-
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
5779
|
-
}
|
|
5780
|
-
return stops;
|
|
5781
|
-
}
|
|
5782
|
-
function writeTabStops(doc, props, paragraph2, base) {
|
|
5783
|
-
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
5784
|
-
return;
|
|
5785
|
-
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
5786
|
-
if (!paragraph2.tabStops?.length) return;
|
|
5787
|
-
const tabs = makeW(doc, "tabs");
|
|
5788
|
-
for (const stop of paragraph2.tabStops) {
|
|
5789
|
-
const tab = makeW(doc, "tab");
|
|
5790
|
-
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
5791
|
-
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
5792
|
-
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
5793
|
-
tabs.appendChild(tab);
|
|
5794
|
-
}
|
|
5795
|
-
props.appendChild(tabs);
|
|
5796
|
-
}
|
|
5797
|
-
var PPR_ORDER = [
|
|
5798
|
-
"pStyle",
|
|
5799
|
-
"keepNext",
|
|
5800
|
-
"keepLines",
|
|
5801
|
-
"pageBreakBefore",
|
|
5802
|
-
"framePr",
|
|
5803
|
-
"widowControl",
|
|
5804
|
-
"numPr",
|
|
5805
|
-
"suppressLineNumbers",
|
|
5806
|
-
"pBdr",
|
|
5807
|
-
"shd",
|
|
5808
|
-
"tabs",
|
|
5809
|
-
"suppressAutoHyphens",
|
|
5810
|
-
"kinsoku",
|
|
5811
|
-
"wordWrap",
|
|
5812
|
-
"overflowPunct",
|
|
5813
|
-
"topLinePunct",
|
|
5814
|
-
"autoSpaceDE",
|
|
5815
|
-
"autoSpaceDN",
|
|
5816
|
-
"bidi",
|
|
5817
|
-
"adjustRightInd",
|
|
5818
|
-
"snapToGrid",
|
|
5819
|
-
"spacing",
|
|
5820
|
-
"ind",
|
|
5821
|
-
"contextualSpacing",
|
|
5822
|
-
"mirrorIndents",
|
|
5823
|
-
"suppressOverlap",
|
|
5824
|
-
"jc",
|
|
5825
|
-
"textDirection",
|
|
5826
|
-
"textAlignment",
|
|
5827
|
-
"textboxTightWrap",
|
|
5828
|
-
"outlineLvl",
|
|
5829
|
-
"divId",
|
|
5830
|
-
"cnfStyle",
|
|
5831
|
-
"rPr",
|
|
5832
|
-
"sectPr",
|
|
5833
|
-
"pPrChange"
|
|
5834
|
-
];
|
|
5835
|
-
function orderParagraphProperties(props) {
|
|
5836
|
-
orderChildren(props, PPR_ORDER);
|
|
5837
|
-
}
|
|
5838
|
-
|
|
5839
6726
|
// docx/write-sections.ts
|
|
5840
6727
|
var WRITABLE = /* @__PURE__ */ new Set([
|
|
5841
6728
|
"endsAtBlockId",
|
|
@@ -6440,16 +7327,16 @@ function isWordElement(element4, names) {
|
|
|
6440
7327
|
}
|
|
6441
7328
|
var isRevisionWrapperElement = (element4) => isWordElement(element4, REVISION_WRAPPER_NAMES2);
|
|
6442
7329
|
var isCommentAnchorElement = (element4) => isWordElement(element4, COMMENT_ANCHOR_NAMES);
|
|
6443
|
-
function
|
|
7330
|
+
function setAttribute3(element4, local, value) {
|
|
6444
7331
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
6445
7332
|
}
|
|
6446
7333
|
function removeChildren(element4, local) {
|
|
6447
7334
|
for (const child7 of children2(element4, local)) element4.removeChild(child7);
|
|
6448
7335
|
}
|
|
6449
7336
|
function writeRevisionMetadata(element4, revision) {
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
if (revision.date)
|
|
7337
|
+
setAttribute3(element4, "id", revision.id);
|
|
7338
|
+
setAttribute3(element4, "author", revision.author);
|
|
7339
|
+
if (revision.date) setAttribute3(element4, "date", revision.date);
|
|
6453
7340
|
else element4.removeAttributeNS(WORD_NS, "date");
|
|
6454
7341
|
if (revision.dateUtc) element4.setAttributeNS(WORD_DATE_UTC_NS, "w16du:dateUtc", revision.dateUtc);
|
|
6455
7342
|
else element4.removeAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
@@ -6584,184 +7471,6 @@ function restoreAnnotations(markers, before, after) {
|
|
|
6584
7471
|
}
|
|
6585
7472
|
}
|
|
6586
7473
|
|
|
6587
|
-
// docx/write-paragraph-decoration.ts
|
|
6588
|
-
var SIDES5 = ["top", "left", "bottom", "right", "between"];
|
|
6589
|
-
function wordColor(color) {
|
|
6590
|
-
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
6591
|
-
return hex ? hex.toUpperCase() : "auto";
|
|
6592
|
-
}
|
|
6593
|
-
function borderElement(doc, name, side) {
|
|
6594
|
-
const element4 = makeW(doc, name);
|
|
6595
|
-
const set = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
6596
|
-
set("val", side.style ?? "single");
|
|
6597
|
-
if (side.style !== "none" && side.style !== "nil") {
|
|
6598
|
-
set("sz", String(side.sizeEighthPoints ?? 4));
|
|
6599
|
-
set("space", String(side.spacePoints ?? 1));
|
|
6600
|
-
set("color", wordColor(side.color));
|
|
6601
|
-
if (side.themeColor) set("themeColor", side.themeColor);
|
|
6602
|
-
}
|
|
6603
|
-
return element4;
|
|
6604
|
-
}
|
|
6605
|
-
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
6606
|
-
function updateShading(doc, props, paragraph2, base) {
|
|
6607
|
-
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
6608
|
-
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
6609
|
-
if (!paragraph2.shadingFill) return;
|
|
6610
|
-
const shd = makeW(doc, "shd");
|
|
6611
|
-
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
6612
|
-
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
6613
|
-
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
6614
|
-
props.appendChild(shd);
|
|
6615
|
-
}
|
|
6616
|
-
function updateBorders(doc, props, paragraph2, base) {
|
|
6617
|
-
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
6618
|
-
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
6619
|
-
const borders = paragraph2.borders;
|
|
6620
|
-
if (!borders) return;
|
|
6621
|
-
const pBdr = makeW(doc, "pBdr");
|
|
6622
|
-
for (const side of SIDES5) {
|
|
6623
|
-
const value = borders[side];
|
|
6624
|
-
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
6625
|
-
}
|
|
6626
|
-
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
6627
|
-
}
|
|
6628
|
-
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
6629
|
-
updateShading(doc, props, paragraph2, base);
|
|
6630
|
-
updateBorders(doc, props, paragraph2, base);
|
|
6631
|
-
}
|
|
6632
|
-
|
|
6633
|
-
// docx/write-paragraph-properties.ts
|
|
6634
|
-
function setAttribute3(element4, local, value) {
|
|
6635
|
-
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
6636
|
-
}
|
|
6637
|
-
function setWordValue(element4, local, value) {
|
|
6638
|
-
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
6639
|
-
else setAttribute3(element4, local, String(value));
|
|
6640
|
-
}
|
|
6641
|
-
function updateDirection(doc, props, paragraph2, base) {
|
|
6642
|
-
if (base && paragraph2.direction === base.direction) return;
|
|
6643
|
-
let bidi = first2(props, "bidi");
|
|
6644
|
-
if (paragraph2.direction === void 0) {
|
|
6645
|
-
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
6646
|
-
} else {
|
|
6647
|
-
if (!bidi) {
|
|
6648
|
-
bidi = makeW(doc, "bidi");
|
|
6649
|
-
props.appendChild(bidi);
|
|
6650
|
-
}
|
|
6651
|
-
setAttribute3(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
6652
|
-
}
|
|
6653
|
-
}
|
|
6654
|
-
function updateSpacing(doc, props, paragraph2, base) {
|
|
6655
|
-
let spacing3 = first2(props, "spacing");
|
|
6656
|
-
if (!spacing3) {
|
|
6657
|
-
spacing3 = makeW(doc, "spacing");
|
|
6658
|
-
props.appendChild(spacing3);
|
|
6659
|
-
}
|
|
6660
|
-
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
6661
|
-
setWordValue(spacing3, "before", paragraph2.spacingBeforeTwips);
|
|
6662
|
-
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
6663
|
-
setWordValue(spacing3, "after", paragraph2.spacingAfterTwips);
|
|
6664
|
-
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
6665
|
-
setWordValue(spacing3, "line", paragraph2.lineSpacingTwips);
|
|
6666
|
-
setWordValue(
|
|
6667
|
-
spacing3,
|
|
6668
|
-
"lineRule",
|
|
6669
|
-
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
6670
|
-
);
|
|
6671
|
-
}
|
|
6672
|
-
if (!spacing3.attributes.length && !spacing3.childNodes.length) props.removeChild(spacing3);
|
|
6673
|
-
}
|
|
6674
|
-
function updateIndent(doc, props, paragraph2, base) {
|
|
6675
|
-
let indent = first2(props, "ind");
|
|
6676
|
-
if (!indent) {
|
|
6677
|
-
indent = makeW(doc, "ind");
|
|
6678
|
-
props.appendChild(indent);
|
|
6679
|
-
}
|
|
6680
|
-
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
6681
|
-
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
6682
|
-
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
6683
|
-
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
6684
|
-
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
6685
|
-
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
6686
|
-
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
6687
|
-
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
6688
|
-
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
6689
|
-
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
6690
|
-
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
6691
|
-
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
6692
|
-
if (!indent.attributes.length) props.removeChild(indent);
|
|
6693
|
-
}
|
|
6694
|
-
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
6695
|
-
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
6696
|
-
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
6697
|
-
if (paragraph2.pageBreakBefore !== void 0) {
|
|
6698
|
-
const element4 = makeW(doc, "pageBreakBefore");
|
|
6699
|
-
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
6700
|
-
props.appendChild(element4);
|
|
6701
|
-
}
|
|
6702
|
-
}
|
|
6703
|
-
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
6704
|
-
for (const key of [
|
|
6705
|
-
"keepNext",
|
|
6706
|
-
"keepLines",
|
|
6707
|
-
"widowControl",
|
|
6708
|
-
"contextualSpacing",
|
|
6709
|
-
"suppressLineNumbers"
|
|
6710
|
-
]) {
|
|
6711
|
-
if (base && paragraph2[key] === base[key]) continue;
|
|
6712
|
-
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
6713
|
-
const value = paragraph2[key];
|
|
6714
|
-
if (value === void 0) continue;
|
|
6715
|
-
const element4 = makeW(doc, key);
|
|
6716
|
-
if (!value) setAttribute3(element4, "val", "0");
|
|
6717
|
-
props.appendChild(element4);
|
|
6718
|
-
}
|
|
6719
|
-
}
|
|
6720
|
-
function updateDropCap(doc, props, paragraph2, base) {
|
|
6721
|
-
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
6722
|
-
let frame2 = first2(props, "framePr");
|
|
6723
|
-
const cap = paragraph2.dropCap;
|
|
6724
|
-
if (!cap) {
|
|
6725
|
-
if (frame2) props.removeChild(frame2);
|
|
6726
|
-
return;
|
|
6727
|
-
}
|
|
6728
|
-
if (!frame2) {
|
|
6729
|
-
frame2 = makeW(doc, "framePr");
|
|
6730
|
-
props.appendChild(frame2);
|
|
6731
|
-
setAttribute3(frame2, "wrap", "around");
|
|
6732
|
-
setAttribute3(frame2, "vAnchor", "text");
|
|
6733
|
-
setAttribute3(frame2, "hAnchor", "text");
|
|
6734
|
-
}
|
|
6735
|
-
setAttribute3(frame2, "dropCap", cap.style);
|
|
6736
|
-
setAttribute3(frame2, "lines", String(cap.lines));
|
|
6737
|
-
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
6738
|
-
}
|
|
6739
|
-
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
6740
|
-
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
6741
|
-
updateKeepOptions(doc, props, paragraph2, base);
|
|
6742
|
-
updateDropCap(doc, props, paragraph2, base);
|
|
6743
|
-
updateDirection(doc, props, paragraph2, base);
|
|
6744
|
-
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
6745
|
-
const spacingKeys = [
|
|
6746
|
-
"spacingBeforeTwips",
|
|
6747
|
-
"spacingAfterTwips",
|
|
6748
|
-
"lineSpacingTwips",
|
|
6749
|
-
"lineSpacingRule"
|
|
6750
|
-
];
|
|
6751
|
-
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
6752
|
-
updateSpacing(doc, props, paragraph2, base);
|
|
6753
|
-
const indentKeys = [
|
|
6754
|
-
"indentLeftTwips",
|
|
6755
|
-
"indentRightTwips",
|
|
6756
|
-
"indentStartTwips",
|
|
6757
|
-
"indentEndTwips",
|
|
6758
|
-
"firstLineTwips",
|
|
6759
|
-
"hangingTwips"
|
|
6760
|
-
];
|
|
6761
|
-
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
6762
|
-
updateIndent(doc, props, paragraph2, base);
|
|
6763
|
-
}
|
|
6764
|
-
|
|
6765
7474
|
// docx/bookmarks.ts
|
|
6766
7475
|
function paragraphBookmarkNames(node) {
|
|
6767
7476
|
return children2(node, "bookmarkStart").map((el5) => getW(el5, "name")).filter((name) => Boolean(name));
|
|
@@ -8961,10 +9670,10 @@ function writeDrawingRichTextBody(container, body) {
|
|
|
8961
9670
|
const paragraphs = body.paragraphs.length ? body.paragraphs : [{ items: [] }];
|
|
8962
9671
|
for (const paragraph2 of paragraphs) container.appendChild(writeDrawingParagraph(doc, paragraph2));
|
|
8963
9672
|
}
|
|
8964
|
-
function drawingRichTextBodyXml(body,
|
|
8965
|
-
const prefix2 =
|
|
9673
|
+
function drawingRichTextBodyXml(body, qualifiedName2 = "a:txBody", namespace = NS.a) {
|
|
9674
|
+
const prefix2 = qualifiedName2.includes(":") ? qualifiedName2.split(":")[0] : void 0;
|
|
8966
9675
|
const declaration = prefix2 && prefix2 !== "a" ? ` xmlns:${prefix2}="${namespace}"` : "";
|
|
8967
|
-
const doc = parseXml(`<${
|
|
9676
|
+
const doc = parseXml(`<${qualifiedName2}${declaration} xmlns:a="${NS.a}" xmlns:r="${NS.r}"/>`);
|
|
8968
9677
|
writeDrawingRichTextBody(doc.documentElement, body);
|
|
8969
9678
|
return buildXml(doc);
|
|
8970
9679
|
}
|
|
@@ -15936,7 +16645,8 @@ var pie = {
|
|
|
15936
16645
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
15937
16646
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
15938
16647
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15939
|
-
gd16("
|
|
16648
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
16649
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15940
16650
|
gd16("stx", "cos wd2 stAng"),
|
|
15941
16651
|
gd16("sty", "sin hd2 stAng"),
|
|
15942
16652
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15981,7 +16691,8 @@ var chord = {
|
|
|
15981
16691
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
15982
16692
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
15983
16693
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15984
|
-
gd16("
|
|
16694
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
16695
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15985
16696
|
gd16("stx", "cos wd2 stAng"),
|
|
15986
16697
|
gd16("sty", "sin hd2 stAng"),
|
|
15987
16698
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -16005,7 +16716,8 @@ var arc = {
|
|
|
16005
16716
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
16006
16717
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
16007
16718
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
16008
|
-
gd16("
|
|
16719
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
16720
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
16009
16721
|
gd16("stx", "cos wd2 stAng"),
|
|
16010
16722
|
gd16("sty", "sin hd2 stAng"),
|
|
16011
16723
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -16100,7 +16812,8 @@ var blockArc = {
|
|
|
16100
16812
|
gd16("iwd2", "+- wd2 0 thw"),
|
|
16101
16813
|
gd16("ihd2", "+- hd2 0 thh2"),
|
|
16102
16814
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
16103
|
-
gd16("
|
|
16815
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
16816
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
16104
16817
|
gd16("mswAng", "+- 0 0 swAng2"),
|
|
16105
16818
|
gd16("stx", "cos wd2 stAng"),
|
|
16106
16819
|
gd16("sty", "sin hd2 stAng"),
|
|
@@ -18263,12 +18976,12 @@ function shapeParagraphs(wsp) {
|
|
|
18263
18976
|
function textIsPlain(wsp) {
|
|
18264
18977
|
const content = child4(child4(wsp, WPS_NS2, "txbx"), W_NS2, "txbxContent");
|
|
18265
18978
|
if (!content) return true;
|
|
18266
|
-
const
|
|
18979
|
+
const only2 = (node, allowed) => elementsOf(node).every(
|
|
18267
18980
|
(item2) => item2.namespaceURI === W_NS2 && allowed.includes(item2.localName)
|
|
18268
18981
|
);
|
|
18269
|
-
return
|
|
18270
|
-
(paragraph2) =>
|
|
18271
|
-
(run2) =>
|
|
18982
|
+
return only2(content, ["p"]) && Array.from(content.getElementsByTagNameNS(W_NS2, "p")).every(
|
|
18983
|
+
(paragraph2) => only2(paragraph2, ["pPr", "r"]) && Array.from(paragraph2.getElementsByTagNameNS(W_NS2, "r")).every(
|
|
18984
|
+
(run2) => only2(run2, ["rPr", "t"])
|
|
18272
18985
|
)
|
|
18273
18986
|
);
|
|
18274
18987
|
}
|
|
@@ -18511,7 +19224,7 @@ function parseAttributes(source2) {
|
|
|
18511
19224
|
}
|
|
18512
19225
|
return attrs2;
|
|
18513
19226
|
}
|
|
18514
|
-
function
|
|
19227
|
+
function tagEnd2(xml, from) {
|
|
18515
19228
|
let quote = "";
|
|
18516
19229
|
for (let i = from; i < xml.length; i++) {
|
|
18517
19230
|
const ch = xml[i];
|
|
@@ -18542,7 +19255,7 @@ function parseOrderedXml(xml) {
|
|
|
18542
19255
|
i = close < 0 ? -1 : xml.indexOf("<", close + 3);
|
|
18543
19256
|
continue;
|
|
18544
19257
|
}
|
|
18545
|
-
const end =
|
|
19258
|
+
const end = tagEnd2(xml, i + 1);
|
|
18546
19259
|
if (end < 0) {
|
|
18547
19260
|
break;
|
|
18548
19261
|
}
|
|
@@ -19122,17 +19835,17 @@ function isShadowedBound(node, constraint) {
|
|
|
19122
19835
|
|
|
19123
19836
|
// diagram/engine/constraint-eval.ts
|
|
19124
19837
|
function relatedNodes(node, relation2, name, ptType) {
|
|
19125
|
-
const
|
|
19838
|
+
const matches2 = (candidate) => (!name || candidate.name === name) && (matchesPointType(candidate.point, ptType) || candidate.presOf.length > 0 && matchesPointType(candidate.presOf[0], ptType));
|
|
19126
19839
|
if (relation2 === "self") {
|
|
19127
19840
|
return name && node.name !== name ? [] : [node];
|
|
19128
19841
|
}
|
|
19129
19842
|
if (relation2 === "ch") {
|
|
19130
|
-
return node.children.filter(
|
|
19843
|
+
return node.children.filter(matches2);
|
|
19131
19844
|
}
|
|
19132
19845
|
const out = [];
|
|
19133
19846
|
const visit = (current) => {
|
|
19134
19847
|
for (const child7 of current.children) {
|
|
19135
|
-
if (
|
|
19848
|
+
if (matches2(child7)) {
|
|
19136
19849
|
out.push(child7);
|
|
19137
19850
|
}
|
|
19138
19851
|
visit(child7);
|
|
@@ -23434,14 +24147,14 @@ function findDiagramShapeIndex(shapes, nodes, nodeId) {
|
|
|
23434
24147
|
const node = nodes.find((n2) => n2.id === nodeId);
|
|
23435
24148
|
if (node?.text) {
|
|
23436
24149
|
const text2 = node.text.trim();
|
|
23437
|
-
const
|
|
24150
|
+
const matches2 = [];
|
|
23438
24151
|
for (let i = 0; i < shapes.length; i++) {
|
|
23439
24152
|
if (shapes[i].text?.trim() === text2) {
|
|
23440
|
-
|
|
24153
|
+
matches2.push(i);
|
|
23441
24154
|
}
|
|
23442
24155
|
}
|
|
23443
|
-
if (
|
|
23444
|
-
return
|
|
24156
|
+
if (matches2.length === 1) {
|
|
24157
|
+
return matches2[0];
|
|
23445
24158
|
}
|
|
23446
24159
|
}
|
|
23447
24160
|
return -1;
|
|
@@ -28402,8 +29115,8 @@ function parseDisplayUnits(context, element4) {
|
|
|
28402
29115
|
|
|
28403
29116
|
// chart/write-util.ts
|
|
28404
29117
|
var INVALID_XML = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
28405
|
-
var
|
|
28406
|
-
var escapeAttribute = (value) =>
|
|
29118
|
+
var escapeText2 = (value) => value.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
29119
|
+
var escapeAttribute = (value) => escapeText2(value).replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
28407
29120
|
function chartNumber(value) {
|
|
28408
29121
|
if (!Number.isFinite(value)) throw new Error(`Chart number ${value} is not finite`);
|
|
28409
29122
|
const text2 = String(value);
|
|
@@ -29083,7 +29796,7 @@ function run(value) {
|
|
|
29083
29796
|
const hasProperties = Object.keys(properties).length > 0;
|
|
29084
29797
|
if (text2 === "\n")
|
|
29085
29798
|
return hasProperties ? `<a:br>${runProperties("rPr", properties)}</a:br>` : "<a:br/>";
|
|
29086
|
-
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${
|
|
29799
|
+
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${escapeText2(text2)}</a:t></a:r>`;
|
|
29087
29800
|
}
|
|
29088
29801
|
function paragraph(value) {
|
|
29089
29802
|
const align = value.align ? ` algn="${escapeAttribute(value.align)}"` : "";
|
|
@@ -29211,7 +29924,7 @@ function chartTextBodyFromXml(xml) {
|
|
|
29211
29924
|
}
|
|
29212
29925
|
|
|
29213
29926
|
// chart/write-text.ts
|
|
29214
|
-
var textElement = (local, value) => `<c:${local}>${
|
|
29927
|
+
var textElement = (local, value) => `<c:${local}>${escapeText2(value)}</c:${local}>`;
|
|
29215
29928
|
function cachePoints(cache) {
|
|
29216
29929
|
return cache.points.map((point, position2) => {
|
|
29217
29930
|
const format = point.formatCode === void 0 ? "" : ` formatCode="${escapeAttribute(point.formatCode)}"`;
|
|
@@ -29341,7 +30054,7 @@ function trendlineLabelXml(context, label) {
|
|
|
29341
30054
|
function trendlineXml(context, trendline) {
|
|
29342
30055
|
return elementXml(
|
|
29343
30056
|
"trendline",
|
|
29344
|
-
(trendline.name === void 0 ? "" : `<c:name>${
|
|
30057
|
+
(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)
|
|
29345
30058
|
);
|
|
29346
30059
|
}
|
|
29347
30060
|
function errorBarsXml(context, bars2) {
|
|
@@ -30086,7 +30799,7 @@ function attributes(entries) {
|
|
|
30086
30799
|
}).join("");
|
|
30087
30800
|
}
|
|
30088
30801
|
var cxElement = (local, content = "", attrs2 = "") => content ? `<cx:${local}${attrs2}>${content}</cx:${local}>` : `<cx:${local}${attrs2}/>`;
|
|
30089
|
-
var cxText = (local, text2, attrs2 = "") => text2 === void 0 ? "" : `<cx:${local}${attrs2}>${
|
|
30802
|
+
var cxText = (local, text2, attrs2 = "") => text2 === void 0 ? "" : `<cx:${local}${attrs2}>${escapeText2(text2)}</cx:${local}>`;
|
|
30090
30803
|
var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
|
|
30091
30804
|
var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
|
|
30092
30805
|
var shapeXml = (context, shape2) => shape2 ? cxElement("spPr", shapePropertiesInnerXml(context, shape2)) : "";
|
|
@@ -30526,7 +31239,7 @@ function realignChartTitleBody(body, text2) {
|
|
|
30526
31239
|
}
|
|
30527
31240
|
|
|
30528
31241
|
// chart/edit/title.ts
|
|
30529
|
-
var chartTitleRichXml = (text2) => `<a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:r><a:rPr lang="en-US"/><a:t>${
|
|
31242
|
+
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>`;
|
|
30530
31243
|
function newChartTitle(text2) {
|
|
30531
31244
|
const rich = chartTextBodyFromXml(chartTitleRichXml(text2));
|
|
30532
31245
|
return { tx: { rich, text: rich.text }, text: rich.text, overlay: false };
|
|
@@ -36610,6 +37323,10 @@ var WRAPS = [
|
|
|
36610
37323
|
function parsePlacement(anchor) {
|
|
36611
37324
|
const wrap2 = WRAPS.find(([local]) => firstNS(anchor, WP_NS2, local))?.[1] ?? "none";
|
|
36612
37325
|
const placement = { wrap: wrap2 };
|
|
37326
|
+
const wrapElement2 = WRAPS.map(([local]) => firstNS(anchor, WP_NS2, local)).find(Boolean);
|
|
37327
|
+
const wrapText = wrapElement2?.getAttribute("wrapText");
|
|
37328
|
+
if (wrapText === "bothSides" || wrapText === "left" || wrapText === "right" || wrapText === "largest")
|
|
37329
|
+
placement.wrapText = wrapText;
|
|
36613
37330
|
if (anchor.getAttribute("behindDoc") === "1") placement.behindText = true;
|
|
36614
37331
|
const positionH = firstNS(anchor, WP_NS2, "positionH");
|
|
36615
37332
|
const relativeFrom = enumValue(
|
|
@@ -37041,6 +37758,34 @@ function chartRun(doc, node, image, base, oldDrawing, oldContainer, allocator) {
|
|
|
37041
37758
|
return void 0;
|
|
37042
37759
|
}
|
|
37043
37760
|
|
|
37761
|
+
// docx/write-fallback.ts
|
|
37762
|
+
var PT_PER_PX2 = 0.75;
|
|
37763
|
+
function setStyleSize(style, name, pt) {
|
|
37764
|
+
const value = `${Math.round(pt * 100) / 100}pt`;
|
|
37765
|
+
const pattern = new RegExp(`(^|;)\\s*${name}\\s*:\\s*[^;]*`, "i");
|
|
37766
|
+
return pattern.test(style) ? style.replace(pattern, (_all, lead) => `${lead}${name}:${value}`) : style;
|
|
37767
|
+
}
|
|
37768
|
+
function patchFallbackSize(content, image, base) {
|
|
37769
|
+
if (!base || image.widthPx === base.widthPx && image.heightPx === base.heightPx) return;
|
|
37770
|
+
const fallback = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Fallback");
|
|
37771
|
+
if (!fallback) return;
|
|
37772
|
+
const stack = [fallback];
|
|
37773
|
+
while (stack.length) {
|
|
37774
|
+
const node = stack.pop();
|
|
37775
|
+
const style = node.getAttribute("style");
|
|
37776
|
+
if (style && /(^|;)\s*width\s*:/i.test(style)) {
|
|
37777
|
+
let next = style;
|
|
37778
|
+
if (image.widthPx !== base.widthPx)
|
|
37779
|
+
next = setStyleSize(next, "width", image.widthPx * PT_PER_PX2);
|
|
37780
|
+
if (image.heightPx !== base.heightPx)
|
|
37781
|
+
next = setStyleSize(next, "height", image.heightPx * PT_PER_PX2);
|
|
37782
|
+
node.setAttribute("style", next);
|
|
37783
|
+
continue;
|
|
37784
|
+
}
|
|
37785
|
+
for (const child7 of Array.from(node.childNodes)) if (isElement(child7)) stack.push(child7);
|
|
37786
|
+
}
|
|
37787
|
+
}
|
|
37788
|
+
|
|
37044
37789
|
// docx/diagram-document.ts
|
|
37045
37790
|
function diagramsIn(blocks) {
|
|
37046
37791
|
const diagrams = [];
|
|
@@ -37758,6 +38503,13 @@ function createImageRun(doc, image, base, old, allocator) {
|
|
|
37758
38503
|
}
|
|
37759
38504
|
if (base && oldDrawing && image.shape?.editable && base.shape?.editable) {
|
|
37760
38505
|
const next = rebuildShapeDrawing(doc, image, oldDrawing);
|
|
38506
|
+
const choice = oldDrawing.parentNode;
|
|
38507
|
+
if (oldContainer?.localName === "AlternateContent" && choice) {
|
|
38508
|
+
choice.replaceChild(next, oldDrawing);
|
|
38509
|
+
patchFallbackSize(oldContainer, image, base);
|
|
38510
|
+
clearNonProperties(node, oldContainer);
|
|
38511
|
+
return node;
|
|
38512
|
+
}
|
|
37761
38513
|
clearNonProperties(node);
|
|
37762
38514
|
node.appendChild(next);
|
|
37763
38515
|
return node;
|
|
@@ -38883,15 +39635,15 @@ function runIsSafe(run2) {
|
|
|
38883
39635
|
const content = Array.from(run2.childNodes).filter(
|
|
38884
39636
|
(child7) => isElement(child7) && !named2(child7, "rPr") && !isCachedPageBreak(child7)
|
|
38885
39637
|
);
|
|
38886
|
-
const
|
|
38887
|
-
if (
|
|
38888
|
-
if (
|
|
38889
|
-
(name) => named2(
|
|
39638
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
39639
|
+
if (only2 && named2(only2, "br") && isModeledBreak(only2)) return true;
|
|
39640
|
+
if (only2 && ["footnoteReference", "endnoteReference", "footnoteRef", "endnoteRef"].some(
|
|
39641
|
+
(name) => named2(only2, name)
|
|
38890
39642
|
))
|
|
38891
39643
|
return true;
|
|
38892
|
-
if (
|
|
38893
|
-
const type = getW(
|
|
38894
|
-
const data = Array.from(
|
|
39644
|
+
if (only2 && named2(only2, "fldChar")) {
|
|
39645
|
+
const type = getW(only2, "fldCharType") ?? "";
|
|
39646
|
+
const data = Array.from(only2.childNodes).filter(
|
|
38895
39647
|
(node) => isElement(node) || Boolean(node.textContent?.trim())
|
|
38896
39648
|
);
|
|
38897
39649
|
if (!data.length) return ["begin", "separate", "end"].includes(type);
|
|
@@ -39023,6 +39775,10 @@ function parseDirectParagraphProperties(props) {
|
|
|
39023
39775
|
const line3 = signedTwipValue2(getW(spacing3, "line"));
|
|
39024
39776
|
if (before !== void 0) paragraph2.spacingBeforeTwips = before;
|
|
39025
39777
|
if (after !== void 0) paragraph2.spacingAfterTwips = after;
|
|
39778
|
+
const beforeAuto = parseOnOff(getW(spacing3, "beforeAutospacing"));
|
|
39779
|
+
const afterAuto = parseOnOff(getW(spacing3, "afterAutospacing"));
|
|
39780
|
+
if (beforeAuto !== void 0) paragraph2.spacingBeforeAuto = beforeAuto;
|
|
39781
|
+
if (afterAuto !== void 0) paragraph2.spacingAfterAuto = afterAuto;
|
|
39026
39782
|
if (line3 !== void 0) {
|
|
39027
39783
|
paragraph2.lineSpacingTwips = line3;
|
|
39028
39784
|
}
|
|
@@ -39054,8 +39810,8 @@ function parseDirectParagraphProperties(props) {
|
|
|
39054
39810
|
|
|
39055
39811
|
// docx/run-segmentation.ts
|
|
39056
39812
|
var basisOf = (run2) => run2.restoredRunPropertiesXml ?? run2.sourceRunPropertiesXml;
|
|
39057
|
-
function keepsUnmodeledProperties(before, after) {
|
|
39058
|
-
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () =>
|
|
39813
|
+
function keepsUnmodeledProperties(before, after, basis = basisOf) {
|
|
39814
|
+
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () => basis(run2)));
|
|
39059
39815
|
const was = owners(before);
|
|
39060
39816
|
const now = owners(after);
|
|
39061
39817
|
const kept = (from, to, shift) => {
|
|
@@ -39089,13 +39845,22 @@ function runsToWriteAnew(paragraph2, base, slots) {
|
|
|
39089
39845
|
return !remaining.length || remaining.every((run2) => run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml);
|
|
39090
39846
|
}))
|
|
39091
39847
|
return none;
|
|
39092
|
-
if (paragraph2.runs.every(
|
|
39093
|
-
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
39094
|
-
))
|
|
39095
|
-
return none;
|
|
39096
39848
|
const sameText = paragraph2.runs.map((run2) => run2.text).join("") === base.runs.map((run2) => run2.text).join("");
|
|
39097
39849
|
const sameBoundaries = paragraph2.runs.length === base.runs.length && paragraph2.runs.every((run2, index) => run2.text === base.runs[index]?.text);
|
|
39098
39850
|
if (sameBoundaries || !sameText && paragraph2.runs.length === base.runs.length) return none;
|
|
39851
|
+
if (paragraph2.runs.every(
|
|
39852
|
+
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
39853
|
+
)) {
|
|
39854
|
+
if (keepsUnmodeledProperties(
|
|
39855
|
+
base.runs,
|
|
39856
|
+
paragraph2.runs,
|
|
39857
|
+
(run2) => run2.sourceRunPropertiesXml ?? run2.restoredRunPropertiesXml
|
|
39858
|
+
))
|
|
39859
|
+
return none;
|
|
39860
|
+
throw new Error(
|
|
39861
|
+
`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.`
|
|
39862
|
+
);
|
|
39863
|
+
}
|
|
39099
39864
|
const object = (run2) => Boolean(run2.image || run2.equation);
|
|
39100
39865
|
if (!paragraph2.runs.some(object) && !base.runs.some(object) && keepsUnmodeledProperties(base.runs, paragraph2.runs))
|
|
39101
39866
|
return new Set(
|
|
@@ -40256,14 +41021,14 @@ async function applyNumberingCatalog(zip, model, binding) {
|
|
|
40256
41021
|
}
|
|
40257
41022
|
|
|
40258
41023
|
// docx/style-numbering-package.ts
|
|
40259
|
-
var
|
|
40260
|
-
var
|
|
41024
|
+
var STYLES_PART2 = "word/styles.xml";
|
|
41025
|
+
var AFTER_PPR2 = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
40261
41026
|
var withoutNumbering = (catalog) => catalog ? {
|
|
40262
41027
|
...catalog,
|
|
40263
41028
|
styles: Object.fromEntries(
|
|
40264
41029
|
Object.entries(catalog.styles).map(([id, style]) => {
|
|
40265
|
-
const { numbering: _numbering, ...rest } = style;
|
|
40266
|
-
return [id, rest];
|
|
41030
|
+
const { numbering: _numbering, formatting, ...rest } = style;
|
|
41031
|
+
return [id, { ...rest, formatting: unwritableFormatting(formatting) }];
|
|
40267
41032
|
})
|
|
40268
41033
|
)
|
|
40269
41034
|
} : void 0;
|
|
@@ -40276,7 +41041,7 @@ function setNumPr(style, numbering) {
|
|
|
40276
41041
|
if (!numbering && !pPr) return;
|
|
40277
41042
|
if (!pPr) {
|
|
40278
41043
|
pPr = makeW(doc, "pPr");
|
|
40279
|
-
const anchor = elementsOf2(style).find((child7) =>
|
|
41044
|
+
const anchor = elementsOf2(style).find((child7) => AFTER_PPR2.includes(child7.localName)) ?? null;
|
|
40280
41045
|
style.insertBefore(pPr, anchor);
|
|
40281
41046
|
}
|
|
40282
41047
|
for (const existing of children2(pPr, "numPr")) pPr.removeChild(existing);
|
|
@@ -40300,7 +41065,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
40300
41065
|
(id) => JSON.stringify(next[id]?.numbering) !== JSON.stringify(prior[id]?.numbering)
|
|
40301
41066
|
);
|
|
40302
41067
|
if (!changed.length) return;
|
|
40303
|
-
const file = zip.file(
|
|
41068
|
+
const file = zip.file(STYLES_PART2);
|
|
40304
41069
|
if (!file) throw new Error("Cannot link styles to a list: the package has no styles.xml.");
|
|
40305
41070
|
const doc = parseXml2(await file.async("string"));
|
|
40306
41071
|
const styles = children2(doc.documentElement, "style");
|
|
@@ -40311,7 +41076,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
40311
41076
|
if (!style) throw new Error(`Cannot link style "${id}" to a list: it is not in styles.xml.`);
|
|
40312
41077
|
setNumPr(style, next[id]?.numbering);
|
|
40313
41078
|
}
|
|
40314
|
-
zip.file(
|
|
41079
|
+
zip.file(STYLES_PART2, buildXml(doc));
|
|
40315
41080
|
}
|
|
40316
41081
|
|
|
40317
41082
|
// docx/write-header-footer.ts
|
|
@@ -41721,7 +42486,7 @@ function headerFooterResults(model) {
|
|
|
41721
42486
|
return void 0;
|
|
41722
42487
|
}
|
|
41723
42488
|
}
|
|
41724
|
-
async function saveDocx(model, pendingMedia) {
|
|
42489
|
+
async function saveDocx(model, pendingMedia, options2) {
|
|
41725
42490
|
const ids = /* @__PURE__ */ new Set();
|
|
41726
42491
|
for (const block of model.blocks) {
|
|
41727
42492
|
if (ids.has(block.id)) throw new Error(`Duplicate document block id: ${block.id}`);
|
|
@@ -41812,6 +42577,7 @@ async function saveDocx(model, pendingMedia) {
|
|
|
41812
42577
|
await applyNumberingCatalog(zip, model, binding);
|
|
41813
42578
|
await applyCoreProperties(zip, model.properties, binding?.base.properties);
|
|
41814
42579
|
if (binding) await applyStyleNumbering(zip, model, binding.base);
|
|
42580
|
+
if (binding) await applyStyleFormatting(zip, model, binding.base);
|
|
41815
42581
|
if (model.compatibilityMode !== binding?.base.compatibilityMode)
|
|
41816
42582
|
await applyCompatibilityMode(zip, model.compatibilityMode);
|
|
41817
42583
|
if (Boolean(model.evenAndOddHeaders) !== Boolean(binding?.base.evenAndOddHeaders))
|
|
@@ -41843,6 +42609,8 @@ async function saveDocx(model, pendingMedia) {
|
|
|
41843
42609
|
}
|
|
41844
42610
|
if (JSON.stringify(model.comments ?? []) !== JSON.stringify(binding?.base.comments ?? []))
|
|
41845
42611
|
await applyComments(zip, model.comments ?? []);
|
|
42612
|
+
if (binding) await applyDataBindings(zip, model, binding.base, binding.context.sourceXml);
|
|
42613
|
+
if (binding) await stampModified(zip, options2?.modified);
|
|
41846
42614
|
dropAddedFolders(zip, sourceEntries);
|
|
41847
42615
|
return zip.generateAsync({ type: "uint8array", compression: "DEFLATE" });
|
|
41848
42616
|
}
|
|
@@ -41898,8 +42666,11 @@ function parseCell(cell2, parseParagraph3, id, control) {
|
|
|
41898
42666
|
const element4 = child7;
|
|
41899
42667
|
if (element4.namespaceURI !== WORD_NS) return [];
|
|
41900
42668
|
if (element4.localName === "p") return [result.paragraphs[paragraphIndex++]];
|
|
41901
|
-
if (element4.localName === "tbl")
|
|
41902
|
-
|
|
42669
|
+
if (element4.localName === "tbl") {
|
|
42670
|
+
const inner = parseTable(element4, `${id}-nested${tableIndex++}`, parseParagraph3);
|
|
42671
|
+
markRestructurable(inner, element4);
|
|
42672
|
+
return [inner];
|
|
42673
|
+
}
|
|
41903
42674
|
return [];
|
|
41904
42675
|
}
|
|
41905
42676
|
);
|
|
@@ -41955,6 +42726,9 @@ function parseRowProperties(row) {
|
|
|
41955
42726
|
if (onOffElement(first2(trPr, "tblHeader"))) result.header = true;
|
|
41956
42727
|
return result;
|
|
41957
42728
|
}
|
|
42729
|
+
function markRestructurable(table, node) {
|
|
42730
|
+
if (canRestructureTable(node) && tableGrid(table)) table.restructurable = true;
|
|
42731
|
+
}
|
|
41958
42732
|
function parseTable(node, id, parseParagraph3) {
|
|
41959
42733
|
const rowEntries = flatRows(node);
|
|
41960
42734
|
const rows2 = rowEntries.map(
|
|
@@ -41995,6 +42769,7 @@ function parseTable(node, id, parseParagraph3) {
|
|
|
41995
42769
|
return properties;
|
|
41996
42770
|
});
|
|
41997
42771
|
if (rowProperties.some((row) => Object.keys(row).length)) table.rowProperties = rowProperties;
|
|
42772
|
+
if (!table.structureEditable) markRestructurable(table, node);
|
|
41998
42773
|
return table;
|
|
41999
42774
|
}
|
|
42000
42775
|
|
|
@@ -42131,23 +42906,23 @@ function parseRun2(node, revision) {
|
|
|
42131
42906
|
let noteSeparator;
|
|
42132
42907
|
let fieldChar;
|
|
42133
42908
|
const fieldCode = content.length > 0 && content.every((child7) => named2(child7, "instrText")) ? content.map((child7) => textContent(child7)).join("") : void 0;
|
|
42134
|
-
const
|
|
42135
|
-
if (
|
|
42136
|
-
if (named2(
|
|
42137
|
-
const kind = classifyBreak(
|
|
42909
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
42910
|
+
if (only2) {
|
|
42911
|
+
if (named2(only2, "br")) {
|
|
42912
|
+
const kind = classifyBreak(only2);
|
|
42138
42913
|
if (kind === "page" || kind === "column") breakKind = kind;
|
|
42139
|
-
} else if (named2(
|
|
42140
|
-
const id = getW(
|
|
42914
|
+
} else if (named2(only2, "footnoteReference")) {
|
|
42915
|
+
const id = getW(only2, "id");
|
|
42141
42916
|
if (id) noteReference = { kind: "footnote", id };
|
|
42142
|
-
} else if (named2(
|
|
42143
|
-
const id = getW(
|
|
42917
|
+
} else if (named2(only2, "endnoteReference")) {
|
|
42918
|
+
const id = getW(only2, "id");
|
|
42144
42919
|
if (id) noteReference = { kind: "endnote", id };
|
|
42145
|
-
} else if (named2(
|
|
42146
|
-
else if (named2(
|
|
42147
|
-
else if (named2(
|
|
42148
|
-
else if (named2(
|
|
42149
|
-
else if (named2(
|
|
42150
|
-
const type = getW(
|
|
42920
|
+
} else if (named2(only2, "footnoteRef")) noteMark = "footnote";
|
|
42921
|
+
else if (named2(only2, "endnoteRef")) noteMark = "endnote";
|
|
42922
|
+
else if (named2(only2, "separator")) noteSeparator = "separator";
|
|
42923
|
+
else if (named2(only2, "continuationSeparator")) noteSeparator = "continuationSeparator";
|
|
42924
|
+
else if (named2(only2, "fldChar")) {
|
|
42925
|
+
const type = getW(only2, "fldCharType");
|
|
42151
42926
|
if (type === "begin" || type === "separate" || type === "end") fieldChar = type;
|
|
42152
42927
|
}
|
|
42153
42928
|
}
|
|
@@ -42169,9 +42944,9 @@ function parseRun2(node, revision) {
|
|
|
42169
42944
|
if (noteSeparator) run2.noteSeparator = noteSeparator;
|
|
42170
42945
|
if (fieldChar) {
|
|
42171
42946
|
run2.fieldChar = fieldChar;
|
|
42172
|
-
const flags = parseFieldFlags(
|
|
42947
|
+
const flags = parseFieldFlags(only2);
|
|
42173
42948
|
if (flags) run2.fieldFlags = flags;
|
|
42174
|
-
const data = fieldChar === "begin" ? first2(
|
|
42949
|
+
const data = fieldChar === "begin" ? first2(only2, "ffData") : void 0;
|
|
42175
42950
|
const formField = data && parseFormField(data);
|
|
42176
42951
|
if (formField) run2.formField = formField;
|
|
42177
42952
|
}
|
|
@@ -42582,6 +43357,7 @@ function parseSettings(xml) {
|
|
|
42582
43357
|
);
|
|
42583
43358
|
return {
|
|
42584
43359
|
...compatibilityMode !== void 0 && Number.isInteger(compatibilityMode) && compatibilityMode > 0 ? { compatibilityMode } : {},
|
|
43360
|
+
...onOffElement(first2(first2(root, "compat"), "doNotUseHTMLParagraphAutoSpacing")) === true ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
42585
43361
|
evenAndOddHeaders: onOffElement(first2(root, "evenAndOddHeaders")) === true,
|
|
42586
43362
|
autoHyphenation: onOffElement(first2(root, "autoHyphenation")) === true,
|
|
42587
43363
|
...footnoteNumFmt ? { footnoteNumFmt } : {},
|
|
@@ -42662,6 +43438,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
42662
43438
|
return {
|
|
42663
43439
|
sections: sections2,
|
|
42664
43440
|
...settings.compatibilityMode !== void 0 ? { compatibilityMode: settings.compatibilityMode } : {},
|
|
43441
|
+
...settings.doNotUseHtmlParagraphAutoSpacing ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
42665
43442
|
...footnotes ? { footnotes } : {},
|
|
42666
43443
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
42667
43444
|
...endnotes ? { endnotes } : {},
|
|
@@ -42904,6 +43681,7 @@ async function readPackage(input) {
|
|
|
42904
43681
|
const parts = await parseDocumentParts(zip, body, blocks, drawings);
|
|
42905
43682
|
model.sections = parts.sections;
|
|
42906
43683
|
if (parts.compatibilityMode !== void 0) model.compatibilityMode = parts.compatibilityMode;
|
|
43684
|
+
if (parts.doNotUseHtmlParagraphAutoSpacing) model.doNotUseHtmlParagraphAutoSpacing = true;
|
|
42907
43685
|
if (parts.footnotes) model.footnotes = parts.footnotes;
|
|
42908
43686
|
if (parts.footnoteSeparators) model.footnoteSeparators = parts.footnoteSeparators;
|
|
42909
43687
|
if (parts.endnotes) model.endnotes = parts.endnotes;
|
|
@@ -42913,14 +43691,16 @@ async function readPackage(input) {
|
|
|
42913
43691
|
if (parts.autoHyphenation) model.autoHyphenation = true;
|
|
42914
43692
|
const coreFile = zip.file("docProps/core.xml");
|
|
42915
43693
|
if (coreFile) {
|
|
42916
|
-
const properties =
|
|
43694
|
+
const properties = parseCoreProperties2(await coreFile.async("string"));
|
|
42917
43695
|
if (properties) model.properties = properties;
|
|
42918
43696
|
}
|
|
42919
43697
|
await readPlaceholderTexts(zip, drawings.rels, model);
|
|
42920
43698
|
const pageColor = parsePageBackground(document.documentElement);
|
|
42921
43699
|
if (pageColor) model.pageColor = pageColor;
|
|
42922
43700
|
model.warnings.push(...parts.warnings);
|
|
42923
|
-
if (blocks.some(
|
|
43701
|
+
if (blocks.some(
|
|
43702
|
+
(block) => block.type === "table" && !block.structureEditable && !block.restructurable
|
|
43703
|
+
))
|
|
42924
43704
|
model.warnings.push(
|
|
42925
43705
|
"Merged, nested, or complex tables can be read, but their row and column structure cannot be edited safely."
|
|
42926
43706
|
);
|
|
@@ -42946,7 +43726,7 @@ async function readPackage(input) {
|
|
|
42946
43726
|
(block) => block.type === "table" && block.rows.some((row) => row.some((cell2) => cell2.nestedTables?.length))
|
|
42947
43727
|
))
|
|
42948
43728
|
model.warnings.push(
|
|
42949
|
-
"Text
|
|
43729
|
+
"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."
|
|
42950
43730
|
);
|
|
42951
43731
|
const pictureBlocks = documentDrawingBlocks({ ...model, blocks });
|
|
42952
43732
|
await resolveDocumentDiagrams(
|
|
@@ -42984,9 +43764,9 @@ async function loadDocx(input) {
|
|
|
42984
43764
|
return {
|
|
42985
43765
|
model,
|
|
42986
43766
|
media,
|
|
42987
|
-
save: (next = model, pendingMedia) => {
|
|
43767
|
+
save: (next = model, pendingMedia, options2) => {
|
|
42988
43768
|
if (next !== model) remember(next, context);
|
|
42989
|
-
return saveDocx(next, pendingMedia);
|
|
43769
|
+
return saveDocx(next, pendingMedia, options2);
|
|
42990
43770
|
}
|
|
42991
43771
|
};
|
|
42992
43772
|
}
|
|
@@ -43357,7 +44137,7 @@ function reviewDocumentFormatting(model, mode) {
|
|
|
43357
44137
|
}
|
|
43358
44138
|
|
|
43359
44139
|
// docx/revision-commands.ts
|
|
43360
|
-
function
|
|
44140
|
+
function paragraphsOf3(blocks) {
|
|
43361
44141
|
const paragraphs = [];
|
|
43362
44142
|
for (const block of blocks)
|
|
43363
44143
|
if (block.type === "paragraph") paragraphs.push(block);
|
|
@@ -43365,7 +44145,7 @@ function paragraphsOf2(blocks) {
|
|
|
43365
44145
|
return paragraphs;
|
|
43366
44146
|
}
|
|
43367
44147
|
function documentParagraphs2(model) {
|
|
43368
|
-
return documentBlockLists(model).flatMap(
|
|
44148
|
+
return documentBlockLists(model).flatMap(paragraphsOf3);
|
|
43369
44149
|
}
|
|
43370
44150
|
function listRevisions(model) {
|
|
43371
44151
|
const entries = [];
|
|
@@ -44574,13 +45354,13 @@ function resolveCellVisuals(table, cell2, placement, styles) {
|
|
|
44574
45354
|
function visibleText(paragraph2) {
|
|
44575
45355
|
return paragraph2.runs.filter((run2) => !run2.fieldCode && !run2.fieldChar).filter((run2) => run2.revision?.kind !== "delete" && run2.revision?.kind !== "moveFrom").map((run2) => run2.text).join("");
|
|
44576
45356
|
}
|
|
44577
|
-
function
|
|
45357
|
+
function paragraphsOf4(blocks) {
|
|
44578
45358
|
return blocks.flatMap(
|
|
44579
45359
|
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell2) => cell2.paragraphs))
|
|
44580
45360
|
);
|
|
44581
45361
|
}
|
|
44582
45362
|
function documentStats(model) {
|
|
44583
|
-
const paragraphs =
|
|
45363
|
+
const paragraphs = paragraphsOf4(model.blocks);
|
|
44584
45364
|
const text2 = paragraphs.map(visibleText).join("");
|
|
44585
45365
|
const revisions = paragraphs.reduce(
|
|
44586
45366
|
(count, paragraph2) => count + paragraph2.runs.filter((run2) => run2.revision).length + (paragraph2.markRevision ? 1 : 0),
|