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.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import JSZip from 'jszip';
|
|
|
5
5
|
var NS = {
|
|
6
6
|
/** WordprocessingML main. */
|
|
7
7
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
8
|
+
/** PresentationML main. */
|
|
9
|
+
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
8
10
|
/** SpreadsheetML main. */
|
|
9
11
|
x: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
|
|
10
12
|
/** DrawingML main. */
|
|
@@ -19,6 +21,12 @@ var NS = {
|
|
|
19
21
|
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
20
22
|
/** Office 2007+ diagram drawing (`dsp`). */
|
|
21
23
|
dsp: "http://schemas.microsoft.com/office/drawing/2008/diagram",
|
|
24
|
+
/** DrawingML Word drawing (`wp:inline`, `wp:anchor`). */
|
|
25
|
+
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
26
|
+
/** DrawingML picture. */
|
|
27
|
+
pic: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
28
|
+
/** Word 2010 shapes (`wps`). */
|
|
29
|
+
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
|
22
30
|
/** Relationships (`r:id`, `r:embed`). */
|
|
23
31
|
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
24
32
|
/** Markup compatibility (`mc:AlternateContent`). */
|
|
@@ -26,7 +34,42 @@ var NS = {
|
|
|
26
34
|
/** OPC relationships part. */
|
|
27
35
|
rels: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
28
36
|
/** OPC content types part. */
|
|
29
|
-
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
37
|
+
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
38
|
+
/** Office Math. */
|
|
39
|
+
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
40
|
+
/** Core properties. */
|
|
41
|
+
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
42
|
+
/** Dublin Core elements. */
|
|
43
|
+
dc: "http://purl.org/dc/elements/1.1/",
|
|
44
|
+
/** Legacy VML. */
|
|
45
|
+
v: "urn:schemas-microsoft-com:vml",
|
|
46
|
+
/** Office VML extensions. */
|
|
47
|
+
o: "urn:schemas-microsoft-com:office:office",
|
|
48
|
+
/** Word VML extensions. */
|
|
49
|
+
w10: "urn:schemas-microsoft-com:office:word",
|
|
50
|
+
/** SpreadsheetML drawing (`xdr:wsDr`, cell anchors). */
|
|
51
|
+
xdr: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
|
|
52
|
+
/** SpreadsheetML 2009 extensions (`x14:conditionalFormatting`, `x14:dataBar`). */
|
|
53
|
+
x14: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
54
|
+
/** SpreadsheetML 2009 attribute extensions (`x14ac:dyDescent`). */
|
|
55
|
+
x14ac: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac",
|
|
56
|
+
/** SpreadsheetML revision ids (`xr:uid`). */
|
|
57
|
+
xr: "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
|
|
58
|
+
/** Excel threaded comments and persons. */
|
|
59
|
+
tc: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
|
|
60
|
+
/** Legacy VML Excel client data (`x:ClientData`). */
|
|
61
|
+
xv: "urn:schemas-microsoft-com:office:excel",
|
|
62
|
+
/** Extended (app) properties. */
|
|
63
|
+
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
|
|
64
|
+
/** Dublin Core terms (`dcterms:created`). */
|
|
65
|
+
dcterms: "http://purl.org/dc/terms/",
|
|
66
|
+
/** Custom document properties (`docProps/custom.xml`). */
|
|
67
|
+
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
|
68
|
+
/** Document property variant types (`vt:lpwstr`, `vt:vector`). */
|
|
69
|
+
vt: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
70
|
+
/** XML itself (`xml:space`). */
|
|
71
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
72
|
+
};
|
|
30
73
|
var DEFAULT_XML_LIMITS = {
|
|
31
74
|
maxDepth: 512,
|
|
32
75
|
maxNodes: 5e6
|
|
@@ -787,6 +830,10 @@ function parseFormatting(pPr) {
|
|
|
787
830
|
const line2 = signedTwipValue(getW(spacing2, "line"));
|
|
788
831
|
if (before !== void 0) result.spacingBeforeTwips = before;
|
|
789
832
|
if (after !== void 0) result.spacingAfterTwips = after;
|
|
833
|
+
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
834
|
+
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
835
|
+
if (beforeAuto !== void 0) result.spacingBeforeAuto = beforeAuto;
|
|
836
|
+
if (afterAuto !== void 0) result.spacingAfterAuto = afterAuto;
|
|
790
837
|
if (line2 !== void 0) result.lineSpacingTwips = line2;
|
|
791
838
|
const rule = getW(spacing2, "lineRule");
|
|
792
839
|
if (rule === "auto" || rule === "exact" || rule === "atLeast") result.lineSpacingRule = rule;
|
|
@@ -1586,7 +1633,7 @@ function applyPictureEffects(blip, effects) {
|
|
|
1586
1633
|
const node = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
1587
1634
|
if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
|
|
1588
1635
|
throw new Error("Picture effect source does not match its kind");
|
|
1589
|
-
const
|
|
1636
|
+
const set2 = (name2, value) => {
|
|
1590
1637
|
const original = picturePercentage(node.getAttribute(name2));
|
|
1591
1638
|
if (value === void 0) node.removeAttribute(name2);
|
|
1592
1639
|
else if (value !== original) {
|
|
@@ -1599,12 +1646,12 @@ function applyPictureEffects(blip, effects) {
|
|
|
1599
1646
|
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
1600
1647
|
))
|
|
1601
1648
|
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
1602
|
-
|
|
1603
|
-
|
|
1649
|
+
set2("bright", effect.brightness);
|
|
1650
|
+
set2("contrast", effect.contrast);
|
|
1604
1651
|
}
|
|
1605
1652
|
if (effect.kind === "alphaModFix") {
|
|
1606
1653
|
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
1607
|
-
|
|
1654
|
+
set2("amt", effect.amount);
|
|
1608
1655
|
}
|
|
1609
1656
|
return node;
|
|
1610
1657
|
});
|
|
@@ -2917,6 +2964,233 @@ async function openZip(input, limits = {}) {
|
|
|
2917
2964
|
return guardZip(await JSZip.loadAsync(bytes), limits);
|
|
2918
2965
|
}
|
|
2919
2966
|
|
|
2967
|
+
// opc/properties/patch.ts
|
|
2968
|
+
var XMLNS3 = "http://www.w3.org/2000/xmlns/";
|
|
2969
|
+
function tagEnd(xml, from) {
|
|
2970
|
+
let quote = "";
|
|
2971
|
+
for (let i = from + 1; i < xml.length; i++) {
|
|
2972
|
+
const ch = xml[i];
|
|
2973
|
+
if (quote) {
|
|
2974
|
+
if (ch === quote) quote = "";
|
|
2975
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
2976
|
+
else if (ch === ">") return i + 1;
|
|
2977
|
+
}
|
|
2978
|
+
throw new Error("Unterminated tag in property part");
|
|
2979
|
+
}
|
|
2980
|
+
function skipMarkup(xml, at) {
|
|
2981
|
+
if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
|
|
2982
|
+
if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
|
|
2983
|
+
if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
|
|
2984
|
+
return void 0;
|
|
2985
|
+
}
|
|
2986
|
+
function scan(xml) {
|
|
2987
|
+
let i = 0;
|
|
2988
|
+
let rootStart = -1;
|
|
2989
|
+
while (rootStart < 0) {
|
|
2990
|
+
const lt = xml.indexOf("<", i);
|
|
2991
|
+
if (lt < 0) throw new Error("Property part has no root element");
|
|
2992
|
+
const skipped = skipMarkup(xml, lt);
|
|
2993
|
+
if (skipped !== void 0) i = skipped;
|
|
2994
|
+
else rootStart = lt;
|
|
2995
|
+
}
|
|
2996
|
+
const openEnd = tagEnd(xml, rootStart);
|
|
2997
|
+
if (xml[openEnd - 2] === "/") {
|
|
2998
|
+
const root = {
|
|
2999
|
+
start: rootStart,
|
|
3000
|
+
openEnd,
|
|
3001
|
+
closeStart: openEnd,
|
|
3002
|
+
end: openEnd,
|
|
3003
|
+
selfClosing: true
|
|
3004
|
+
};
|
|
3005
|
+
return { root, children: [] };
|
|
3006
|
+
}
|
|
3007
|
+
const children3 = [];
|
|
3008
|
+
let depth = 0;
|
|
3009
|
+
let child7;
|
|
3010
|
+
i = openEnd;
|
|
3011
|
+
for (; ; ) {
|
|
3012
|
+
const lt = xml.indexOf("<", i);
|
|
3013
|
+
if (lt < 0) throw new Error("Property part root is not closed");
|
|
3014
|
+
const skipped = skipMarkup(xml, lt);
|
|
3015
|
+
if (skipped !== void 0) {
|
|
3016
|
+
i = skipped;
|
|
3017
|
+
continue;
|
|
3018
|
+
}
|
|
3019
|
+
const end = tagEnd(xml, lt);
|
|
3020
|
+
i = end;
|
|
3021
|
+
if (xml[lt + 1] === "/") {
|
|
3022
|
+
if (depth === 0) {
|
|
3023
|
+
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
3024
|
+
return { root, children: children3 };
|
|
3025
|
+
}
|
|
3026
|
+
depth--;
|
|
3027
|
+
if (depth === 0 && child7)
|
|
3028
|
+
children3.push({ ...child7, closeStart: lt, end, selfClosing: false });
|
|
3029
|
+
} else if (xml[end - 2] === "/") {
|
|
3030
|
+
if (depth === 0)
|
|
3031
|
+
children3.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
3032
|
+
} else {
|
|
3033
|
+
if (depth === 0) child7 = { start: lt, openEnd: end };
|
|
3034
|
+
depth++;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
var escapeText = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
3039
|
+
var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
3040
|
+
var PartPatch = class {
|
|
3041
|
+
constructor(xml, rootElement) {
|
|
3042
|
+
this.xml = xml;
|
|
3043
|
+
const { root, children: children3 } = scan(xml);
|
|
3044
|
+
const kids = elements(rootElement);
|
|
3045
|
+
if (kids.length !== children3.length) throw new Error("Property part markup is not supported");
|
|
3046
|
+
kids.forEach((kid, index) => this.spans.set(kid, children3[index]));
|
|
3047
|
+
this.root = root;
|
|
3048
|
+
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
3049
|
+
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
3050
|
+
else if (attribute2.namespaceURI === XMLNS3 || attribute2.name.startsWith("xmlns:"))
|
|
3051
|
+
this.prefixes.set(attribute2.value, attribute2.localName);
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
xml;
|
|
3055
|
+
root;
|
|
3056
|
+
spans = /* @__PURE__ */ new Map();
|
|
3057
|
+
edits = [];
|
|
3058
|
+
appended = [];
|
|
3059
|
+
prefixes = /* @__PURE__ */ new Map();
|
|
3060
|
+
defaultNs = null;
|
|
3061
|
+
seq = 0;
|
|
3062
|
+
add(start, end, text) {
|
|
3063
|
+
this.edits.push({ start, end, text, seq: this.seq++ });
|
|
3064
|
+
}
|
|
3065
|
+
span(element4) {
|
|
3066
|
+
const span = this.spans.get(element4);
|
|
3067
|
+
if (!span) throw new Error("Element is not a child of the patched root");
|
|
3068
|
+
return span;
|
|
3069
|
+
}
|
|
3070
|
+
/** The prefix bound to `ns` on the root, declaring `preferred` for it when none is. */
|
|
3071
|
+
prefix(ns, preferred) {
|
|
3072
|
+
const known = this.prefixes.get(ns);
|
|
3073
|
+
if (known !== void 0) return known;
|
|
3074
|
+
const taken = new Set(this.prefixes.values());
|
|
3075
|
+
let prefix2 = preferred;
|
|
3076
|
+
for (let n = 1; taken.has(prefix2); n++) prefix2 = `${preferred}${n}`;
|
|
3077
|
+
this.prefixes.set(ns, prefix2);
|
|
3078
|
+
const at = this.root.openEnd - (this.root.selfClosing ? 2 : 1);
|
|
3079
|
+
this.add(at, at, ` xmlns:${prefix2}="${ns}"`);
|
|
3080
|
+
return prefix2;
|
|
3081
|
+
}
|
|
3082
|
+
/** `local` qualified for an element in `ns`: unprefixed in the default namespace. */
|
|
3083
|
+
qualify(ns, local, preferred) {
|
|
3084
|
+
return this.defaultNs === ns && !this.prefixes.has(ns) ? local : `${this.prefix(ns, preferred)}:${local}`;
|
|
3085
|
+
}
|
|
3086
|
+
/** Replaces the element's content, keeping its start tag (and attributes) as written. */
|
|
3087
|
+
setContent(element4, content) {
|
|
3088
|
+
const span = this.span(element4);
|
|
3089
|
+
if (span.selfClosing)
|
|
3090
|
+
this.add(span.openEnd - 2, span.openEnd, `>${content}</${qualifiedName(this.xml, span)}>`);
|
|
3091
|
+
else this.add(span.openEnd, span.closeStart, content);
|
|
3092
|
+
}
|
|
3093
|
+
/** Adds ` name="value"` text to the element's start tag. */
|
|
3094
|
+
addAttribute(element4, attribute2) {
|
|
3095
|
+
const span = this.span(element4);
|
|
3096
|
+
const at = span.openEnd - (span.selfClosing ? 2 : 1);
|
|
3097
|
+
this.add(at, at, attribute2);
|
|
3098
|
+
}
|
|
3099
|
+
remove(element4) {
|
|
3100
|
+
const span = this.span(element4);
|
|
3101
|
+
this.add(span.start, span.end, "");
|
|
3102
|
+
}
|
|
3103
|
+
/** Inserts `markup` before `before`, or as the root's last child. */
|
|
3104
|
+
insert(markup, before) {
|
|
3105
|
+
if (before) {
|
|
3106
|
+
const at = this.span(before).start;
|
|
3107
|
+
this.add(at, at, markup);
|
|
3108
|
+
} else this.appended.push(markup);
|
|
3109
|
+
}
|
|
3110
|
+
toString() {
|
|
3111
|
+
const edits = [...this.edits];
|
|
3112
|
+
if (this.appended.length) {
|
|
3113
|
+
const text = this.appended.join("");
|
|
3114
|
+
const root = this.root;
|
|
3115
|
+
if (root.selfClosing) {
|
|
3116
|
+
const name = qualifiedName(this.xml, root);
|
|
3117
|
+
edits.push({
|
|
3118
|
+
start: root.end - 2,
|
|
3119
|
+
end: root.end,
|
|
3120
|
+
text: `>${text}</${name}>`,
|
|
3121
|
+
seq: this.seq
|
|
3122
|
+
});
|
|
3123
|
+
} else edits.push({ start: root.closeStart, end: root.closeStart, text, seq: this.seq });
|
|
3124
|
+
}
|
|
3125
|
+
edits.sort((a2, b) => a2.start - b.start || a2.end - a2.start - (b.end - b.start) || a2.seq - b.seq);
|
|
3126
|
+
let out = "";
|
|
3127
|
+
let at = 0;
|
|
3128
|
+
for (const edit of edits) {
|
|
3129
|
+
out += this.xml.slice(at, edit.start) + edit.text;
|
|
3130
|
+
at = Math.max(at, edit.end);
|
|
3131
|
+
}
|
|
3132
|
+
return out + this.xml.slice(at);
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
|
|
3136
|
+
// opc/properties/core.ts
|
|
3137
|
+
var XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
3138
|
+
var FIELDS = [
|
|
3139
|
+
["title", "dc", false],
|
|
3140
|
+
["subject", "dc", false],
|
|
3141
|
+
["creator", "dc", false],
|
|
3142
|
+
["keywords", "cp", false],
|
|
3143
|
+
["description", "dc", false],
|
|
3144
|
+
["lastModifiedBy", "cp", false],
|
|
3145
|
+
["created", "dcterms", true],
|
|
3146
|
+
["modified", "dcterms", true],
|
|
3147
|
+
["category", "cp", false],
|
|
3148
|
+
["contentStatus", "cp", false],
|
|
3149
|
+
["revision", "cp", false],
|
|
3150
|
+
["language", "dc", false],
|
|
3151
|
+
["identifier", "dc", false],
|
|
3152
|
+
["lastPrinted", "cp", false],
|
|
3153
|
+
["version", "cp", false]
|
|
3154
|
+
];
|
|
3155
|
+
FIELDS.map(([field]) => field);
|
|
3156
|
+
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3157
|
+
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
3158
|
+
function parseCoreProperties(xml) {
|
|
3159
|
+
const out = {};
|
|
3160
|
+
if (!xml) return out;
|
|
3161
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3162
|
+
for (const [field, prefix2] of FIELDS) {
|
|
3163
|
+
const text = first(root, field, NS[prefix2])?.textContent ?? "";
|
|
3164
|
+
if (text !== "") out[field] = text;
|
|
3165
|
+
}
|
|
3166
|
+
return out;
|
|
3167
|
+
}
|
|
3168
|
+
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
3169
|
+
function writeCoreProperties(props, sourceXml) {
|
|
3170
|
+
const xml = sourceXml ?? EMPTY_CORE;
|
|
3171
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
3172
|
+
const patch = new PartPatch(xml, root);
|
|
3173
|
+
for (const [field, prefix2, isDate] of FIELDS) {
|
|
3174
|
+
const ns = NS[prefix2];
|
|
3175
|
+
const value = props[field];
|
|
3176
|
+
const element4 = first(root, field, ns);
|
|
3177
|
+
if (value === void 0 || value === "") {
|
|
3178
|
+
if (element4 && (element4.textContent ?? "") !== "") patch.remove(element4);
|
|
3179
|
+
continue;
|
|
3180
|
+
}
|
|
3181
|
+
if (element4 && element4.textContent === value) continue;
|
|
3182
|
+
const typed = () => ` ${patch.prefix(XSI, "xsi")}:type="${patch.prefix(NS.dcterms, "dcterms")}:W3CDTF"`;
|
|
3183
|
+
if (element4) {
|
|
3184
|
+
if (isDate && !element4.getAttributeNS(XSI, "type")) patch.addAttribute(element4, typed());
|
|
3185
|
+
patch.setContent(element4, escapeText(value));
|
|
3186
|
+
continue;
|
|
3187
|
+
}
|
|
3188
|
+
const name = patch.qualify(ns, field, prefix2);
|
|
3189
|
+
patch.insert(`<${name}${isDate ? typed() : ""}>${escapeText(value)}</${name}>`);
|
|
3190
|
+
}
|
|
3191
|
+
return patch.toString();
|
|
3192
|
+
}
|
|
3193
|
+
|
|
2920
3194
|
// docx/zip-parts.ts
|
|
2921
3195
|
var DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels";
|
|
2922
3196
|
var ensureDocumentRelationship = (zip, type, target) => ensureRelationship(zip, DOCUMENT_RELS_PATH, type, target);
|
|
@@ -2944,7 +3218,7 @@ var PREFIX = {
|
|
|
2944
3218
|
};
|
|
2945
3219
|
var CORE_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
2946
3220
|
var CORE_REL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
|
2947
|
-
function
|
|
3221
|
+
function parseCoreProperties2(xml) {
|
|
2948
3222
|
const root = parseXml2(xml).documentElement;
|
|
2949
3223
|
const result = {};
|
|
2950
3224
|
for (const field of PROPERTY_FIELDS) {
|
|
@@ -3012,265 +3286,18 @@ function dropAddedFolders(zip, source2) {
|
|
|
3012
3286
|
if (entry2.dir && !source2.has(name)) delete zip.files[name];
|
|
3013
3287
|
}
|
|
3014
3288
|
|
|
3015
|
-
// docx/
|
|
3016
|
-
var
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
equation: "equation",
|
|
3027
|
-
citation: "citation",
|
|
3028
|
-
bibliography: "bibliography",
|
|
3029
|
-
docPartObj: "docPartObj",
|
|
3030
|
-
docPartList: "docPartList"
|
|
3031
|
-
};
|
|
3032
|
-
function attrW14(element4, local) {
|
|
3033
|
-
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
3289
|
+
// docx/save-modified.ts
|
|
3290
|
+
var CORE_PATH2 = "docProps/core.xml";
|
|
3291
|
+
async function stampModified(zip, option) {
|
|
3292
|
+
if (!option) return;
|
|
3293
|
+
const file = zip.file(CORE_PATH2);
|
|
3294
|
+
if (!file) return;
|
|
3295
|
+
const source2 = await file.async("string");
|
|
3296
|
+
const props = parseCoreProperties(source2);
|
|
3297
|
+
props.modified = formatW3cdtf(option.at ?? /* @__PURE__ */ new Date());
|
|
3298
|
+
if (option.author) props.lastModifiedBy = option.author;
|
|
3299
|
+
zip.file(CORE_PATH2, writeCoreProperties(props, source2));
|
|
3034
3300
|
}
|
|
3035
|
-
function glyph(element4) {
|
|
3036
|
-
const code = attrW14(element4, "val");
|
|
3037
|
-
if (!code) return void 0;
|
|
3038
|
-
const font = attrW14(element4, "font");
|
|
3039
|
-
return { code, ...font ? { font } : {} };
|
|
3040
|
-
}
|
|
3041
|
-
function kindOf(child7) {
|
|
3042
|
-
if (child7.namespaceURI === WORD_NS)
|
|
3043
|
-
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
3044
|
-
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
3045
|
-
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
3046
|
-
return "repeatingSection";
|
|
3047
|
-
return void 0;
|
|
3048
|
-
}
|
|
3049
|
-
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
3050
|
-
(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"
|
|
3051
|
-
);
|
|
3052
|
-
function parseKind(sdtPr) {
|
|
3053
|
-
const [type] = typeElements(sdtPr);
|
|
3054
|
-
return (type && kindOf(type)) ?? "richText";
|
|
3055
|
-
}
|
|
3056
|
-
var generated = 0;
|
|
3057
|
-
function parseContentControl(sdt, level3) {
|
|
3058
|
-
const sdtPr = first2(sdt, "sdtPr");
|
|
3059
|
-
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level3, kind: "richText" };
|
|
3060
|
-
const kind = parseKind(sdtPr);
|
|
3061
|
-
const control = {
|
|
3062
|
-
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
3063
|
-
level: level3,
|
|
3064
|
-
kind
|
|
3065
|
-
};
|
|
3066
|
-
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
3067
|
-
if (alias !== void 0) control.alias = alias;
|
|
3068
|
-
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
3069
|
-
if (tag !== void 0) control.tag = tag;
|
|
3070
|
-
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
3071
|
-
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
3072
|
-
control.lock = lock;
|
|
3073
|
-
const showing = first2(sdtPr, "showingPlcHdr");
|
|
3074
|
-
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
3075
|
-
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
3076
|
-
const temporary = first2(sdtPr, "temporary");
|
|
3077
|
-
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
3078
|
-
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
3079
|
-
if (placeholder) control.placeholder = placeholder;
|
|
3080
|
-
if (kind === "text") {
|
|
3081
|
-
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
3082
|
-
if (multi) control.multiLine = true;
|
|
3083
|
-
}
|
|
3084
|
-
if (kind === "checkbox") {
|
|
3085
|
-
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
3086
|
-
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
3087
|
-
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
3088
|
-
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
3089
|
-
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
3090
|
-
if (on) control.checkedGlyph = on;
|
|
3091
|
-
if (off) control.uncheckedGlyph = off;
|
|
3092
|
-
}
|
|
3093
|
-
if (kind === "dropDownList" || kind === "comboBox") {
|
|
3094
|
-
const list2 = first2(sdtPr, kind);
|
|
3095
|
-
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
3096
|
-
const display = getW(item2, "displayText");
|
|
3097
|
-
const value = getW(item2, "value") ?? display ?? "";
|
|
3098
|
-
return { display: display ?? value, value };
|
|
3099
|
-
});
|
|
3100
|
-
}
|
|
3101
|
-
if (kind === "date") {
|
|
3102
|
-
const date = first2(sdtPr, "date");
|
|
3103
|
-
const fullDate = getW(date, "fullDate");
|
|
3104
|
-
if (fullDate) control.fullDate = fullDate;
|
|
3105
|
-
const format = getW(first2(date, "dateFormat"), "val");
|
|
3106
|
-
if (format) control.dateFormat = format;
|
|
3107
|
-
const lid = getW(first2(date, "lid"), "val");
|
|
3108
|
-
if (lid) control.dateLocale = lid;
|
|
3109
|
-
}
|
|
3110
|
-
control.sourceXml = buildXml(sdtPr);
|
|
3111
|
-
const end = first2(sdt, "sdtEndPr");
|
|
3112
|
-
if (end) control.endSourceXml = buildXml(end);
|
|
3113
|
-
return control;
|
|
3114
|
-
}
|
|
3115
|
-
|
|
3116
|
-
// docx/expect-defined.ts
|
|
3117
|
-
function expectDefined(value, context) {
|
|
3118
|
-
if (value === void 0 || value === null) {
|
|
3119
|
-
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
3120
|
-
}
|
|
3121
|
-
return value;
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3124
|
-
// docx/parse-revisions.ts
|
|
3125
|
-
var REVISION_WRAPPERS = {
|
|
3126
|
-
ins: "insert",
|
|
3127
|
-
del: "delete",
|
|
3128
|
-
moveFrom: "moveFrom",
|
|
3129
|
-
moveTo: "moveTo"
|
|
3130
|
-
};
|
|
3131
|
-
var MOVE_RANGES = {
|
|
3132
|
-
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
3133
|
-
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
3134
|
-
moveToRangeStart: { kind: "moveTo", start: true },
|
|
3135
|
-
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
3136
|
-
};
|
|
3137
|
-
function trackMoveRange(item2, moves) {
|
|
3138
|
-
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
3139
|
-
const range = MOVE_RANGES[item2.localName ?? ""];
|
|
3140
|
-
if (!range) return false;
|
|
3141
|
-
const id = getW(item2, "id") ?? "";
|
|
3142
|
-
const open = moves[range.kind];
|
|
3143
|
-
if (range.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
3144
|
-
else {
|
|
3145
|
-
const index = open.findIndex((entry2) => entry2.id === id);
|
|
3146
|
-
if (index >= 0) open.splice(index, 1);
|
|
3147
|
-
}
|
|
3148
|
-
return true;
|
|
3149
|
-
}
|
|
3150
|
-
function isCommentReferenceRun(run2) {
|
|
3151
|
-
const content = Array.from(run2.childNodes).filter(
|
|
3152
|
-
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
3153
|
-
);
|
|
3154
|
-
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
3155
|
-
}
|
|
3156
|
-
function revisionFrom(node, kind) {
|
|
3157
|
-
const revision = {
|
|
3158
|
-
kind,
|
|
3159
|
-
author: getW(node, "author") || "Unknown",
|
|
3160
|
-
id: getW(node, "id") ?? "0"
|
|
3161
|
-
};
|
|
3162
|
-
const date = getW(node, "date");
|
|
3163
|
-
if (date) revision.date = date;
|
|
3164
|
-
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
3165
|
-
if (dateUtc) revision.dateUtc = dateUtc;
|
|
3166
|
-
return revision;
|
|
3167
|
-
}
|
|
3168
|
-
function paragraphMarkRevision(pPr) {
|
|
3169
|
-
const rPr = first2(pPr, "rPr");
|
|
3170
|
-
const ins = first2(rPr, "ins");
|
|
3171
|
-
if (ins) return revisionFrom(ins, "insert");
|
|
3172
|
-
const del = first2(rPr, "del");
|
|
3173
|
-
if (del) return revisionFrom(del, "delete");
|
|
3174
|
-
return void 0;
|
|
3175
|
-
}
|
|
3176
|
-
function paragraphFormatRevision(pPr) {
|
|
3177
|
-
const change = first2(pPr, "pPrChange");
|
|
3178
|
-
if (!change) return void 0;
|
|
3179
|
-
const revision = revisionFrom(change, "paragraphChange");
|
|
3180
|
-
const previous = first2(change, "pPr");
|
|
3181
|
-
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
3182
|
-
return revision;
|
|
3183
|
-
}
|
|
3184
|
-
function runFormatRevision(rPr) {
|
|
3185
|
-
const change = first2(rPr, "rPrChange");
|
|
3186
|
-
if (!change) return void 0;
|
|
3187
|
-
const revision = revisionFrom(change, "formatChange");
|
|
3188
|
-
const previous = first2(change, "rPr");
|
|
3189
|
-
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
3190
|
-
return revision;
|
|
3191
|
-
}
|
|
3192
|
-
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
3193
|
-
const runs = [];
|
|
3194
|
-
let hasMove = false;
|
|
3195
|
-
const push = (run2) => {
|
|
3196
|
-
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
3197
|
-
runs.push(run2);
|
|
3198
|
-
};
|
|
3199
|
-
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
3200
|
-
if (named2(item2, "r")) {
|
|
3201
|
-
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
3202
|
-
} else if (named2(item2, "hyperlink")) {
|
|
3203
|
-
const link = resolveLink?.(item2);
|
|
3204
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
3205
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
3206
|
-
if (link) parsed.link = link;
|
|
3207
|
-
push(parsed);
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
3211
|
-
const kind = expectDefined(
|
|
3212
|
-
REVISION_WRAPPERS[item2.localName],
|
|
3213
|
-
`revision wrapper ${item2.localName}`
|
|
3214
|
-
);
|
|
3215
|
-
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
3216
|
-
const revision = revisionFrom(item2, kind);
|
|
3217
|
-
const range = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
3218
|
-
if (range) revision.move = { name: range.name, rangeId: range.id };
|
|
3219
|
-
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
3220
|
-
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
3221
|
-
parsed.revision = revision;
|
|
3222
|
-
push(parsed);
|
|
3223
|
-
}
|
|
3224
|
-
}
|
|
3225
|
-
} else if (trackMoveRange(item2, moves)) {
|
|
3226
|
-
continue;
|
|
3227
|
-
} else if (named2(item2, "commentRangeStart")) {
|
|
3228
|
-
const id = getW(item2, "id");
|
|
3229
|
-
if (id !== void 0) active.push(id);
|
|
3230
|
-
} else if (named2(item2, "commentRangeEnd")) {
|
|
3231
|
-
const id = getW(item2, "id");
|
|
3232
|
-
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
3233
|
-
if (index >= 0) active.splice(index, 1);
|
|
3234
|
-
} else {
|
|
3235
|
-
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
return { runs, hasMove };
|
|
3239
|
-
}
|
|
3240
|
-
|
|
3241
|
-
// docx/parse-content-control.ts
|
|
3242
|
-
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
3243
|
-
const control = parseContentControl(sdt, "inline");
|
|
3244
|
-
const content = sdtContent(sdt);
|
|
3245
|
-
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
3246
|
-
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
3247
|
-
for (const run2 of runs) run2.contentControl ??= control;
|
|
3248
|
-
return runs;
|
|
3249
|
-
}
|
|
3250
|
-
function flatChildren(parent, names, level3 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
3251
|
-
const found = [];
|
|
3252
|
-
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
3253
|
-
if (isSdt(child7)) {
|
|
3254
|
-
const content = sdtContent(child7);
|
|
3255
|
-
if (!content) continue;
|
|
3256
|
-
let control = controls.get(child7);
|
|
3257
|
-
if (!control) {
|
|
3258
|
-
control = parseContentControl(child7, level3);
|
|
3259
|
-
controls.set(child7, control);
|
|
3260
|
-
}
|
|
3261
|
-
found.push(...flatChildren(content, names, level3, { control, sdt: child7 }, controls));
|
|
3262
|
-
} else if (names.some((name) => named2(child7, name)))
|
|
3263
|
-
found.push({
|
|
3264
|
-
element: child7,
|
|
3265
|
-
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
3266
|
-
});
|
|
3267
|
-
}
|
|
3268
|
-
return found;
|
|
3269
|
-
}
|
|
3270
|
-
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
3271
|
-
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
3272
|
-
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
3273
|
-
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
3274
3301
|
|
|
3275
3302
|
// docx/element-order.ts
|
|
3276
3303
|
var RPR_ORDER = [
|
|
@@ -3359,6 +3386,720 @@ function orderSectionProperties(sectPr) {
|
|
|
3359
3386
|
orderChildren(sectPr, SECTPR_ORDER);
|
|
3360
3387
|
}
|
|
3361
3388
|
|
|
3389
|
+
// docx/tab-stops.ts
|
|
3390
|
+
function parseTabStops(tabs) {
|
|
3391
|
+
const stops = [];
|
|
3392
|
+
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
3393
|
+
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
3394
|
+
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
3395
|
+
if (!align || pos === void 0) continue;
|
|
3396
|
+
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
3397
|
+
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
3398
|
+
}
|
|
3399
|
+
return stops;
|
|
3400
|
+
}
|
|
3401
|
+
function writeTabStops(doc, props, paragraph2, base) {
|
|
3402
|
+
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
3403
|
+
return;
|
|
3404
|
+
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
3405
|
+
if (!paragraph2.tabStops?.length) return;
|
|
3406
|
+
const tabs = makeW(doc, "tabs");
|
|
3407
|
+
for (const stop of paragraph2.tabStops) {
|
|
3408
|
+
const tab = makeW(doc, "tab");
|
|
3409
|
+
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
3410
|
+
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
3411
|
+
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
3412
|
+
tabs.appendChild(tab);
|
|
3413
|
+
}
|
|
3414
|
+
props.appendChild(tabs);
|
|
3415
|
+
}
|
|
3416
|
+
var PPR_ORDER = [
|
|
3417
|
+
"pStyle",
|
|
3418
|
+
"keepNext",
|
|
3419
|
+
"keepLines",
|
|
3420
|
+
"pageBreakBefore",
|
|
3421
|
+
"framePr",
|
|
3422
|
+
"widowControl",
|
|
3423
|
+
"numPr",
|
|
3424
|
+
"suppressLineNumbers",
|
|
3425
|
+
"pBdr",
|
|
3426
|
+
"shd",
|
|
3427
|
+
"tabs",
|
|
3428
|
+
"suppressAutoHyphens",
|
|
3429
|
+
"kinsoku",
|
|
3430
|
+
"wordWrap",
|
|
3431
|
+
"overflowPunct",
|
|
3432
|
+
"topLinePunct",
|
|
3433
|
+
"autoSpaceDE",
|
|
3434
|
+
"autoSpaceDN",
|
|
3435
|
+
"bidi",
|
|
3436
|
+
"adjustRightInd",
|
|
3437
|
+
"snapToGrid",
|
|
3438
|
+
"spacing",
|
|
3439
|
+
"ind",
|
|
3440
|
+
"contextualSpacing",
|
|
3441
|
+
"mirrorIndents",
|
|
3442
|
+
"suppressOverlap",
|
|
3443
|
+
"jc",
|
|
3444
|
+
"textDirection",
|
|
3445
|
+
"textAlignment",
|
|
3446
|
+
"textboxTightWrap",
|
|
3447
|
+
"outlineLvl",
|
|
3448
|
+
"divId",
|
|
3449
|
+
"cnfStyle",
|
|
3450
|
+
"rPr",
|
|
3451
|
+
"sectPr",
|
|
3452
|
+
"pPrChange"
|
|
3453
|
+
];
|
|
3454
|
+
function orderParagraphProperties(props) {
|
|
3455
|
+
orderChildren(props, PPR_ORDER);
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
// docx/write-paragraph-decoration.ts
|
|
3459
|
+
var SIDES3 = ["top", "left", "bottom", "right", "between"];
|
|
3460
|
+
function wordColor(color) {
|
|
3461
|
+
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
3462
|
+
return hex ? hex.toUpperCase() : "auto";
|
|
3463
|
+
}
|
|
3464
|
+
function borderElement(doc, name, side) {
|
|
3465
|
+
const element4 = makeW(doc, name);
|
|
3466
|
+
const set2 = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
3467
|
+
set2("val", side.style ?? "single");
|
|
3468
|
+
if (side.style !== "none" && side.style !== "nil") {
|
|
3469
|
+
set2("sz", String(side.sizeEighthPoints ?? 4));
|
|
3470
|
+
set2("space", String(side.spacePoints ?? 1));
|
|
3471
|
+
set2("color", wordColor(side.color));
|
|
3472
|
+
if (side.themeColor) set2("themeColor", side.themeColor);
|
|
3473
|
+
}
|
|
3474
|
+
return element4;
|
|
3475
|
+
}
|
|
3476
|
+
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
3477
|
+
function updateShading(doc, props, paragraph2, base) {
|
|
3478
|
+
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
3479
|
+
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
3480
|
+
if (!paragraph2.shadingFill) return;
|
|
3481
|
+
const shd = makeW(doc, "shd");
|
|
3482
|
+
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
3483
|
+
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
3484
|
+
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
3485
|
+
props.appendChild(shd);
|
|
3486
|
+
}
|
|
3487
|
+
function updateBorders(doc, props, paragraph2, base) {
|
|
3488
|
+
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
3489
|
+
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
3490
|
+
const borders = paragraph2.borders;
|
|
3491
|
+
if (!borders) return;
|
|
3492
|
+
const pBdr = makeW(doc, "pBdr");
|
|
3493
|
+
for (const side of SIDES3) {
|
|
3494
|
+
const value = borders[side];
|
|
3495
|
+
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
3496
|
+
}
|
|
3497
|
+
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
3498
|
+
}
|
|
3499
|
+
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
3500
|
+
updateShading(doc, props, paragraph2, base);
|
|
3501
|
+
updateBorders(doc, props, paragraph2, base);
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
// docx/write-paragraph-properties.ts
|
|
3505
|
+
function setAttribute(element4, local, value) {
|
|
3506
|
+
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
3507
|
+
}
|
|
3508
|
+
function setWordValue(element4, local, value) {
|
|
3509
|
+
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
3510
|
+
else setAttribute(element4, local, String(value));
|
|
3511
|
+
}
|
|
3512
|
+
function updateDirection(doc, props, paragraph2, base) {
|
|
3513
|
+
if (base && paragraph2.direction === base.direction) return;
|
|
3514
|
+
let bidi = first2(props, "bidi");
|
|
3515
|
+
if (paragraph2.direction === void 0) {
|
|
3516
|
+
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
3517
|
+
} else {
|
|
3518
|
+
if (!bidi) {
|
|
3519
|
+
bidi = makeW(doc, "bidi");
|
|
3520
|
+
props.appendChild(bidi);
|
|
3521
|
+
}
|
|
3522
|
+
setAttribute(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
function updateSpacing(doc, props, paragraph2, base) {
|
|
3526
|
+
let spacing2 = first2(props, "spacing");
|
|
3527
|
+
if (!spacing2) {
|
|
3528
|
+
spacing2 = makeW(doc, "spacing");
|
|
3529
|
+
props.appendChild(spacing2);
|
|
3530
|
+
}
|
|
3531
|
+
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
3532
|
+
setWordValue(spacing2, "before", paragraph2.spacingBeforeTwips);
|
|
3533
|
+
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
3534
|
+
setWordValue(spacing2, "after", paragraph2.spacingAfterTwips);
|
|
3535
|
+
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
3536
|
+
setWordValue(spacing2, "line", paragraph2.lineSpacingTwips);
|
|
3537
|
+
setWordValue(
|
|
3538
|
+
spacing2,
|
|
3539
|
+
"lineRule",
|
|
3540
|
+
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
3541
|
+
);
|
|
3542
|
+
}
|
|
3543
|
+
if (!spacing2.attributes.length && !spacing2.childNodes.length) props.removeChild(spacing2);
|
|
3544
|
+
}
|
|
3545
|
+
function updateIndent(doc, props, paragraph2, base) {
|
|
3546
|
+
let indent = first2(props, "ind");
|
|
3547
|
+
if (!indent) {
|
|
3548
|
+
indent = makeW(doc, "ind");
|
|
3549
|
+
props.appendChild(indent);
|
|
3550
|
+
}
|
|
3551
|
+
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
3552
|
+
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
3553
|
+
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
3554
|
+
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
3555
|
+
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
3556
|
+
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
3557
|
+
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
3558
|
+
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
3559
|
+
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
3560
|
+
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
3561
|
+
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
3562
|
+
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
3563
|
+
if (!indent.attributes.length) props.removeChild(indent);
|
|
3564
|
+
}
|
|
3565
|
+
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
3566
|
+
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
3567
|
+
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
3568
|
+
if (paragraph2.pageBreakBefore !== void 0) {
|
|
3569
|
+
const element4 = makeW(doc, "pageBreakBefore");
|
|
3570
|
+
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
3571
|
+
props.appendChild(element4);
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
3575
|
+
for (const key of [
|
|
3576
|
+
"keepNext",
|
|
3577
|
+
"keepLines",
|
|
3578
|
+
"widowControl",
|
|
3579
|
+
"contextualSpacing",
|
|
3580
|
+
"suppressLineNumbers"
|
|
3581
|
+
]) {
|
|
3582
|
+
if (base && paragraph2[key] === base[key]) continue;
|
|
3583
|
+
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
3584
|
+
const value = paragraph2[key];
|
|
3585
|
+
if (value === void 0) continue;
|
|
3586
|
+
const element4 = makeW(doc, key);
|
|
3587
|
+
if (!value) setAttribute(element4, "val", "0");
|
|
3588
|
+
props.appendChild(element4);
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
function updateDropCap(doc, props, paragraph2, base) {
|
|
3592
|
+
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
3593
|
+
let frame2 = first2(props, "framePr");
|
|
3594
|
+
const cap = paragraph2.dropCap;
|
|
3595
|
+
if (!cap) {
|
|
3596
|
+
if (frame2) props.removeChild(frame2);
|
|
3597
|
+
return;
|
|
3598
|
+
}
|
|
3599
|
+
if (!frame2) {
|
|
3600
|
+
frame2 = makeW(doc, "framePr");
|
|
3601
|
+
props.appendChild(frame2);
|
|
3602
|
+
setAttribute(frame2, "wrap", "around");
|
|
3603
|
+
setAttribute(frame2, "vAnchor", "text");
|
|
3604
|
+
setAttribute(frame2, "hAnchor", "text");
|
|
3605
|
+
}
|
|
3606
|
+
setAttribute(frame2, "dropCap", cap.style);
|
|
3607
|
+
setAttribute(frame2, "lines", String(cap.lines));
|
|
3608
|
+
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
3609
|
+
}
|
|
3610
|
+
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
3611
|
+
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
3612
|
+
updateKeepOptions(doc, props, paragraph2, base);
|
|
3613
|
+
updateDropCap(doc, props, paragraph2, base);
|
|
3614
|
+
updateDirection(doc, props, paragraph2, base);
|
|
3615
|
+
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
3616
|
+
const spacingKeys = [
|
|
3617
|
+
"spacingBeforeTwips",
|
|
3618
|
+
"spacingAfterTwips",
|
|
3619
|
+
"lineSpacingTwips",
|
|
3620
|
+
"lineSpacingRule"
|
|
3621
|
+
];
|
|
3622
|
+
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
3623
|
+
updateSpacing(doc, props, paragraph2, base);
|
|
3624
|
+
const indentKeys = [
|
|
3625
|
+
"indentLeftTwips",
|
|
3626
|
+
"indentRightTwips",
|
|
3627
|
+
"indentStartTwips",
|
|
3628
|
+
"indentEndTwips",
|
|
3629
|
+
"firstLineTwips",
|
|
3630
|
+
"hangingTwips"
|
|
3631
|
+
];
|
|
3632
|
+
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
3633
|
+
updateIndent(doc, props, paragraph2, base);
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
// docx/style-formatting-package.ts
|
|
3637
|
+
var STYLES_PART = "word/styles.xml";
|
|
3638
|
+
var AFTER_PPR = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
3639
|
+
var WRITABLE_STYLE_FORMATTING = [
|
|
3640
|
+
"align",
|
|
3641
|
+
"justification",
|
|
3642
|
+
"direction",
|
|
3643
|
+
"spacingBeforeTwips",
|
|
3644
|
+
"spacingAfterTwips",
|
|
3645
|
+
"lineSpacingTwips",
|
|
3646
|
+
"lineSpacingRule",
|
|
3647
|
+
"indentLeftTwips",
|
|
3648
|
+
"indentRightTwips",
|
|
3649
|
+
"indentStartTwips",
|
|
3650
|
+
"indentEndTwips",
|
|
3651
|
+
"firstLineTwips",
|
|
3652
|
+
"hangingTwips",
|
|
3653
|
+
"pageBreakBefore",
|
|
3654
|
+
"keepNext",
|
|
3655
|
+
"keepLines",
|
|
3656
|
+
"widowControl",
|
|
3657
|
+
"contextualSpacing",
|
|
3658
|
+
"suppressLineNumbers",
|
|
3659
|
+
"borders",
|
|
3660
|
+
"shadingFill"
|
|
3661
|
+
];
|
|
3662
|
+
function unwritableFormatting(formatting) {
|
|
3663
|
+
const rest = { ...formatting };
|
|
3664
|
+
for (const key of WRITABLE_STYLE_FORMATTING) delete rest[key];
|
|
3665
|
+
return rest;
|
|
3666
|
+
}
|
|
3667
|
+
var asParagraph = (formatting) => ({
|
|
3668
|
+
type: "paragraph",
|
|
3669
|
+
id: "style",
|
|
3670
|
+
runs: [],
|
|
3671
|
+
...formatting
|
|
3672
|
+
});
|
|
3673
|
+
function pPrOf(style) {
|
|
3674
|
+
let pPr = first2(style, "pPr");
|
|
3675
|
+
if (pPr) return pPr;
|
|
3676
|
+
pPr = makeW(style.ownerDocument, "pPr");
|
|
3677
|
+
const anchor = Array.from(style.childNodes).find(
|
|
3678
|
+
(node) => node.nodeType === 1 && AFTER_PPR.includes(node.localName)
|
|
3679
|
+
) ?? null;
|
|
3680
|
+
style.insertBefore(pPr, anchor);
|
|
3681
|
+
return pPr;
|
|
3682
|
+
}
|
|
3683
|
+
async function applyStyleFormatting(zip, model, base) {
|
|
3684
|
+
const next = model.paragraphStyles?.styles ?? {};
|
|
3685
|
+
const prior = base.paragraphStyles?.styles ?? {};
|
|
3686
|
+
const changed = Object.keys(next).filter(
|
|
3687
|
+
(id) => JSON.stringify(next[id]?.formatting) !== JSON.stringify(prior[id]?.formatting)
|
|
3688
|
+
);
|
|
3689
|
+
if (!changed.length) return;
|
|
3690
|
+
const file = zip.file(STYLES_PART);
|
|
3691
|
+
if (!file) throw new Error("Cannot edit a style: the package has no styles.xml.");
|
|
3692
|
+
const doc = parseXml2(await file.async("string"));
|
|
3693
|
+
const styles = children2(doc.documentElement, "style");
|
|
3694
|
+
for (const id of changed) {
|
|
3695
|
+
const style = styles.find(
|
|
3696
|
+
(element4) => getW(element4, "type") === "paragraph" && getW(element4, "styleId") === id
|
|
3697
|
+
);
|
|
3698
|
+
if (!style) throw new Error(`Cannot edit style "${id}": it is not in styles.xml.`);
|
|
3699
|
+
const after = asParagraph(next[id].formatting);
|
|
3700
|
+
const before = asParagraph(prior[id]?.formatting ?? {});
|
|
3701
|
+
const pPr = pPrOf(style);
|
|
3702
|
+
if (after.align !== before.align || after.justification !== before.justification || after.direction !== before.direction) {
|
|
3703
|
+
for (const jc of children2(pPr, "jc")) pPr.removeChild(jc);
|
|
3704
|
+
const value = paragraphJustification(after);
|
|
3705
|
+
if (value) {
|
|
3706
|
+
const jc = makeW(doc, "jc");
|
|
3707
|
+
jc.setAttributeNS(WORD_NS, "w:val", value);
|
|
3708
|
+
pPr.appendChild(jc);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
writeParagraphProperties(doc, pPr, after, before);
|
|
3712
|
+
orderParagraphProperties(pPr);
|
|
3713
|
+
}
|
|
3714
|
+
zip.file(STYLES_PART, buildXml(doc));
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
// docx/data-binding.ts
|
|
3718
|
+
function parsePrefixes(text) {
|
|
3719
|
+
const map = /* @__PURE__ */ new Map();
|
|
3720
|
+
for (const match of (text ?? "").matchAll(/xmlns:([\w.-]+)\s*=\s*(?:'([^']*)'|"([^"]*)")/g))
|
|
3721
|
+
map.set(match[1], match[2] ?? match[3] ?? "");
|
|
3722
|
+
return map;
|
|
3723
|
+
}
|
|
3724
|
+
function sourceBindings(sourceXml) {
|
|
3725
|
+
const result = /* @__PURE__ */ new Map();
|
|
3726
|
+
const document = parseXml2(sourceXml);
|
|
3727
|
+
for (const sdt of Array.from(document.getElementsByTagNameNS(WORD_NS, "sdt"))) {
|
|
3728
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
3729
|
+
const element4 = sdtPr && elements(sdtPr).find((node) => node.localName === "dataBinding");
|
|
3730
|
+
const id = getW(first2(sdtPr, "id"), "val");
|
|
3731
|
+
const xpath = element4?.getAttributeNS(WORD_NS, "xpath");
|
|
3732
|
+
const storeItemId = element4?.getAttributeNS(WORD_NS, "storeItemID");
|
|
3733
|
+
if (id && element4 && xpath && storeItemId)
|
|
3734
|
+
result.set(id, {
|
|
3735
|
+
xpath,
|
|
3736
|
+
storeItemId,
|
|
3737
|
+
prefixes: parsePrefixes(element4.getAttributeNS(WORD_NS, "prefixMappings") ?? void 0)
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
3740
|
+
return result;
|
|
3741
|
+
}
|
|
3742
|
+
function paragraphsOf(blocks) {
|
|
3743
|
+
return blocks.flatMap(
|
|
3744
|
+
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((c2) => c2.paragraphs))
|
|
3745
|
+
);
|
|
3746
|
+
}
|
|
3747
|
+
function boundTexts(model) {
|
|
3748
|
+
const parts = /* @__PURE__ */ new Map();
|
|
3749
|
+
const add4 = (id, text) => parts.set(id, [...parts.get(id) ?? [], text]);
|
|
3750
|
+
for (const paragraph2 of paragraphsOf(model.blocks)) {
|
|
3751
|
+
const own2 = paragraph2.contentControl;
|
|
3752
|
+
if (own2?.dataBound) {
|
|
3753
|
+
add4(own2.id, paragraph2.runs.map((run2) => run2.text).join(""));
|
|
3754
|
+
continue;
|
|
3755
|
+
}
|
|
3756
|
+
const inline = /* @__PURE__ */ new Map();
|
|
3757
|
+
for (const run2 of paragraph2.runs) {
|
|
3758
|
+
const control = run2.contentControl;
|
|
3759
|
+
if (!control?.dataBound) continue;
|
|
3760
|
+
if (!inline.has(control.id)) inline.set(control.id, "");
|
|
3761
|
+
if (!control.showingPlaceholder) inline.set(control.id, inline.get(control.id) + run2.text);
|
|
3762
|
+
}
|
|
3763
|
+
for (const [id, text] of inline) add4(id, text);
|
|
3764
|
+
}
|
|
3765
|
+
return new Map([...parts].map(([id, texts]) => [id, texts.join("\n")]));
|
|
3766
|
+
}
|
|
3767
|
+
function parseXPath(binding) {
|
|
3768
|
+
const parts = binding.xpath.split("/");
|
|
3769
|
+
if (parts.shift() !== "" || !parts.length) return void 0;
|
|
3770
|
+
if (parts.at(-1) === "text()") parts.pop();
|
|
3771
|
+
const parse = (raw2, attribute3) => {
|
|
3772
|
+
const match = /^(?:([A-Za-z_][\w.-]*):)?([A-Za-z_][\w.-]*)(?:\[(\d+)\])?$/.exec(raw2);
|
|
3773
|
+
if (!match || attribute3 && match[3]) return void 0;
|
|
3774
|
+
const [, prefix2 = "", name = "", index] = match;
|
|
3775
|
+
if (prefix2 && !binding.prefixes.has(prefix2)) return void 0;
|
|
3776
|
+
return { prefix: prefix2, name, index: index ? Number(index) : 1 };
|
|
3777
|
+
};
|
|
3778
|
+
const last = parts.at(-1);
|
|
3779
|
+
const attribute2 = last?.startsWith("@") ? parse(last.slice(1), true) : void 0;
|
|
3780
|
+
if (last?.startsWith("@")) {
|
|
3781
|
+
parts.pop();
|
|
3782
|
+
if (!attribute2) return void 0;
|
|
3783
|
+
}
|
|
3784
|
+
const steps = parts.map((part) => parse(part, false));
|
|
3785
|
+
if (!steps.length || steps.some((step) => !step)) return void 0;
|
|
3786
|
+
return { steps, ...attribute2 ? { attribute: attribute2 } : {} };
|
|
3787
|
+
}
|
|
3788
|
+
var matches = (element4, step, binding) => element4.localName === step.name && (element4.namespaceURI ?? "") === (step.prefix ? binding.prefixes.get(step.prefix) ?? "" : "");
|
|
3789
|
+
function writeValue(root, binding, value) {
|
|
3790
|
+
const path3 = parseXPath(binding);
|
|
3791
|
+
if (!path3) return "unsupported";
|
|
3792
|
+
let node = root;
|
|
3793
|
+
for (const [depth, step] of path3.steps.entries()) {
|
|
3794
|
+
const candidates = depth === 0 ? [root].filter((e) => matches(e, step, binding)) : elements(node).filter((e) => matches(e, step, binding));
|
|
3795
|
+
node = candidates[step.index - 1];
|
|
3796
|
+
if (!node) return false;
|
|
3797
|
+
}
|
|
3798
|
+
if (path3.attribute) {
|
|
3799
|
+
const { prefix: prefix2, name } = path3.attribute;
|
|
3800
|
+
const ns = prefix2 ? binding.prefixes.get(prefix2) : void 0;
|
|
3801
|
+
if (ns) node.setAttributeNS(ns, `${prefix2}:${name}`, value);
|
|
3802
|
+
else node.setAttribute(name, value);
|
|
3803
|
+
return true;
|
|
3804
|
+
}
|
|
3805
|
+
for (const child7 of Array.from(node.childNodes)) node.removeChild(child7);
|
|
3806
|
+
if (value) node.appendChild(node.ownerDocument.createTextNode(value));
|
|
3807
|
+
return true;
|
|
3808
|
+
}
|
|
3809
|
+
async function findItemPart(zip, storeItemId) {
|
|
3810
|
+
const wanted = storeItemId.toLowerCase();
|
|
3811
|
+
for (const name of Object.keys(zip.files)) {
|
|
3812
|
+
const props = /^customXml\/itemProps(\d+)\.xml$/.exec(name);
|
|
3813
|
+
if (!props) continue;
|
|
3814
|
+
const root = parseXml2(await zip.file(name).async("string")).documentElement;
|
|
3815
|
+
const id = Array.from(root.attributes).find((attribute2) => attribute2.localName === "itemID");
|
|
3816
|
+
if ((id?.value ?? "").toLowerCase() === wanted) return `customXml/item${props[1]}.xml`;
|
|
3817
|
+
}
|
|
3818
|
+
return void 0;
|
|
3819
|
+
}
|
|
3820
|
+
async function applyDataBindings(zip, model, base, sourceXml) {
|
|
3821
|
+
const now = boundTexts(model);
|
|
3822
|
+
if (!now.size) return;
|
|
3823
|
+
const before = boundTexts(base);
|
|
3824
|
+
const bindings = sourceBindings(sourceXml);
|
|
3825
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
3826
|
+
for (const [id, text] of now) {
|
|
3827
|
+
const binding = bindings.get(id);
|
|
3828
|
+
if (!binding || before.get(id) === text) continue;
|
|
3829
|
+
const part = await findItemPart(zip, binding.storeItemId);
|
|
3830
|
+
const file = part ? zip.file(part) : void 0;
|
|
3831
|
+
if (!part || !file) continue;
|
|
3832
|
+
const document = parsed.get(part) ?? parseXml2(await file.async("string"));
|
|
3833
|
+
parsed.set(part, document);
|
|
3834
|
+
const written = writeValue(document.documentElement, binding, text);
|
|
3835
|
+
if (written !== true)
|
|
3836
|
+
throw new Error(
|
|
3837
|
+
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.`
|
|
3838
|
+
);
|
|
3839
|
+
}
|
|
3840
|
+
for (const [part, document] of parsed) zip.file(part, buildXml(document));
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
// docx/content-control.ts
|
|
3844
|
+
var WORD_2012_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
3845
|
+
var sdtContent = (sdt) => first2(sdt, "sdtContent");
|
|
3846
|
+
var isSdt = (element4) => named2(element4, "sdt");
|
|
3847
|
+
var TYPE_ELEMENTS = {
|
|
3848
|
+
text: "text",
|
|
3849
|
+
dropDownList: "dropDownList",
|
|
3850
|
+
comboBox: "comboBox",
|
|
3851
|
+
date: "date",
|
|
3852
|
+
picture: "picture",
|
|
3853
|
+
group: "group",
|
|
3854
|
+
equation: "equation",
|
|
3855
|
+
citation: "citation",
|
|
3856
|
+
bibliography: "bibliography",
|
|
3857
|
+
docPartObj: "docPartObj",
|
|
3858
|
+
docPartList: "docPartList"
|
|
3859
|
+
};
|
|
3860
|
+
function attrW14(element4, local) {
|
|
3861
|
+
return element4?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
|
|
3862
|
+
}
|
|
3863
|
+
function glyph(element4) {
|
|
3864
|
+
const code = attrW14(element4, "val");
|
|
3865
|
+
if (!code) return void 0;
|
|
3866
|
+
const font = attrW14(element4, "font");
|
|
3867
|
+
return { code, ...font ? { font } : {} };
|
|
3868
|
+
}
|
|
3869
|
+
function kindOf(child7) {
|
|
3870
|
+
if (child7.namespaceURI === WORD_NS)
|
|
3871
|
+
return Object.hasOwn(TYPE_ELEMENTS, child7.localName) ? TYPE_ELEMENTS[child7.localName] : void 0;
|
|
3872
|
+
if (child7.namespaceURI === WORD_2010_NS && child7.localName === "checkbox") return "checkbox";
|
|
3873
|
+
if (child7.namespaceURI === WORD_2012_NS && child7.localName === "repeatingSection")
|
|
3874
|
+
return "repeatingSection";
|
|
3875
|
+
return void 0;
|
|
3876
|
+
}
|
|
3877
|
+
var typeElements = (sdtPr) => Array.from(sdtPr.childNodes).filter(isElement).filter(
|
|
3878
|
+
(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"
|
|
3879
|
+
);
|
|
3880
|
+
function parseKind(sdtPr) {
|
|
3881
|
+
const [type] = typeElements(sdtPr);
|
|
3882
|
+
return (type && kindOf(type)) ?? "richText";
|
|
3883
|
+
}
|
|
3884
|
+
var generated = 0;
|
|
3885
|
+
function parseContentControl(sdt, level3) {
|
|
3886
|
+
const sdtPr = first2(sdt, "sdtPr");
|
|
3887
|
+
if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level3, kind: "richText" };
|
|
3888
|
+
const kind = parseKind(sdtPr);
|
|
3889
|
+
const control = {
|
|
3890
|
+
id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
|
|
3891
|
+
level: level3,
|
|
3892
|
+
kind
|
|
3893
|
+
};
|
|
3894
|
+
const alias = getW(first2(sdtPr, "alias"), "val");
|
|
3895
|
+
if (alias !== void 0) control.alias = alias;
|
|
3896
|
+
const tag = getW(first2(sdtPr, "tag"), "val");
|
|
3897
|
+
if (tag !== void 0) control.tag = tag;
|
|
3898
|
+
const lock = getW(first2(sdtPr, "lock"), "val");
|
|
3899
|
+
if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
|
|
3900
|
+
control.lock = lock;
|
|
3901
|
+
const showing = first2(sdtPr, "showingPlcHdr");
|
|
3902
|
+
if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
|
|
3903
|
+
if (first2(sdtPr, "dataBinding")) control.dataBound = true;
|
|
3904
|
+
const temporary = first2(sdtPr, "temporary");
|
|
3905
|
+
if (temporary && (parseOnOff(getW(temporary, "val")) ?? true)) control.temporary = true;
|
|
3906
|
+
const placeholder = getW(first2(first2(sdtPr, "placeholder"), "docPart"), "val");
|
|
3907
|
+
if (placeholder) control.placeholder = placeholder;
|
|
3908
|
+
if (kind === "text") {
|
|
3909
|
+
const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
|
|
3910
|
+
if (multi) control.multiLine = true;
|
|
3911
|
+
}
|
|
3912
|
+
if (kind === "checkbox") {
|
|
3913
|
+
const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
|
|
3914
|
+
const checked = first(box, "checked", WORD_2010_NS, false);
|
|
3915
|
+
control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
|
|
3916
|
+
const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
|
|
3917
|
+
const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
|
|
3918
|
+
if (on) control.checkedGlyph = on;
|
|
3919
|
+
if (off) control.uncheckedGlyph = off;
|
|
3920
|
+
}
|
|
3921
|
+
if (kind === "dropDownList" || kind === "comboBox") {
|
|
3922
|
+
const list2 = first2(sdtPr, kind);
|
|
3923
|
+
control.items = (list2 ? Array.from(list2.childNodes).filter(isElement) : []).filter((item2) => named2(item2, "listItem")).map((item2) => {
|
|
3924
|
+
const display = getW(item2, "displayText");
|
|
3925
|
+
const value = getW(item2, "value") ?? display ?? "";
|
|
3926
|
+
return { display: display ?? value, value };
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
if (kind === "date") {
|
|
3930
|
+
const date = first2(sdtPr, "date");
|
|
3931
|
+
const fullDate = getW(date, "fullDate");
|
|
3932
|
+
if (fullDate) control.fullDate = fullDate;
|
|
3933
|
+
const format = getW(first2(date, "dateFormat"), "val");
|
|
3934
|
+
if (format) control.dateFormat = format;
|
|
3935
|
+
const lid = getW(first2(date, "lid"), "val");
|
|
3936
|
+
if (lid) control.dateLocale = lid;
|
|
3937
|
+
}
|
|
3938
|
+
control.sourceXml = buildXml(sdtPr);
|
|
3939
|
+
const end = first2(sdt, "sdtEndPr");
|
|
3940
|
+
if (end) control.endSourceXml = buildXml(end);
|
|
3941
|
+
return control;
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
// docx/expect-defined.ts
|
|
3945
|
+
function expectDefined(value, context) {
|
|
3946
|
+
if (value === void 0 || value === null) {
|
|
3947
|
+
throw new Error(`Internal invariant violated: ${context} is missing.`);
|
|
3948
|
+
}
|
|
3949
|
+
return value;
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
// docx/parse-revisions.ts
|
|
3953
|
+
var REVISION_WRAPPERS = {
|
|
3954
|
+
ins: "insert",
|
|
3955
|
+
del: "delete",
|
|
3956
|
+
moveFrom: "moveFrom",
|
|
3957
|
+
moveTo: "moveTo"
|
|
3958
|
+
};
|
|
3959
|
+
var MOVE_RANGES = {
|
|
3960
|
+
moveFromRangeStart: { kind: "moveFrom", start: true },
|
|
3961
|
+
moveFromRangeEnd: { kind: "moveFrom", start: false },
|
|
3962
|
+
moveToRangeStart: { kind: "moveTo", start: true },
|
|
3963
|
+
moveToRangeEnd: { kind: "moveTo", start: false }
|
|
3964
|
+
};
|
|
3965
|
+
function trackMoveRange(item2, moves) {
|
|
3966
|
+
if (item2.namespaceURI && item2.namespaceURI !== WORD_NS) return false;
|
|
3967
|
+
const range = MOVE_RANGES[item2.localName ?? ""];
|
|
3968
|
+
if (!range) return false;
|
|
3969
|
+
const id = getW(item2, "id") ?? "";
|
|
3970
|
+
const open = moves[range.kind];
|
|
3971
|
+
if (range.start) open.push({ name: getW(item2, "name") ?? id, id });
|
|
3972
|
+
else {
|
|
3973
|
+
const index = open.findIndex((entry2) => entry2.id === id);
|
|
3974
|
+
if (index >= 0) open.splice(index, 1);
|
|
3975
|
+
}
|
|
3976
|
+
return true;
|
|
3977
|
+
}
|
|
3978
|
+
function isCommentReferenceRun(run2) {
|
|
3979
|
+
const content = Array.from(run2.childNodes).filter(
|
|
3980
|
+
(child7) => isElement(child7) && !named2(child7, "rPr")
|
|
3981
|
+
);
|
|
3982
|
+
return content.length > 0 && content.every((child7) => named2(child7, "commentReference"));
|
|
3983
|
+
}
|
|
3984
|
+
function revisionFrom(node, kind) {
|
|
3985
|
+
const revision = {
|
|
3986
|
+
kind,
|
|
3987
|
+
author: getW(node, "author") || "Unknown",
|
|
3988
|
+
id: getW(node, "id") ?? "0"
|
|
3989
|
+
};
|
|
3990
|
+
const date = getW(node, "date");
|
|
3991
|
+
if (date) revision.date = date;
|
|
3992
|
+
const dateUtc = node.getAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
3993
|
+
if (dateUtc) revision.dateUtc = dateUtc;
|
|
3994
|
+
return revision;
|
|
3995
|
+
}
|
|
3996
|
+
function paragraphMarkRevision(pPr) {
|
|
3997
|
+
const rPr = first2(pPr, "rPr");
|
|
3998
|
+
const ins = first2(rPr, "ins");
|
|
3999
|
+
if (ins) return revisionFrom(ins, "insert");
|
|
4000
|
+
const del = first2(rPr, "del");
|
|
4001
|
+
if (del) return revisionFrom(del, "delete");
|
|
4002
|
+
return void 0;
|
|
4003
|
+
}
|
|
4004
|
+
function paragraphFormatRevision(pPr) {
|
|
4005
|
+
const change = first2(pPr, "pPrChange");
|
|
4006
|
+
if (!change) return void 0;
|
|
4007
|
+
const revision = revisionFrom(change, "paragraphChange");
|
|
4008
|
+
const previous = first2(change, "pPr");
|
|
4009
|
+
if (previous) revision.previousParagraphPropertiesXml = buildXml(previous);
|
|
4010
|
+
return revision;
|
|
4011
|
+
}
|
|
4012
|
+
function runFormatRevision(rPr) {
|
|
4013
|
+
const change = first2(rPr, "rPrChange");
|
|
4014
|
+
if (!change) return void 0;
|
|
4015
|
+
const revision = revisionFrom(change, "formatChange");
|
|
4016
|
+
const previous = first2(change, "rPr");
|
|
4017
|
+
if (previous) revision.previousRunPropertiesXml = buildXml(previous);
|
|
4018
|
+
return revision;
|
|
4019
|
+
}
|
|
4020
|
+
function collectParagraphRuns(node, parseRun3, parseOther, resolveLink, active = [], moves = { moveFrom: [], moveTo: [] }) {
|
|
4021
|
+
const runs = [];
|
|
4022
|
+
let hasMove = false;
|
|
4023
|
+
const push = (run2) => {
|
|
4024
|
+
if (active.length) run2.commentIds = [.../* @__PURE__ */ new Set([...active, ...run2.commentIds ?? []])];
|
|
4025
|
+
runs.push(run2);
|
|
4026
|
+
};
|
|
4027
|
+
for (const item2 of Array.from(node.childNodes).filter(isElement)) {
|
|
4028
|
+
if (named2(item2, "r")) {
|
|
4029
|
+
if (!isCommentReferenceRun(item2)) push(parseRun3(item2));
|
|
4030
|
+
} else if (named2(item2, "hyperlink")) {
|
|
4031
|
+
const link = resolveLink?.(item2);
|
|
4032
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4033
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7)] : parseOther?.(child7) ?? []) {
|
|
4034
|
+
if (link) parsed.link = link;
|
|
4035
|
+
push(parsed);
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
} else if ((!item2.namespaceURI || item2.namespaceURI === WORD_NS) && Object.hasOwn(REVISION_WRAPPERS, item2.localName)) {
|
|
4039
|
+
const kind = expectDefined(
|
|
4040
|
+
REVISION_WRAPPERS[item2.localName],
|
|
4041
|
+
`revision wrapper ${item2.localName}`
|
|
4042
|
+
);
|
|
4043
|
+
if (kind === "moveFrom" || kind === "moveTo") hasMove = true;
|
|
4044
|
+
const revision = revisionFrom(item2, kind);
|
|
4045
|
+
const range = kind === "moveFrom" || kind === "moveTo" ? moves[kind].at(-1) : void 0;
|
|
4046
|
+
if (range) revision.move = { name: range.name, rangeId: range.id };
|
|
4047
|
+
for (const child7 of Array.from(item2.childNodes).filter(isElement)) {
|
|
4048
|
+
for (const parsed of named2(child7, "r") ? [parseRun3(child7, revision)] : parseOther?.(child7) ?? []) {
|
|
4049
|
+
parsed.revision = revision;
|
|
4050
|
+
push(parsed);
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
} else if (trackMoveRange(item2, moves)) {
|
|
4054
|
+
continue;
|
|
4055
|
+
} else if (named2(item2, "commentRangeStart")) {
|
|
4056
|
+
const id = getW(item2, "id");
|
|
4057
|
+
if (id !== void 0) active.push(id);
|
|
4058
|
+
} else if (named2(item2, "commentRangeEnd")) {
|
|
4059
|
+
const id = getW(item2, "id");
|
|
4060
|
+
const index = id === void 0 ? -1 : active.indexOf(id);
|
|
4061
|
+
if (index >= 0) active.splice(index, 1);
|
|
4062
|
+
} else {
|
|
4063
|
+
for (const run2 of parseOther?.(item2) ?? []) push(run2);
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
return { runs, hasMove };
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
// docx/parse-content-control.ts
|
|
4070
|
+
function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, moves) {
|
|
4071
|
+
const control = parseContentControl(sdt, "inline");
|
|
4072
|
+
const content = sdtContent(sdt);
|
|
4073
|
+
const runs = content ? collectParagraphRuns(content, parseRun3, parseOther, resolveLink, comments, moves).runs : [];
|
|
4074
|
+
if (!runs.length) return [{ text: "", contentControl: control }];
|
|
4075
|
+
for (const run2 of runs) run2.contentControl ??= control;
|
|
4076
|
+
return runs;
|
|
4077
|
+
}
|
|
4078
|
+
function flatChildren(parent, names, level3 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
|
|
4079
|
+
const found = [];
|
|
4080
|
+
for (const child7 of Array.from(parent.childNodes).filter(isElement)) {
|
|
4081
|
+
if (isSdt(child7)) {
|
|
4082
|
+
const content = sdtContent(child7);
|
|
4083
|
+
if (!content) continue;
|
|
4084
|
+
let control = controls.get(child7);
|
|
4085
|
+
if (!control) {
|
|
4086
|
+
control = parseContentControl(child7, level3);
|
|
4087
|
+
controls.set(child7, control);
|
|
4088
|
+
}
|
|
4089
|
+
found.push(...flatChildren(content, names, level3, { control, sdt: child7 }, controls));
|
|
4090
|
+
} else if (names.some((name) => named2(child7, name)))
|
|
4091
|
+
found.push({
|
|
4092
|
+
element: child7,
|
|
4093
|
+
...enclosing ? { control: enclosing.control, sdt: enclosing.sdt } : {}
|
|
4094
|
+
});
|
|
4095
|
+
}
|
|
4096
|
+
return found;
|
|
4097
|
+
}
|
|
4098
|
+
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
4099
|
+
var flatRows = (table) => flatChildren(table, ["tr"], "row");
|
|
4100
|
+
var flatCells = (row) => flatChildren(row, ["tc"], "cell");
|
|
4101
|
+
var flatCellParagraphs = (cell2) => flatChildren(cell2, ["p"]);
|
|
4102
|
+
|
|
3362
4103
|
// docx/content-control-values.ts
|
|
3363
4104
|
var validLock = (lock) => lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked" ? lock : void 0;
|
|
3364
4105
|
function validId(id) {
|
|
@@ -3584,15 +4325,15 @@ function writeDate(doc, sdtPr, control) {
|
|
|
3584
4325
|
const fullDate = validDate(control.fullDate) ?? (control.fullDate === existing ? existing : void 0);
|
|
3585
4326
|
if (fullDate) date.setAttributeNS(WORD_NS, "w:fullDate", fullDate);
|
|
3586
4327
|
else date.removeAttributeNS(WORD_NS, "fullDate");
|
|
3587
|
-
const
|
|
4328
|
+
const set2 = (local, value, order) => {
|
|
3588
4329
|
for (const old of children2(date, local)) date.removeChild(old);
|
|
3589
4330
|
if (typeof value !== "string") return;
|
|
3590
4331
|
const element4 = makeW(doc, local);
|
|
3591
4332
|
element4.setAttributeNS(WORD_NS, "w:val", value);
|
|
3592
4333
|
date.insertBefore(element4, Array.from(date.childNodes)[order] ?? null);
|
|
3593
4334
|
};
|
|
3594
|
-
|
|
3595
|
-
|
|
4335
|
+
set2("dateFormat", control.dateFormat, 0);
|
|
4336
|
+
set2("lid", control.dateLocale, 1);
|
|
3596
4337
|
}
|
|
3597
4338
|
var writesType = (kind) => NAMED_TYPES.has(kind) || ["richText", "text", "checkbox", "dropDownList", "comboBox", "date"].includes(kind);
|
|
3598
4339
|
function patchContentControl(doc, sdt, control) {
|
|
@@ -3770,13 +4511,13 @@ function rangeKeys(run2) {
|
|
|
3770
4511
|
keys.push(`${revision.kind}:${revision.move.name}`);
|
|
3771
4512
|
return keys;
|
|
3772
4513
|
}
|
|
3773
|
-
function
|
|
4514
|
+
function paragraphsOf2(blocks) {
|
|
3774
4515
|
return blocks.flatMap(
|
|
3775
4516
|
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell2) => cell2.paragraphs))
|
|
3776
4517
|
);
|
|
3777
4518
|
}
|
|
3778
4519
|
function commentContinuations(blocks) {
|
|
3779
|
-
const paragraphs =
|
|
4520
|
+
const paragraphs = paragraphsOf2(blocks);
|
|
3780
4521
|
const first3 = /* @__PURE__ */ new Map();
|
|
3781
4522
|
const last = /* @__PURE__ */ new Map();
|
|
3782
4523
|
const idsByParagraph = paragraphs.map((paragraph2, index) => {
|
|
@@ -3841,7 +4582,7 @@ var COMMENTS_PATH = "word/comments.xml";
|
|
|
3841
4582
|
var COMMENTS_EXTENDED_PATH = "word/commentsExtended.xml";
|
|
3842
4583
|
var W14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
3843
4584
|
var W15_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
3844
|
-
function
|
|
4585
|
+
function setAttribute2(element4, local, value) {
|
|
3845
4586
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
3846
4587
|
}
|
|
3847
4588
|
function paraIdFor(id, index) {
|
|
@@ -3856,10 +4597,10 @@ function buildCommentsDocument(comments) {
|
|
|
3856
4597
|
const root = doc.documentElement;
|
|
3857
4598
|
comments.forEach((comment, index) => {
|
|
3858
4599
|
const el5 = makeW(doc, "comment");
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
if (comment.date)
|
|
3862
|
-
if (comment.initials)
|
|
4600
|
+
setAttribute2(el5, "id", comment.id);
|
|
4601
|
+
setAttribute2(el5, "author", comment.author);
|
|
4602
|
+
if (comment.date) setAttribute2(el5, "date", comment.date);
|
|
4603
|
+
if (comment.initials) setAttribute2(el5, "initials", comment.initials);
|
|
3863
4604
|
const p = makeW(doc, "p");
|
|
3864
4605
|
p.setAttributeNS(W14_NS, "w14:paraId", paraIdFor(comment.id, index));
|
|
3865
4606
|
const r = makeW(doc, "r");
|
|
@@ -3923,15 +4664,15 @@ async function applyComments(zip, comments) {
|
|
|
3923
4664
|
}
|
|
3924
4665
|
function commentRangeStartNode(doc, id) {
|
|
3925
4666
|
const element4 = makeW(doc, "commentRangeStart");
|
|
3926
|
-
|
|
4667
|
+
setAttribute2(element4, "id", id);
|
|
3927
4668
|
return element4;
|
|
3928
4669
|
}
|
|
3929
4670
|
function commentRangeEndNodes(doc, id) {
|
|
3930
4671
|
const end = makeW(doc, "commentRangeEnd");
|
|
3931
|
-
|
|
4672
|
+
setAttribute2(end, "id", id);
|
|
3932
4673
|
const run2 = makeW(doc, "r");
|
|
3933
4674
|
const reference = makeW(doc, "commentReference");
|
|
3934
|
-
|
|
4675
|
+
setAttribute2(reference, "id", id);
|
|
3935
4676
|
run2.appendChild(reference);
|
|
3936
4677
|
return [end, run2];
|
|
3937
4678
|
}
|
|
@@ -4177,10 +4918,10 @@ function buildRowProperties(doc, row, gridAfter) {
|
|
|
4177
4918
|
}
|
|
4178
4919
|
|
|
4179
4920
|
// docx/write-table-margins.ts
|
|
4180
|
-
var
|
|
4921
|
+
var SIDES4 = ["top", "left", "bottom", "right"];
|
|
4181
4922
|
var ORDER2 = ["top", "start", "left", "bottom", "end", "right"];
|
|
4182
4923
|
function patchMarginProperties(doc, host, propertiesTag, marginTag, propertiesOrder, next, base) {
|
|
4183
|
-
const changed =
|
|
4924
|
+
const changed = SIDES4.filter((side) => next?.[side] !== base?.[side]);
|
|
4184
4925
|
if (!changed.length) return;
|
|
4185
4926
|
for (const side of changed) {
|
|
4186
4927
|
const value = next?.[side];
|
|
@@ -4500,14 +5241,21 @@ function unwrapDroppedControls(elements2, next) {
|
|
|
4500
5241
|
});
|
|
4501
5242
|
}
|
|
4502
5243
|
|
|
4503
|
-
// docx/
|
|
5244
|
+
// docx/table-structure-check.ts
|
|
5245
|
+
var only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
5246
|
+
function plainParagraphs(cell2) {
|
|
5247
|
+
for (const paragraph2 of children2(cell2, "p")) {
|
|
5248
|
+
if (!only(paragraph2, ["pPr", "r"])) return false;
|
|
5249
|
+
for (const run2 of children2(paragraph2, "r"))
|
|
5250
|
+
if (!only(run2, ["rPr", "t", "tab", "br", "cr", "noBreakHyphen"])) return false;
|
|
5251
|
+
}
|
|
5252
|
+
return true;
|
|
5253
|
+
}
|
|
4504
5254
|
function canEditTableStructure(table) {
|
|
4505
|
-
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node) => allowed.some((name) => named2(node, name)));
|
|
4506
5255
|
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
4507
5256
|
const grid = first2(table, "tblGrid");
|
|
4508
5257
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
4509
5258
|
const rows = children2(table, "tr");
|
|
4510
|
-
if (!rows.length) return false;
|
|
4511
5259
|
const [firstRow] = rows;
|
|
4512
5260
|
if (!firstRow) return false;
|
|
4513
5261
|
const width = children2(firstRow, "tc").length;
|
|
@@ -4523,15 +5271,206 @@ function canEditTableStructure(table) {
|
|
|
4523
5271
|
const props = first2(cell2, "tcPr");
|
|
4524
5272
|
if (props && ["gridSpan", "vMerge", "hMerge", "tcPrChange"].some((key) => first2(props, key)))
|
|
4525
5273
|
return false;
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
5274
|
+
if (!plainParagraphs(cell2)) return false;
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
return true;
|
|
5278
|
+
}
|
|
5279
|
+
function canRestructureTable(table) {
|
|
5280
|
+
if (!only(table, ["tblPr", "tblGrid", "tr"])) return false;
|
|
5281
|
+
const grid = first2(table, "tblGrid");
|
|
5282
|
+
if (!grid || !only(grid, ["gridCol"])) return false;
|
|
5283
|
+
const rows = children2(table, "tr");
|
|
5284
|
+
if (!rows.length) return false;
|
|
5285
|
+
for (const row of rows) {
|
|
5286
|
+
if (!only(row, ["trPr", "tc"]) || !children2(row, "tc").length) return false;
|
|
5287
|
+
const rowProps = first2(row, "trPr");
|
|
5288
|
+
if (rowProps && ["gridBefore", "gridAfter", "wBefore", "wAfter", "trPrChange", "ins", "del"].some(
|
|
5289
|
+
(key) => first2(rowProps, key)
|
|
5290
|
+
))
|
|
5291
|
+
return false;
|
|
5292
|
+
for (const cell2 of children2(row, "tc")) {
|
|
5293
|
+
if (!only(cell2, ["tcPr", "p", "tbl"]) || !children2(cell2, "p").length) return false;
|
|
5294
|
+
const props = first2(cell2, "tcPr");
|
|
5295
|
+
if (props && ["hMerge", "tcPrChange", "cellIns", "cellDel", "cellMerge"].some((key) => first2(props, key)))
|
|
5296
|
+
return false;
|
|
5297
|
+
if (!plainParagraphs(cell2)) return false;
|
|
4531
5298
|
}
|
|
4532
5299
|
}
|
|
4533
5300
|
return true;
|
|
4534
5301
|
}
|
|
5302
|
+
|
|
5303
|
+
// docx/write-table-structure.ts
|
|
5304
|
+
var set = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
5305
|
+
function restructured(next, base) {
|
|
5306
|
+
const shape = (table) => JSON.stringify([
|
|
5307
|
+
table.grid,
|
|
5308
|
+
table.rows.map(
|
|
5309
|
+
(row) => row.map((cell2) => [
|
|
5310
|
+
cell2.paragraphs.map((p) => p.id),
|
|
5311
|
+
cell2.gridSpan ?? 1,
|
|
5312
|
+
cell2.verticalMerge ?? "",
|
|
5313
|
+
cell2.widthTwips
|
|
5314
|
+
])
|
|
5315
|
+
)
|
|
5316
|
+
]);
|
|
5317
|
+
return shape(next) !== shape(base);
|
|
5318
|
+
}
|
|
5319
|
+
function patchCellLayout(doc, tc, cell2, base) {
|
|
5320
|
+
const span = cell2.gridSpan ?? 1;
|
|
5321
|
+
const width = cell2.widthTwips;
|
|
5322
|
+
if (span === (base.gridSpan ?? 1) && width === base.widthTwips && cell2.verticalMerge === base.verticalMerge)
|
|
5323
|
+
return;
|
|
5324
|
+
let props = first2(tc, "tcPr");
|
|
5325
|
+
if (!props) {
|
|
5326
|
+
props = makeW(doc, "tcPr");
|
|
5327
|
+
tc.insertBefore(props, tc.firstChild);
|
|
5328
|
+
}
|
|
5329
|
+
const replace = (name, next) => {
|
|
5330
|
+
for (const old of children2(props, name)) props.removeChild(old);
|
|
5331
|
+
if (next) props.appendChild(next);
|
|
5332
|
+
};
|
|
5333
|
+
if (width !== base.widthTwips) {
|
|
5334
|
+
const old = first2(props, "tcW");
|
|
5335
|
+
if (width === void 0) replace("tcW", void 0);
|
|
5336
|
+
else {
|
|
5337
|
+
const element4 = old ?? makeW(doc, "tcW");
|
|
5338
|
+
set(element4, "w", String(width));
|
|
5339
|
+
set(element4, "type", "dxa");
|
|
5340
|
+
if (!old) props.appendChild(element4);
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
if (span !== (base.gridSpan ?? 1)) {
|
|
5344
|
+
const element4 = span > 1 ? makeW(doc, "gridSpan") : void 0;
|
|
5345
|
+
if (element4) set(element4, "val", String(span));
|
|
5346
|
+
replace("gridSpan", element4);
|
|
5347
|
+
}
|
|
5348
|
+
if (cell2.verticalMerge !== base.verticalMerge) {
|
|
5349
|
+
const element4 = cell2.verticalMerge ? makeW(doc, "vMerge") : void 0;
|
|
5350
|
+
if (element4 && cell2.verticalMerge === "restart") set(element4, "val", "restart");
|
|
5351
|
+
replace("vMerge", element4);
|
|
5352
|
+
}
|
|
5353
|
+
orderChildren(props, CELL_ORDER);
|
|
5354
|
+
if (!Array.from(props.childNodes).some((node) => node.nodeType === 1) && !props.attributes.length)
|
|
5355
|
+
tc.removeChild(props);
|
|
5356
|
+
}
|
|
5357
|
+
function patchGrid(doc, node, table) {
|
|
5358
|
+
const grid = first2(node, "tblGrid");
|
|
5359
|
+
if (!grid || !table.grid) return;
|
|
5360
|
+
const old = children2(grid, "gridCol");
|
|
5361
|
+
table.grid.forEach((width, index) => {
|
|
5362
|
+
let column = old[index];
|
|
5363
|
+
if (!column) {
|
|
5364
|
+
column = makeW(doc, "gridCol");
|
|
5365
|
+
grid.appendChild(column);
|
|
5366
|
+
}
|
|
5367
|
+
if (column.getAttributeNS(WORD_NS, "w") !== String(width)) set(column, "w", String(width));
|
|
5368
|
+
});
|
|
5369
|
+
for (const extra of old.slice(table.grid.length)) grid.removeChild(extra);
|
|
5370
|
+
}
|
|
5371
|
+
function writeRestructuredTable(doc, table, node, base, writeParagraph, replaceSlots2, writeNested) {
|
|
5372
|
+
if (table.rows.some((row) => !row.length || row.some((cell2) => !cell2.paragraphs.length)))
|
|
5373
|
+
throw new Error("Every table row needs a cell and every cell a paragraph.");
|
|
5374
|
+
const oldRows = flatRows(node).map((entry2) => entry2.element);
|
|
5375
|
+
const oldCells = oldRows.map((tr) => flatCells(tr).map((entry2) => entry2.element));
|
|
5376
|
+
const cellById = /* @__PURE__ */ new Map();
|
|
5377
|
+
const paragraphById = /* @__PURE__ */ new Map();
|
|
5378
|
+
base.rows.forEach(
|
|
5379
|
+
(row, ri) => row.forEach((cell2, ci) => {
|
|
5380
|
+
const tc = oldCells[ri]?.[ci];
|
|
5381
|
+
if (!tc) return;
|
|
5382
|
+
const id = cell2.paragraphs[0]?.id;
|
|
5383
|
+
if (id) cellById.set(id, { tc, model: cell2, row: ri });
|
|
5384
|
+
const flat = flatCellParagraphs(tc);
|
|
5385
|
+
cell2.paragraphs.forEach((model, pi) => {
|
|
5386
|
+
const entry2 = flat[pi];
|
|
5387
|
+
if (entry2) paragraphById.set(model.id, { element: entry2.element, model });
|
|
5388
|
+
});
|
|
5389
|
+
})
|
|
5390
|
+
);
|
|
5391
|
+
const usedRows = /* @__PURE__ */ new Set();
|
|
5392
|
+
const usedCells = /* @__PURE__ */ new Set();
|
|
5393
|
+
const nextRows = table.rows.map((row, rowIndex) => {
|
|
5394
|
+
const sourceRow = row.map((cell2) => cellById.get(cell2.paragraphs[0]?.id ?? "")?.row).find((index) => index !== void 0 && !usedRows.has(index));
|
|
5395
|
+
if (sourceRow !== void 0) usedRows.add(sourceRow);
|
|
5396
|
+
const tr = sourceRow === void 0 ? makeW(doc, "tr") : oldRows[sourceRow] ?? makeW(doc, "tr");
|
|
5397
|
+
patchRowProperties(
|
|
5398
|
+
doc,
|
|
5399
|
+
tr,
|
|
5400
|
+
table.rowProperties?.[rowIndex],
|
|
5401
|
+
sourceRow === void 0 ? void 0 : base.rowProperties?.[sourceRow]
|
|
5402
|
+
);
|
|
5403
|
+
const nextCells = row.map((cell2) => {
|
|
5404
|
+
const source2 = cellById.get(cell2.paragraphs[0]?.id ?? "");
|
|
5405
|
+
const reuse = source2 && source2.row === sourceRow && !usedCells.has(source2.tc) ? source2 : void 0;
|
|
5406
|
+
const tc = reuse?.tc ?? makeW(doc, "tc");
|
|
5407
|
+
if (reuse) {
|
|
5408
|
+
usedCells.add(reuse.tc);
|
|
5409
|
+
patchCellLayout(doc, tc, cell2, reuse.model);
|
|
5410
|
+
patchCellBorders(doc, tc, cell2.borders, reuse.model.borders);
|
|
5411
|
+
patchCellShading(doc, tc, cell2, reuse.model);
|
|
5412
|
+
patchCellMargins(doc, tc, cell2.margins, reuse.model.margins);
|
|
5413
|
+
patchCellVerticalAlignment(doc, tc, cell2.verticalAlign, reuse.model.verticalAlign);
|
|
5414
|
+
} else {
|
|
5415
|
+
const props = buildCellProperties(doc, cell2);
|
|
5416
|
+
if (props) tc.insertBefore(props, tc.firstChild);
|
|
5417
|
+
}
|
|
5418
|
+
const oldParagraphs = reuse ? flatCellParagraphs(tc).map((entry2) => entry2.element) : [];
|
|
5419
|
+
const owned = new Set(oldParagraphs);
|
|
5420
|
+
const nextParagraphs = cell2.paragraphs.map((paragraph2) => {
|
|
5421
|
+
const found = paragraphById.get(paragraph2.id);
|
|
5422
|
+
const element4 = found ? owned.has(found.element) ? found.element : found.element.cloneNode(true) : makeW(doc, "p");
|
|
5423
|
+
return writeParagraph(doc, paragraph2, element4, found?.model);
|
|
5424
|
+
});
|
|
5425
|
+
replaceSlots2(doc, tc, oldParagraphs, nextParagraphs);
|
|
5426
|
+
if (reuse) writeNested(doc, tc, cell2, reuse.model);
|
|
5427
|
+
return tc;
|
|
5428
|
+
});
|
|
5429
|
+
replaceSlots2(doc, tr, sourceRow === void 0 ? [] : oldCells[sourceRow] ?? [], nextCells);
|
|
5430
|
+
return tr;
|
|
5431
|
+
});
|
|
5432
|
+
replaceSlots2(doc, node, oldRows, nextRows);
|
|
5433
|
+
patchTableMargins(doc, table, node, base);
|
|
5434
|
+
patchGrid(doc, node, table);
|
|
5435
|
+
return node;
|
|
5436
|
+
}
|
|
5437
|
+
|
|
5438
|
+
// docx/table-grid.ts
|
|
5439
|
+
var spanOf = (cell2) => Math.max(1, cell2.gridSpan ?? 1);
|
|
5440
|
+
function tableGrid(table) {
|
|
5441
|
+
const columns = table.grid?.length ?? sumSpans(table.rows[0]);
|
|
5442
|
+
if (!columns || !table.rows.length) return void 0;
|
|
5443
|
+
const rows = [];
|
|
5444
|
+
const cover = [];
|
|
5445
|
+
for (let row = 0; row < table.rows.length; row++) {
|
|
5446
|
+
const cells = table.rows[row] ?? [];
|
|
5447
|
+
if (!cells.length || sumSpans(cells) !== columns) return void 0;
|
|
5448
|
+
const placed = [];
|
|
5449
|
+
const line2 = new Array(columns);
|
|
5450
|
+
let col = 0;
|
|
5451
|
+
cells.forEach((cell2, index) => {
|
|
5452
|
+
const entry2 = { cell: cell2, row, index, col, span: spanOf(cell2) };
|
|
5453
|
+
for (let k = 0; k < entry2.span; k++) line2[col + k] = entry2;
|
|
5454
|
+
col += entry2.span;
|
|
5455
|
+
placed.push(entry2);
|
|
5456
|
+
});
|
|
5457
|
+
rows.push(placed);
|
|
5458
|
+
cover.push(line2);
|
|
5459
|
+
}
|
|
5460
|
+
const grid = { columns, rows, cover };
|
|
5461
|
+
for (const entry2 of rows.flat())
|
|
5462
|
+
if (entry2.cell.verticalMerge === "continue") {
|
|
5463
|
+
const above = entry2.row > 0 ? cover[entry2.row - 1]?.[entry2.col] : void 0;
|
|
5464
|
+
if (!above || above.col !== entry2.col || above.span !== entry2.span) return void 0;
|
|
5465
|
+
if (!above.cell.verticalMerge) return void 0;
|
|
5466
|
+
}
|
|
5467
|
+
return grid;
|
|
5468
|
+
}
|
|
5469
|
+
function sumSpans(cells) {
|
|
5470
|
+
return (cells ?? []).reduce((sum, cell2) => sum + spanOf(cell2), 0);
|
|
5471
|
+
}
|
|
5472
|
+
|
|
5473
|
+
// docx/write-table.ts
|
|
4535
5474
|
var layout = (table) => table.rows.map((row) => row.map((cell2) => cell2.paragraphs.map((p) => p.id)));
|
|
4536
5475
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
4537
5476
|
"grid",
|
|
@@ -4549,13 +5488,15 @@ function pick(source2, keys) {
|
|
|
4549
5488
|
for (const key of keys) if (record[key] !== void 0) result[key] = record[key];
|
|
4550
5489
|
return result;
|
|
4551
5490
|
}
|
|
4552
|
-
function assertNoDescriptorEdits(table, base) {
|
|
5491
|
+
function assertNoDescriptorEdits(table, base, layoutEdits = false) {
|
|
4553
5492
|
if (!base) return;
|
|
4554
|
-
|
|
5493
|
+
const tableKeys = layoutEdits ? TABLE_DESCRIPTOR_KEYS.filter((key) => key !== "grid") : TABLE_DESCRIPTOR_KEYS;
|
|
5494
|
+
if (JSON.stringify(pick(table, tableKeys)) !== JSON.stringify(pick(base, tableKeys)))
|
|
4555
5495
|
throw new Error(
|
|
4556
5496
|
"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."
|
|
4557
5497
|
);
|
|
4558
5498
|
const baseCellById = /* @__PURE__ */ new Map();
|
|
5499
|
+
if (layoutEdits) return;
|
|
4559
5500
|
for (const row of base.rows)
|
|
4560
5501
|
for (const cell2 of row) {
|
|
4561
5502
|
const id = cell2.paragraphs[0]?.id;
|
|
@@ -4580,11 +5521,24 @@ function writeNestedTables(doc, tc, cell2, base, writeParagraph, replaceSlots2)
|
|
|
4580
5521
|
next.forEach((table, index) => {
|
|
4581
5522
|
const node = nodes[index];
|
|
4582
5523
|
if (node && before[index])
|
|
4583
|
-
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2);
|
|
5524
|
+
writeTable(doc, table, node, before[index], writeParagraph, replaceSlots2, true);
|
|
4584
5525
|
});
|
|
4585
5526
|
}
|
|
4586
|
-
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
5527
|
+
function writeTable(doc, table, node, base, writeParagraph, replaceSlots2, nested = false) {
|
|
4587
5528
|
if (base && JSON.stringify(table) === JSON.stringify(base)) return node;
|
|
5529
|
+
const baseGrid = base && tableGrid(base);
|
|
5530
|
+
if (base && baseGrid && (nested || !base.structureEditable || table.structureEditable === false) && restructured(table, base) && canRestructureTable(node)) {
|
|
5531
|
+
assertNoDescriptorEdits(table, base, true);
|
|
5532
|
+
return writeRestructuredTable(
|
|
5533
|
+
doc,
|
|
5534
|
+
table,
|
|
5535
|
+
node,
|
|
5536
|
+
base,
|
|
5537
|
+
writeParagraph,
|
|
5538
|
+
replaceSlots2,
|
|
5539
|
+
(d, tc, cell2, before) => writeNestedTables(d, tc, cell2, before, writeParagraph, replaceSlots2)
|
|
5540
|
+
);
|
|
5541
|
+
}
|
|
4588
5542
|
assertNoDescriptorEdits(table, base);
|
|
4589
5543
|
patchTableMargins(doc, table, node, base);
|
|
4590
5544
|
const structural = base && JSON.stringify(layout(table)) !== JSON.stringify(layout(base));
|
|
@@ -4710,13 +5664,13 @@ function writeTable(doc, table, node, base, writeParagraph, replaceSlots2) {
|
|
|
4710
5664
|
|
|
4711
5665
|
// docx/write-footnote-columns.ts
|
|
4712
5666
|
var W15 = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
4713
|
-
var
|
|
5667
|
+
var XMLNS4 = "http://www.w3.org/2000/xmlns/";
|
|
4714
5668
|
var MC2 = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
4715
5669
|
function prefix(doc, preferred, namespace) {
|
|
4716
5670
|
let name = preferred;
|
|
4717
5671
|
for (let suffix = 1; doc.documentElement.lookupNamespaceURI(name) && doc.documentElement.lookupNamespaceURI(name) !== namespace; suffix++)
|
|
4718
5672
|
name = preferred + suffix;
|
|
4719
|
-
doc.documentElement.setAttributeNS(
|
|
5673
|
+
doc.documentElement.setAttributeNS(XMLNS4, "xmlns:" + name, namespace);
|
|
4720
5674
|
return name;
|
|
4721
5675
|
}
|
|
4722
5676
|
function writeFootnoteColumns(doc, section, value) {
|
|
@@ -4739,13 +5693,13 @@ function writeFootnoteColumns(doc, section, value) {
|
|
|
4739
5693
|
}
|
|
4740
5694
|
|
|
4741
5695
|
// docx/page-borders.ts
|
|
4742
|
-
var
|
|
5696
|
+
var SIDES5 = ["top", "left", "bottom", "right"];
|
|
4743
5697
|
var ATTRIBUTES = ["offsetFrom", "display", "zOrder"];
|
|
4744
5698
|
var setW4 = (element4, name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, value);
|
|
4745
5699
|
function parsePageBorders(element4) {
|
|
4746
5700
|
if (!element4) return void 0;
|
|
4747
5701
|
const result = {};
|
|
4748
|
-
for (const side of
|
|
5702
|
+
for (const side of SIDES5) {
|
|
4749
5703
|
const source2 = first2(element4, side);
|
|
4750
5704
|
const value = borderSide(source2);
|
|
4751
5705
|
const art = getW(source2, "art");
|
|
@@ -4783,7 +5737,7 @@ function patchPageBorders(doc, sectPr, next, base, create2) {
|
|
|
4783
5737
|
return;
|
|
4784
5738
|
}
|
|
4785
5739
|
const element4 = create2(doc, sectPr, "pgBorders");
|
|
4786
|
-
for (const side of
|
|
5740
|
+
for (const side of SIDES5) {
|
|
4787
5741
|
if (JSON.stringify(next[side]) === JSON.stringify(base?.[side])) continue;
|
|
4788
5742
|
for (const old of children2(element4, side)) element4.removeChild(old);
|
|
4789
5743
|
const value = next[side];
|
|
@@ -4964,75 +5918,6 @@ function writePageNumbering(doc, sectPr, section) {
|
|
|
4964
5918
|
}
|
|
4965
5919
|
}
|
|
4966
5920
|
|
|
4967
|
-
// docx/tab-stops.ts
|
|
4968
|
-
function parseTabStops(tabs) {
|
|
4969
|
-
const stops = [];
|
|
4970
|
-
for (const tab of tabs ? children2(tabs, "tab") : []) {
|
|
4971
|
-
const align = enumValue(isStTabJc, getW(tab, "val"), "w:tab/@w:val");
|
|
4972
|
-
const pos = parseSignedTwips(getW(tab, "pos"));
|
|
4973
|
-
if (!align || pos === void 0) continue;
|
|
4974
|
-
const leader = enumValue(isStTabTlc, getW(tab, "leader"), "w:tab/@w:leader");
|
|
4975
|
-
stops.push({ posTwips: pos, align, ...leader ? { leader } : {} });
|
|
4976
|
-
}
|
|
4977
|
-
return stops;
|
|
4978
|
-
}
|
|
4979
|
-
function writeTabStops(doc, props, paragraph2, base) {
|
|
4980
|
-
if (base && JSON.stringify(paragraph2.tabStops ?? []) === JSON.stringify(base.tabStops ?? []))
|
|
4981
|
-
return;
|
|
4982
|
-
for (const tabs2 of children2(props, "tabs")) props.removeChild(tabs2);
|
|
4983
|
-
if (!paragraph2.tabStops?.length) return;
|
|
4984
|
-
const tabs = makeW(doc, "tabs");
|
|
4985
|
-
for (const stop of paragraph2.tabStops) {
|
|
4986
|
-
const tab = makeW(doc, "tab");
|
|
4987
|
-
tab.setAttributeNS(WORD_NS, "w:val", stop.align);
|
|
4988
|
-
if (stop.leader) tab.setAttributeNS(WORD_NS, "w:leader", stop.leader);
|
|
4989
|
-
tab.setAttributeNS(WORD_NS, "w:pos", String(stop.posTwips));
|
|
4990
|
-
tabs.appendChild(tab);
|
|
4991
|
-
}
|
|
4992
|
-
props.appendChild(tabs);
|
|
4993
|
-
}
|
|
4994
|
-
var PPR_ORDER = [
|
|
4995
|
-
"pStyle",
|
|
4996
|
-
"keepNext",
|
|
4997
|
-
"keepLines",
|
|
4998
|
-
"pageBreakBefore",
|
|
4999
|
-
"framePr",
|
|
5000
|
-
"widowControl",
|
|
5001
|
-
"numPr",
|
|
5002
|
-
"suppressLineNumbers",
|
|
5003
|
-
"pBdr",
|
|
5004
|
-
"shd",
|
|
5005
|
-
"tabs",
|
|
5006
|
-
"suppressAutoHyphens",
|
|
5007
|
-
"kinsoku",
|
|
5008
|
-
"wordWrap",
|
|
5009
|
-
"overflowPunct",
|
|
5010
|
-
"topLinePunct",
|
|
5011
|
-
"autoSpaceDE",
|
|
5012
|
-
"autoSpaceDN",
|
|
5013
|
-
"bidi",
|
|
5014
|
-
"adjustRightInd",
|
|
5015
|
-
"snapToGrid",
|
|
5016
|
-
"spacing",
|
|
5017
|
-
"ind",
|
|
5018
|
-
"contextualSpacing",
|
|
5019
|
-
"mirrorIndents",
|
|
5020
|
-
"suppressOverlap",
|
|
5021
|
-
"jc",
|
|
5022
|
-
"textDirection",
|
|
5023
|
-
"textAlignment",
|
|
5024
|
-
"textboxTightWrap",
|
|
5025
|
-
"outlineLvl",
|
|
5026
|
-
"divId",
|
|
5027
|
-
"cnfStyle",
|
|
5028
|
-
"rPr",
|
|
5029
|
-
"sectPr",
|
|
5030
|
-
"pPrChange"
|
|
5031
|
-
];
|
|
5032
|
-
function orderParagraphProperties(props) {
|
|
5033
|
-
orderChildren(props, PPR_ORDER);
|
|
5034
|
-
}
|
|
5035
|
-
|
|
5036
5921
|
// docx/write-sections.ts
|
|
5037
5922
|
var WRITABLE = /* @__PURE__ */ new Set([
|
|
5038
5923
|
"endsAtBlockId",
|
|
@@ -5637,16 +6522,16 @@ function isWordElement(element4, names) {
|
|
|
5637
6522
|
}
|
|
5638
6523
|
var isRevisionWrapperElement = (element4) => isWordElement(element4, REVISION_WRAPPER_NAMES2);
|
|
5639
6524
|
var isCommentAnchorElement = (element4) => isWordElement(element4, COMMENT_ANCHOR_NAMES);
|
|
5640
|
-
function
|
|
6525
|
+
function setAttribute3(element4, local, value) {
|
|
5641
6526
|
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
5642
6527
|
}
|
|
5643
6528
|
function removeChildren(element4, local) {
|
|
5644
6529
|
for (const child7 of children2(element4, local)) element4.removeChild(child7);
|
|
5645
6530
|
}
|
|
5646
6531
|
function writeRevisionMetadata(element4, revision) {
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
if (revision.date)
|
|
6532
|
+
setAttribute3(element4, "id", revision.id);
|
|
6533
|
+
setAttribute3(element4, "author", revision.author);
|
|
6534
|
+
if (revision.date) setAttribute3(element4, "date", revision.date);
|
|
5650
6535
|
else element4.removeAttributeNS(WORD_NS, "date");
|
|
5651
6536
|
if (revision.dateUtc) element4.setAttributeNS(WORD_DATE_UTC_NS, "w16du:dateUtc", revision.dateUtc);
|
|
5652
6537
|
else element4.removeAttributeNS(WORD_DATE_UTC_NS, "dateUtc");
|
|
@@ -5781,184 +6666,6 @@ function restoreAnnotations(markers, before, after) {
|
|
|
5781
6666
|
}
|
|
5782
6667
|
}
|
|
5783
6668
|
|
|
5784
|
-
// docx/write-paragraph-decoration.ts
|
|
5785
|
-
var SIDES5 = ["top", "left", "bottom", "right", "between"];
|
|
5786
|
-
function wordColor(color) {
|
|
5787
|
-
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
5788
|
-
return hex ? hex.toUpperCase() : "auto";
|
|
5789
|
-
}
|
|
5790
|
-
function borderElement(doc, name, side) {
|
|
5791
|
-
const element4 = makeW(doc, name);
|
|
5792
|
-
const set = (local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
5793
|
-
set("val", side.style ?? "single");
|
|
5794
|
-
if (side.style !== "none" && side.style !== "nil") {
|
|
5795
|
-
set("sz", String(side.sizeEighthPoints ?? 4));
|
|
5796
|
-
set("space", String(side.spacePoints ?? 1));
|
|
5797
|
-
set("color", wordColor(side.color));
|
|
5798
|
-
if (side.themeColor) set("themeColor", side.themeColor);
|
|
5799
|
-
}
|
|
5800
|
-
return element4;
|
|
5801
|
-
}
|
|
5802
|
-
var sameJson = (a2, b) => JSON.stringify(a2 ?? null) === JSON.stringify(b ?? null);
|
|
5803
|
-
function updateShading(doc, props, paragraph2, base) {
|
|
5804
|
-
if (base && paragraph2.shadingFill === base.shadingFill) return;
|
|
5805
|
-
for (const element4 of children2(props, "shd")) props.removeChild(element4);
|
|
5806
|
-
if (!paragraph2.shadingFill) return;
|
|
5807
|
-
const shd = makeW(doc, "shd");
|
|
5808
|
-
shd.setAttributeNS(WORD_NS, "w:val", "clear");
|
|
5809
|
-
shd.setAttributeNS(WORD_NS, "w:color", "auto");
|
|
5810
|
-
shd.setAttributeNS(WORD_NS, "w:fill", wordColor(paragraph2.shadingFill));
|
|
5811
|
-
props.appendChild(shd);
|
|
5812
|
-
}
|
|
5813
|
-
function updateBorders(doc, props, paragraph2, base) {
|
|
5814
|
-
if (base && sameJson(paragraph2.borders, base.borders)) return;
|
|
5815
|
-
for (const element4 of children2(props, "pBdr")) props.removeChild(element4);
|
|
5816
|
-
const borders = paragraph2.borders;
|
|
5817
|
-
if (!borders) return;
|
|
5818
|
-
const pBdr = makeW(doc, "pBdr");
|
|
5819
|
-
for (const side of SIDES5) {
|
|
5820
|
-
const value = borders[side];
|
|
5821
|
-
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
5822
|
-
}
|
|
5823
|
-
if (pBdr.childNodes.length) props.appendChild(pBdr);
|
|
5824
|
-
}
|
|
5825
|
-
function writeParagraphDecoration(doc, props, paragraph2, base) {
|
|
5826
|
-
updateShading(doc, props, paragraph2, base);
|
|
5827
|
-
updateBorders(doc, props, paragraph2, base);
|
|
5828
|
-
}
|
|
5829
|
-
|
|
5830
|
-
// docx/write-paragraph-properties.ts
|
|
5831
|
-
function setAttribute3(element4, local, value) {
|
|
5832
|
-
element4.setAttributeNS(WORD_NS, `w:${local}`, value);
|
|
5833
|
-
}
|
|
5834
|
-
function setWordValue(element4, local, value) {
|
|
5835
|
-
if (value === void 0) element4.removeAttributeNS(WORD_NS, local);
|
|
5836
|
-
else setAttribute3(element4, local, String(value));
|
|
5837
|
-
}
|
|
5838
|
-
function updateDirection(doc, props, paragraph2, base) {
|
|
5839
|
-
if (base && paragraph2.direction === base.direction) return;
|
|
5840
|
-
let bidi = first2(props, "bidi");
|
|
5841
|
-
if (paragraph2.direction === void 0) {
|
|
5842
|
-
for (const element4 of children2(props, "bidi")) props.removeChild(element4);
|
|
5843
|
-
} else {
|
|
5844
|
-
if (!bidi) {
|
|
5845
|
-
bidi = makeW(doc, "bidi");
|
|
5846
|
-
props.appendChild(bidi);
|
|
5847
|
-
}
|
|
5848
|
-
setAttribute3(bidi, "val", paragraph2.direction === "rtl" ? "1" : "0");
|
|
5849
|
-
}
|
|
5850
|
-
}
|
|
5851
|
-
function updateSpacing(doc, props, paragraph2, base) {
|
|
5852
|
-
let spacing2 = first2(props, "spacing");
|
|
5853
|
-
if (!spacing2) {
|
|
5854
|
-
spacing2 = makeW(doc, "spacing");
|
|
5855
|
-
props.appendChild(spacing2);
|
|
5856
|
-
}
|
|
5857
|
-
if (!base || paragraph2.spacingBeforeTwips !== base.spacingBeforeTwips)
|
|
5858
|
-
setWordValue(spacing2, "before", paragraph2.spacingBeforeTwips);
|
|
5859
|
-
if (!base || paragraph2.spacingAfterTwips !== base.spacingAfterTwips)
|
|
5860
|
-
setWordValue(spacing2, "after", paragraph2.spacingAfterTwips);
|
|
5861
|
-
if (!base || paragraph2.lineSpacingTwips !== base.lineSpacingTwips || paragraph2.lineSpacingRule !== base.lineSpacingRule) {
|
|
5862
|
-
setWordValue(spacing2, "line", paragraph2.lineSpacingTwips);
|
|
5863
|
-
setWordValue(
|
|
5864
|
-
spacing2,
|
|
5865
|
-
"lineRule",
|
|
5866
|
-
paragraph2.lineSpacingRule ?? (paragraph2.lineSpacingTwips === void 0 ? void 0 : "auto")
|
|
5867
|
-
);
|
|
5868
|
-
}
|
|
5869
|
-
if (!spacing2.attributes.length && !spacing2.childNodes.length) props.removeChild(spacing2);
|
|
5870
|
-
}
|
|
5871
|
-
function updateIndent(doc, props, paragraph2, base) {
|
|
5872
|
-
let indent = first2(props, "ind");
|
|
5873
|
-
if (!indent) {
|
|
5874
|
-
indent = makeW(doc, "ind");
|
|
5875
|
-
props.appendChild(indent);
|
|
5876
|
-
}
|
|
5877
|
-
if (!base || paragraph2.indentLeftTwips !== base.indentLeftTwips)
|
|
5878
|
-
setWordValue(indent, "left", paragraph2.indentLeftTwips);
|
|
5879
|
-
if (!base || paragraph2.indentRightTwips !== base.indentRightTwips)
|
|
5880
|
-
setWordValue(indent, "right", paragraph2.indentRightTwips);
|
|
5881
|
-
if (!base || paragraph2.indentStartTwips !== base.indentStartTwips)
|
|
5882
|
-
setWordValue(indent, "start", paragraph2.indentStartTwips);
|
|
5883
|
-
if (!base || paragraph2.indentEndTwips !== base.indentEndTwips)
|
|
5884
|
-
setWordValue(indent, "end", paragraph2.indentEndTwips);
|
|
5885
|
-
if (!base || paragraph2.firstLineTwips !== base.firstLineTwips)
|
|
5886
|
-
setWordValue(indent, "firstLine", paragraph2.firstLineTwips);
|
|
5887
|
-
if (!base || paragraph2.hangingTwips !== base.hangingTwips)
|
|
5888
|
-
setWordValue(indent, "hanging", paragraph2.hangingTwips);
|
|
5889
|
-
if (!indent.attributes.length) props.removeChild(indent);
|
|
5890
|
-
}
|
|
5891
|
-
function updatePageBreakBefore(doc, props, paragraph2, base) {
|
|
5892
|
-
if (base && paragraph2.pageBreakBefore === base.pageBreakBefore) return;
|
|
5893
|
-
for (const element4 of children2(props, "pageBreakBefore")) props.removeChild(element4);
|
|
5894
|
-
if (paragraph2.pageBreakBefore !== void 0) {
|
|
5895
|
-
const element4 = makeW(doc, "pageBreakBefore");
|
|
5896
|
-
if (!paragraph2.pageBreakBefore) element4.setAttributeNS(WORD_NS, "w:val", "0");
|
|
5897
|
-
props.appendChild(element4);
|
|
5898
|
-
}
|
|
5899
|
-
}
|
|
5900
|
-
function updateKeepOptions(doc, props, paragraph2, base) {
|
|
5901
|
-
for (const key of [
|
|
5902
|
-
"keepNext",
|
|
5903
|
-
"keepLines",
|
|
5904
|
-
"widowControl",
|
|
5905
|
-
"contextualSpacing",
|
|
5906
|
-
"suppressLineNumbers"
|
|
5907
|
-
]) {
|
|
5908
|
-
if (base && paragraph2[key] === base[key]) continue;
|
|
5909
|
-
for (const element5 of children2(props, key)) props.removeChild(element5);
|
|
5910
|
-
const value = paragraph2[key];
|
|
5911
|
-
if (value === void 0) continue;
|
|
5912
|
-
const element4 = makeW(doc, key);
|
|
5913
|
-
if (!value) setAttribute3(element4, "val", "0");
|
|
5914
|
-
props.appendChild(element4);
|
|
5915
|
-
}
|
|
5916
|
-
}
|
|
5917
|
-
function updateDropCap(doc, props, paragraph2, base) {
|
|
5918
|
-
if (base && JSON.stringify(paragraph2.dropCap) === JSON.stringify(base.dropCap)) return;
|
|
5919
|
-
let frame2 = first2(props, "framePr");
|
|
5920
|
-
const cap = paragraph2.dropCap;
|
|
5921
|
-
if (!cap) {
|
|
5922
|
-
if (frame2) props.removeChild(frame2);
|
|
5923
|
-
return;
|
|
5924
|
-
}
|
|
5925
|
-
if (!frame2) {
|
|
5926
|
-
frame2 = makeW(doc, "framePr");
|
|
5927
|
-
props.appendChild(frame2);
|
|
5928
|
-
setAttribute3(frame2, "wrap", "around");
|
|
5929
|
-
setAttribute3(frame2, "vAnchor", "text");
|
|
5930
|
-
setAttribute3(frame2, "hAnchor", "text");
|
|
5931
|
-
}
|
|
5932
|
-
setAttribute3(frame2, "dropCap", cap.style);
|
|
5933
|
-
setAttribute3(frame2, "lines", String(cap.lines));
|
|
5934
|
-
setWordValue(frame2, "hSpace", cap.distanceTwips);
|
|
5935
|
-
}
|
|
5936
|
-
function writeParagraphProperties(doc, props, paragraph2, base) {
|
|
5937
|
-
updatePageBreakBefore(doc, props, paragraph2, base);
|
|
5938
|
-
updateKeepOptions(doc, props, paragraph2, base);
|
|
5939
|
-
updateDropCap(doc, props, paragraph2, base);
|
|
5940
|
-
updateDirection(doc, props, paragraph2, base);
|
|
5941
|
-
writeParagraphDecoration(doc, props, paragraph2, base);
|
|
5942
|
-
const spacingKeys = [
|
|
5943
|
-
"spacingBeforeTwips",
|
|
5944
|
-
"spacingAfterTwips",
|
|
5945
|
-
"lineSpacingTwips",
|
|
5946
|
-
"lineSpacingRule"
|
|
5947
|
-
];
|
|
5948
|
-
if (!base || spacingKeys.some((key) => paragraph2[key] !== base[key]))
|
|
5949
|
-
updateSpacing(doc, props, paragraph2, base);
|
|
5950
|
-
const indentKeys = [
|
|
5951
|
-
"indentLeftTwips",
|
|
5952
|
-
"indentRightTwips",
|
|
5953
|
-
"indentStartTwips",
|
|
5954
|
-
"indentEndTwips",
|
|
5955
|
-
"firstLineTwips",
|
|
5956
|
-
"hangingTwips"
|
|
5957
|
-
];
|
|
5958
|
-
if (!base || indentKeys.some((key) => paragraph2[key] !== base[key]))
|
|
5959
|
-
updateIndent(doc, props, paragraph2, base);
|
|
5960
|
-
}
|
|
5961
|
-
|
|
5962
6669
|
// docx/bookmarks.ts
|
|
5963
6670
|
function paragraphBookmarkNames(node) {
|
|
5964
6671
|
return children2(node, "bookmarkStart").map((el5) => getW(el5, "name")).filter((name) => Boolean(name));
|
|
@@ -8039,10 +8746,10 @@ function writeDrawingRichTextBody(container, body) {
|
|
|
8039
8746
|
const paragraphs = body.paragraphs.length ? body.paragraphs : [{ items: [] }];
|
|
8040
8747
|
for (const paragraph2 of paragraphs) container.appendChild(writeDrawingParagraph(doc, paragraph2));
|
|
8041
8748
|
}
|
|
8042
|
-
function drawingRichTextBodyXml(body,
|
|
8043
|
-
const prefix2 =
|
|
8749
|
+
function drawingRichTextBodyXml(body, qualifiedName2 = "a:txBody", namespace = NS.a) {
|
|
8750
|
+
const prefix2 = qualifiedName2.includes(":") ? qualifiedName2.split(":")[0] : void 0;
|
|
8044
8751
|
const declaration = prefix2 && prefix2 !== "a" ? ` xmlns:${prefix2}="${namespace}"` : "";
|
|
8045
|
-
const doc = parseXml(`<${
|
|
8752
|
+
const doc = parseXml(`<${qualifiedName2}${declaration} xmlns:a="${NS.a}" xmlns:r="${NS.r}"/>`);
|
|
8046
8753
|
writeDrawingRichTextBody(doc.documentElement, body);
|
|
8047
8754
|
return buildXml(doc);
|
|
8048
8755
|
}
|
|
@@ -14967,7 +15674,8 @@ var pie = {
|
|
|
14967
15674
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
14968
15675
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
14969
15676
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
14970
|
-
gd16("
|
|
15677
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15678
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
14971
15679
|
gd16("stx", "cos wd2 stAng"),
|
|
14972
15680
|
gd16("sty", "sin hd2 stAng"),
|
|
14973
15681
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15012,7 +15720,8 @@ var chord = {
|
|
|
15012
15720
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
15013
15721
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
15014
15722
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15015
|
-
gd16("
|
|
15723
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15724
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15016
15725
|
gd16("stx", "cos wd2 stAng"),
|
|
15017
15726
|
gd16("sty", "sin hd2 stAng"),
|
|
15018
15727
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15036,7 +15745,8 @@ var arc = {
|
|
|
15036
15745
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
15037
15746
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
15038
15747
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15039
|
-
gd16("
|
|
15748
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15749
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15040
15750
|
gd16("stx", "cos wd2 stAng"),
|
|
15041
15751
|
gd16("sty", "sin hd2 stAng"),
|
|
15042
15752
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -15131,7 +15841,8 @@ var blockArc = {
|
|
|
15131
15841
|
gd16("iwd2", "+- wd2 0 thw"),
|
|
15132
15842
|
gd16("ihd2", "+- hd2 0 thh2"),
|
|
15133
15843
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
15134
|
-
gd16("
|
|
15844
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
15845
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
15135
15846
|
gd16("mswAng", "+- 0 0 swAng2"),
|
|
15136
15847
|
gd16("stx", "cos wd2 stAng"),
|
|
15137
15848
|
gd16("sty", "sin hd2 stAng"),
|
|
@@ -17294,12 +18005,12 @@ function shapeParagraphs(wsp) {
|
|
|
17294
18005
|
function textIsPlain(wsp) {
|
|
17295
18006
|
const content = child4(child4(wsp, WPS_NS2, "txbx"), W_NS2, "txbxContent");
|
|
17296
18007
|
if (!content) return true;
|
|
17297
|
-
const
|
|
18008
|
+
const only2 = (node, allowed) => elementsOf(node).every(
|
|
17298
18009
|
(item2) => item2.namespaceURI === W_NS2 && allowed.includes(item2.localName)
|
|
17299
18010
|
);
|
|
17300
|
-
return
|
|
17301
|
-
(paragraph2) =>
|
|
17302
|
-
(run2) =>
|
|
18011
|
+
return only2(content, ["p"]) && Array.from(content.getElementsByTagNameNS(W_NS2, "p")).every(
|
|
18012
|
+
(paragraph2) => only2(paragraph2, ["pPr", "r"]) && Array.from(paragraph2.getElementsByTagNameNS(W_NS2, "r")).every(
|
|
18013
|
+
(run2) => only2(run2, ["rPr", "t"])
|
|
17303
18014
|
)
|
|
17304
18015
|
);
|
|
17305
18016
|
}
|
|
@@ -17542,7 +18253,7 @@ function parseAttributes(source2) {
|
|
|
17542
18253
|
}
|
|
17543
18254
|
return attrs2;
|
|
17544
18255
|
}
|
|
17545
|
-
function
|
|
18256
|
+
function tagEnd2(xml, from) {
|
|
17546
18257
|
let quote = "";
|
|
17547
18258
|
for (let i = from; i < xml.length; i++) {
|
|
17548
18259
|
const ch = xml[i];
|
|
@@ -17573,7 +18284,7 @@ function parseOrderedXml(xml) {
|
|
|
17573
18284
|
i = close < 0 ? -1 : xml.indexOf("<", close + 3);
|
|
17574
18285
|
continue;
|
|
17575
18286
|
}
|
|
17576
|
-
const end =
|
|
18287
|
+
const end = tagEnd2(xml, i + 1);
|
|
17577
18288
|
if (end < 0) {
|
|
17578
18289
|
break;
|
|
17579
18290
|
}
|
|
@@ -18153,17 +18864,17 @@ function isShadowedBound(node, constraint) {
|
|
|
18153
18864
|
|
|
18154
18865
|
// diagram/engine/constraint-eval.ts
|
|
18155
18866
|
function relatedNodes(node, relation2, name, ptType) {
|
|
18156
|
-
const
|
|
18867
|
+
const matches2 = (candidate) => (!name || candidate.name === name) && (matchesPointType(candidate.point, ptType) || candidate.presOf.length > 0 && matchesPointType(candidate.presOf[0], ptType));
|
|
18157
18868
|
if (relation2 === "self") {
|
|
18158
18869
|
return name && node.name !== name ? [] : [node];
|
|
18159
18870
|
}
|
|
18160
18871
|
if (relation2 === "ch") {
|
|
18161
|
-
return node.children.filter(
|
|
18872
|
+
return node.children.filter(matches2);
|
|
18162
18873
|
}
|
|
18163
18874
|
const out = [];
|
|
18164
18875
|
const visit = (current) => {
|
|
18165
18876
|
for (const child7 of current.children) {
|
|
18166
|
-
if (
|
|
18877
|
+
if (matches2(child7)) {
|
|
18167
18878
|
out.push(child7);
|
|
18168
18879
|
}
|
|
18169
18880
|
visit(child7);
|
|
@@ -25475,8 +26186,8 @@ function parseDisplayUnits(context, element4) {
|
|
|
25475
26186
|
|
|
25476
26187
|
// chart/write-util.ts
|
|
25477
26188
|
var INVALID_XML = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
25478
|
-
var
|
|
25479
|
-
var escapeAttribute = (value) =>
|
|
26189
|
+
var escapeText2 = (value) => value.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
26190
|
+
var escapeAttribute = (value) => escapeText2(value).replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
25480
26191
|
function chartNumber(value) {
|
|
25481
26192
|
if (!Number.isFinite(value)) throw new Error(`Chart number ${value} is not finite`);
|
|
25482
26193
|
const text = String(value);
|
|
@@ -26156,7 +26867,7 @@ function run(value) {
|
|
|
26156
26867
|
const hasProperties = Object.keys(properties).length > 0;
|
|
26157
26868
|
if (text === "\n")
|
|
26158
26869
|
return hasProperties ? `<a:br>${runProperties("rPr", properties)}</a:br>` : "<a:br/>";
|
|
26159
|
-
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${
|
|
26870
|
+
return `<a:r>${hasProperties ? runProperties("rPr", properties) : ""}<a:t>${escapeText2(text)}</a:t></a:r>`;
|
|
26160
26871
|
}
|
|
26161
26872
|
function paragraph(value) {
|
|
26162
26873
|
const align = value.align ? ` algn="${escapeAttribute(value.align)}"` : "";
|
|
@@ -26276,7 +26987,7 @@ function numberFormatXml(format) {
|
|
|
26276
26987
|
}
|
|
26277
26988
|
|
|
26278
26989
|
// chart/write-text.ts
|
|
26279
|
-
var textElement = (local, value) => `<c:${local}>${
|
|
26990
|
+
var textElement = (local, value) => `<c:${local}>${escapeText2(value)}</c:${local}>`;
|
|
26280
26991
|
function cachePoints(cache) {
|
|
26281
26992
|
return cache.points.map((point, position2) => {
|
|
26282
26993
|
const format = point.formatCode === void 0 ? "" : ` formatCode="${escapeAttribute(point.formatCode)}"`;
|
|
@@ -26406,7 +27117,7 @@ function trendlineLabelXml(context, label) {
|
|
|
26406
27117
|
function trendlineXml(context, trendline) {
|
|
26407
27118
|
return elementXml(
|
|
26408
27119
|
"trendline",
|
|
26409
|
-
(trendline.name === void 0 ? "" : `<c:name>${
|
|
27120
|
+
(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)
|
|
26410
27121
|
);
|
|
26411
27122
|
}
|
|
26412
27123
|
function errorBarsXml(context, bars) {
|
|
@@ -27151,7 +27862,7 @@ function attributes(entries) {
|
|
|
27151
27862
|
}).join("");
|
|
27152
27863
|
}
|
|
27153
27864
|
var cxElement = (local, content = "", attrs2 = "") => content ? `<cx:${local}${attrs2}>${content}</cx:${local}>` : `<cx:${local}${attrs2}/>`;
|
|
27154
|
-
var cxText = (local, text, attrs2 = "") => text === void 0 ? "" : `<cx:${local}${attrs2}>${
|
|
27865
|
+
var cxText = (local, text, attrs2 = "") => text === void 0 ? "" : `<cx:${local}${attrs2}>${escapeText2(text)}</cx:${local}>`;
|
|
27155
27866
|
var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
|
|
27156
27867
|
var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
|
|
27157
27868
|
var shapeXml = (context, shape) => shape ? cxElement("spPr", shapePropertiesInnerXml(context, shape)) : "";
|
|
@@ -28921,6 +29632,10 @@ var WRAPS = [
|
|
|
28921
29632
|
function parsePlacement(anchor) {
|
|
28922
29633
|
const wrap2 = WRAPS.find(([local]) => firstNS(anchor, WP_NS2, local))?.[1] ?? "none";
|
|
28923
29634
|
const placement = { wrap: wrap2 };
|
|
29635
|
+
const wrapElement2 = WRAPS.map(([local]) => firstNS(anchor, WP_NS2, local)).find(Boolean);
|
|
29636
|
+
const wrapText = wrapElement2?.getAttribute("wrapText");
|
|
29637
|
+
if (wrapText === "bothSides" || wrapText === "left" || wrapText === "right" || wrapText === "largest")
|
|
29638
|
+
placement.wrapText = wrapText;
|
|
28924
29639
|
if (anchor.getAttribute("behindDoc") === "1") placement.behindText = true;
|
|
28925
29640
|
const positionH = firstNS(anchor, WP_NS2, "positionH");
|
|
28926
29641
|
const relativeFrom = enumValue(
|
|
@@ -29352,6 +30067,34 @@ function chartRun(doc, node, image, base, oldDrawing, oldContainer, allocator) {
|
|
|
29352
30067
|
return void 0;
|
|
29353
30068
|
}
|
|
29354
30069
|
|
|
30070
|
+
// docx/write-fallback.ts
|
|
30071
|
+
var PT_PER_PX2 = 0.75;
|
|
30072
|
+
function setStyleSize(style, name, pt) {
|
|
30073
|
+
const value = `${Math.round(pt * 100) / 100}pt`;
|
|
30074
|
+
const pattern = new RegExp(`(^|;)\\s*${name}\\s*:\\s*[^;]*`, "i");
|
|
30075
|
+
return pattern.test(style) ? style.replace(pattern, (_all, lead) => `${lead}${name}:${value}`) : style;
|
|
30076
|
+
}
|
|
30077
|
+
function patchFallbackSize(content, image, base) {
|
|
30078
|
+
if (!base || image.widthPx === base.widthPx && image.heightPx === base.heightPx) return;
|
|
30079
|
+
const fallback = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Fallback");
|
|
30080
|
+
if (!fallback) return;
|
|
30081
|
+
const stack = [fallback];
|
|
30082
|
+
while (stack.length) {
|
|
30083
|
+
const node = stack.pop();
|
|
30084
|
+
const style = node.getAttribute("style");
|
|
30085
|
+
if (style && /(^|;)\s*width\s*:/i.test(style)) {
|
|
30086
|
+
let next = style;
|
|
30087
|
+
if (image.widthPx !== base.widthPx)
|
|
30088
|
+
next = setStyleSize(next, "width", image.widthPx * PT_PER_PX2);
|
|
30089
|
+
if (image.heightPx !== base.heightPx)
|
|
30090
|
+
next = setStyleSize(next, "height", image.heightPx * PT_PER_PX2);
|
|
30091
|
+
node.setAttribute("style", next);
|
|
30092
|
+
continue;
|
|
30093
|
+
}
|
|
30094
|
+
for (const child7 of Array.from(node.childNodes)) if (isElement(child7)) stack.push(child7);
|
|
30095
|
+
}
|
|
30096
|
+
}
|
|
30097
|
+
|
|
29355
30098
|
// docx/diagram-document.ts
|
|
29356
30099
|
function diagramsIn(blocks) {
|
|
29357
30100
|
const diagrams = [];
|
|
@@ -29975,6 +30718,13 @@ function createImageRun(doc, image, base, old, allocator) {
|
|
|
29975
30718
|
}
|
|
29976
30719
|
if (base && oldDrawing && image.shape?.editable && base.shape?.editable) {
|
|
29977
30720
|
const next = rebuildShapeDrawing(doc, image, oldDrawing);
|
|
30721
|
+
const choice = oldDrawing.parentNode;
|
|
30722
|
+
if (oldContainer?.localName === "AlternateContent" && choice) {
|
|
30723
|
+
choice.replaceChild(next, oldDrawing);
|
|
30724
|
+
patchFallbackSize(oldContainer, image, base);
|
|
30725
|
+
clearNonProperties(node, oldContainer);
|
|
30726
|
+
return node;
|
|
30727
|
+
}
|
|
29978
30728
|
clearNonProperties(node);
|
|
29979
30729
|
node.appendChild(next);
|
|
29980
30730
|
return node;
|
|
@@ -31047,15 +31797,15 @@ function runIsSafe(run2) {
|
|
|
31047
31797
|
const content = Array.from(run2.childNodes).filter(
|
|
31048
31798
|
(child7) => isElement(child7) && !named2(child7, "rPr") && !isCachedPageBreak(child7)
|
|
31049
31799
|
);
|
|
31050
|
-
const
|
|
31051
|
-
if (
|
|
31052
|
-
if (
|
|
31053
|
-
(name) => named2(
|
|
31800
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
31801
|
+
if (only2 && named2(only2, "br") && isModeledBreak(only2)) return true;
|
|
31802
|
+
if (only2 && ["footnoteReference", "endnoteReference", "footnoteRef", "endnoteRef"].some(
|
|
31803
|
+
(name) => named2(only2, name)
|
|
31054
31804
|
))
|
|
31055
31805
|
return true;
|
|
31056
|
-
if (
|
|
31057
|
-
const type = getW(
|
|
31058
|
-
const data = Array.from(
|
|
31806
|
+
if (only2 && named2(only2, "fldChar")) {
|
|
31807
|
+
const type = getW(only2, "fldCharType") ?? "";
|
|
31808
|
+
const data = Array.from(only2.childNodes).filter(
|
|
31059
31809
|
(node) => isElement(node) || Boolean(node.textContent?.trim())
|
|
31060
31810
|
);
|
|
31061
31811
|
if (!data.length) return ["begin", "separate", "end"].includes(type);
|
|
@@ -31187,6 +31937,10 @@ function parseDirectParagraphProperties(props) {
|
|
|
31187
31937
|
const line2 = signedTwipValue2(getW(spacing2, "line"));
|
|
31188
31938
|
if (before !== void 0) paragraph2.spacingBeforeTwips = before;
|
|
31189
31939
|
if (after !== void 0) paragraph2.spacingAfterTwips = after;
|
|
31940
|
+
const beforeAuto = parseOnOff(getW(spacing2, "beforeAutospacing"));
|
|
31941
|
+
const afterAuto = parseOnOff(getW(spacing2, "afterAutospacing"));
|
|
31942
|
+
if (beforeAuto !== void 0) paragraph2.spacingBeforeAuto = beforeAuto;
|
|
31943
|
+
if (afterAuto !== void 0) paragraph2.spacingAfterAuto = afterAuto;
|
|
31190
31944
|
if (line2 !== void 0) {
|
|
31191
31945
|
paragraph2.lineSpacingTwips = line2;
|
|
31192
31946
|
}
|
|
@@ -31218,8 +31972,8 @@ function parseDirectParagraphProperties(props) {
|
|
|
31218
31972
|
|
|
31219
31973
|
// docx/run-segmentation.ts
|
|
31220
31974
|
var basisOf = (run2) => run2.restoredRunPropertiesXml ?? run2.sourceRunPropertiesXml;
|
|
31221
|
-
function keepsUnmodeledProperties(before, after) {
|
|
31222
|
-
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () =>
|
|
31975
|
+
function keepsUnmodeledProperties(before, after, basis = basisOf) {
|
|
31976
|
+
const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () => basis(run2)));
|
|
31223
31977
|
const was = owners(before);
|
|
31224
31978
|
const now = owners(after);
|
|
31225
31979
|
const kept = (from, to, shift) => {
|
|
@@ -31253,13 +32007,22 @@ function runsToWriteAnew(paragraph2, base, slots) {
|
|
|
31253
32007
|
return !remaining.length || remaining.every((run2) => run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml);
|
|
31254
32008
|
}))
|
|
31255
32009
|
return none;
|
|
31256
|
-
if (paragraph2.runs.every(
|
|
31257
|
-
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
31258
|
-
))
|
|
31259
|
-
return none;
|
|
31260
32010
|
const sameText = paragraph2.runs.map((run2) => run2.text).join("") === base.runs.map((run2) => run2.text).join("");
|
|
31261
32011
|
const sameBoundaries = paragraph2.runs.length === base.runs.length && paragraph2.runs.every((run2, index) => run2.text === base.runs[index]?.text);
|
|
31262
32012
|
if (sameBoundaries || !sameText && paragraph2.runs.length === base.runs.length) return none;
|
|
32013
|
+
if (paragraph2.runs.every(
|
|
32014
|
+
(run2) => !run2.image && !run2.equation && (run2.restoredRunPropertiesXml || run2.sourceRunPropertiesXml)
|
|
32015
|
+
)) {
|
|
32016
|
+
if (keepsUnmodeledProperties(
|
|
32017
|
+
base.runs,
|
|
32018
|
+
paragraph2.runs,
|
|
32019
|
+
(run2) => run2.sourceRunPropertiesXml ?? run2.restoredRunPropertiesXml
|
|
32020
|
+
))
|
|
32021
|
+
return none;
|
|
32022
|
+
throw new Error(
|
|
32023
|
+
`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.`
|
|
32024
|
+
);
|
|
32025
|
+
}
|
|
31263
32026
|
const object = (run2) => Boolean(run2.image || run2.equation);
|
|
31264
32027
|
if (!paragraph2.runs.some(object) && !base.runs.some(object) && keepsUnmodeledProperties(base.runs, paragraph2.runs))
|
|
31265
32028
|
return new Set(
|
|
@@ -32396,14 +33159,14 @@ async function applyNumberingCatalog(zip, model, binding) {
|
|
|
32396
33159
|
}
|
|
32397
33160
|
|
|
32398
33161
|
// docx/style-numbering-package.ts
|
|
32399
|
-
var
|
|
32400
|
-
var
|
|
33162
|
+
var STYLES_PART2 = "word/styles.xml";
|
|
33163
|
+
var AFTER_PPR2 = ["rPr", "tblPr", "trPr", "tcPr", "tblStylePr"];
|
|
32401
33164
|
var withoutNumbering = (catalog) => catalog ? {
|
|
32402
33165
|
...catalog,
|
|
32403
33166
|
styles: Object.fromEntries(
|
|
32404
33167
|
Object.entries(catalog.styles).map(([id, style]) => {
|
|
32405
|
-
const { numbering: _numbering, ...rest } = style;
|
|
32406
|
-
return [id, rest];
|
|
33168
|
+
const { numbering: _numbering, formatting, ...rest } = style;
|
|
33169
|
+
return [id, { ...rest, formatting: unwritableFormatting(formatting) }];
|
|
32407
33170
|
})
|
|
32408
33171
|
)
|
|
32409
33172
|
} : void 0;
|
|
@@ -32416,7 +33179,7 @@ function setNumPr(style, numbering) {
|
|
|
32416
33179
|
if (!numbering && !pPr) return;
|
|
32417
33180
|
if (!pPr) {
|
|
32418
33181
|
pPr = makeW(doc, "pPr");
|
|
32419
|
-
const anchor = elementsOf2(style).find((child7) =>
|
|
33182
|
+
const anchor = elementsOf2(style).find((child7) => AFTER_PPR2.includes(child7.localName)) ?? null;
|
|
32420
33183
|
style.insertBefore(pPr, anchor);
|
|
32421
33184
|
}
|
|
32422
33185
|
for (const existing of children2(pPr, "numPr")) pPr.removeChild(existing);
|
|
@@ -32440,7 +33203,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
32440
33203
|
(id) => JSON.stringify(next[id]?.numbering) !== JSON.stringify(prior[id]?.numbering)
|
|
32441
33204
|
);
|
|
32442
33205
|
if (!changed.length) return;
|
|
32443
|
-
const file = zip.file(
|
|
33206
|
+
const file = zip.file(STYLES_PART2);
|
|
32444
33207
|
if (!file) throw new Error("Cannot link styles to a list: the package has no styles.xml.");
|
|
32445
33208
|
const doc = parseXml2(await file.async("string"));
|
|
32446
33209
|
const styles = children2(doc.documentElement, "style");
|
|
@@ -32451,7 +33214,7 @@ async function applyStyleNumbering(zip, model, base) {
|
|
|
32451
33214
|
if (!style) throw new Error(`Cannot link style "${id}" to a list: it is not in styles.xml.`);
|
|
32452
33215
|
setNumPr(style, next[id]?.numbering);
|
|
32453
33216
|
}
|
|
32454
|
-
zip.file(
|
|
33217
|
+
zip.file(STYLES_PART2, buildXml(doc));
|
|
32455
33218
|
}
|
|
32456
33219
|
|
|
32457
33220
|
// docx/write-header-footer.ts
|
|
@@ -33844,7 +34607,7 @@ function headerFooterResults(model) {
|
|
|
33844
34607
|
return void 0;
|
|
33845
34608
|
}
|
|
33846
34609
|
}
|
|
33847
|
-
async function saveDocx(model, pendingMedia) {
|
|
34610
|
+
async function saveDocx(model, pendingMedia, options) {
|
|
33848
34611
|
const ids = /* @__PURE__ */ new Set();
|
|
33849
34612
|
for (const block of model.blocks) {
|
|
33850
34613
|
if (ids.has(block.id)) throw new Error(`Duplicate document block id: ${block.id}`);
|
|
@@ -33935,6 +34698,7 @@ async function saveDocx(model, pendingMedia) {
|
|
|
33935
34698
|
await applyNumberingCatalog(zip, model, binding);
|
|
33936
34699
|
await applyCoreProperties(zip, model.properties, binding?.base.properties);
|
|
33937
34700
|
if (binding) await applyStyleNumbering(zip, model, binding.base);
|
|
34701
|
+
if (binding) await applyStyleFormatting(zip, model, binding.base);
|
|
33938
34702
|
if (model.compatibilityMode !== binding?.base.compatibilityMode)
|
|
33939
34703
|
await applyCompatibilityMode(zip, model.compatibilityMode);
|
|
33940
34704
|
if (Boolean(model.evenAndOddHeaders) !== Boolean(binding?.base.evenAndOddHeaders))
|
|
@@ -33966,6 +34730,8 @@ async function saveDocx(model, pendingMedia) {
|
|
|
33966
34730
|
}
|
|
33967
34731
|
if (JSON.stringify(model.comments ?? []) !== JSON.stringify(binding?.base.comments ?? []))
|
|
33968
34732
|
await applyComments(zip, model.comments ?? []);
|
|
34733
|
+
if (binding) await applyDataBindings(zip, model, binding.base, binding.context.sourceXml);
|
|
34734
|
+
if (binding) await stampModified(zip, options?.modified);
|
|
33969
34735
|
dropAddedFolders(zip, sourceEntries);
|
|
33970
34736
|
return zip.generateAsync({ type: "uint8array", compression: "DEFLATE" });
|
|
33971
34737
|
}
|
|
@@ -34021,8 +34787,11 @@ function parseCell(cell2, parseParagraph3, id, control) {
|
|
|
34021
34787
|
const element4 = child7;
|
|
34022
34788
|
if (element4.namespaceURI !== WORD_NS) return [];
|
|
34023
34789
|
if (element4.localName === "p") return [result.paragraphs[paragraphIndex++]];
|
|
34024
|
-
if (element4.localName === "tbl")
|
|
34025
|
-
|
|
34790
|
+
if (element4.localName === "tbl") {
|
|
34791
|
+
const inner = parseTable(element4, `${id}-nested${tableIndex++}`, parseParagraph3);
|
|
34792
|
+
markRestructurable(inner, element4);
|
|
34793
|
+
return [inner];
|
|
34794
|
+
}
|
|
34026
34795
|
return [];
|
|
34027
34796
|
}
|
|
34028
34797
|
);
|
|
@@ -34078,6 +34847,9 @@ function parseRowProperties(row) {
|
|
|
34078
34847
|
if (onOffElement(first2(trPr, "tblHeader"))) result.header = true;
|
|
34079
34848
|
return result;
|
|
34080
34849
|
}
|
|
34850
|
+
function markRestructurable(table, node) {
|
|
34851
|
+
if (canRestructureTable(node) && tableGrid(table)) table.restructurable = true;
|
|
34852
|
+
}
|
|
34081
34853
|
function parseTable(node, id, parseParagraph3) {
|
|
34082
34854
|
const rowEntries = flatRows(node);
|
|
34083
34855
|
const rows = rowEntries.map(
|
|
@@ -34118,6 +34890,7 @@ function parseTable(node, id, parseParagraph3) {
|
|
|
34118
34890
|
return properties;
|
|
34119
34891
|
});
|
|
34120
34892
|
if (rowProperties.some((row) => Object.keys(row).length)) table.rowProperties = rowProperties;
|
|
34893
|
+
if (!table.structureEditable) markRestructurable(table, node);
|
|
34121
34894
|
return table;
|
|
34122
34895
|
}
|
|
34123
34896
|
|
|
@@ -34251,23 +35024,23 @@ function parseRun2(node, revision) {
|
|
|
34251
35024
|
let noteSeparator;
|
|
34252
35025
|
let fieldChar;
|
|
34253
35026
|
const fieldCode = content.length > 0 && content.every((child7) => named2(child7, "instrText")) ? content.map((child7) => textContent(child7)).join("") : void 0;
|
|
34254
|
-
const
|
|
34255
|
-
if (
|
|
34256
|
-
if (named2(
|
|
34257
|
-
const kind = classifyBreak(
|
|
35027
|
+
const only2 = content.length === 1 ? content[0] : void 0;
|
|
35028
|
+
if (only2) {
|
|
35029
|
+
if (named2(only2, "br")) {
|
|
35030
|
+
const kind = classifyBreak(only2);
|
|
34258
35031
|
if (kind === "page" || kind === "column") breakKind = kind;
|
|
34259
|
-
} else if (named2(
|
|
34260
|
-
const id = getW(
|
|
35032
|
+
} else if (named2(only2, "footnoteReference")) {
|
|
35033
|
+
const id = getW(only2, "id");
|
|
34261
35034
|
if (id) noteReference = { kind: "footnote", id };
|
|
34262
|
-
} else if (named2(
|
|
34263
|
-
const id = getW(
|
|
35035
|
+
} else if (named2(only2, "endnoteReference")) {
|
|
35036
|
+
const id = getW(only2, "id");
|
|
34264
35037
|
if (id) noteReference = { kind: "endnote", id };
|
|
34265
|
-
} else if (named2(
|
|
34266
|
-
else if (named2(
|
|
34267
|
-
else if (named2(
|
|
34268
|
-
else if (named2(
|
|
34269
|
-
else if (named2(
|
|
34270
|
-
const type = getW(
|
|
35038
|
+
} else if (named2(only2, "footnoteRef")) noteMark = "footnote";
|
|
35039
|
+
else if (named2(only2, "endnoteRef")) noteMark = "endnote";
|
|
35040
|
+
else if (named2(only2, "separator")) noteSeparator = "separator";
|
|
35041
|
+
else if (named2(only2, "continuationSeparator")) noteSeparator = "continuationSeparator";
|
|
35042
|
+
else if (named2(only2, "fldChar")) {
|
|
35043
|
+
const type = getW(only2, "fldCharType");
|
|
34271
35044
|
if (type === "begin" || type === "separate" || type === "end") fieldChar = type;
|
|
34272
35045
|
}
|
|
34273
35046
|
}
|
|
@@ -34289,9 +35062,9 @@ function parseRun2(node, revision) {
|
|
|
34289
35062
|
if (noteSeparator) run2.noteSeparator = noteSeparator;
|
|
34290
35063
|
if (fieldChar) {
|
|
34291
35064
|
run2.fieldChar = fieldChar;
|
|
34292
|
-
const flags = parseFieldFlags(
|
|
35065
|
+
const flags = parseFieldFlags(only2);
|
|
34293
35066
|
if (flags) run2.fieldFlags = flags;
|
|
34294
|
-
const data = fieldChar === "begin" ? first2(
|
|
35067
|
+
const data = fieldChar === "begin" ? first2(only2, "ffData") : void 0;
|
|
34295
35068
|
const formField = data && parseFormField(data);
|
|
34296
35069
|
if (formField) run2.formField = formField;
|
|
34297
35070
|
}
|
|
@@ -34631,6 +35404,7 @@ function parseSettings(xml) {
|
|
|
34631
35404
|
);
|
|
34632
35405
|
return {
|
|
34633
35406
|
...compatibilityMode !== void 0 && Number.isInteger(compatibilityMode) && compatibilityMode > 0 ? { compatibilityMode } : {},
|
|
35407
|
+
...onOffElement(first2(first2(root, "compat"), "doNotUseHTMLParagraphAutoSpacing")) === true ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
34634
35408
|
evenAndOddHeaders: onOffElement(first2(root, "evenAndOddHeaders")) === true,
|
|
34635
35409
|
autoHyphenation: onOffElement(first2(root, "autoHyphenation")) === true,
|
|
34636
35410
|
...footnoteNumFmt ? { footnoteNumFmt } : {},
|
|
@@ -34711,6 +35485,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
|
|
|
34711
35485
|
return {
|
|
34712
35486
|
sections,
|
|
34713
35487
|
...settings.compatibilityMode !== void 0 ? { compatibilityMode: settings.compatibilityMode } : {},
|
|
35488
|
+
...settings.doNotUseHtmlParagraphAutoSpacing ? { doNotUseHtmlParagraphAutoSpacing: true } : {},
|
|
34714
35489
|
...footnotes ? { footnotes } : {},
|
|
34715
35490
|
...footnoteSeparators ? { footnoteSeparators } : {},
|
|
34716
35491
|
...endnotes ? { endnotes } : {},
|
|
@@ -34953,6 +35728,7 @@ async function readPackage(input) {
|
|
|
34953
35728
|
const parts = await parseDocumentParts(zip, body, blocks, drawings);
|
|
34954
35729
|
model.sections = parts.sections;
|
|
34955
35730
|
if (parts.compatibilityMode !== void 0) model.compatibilityMode = parts.compatibilityMode;
|
|
35731
|
+
if (parts.doNotUseHtmlParagraphAutoSpacing) model.doNotUseHtmlParagraphAutoSpacing = true;
|
|
34956
35732
|
if (parts.footnotes) model.footnotes = parts.footnotes;
|
|
34957
35733
|
if (parts.footnoteSeparators) model.footnoteSeparators = parts.footnoteSeparators;
|
|
34958
35734
|
if (parts.endnotes) model.endnotes = parts.endnotes;
|
|
@@ -34962,14 +35738,16 @@ async function readPackage(input) {
|
|
|
34962
35738
|
if (parts.autoHyphenation) model.autoHyphenation = true;
|
|
34963
35739
|
const coreFile = zip.file("docProps/core.xml");
|
|
34964
35740
|
if (coreFile) {
|
|
34965
|
-
const properties =
|
|
35741
|
+
const properties = parseCoreProperties2(await coreFile.async("string"));
|
|
34966
35742
|
if (properties) model.properties = properties;
|
|
34967
35743
|
}
|
|
34968
35744
|
await readPlaceholderTexts(zip, drawings.rels, model);
|
|
34969
35745
|
const pageColor = parsePageBackground(document.documentElement);
|
|
34970
35746
|
if (pageColor) model.pageColor = pageColor;
|
|
34971
35747
|
model.warnings.push(...parts.warnings);
|
|
34972
|
-
if (blocks.some(
|
|
35748
|
+
if (blocks.some(
|
|
35749
|
+
(block) => block.type === "table" && !block.structureEditable && !block.restructurable
|
|
35750
|
+
))
|
|
34973
35751
|
model.warnings.push(
|
|
34974
35752
|
"Merged, nested, or complex tables can be read, but their row and column structure cannot be edited safely."
|
|
34975
35753
|
);
|
|
@@ -34995,7 +35773,7 @@ async function readPackage(input) {
|
|
|
34995
35773
|
(block) => block.type === "table" && block.rows.some((row) => row.some((cell2) => cell2.nestedTables?.length))
|
|
34996
35774
|
))
|
|
34997
35775
|
model.warnings.push(
|
|
34998
|
-
"Text
|
|
35776
|
+
"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."
|
|
34999
35777
|
);
|
|
35000
35778
|
const pictureBlocks = documentDrawingBlocks({ ...model, blocks });
|
|
35001
35779
|
await resolveDocumentDiagrams(
|
|
@@ -35033,9 +35811,9 @@ async function loadDocx(input) {
|
|
|
35033
35811
|
return {
|
|
35034
35812
|
model,
|
|
35035
35813
|
media,
|
|
35036
|
-
save: (next = model, pendingMedia) => {
|
|
35814
|
+
save: (next = model, pendingMedia, options) => {
|
|
35037
35815
|
if (next !== model) remember(next, context);
|
|
35038
|
-
return saveDocx(next, pendingMedia);
|
|
35816
|
+
return saveDocx(next, pendingMedia, options);
|
|
35039
35817
|
}
|
|
35040
35818
|
};
|
|
35041
35819
|
}
|