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/embedded.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
|
|
@@ -793,6 +836,10 @@ function parseFormatting(pPr) {
|
|
|
793
836
|
const line2 = signedTwipValue(getW(spacing2, "line"));
|
|
794
837
|
if (before !== void 0) result.spacingBeforeTwips = before;
|
|
795
838
|
if (after !== void 0) result.spacingAfterTwips = after;
|
|
839
|
+
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
840
|
+
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
841
|
+
if (beforeAuto !== void 0) result.spacingBeforeAuto = beforeAuto;
|
|
842
|
+
if (afterAuto !== void 0) result.spacingAfterAuto = afterAuto;
|
|
796
843
|
if (line2 !== void 0) result.lineSpacingTwips = line2;
|
|
797
844
|
const rule = getW(spacing2, "lineRule");
|
|
798
845
|
if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
|
|
@@ -1592,7 +1639,7 @@ function applyPictureEffects(blip, effects) {
|
|
|
1592
1639
|
const node = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
1593
1640
|
if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
|
|
1594
1641
|
throw new Error("Picture effect source does not match its kind");
|
|
1595
|
-
const
|
|
1642
|
+
const set2 = (name2, value) => {
|
|
1596
1643
|
const original = picturePercentage(node.getAttribute(name2));
|
|
1597
1644
|
if (value === void 0) node.removeAttribute(name2);
|
|
1598
1645
|
else if (value !== original) {
|
|
@@ -1605,12 +1652,12 @@ function applyPictureEffects(blip, effects) {
|
|
|
1605
1652
|
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
1606
1653
|
))
|
|
1607
1654
|
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
1608
|
-
|
|
1609
|
-
|
|
1655
|
+
set2("bright", effect.brightness);
|
|
1656
|
+
set2("contrast", effect.contrast);
|
|
1610
1657
|
}
|
|
1611
1658
|
if (effect.kind === "alphaModFix") {
|
|
1612
1659
|
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
1613
|
-
|
|
1660
|
+
set2("amt", effect.amount);
|
|
1614
1661
|
}
|
|
1615
1662
|
return node;
|
|
1616
1663
|
});
|
|
@@ -2923,6 +2970,233 @@ async function openZip(input, limits = {}) {
|
|
|
2923
2970
|
return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
|
|
2924
2971
|
}
|
|
2925
2972
|
|
|
2973
|
+
// opc/properties/patch.ts
|
|
2974
|
+
var XMLNS3 = "http://www.w3.org/2000/xmlns/";
|
|
2975
|
+
function tagEnd(xml, from) {
|
|
2976
|
+
let quote = "";
|
|
2977
|
+
for (let i = from + 1; i < xml.length; i++) {
|
|
2978
|
+
const ch = xml[i];
|
|
2979
|
+
if (quote) {
|
|
2980
|
+
if (ch === quote) quote = "";
|
|
2981
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
2982
|
+
else if (ch === ">") return i + 1;
|
|
2983
|
+
}
|
|
2984
|
+
throw new Error("Unterminated tag in property part");
|
|
2985
|
+
}
|
|
2986
|
+
function skipMarkup(xml, at) {
|
|
2987
|
+
if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
|
|
2988
|
+
if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
|
|
2989
|
+
if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
|
|
2990
|
+
return void 0;
|
|
2991
|
+
}
|
|
2992
|
+
function scan(xml) {
|
|
2993
|
+
let i = 0;
|
|
2994
|
+
let rootStart = -1;
|
|
2995
|
+
while (rootStart < 0) {
|
|
2996
|
+
const lt = xml.indexOf("<", i);
|
|
2997
|
+
if (lt < 0) throw new Error("Property part has no root element");
|
|
2998
|
+
const skipped = skipMarkup(xml, lt);
|
|
2999
|
+
if (skipped !== void 0) i = skipped;
|
|
3000
|
+
else rootStart = lt;
|
|
3001
|
+
}
|
|
3002
|
+
const openEnd = tagEnd(xml, rootStart);
|
|
3003
|
+
if (xml[openEnd - 2] === "/") {
|
|
3004
|
+
const root = {
|
|
3005
|
+
start: rootStart,
|
|
3006
|
+
openEnd,
|
|
3007
|
+
closeStart: openEnd,
|
|
3008
|
+
end: openEnd,
|
|
3009
|
+
selfClosing: true
|
|
3010
|
+
};
|
|
3011
|
+
return { root, children: [] };
|
|
3012
|
+
}
|
|
3013
|
+
const children3 = [];
|
|
3014
|
+
let depth = 0;
|
|
3015
|
+
let child7;
|
|
3016
|
+
i = openEnd;
|
|
3017
|
+
for (; ; ) {
|
|
3018
|
+
const lt = xml.indexOf("<", i);
|
|
3019
|
+
if (lt < 0) throw new Error("Property part root is not closed");
|
|
3020
|
+
const skipped = skipMarkup(xml, lt);
|
|
3021
|
+
if (skipped !== void 0) {
|
|
3022
|
+
i = skipped;
|
|
3023
|
+
continue;
|
|
3024
|
+
}
|
|
3025
|
+
const end = tagEnd(xml, lt);
|
|
3026
|
+
i = end;
|
|
3027
|
+
if (xml[lt + 1] === "/") {
|
|
3028
|
+
if (depth === 0) {
|
|
3029
|
+
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
3030
|
+
return { root, children: children3 };
|
|
3031
|
+
}
|
|
3032
|
+
depth--;
|
|
3033
|
+
if (depth === 0 && child7)
|
|
3034
|
+
children3.push({ ...child7, closeStart: lt, end, selfClosing: false });
|
|
3035
|
+
} else if (xml[end - 2] === "/") {
|
|
3036
|
+
if (depth === 0)
|
|
3037
|
+
children3.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
3038
|
+
} else {
|
|
3039
|
+
if (depth === 0) child7 = { start: lt, openEnd: end };
|
|
3040
|
+
depth++;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
var escapeText = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
3045
|
+
var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
3046
|
+
var PartPatch = class {
|
|
3047
|
+
constructor(xml, rootElement) {
|
|
3048
|
+
this.xml = xml;
|
|
3049
|
+
const { root, children: children3 } = scan(xml);
|
|
3050
|
+
const kids = elements(rootElement);
|
|
3051
|
+
if (kids.length !== children3.length) throw new Error("Property part markup is not supported");
|
|
3052
|
+
kids.forEach((kid, index) => this.spans.set(kid, children3[index]));
|
|
3053
|
+
this.root = root;
|
|
3054
|
+
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
3055
|
+
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
3056
|
+
else if (attribute2.namespaceURI === XMLNS3 || attribute2.name.startsWith("xmlns:"))
|
|
3057
|
+
this.prefixes.set(attribute2.value, attribute2.localName);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
xml;
|
|
3061
|
+
root;
|
|
3062
|
+
spans = /* @__PURE__ */ new Map();
|
|
3063
|
+
edits = [];
|
|
3064
|
+
appended = [];
|
|
3065
|
+
prefixes = /* @__PURE__ */ new Map();
|
|
3066
|
+
defaultNs = null;
|
|
3067
|
+
seq = 0;
|
|
3068
|
+
add(start, end, text) {
|
|
3069
|
+
this.edits.push({ start, end, text, seq: this.seq++ });
|
|
3070
|
+
}
|
|
3071
|
+
span(element4) {
|
|
3072
|
+
const span = this.spans.get(element4);
|
|
3073
|
+
if (!span) throw new Error("Element is not a child of the patched root");
|
|
3074
|
+
return span;
|
|
3075
|
+
}
|
|
3076
|
+
/** The prefix bound to `ns` on the root, declaring `preferred` for it when none is. */
|
|
3077
|
+
prefix(ns, preferred) {
|
|
3078
|
+
const known = this.prefixes.get(ns);
|
|
3079
|
+
if (known !== void 0) return known;
|
|
3080
|
+
const taken = new Set(this.prefixes.values());
|
|
3081
|
+
let prefix2 = preferred;
|
|
3082
|
+
for (let n = 1; taken.has(prefix2); n++) prefix2 = `${preferred}${n}`;
|
|
3083
|
+
this.prefixes.set(ns, prefix2);
|
|
3084
|
+
const at = this.root.openEnd - (this.root.selfClosing ? 2 : 1);
|
|
3085
|
+
this.add(at, at, ` xmlns:${prefix2}="${ns}"`);
|
|
3086
|
+
return prefix2;
|
|
3087
|
+
}
|
|
3088
|
+
/** `local` qualified for an element in `ns`: unprefixed in the default namespace. */
|
|
3089
|
+
qualify(ns, local, preferred) {
|
|
3090
|
+
return this.defaultNs === ns && !this.prefixes.has(ns) ? local : `${this.prefix(ns, preferred)}:${local}`;
|
|
3091
|
+
}
|
|
3092
|
+
/** Replaces the element's content, keeping its start tag (and attributes) as written. */
|
|
3093
|
+
setContent(element4, content) {
|
|
3094
|
+
const span = this.span(element4);
|
|
3095
|
+
if (span.selfClosing)
|
|
3096
|
+
this.add(span.openEnd - 2, span.openEnd, `>${content}</${qualifiedName(this.xml, span)}>`);
|
|
3097
|
+
else this.add(span.openEnd, span.closeStart, content);
|
|
3098
|
+
}
|
|
3099
|
+
/** Adds ` name="value"` text to the element's start tag. */
|
|
3100
|
+
addAttribute(element4, attribute2) {
|
|
3101
|
+
const span = this.span(element4);
|
|
3102
|
+
const at = span.openEnd - (span.selfClosing ? 2 : 1);
|
|
3103
|
+
this.add(at, at, attribute2);
|
|
3104
|
+
}
|
|
3105
|
+
remove(element4) {
|
|
3106
|
+
const span = this.span(element4);
|
|
3107
|
+
this.add(span.start, span.end, "");
|
|
3108
|
+
}
|
|
3109
|
+
/** Inserts `markup` before `before`, or as the root's last child. */
|
|
3110
|
+
insert(markup, before) {
|
|
3111
|
+
if (before) {
|
|
3112
|
+
const at = this.span(before).start;
|
|
3113
|
+
this.add(at, at, markup);
|
|
3114
|
+
} else this.appended.push(markup);
|
|
3115
|
+
}
|
|
3116
|
+
toString() {
|
|
3117
|
+
const edits = [...this.edits];
|
|
3118
|
+
if (this.appended.length) {
|
|
3119
|
+
const text = this.appended.join("");
|
|
3120
|
+
const root = this.root;
|
|
3121
|
+
if (root.selfClosing) {
|
|
3122
|
+
const name = qualifiedName(this.xml, root);
|
|
3123
|
+
edits.push({
|
|
3124
|
+
start: root.end - 2,
|
|
3125
|
+
end: root.end,
|
|
3126
|
+
text: `>${text}</${name}>`,
|
|
3127
|
+
seq: this.seq
|
|
3128
|
+
});
|
|
3129
|
+
} else edits.push({ start: root.closeStart, end: root.closeStart, text, seq: this.seq });
|
|
3130
|
+
}
|
|
3131
|
+
edits.sort((a2, b) => a2.start - b.start || a2.end - a2.start - (b.end - b.start) || a2.seq - b.seq);
|
|
3132
|
+
let out = "";
|
|
3133
|
+
let at = 0;
|
|
3134
|
+
for (const edit of edits) {
|
|
3135
|
+
out += this.xml.slice(at, edit.start) + edit.text;
|
|
3136
|
+
at = Math.max(at, edit.end);
|
|
3137
|
+
}
|
|
3138
|
+
return out + this.xml.slice(at);
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
|
|
3142
|
+
// opc/properties/core.ts
|
|
3143
|
+
var XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
3144
|
+
var FIELDS = [
|
|
3145
|
+
["title", "dc", false],
|
|
3146
|
+
["subject", "dc", false],
|
|
3147
|
+
["creator", "dc", false],
|
|
3148
|
+
["keywords", "cp", false],
|
|
3149
|
+
["description", "dc", false],
|
|
3150
|
+
["lastModifiedBy", "cp", false],
|
|
3151
|
+
["created", "dcterms", true],
|
|
3152
|
+
["modified", "dcterms", true],
|
|
3153
|
+
["category", "cp", false],
|
|
3154
|
+
["contentStatus", "cp", false],
|
|
3155
|
+
["revision", "cp", false],
|
|
3156
|
+
["language", "dc", false],
|
|
3157
|
+
["identifier", "dc", false],
|
|
3158
|
+
["lastPrinted", "cp", false],
|
|
3159
|
+
["version", "cp", false]
|
|
3160
|
+
];
|
|
3161
|
+
FIELDS.map(([field]) => field);
|
|
3162
|
+
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3163
|
+
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
3164
|
+
function parseCoreProperties(xml) {
|
|
3165
|
+
const out = {};
|
|
3166
|
+
if (!xml) return out;
|
|
3167
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3168
|
+
for (const [field, prefix2] of FIELDS) {
|
|
3169
|
+
const text = first(root, field, NS[prefix2])?.textContent ?? "";
|
|
3170
|
+
if (text !== "") out[field] = text;
|
|
3171
|
+
}
|
|
3172
|
+
return out;
|
|
3173
|
+
}
|
|
3174
|
+
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
3175
|
+
function writeCoreProperties(props, sourceXml) {
|
|
3176
|
+
const xml = sourceXml ?? EMPTY_CORE;
|
|
3177
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3178
|
+
const patch = new PartPatch(xml, root);
|
|
3179
|
+
for (const [field, prefix2, isDate] of FIELDS) {
|
|
3180
|
+
const ns = NS[prefix2];
|
|
3181
|
+
const value = props[field];
|
|
3182
|
+
const element4 = first(root, field, ns);
|
|
3183
|
+
if (value === void 0 || value === "") {
|
|
3184
|
+
if (element4 && (element4.textContent ?? "") !== "") patch.remove(element4);
|
|
3185
|
+
continue;
|
|
3186
|
+
}
|
|
3187
|
+
if (element4 && element4.textContent === value) continue;
|
|
3188
|
+
const typed = () => ` ${patch.prefix(XSI, "xsi")}:type="${patch.prefix(NS.dcterms, "dcterms")}:W3CDTF"`;
|
|
3189
|
+
if (element4) {
|
|
3190
|
+
if (isDate && !element4.getAttributeNS(XSI, "type")) patch.addAttribute(element4, typed());
|
|
3191
|
+
patch.setContent(element4, escapeText(value));
|
|
3192
|
+
continue;
|
|
3193
|
+
}
|
|
3194
|
+
const name = patch.qualify(ns, field, prefix2);
|
|
3195
|
+
patch.insert(`<${name}${isDate ? typed() : ""}>${escapeText(value)}</${name}>`);
|
|
3196
|
+
}
|
|
3197
|
+
return patch.toString();
|
|
3198
|
+
}
|
|
3199
|
+
|
|
2926
3200
|
// docx/zip-parts.ts
|
|
2927
3201
|
var DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels";
|
|
2928
3202
|
var ensureDocumentRelationship = (zip, type, target) => ensureRelationship(zip, DOCUMENT_RELS_PATH, type, target);
|
|
@@ -2950,7 +3224,7 @@ var PREFIX = {
|
|
|
2950
3224
|
};
|
|
2951
3225
|
var CORE_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
2952
3226
|
var CORE_REL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
2953
|
-
function
|
|
3227
|
+
function parseCoreProperties2(xml) {
|
|
2954
3228
|
const root = parseXml2(xml).documentElement;
|
|
2955
3229
|
const result = {};
|
|
2956
3230
|
for (const field of PROPERTY_FIELDS) {
|
|
@@ -3018,265 +3292,18 @@ function dropAddedFolders(zip, source2) {
|
|
|
3018
3292
|
if (entry2.dir && !source2.has(name)) delete zip.files[name];
|
|
3019
3293
|
}
|
|
3020
3294
|
|
|
3021
|
-
// docx/
|
|
3022
|
-
var
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
equation: "equation",
|
|
3033
|
-
citation: "citation",
|
|
3034
|
-
bibliography: "bibliography",
|
|
3035
|
-
docPartObj: "docPartObj",
|
|
3036
|
-
docPartList: "docPartList"
|
|
3037
|
-
};
|
|
3038
|
-
function attrW14(element4, local) {
|
|
3039
|
-
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
3295
|
+
// docx/save-modified.ts
|
|
3296
|
+
var CORE_PATH2 = "docProps/core.xml";
|
|
3297
|
+
async function stampModified(zip, option) {
|
|
3298
|
+
if (!option) return;
|
|
3299
|
+
const file = zip.file(CORE_PATH2);
|
|
3300
|
+
if (!file) return;
|
|
3301
|
+
const source2 = await file.async("string");
|
|
3302
|
+
const props = parseCoreProperties(source2);
|
|
3303
|
+
props.modified = formatW3cdtf(option.at ?? /* @__PURE__ */ new Date());
|
|
3304
|
+
if (option.author) props.lastModifiedBy = option.author;
|
|
3305
|
+
zip.file(CORE_PATH2, writeCoreProperties(props, source2));
|
|
3040
3306
|
}
|
|
3041
|
-
function glyph(element4) {
|
|
3042
|
-
const code = attrW14(element4, "val");
|
|
3043
|
-
if (!code) return void 0;
|
|
3044
|
-
const font = attrW14(element4, "font");
|
|
3045
|
-
return { code, ...font ? { font } : {} };
|
|
3046
|
-
}
|
|
3047
|
-
function kindOf(child7) {
|
|
3048
|
-
if (child7.namespaceURI === WORD_NS)
|
|
3049
|
-
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
3050
|
-
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
3051
|
-
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
3052
|
-
return "repeatingSection";
|
|
3053
|
-
return void 0;
|
|
3054
|
-
}
|
|
3055
|
-
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
3056
|
-
(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"
|
|
3057
|
-
);
|
|
3058
|
-
function parseKind(sdtPr) {
|
|
3059
|
-
const [type] = typeElements(sdtPr);
|
|
3060
|
-
return (type && kindOf(type)) ?? "richText";
|
|
3061
|
-
}
|
|
3062
|
-
var generated = 0;
|
|
3063
|
-
function parseContentControl(sdt, level3) {
|
|
3064
|
-
const sdtPr = first2(sdt, "sdtPr");
|
|
3065
|
-
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level3, kind: "richText" };
|
|
3066
|
-
const kind = parseKind(sdtPr);
|
|
3067
|
-
const control = {
|
|
3068
|
-
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
3069
|
-
level: level3,
|
|
3070
|
-
kind
|
|
3071
|
-
};
|
|
3072
|
-
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
3073
|
-
if (alias !== void 0) control.alias = alias;
|
|
3074
|
-
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
3075
|
-
if (tag !== void 0) control.tag = tag;
|
|
3076
|
-
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
3077
|
-
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
3078
|
-
control.lock = lock;
|
|
3079
|
-
const showing = first2(sdtPr, "showingPlcHdr");
|
|
3080
|
-
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
3081
|
-
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
3082
|
-
const temporary = first2(sdtPr, "temporary");
|
|
3083
|
-
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
3084
|
-
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
3085
|
-
if (placeholder) control.placeholder = placeholder;
|
|
3086
|
-
if (kind === "text") {
|
|
3087
|
-
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
3088
|
-
if (multi) control.multiLine = true;
|
|
3089
|
-
}
|
|
3090
|
-
if (kind === "checkbox") {
|
|
3091
|
-
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
3092
|
-
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
3093
|
-
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
3094
|
-
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
3095
|
-
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
3096
|
-
if (on) control.checkedGlyph = on;
|
|
3097
|
-
if (off) control.uncheckedGlyph = off;
|
|
3098
|
-
}
|
|
3099
|
-
if (kind === "dropDownList" || kind === "comboBox") {
|
|
3100
|
-
const list2 = first2(sdtPr, kind);
|
|
3101
|
-
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
3102
|
-
const display = getW(item2, "displayText");
|
|
3103
|
-
const value = getW(item2, "value") ?? display ?? "";
|
|
3104
|
-
return { display: display ?? value, value };
|
|
3105
|
-
});
|
|
3106
|
-
}
|
|
3107
|
-
if (kind === "date") {
|
|
3108
|
-
const date = first2(sdtPr, "date");
|
|
3109
|
-
const fullDate = getW(date, "fullDate");
|
|
3110
|
-
if (fullDate) control.fullDate = fullDate;
|
|
3111
|
-
const format = getW(first2(date, "dateFormat"), "val");
|
|
3112
|
-
if (format) control.dateFormat = format;
|
|
3113
|
-
const lid = getW(first2(date, "lid"), "val");
|
|
3114
|
-
if (lid) control.dateLocale = lid;
|
|
3115
|
-
}
|
|
3116
|
-
control.sourceXml = buildXml(sdtPr);
|
|
3117
|
-
const end = first2(sdt, "sdtEndPr");
|
|
3118
|
-
if (end) control.endSourceXml = buildXml(end);
|
|
3119
|
-
return control;
|
|
3120
|
-
}
|
|
3121
|
-
|
|
3122
|
-
// docx/expect-defined.ts
|
|
3123
|
-
function expectDefined(value, context) {
|
|
3124
|
-
if (value === void 0 || value === null) {
|
|
3125
|
-
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
3126
|
-
}
|
|
3127
|
-
return value;
|
|
3128
|
-
}
|
|
3129
|
-
|
|
3130
|
-
// docx/parse-revisions.ts
|
|
3131
|
-
var REVISION_WRAPPERS = {
|
|
3132
|
-
ins: "insert",
|
|
3133
|
-
del: "delete",
|
|
3134
|
-
moveFrom: "moveFrom",
|
|
3135
|
-
moveTo: "moveTo"
|
|
3136
|
-
};
|
|
3137
|
-
var MOVE_RANGES = {
|
|
3138
|
-
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
3139
|
-
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
3140
|
-
moveToRangeStart: { kind: "moveTo", start: true },
|
|
3141
|
-
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
3142
|
-
};
|
|
3143
|
-
function trackMoveRange(item2, moves) {
|
|
3144
|
-
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
3145
|
-
const range = MOVE_RANGES[item2.localName ?? ""];
|
|
3146
|
-
if (!range) return false;
|
|
3147
|
-
const id = getW(item2, "id") ?? "";
|
|
3148
|
-
const open = moves[range.kind];
|
|
3149
|
-
if (range.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
3150
|
-
else {
|
|
3151
|
-
const index = open.findIndex((entry2) => entry2.id === id);
|
|
3152
|
-
if (index >= 0) open.splice(index, 1);
|
|
3153
|
-
}
|
|
3154
|
-
return true;
|
|
3155
|
-
}
|
|
3156
|
-
function isCommentReferenceRun(run2) {
|
|
3157
|
-
const content = Array.from(run2.childNodes).filter(
|
|
3158
|
-
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
3159
|
-
);
|
|
3160
|
-
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
3161
|
-
}
|
|
3162
|
-
function revisionFrom(node, kind) {
|
|
3163
|
-
const revision = {
|
|
3164
|
-
kind,
|
|
3165
|
-
author: getW(node, "author") || "Unknown",
|
|
3166
|
-
id: getW(node, "id") ?? "0"
|
|
3167
|
-
};
|
|
3168
|
-
const date = getW(node, "date");
|
|
3169
|
-
if (date) revision.date = date;
|
|
3170
|
-
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
3171
|
-
if (dateUtc) revision.dateUtc = dateUtc;
|
|
3172
|
-
return revision;
|
|
3173
|
-
}
|
|
3174
|
-
function paragraphMarkRevision(pPr) {
|
|
3175
|
-
const rPr = first2(pPr, "rPr");
|
|
3176
|
-
const ins = first2(rPr, "ins");
|
|
3177
|
-
if (ins) return revisionFrom(ins, "insert");
|
|
3178
|
-
const del = first2(rPr, "del");
|
|
3179
|
-
if (del) return revisionFrom(del, "delete");
|
|
3180
|
-
return void 0;
|
|
3181
|
-
}
|
|
3182
|
-
function paragraphFormatRevision(pPr) {
|
|
3183
|
-
const change = first2(pPr, "pPrChange");
|
|
3184
|
-
if (!change) return void 0;
|
|
3185
|
-
const revision = revisionFrom(change, "paragraphChange");
|
|
3186
|
-
const previous = first2(change, "pPr");
|
|
3187
|
-
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
3188
|
-
return revision;
|
|
3189
|
-
}
|
|
3190
|
-
function runFormatRevision(rPr) {
|
|
3191
|
-
const change = first2(rPr, "rPrChange");
|
|
3192
|
-
if (!change) return void 0;
|
|
3193
|
-
const revision = revisionFrom(change, "formatChange");
|
|
3194
|
-
const previous = first2(change, "rPr");
|
|
3195
|
-
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
3196
|
-
return revision;
|
|
3197
|
-
}
|
|
3198
|
-
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
3199
|
-
const runs = [];
|
|
3200
|
-
let hasMove = false;
|
|
3201
|
-
const push = (run2) => {
|
|
3202
|
-
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
3203
|
-
runs.push(run2);
|
|
3204
|
-
};
|
|
3205
|
-
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
3206
|
-
if (named2(item2, "r")) {
|
|
3207
|
-
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
3208
|
-
} else if (named2(item2, "hyperlink")) {
|
|
3209
|
-
const link = resolveLink?.(item2);
|
|
3210
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
3211
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
3212
|
-
if (link) parsed.link = link;
|
|
3213
|
-
push(parsed);
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
3217
|
-
const kind = expectDefined(
|
|
3218
|
-
REVISION_WRAPPERS[item2.localName],
|
|
3219
|
-
`revision wrapper ${item2.localName}`
|
|
3220
|
-
);
|
|
3221
|
-
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
3222
|
-
const revision = revisionFrom(item2, kind);
|
|
3223
|
-
const range = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
3224
|
-
if (range) revision.move = { name: range.name, rangeId: range.id };
|
|
3225
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
3226
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
3227
|
-
parsed.revision = revision;
|
|
3228
|
-
push(parsed);
|
|
3229
|
-
}
|
|
3230
|
-
}
|
|
3231
|
-
} else if (trackMoveRange(item2, moves)) {
|
|
3232
|
-
continue;
|
|
3233
|
-
} else if (named2(item2, "commentRangeStart")) {
|
|
3234
|
-
const id = getW(item2, "id");
|
|
3235
|
-
if (id !== void 0) active.push(id);
|
|
3236
|
-
} else if (named2(item2, "commentRangeEnd")) {
|
|
3237
|
-
const id = getW(item2, "id");
|
|
3238
|
-
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
3239
|
-
if (index >= 0) active.splice(index, 1);
|
|
3240
|
-
} else {
|
|
3241
|
-
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
|
-
return { runs, hasMove };
|
|
3245
|
-
}
|
|
3246
|
-
|
|
3247
|
-
// docx/parse-content-control.ts
|
|
3248
|
-
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
3249
|
-
const control = parseContentControl(sdt, "inline");
|
|
3250
|
-
const content = sdtContent(sdt);
|
|
3251
|
-
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
3252
|
-
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
3253
|
-
for (const run2 of runs) run2.contentControl ??= control;
|
|
3254
|
-
return runs;
|
|
3255
|
-
}
|
|
3256
|
-
function flatChildren(parent, names, level3 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
3257
|
-
const found = [];
|
|
3258
|
-
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
3259
|
-
if (isSdt(child7)) {
|
|
3260
|
-
const content = sdtContent(child7);
|
|
3261
|
-
if (!content) continue;
|
|
3262
|
-
let control = controls.get(child7);
|
|
3263
|
-
if (!control) {
|
|
3264
|
-
control = parseContentControl(child7, level3);
|
|
3265
|
-
controls.set(child7, control);
|
|
3266
|
-
}
|
|
3267
|
-
found.push(...flatChildren(content, names, level3, { control, sdt: child7 }, controls));
|
|
3268
|
-
} else if (names.some((name) => named2(child7, name)))
|
|
3269
|
-
found.push({
|
|
3270
|
-
element: child7,
|
|
3271
|
-
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
3272
|
-
});
|
|
3273
|
-
}
|
|
3274
|
-
return found;
|
|
3275
|
-
}
|
|
3276
|
-
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
3277
|
-
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
3278
|
-
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
3279
|
-
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
3280
3307
|
|
|
3281
3308
|
// docx/element-order.ts
|
|
3282
3309
|
var RPR_ORDER = [
|
|
@@ -3365,6 +3392,720 @@ function orderSectionProperties(sectPr) {
|
|
|
3365
3392
|
orderChildren(sectPr, SECTPR_ORDER);
|
|
3366
3393
|
}
|
|
3367
3394
|
|
|
3395
|
+
// docx/tab-stops.ts
|
|
3396
|
+
function parseTabStops(tabs) {
|
|
3397
|
+
const stops = [];
|
|
3398
|
+
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
3399
|
+
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
3400
|
+
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
3401
|
+
if (!align || pos === void 0) continue;
|
|
3402
|
+
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
3403
|
+
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
3404
|
+
}
|
|
3405
|
+
return stops;
|
|
3406
|
+
}
|
|
3407
|
+
function writeTabStops(doc, props, paragraph2, base) {
|
|
3408
|
+
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
3409
|
+
return;
|
|
3410
|
+
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
3411
|
+
if (!paragraph2.tabStops?.length) return;
|
|
3412
|
+
const tabs = makeW(doc, "tabs");
|
|
3413
|
+
for (const stop of paragraph2.tabStops) {
|
|
3414
|
+
const tab = makeW(doc, "tab");
|
|
3415
|
+
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
3416
|
+
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
3417
|
+
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
3418
|
+
tabs.appendChild(tab);
|
|
3419
|
+
}
|
|
3420
|
+
props.appendChild(tabs);
|
|
3421
|
+
}
|
|
3422
|
+
var PPR_ORDER = [
|
|
3423
|
+
"pStyle",
|
|
3424
|
+
"keepNext",
|
|
3425
|
+
"keepLines",
|
|
3426
|
+
"pageBreakBefore",
|
|
3427
|
+
"framePr",
|
|
3428
|
+
"widowControl",
|
|
3429
|
+
"numPr",
|
|
3430
|
+
"suppressLineNumbers",
|
|
3431
|
+
"pBdr",
|
|
3432
|
+
"shd",
|
|
3433
|
+
"tabs",
|
|
3434
|
+
"suppressAutoHyphens",
|
|
3435
|
+
"kinsoku",
|
|
3436
|
+
"wordWrap",
|
|
3437
|
+
"overflowPunct",
|
|
3438
|
+
"topLinePunct",
|
|
3439
|
+
"autoSpaceDE",
|
|
3440
|
+
"autoSpaceDN",
|
|
3441
|
+
"bidi",
|
|
3442
|
+
"adjustRightInd",
|
|
3443
|
+
"snapToGrid",
|
|
3444
|
+
"spacing",
|
|
3445
|
+
"ind",
|
|
3446
|
+
"contextualSpacing",
|
|
3447
|
+
"mirrorIndents",
|
|
3448
|
+
"suppressOverlap",
|
|
3449
|
+
"jc",
|
|
3450
|
+
"textDirection",
|
|
3451
|
+
"textAlignment",
|
|
3452
|
+
"textboxTightWrap",
|
|
3453
|
+
"outlineLvl",
|
|
3454
|
+
"divId",
|
|
3455
|
+
"cnfStyle",
|
|
3456
|
+
"rPr",
|
|
3457
|
+
"sectPr",
|
|
3458
|
+
"pPrChange"
|
|
3459
|
+
];
|
|
3460
|
+
function orderParagraphProperties(props) {
|
|
3461
|
+
orderChildren(props, PPR_ORDER);
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
// docx/write-paragraph-decoration.ts
|
|
3465
|
+
var SIDES3 = ["top", "left", "bottom", "right", "between"];
|
|
3466
|
+
function wordColor(color) {
|
|
3467
|
+
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
3468
|
+
return hex ? hex.toUpperCase() : "auto";
|
|
3469
|
+
}
|
|
3470
|
+
function borderElement(doc, name, side) {
|
|
3471
|
+
const element4 = makeW(doc, name);
|
|
3472
|
+
const set2 = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
3473
|
+
set2("val", side.style ?? "single");
|
|
3474
|
+
if (side.style !== "none" && side.style !== "nil") {
|
|
3475
|
+
set2("sz", String(side.sizeEighthPoints ?? 4));
|
|
3476
|
+
set2("space", String(side.spacePoints ?? 1));
|
|
3477
|
+
set2("color", wordColor(side.color));
|
|
3478
|
+
if (side.themeColor) set2("themeColor", side.themeColor);
|
|
3479
|
+
}
|
|
3480
|
+
return element4;
|
|
3481
|
+
}
|
|
3482
|
+
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
3483
|
+
function updateShading(doc, props, paragraph2, base) {
|
|
3484
|
+
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
3485
|
+
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
3486
|
+
if (!paragraph2.shadingFill) return;
|
|
3487
|
+
const shd = makeW(doc, "shd");
|
|
3488
|
+
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
3489
|
+
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
3490
|
+
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
3491
|
+
props.appendChild(shd);
|
|
3492
|
+
}
|
|
3493
|
+
function updateBorders(doc, props, paragraph2, base) {
|
|
3494
|
+
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
3495
|
+
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
3496
|
+
const borders = paragraph2.borders;
|
|
3497
|
+
if (!borders) return;
|
|
3498
|
+
const pBdr = makeW(doc, "pBdr");
|
|
3499
|
+
for (const side of SIDES3) {
|
|
3500
|
+
const value = borders[side];
|
|
3501
|
+
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
3502
|
+
}
|
|
3503
|
+
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
3504
|
+
}
|
|
3505
|
+
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
3506
|
+
updateShading(doc, props, paragraph2, base);
|
|
3507
|
+
updateBorders(doc, props, paragraph2, base);
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
// docx/write-paragraph-properties.ts
|
|
3511
|
+
function setAttribute(element4, local, value) {
|
|
3512
|
+
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
3513
|
+
}
|
|
3514
|
+
function setWordValue(element4, local, value) {
|
|
3515
|
+
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
3516
|
+
else setAttribute(element4, local, String(value));
|
|
3517
|
+
}
|
|
3518
|
+
function updateDirection(doc, props, paragraph2, base) {
|
|
3519
|
+
if (base && paragraph2.direction === base.direction) return;
|
|
3520
|
+
let bidi = first2(props, "bidi");
|
|
3521
|
+
if (paragraph2.direction === void 0) {
|
|
3522
|
+
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
3523
|
+
} else {
|
|
3524
|
+
if (!bidi) {
|
|
3525
|
+
bidi = makeW(doc, "bidi");
|
|
3526
|
+
props.appendChild(bidi);
|
|
3527
|
+
}
|
|
3528
|
+
setAttribute(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
function updateSpacing(doc, props, paragraph2, base) {
|
|
3532
|
+
let spacing2 = first2(props, "spacing");
|
|
3533
|
+
if (!spacing2) {
|
|
3534
|
+
spacing2 = makeW(doc, "spacing");
|
|
3535
|
+
props.appendChild(spacing2);
|
|
3536
|
+
}
|
|
3537
|
+
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
3538
|
+
setWordValue(spacing2, "before", paragraph2.spacingBeforeTwips);
|
|
3539
|
+
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
3540
|
+
setWordValue(spacing2, "after", paragraph2.spacingAfterTwips);
|
|
3541
|
+
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
3542
|
+
setWordValue(spacing2, "line", paragraph2.lineSpacingTwips);
|
|
3543
|
+
setWordValue(
|
|
3544
|
+
spacing2,
|
|
3545
|
+
"lineRule",
|
|
3546
|
+
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
3547
|
+
);
|
|
3548
|
+
}
|
|
3549
|
+
if (!spacing2.attributes.length && !spacing2.childNodes.length) props.removeChild(spacing2);
|
|
3550
|
+
}
|
|
3551
|
+
function updateIndent(doc, props, paragraph2, base) {
|
|
3552
|
+
let indent = first2(props, "ind");
|
|
3553
|
+
if (!indent) {
|
|
3554
|
+
indent = makeW(doc, "ind");
|
|
3555
|
+
props.appendChild(indent);
|
|
3556
|
+
}
|
|
3557
|
+
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
3558
|
+
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
3559
|
+
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
3560
|
+
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
3561
|
+
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
3562
|
+
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
3563
|
+
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
3564
|
+
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
3565
|
+
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
3566
|
+
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
3567
|
+
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
3568
|
+
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
3569
|
+
if (!indent.attributes.length) props.removeChild(indent);
|
|
3570
|
+
}
|
|
3571
|
+
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
3572
|
+
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
3573
|
+
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
3574
|
+
if (paragraph2.pageBreakBefore !== void 0) {
|
|
3575
|
+
const element4 = makeW(doc, "pageBreakBefore");
|
|
3576
|
+
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
3577
|
+
props.appendChild(element4);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
3581
|
+
for (const key of [
|
|
3582
|
+
"keepNext",
|
|
3583
|
+
"keepLines",
|
|
3584
|
+
"widowControl",
|
|
3585
|
+
"contextualSpacing",
|
|
3586
|
+
"suppressLineNumbers"
|
|
3587
|
+
]) {
|
|
3588
|
+
if (base && paragraph2[key] === base[key]) continue;
|
|
3589
|
+
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
3590
|
+
const value = paragraph2[key];
|
|
3591
|
+
if (value === void 0) continue;
|
|
3592
|
+
const element4 = makeW(doc, key);
|
|
3593
|
+
if (!value) setAttribute(element4, "val", "0");
|
|
3594
|
+
props.appendChild(element4);
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
function updateDropCap(doc, props, paragraph2, base) {
|
|
3598
|
+
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
3599
|
+
let frame2 = first2(props, "framePr");
|
|
3600
|
+
const cap = paragraph2.dropCap;
|
|
3601
|
+
if (!cap) {
|
|
3602
|
+
if (frame2) props.removeChild(frame2);
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
if (!frame2) {
|
|
3606
|
+
frame2 = makeW(doc, "framePr");
|
|
3607
|
+
props.appendChild(frame2);
|
|
3608
|
+
setAttribute(frame2, "wrap", "around");
|
|
3609
|
+
setAttribute(frame2, "vAnchor", "text");
|
|
3610
|
+
setAttribute(frame2, "hAnchor", "text");
|
|
3611
|
+
}
|
|
3612
|
+
setAttribute(frame2, "dropCap", cap.style);
|
|
3613
|
+
setAttribute(frame2, "lines", String(cap.lines));
|
|
3614
|
+
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
3615
|
+
}
|
|
3616
|
+
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
3617
|
+
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
3618
|
+
updateKeepOptions(doc, props, paragraph2, base);
|
|
3619
|
+
updateDropCap(doc, props, paragraph2, base);
|
|
3620
|
+
updateDirection(doc, props, paragraph2, base);
|
|
3621
|
+
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
3622
|
+
const spacingKeys = [
|
|
3623
|
+
"spacingBeforeTwips",
|
|
3624
|
+
"spacingAfterTwips",
|
|
3625
|
+
"lineSpacingTwips",
|
|
3626
|
+
"lineSpacingRule"
|
|
3627
|
+
];
|
|
3628
|
+
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
3629
|
+
updateSpacing(doc, props, paragraph2, base);
|
|
3630
|
+
const indentKeys = [
|
|
3631
|
+
"indentLeftTwips",
|
|
3632
|
+
"indentRightTwips",
|
|
3633
|
+
"indentStartTwips",
|
|
3634
|
+
"indentEndTwips",
|
|
3635
|
+
"firstLineTwips",
|
|
3636
|
+
"hangingTwips"
|
|
3637
|
+
];
|
|
3638
|
+
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
3639
|
+
updateIndent(doc, props, paragraph2, base);
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3642
|
+
// docx/style-formatting-package.ts
|
|
3643
|
+
var STYLES_PART = "word/styles.xml";
|
|
3644
|
+
var AFTER_PPR = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
3645
|
+
var WRITABLE_STYLE_FORMATTING = [
|
|
3646
|
+
"align",
|
|
3647
|
+
"justification",
|
|
3648
|
+
"direction",
|
|
3649
|
+
"spacingBeforeTwips",
|
|
3650
|
+
"spacingAfterTwips",
|
|
3651
|
+
"lineSpacingTwips",
|
|
3652
|
+
"lineSpacingRule",
|
|
3653
|
+
"indentLeftTwips",
|
|
3654
|
+
"indentRightTwips",
|
|
3655
|
+
"indentStartTwips",
|
|
3656
|
+
"indentEndTwips",
|
|
3657
|
+
"firstLineTwips",
|
|
3658
|
+
"hangingTwips",
|
|
3659
|
+
"pageBreakBefore",
|
|
3660
|
+
"keepNext",
|
|
3661
|
+
"keepLines",
|
|
3662
|
+
"widowControl",
|
|
3663
|
+
"contextualSpacing",
|
|
3664
|
+
"suppressLineNumbers",
|
|
3665
|
+
"borders",
|
|
3666
|
+
"shadingFill"
|
|
3667
|
+
];
|
|
3668
|
+
function unwritableFormatting(formatting) {
|
|
3669
|
+
const rest = { ...formatting };
|
|
3670
|
+
for (const key of WRITABLE_STYLE_FORMATTING) delete rest[key];
|
|
3671
|
+
return rest;
|
|
3672
|
+
}
|
|
3673
|
+
var asParagraph = (formatting) => ({
|
|
3674
|
+
type: "paragraph",
|
|
3675
|
+
id: "style",
|
|
3676
|
+
runs: [],
|
|
3677
|
+
...formatting
|
|
3678
|
+
});
|
|
3679
|
+
function pPrOf(style) {
|
|
3680
|
+
let pPr = first2(style, "pPr");
|
|
3681
|
+
if (pPr) return pPr;
|
|
3682
|
+
pPr = makeW(style.ownerDocument, "pPr");
|
|
3683
|
+
const anchor = Array.from(style.childNodes).find(
|
|
3684
|
+
(node) => node.nodeType === 1 && AFTER_PPR.includes(node.localName)
|
|
3685
|
+
) ?? null;
|
|
3686
|
+
style.insertBefore(pPr, anchor);
|
|
3687
|
+
return pPr;
|
|
3688
|
+
}
|
|
3689
|
+
async function applyStyleFormatting(zip, model, base) {
|
|
3690
|
+
const next = model.paragraphStyles?.styles ?? {};
|
|
3691
|
+
const prior = base.paragraphStyles?.styles ?? {};
|
|
3692
|
+
const changed = Object.keys(next).filter(
|
|
3693
|
+
(id) => JSON.stringify(next[id]?.formatting) !== JSON.stringify(prior[id]?.formatting)
|
|
3694
|
+
);
|
|
3695
|
+
if (!changed.length) return;
|
|
3696
|
+
const file = zip.file(STYLES_PART);
|
|
3697
|
+
if (!file) throw new Error("Cannot edit a style: the package has no styles.xml.");
|
|
3698
|
+
const doc = parseXml2(await file.async("string"));
|
|
3699
|
+
const styles = children2(doc.documentElement, "style");
|
|
3700
|
+
for (const id of changed) {
|
|
3701
|
+
const style = styles.find(
|
|
3702
|
+
(element4) => getW(element4, "type") === "paragraph" && getW(element4, "styleId") === id
|
|
3703
|
+
);
|
|
3704
|
+
if (!style) throw new Error(`Cannot edit style "${id}": it is not in styles.xml.`);
|
|
3705
|
+
const after = asParagraph(next[id].formatting);
|
|
3706
|
+
const before = asParagraph(prior[id]?.formatting ?? {});
|
|
3707
|
+
const pPr = pPrOf(style);
|
|
3708
|
+
if (after.align !== before.align || after.justification !== before.justification || after.direction !== before.direction) {
|
|
3709
|
+
for (const jc of children2(pPr, "jc")) pPr.removeChild(jc);
|
|
3710
|
+
const value = paragraphJustification(after);
|
|
3711
|
+
if (value) {
|
|
3712
|
+
const jc = makeW(doc, "jc");
|
|
3713
|
+
jc.setAttributeNS(WORD_NS, "w:val", value);
|
|
3714
|
+
pPr.appendChild(jc);
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
writeParagraphProperties(doc, pPr, after, before);
|
|
3718
|
+
orderParagraphProperties(pPr);
|
|
3719
|
+
}
|
|
3720
|
+
zip.file(STYLES_PART, buildXml(doc));
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
// docx/data-binding.ts
|
|
3724
|
+
function parsePrefixes(text) {
|
|
3725
|
+
const map = /* @__PURE__ */ new Map();
|
|
3726
|
+
for (const match of (text ?? "").matchAll(/xmlns:([\w.-]+)\s*=\s*(?:'([^']*)'|"([^"]*)")/g))
|
|
3727
|
+
map.set(match[1], match[2] ?? match[3] ?? "");
|
|
3728
|
+
return map;
|
|
3729
|
+
}
|
|
3730
|
+
function sourceBindings(sourceXml) {
|
|
3731
|
+
const result = /* @__PURE__ */ new Map();
|
|
3732
|
+
const document = parseXml2(sourceXml);
|
|
3733
|
+
for (const sdt of Array.from(document.getElementsByTagNameNS(WORD_NS, "sdt"))) {
|
|
3734
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
3735
|
+
const element4 = sdtPr && elements(sdtPr).find((node) => node.localName === "dataBinding");
|
|
3736
|
+
const id = getW(first2(sdtPr, "id"), "val");
|
|
3737
|
+
const xpath = element4?.getAttributeNS(WORD_NS, "xpath");
|
|
3738
|
+
const storeItemId = element4?.getAttributeNS(WORD_NS, "storeItemID");
|
|
3739
|
+
if (id && element4 && xpath && storeItemId)
|
|
3740
|
+
result.set(id, {
|
|
3741
|
+
xpath,
|
|
3742
|
+
storeItemId,
|
|
3743
|
+
prefixes: parsePrefixes(element4.getAttributeNS(WORD_NS, "prefixMappings") ?? void 0)
|
|
3744
|
+
});
|
|
3745
|
+
}
|
|
3746
|
+
return result;
|
|
3747
|
+
}
|
|
3748
|
+
function paragraphsOf(blocks) {
|
|
3749
|
+
return blocks.flatMap(
|
|
3750
|
+
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((c2) => c2.paragraphs))
|
|
3751
|
+
);
|
|
3752
|
+
}
|
|
3753
|
+
function boundTexts(model) {
|
|
3754
|
+
const parts = /* @__PURE__ */ new Map();
|
|
3755
|
+
const add4 = (id, text) => parts.set(id, [...parts.get(id) ?? [], text]);
|
|
3756
|
+
for (const paragraph2 of paragraphsOf(model.blocks)) {
|
|
3757
|
+
const own2 = paragraph2.contentControl;
|
|
3758
|
+
if (own2?.dataBound) {
|
|
3759
|
+
add4(own2.id, paragraph2.runs.map((run2) => run2.text).join(""));
|
|
3760
|
+
continue;
|
|
3761
|
+
}
|
|
3762
|
+
const inline = /* @__PURE__ */ new Map();
|
|
3763
|
+
for (const run2 of paragraph2.runs) {
|
|
3764
|
+
const control = run2.contentControl;
|
|
3765
|
+
if (!control?.dataBound) continue;
|
|
3766
|
+
if (!inline.has(control.id)) inline.set(control.id, "");
|
|
3767
|
+
if (!control.showingPlaceholder) inline.set(control.id, inline.get(control.id) + run2.text);
|
|
3768
|
+
}
|
|
3769
|
+
for (const [id, text] of inline) add4(id, text);
|
|
3770
|
+
}
|
|
3771
|
+
return new Map([...parts].map(([id, texts]) => [id, texts.join("\n")]));
|
|
3772
|
+
}
|
|
3773
|
+
function parseXPath(binding) {
|
|
3774
|
+
const parts = binding.xpath.split("/");
|
|
3775
|
+
if (parts.shift() !== "" || !parts.length) return void 0;
|
|
3776
|
+
if (parts.at(-1) === "text()") parts.pop();
|
|
3777
|
+
const parse = (raw2, attribute3) => {
|
|
3778
|
+
const match = /^(?:([A-Za-z_][\w.-]*):)?([A-Za-z_][\w.-]*)(?:\[(\d+)\])?$/.exec(raw2);
|
|
3779
|
+
if (!match || attribute3 && match[3]) return void 0;
|
|
3780
|
+
const [, prefix2 = "", name = "", index] = match;
|
|
3781
|
+
if (prefix2 && !binding.prefixes.has(prefix2)) return void 0;
|
|
3782
|
+
return { prefix: prefix2, name, index: index ? Number(index) : 1 };
|
|
3783
|
+
};
|
|
3784
|
+
const last = parts.at(-1);
|
|
3785
|
+
const attribute2 = last?.startsWith("@") ? parse(last.slice(1), true) : void 0;
|
|
3786
|
+
if (last?.startsWith("@")) {
|
|
3787
|
+
parts.pop();
|
|
3788
|
+
if (!attribute2) return void 0;
|
|
3789
|
+
}
|
|
3790
|
+
const steps = parts.map((part) => parse(part, false));
|
|
3791
|
+
if (!steps.length || steps.some((step) => !step)) return void 0;
|
|
3792
|
+
return { steps, ...attribute2 ? { attribute: attribute2 } : {} };
|
|
3793
|
+
}
|
|
3794
|
+
var matches = (element4, step, binding) => element4.localName === step.name && (element4.namespaceURI ?? "") === (step.prefix ? binding.prefixes.get(step.prefix) ?? "" : "");
|
|
3795
|
+
function writeValue(root, binding, value) {
|
|
3796
|
+
const path3 = parseXPath(binding);
|
|
3797
|
+
if (!path3) return "unsupported";
|
|
3798
|
+
let node = root;
|
|
3799
|
+
for (const [depth, step] of path3.steps.entries()) {
|
|
3800
|
+
const candidates = depth === 0 ? [root].filter((e) => matches(e, step, binding)) : elements(node).filter((e) => matches(e, step, binding));
|
|
3801
|
+
node = candidates[step.index - 1];
|
|
3802
|
+
if (!node) return false;
|
|
3803
|
+
}
|
|
3804
|
+
if (path3.attribute) {
|
|
3805
|
+
const { prefix: prefix2, name } = path3.attribute;
|
|
3806
|
+
const ns = prefix2 ? binding.prefixes.get(prefix2) : void 0;
|
|
3807
|
+
if (ns) node.setAttributeNS(ns, `${prefix2}:${name}`, value);
|
|
3808
|
+
else node.setAttribute(name, value);
|
|
3809
|
+
return true;
|
|
3810
|
+
}
|
|
3811
|
+
for (const child7 of Array.from(node.childNodes)) node.removeChild(child7);
|
|
3812
|
+
if (value) node.appendChild(node.ownerDocument.createTextNode(value));
|
|
3813
|
+
return true;
|
|
3814
|
+
}
|
|
3815
|
+
async function findItemPart(zip, storeItemId) {
|
|
3816
|
+
const wanted = storeItemId.toLowerCase();
|
|
3817
|
+
for (const name of Object.keys(zip.files)) {
|
|
3818
|
+
const props = /^customXml\/itemProps(\d+)\.xml$/.exec(name);
|
|
3819
|
+
if (!props) continue;
|
|
3820
|
+
const root = parseXml2(await zip.file(name).async("string")).documentElement;
|
|
3821
|
+
const id = Array.from(root.attributes).find((attribute2) => attribute2.localName === "itemID");
|
|
3822
|
+
if ((id?.value ?? "").toLowerCase() === wanted) return `customXml/item${props[1]}.xml`;
|
|
3823
|
+
}
|
|
3824
|
+
return void 0;
|
|
3825
|
+
}
|
|
3826
|
+
async function applyDataBindings(zip, model, base, sourceXml) {
|
|
3827
|
+
const now = boundTexts(model);
|
|
3828
|
+
if (!now.size) return;
|
|
3829
|
+
const before = boundTexts(base);
|
|
3830
|
+
const bindings = sourceBindings(sourceXml);
|
|
3831
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
3832
|
+
for (const [id, text] of now) {
|
|
3833
|
+
const binding = bindings.get(id);
|
|
3834
|
+
if (!binding || before.get(id) === text) continue;
|
|
3835
|
+
const part = await findItemPart(zip, binding.storeItemId);
|
|
3836
|
+
const file = part ? zip.file(part) : void 0;
|
|
3837
|
+
if (!part || !file) continue;
|
|
3838
|
+
const document = parsed.get(part) ?? parseXml2(await file.async("string"));
|
|
3839
|
+
parsed.set(part, document);
|
|
3840
|
+
const written = writeValue(document.documentElement, binding, text);
|
|
3841
|
+
if (written !== true)
|
|
3842
|
+
throw new Error(
|
|
3843
|
+
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.`
|
|
3844
|
+
);
|
|
3845
|
+
}
|
|
3846
|
+
for (const [part, document] of parsed) zip.file(part, buildXml(document));
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
// docx/content-control.ts
|
|
3850
|
+
var WORD_2012_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
3851
|
+
var sdtContent = (sdt) => first2(sdt, "sdtContent");
|
|
3852
|
+
var isSdt = (element4) => named2(element4, "sdt");
|
|
3853
|
+
var TYPE_ELEMENTS = {
|
|
3854
|
+
text: "text",
|
|
3855
|
+
dropDownList: "dropDownList",
|
|
3856
|
+
comboBox: "comboBox",
|
|
3857
|
+
date: "date",
|
|
3858
|
+
picture: "picture",
|
|
3859
|
+
group: "group",
|
|
3860
|
+
equation: "equation",
|
|
3861
|
+
citation: "citation",
|
|
3862
|
+
bibliography: "bibliography",
|
|
3863
|
+
docPartObj: "docPartObj",
|
|
3864
|
+
docPartList: "docPartList"
|
|
3865
|
+
};
|
|
3866
|
+
function attrW14(element4, local) {
|
|
3867
|
+
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
3868
|
+
}
|
|
3869
|
+
function glyph(element4) {
|
|
3870
|
+
const code = attrW14(element4, "val");
|
|
3871
|
+
if (!code) return void 0;
|
|
3872
|
+
const font = attrW14(element4, "font");
|
|
3873
|
+
return { code, ...font ? { font } : {} };
|
|
3874
|
+
}
|
|
3875
|
+
function kindOf(child7) {
|
|
3876
|
+
if (child7.namespaceURI === WORD_NS)
|
|
3877
|
+
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
3878
|
+
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
3879
|
+
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
3880
|
+
return "repeatingSection";
|
|
3881
|
+
return void 0;
|
|
3882
|
+
}
|
|
3883
|
+
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
3884
|
+
(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"
|
|
3885
|
+
);
|
|
3886
|
+
function parseKind(sdtPr) {
|
|
3887
|
+
const [type] = typeElements(sdtPr);
|
|
3888
|
+
return (type && kindOf(type)) ?? "richText";
|
|
3889
|
+
}
|
|
3890
|
+
var generated = 0;
|
|
3891
|
+
function parseContentControl(sdt, level3) {
|
|
3892
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
3893
|
+
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level3, kind: "richText" };
|
|
3894
|
+
const kind = parseKind(sdtPr);
|
|
3895
|
+
const control = {
|
|
3896
|
+
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
3897
|
+
level: level3,
|
|
3898
|
+
kind
|
|
3899
|
+
};
|
|
3900
|
+
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
3901
|
+
if (alias !== void 0) control.alias = alias;
|
|
3902
|
+
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
3903
|
+
if (tag !== void 0) control.tag = tag;
|
|
3904
|
+
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
3905
|
+
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
3906
|
+
control.lock = lock;
|
|
3907
|
+
const showing = first2(sdtPr, "showingPlcHdr");
|
|
3908
|
+
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
3909
|
+
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
3910
|
+
const temporary = first2(sdtPr, "temporary");
|
|
3911
|
+
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
3912
|
+
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
3913
|
+
if (placeholder) control.placeholder = placeholder;
|
|
3914
|
+
if (kind === "text") {
|
|
3915
|
+
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
3916
|
+
if (multi) control.multiLine = true;
|
|
3917
|
+
}
|
|
3918
|
+
if (kind === "checkbox") {
|
|
3919
|
+
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
3920
|
+
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
3921
|
+
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
3922
|
+
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
3923
|
+
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
3924
|
+
if (on) control.checkedGlyph = on;
|
|
3925
|
+
if (off) control.uncheckedGlyph = off;
|
|
3926
|
+
}
|
|
3927
|
+
if (kind === "dropDownList" || kind === "comboBox") {
|
|
3928
|
+
const list2 = first2(sdtPr, kind);
|
|
3929
|
+
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
3930
|
+
const display = getW(item2, "displayText");
|
|
3931
|
+
const value = getW(item2, "value") ?? display ?? "";
|
|
3932
|
+
return { display: display ?? value, value };
|
|
3933
|
+
});
|
|
3934
|
+
}
|
|
3935
|
+
if (kind === "date") {
|
|
3936
|
+
const date = first2(sdtPr, "date");
|
|
3937
|
+
const fullDate = getW(date, "fullDate");
|
|
3938
|
+
if (fullDate) control.fullDate = fullDate;
|
|
3939
|
+
const format = getW(first2(date, "dateFormat"), "val");
|
|
3940
|
+
if (format) control.dateFormat = format;
|
|
3941
|
+
const lid = getW(first2(date, "lid"), "val");
|
|
3942
|
+
if (lid) control.dateLocale = lid;
|
|
3943
|
+
}
|
|
3944
|
+
control.sourceXml = buildXml(sdtPr);
|
|
3945
|
+
const end = first2(sdt, "sdtEndPr");
|
|
3946
|
+
if (end) control.endSourceXml = buildXml(end);
|
|
3947
|
+
return control;
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
// docx/expect-defined.ts
|
|
3951
|
+
function expectDefined(value, context) {
|
|
3952
|
+
if (value === void 0 || value === null) {
|
|
3953
|
+
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
3954
|
+
}
|
|
3955
|
+
return value;
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
// docx/parse-revisions.ts
|
|
3959
|
+
var REVISION_WRAPPERS = {
|
|
3960
|
+
ins: "insert",
|
|
3961
|
+
del: "delete",
|
|
3962
|
+
moveFrom: "moveFrom",
|
|
3963
|
+
moveTo: "moveTo"
|
|
3964
|
+
};
|
|
3965
|
+
var MOVE_RANGES = {
|
|
3966
|
+
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
3967
|
+
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
3968
|
+
moveToRangeStart: { kind: "moveTo", start: true },
|
|
3969
|
+
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
3970
|
+
};
|
|
3971
|
+
function trackMoveRange(item2, moves) {
|
|
3972
|
+
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
3973
|
+
const range = MOVE_RANGES[item2.localName ?? ""];
|
|
3974
|
+
if (!range) return false;
|
|
3975
|
+
const id = getW(item2, "id") ?? "";
|
|
3976
|
+
const open = moves[range.kind];
|
|
3977
|
+
if (range.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
3978
|
+
else {
|
|
3979
|
+
const index = open.findIndex((entry2) => entry2.id === id);
|
|
3980
|
+
if (index >= 0) open.splice(index, 1);
|
|
3981
|
+
}
|
|
3982
|
+
return true;
|
|
3983
|
+
}
|
|
3984
|
+
function isCommentReferenceRun(run2) {
|
|
3985
|
+
const content = Array.from(run2.childNodes).filter(
|
|
3986
|
+
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
3987
|
+
);
|
|
3988
|
+
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
3989
|
+
}
|
|
3990
|
+
function revisionFrom(node, kind) {
|
|
3991
|
+
const revision = {
|
|
3992
|
+
kind,
|
|
3993
|
+
author: getW(node, "author") || "Unknown",
|
|
3994
|
+
id: getW(node, "id") ?? "0"
|
|
3995
|
+
};
|
|
3996
|
+
const date = getW(node, "date");
|
|
3997
|
+
if (date) revision.date = date;
|
|
3998
|
+
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
3999
|
+
if (dateUtc) revision.dateUtc = dateUtc;
|
|
4000
|
+
return revision;
|
|
4001
|
+
}
|
|
4002
|
+
function paragraphMarkRevision(pPr) {
|
|
4003
|
+
const rPr = first2(pPr, "rPr");
|
|
4004
|
+
const ins = first2(rPr, "ins");
|
|
4005
|
+
if (ins) return revisionFrom(ins, "insert");
|
|
4006
|
+
const del = first2(rPr, "del");
|
|
4007
|
+
if (del) return revisionFrom(del, "delete");
|
|
4008
|
+
return void 0;
|
|
4009
|
+
}
|
|
4010
|
+
function paragraphFormatRevision(pPr) {
|
|
4011
|
+
const change = first2(pPr, "pPrChange");
|
|
4012
|
+
if (!change) return void 0;
|
|
4013
|
+
const revision = revisionFrom(change, "paragraphChange");
|
|
4014
|
+
const previous = first2(change, "pPr");
|
|
4015
|
+
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
4016
|
+
return revision;
|
|
4017
|
+
}
|
|
4018
|
+
function runFormatRevision(rPr) {
|
|
4019
|
+
const change = first2(rPr, "rPrChange");
|
|
4020
|
+
if (!change) return void 0;
|
|
4021
|
+
const revision = revisionFrom(change, "formatChange");
|
|
4022
|
+
const previous = first2(change, "rPr");
|
|
4023
|
+
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
4024
|
+
return revision;
|
|
4025
|
+
}
|
|
4026
|
+
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
4027
|
+
const runs = [];
|
|
4028
|
+
let hasMove = false;
|
|
4029
|
+
const push = (run2) => {
|
|
4030
|
+
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
4031
|
+
runs.push(run2);
|
|
4032
|
+
};
|
|
4033
|
+
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
4034
|
+
if (named2(item2, "r")) {
|
|
4035
|
+
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
4036
|
+
} else if (named2(item2, "hyperlink")) {
|
|
4037
|
+
const link = resolveLink?.(item2);
|
|
4038
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4039
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
4040
|
+
if (link) parsed.link = link;
|
|
4041
|
+
push(parsed);
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
4045
|
+
const kind = expectDefined(
|
|
4046
|
+
REVISION_WRAPPERS[item2.localName],
|
|
4047
|
+
`revision wrapper ${item2.localName}`
|
|
4048
|
+
);
|
|
4049
|
+
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
4050
|
+
const revision = revisionFrom(item2, kind);
|
|
4051
|
+
const range = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
4052
|
+
if (range) revision.move = { name: range.name, rangeId: range.id };
|
|
4053
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4054
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
4055
|
+
parsed.revision = revision;
|
|
4056
|
+
push(parsed);
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
} else if (trackMoveRange(item2, moves)) {
|
|
4060
|
+
continue;
|
|
4061
|
+
} else if (named2(item2, "commentRangeStart")) {
|
|
4062
|
+
const id = getW(item2, "id");
|
|
4063
|
+
if (id !== void 0) active.push(id);
|
|
4064
|
+
} else if (named2(item2, "commentRangeEnd")) {
|
|
4065
|
+
const id = getW(item2, "id");
|
|
4066
|
+
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
4067
|
+
if (index >= 0) active.splice(index, 1);
|
|
4068
|
+
} else {
|
|
4069
|
+
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
return { runs, hasMove };
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4075
|
+
// docx/parse-content-control.ts
|
|
4076
|
+
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
4077
|
+
const control = parseContentControl(sdt, "inline");
|
|
4078
|
+
const content = sdtContent(sdt);
|
|
4079
|
+
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
4080
|
+
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
4081
|
+
for (const run2 of runs) run2.contentControl ??= control;
|
|
4082
|
+
return runs;
|
|
4083
|
+
}
|
|
4084
|
+
function flatChildren(parent, names, level3 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
4085
|
+
const found = [];
|
|
4086
|
+
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
4087
|
+
if (isSdt(child7)) {
|
|
4088
|
+
const content = sdtContent(child7);
|
|
4089
|
+
if (!content) continue;
|
|
4090
|
+
let control = controls.get(child7);
|
|
4091
|
+
if (!control) {
|
|
4092
|
+
control = parseContentControl(child7, level3);
|
|
4093
|
+
controls.set(child7, control);
|
|
4094
|
+
}
|
|
4095
|
+
found.push(...flatChildren(content, names, level3, { control, sdt: child7 }, controls));
|
|
4096
|
+
} else if (names.some((name) => named2(child7, name)))
|
|
4097
|
+
found.push({
|
|
4098
|
+
element: child7,
|
|
4099
|
+
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
4100
|
+
});
|
|
4101
|
+
}
|
|
4102
|
+
return found;
|
|
4103
|
+
}
|
|
4104
|
+
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
4105
|
+
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
4106
|
+
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
4107
|
+
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
4108
|
+
|
|
3368
4109
|
// docx/content-control-values.ts
|
|
3369
4110
|
var validLock = (lock) => lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked" ? lock : void 0;
|
|
3370
4111
|
function validId(id) {
|
|
@@ -3590,15 +4331,15 @@ function writeDate(doc, sdtPr, control) {
|
|
|
3590
4331
|
const fullDate = validDate(control.fullDate) ?? (control.fullDate === existing ? existing : void 0);
|
|
3591
4332
|
if (fullDate) date.setAttributeNS(WORD_NS, "w:fullDate", fullDate);
|
|
3592
4333
|
else date.removeAttributeNS(WORD_NS, "fullDate");
|
|
3593
|
-
const
|
|
4334
|
+
const set2 = (local, value, order) => {
|
|
3594
4335
|
for (const old of children2(date, local)) date.removeChild(old);
|
|
3595
4336
|
if (typeof value !== "string") return;
|
|
3596
4337
|
const element4 = makeW(doc, local);
|
|
3597
4338
|
element4.setAttributeNS(WORD_NS, "w:val", value);
|
|
3598
4339
|
date.insertBefore(element4, Array.from(date.childNodes)[order] ?? null);
|
|
3599
4340
|
};
|
|
3600
|
-
|
|
3601
|
-
|
|
4341
|
+
set2("dateFormat", control.dateFormat, 0);
|
|
4342
|
+
set2("lid", control.dateLocale, 1);
|
|
3602
4343
|
}
|
|
3603
4344
|
var writesType = (kind) => NAMED_TYPES.has(kind) || ["richText", "text", "checkbox", "dropDownList", "comboBox", "date"].includes(kind);
|
|
3604
4345
|
function patchContentControl(doc, sdt, control) {
|
|
@@ -3776,13 +4517,13 @@ function rangeKeys(run2) {
|
|
|
3776
4517
|
keys.push(`${revision.kind}:${revision.move.name}`);
|
|
3777
4518
|
return keys;
|
|
3778
4519
|
}
|
|
3779
|
-
function
|
|
4520
|
+
function paragraphsOf2(blocks) {
|
|
3780
4521
|
return blocks.flatMap(
|
|
3781
4522
|
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell2) => cell2.paragraphs))
|
|
3782
4523
|
);
|
|
3783
4524
|
}
|
|
3784
4525
|
function commentContinuations(blocks) {
|
|
3785
|
-
const paragraphs =
|
|
4526
|
+
const paragraphs = paragraphsOf2(blocks);
|
|
3786
4527
|
const first3 = /* @__PURE__ */ new Map();
|
|
3787
4528
|
const last = /* @__PURE__ */ new Map();
|
|
3788
4529
|
const idsByParagraph = paragraphs.map((paragraph2, index) => {
|
|
@@ -3847,7 +4588,7 @@ var COMMENTS_PATH = "word/comments.xml";
|
|
|
3847
4588
|
var COMMENTS_EXTENDED_PATH = "word/commentsExtended.xml";
|
|
3848
4589
|
var W14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
3849
4590
|
var W15_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
3850
|
-
function
|
|
4591
|
+
function setAttribute2(element4, local, value) {
|
|
3851
4592
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
3852
4593
|
}
|
|
3853
4594
|
function paraIdFor(id, index) {
|
|
@@ -3862,10 +4603,10 @@ function buildCommentsDocument(comments) {
|
|
|
3862
4603
|
const root = doc.documentElement;
|
|
3863
4604
|
comments.forEach((comment, index) => {
|
|
3864
4605
|
const el5 = makeW(doc, "comment");
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
if (comment.date)
|
|
3868
|
-
if (comment.initials)
|
|
4606
|
+
setAttribute2(el5, "id", comment.id);
|
|
4607
|
+
setAttribute2(el5, "author", comment.author);
|
|
4608
|
+
if (comment.date) setAttribute2(el5, "date", comment.date);
|
|
4609
|
+
if (comment.initials) setAttribute2(el5, "initials", comment.initials);
|
|
3869
4610
|
const p = makeW(doc, "p");
|
|
3870
4611
|
p.setAttributeNS(W14_NS, "w14:paraId", paraIdFor(comment.id, index));
|
|
3871
4612
|
const r = makeW(doc, "r");
|
|
@@ -3929,15 +4670,15 @@ async function applyComments(zip, comments) {
|
|
|
3929
4670
|
}
|
|
3930
4671
|
function commentRangeStartNode(doc, id) {
|
|
3931
4672
|
const element4 = makeW(doc, "commentRangeStart");
|
|
3932
|
-
|
|
4673
|
+
setAttribute2(element4, "id", id);
|
|
3933
4674
|
return element4;
|
|
3934
4675
|
}
|
|
3935
4676
|
function commentRangeEndNodes(doc, id) {
|
|
3936
4677
|
const end = makeW(doc, "commentRangeEnd");
|
|
3937
|
-
|
|
4678
|
+
setAttribute2(end, "id", id);
|
|
3938
4679
|
const run2 = makeW(doc, "r");
|
|
3939
4680
|
const reference = makeW(doc, "commentReference");
|
|
3940
|
-
|
|
4681
|
+
setAttribute2(reference, "id", id);
|
|
3941
4682
|
run2.appendChild(reference);
|
|
3942
4683
|
return [end, run2];
|
|
3943
4684
|
}
|
|
@@ -4183,10 +4924,10 @@ function buildRowProperties(doc, row, gridAfter) {
|
|
|
4183
4924
|
}
|
|
4184
4925
|
|
|
4185
4926
|
// docx/write-table-margins.ts
|
|
4186
|
-
var
|
|
4927
|
+
var SIDES4 = ["top", "left", "bottom", "right"];
|
|
4187
4928
|
var ORDER2 = ["top", "start", "left", "bottom", "end", "right"];
|
|
4188
4929
|
function patchMarginProperties(doc, host, propertiesTag, marginTag, propertiesOrder, next, base) {
|
|
4189
|
-
const changed =
|
|
4930
|
+
const changed = SIDES4.filter((side) => next?.[side] !== base?.[side]);
|
|
4190
4931
|
if (!changed.length) return;
|
|
4191
4932
|
for (const side of changed) {
|
|
4192
4933
|
const value = next?.[side];
|
|
@@ -4506,14 +5247,21 @@ function unwrapDroppedControls(elements2, next) {
|
|
|
4506
5247
|
});
|
|
4507
5248
|
}
|
|
4508
5249
|
|
|
4509
|
-
// docx/
|
|
5250
|
+
// docx/table-structure-check.ts
|
|
5251
|
+
var only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
5252
|
+
function plainParagraphs(cell2) {
|
|
5253
|
+
for (const paragraph2 of children2(cell2, "p")) {
|
|
5254
|
+
if (!only(paragraph2, ["pPr", "r"])) return false;
|
|
5255
|
+
for (const run2 of children2(paragraph2, "r"))
|
|
5256
|
+
if (!only(run2, ["rPr", "t", "tab", "br", "cr", "noBreakHyphen"])) return false;
|
|
5257
|
+
}
|
|
5258
|
+
return true;
|
|
5259
|
+
}
|
|
4510
5260
|
function canEditTableStructure(table) {
|
|
4511
|
-
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
4512
5261
|
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
4513
5262
|
const grid = first2(table, "tblGrid");
|
|
4514
5263
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
4515
5264
|
const rows = children2(table, "tr");
|
|
4516
|
-
if (!rows.length) return false;
|
|
4517
5265
|
const [firstRow] = rows;
|
|
4518
5266
|
if (!firstRow) return false;
|
|
4519
5267
|
const width = children2(firstRow, "tc").length;
|
|
@@ -4529,15 +5277,206 @@ function canEditTableStructure(table) {
|
|
|
4529
5277
|
const props = first2(cell2, "tcPr");
|
|
4530
5278
|
if (props && ["gridSpan", "vMerge", "hMerge", "tcPrChange"].some((key) => first2(props, key)))
|
|
4531
5279
|
return false;
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
5280
|
+
if (!plainParagraphs(cell2)) return false;
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
return true;
|
|
5284
|
+
}
|
|
5285
|
+
function canRestructureTable(table) {
|
|
5286
|
+
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
5287
|
+
const grid = first2(table, "tblGrid");
|
|
5288
|
+
if (!grid || !only(grid, ["gridCol"])) return false;
|
|
5289
|
+
const rows = children2(table, "tr");
|
|
5290
|
+
if (!rows.length) return false;
|
|
5291
|
+
for (const row of rows) {
|
|
5292
|
+
if (!only(row, ["trPr", "tc"]) || !children2(row, "tc").length) return false;
|
|
5293
|
+
const rowProps = first2(row, "trPr");
|
|
5294
|
+
if (rowProps && ["gridBefore", "gridAfter", "wBefore", "wAfter", "trPrChange", "ins", "del"].some(
|
|
5295
|
+
(key) => first2(rowProps, key)
|
|
5296
|
+
))
|
|
5297
|
+
return false;
|
|
5298
|
+
for (const cell2 of children2(row, "tc")) {
|
|
5299
|
+
if (!only(cell2, ["tcPr", "p", "tbl"]) || !children2(cell2, "p").length) return false;
|
|
5300
|
+
const props = first2(cell2, "tcPr");
|
|
5301
|
+
if (props && ["hMerge", "tcPrChange", "cellIns", "cellDel", "cellMerge"].some((key) => first2(props, key)))
|
|
5302
|
+
return false;
|
|
5303
|
+
if (!plainParagraphs(cell2)) return false;
|
|
4537
5304
|
}
|
|
4538
5305
|
}
|
|
4539
5306
|
return true;
|
|
4540
5307
|
}
|
|
5308
|
+
|
|
5309
|
+
// docx/write-table-structure.ts
|
|
5310
|
+
var set = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
5311
|
+
function restructured(next, base) {
|
|
5312
|
+
const shape = (table) => JSON.stringify([
|
|
5313
|
+
table.grid,
|
|
5314
|
+
table.rows.map(
|
|
5315
|
+
(row) => row.map((cell2) => [
|
|
5316
|
+
cell2.paragraphs.map((p) => p.id),
|
|
5317
|
+
cell2.gridSpan ?? 1,
|
|
5318
|
+
cell2.verticalMerge ?? "",
|
|
5319
|
+
cell2.widthTwips
|
|
5320
|
+
])
|
|
5321
|
+
)
|
|
5322
|
+
]);
|
|
5323
|
+
return shape(next) !== shape(base);
|
|
5324
|
+
}
|
|
5325
|
+
function patchCellLayout(doc, tc, cell2, base) {
|
|
5326
|
+
const span = cell2.gridSpan ?? 1;
|
|
5327
|
+
const width = cell2.widthTwips;
|
|
5328
|
+
if (span === (base.gridSpan ?? 1) && width === base.widthTwips && cell2.verticalMerge === base.verticalMerge)
|
|
5329
|
+
return;
|
|
5330
|
+
let props = first2(tc, "tcPr");
|
|
5331
|
+
if (!props) {
|
|
5332
|
+
props = makeW(doc, "tcPr");
|
|
5333
|
+
tc.insertBefore(props, tc.firstChild);
|
|
5334
|
+
}
|
|
5335
|
+
const replace = (name, next) => {
|
|
5336
|
+
for (const old of children2(props, name)) props.removeChild(old);
|
|
5337
|
+
if (next) props.appendChild(next);
|
|
5338
|
+
};
|
|
5339
|
+
if (width !== base.widthTwips) {
|
|
5340
|
+
const old = first2(props, "tcW");
|
|
5341
|
+
if (width === void 0) replace("tcW", void 0);
|
|
5342
|
+
else {
|
|
5343
|
+
const element4 = old ?? makeW(doc, "tcW");
|
|
5344
|
+
set(element4, "w", String(width));
|
|
5345
|
+
set(element4, "type", "dxa");
|
|
5346
|
+
if (!old) props.appendChild(element4);
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5349
|
+
if (span !== (base.gridSpan ?? 1)) {
|
|
5350
|
+
const element4 = span > 1 ? makeW(doc, "gridSpan") : void 0;
|
|
5351
|
+
if (element4) set(element4, "val", String(span));
|
|
5352
|
+
replace("gridSpan", element4);
|
|
5353
|
+
}
|
|
5354
|
+
if (cell2.verticalMerge !== base.verticalMerge) {
|
|
5355
|
+
const element4 = cell2.verticalMerge ? makeW(doc, "vMerge") : void 0;
|
|
5356
|
+
if (element4 && cell2.verticalMerge === "restart") set(element4, "val", "restart");
|
|
5357
|
+
replace("vMerge", element4);
|
|
5358
|
+
}
|
|
5359
|
+
orderChildren(props, CELL_ORDER);
|
|
5360
|
+
if (!Array.from(props.childNodes).some((node) => node.nodeType === 1) && !props.attributes.length)
|
|
5361
|
+
tc.removeChild(props);
|
|
5362
|
+
}
|
|
5363
|
+
function patchGrid(doc, node, table) {
|
|
5364
|
+
const grid = first2(node, "tblGrid");
|
|
5365
|
+
if (!grid || !table.grid) return;
|
|
5366
|
+
const old = children2(grid, "gridCol");
|
|
5367
|
+
table.grid.forEach((width, index) => {
|
|
5368
|
+
let column = old[index];
|
|
5369
|
+
if (!column) {
|
|
5370
|
+
column = makeW(doc, "gridCol");
|
|
5371
|
+
grid.appendChild(column);
|
|
5372
|
+
}
|
|
5373
|
+
if (column.getAttributeNS(WORD_NS, "w") !== String(width)) set(column, "w", String(width));
|
|
5374
|
+
});
|
|
5375
|
+
for (const extra of old.slice(table.grid.length)) grid.removeChild(extra);
|
|
5376
|
+
}
|
|
5377
|
+
function writeRestructuredTable(doc, table, node, base, writeParagraph, replaceSlots2, writeNested) {
|
|
5378
|
+
if (table.rows.some((row) => !row.length || row.some((cell2) => !cell2.paragraphs.length)))
|
|
5379
|
+
throw new Error("Every table row needs a cell and every cell a paragraph.");
|
|
5380
|
+
const oldRows = flatRows(node).map((entry2) => entry2.element);
|
|
5381
|
+
const oldCells = oldRows.map((tr) => flatCells(tr).map((entry2) => entry2.element));
|
|
5382
|
+
const cellById = /* @__PURE__ */ new Map();
|
|
5383
|
+
const paragraphById = /* @__PURE__ */ new Map();
|
|
5384
|
+
base.rows.forEach(
|
|
5385
|
+
(row, ri) => row.forEach((cell2, ci) => {
|
|
5386
|
+
const tc = oldCells[ri]?.[ci];
|
|
5387
|
+
if (!tc) return;
|
|
5388
|
+
const id = cell2.paragraphs[0]?.id;
|
|
5389
|
+
if (id) cellById.set(id, { tc, model: cell2, row: ri });
|
|
5390
|
+
const flat = flatCellParagraphs(tc);
|
|
5391
|
+
cell2.paragraphs.forEach((model, pi) => {
|
|
5392
|
+
const entry2 = flat[pi];
|
|
5393
|
+
if (entry2) paragraphById.set(model.id, { element: entry2.element, model });
|
|
5394
|
+
});
|
|
5395
|
+
})
|
|
5396
|
+
);
|
|
5397
|
+
const usedRows = /* @__PURE__ */ new Set();
|
|
5398
|
+
const usedCells = /* @__PURE__ */ new Set();
|
|
5399
|
+
const nextRows = table.rows.map((row, rowIndex) => {
|
|
5400
|
+
const sourceRow = row.map((cell2) => cellById.get(cell2.paragraphs[0]?.id ?? "")?.row).find((index) => index !== void 0 && !usedRows.has(index));
|
|
5401
|
+
if (sourceRow !== void 0) usedRows.add(sourceRow);
|
|
5402
|
+
const tr = sourceRow === void 0 ? makeW(doc, "tr") : oldRows[sourceRow] ?? makeW(doc, "tr");
|
|
5403
|
+
patchRowProperties(
|
|
5404
|
+
doc,
|
|
5405
|
+
tr,
|
|
5406
|
+
table.rowProperties?.[rowIndex],
|
|
5407
|
+
sourceRow === void 0 ? void 0 : base.rowProperties?.[sourceRow]
|
|
5408
|
+
);
|
|
5409
|
+
const nextCells = row.map((cell2) => {
|
|
5410
|
+
const source2 = cellById.get(cell2.paragraphs[0]?.id ?? "");
|
|
5411
|
+
const reuse = source2 && source2.row === sourceRow && !usedCells.has(source2.tc) ? source2 : void 0;
|
|
5412
|
+
const tc = reuse?.tc ?? makeW(doc, "tc");
|
|
5413
|
+
if (reuse) {
|
|
5414
|
+
usedCells.add(reuse.tc);
|
|
5415
|
+
patchCellLayout(doc, tc, cell2, reuse.model);
|
|
5416
|
+
patchCellBorders(doc, tc, cell2.borders, reuse.model.borders);
|
|
5417
|
+
patchCellShading(doc, tc, cell2, reuse.model);
|
|
5418
|
+
patchCellMargins(doc, tc, cell2.margins, reuse.model.margins);
|
|
5419
|
+
patchCellVerticalAlignment(doc, tc, cell2.verticalAlign, reuse.model.verticalAlign);
|
|
5420
|
+
} else {
|
|
5421
|
+
const props = buildCellProperties(doc, cell2);
|
|
5422
|
+
if (props) tc.insertBefore(props, tc.firstChild);
|
|
5423
|
+
}
|
|
5424
|
+
const oldParagraphs = reuse ? flatCellParagraphs(tc).map((entry2) => entry2.element) : [];
|
|
5425
|
+
const owned = new Set(oldParagraphs);
|
|
5426
|
+
const nextParagraphs = cell2.paragraphs.map((paragraph2) => {
|
|
5427
|
+
const found = paragraphById.get(paragraph2.id);
|
|
5428
|
+
const element4 = found ? owned.has(found.element) ? found.element : found.element.cloneNode(true) : makeW(doc, "p");
|
|
5429
|
+
return writeParagraph(doc, paragraph2, element4, found?.model);
|
|
5430
|
+
});
|
|
5431
|
+
replaceSlots2(doc, tc, oldParagraphs, nextParagraphs);
|
|
5432
|
+
if (reuse) writeNested(doc, tc, cell2, reuse.model);
|
|
5433
|
+
return tc;
|
|
5434
|
+
});
|
|
5435
|
+
replaceSlots2(doc, tr, sourceRow === void 0 ? [] : oldCells[sourceRow] ?? [], nextCells);
|
|
5436
|
+
return tr;
|
|
5437
|
+
});
|
|
5438
|
+
replaceSlots2(doc, node, oldRows, nextRows);
|
|
5439
|
+
patchTableMargins(doc, table, node, base);
|
|
5440
|
+
patchGrid(doc, node, table);
|
|
5441
|
+
return node;
|
|
5442
|
+
}
|
|
5443
|
+
|
|
5444
|
+
// docx/table-grid.ts
|
|
5445
|
+
var spanOf = (cell2) => Math.max(1, cell2.gridSpan ?? 1);
|
|
5446
|
+
function tableGrid(table) {
|
|
5447
|
+
const columns = table.grid?.length ?? sumSpans(table.rows[0]);
|
|
5448
|
+
if (!columns || !table.rows.length) return void 0;
|
|
5449
|
+
const rows = [];
|
|
5450
|
+
const cover = [];
|
|
5451
|
+
for (let row = 0; row < table.rows.length; row++) {
|
|
5452
|
+
const cells = table.rows[row] ?? [];
|
|
5453
|
+
if (!cells.length || sumSpans(cells) !== columns) return void 0;
|
|
5454
|
+
const placed = [];
|
|
5455
|
+
const line2 = new Array(columns);
|
|
5456
|
+
let col = 0;
|
|
5457
|
+
cells.forEach((cell2, index) => {
|
|
5458
|
+
const entry2 = { cell: cell2, row, index, col, span: spanOf(cell2) };
|
|
5459
|
+
for (let k = 0; k < entry2.span; k++) line2[col + k] = entry2;
|
|
5460
|
+
col += entry2.span;
|
|
5461
|
+
placed.push(entry2);
|
|
5462
|
+
});
|
|
5463
|
+
rows.push(placed);
|
|
5464
|
+
cover.push(line2);
|
|
5465
|
+
}
|
|
5466
|
+
const grid = { columns, rows, cover };
|
|
5467
|
+
for (const entry2 of rows.flat())
|
|
5468
|
+
if (entry2.cell.verticalMerge === "continue") {
|
|
5469
|
+
const above = entry2.row > 0 ? cover[entry2.row - 1]?.[entry2.col] : void 0;
|
|
5470
|
+
if (!above || above.col !== entry2.col || above.span !== entry2.span) return void 0;
|
|
5471
|
+
if (!above.cell.verticalMerge) return void 0;
|
|
5472
|
+
}
|
|
5473
|
+
return grid;
|
|
5474
|
+
}
|
|
5475
|
+
function sumSpans(cells) {
|
|
5476
|
+
return (cells ?? []).reduce((sum, cell2) => sum + spanOf(cell2), 0);
|
|
5477
|
+
}
|
|
5478
|
+
|
|
5479
|
+
// docx/write-table.ts
|
|
4541
5480
|
var layout = (table) => table.rows.map((row) => row.map((cell2) => cell2.paragraphs.map((p) => p.id)));
|
|
4542
5481
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
4543
5482
|
"grid",
|
|
@@ -4555,13 +5494,15 @@ function pick(source2, keys) {
|
|
|
4555
5494
|
for (const key of keys) if (record[key] !== void 0) result[key] = record[key];
|
|
4556
5495
|
return result;
|
|
4557
5496
|
}
|
|
4558
|
-
function assertNoDescriptorEdits(table, base) {
|
|
5497
|
+
function assertNoDescriptorEdits(table, base, layoutEdits = false) {
|
|
4559
5498
|
if (!base) return;
|
|
4560
|
-
|
|
5499
|
+
const tableKeys = layoutEdits ? TABLE_DESCRIPTOR_KEYS.filter((key) => key !== "grid") : TABLE_DESCRIPTOR_KEYS;
|
|
5500
|
+
if (JSON.stringify(pick(table, tableKeys)) !== JSON.stringify(pick(base, tableKeys)))
|
|
4561
5501
|
throw new Error(
|
|
4562
5502
|
"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."
|
|
4563
5503
|
);
|
|
4564
5504
|
const baseCellById = /* @__PURE__ */ new Map();
|
|
5505
|
+
if (layoutEdits) return;
|
|
4565
5506
|
for (const row of base.rows)
|
|
4566
5507
|
for (const cell2 of row) {
|
|
4567
5508
|
const id = cell2.paragraphs[0]?.id;
|
|
@@ -4586,11 +5527,24 @@ function writeNestedTables(doc, tc, cell2, base, writeParagraph, replaceSlots2)
|
|
|
4586
5527
|
next.forEach((table, index) => {
|
|
4587
5528
|
const node = nodes[index];
|
|
4588
5529
|
if (node && before[index])
|
|
4589
|
-
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2);
|
|
5530
|
+
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2, true);
|
|
4590
5531
|
});
|
|
4591
5532
|
}
|
|
4592
|
-
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
5533
|
+
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2, nested = false) {
|
|
4593
5534
|
if (base && JSON.stringify(table) === JSON.stringify(base)) return node;
|
|
5535
|
+
const baseGrid = base && tableGrid(base);
|
|
5536
|
+
if (base && baseGrid && (nested || !base.structureEditable || table.structureEditable === false) && restructured(table, base) && canRestructureTable(node)) {
|
|
5537
|
+
assertNoDescriptorEdits(table, base, true);
|
|
5538
|
+
return writeRestructuredTable(
|
|
5539
|
+
doc,
|
|
5540
|
+
table,
|
|
5541
|
+
node,
|
|
5542
|
+
base,
|
|
5543
|
+
writeParagraph,
|
|
5544
|
+
replaceSlots2,
|
|
5545
|
+
(d, tc, cell2, before) => writeNestedTables(d, tc, cell2, before, writeParagraph, replaceSlots2)
|
|
5546
|
+
);
|
|
5547
|
+
}
|
|
4594
5548
|
assertNoDescriptorEdits(table, base);
|
|
4595
5549
|
patchTableMargins(doc, table, node, base);
|
|
4596
5550
|
const structural = base && JSON.stringify(layout(table)) !== JSON.stringify(layout(base));
|
|
@@ -4716,13 +5670,13 @@ function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
|
4716
5670
|
|
|
4717
5671
|
// docx/write-footnote-columns.ts
|
|
4718
5672
|
var W15 = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
4719
|
-
var
|
|
5673
|
+
var XMLNS4 = "http://www.w3.org/2000/xmlns/";
|
|
4720
5674
|
var MC2 = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
4721
5675
|
function prefix(doc, preferred, namespace) {
|
|
4722
5676
|
let name = preferred;
|
|
4723
5677
|
for (let suffix = 1; doc.documentElement.lookupNamespaceURI(name) && doc.documentElement.lookupNamespaceURI(name) !== namespace; suffix++)
|
|
4724
5678
|
name = preferred + suffix;
|
|
4725
|
-
doc.documentElement.setAttributeNS(
|
|
5679
|
+
doc.documentElement.setAttributeNS(XMLNS4, "xmlns:" + name, namespace);
|
|
4726
5680
|
return name;
|
|
4727
5681
|
}
|
|
4728
5682
|
function writeFootnoteColumns(doc, section, value) {
|
|
@@ -4745,13 +5699,13 @@ function writeFootnoteColumns(doc, section, value) {
|
|
|
4745
5699
|
}
|
|
4746
5700
|
|
|
4747
5701
|
// docx/page-borders.ts
|
|
4748
|
-
var
|
|
5702
|
+
var SIDES5 = ["top", "left", "bottom", "right"];
|
|
4749
5703
|
var ATTRIBUTES = ["offsetFrom", "display", "zOrder"];
|
|
4750
5704
|
var setW4 = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
4751
5705
|
function parsePageBorders(element4) {
|
|
4752
5706
|
if (!element4) return void 0;
|
|
4753
5707
|
const result = {};
|
|
4754
|
-
for (const side of
|
|
5708
|
+
for (const side of SIDES5) {
|
|
4755
5709
|
const source2 = first2(element4, side);
|
|
4756
5710
|
const value = borderSide(source2);
|
|
4757
5711
|
const art = getW(source2, "art");
|
|
@@ -4789,7 +5743,7 @@ function patchPageBorders(doc, sectPr, next, base, create2) {
|
|
|
4789
5743
|
return;
|
|
4790
5744
|
}
|
|
4791
5745
|
const element4 = create2(doc, sectPr, "pgBorders");
|
|
4792
|
-
for (const side of
|
|
5746
|
+
for (const side of SIDES5) {
|
|
4793
5747
|
if (JSON.stringify(next[side]) === JSON.stringify(base?.[side])) continue;
|
|
4794
5748
|
for (const old of children2(element4, side)) element4.removeChild(old);
|
|
4795
5749
|
const value = next[side];
|
|
@@ -4970,75 +5924,6 @@ function writePageNumbering(doc, sectPr, section) {
|
|
|
4970
5924
|
}
|
|
4971
5925
|
}
|
|
4972
5926
|
|
|
4973
|
-
// docx/tab-stops.ts
|
|
4974
|
-
function parseTabStops(tabs) {
|
|
4975
|
-
const stops = [];
|
|
4976
|
-
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
4977
|
-
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
4978
|
-
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
4979
|
-
if (!align || pos === void 0) continue;
|
|
4980
|
-
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
4981
|
-
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
4982
|
-
}
|
|
4983
|
-
return stops;
|
|
4984
|
-
}
|
|
4985
|
-
function writeTabStops(doc, props, paragraph2, base) {
|
|
4986
|
-
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
4987
|
-
return;
|
|
4988
|
-
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
4989
|
-
if (!paragraph2.tabStops?.length) return;
|
|
4990
|
-
const tabs = makeW(doc, "tabs");
|
|
4991
|
-
for (const stop of paragraph2.tabStops) {
|
|
4992
|
-
const tab = makeW(doc, "tab");
|
|
4993
|
-
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
4994
|
-
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
4995
|
-
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
4996
|
-
tabs.appendChild(tab);
|
|
4997
|
-
}
|
|
4998
|
-
props.appendChild(tabs);
|
|
4999
|
-
}
|
|
5000
|
-
var PPR_ORDER = [
|
|
5001
|
-
"pStyle",
|
|
5002
|
-
"keepNext",
|
|
5003
|
-
"keepLines",
|
|
5004
|
-
"pageBreakBefore",
|
|
5005
|
-
"framePr",
|
|
5006
|
-
"widowControl",
|
|
5007
|
-
"numPr",
|
|
5008
|
-
"suppressLineNumbers",
|
|
5009
|
-
"pBdr",
|
|
5010
|
-
"shd",
|
|
5011
|
-
"tabs",
|
|
5012
|
-
"suppressAutoHyphens",
|
|
5013
|
-
"kinsoku",
|
|
5014
|
-
"wordWrap",
|
|
5015
|
-
"overflowPunct",
|
|
5016
|
-
"topLinePunct",
|
|
5017
|
-
"autoSpaceDE",
|
|
5018
|
-
"autoSpaceDN",
|
|
5019
|
-
"bidi",
|
|
5020
|
-
"adjustRightInd",
|
|
5021
|
-
"snapToGrid",
|
|
5022
|
-
"spacing",
|
|
5023
|
-
"ind",
|
|
5024
|
-
"contextualSpacing",
|
|
5025
|
-
"mirrorIndents",
|
|
5026
|
-
"suppressOverlap",
|
|
5027
|
-
"jc",
|
|
5028
|
-
"textDirection",
|
|
5029
|
-
"textAlignment",
|
|
5030
|
-
"textboxTightWrap",
|
|
5031
|
-
"outlineLvl",
|
|
5032
|
-
"divId",
|
|
5033
|
-
"cnfStyle",
|
|
5034
|
-
"rPr",
|
|
5035
|
-
"sectPr",
|
|
5036
|
-
"pPrChange"
|
|
5037
|
-
];
|
|
5038
|
-
function orderParagraphProperties(props) {
|
|
5039
|
-
orderChildren(props, PPR_ORDER);
|
|
5040
|
-
}
|
|
5041
|
-
|
|
5042
5927
|
// docx/write-sections.ts
|
|
5043
5928
|
var WRITABLE = /* @__PURE__ */ new Set([
|
|
5044
5929
|
"endsAtBlockId",
|
|
@@ -5643,16 +6528,16 @@ function isWordElement(element4, names) {
|
|
|
5643
6528
|
}
|
|
5644
6529
|
var isRevisionWrapperElement = (element4) => isWordElement(element4, REVISION_WRAPPER_NAMES2);
|
|
5645
6530
|
var isCommentAnchorElement = (element4) => isWordElement(element4, COMMENT_ANCHOR_NAMES);
|
|
5646
|
-
function
|
|
6531
|
+
function setAttribute3(element4, local, value) {
|
|
5647
6532
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
5648
6533
|
}
|
|
5649
6534
|
function removeChildren(element4, local) {
|
|
5650
6535
|
for (const child7 of children2(element4, local)) element4.removeChild(child7);
|
|
5651
6536
|
}
|
|
5652
6537
|
function writeRevisionMetadata(element4, revision) {
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
if (revision.date)
|
|
6538
|
+
setAttribute3(element4, "id", revision.id);
|
|
6539
|
+
setAttribute3(element4, "author", revision.author);
|
|
6540
|
+
if (revision.date) setAttribute3(element4, "date", revision.date);
|
|
5656
6541
|
else element4.removeAttributeNS(WORD_NS, "date");
|
|
5657
6542
|
if (revision.dateUtc) element4.setAttributeNS(WORD_DATE_UTC_NS, "w16du:dateUtc", revision.dateUtc);
|
|
5658
6543
|
else element4.removeAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
@@ -5787,184 +6672,6 @@ function restoreAnnotations(markers, before, after) {
|
|
|
5787
6672
|
}
|
|
5788
6673
|
}
|
|
5789
6674
|
|
|
5790
|
-
// docx/write-paragraph-decoration.ts
|
|
5791
|
-
var SIDES5 = ["top", "left", "bottom", "right", "between"];
|
|
5792
|
-
function wordColor(color) {
|
|
5793
|
-
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
5794
|
-
return hex ? hex.toUpperCase() : "auto";
|
|
5795
|
-
}
|
|
5796
|
-
function borderElement(doc, name, side) {
|
|
5797
|
-
const element4 = makeW(doc, name);
|
|
5798
|
-
const set = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
5799
|
-
set("val", side.style ?? "single");
|
|
5800
|
-
if (side.style !== "none" && side.style !== "nil") {
|
|
5801
|
-
set("sz", String(side.sizeEighthPoints ?? 4));
|
|
5802
|
-
set("space", String(side.spacePoints ?? 1));
|
|
5803
|
-
set("color", wordColor(side.color));
|
|
5804
|
-
if (side.themeColor) set("themeColor", side.themeColor);
|
|
5805
|
-
}
|
|
5806
|
-
return element4;
|
|
5807
|
-
}
|
|
5808
|
-
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
5809
|
-
function updateShading(doc, props, paragraph2, base) {
|
|
5810
|
-
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
5811
|
-
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
5812
|
-
if (!paragraph2.shadingFill) return;
|
|
5813
|
-
const shd = makeW(doc, "shd");
|
|
5814
|
-
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
5815
|
-
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
5816
|
-
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
5817
|
-
props.appendChild(shd);
|
|
5818
|
-
}
|
|
5819
|
-
function updateBorders(doc, props, paragraph2, base) {
|
|
5820
|
-
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
5821
|
-
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
5822
|
-
const borders = paragraph2.borders;
|
|
5823
|
-
if (!borders) return;
|
|
5824
|
-
const pBdr = makeW(doc, "pBdr");
|
|
5825
|
-
for (const side of SIDES5) {
|
|
5826
|
-
const value = borders[side];
|
|
5827
|
-
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
5828
|
-
}
|
|
5829
|
-
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
5830
|
-
}
|
|
5831
|
-
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
5832
|
-
updateShading(doc, props, paragraph2, base);
|
|
5833
|
-
updateBorders(doc, props, paragraph2, base);
|
|
5834
|
-
}
|
|
5835
|
-
|
|
5836
|
-
// docx/write-paragraph-properties.ts
|
|
5837
|
-
function setAttribute3(element4, local, value) {
|
|
5838
|
-
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
5839
|
-
}
|
|
5840
|
-
function setWordValue(element4, local, value) {
|
|
5841
|
-
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
5842
|
-
else setAttribute3(element4, local, String(value));
|
|
5843
|
-
}
|
|
5844
|
-
function updateDirection(doc, props, paragraph2, base) {
|
|
5845
|
-
if (base && paragraph2.direction === base.direction) return;
|
|
5846
|
-
let bidi = first2(props, "bidi");
|
|
5847
|
-
if (paragraph2.direction === void 0) {
|
|
5848
|
-
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
5849
|
-
} else {
|
|
5850
|
-
if (!bidi) {
|
|
5851
|
-
bidi = makeW(doc, "bidi");
|
|
5852
|
-
props.appendChild(bidi);
|
|
5853
|
-
}
|
|
5854
|
-
setAttribute3(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
5855
|
-
}
|
|
5856
|
-
}
|
|
5857
|
-
function updateSpacing(doc, props, paragraph2, base) {
|
|
5858
|
-
let spacing2 = first2(props, "spacing");
|
|
5859
|
-
if (!spacing2) {
|
|
5860
|
-
spacing2 = makeW(doc, "spacing");
|
|
5861
|
-
props.appendChild(spacing2);
|
|
5862
|
-
}
|
|
5863
|
-
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
5864
|
-
setWordValue(spacing2, "before", paragraph2.spacingBeforeTwips);
|
|
5865
|
-
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
5866
|
-
setWordValue(spacing2, "after", paragraph2.spacingAfterTwips);
|
|
5867
|
-
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
5868
|
-
setWordValue(spacing2, "line", paragraph2.lineSpacingTwips);
|
|
5869
|
-
setWordValue(
|
|
5870
|
-
spacing2,
|
|
5871
|
-
"lineRule",
|
|
5872
|
-
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
5873
|
-
);
|
|
5874
|
-
}
|
|
5875
|
-
if (!spacing2.attributes.length && !spacing2.childNodes.length) props.removeChild(spacing2);
|
|
5876
|
-
}
|
|
5877
|
-
function updateIndent(doc, props, paragraph2, base) {
|
|
5878
|
-
let indent = first2(props, "ind");
|
|
5879
|
-
if (!indent) {
|
|
5880
|
-
indent = makeW(doc, "ind");
|
|
5881
|
-
props.appendChild(indent);
|
|
5882
|
-
}
|
|
5883
|
-
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
5884
|
-
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
5885
|
-
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
5886
|
-
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
5887
|
-
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
5888
|
-
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
5889
|
-
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
5890
|
-
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
5891
|
-
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
5892
|
-
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
5893
|
-
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
5894
|
-
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
5895
|
-
if (!indent.attributes.length) props.removeChild(indent);
|
|
5896
|
-
}
|
|
5897
|
-
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
5898
|
-
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
5899
|
-
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
5900
|
-
if (paragraph2.pageBreakBefore !== void 0) {
|
|
5901
|
-
const element4 = makeW(doc, "pageBreakBefore");
|
|
5902
|
-
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
5903
|
-
props.appendChild(element4);
|
|
5904
|
-
}
|
|
5905
|
-
}
|
|
5906
|
-
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
5907
|
-
for (const key of [
|
|
5908
|
-
"keepNext",
|
|
5909
|
-
"keepLines",
|
|
5910
|
-
"widowControl",
|
|
5911
|
-
"contextualSpacing",
|
|
5912
|
-
"suppressLineNumbers"
|
|
5913
|
-
]) {
|
|
5914
|
-
if (base && paragraph2[key] === base[key]) continue;
|
|
5915
|
-
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
5916
|
-
const value = paragraph2[key];
|
|
5917
|
-
if (value === void 0) continue;
|
|
5918
|
-
const element4 = makeW(doc, key);
|
|
5919
|
-
if (!value) setAttribute3(element4, "val", "0");
|
|
5920
|
-
props.appendChild(element4);
|
|
5921
|
-
}
|
|
5922
|
-
}
|
|
5923
|
-
function updateDropCap(doc, props, paragraph2, base) {
|
|
5924
|
-
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
5925
|
-
let frame2 = first2(props, "framePr");
|
|
5926
|
-
const cap = paragraph2.dropCap;
|
|
5927
|
-
if (!cap) {
|
|
5928
|
-
if (frame2) props.removeChild(frame2);
|
|
5929
|
-
return;
|
|
5930
|
-
}
|
|
5931
|
-
if (!frame2) {
|
|
5932
|
-
frame2 = makeW(doc, "framePr");
|
|
5933
|
-
props.appendChild(frame2);
|
|
5934
|
-
setAttribute3(frame2, "wrap", "around");
|
|
5935
|
-
setAttribute3(frame2, "vAnchor", "text");
|
|
5936
|
-
setAttribute3(frame2, "hAnchor", "text");
|
|
5937
|
-
}
|
|
5938
|
-
setAttribute3(frame2, "dropCap", cap.style);
|
|
5939
|
-
setAttribute3(frame2, "lines", String(cap.lines));
|
|
5940
|
-
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
5941
|
-
}
|
|
5942
|
-
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
5943
|
-
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
5944
|
-
updateKeepOptions(doc, props, paragraph2, base);
|
|
5945
|
-
updateDropCap(doc, props, paragraph2, base);
|
|
5946
|
-
updateDirection(doc, props, paragraph2, base);
|
|
5947
|
-
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
5948
|
-
const spacingKeys = [
|
|
5949
|
-
"spacingBeforeTwips",
|
|
5950
|
-
"spacingAfterTwips",
|
|
5951
|
-
"lineSpacingTwips",
|
|
5952
|
-
"lineSpacingRule"
|
|
5953
|
-
];
|
|
5954
|
-
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
5955
|
-
updateSpacing(doc, props, paragraph2, base);
|
|
5956
|
-
const indentKeys = [
|
|
5957
|
-
"indentLeftTwips",
|
|
5958
|
-
"indentRightTwips",
|
|
5959
|
-
"indentStartTwips",
|
|
5960
|
-
"indentEndTwips",
|
|
5961
|
-
"firstLineTwips",
|
|
5962
|
-
"hangingTwips"
|
|
5963
|
-
];
|
|
5964
|
-
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
5965
|
-
updateIndent(doc, props, paragraph2, base);
|
|
5966
|
-
}
|
|
5967
|
-
|
|
5968
6675
|
// docx/bookmarks.ts
|
|
5969
6676
|
function paragraphBookmarkNames(node) {
|
|
5970
6677
|
return children2(node, "bookmarkStart").map((el5) => getW(el5, "name")).filter((name) => Boolean(name));
|
|
@@ -8045,10 +8752,10 @@ function writeDrawingRichTextBody(container, body) {
|
|
|
8045
8752
|
const paragraphs = body.paragraphs.length ? body.paragraphs : [{ items: [] }];
|
|
8046
8753
|
for (const paragraph2 of paragraphs) container.appendChild(writeDrawingParagraph(doc, paragraph2));
|
|
8047
8754
|
}
|
|
8048
|
-
function drawingRichTextBodyXml(body,
|
|
8049
|
-
const prefix2 =
|
|
8755
|
+
function drawingRichTextBodyXml(body, qualifiedName2 = "a:txBody", namespace = NS.a) {
|
|
8756
|
+
const prefix2 = qualifiedName2.includes(":") ? qualifiedName2.split(":")[0] : void 0;
|
|
8050
8757
|
const declaration = prefix2 && prefix2 !== "a" ? ` xmlns:${prefix2}="${namespace}"` : "";
|
|
8051
|
-
const doc = parseXml(`<${
|
|
8758
|
+
const doc = parseXml(`<${qualifiedName2}${declaration} xmlns:a="${NS.a}" xmlns:r="${NS.r}"/>`);
|
|
8052
8759
|
writeDrawingRichTextBody(doc.documentElement, body);
|
|
8053
8760
|
return buildXml(doc);
|
|
8054
8761
|
}
|
|
@@ -14973,7 +15680,8 @@ var pie = {
|
|
|
14973
15680
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
14974
15681
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
14975
15682
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
14976
|
-
gd16("
|
|
15683
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15684
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
14977
15685
|
gd16("stx", "cos wd2 stAng"),
|
|
14978
15686
|
gd16("sty", "sin hd2 stAng"),
|
|
14979
15687
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15018,7 +15726,8 @@ var chord = {
|
|
|
15018
15726
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
15019
15727
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
15020
15728
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15021
|
-
gd16("
|
|
15729
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15730
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15022
15731
|
gd16("stx", "cos wd2 stAng"),
|
|
15023
15732
|
gd16("sty", "sin hd2 stAng"),
|
|
15024
15733
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15042,7 +15751,8 @@ var arc = {
|
|
|
15042
15751
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
15043
15752
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
15044
15753
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15045
|
-
gd16("
|
|
15754
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15755
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15046
15756
|
gd16("stx", "cos wd2 stAng"),
|
|
15047
15757
|
gd16("sty", "sin hd2 stAng"),
|
|
15048
15758
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15137,7 +15847,8 @@ var blockArc = {
|
|
|
15137
15847
|
gd16("iwd2", "+- wd2 0 thw"),
|
|
15138
15848
|
gd16("ihd2", "+- hd2 0 thh2"),
|
|
15139
15849
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15140
|
-
gd16("
|
|
15850
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15851
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15141
15852
|
gd16("mswAng", "+- 0 0 swAng2"),
|
|
15142
15853
|
gd16("stx", "cos wd2 stAng"),
|
|
15143
15854
|
gd16("sty", "sin hd2 stAng"),
|
|
@@ -17300,12 +18011,12 @@ function shapeParagraphs(wsp) {
|
|
|
17300
18011
|
function textIsPlain(wsp) {
|
|
17301
18012
|
const content = child4(child4(wsp, WPS_NS2, "txbx"), W_NS2, "txbxContent");
|
|
17302
18013
|
if (!content) return true;
|
|
17303
|
-
const
|
|
18014
|
+
const only2 = (node, allowed) => elementsOf(node).every(
|
|
17304
18015
|
(item2) => item2.namespaceURI === W_NS2 && allowed.includes(item2.localName)
|
|
17305
18016
|
);
|
|
17306
|
-
return
|
|
17307
|
-
(paragraph2) =>
|
|
17308
|
-
(run2) =>
|
|
18017
|
+
return only2(content, ["p"]) && Array.from(content.getElementsByTagNameNS(W_NS2, "p")).every(
|
|
18018
|
+
(paragraph2) => only2(paragraph2, ["pPr", "r"]) && Array.from(paragraph2.getElementsByTagNameNS(W_NS2, "r")).every(
|
|
18019
|
+
(run2) => only2(run2, ["rPr", "t"])
|
|
17309
18020
|
)
|
|
17310
18021
|
);
|
|
17311
18022
|
}
|
|
@@ -17548,7 +18259,7 @@ function parseAttributes(source2) {
|
|
|
17548
18259
|
}
|
|
17549
18260
|
return attrs2;
|
|
17550
18261
|
}
|
|
17551
|
-
function
|
|
18262
|
+
function tagEnd2(xml, from) {
|
|
17552
18263
|
let quote = "";
|
|
17553
18264
|
for (let i = from; i < xml.length; i++) {
|
|
17554
18265
|
const ch = xml[i];
|
|
@@ -17579,7 +18290,7 @@ function parseOrderedXml(xml) {
|
|
|
17579
18290
|
i = close < 0 ? -1 : xml.indexOf("<", close + 3);
|
|
17580
18291
|
continue;
|
|
17581
18292
|
}
|
|
17582
|
-
const end =
|
|
18293
|
+
const end = tagEnd2(xml, i + 1);
|
|
17583
18294
|
if (end < 0) {
|
|
17584
18295
|
break;
|
|
17585
18296
|
}
|
|
@@ -18159,17 +18870,17 @@ function isShadowedBound(node, constraint) {
|
|
|
18159
18870
|
|
|
18160
18871
|
// diagram/engine/constraint-eval.ts
|
|
18161
18872
|
function relatedNodes(node, relation2, name, ptType) {
|
|
18162
|
-
const
|
|
18873
|
+
const matches2 = (candidate) => (!name || candidate.name === name) && (matchesPointType(candidate.point, ptType) || candidate.presOf.length > 0 && matchesPointType(candidate.presOf[0], ptType));
|
|
18163
18874
|
if (relation2 === "self") {
|
|
18164
18875
|
return name && node.name !== name ? [] : [node];
|
|
18165
18876
|
}
|
|
18166
18877
|
if (relation2 === "ch") {
|
|
18167
|
-
return node.children.filter(
|
|
18878
|
+
return node.children.filter(matches2);
|
|
18168
18879
|
}
|
|
18169
18880
|
const out = [];
|
|
18170
18881
|
const visit = (current) => {
|
|
18171
18882
|
for (const child7 of current.children) {
|
|
18172
|
-
if (
|
|
18883
|
+
if (matches2(child7)) {
|
|
18173
18884
|
out.push(child7);
|
|
18174
18885
|
}
|
|
18175
18886
|
visit(child7);
|
|
@@ -25481,8 +26192,8 @@ function parseDisplayUnits(context, element4) {
|
|
|
25481
26192
|
|
|
25482
26193
|
// chart/write-util.ts
|
|
25483
26194
|
var INVALID_XML = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
25484
|
-
var
|
|
25485
|
-
var escapeAttribute = (value) =>
|
|
26195
|
+
var escapeText2 = (value) => value.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
26196
|
+
var escapeAttribute = (value) => escapeText2(value).replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
25486
26197
|
function chartNumber(value) {
|
|
25487
26198
|
if (!Number.isFinite(value)) throw new Error(`Chart number ${value} is not finite`);
|
|
25488
26199
|
const text = String(value);
|
|
@@ -26162,7 +26873,7 @@ function run(value) {
|
|
|
26162
26873
|
const hasProperties = Object.keys(properties).length > 0;
|
|
26163
26874
|
if (text === "\n")
|
|
26164
26875
|
return hasProperties ? `<a:br>${runProperties("rPr", properties)}</a:br>` : "<a:br/>";
|
|
26165
|
-
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${
|
|
26876
|
+
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${escapeText2(text)}</a:t></a:r>`;
|
|
26166
26877
|
}
|
|
26167
26878
|
function paragraph(value) {
|
|
26168
26879
|
const align = value.align ? ` algn="${escapeAttribute(value.align)}"` : "";
|
|
@@ -26282,7 +26993,7 @@ function numberFormatXml(format) {
|
|
|
26282
26993
|
}
|
|
26283
26994
|
|
|
26284
26995
|
// chart/write-text.ts
|
|
26285
|
-
var textElement = (local, value) => `<c:${local}>${
|
|
26996
|
+
var textElement = (local, value) => `<c:${local}>${escapeText2(value)}</c:${local}>`;
|
|
26286
26997
|
function cachePoints(cache) {
|
|
26287
26998
|
return cache.points.map((point, position2) => {
|
|
26288
26999
|
const format = point.formatCode === void 0 ? "" : ` formatCode="${escapeAttribute(point.formatCode)}"`;
|
|
@@ -26412,7 +27123,7 @@ function trendlineLabelXml(context, label) {
|
|
|
26412
27123
|
function trendlineXml(context, trendline) {
|
|
26413
27124
|
return elementXml(
|
|
26414
27125
|
"trendline",
|
|
26415
|
-
(trendline.name === void 0 ? "" : `<c:name>${
|
|
27126
|
+
(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)
|
|
26416
27127
|
);
|
|
26417
27128
|
}
|
|
26418
27129
|
function errorBarsXml(context, bars) {
|
|
@@ -27157,7 +27868,7 @@ function attributes(entries) {
|
|
|
27157
27868
|
}).join("");
|
|
27158
27869
|
}
|
|
27159
27870
|
var cxElement = (local, content = "", attrs2 = "") => content ? `<cx:${local}${attrs2}>${content}</cx:${local}>` : `<cx:${local}${attrs2}/>`;
|
|
27160
|
-
var cxText = (local, text, attrs2 = "") => text === void 0 ? "" : `<cx:${local}${attrs2}>${
|
|
27871
|
+
var cxText = (local, text, attrs2 = "") => text === void 0 ? "" : `<cx:${local}${attrs2}>${escapeText2(text)}</cx:${local}>`;
|
|
27161
27872
|
var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
|
|
27162
27873
|
var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
|
|
27163
27874
|
var shapeXml = (context, shape) => shape ? cxElement("spPr", shapePropertiesInnerXml(context, shape)) : "";
|
|
@@ -28927,6 +29638,10 @@ var WRAPS = [
|
|
|
28927
29638
|
function parsePlacement(anchor) {
|
|
28928
29639
|
const wrap2 = WRAPS.find(([local]) => firstNS(anchor, WP_NS2, local))?.[1] ?? "none";
|
|
28929
29640
|
const placement = { wrap: wrap2 };
|
|
29641
|
+
const wrapElement2 = WRAPS.map(([local]) => firstNS(anchor, WP_NS2, local)).find(Boolean);
|
|
29642
|
+
const wrapText = wrapElement2?.getAttribute("wrapText");
|
|
29643
|
+
if (wrapText === "bothSides" || wrapText === "left" || wrapText === "right" || wrapText === "largest")
|
|
29644
|
+
placement.wrapText = wrapText;
|
|
28930
29645
|
if (anchor.getAttribute("behindDoc") === "1") placement.behindText = true;
|
|
28931
29646
|
const positionH = firstNS(anchor, WP_NS2, "positionH");
|
|
28932
29647
|
const relativeFrom = enumValue(
|
|
@@ -29358,6 +30073,34 @@ function chartRun(doc, node, image, base, oldDrawing, oldContainer, allocator) {
|
|
|
29358
30073
|
return void 0;
|
|
29359
30074
|
}
|
|
29360
30075
|
|
|
30076
|
+
// docx/write-fallback.ts
|
|
30077
|
+
var PT_PER_PX2 = 0.75;
|
|
30078
|
+
function setStyleSize(style, name, pt) {
|
|
30079
|
+
const value = `${Math.round(pt * 100) / 100}pt`;
|
|
30080
|
+
const pattern = new RegExp(`(^|;)\\s*${name}\\s*:\\s*[^;]*`, "i");
|
|
30081
|
+
return pattern.test(style) ? style.replace(pattern, (_all, lead) => `${lead}${name}:${value}`) : style;
|
|
30082
|
+
}
|
|
30083
|
+
function patchFallbackSize(content, image, base) {
|
|
30084
|
+
if (!base || image.widthPx === base.widthPx && image.heightPx === base.heightPx) return;
|
|
30085
|
+
const fallback = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Fallback");
|
|
30086
|
+
if (!fallback) return;
|
|
30087
|
+
const stack = [fallback];
|
|
30088
|
+
while (stack.length) {
|
|
30089
|
+
const node = stack.pop();
|
|
30090
|
+
const style = node.getAttribute("style");
|
|
30091
|
+
if (style && /(^|;)\s*width\s*:/i.test(style)) {
|
|
30092
|
+
let next = style;
|
|
30093
|
+
if (image.widthPx !== base.widthPx)
|
|
30094
|
+
next = setStyleSize(next, "width", image.widthPx * PT_PER_PX2);
|
|
30095
|
+
if (image.heightPx !== base.heightPx)
|
|
30096
|
+
next = setStyleSize(next, "height", image.heightPx * PT_PER_PX2);
|
|
30097
|
+
node.setAttribute("style", next);
|
|
30098
|
+
continue;
|
|
30099
|
+
}
|
|
30100
|
+
for (const child7 of Array.from(node.childNodes)) if (isElement(child7)) stack.push(child7);
|
|
30101
|
+
}
|
|
30102
|
+
}
|
|
30103
|
+
|
|
29361
30104
|
// docx/diagram-document.ts
|
|
29362
30105
|
function diagramsIn(blocks) {
|
|
29363
30106
|
const diagrams = [];
|
|
@@ -29981,6 +30724,13 @@ function createImageRun(doc, image, base, old, allocator) {
|
|
|
29981
30724
|
}
|
|
29982
30725
|
if (base && oldDrawing && image.shape?.editable && base.shape?.editable) {
|
|
29983
30726
|
const next = rebuildShapeDrawing(doc, image, oldDrawing);
|
|
30727
|
+
const choice = oldDrawing.parentNode;
|
|
30728
|
+
if (oldContainer?.localName === "AlternateContent" && choice) {
|
|
30729
|
+
choice.replaceChild(next, oldDrawing);
|
|
30730
|
+
patchFallbackSize(oldContainer, image, base);
|
|
30731
|
+
clearNonProperties(node, oldContainer);
|
|
30732
|
+
return node;
|
|
30733
|
+
}
|
|
29984
30734
|
clearNonProperties(node);
|
|
29985
30735
|
node.appendChild(next);
|
|
29986
30736
|
return node;
|
|
@@ -31053,15 +31803,15 @@ function runIsSafe(run2) {
|
|
|
31053
31803
|
const content = Array.from(run2.childNodes).filter(
|
|
31054
31804
|
(child7) => isElement(child7) && !named2(child7, "rPr") && !isCachedPageBreak(child7)
|
|
31055
31805
|
);
|
|
31056
|
-
const
|
|
31057
|
-
if (
|
|
31058
|
-
if (
|
|
31059
|
-
(name) => named2(
|
|
31806
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
31807
|
+
if (only2 && named2(only2, "br") && isModeledBreak(only2)) return true;
|
|
31808
|
+
if (only2 && ["footnoteReference", "endnoteReference", "footnoteRef", "endnoteRef"].some(
|
|
31809
|
+
(name) => named2(only2, name)
|
|
31060
31810
|
))
|
|
31061
31811
|
return true;
|
|
31062
|
-
if (
|
|
31063
|
-
const type = getW(
|
|
31064
|
-
const data = Array.from(
|
|
31812
|
+
if (only2 && named2(only2, "fldChar")) {
|
|
31813
|
+
const type = getW(only2, "fldCharType") ?? "";
|
|
31814
|
+
const data = Array.from(only2.childNodes).filter(
|
|
31065
31815
|
(node) => isElement(node) || Boolean(node.textContent?.trim())
|
|
31066
31816
|
);
|
|
31067
31817
|
if (!data.length) return ["begin", "separate", "end"].includes(type);
|
|
@@ -31193,6 +31943,10 @@ function parseDirectParagraphProperties(props) {
|
|
|
31193
31943
|
const line2 = signedTwipValue2(getW(spacing2, "line"));
|
|
31194
31944
|
if (before !== void 0) paragraph2.spacingBeforeTwips = before;
|
|
31195
31945
|
if (after !== void 0) paragraph2.spacingAfterTwips = after;
|
|
31946
|
+
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
31947
|
+
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
31948
|
+
if (beforeAuto !== void 0) paragraph2.spacingBeforeAuto = beforeAuto;
|
|
31949
|
+
if (afterAuto !== void 0) paragraph2.spacingAfterAuto = afterAuto;
|
|
31196
31950
|
if (line2 !== void 0) {
|
|
31197
31951
|
paragraph2.lineSpacingTwips = line2;
|
|
31198
31952
|
}
|
|
@@ -31224,8 +31978,8 @@ function parseDirectParagraphProperties(props) {
|
|
|
31224
31978
|
|
|
31225
31979
|
// docx/run-segmentation.ts
|
|
31226
31980
|
var basisOf = (run2) => run2.restoredRunPropertiesXml ?? run2.sourceRunPropertiesXml;
|
|
31227
|
-
function keepsUnmodeledProperties(before, after) {
|
|
31228
|
-
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () =>
|
|
31981
|
+
function keepsUnmodeledProperties(before, after, basis = basisOf) {
|
|
31982
|
+
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () => basis(run2)));
|
|
31229
31983
|
const was = owners(before);
|
|
31230
31984
|
const now = owners(after);
|
|
31231
31985
|
const kept = (from, to, shift) => {
|
|
@@ -31259,13 +32013,22 @@ function runsToWriteAnew(paragraph2, base, slots) {
|
|
|
31259
32013
|
return !remaining.length || remaining.every((run2) => run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml);
|
|
31260
32014
|
}))
|
|
31261
32015
|
return none;
|
|
31262
|
-
if (paragraph2.runs.every(
|
|
31263
|
-
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
31264
|
-
))
|
|
31265
|
-
return none;
|
|
31266
32016
|
const sameText = paragraph2.runs.map((run2) => run2.text).join("") === base.runs.map((run2) => run2.text).join("");
|
|
31267
32017
|
const sameBoundaries = paragraph2.runs.length === base.runs.length && paragraph2.runs.every((run2, index) => run2.text === base.runs[index]?.text);
|
|
31268
32018
|
if (sameBoundaries || !sameText && paragraph2.runs.length === base.runs.length) return none;
|
|
32019
|
+
if (paragraph2.runs.every(
|
|
32020
|
+
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
32021
|
+
)) {
|
|
32022
|
+
if (keepsUnmodeledProperties(
|
|
32023
|
+
base.runs,
|
|
32024
|
+
paragraph2.runs,
|
|
32025
|
+
(run2) => run2.sourceRunPropertiesXml ?? run2.restoredRunPropertiesXml
|
|
32026
|
+
))
|
|
32027
|
+
return none;
|
|
32028
|
+
throw new Error(
|
|
32029
|
+
`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.`
|
|
32030
|
+
);
|
|
32031
|
+
}
|
|
31269
32032
|
const object = (run2) => Boolean(run2.image || run2.equation);
|
|
31270
32033
|
if (!paragraph2.runs.some(object) && !base.runs.some(object) && keepsUnmodeledProperties(base.runs, paragraph2.runs))
|
|
31271
32034
|
return new Set(
|
|
@@ -32402,14 +33165,14 @@ async function applyNumberingCatalog(zip, model, binding) {
|
|
|
32402
33165
|
}
|
|
32403
33166
|
|
|
32404
33167
|
// docx/style-numbering-package.ts
|
|
32405
|
-
var
|
|
32406
|
-
var
|
|
33168
|
+
var STYLES_PART2 = "word/styles.xml";
|
|
33169
|
+
var AFTER_PPR2 = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
32407
33170
|
var withoutNumbering = (catalog) => catalog ? {
|
|
32408
33171
|
...catalog,
|
|
32409
33172
|
styles: Object.fromEntries(
|
|
32410
33173
|
Object.entries(catalog.styles).map(([id, style]) => {
|
|
32411
|
-
const { numbering: _numbering, ...rest } = style;
|
|
32412
|
-
return [id, rest];
|
|
33174
|
+
const { numbering: _numbering, formatting, ...rest } = style;
|
|
33175
|
+
return [id, { ...rest, formatting: unwritableFormatting(formatting) }];
|
|
32413
33176
|
})
|
|
32414
33177
|
)
|
|
32415
33178
|
} : void 0;
|
|
@@ -32422,7 +33185,7 @@ function setNumPr(style, numbering) {
|
|
|
32422
33185
|
if (!numbering && !pPr) return;
|
|
32423
33186
|
if (!pPr) {
|
|
32424
33187
|
pPr = makeW(doc, "pPr");
|
|
32425
|
-
const anchor = elementsOf2(style).find((child7) =>
|
|
33188
|
+
const anchor = elementsOf2(style).find((child7) => AFTER_PPR2.includes(child7.localName)) ?? null;
|
|
32426
33189
|
style.insertBefore(pPr, anchor);
|
|
32427
33190
|
}
|
|
32428
33191
|
for (const existing of children2(pPr, "numPr")) pPr.removeChild(existing);
|
|
@@ -32446,7 +33209,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
32446
33209
|
(id) => JSON.stringify(next[id]?.numbering) !== JSON.stringify(prior[id]?.numbering)
|
|
32447
33210
|
);
|
|
32448
33211
|
if (!changed.length) return;
|
|
32449
|
-
const file = zip.file(
|
|
33212
|
+
const file = zip.file(STYLES_PART2);
|
|
32450
33213
|
if (!file) throw new Error("Cannot link styles to a list: the package has no styles.xml.");
|
|
32451
33214
|
const doc = parseXml2(await file.async("string"));
|
|
32452
33215
|
const styles = children2(doc.documentElement, "style");
|
|
@@ -32457,7 +33220,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
32457
33220
|
if (!style) throw new Error(`Cannot link style "${id}" to a list: it is not in styles.xml.`);
|
|
32458
33221
|
setNumPr(style, next[id]?.numbering);
|
|
32459
33222
|
}
|
|
32460
|
-
zip.file(
|
|
33223
|
+
zip.file(STYLES_PART2, buildXml(doc));
|
|
32461
33224
|
}
|
|
32462
33225
|
|
|
32463
33226
|
// docx/write-header-footer.ts
|
|
@@ -33850,7 +34613,7 @@ function headerFooterResults(model) {
|
|
|
33850
34613
|
return void 0;
|
|
33851
34614
|
}
|
|
33852
34615
|
}
|
|
33853
|
-
async function saveDocx(model, pendingMedia) {
|
|
34616
|
+
async function saveDocx(model, pendingMedia, options) {
|
|
33854
34617
|
const ids = /* @__PURE__ */ new Set();
|
|
33855
34618
|
for (const block of model.blocks) {
|
|
33856
34619
|
if (ids.has(block.id)) throw new Error(`Duplicate document block id: ${block.id}`);
|
|
@@ -33941,6 +34704,7 @@ async function saveDocx(model, pendingMedia) {
|
|
|
33941
34704
|
await applyNumberingCatalog(zip, model, binding);
|
|
33942
34705
|
await applyCoreProperties(zip, model.properties, binding?.base.properties);
|
|
33943
34706
|
if (binding) await applyStyleNumbering(zip, model, binding.base);
|
|
34707
|
+
if (binding) await applyStyleFormatting(zip, model, binding.base);
|
|
33944
34708
|
if (model.compatibilityMode !== binding?.base.compatibilityMode)
|
|
33945
34709
|
await applyCompatibilityMode(zip, model.compatibilityMode);
|
|
33946
34710
|
if (Boolean(model.evenAndOddHeaders) !== Boolean(binding?.base.evenAndOddHeaders))
|
|
@@ -33972,6 +34736,8 @@ async function saveDocx(model, pendingMedia) {
|
|
|
33972
34736
|
}
|
|
33973
34737
|
if (JSON.stringify(model.comments ?? []) !== JSON.stringify(binding?.base.comments ?? []))
|
|
33974
34738
|
await applyComments(zip, model.comments ?? []);
|
|
34739
|
+
if (binding) await applyDataBindings(zip, model, binding.base, binding.context.sourceXml);
|
|
34740
|
+
if (binding) await stampModified(zip, options?.modified);
|
|
33975
34741
|
dropAddedFolders(zip, sourceEntries);
|
|
33976
34742
|
return zip.generateAsync({ type: "uint8array", compression: "DEFLATE" });
|
|
33977
34743
|
}
|
|
@@ -34027,8 +34793,11 @@ function parseCell(cell2, parseParagraph3, id, control) {
|
|
|
34027
34793
|
const element4 = child7;
|
|
34028
34794
|
if (element4.namespaceURI !== WORD_NS) return [];
|
|
34029
34795
|
if (element4.localName === "p") return [result.paragraphs[paragraphIndex++]];
|
|
34030
|
-
if (element4.localName === "tbl")
|
|
34031
|
-
|
|
34796
|
+
if (element4.localName === "tbl") {
|
|
34797
|
+
const inner = parseTable(element4, `${id}-nested${tableIndex++}`, parseParagraph3);
|
|
34798
|
+
markRestructurable(inner, element4);
|
|
34799
|
+
return [inner];
|
|
34800
|
+
}
|
|
34032
34801
|
return [];
|
|
34033
34802
|
}
|
|
34034
34803
|
);
|
|
@@ -34084,6 +34853,9 @@ function parseRowProperties(row) {
|
|
|
34084
34853
|
if (onOffElement(first2(trPr, "tblHeader"))) result.header = true;
|
|
34085
34854
|
return result;
|
|
34086
34855
|
}
|
|
34856
|
+
function markRestructurable(table, node) {
|
|
34857
|
+
if (canRestructureTable(node) && tableGrid(table)) table.restructurable = true;
|
|
34858
|
+
}
|
|
34087
34859
|
function parseTable(node, id, parseParagraph3) {
|
|
34088
34860
|
const rowEntries = flatRows(node);
|
|
34089
34861
|
const rows = rowEntries.map(
|
|
@@ -34124,6 +34896,7 @@ function parseTable(node, id, parseParagraph3) {
|
|
|
34124
34896
|
return properties;
|
|
34125
34897
|
});
|
|
34126
34898
|
if (rowProperties.some((row) => Object.keys(row).length)) table.rowProperties = rowProperties;
|
|
34899
|
+
if (!table.structureEditable) markRestructurable(table, node);
|
|
34127
34900
|
return table;
|
|
34128
34901
|
}
|
|
34129
34902
|
|
|
@@ -34257,23 +35030,23 @@ function parseRun2(node, revision) {
|
|
|
34257
35030
|
let noteSeparator;
|
|
34258
35031
|
let fieldChar;
|
|
34259
35032
|
const fieldCode = content.length > 0 && content.every((child7) => named2(child7, "instrText")) ? content.map((child7) => textContent(child7)).join("") : void 0;
|
|
34260
|
-
const
|
|
34261
|
-
if (
|
|
34262
|
-
if (named2(
|
|
34263
|
-
const kind = classifyBreak(
|
|
35033
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
35034
|
+
if (only2) {
|
|
35035
|
+
if (named2(only2, "br")) {
|
|
35036
|
+
const kind = classifyBreak(only2);
|
|
34264
35037
|
if (kind === "page" || kind === "column") breakKind = kind;
|
|
34265
|
-
} else if (named2(
|
|
34266
|
-
const id = getW(
|
|
35038
|
+
} else if (named2(only2, "footnoteReference")) {
|
|
35039
|
+
const id = getW(only2, "id");
|
|
34267
35040
|
if (id) noteReference = { kind: "footnote", id };
|
|
34268
|
-
} else if (named2(
|
|
34269
|
-
const id = getW(
|
|
35041
|
+
} else if (named2(only2, "endnoteReference")) {
|
|
35042
|
+
const id = getW(only2, "id");
|
|
34270
35043
|
if (id) noteReference = { kind: "endnote", id };
|
|
34271
|
-
} else if (named2(
|
|
34272
|
-
else if (named2(
|
|
34273
|
-
else if (named2(
|
|
34274
|
-
else if (named2(
|
|
34275
|
-
else if (named2(
|
|
34276
|
-
const type = getW(
|
|
35044
|
+
} else if (named2(only2, "footnoteRef")) noteMark = "footnote";
|
|
35045
|
+
else if (named2(only2, "endnoteRef")) noteMark = "endnote";
|
|
35046
|
+
else if (named2(only2, "separator")) noteSeparator = "separator";
|
|
35047
|
+
else if (named2(only2, "continuationSeparator")) noteSeparator = "continuationSeparator";
|
|
35048
|
+
else if (named2(only2, "fldChar")) {
|
|
35049
|
+
const type = getW(only2, "fldCharType");
|
|
34277
35050
|
if (type === "begin" || type === "separate" || type === "end") fieldChar = type;
|
|
34278
35051
|
}
|
|
34279
35052
|
}
|
|
@@ -34295,9 +35068,9 @@ function parseRun2(node, revision) {
|
|
|
34295
35068
|
if (noteSeparator) run2.noteSeparator = noteSeparator;
|
|
34296
35069
|
if (fieldChar) {
|
|
34297
35070
|
run2.fieldChar = fieldChar;
|
|
34298
|
-
const flags = parseFieldFlags(
|
|
35071
|
+
const flags = parseFieldFlags(only2);
|
|
34299
35072
|
if (flags) run2.fieldFlags = flags;
|
|
34300
|
-
const data = fieldChar === "begin" ? first2(
|
|
35073
|
+
const data = fieldChar === "begin" ? first2(only2, "ffData") : void 0;
|
|
34301
35074
|
const formField = data && parseFormField(data);
|
|
34302
35075
|
if (formField) run2.formField = formField;
|
|
34303
35076
|
}
|
|
@@ -34637,6 +35410,7 @@ function parseSettings(xml) {
|
|
|
34637
35410
|
);
|
|
34638
35411
|
return {
|
|
34639
35412
|
...compatibilityMode !== void 0 && Number.isInteger(compatibilityMode) && compatibilityMode > 0 ? { compatibilityMode } : {},
|
|
35413
|
+
...onOffElement(first2(first2(root, "compat"), "doNotUseHTMLParagraphAutoSpacing")) === true ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
34640
35414
|
evenAndOddHeaders: onOffElement(first2(root, "evenAndOddHeaders")) === true,
|
|
34641
35415
|
autoHyphenation: onOffElement(first2(root, "autoHyphenation")) === true,
|
|
34642
35416
|
...footnoteNumFmt ? { footnoteNumFmt } : {},
|
|
@@ -34717,6 +35491,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
34717
35491
|
return {
|
|
34718
35492
|
sections,
|
|
34719
35493
|
...settings.compatibilityMode !== void 0 ? { compatibilityMode: settings.compatibilityMode } : {},
|
|
35494
|
+
...settings.doNotUseHtmlParagraphAutoSpacing ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
34720
35495
|
...footnotes ? { footnotes } : {},
|
|
34721
35496
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
34722
35497
|
...endnotes ? { endnotes } : {},
|
|
@@ -34959,6 +35734,7 @@ async function readPackage(input) {
|
|
|
34959
35734
|
const parts = await parseDocumentParts(zip, body, blocks, drawings);
|
|
34960
35735
|
model.sections = parts.sections;
|
|
34961
35736
|
if (parts.compatibilityMode !== void 0) model.compatibilityMode = parts.compatibilityMode;
|
|
35737
|
+
if (parts.doNotUseHtmlParagraphAutoSpacing) model.doNotUseHtmlParagraphAutoSpacing = true;
|
|
34962
35738
|
if (parts.footnotes) model.footnotes = parts.footnotes;
|
|
34963
35739
|
if (parts.footnoteSeparators) model.footnoteSeparators = parts.footnoteSeparators;
|
|
34964
35740
|
if (parts.endnotes) model.endnotes = parts.endnotes;
|
|
@@ -34968,14 +35744,16 @@ async function readPackage(input) {
|
|
|
34968
35744
|
if (parts.autoHyphenation) model.autoHyphenation = true;
|
|
34969
35745
|
const coreFile = zip.file("docProps/core.xml");
|
|
34970
35746
|
if (coreFile) {
|
|
34971
|
-
const properties =
|
|
35747
|
+
const properties = parseCoreProperties2(await coreFile.async("string"));
|
|
34972
35748
|
if (properties) model.properties = properties;
|
|
34973
35749
|
}
|
|
34974
35750
|
await readPlaceholderTexts(zip, drawings.rels, model);
|
|
34975
35751
|
const pageColor = parsePageBackground(document.documentElement);
|
|
34976
35752
|
if (pageColor) model.pageColor = pageColor;
|
|
34977
35753
|
model.warnings.push(...parts.warnings);
|
|
34978
|
-
if (blocks.some(
|
|
35754
|
+
if (blocks.some(
|
|
35755
|
+
(block) => block.type === "table" && !block.structureEditable && !block.restructurable
|
|
35756
|
+
))
|
|
34979
35757
|
model.warnings.push(
|
|
34980
35758
|
"Merged, nested, or complex tables can be read, but their row and column structure cannot be edited safely."
|
|
34981
35759
|
);
|
|
@@ -35001,7 +35779,7 @@ async function readPackage(input) {
|
|
|
35001
35779
|
(block) => block.type === "table" && block.rows.some((row) => row.some((cell2) => cell2.nestedTables?.length))
|
|
35002
35780
|
))
|
|
35003
35781
|
model.warnings.push(
|
|
35004
|
-
"Text
|
|
35782
|
+
"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."
|
|
35005
35783
|
);
|
|
35006
35784
|
const pictureBlocks = documentDrawingBlocks({ ...model, blocks });
|
|
35007
35785
|
await resolveDocumentDiagrams(
|
|
@@ -35039,9 +35817,9 @@ async function loadDocx(input) {
|
|
|
35039
35817
|
return {
|
|
35040
35818
|
model,
|
|
35041
35819
|
media,
|
|
35042
|
-
save: (next = model, pendingMedia) => {
|
|
35820
|
+
save: (next = model, pendingMedia, options) => {
|
|
35043
35821
|
if (next !== model) remember(next, context);
|
|
35044
|
-
return saveDocx(next, pendingMedia);
|
|
35822
|
+
return saveDocx(next, pendingMedia, options);
|
|
35045
35823
|
}
|
|
35046
35824
|
};
|
|
35047
35825
|
}
|