@syncfusion/ej2-docx 0.0.0-stage → 35.1.40
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/.gitleaksignore +35 -0
- package/README.md +68 -2
- package/core.js +4 -0
- package/dist/ej2-docx.umd.min.js +11 -0
- package/dist/ej2-docx.umd.min.js.map +1 -0
- package/dist/es6/ej2-docx.es2015.js +66697 -0
- package/dist/es6/ej2-docx.es2015.js.map +1 -0
- package/dist/es6/ej2-docx.es5.js +77568 -0
- package/dist/es6/ej2-docx.es5.js.map +1 -0
- package/dist/global/ej2-docx.min.js +11 -0
- package/dist/global/ej2-docx.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/features.js +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +30 -3
- package/src/all.d.ts +50 -0
- package/src/all.js +147 -0
- package/src/core/compat/base64.d.ts +13 -0
- package/src/core/compat/base64.js +90 -0
- package/src/core/compat/object-compat.d.ts +30 -0
- package/src/core/compat/object-compat.js +40 -0
- package/src/core/compat/sha256.d.ts +9 -0
- package/src/core/compat/sha256.js +98 -0
- package/src/core/errors/docx-error.d.ts +89 -0
- package/src/core/errors/docx-error.js +138 -0
- package/src/core/errors/error-codes.d.ts +8 -0
- package/src/core/errors/error-codes.js +0 -0
- package/src/core/errors/index.d.ts +10 -0
- package/src/core/errors/index.js +9 -0
- package/src/core/index.d.ts +12 -0
- package/src/core/index.js +12 -0
- package/src/core/mc/alternate-content.d.ts +7 -0
- package/src/core/mc/alternate-content.js +67 -0
- package/src/core/mc/attributes.d.ts +24 -0
- package/src/core/mc/attributes.js +82 -0
- package/src/core/mc/index.d.ts +7 -0
- package/src/core/mc/index.js +5 -0
- package/src/core/mc/inspect.d.ts +16 -0
- package/src/core/mc/inspect.js +148 -0
- package/src/core/mc/namespaces.d.ts +4 -0
- package/src/core/mc/namespaces.js +4 -0
- package/src/core/mc/scope.d.ts +6 -0
- package/src/core/mc/scope.js +47 -0
- package/src/core/opc/content-types.d.ts +34 -0
- package/src/core/opc/content-types.js +162 -0
- package/src/core/opc/index.d.ts +8 -0
- package/src/core/opc/index.js +4 -0
- package/src/core/opc/package.d.ts +49 -0
- package/src/core/opc/package.js +324 -0
- package/src/core/opc/part-name.d.ts +47 -0
- package/src/core/opc/part-name.js +205 -0
- package/src/core/opc/relationships.d.ts +46 -0
- package/src/core/opc/relationships.js +212 -0
- package/src/core/preservation/index.d.ts +2 -0
- package/src/core/preservation/index.js +1 -0
- package/src/core/preservation/opaque-body.d.ts +16 -0
- package/src/core/preservation/opaque-body.js +69 -0
- package/src/core/registry/block-handlers.d.ts +30 -0
- package/src/core/registry/block-handlers.js +36 -0
- package/src/core/registry/create-defaults.d.ts +39 -0
- package/src/core/registry/create-defaults.js +42 -0
- package/src/core/registry/feature-registry.d.ts +20 -0
- package/src/core/registry/feature-registry.js +29 -0
- package/src/core/registry/index.d.ts +9 -0
- package/src/core/registry/index.js +8 -0
- package/src/core/registry/inline-handlers.d.ts +20 -0
- package/src/core/registry/inline-handlers.js +30 -0
- package/src/core/registry/materialize-handlers.d.ts +35 -0
- package/src/core/registry/materialize-handlers.js +75 -0
- package/src/core/registry/multi-part-handlers.d.ts +37 -0
- package/src/core/registry/multi-part-handlers.js +206 -0
- package/src/core/registry/package-part-handlers.d.ts +28 -0
- package/src/core/registry/package-part-handlers.js +190 -0
- package/src/core/registry/part-handlers.d.ts +24 -0
- package/src/core/registry/part-handlers.js +172 -0
- package/src/core/registry/run-leaf-handlers.d.ts +26 -0
- package/src/core/registry/run-leaf-handlers.js +72 -0
- package/src/core/security/limits.d.ts +40 -0
- package/src/core/security/limits.js +26 -0
- package/src/core/xml/index.d.ts +7 -0
- package/src/core/xml/index.js +3 -0
- package/src/core/xml/model.d.ts +66 -0
- package/src/core/xml/model.js +17 -0
- package/src/core/xml/parse.d.ts +12 -0
- package/src/core/xml/parse.js +382 -0
- package/src/core/xml/serialize.d.ts +6 -0
- package/src/core/xml/serialize.js +93 -0
- package/src/core/zip/crc32.d.ts +2 -0
- package/src/core/zip/crc32.js +25 -0
- package/src/core/zip/deflate.d.ts +6 -0
- package/src/core/zip/deflate.js +6 -0
- package/src/core/zip/index.d.ts +10 -0
- package/src/core/zip/index.js +4 -0
- package/src/core/zip/inflate-raw.d.ts +17 -0
- package/src/core/zip/inflate-raw.js +450 -0
- package/src/core/zip/names.d.ts +6 -0
- package/src/core/zip/names.js +52 -0
- package/src/core/zip/read.d.ts +8 -0
- package/src/core/zip/read.js +262 -0
- package/src/core/zip/write.d.ts +7 -0
- package/src/core/zip/write.js +189 -0
- package/src/core/zip/zip-entry.d.ts +4 -0
- package/src/core/zip/zip-entry.js +0 -0
- package/src/features/bibliography/index.d.ts +100 -0
- package/src/features/bibliography/index.js +290 -0
- package/src/features/bookmarks/index.d.ts +331 -0
- package/src/features/bookmarks/index.js +1009 -0
- package/src/features/comments/comment-extensions.d.ts +157 -0
- package/src/features/comments/comment-extensions.js +356 -0
- package/src/features/comments/index.d.ts +579 -0
- package/src/features/comments/index.js +1727 -0
- package/src/features/content-controls/index.d.ts +821 -0
- package/src/features/content-controls/index.js +2857 -0
- package/src/features/custom-xml/index.d.ts +236 -0
- package/src/features/custom-xml/index.js +661 -0
- package/src/features/document/alignment.d.ts +23 -0
- package/src/features/document/alignment.js +36 -0
- package/src/features/document/alt-chunk.d.ts +103 -0
- package/src/features/document/alt-chunk.js +221 -0
- package/src/features/document/assert-never.d.ts +1 -0
- package/src/features/document/assert-never.js +4 -0
- package/src/features/document/augmentations.d.ts +578 -0
- package/src/features/document/augmentations.js +0 -0
- package/src/features/document/body-always-on.d.ts +36 -0
- package/src/features/document/body-always-on.js +66 -0
- package/src/features/document/body-blocks.d.ts +7 -0
- package/src/features/document/body-blocks.js +78 -0
- package/src/features/document/body-item-adapters.d.ts +62 -0
- package/src/features/document/body-item-adapters.js +97 -0
- package/src/features/document/body-item-collection.d.ts +151 -0
- package/src/features/document/body-item-collection.js +440 -0
- package/src/features/document/body-item.d.ts +35 -0
- package/src/features/document/body-item.js +8 -0
- package/src/features/document/body.d.ts +150 -0
- package/src/features/document/body.js +263 -0
- package/src/features/document/character-format.d.ts +413 -0
- package/src/features/document/character-format.js +2054 -0
- package/src/features/document/color.d.ts +178 -0
- package/src/features/document/color.js +495 -0
- package/src/features/document/document.d.ts +410 -0
- package/src/features/document/document.js +1049 -0
- package/src/features/document/element-type.d.ts +68 -0
- package/src/features/document/element-type.js +133 -0
- package/src/features/document/entity-type.d.ts +92 -0
- package/src/features/document/entity-type.js +93 -0
- package/src/features/document/feature-block.d.ts +16 -0
- package/src/features/document/feature-block.js +0 -0
- package/src/features/document/feature-inline.d.ts +13 -0
- package/src/features/document/feature-inline.js +0 -0
- package/src/features/document/feature-multi-package-part.d.ts +19 -0
- package/src/features/document/feature-multi-package-part.js +8 -0
- package/src/features/document/feature-package-level-part.d.ts +18 -0
- package/src/features/document/feature-package-level-part.js +8 -0
- package/src/features/document/feature-package-part.d.ts +14 -0
- package/src/features/document/feature-package-part.js +0 -0
- package/src/features/document/feature-run-leaf.d.ts +9 -0
- package/src/features/document/feature-run-leaf.js +0 -0
- package/src/features/document/headers-footers.d.ts +206 -0
- package/src/features/document/headers-footers.js +384 -0
- package/src/features/document/index.d.ts +41 -0
- package/src/features/document/index.js +34 -0
- package/src/features/document/length.d.ts +152 -0
- package/src/features/document/length.js +245 -0
- package/src/features/document/load-options.d.ts +14 -0
- package/src/features/document/load-options.js +0 -0
- package/src/features/document/locale-ids.d.ts +227 -0
- package/src/features/document/locale-ids.js +485 -0
- package/src/features/document/on-off.d.ts +9 -0
- package/src/features/document/on-off.js +27 -0
- package/src/features/document/page-setup.d.ts +339 -0
- package/src/features/document/page-setup.js +244 -0
- package/src/features/document/paragraph-format.d.ts +880 -0
- package/src/features/document/paragraph-format.js +2807 -0
- package/src/features/document/paragraph-item-collection.d.ts +162 -0
- package/src/features/document/paragraph-item-collection.js +363 -0
- package/src/features/document/paragraph-item.d.ts +83 -0
- package/src/features/document/paragraph-item.js +103 -0
- package/src/features/document/paragraph.d.ts +435 -0
- package/src/features/document/paragraph.js +888 -0
- package/src/features/document/run.d.ts +1 -0
- package/src/features/document/run.js +768 -0
- package/src/features/document/section-partition-flatten.d.ts +124 -0
- package/src/features/document/section-partition-flatten.js +217 -0
- package/src/features/document/section-properties-model.d.ts +13 -0
- package/src/features/document/section-properties-model.js +0 -0
- package/src/features/document/section.d.ts +93 -0
- package/src/features/document/section.js +178 -0
- package/src/features/document/sections.d.ts +103 -0
- package/src/features/document/sections.js +217 -0
- package/src/features/document/sub-super-script.d.ts +23 -0
- package/src/features/document/sub-super-script.js +43 -0
- package/src/features/document/text-range.d.ts +445 -0
- package/src/features/document/text-range.js +1156 -0
- package/src/features/document/typed-body-collections.d.ts +162 -0
- package/src/features/document/typed-body-collections.js +371 -0
- package/src/features/document/underline-style.d.ts +38 -0
- package/src/features/document/underline-style.js +126 -0
- package/src/features/document/units.d.ts +8 -0
- package/src/features/document/units.js +7 -0
- package/src/features/document/wml.d.ts +16 -0
- package/src/features/document/wml.js +67 -0
- package/src/features/drawing/authoring.d.ts +27 -0
- package/src/features/drawing/authoring.js +271 -0
- package/src/features/drawing/body-pr.d.ts +271 -0
- package/src/features/drawing/body-pr.js +663 -0
- package/src/features/drawing/drawing-shape.d.ts +1192 -0
- package/src/features/drawing/drawing-shape.js +3239 -0
- package/src/features/drawing/encode-builders.d.ts +176 -0
- package/src/features/drawing/encode-builders.js +390 -0
- package/src/features/drawing/fill-format.d.ts +52 -0
- package/src/features/drawing/fill-format.js +124 -0
- package/src/features/drawing/host-codec.d.ts +632 -0
- package/src/features/drawing/host-codec.js +2595 -0
- package/src/features/drawing/index.d.ts +13 -0
- package/src/features/drawing/index.js +33 -0
- package/src/features/drawing/line-format.d.ts +76 -0
- package/src/features/drawing/line-format.js +343 -0
- package/src/features/drawing/parse-register.d.ts +50 -0
- package/src/features/drawing/parse-register.js +257 -0
- package/src/features/drawing/residual-utils.d.ts +47 -0
- package/src/features/drawing/residual-utils.js +290 -0
- package/src/features/drawing/shape-types.d.ts +433 -0
- package/src/features/drawing/shape-types.js +437 -0
- package/src/features/drawing/sp-pr.d.ts +396 -0
- package/src/features/drawing/sp-pr.js +610 -0
- package/src/features/drawing/text-frame.d.ts +90 -0
- package/src/features/drawing/text-frame.js +152 -0
- package/src/features/drawing/types.d.ts +352 -0
- package/src/features/drawing/types.js +60 -0
- package/src/features/drawing/wrap-format.d.ts +62 -0
- package/src/features/drawing/wrap-format.js +114 -0
- package/src/features/editable-ranges/index.d.ts +494 -0
- package/src/features/editable-ranges/index.js +1348 -0
- package/src/features/fields/index.d.ts +428 -0
- package/src/features/fields/index.js +2148 -0
- package/src/features/fields/paragraph-field.d.ts +187 -0
- package/src/features/fields/paragraph-field.js +692 -0
- package/src/features/font-table/font-substitution-table.d.ts +75 -0
- package/src/features/font-table/font-substitution-table.js +257 -0
- package/src/features/font-table/font-table-entry.d.ts +255 -0
- package/src/features/font-table/font-table-entry.js +823 -0
- package/src/features/font-table/font-table.d.ts +128 -0
- package/src/features/font-table/font-table.js +313 -0
- package/src/features/font-table/index.d.ts +27 -0
- package/src/features/font-table/index.js +48 -0
- package/src/features/glossary/index.d.ts +97 -0
- package/src/features/glossary/index.js +286 -0
- package/src/features/headers-footers/index.d.ts +506 -0
- package/src/features/headers-footers/index.js +1666 -0
- package/src/features/hyperlinks/index.d.ts +230 -0
- package/src/features/hyperlinks/index.js +685 -0
- package/src/features/images/caption-authoring-api.d.ts +33 -0
- package/src/features/images/caption-authoring-api.js +33 -0
- package/src/features/images/caption-enums.d.ts +52 -0
- package/src/features/images/caption-enums.js +141 -0
- package/src/features/images/caption-host.d.ts +10 -0
- package/src/features/images/caption-host.js +21 -0
- package/src/features/images/captions.d.ts +13 -0
- package/src/features/images/captions.js +142 -0
- package/src/features/images/host-codec.d.ts +103 -0
- package/src/features/images/host-codec.js +720 -0
- package/src/features/images/image-sniff.d.ts +21 -0
- package/src/features/images/image-sniff.js +71 -0
- package/src/features/images/index.d.ts +506 -0
- package/src/features/images/index.js +1429 -0
- package/src/features/images/layout-types.d.ts +232 -0
- package/src/features/images/layout-types.js +294 -0
- package/src/features/images/public-entry.d.ts +9 -0
- package/src/features/images/public-entry.js +9 -0
- package/src/features/index.d.ts +35 -0
- package/src/features/index.js +36 -0
- package/src/features/mail-merge/index.d.ts +113 -0
- package/src/features/mail-merge/index.js +315 -0
- package/src/features/notes/index.d.ts +573 -0
- package/src/features/notes/index.js +1725 -0
- package/src/features/numbering/abstract-numbering.d.ts +90 -0
- package/src/features/numbering/abstract-numbering.js +292 -0
- package/src/features/numbering/index.d.ts +182 -0
- package/src/features/numbering/index.js +668 -0
- package/src/features/numbering/list-format.d.ts +158 -0
- package/src/features/numbering/list-format.js +590 -0
- package/src/features/numbering/list-string.d.ts +7 -0
- package/src/features/numbering/list-string.js +423 -0
- package/src/features/numbering/list-style.d.ts +204 -0
- package/src/features/numbering/list-style.js +1084 -0
- package/src/features/numbering/numbering-instance.d.ts +101 -0
- package/src/features/numbering/numbering-instance.js +329 -0
- package/src/features/numbering/numbering-level.d.ts +118 -0
- package/src/features/numbering/numbering-level.js +501 -0
- package/src/features/numbering/picture-bullet.d.ts +34 -0
- package/src/features/numbering/picture-bullet.js +88 -0
- package/src/features/ole-object/catalog.d.ts +300 -0
- package/src/features/ole-object/catalog.js +908 -0
- package/src/features/ole-object/index.d.ts +526 -0
- package/src/features/ole-object/index.js +1421 -0
- package/src/features/ole-object/relationship.d.ts +27 -0
- package/src/features/ole-object/relationship.js +27 -0
- package/src/features/ole-object/typed-dom.d.ts +186 -0
- package/src/features/ole-object/typed-dom.js +595 -0
- package/src/features/properties/index.d.ts +205 -0
- package/src/features/properties/index.js +549 -0
- package/src/features/revisions/index.d.ts +204 -0
- package/src/features/revisions/index.js +695 -0
- package/src/features/sections/column-collection.d.ts +119 -0
- package/src/features/sections/column-collection.js +478 -0
- package/src/features/sections/column.d.ts +15 -0
- package/src/features/sections/column.js +37 -0
- package/src/features/sections/index.d.ts +91 -0
- package/src/features/sections/index.js +1096 -0
- package/src/features/sections/margins.d.ts +40 -0
- package/src/features/sections/margins.js +105 -0
- package/src/features/sections/page-number-style.d.ts +21 -0
- package/src/features/sections/page-number-style.js +62 -0
- package/src/features/sections/page-orientation.d.ts +10 -0
- package/src/features/sections/page-orientation.js +10 -0
- package/src/features/sections/page-setup.d.ts +435 -0
- package/src/features/sections/page-setup.js +1479 -0
- package/src/features/sections/page-size.d.ts +59 -0
- package/src/features/sections/page-size.js +68 -0
- package/src/features/sections/section-break-code.d.ts +27 -0
- package/src/features/sections/section-break-code.js +60 -0
- package/src/features/sections/section-document-association.d.ts +18 -0
- package/src/features/sections/section-document-association.js +31 -0
- package/src/features/sections/section-validation.d.ts +43 -0
- package/src/features/sections/section-validation.js +97 -0
- package/src/features/settings/attached-template.d.ts +35 -0
- package/src/features/settings/attached-template.js +98 -0
- package/src/features/settings/compat-settings.d.ts +216 -0
- package/src/features/settings/compat-settings.js +508 -0
- package/src/features/settings/document-background.d.ts +59 -0
- package/src/features/settings/document-background.js +131 -0
- package/src/features/settings/document-protection.d.ts +65 -0
- package/src/features/settings/document-protection.js +157 -0
- package/src/features/settings/document-settings-facades.d.ts +108 -0
- package/src/features/settings/document-settings-facades.js +312 -0
- package/src/features/settings/document-settings-values.d.ts +43 -0
- package/src/features/settings/document-settings-values.js +60 -0
- package/src/features/settings/footnote-properties.d.ts +211 -0
- package/src/features/settings/footnote-properties.js +591 -0
- package/src/features/settings/index.d.ts +356 -0
- package/src/features/settings/index.js +829 -0
- package/src/features/settings/settings-children.d.ts +151 -0
- package/src/features/settings/settings-children.js +505 -0
- package/src/features/settings/web-settings.d.ts +88 -0
- package/src/features/settings/web-settings.js +227 -0
- package/src/features/settings/zoom.d.ts +79 -0
- package/src/features/settings/zoom.js +147 -0
- package/src/features/styles/builtin-catalog.d.ts +159 -0
- package/src/features/styles/builtin-catalog.js +963 -0
- package/src/features/styles/builtin-resolver.d.ts +49 -0
- package/src/features/styles/builtin-resolver.js +165 -0
- package/src/features/styles/default-styles.d.ts +37 -0
- package/src/features/styles/default-styles.js +186 -0
- package/src/features/styles/default-theme.d.ts +13 -0
- package/src/features/styles/default-theme.js +13 -0
- package/src/features/styles/doc-defaults.d.ts +58 -0
- package/src/features/styles/doc-defaults.js +178 -0
- package/src/features/styles/formatting-resolver.d.ts +27 -0
- package/src/features/styles/formatting-resolver.js +72 -0
- package/src/features/styles/index.d.ts +256 -0
- package/src/features/styles/index.js +1325 -0
- package/src/features/styles/latent-styles.d.ts +68 -0
- package/src/features/styles/latent-styles.js +305 -0
- package/src/features/styles/paragraph-properties.d.ts +71 -0
- package/src/features/styles/paragraph-properties.js +237 -0
- package/src/features/styles/run-properties.d.ts +93 -0
- package/src/features/styles/run-properties.js +516 -0
- package/src/features/styles/style-base.d.ts +402 -0
- package/src/features/styles/style-base.js +1026 -0
- package/src/features/styles/style-collection.d.ts +264 -0
- package/src/features/styles/style-collection.js +714 -0
- package/src/features/styles/style-format-bridge.d.ts +64 -0
- package/src/features/styles/style-format-bridge.js +100 -0
- package/src/features/styles/style.d.ts +84 -0
- package/src/features/styles/style.js +375 -0
- package/src/features/styles/styles-with-effects.d.ts +71 -0
- package/src/features/styles/styles-with-effects.js +180 -0
- package/src/features/styles/table-style.d.ts +272 -0
- package/src/features/styles/table-style.js +1226 -0
- package/src/features/styles/theme.d.ts +126 -0
- package/src/features/styles/theme.js +377 -0
- package/src/features/tables/border-style-map.d.ts +24 -0
- package/src/features/tables/border-style-map.js +81 -0
- package/src/features/tables/borders.d.ts +126 -0
- package/src/features/tables/borders.js +527 -0
- package/src/features/tables/collections.d.ts +113 -0
- package/src/features/tables/collections.js +261 -0
- package/src/features/tables/format.d.ts +208 -0
- package/src/features/tables/format.js +716 -0
- package/src/features/tables/index.d.ts +597 -0
- package/src/features/tables/index.js +2386 -0
- package/src/features/tables/paddings.d.ts +41 -0
- package/src/features/tables/paddings.js +97 -0
- package/src/features/tables/tbl-pr-positioning.d.ts +27 -0
- package/src/features/tables/tbl-pr-positioning.js +178 -0
- package/src/features/tables/tbl-pr.d.ts +528 -0
- package/src/features/tables/tbl-pr.js +1208 -0
- package/src/features/tables/tc-pr.d.ts +168 -0
- package/src/features/tables/tc-pr.js +553 -0
- package/src/features/tables/tr-pr.d.ts +60 -0
- package/src/features/tables/tr-pr.js +215 -0
- package/src/features/watermark/detect.d.ts +76 -0
- package/src/features/watermark/detect.js +219 -0
- package/src/features/watermark/index.d.ts +28 -0
- package/src/features/watermark/index.js +91 -0
- package/src/features/watermark/logical-store.d.ts +29 -0
- package/src/features/watermark/logical-store.js +31 -0
- package/src/features/watermark/model.d.ts +285 -0
- package/src/features/watermark/model.js +597 -0
- package/src/features/watermark/parse.d.ts +84 -0
- package/src/features/watermark/parse.js +815 -0
- package/src/features/watermark/serialize.d.ts +98 -0
- package/src/features/watermark/serialize.js +1517 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section partition (load) and flatten (save) for the single physical `w:body`.
|
|
3
|
+
*
|
|
4
|
+
* Evidence: ECMA-376-1 §11.3.10 (Main Document), §17.6 (section properties);
|
|
5
|
+
* transitional `wml.xsd` body / sectPr / CT_PPr.sectPr. Break paragraph belongs
|
|
6
|
+
* to the ending section. Non-final properties live on that paragraph; final
|
|
7
|
+
* properties are the trailing body-level `w:sectPr`.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
import { SectionPropertiesModel } from './section-properties-model';
|
|
12
|
+
import { WordDocument } from './document';
|
|
13
|
+
import { BlockContent, Paragraph } from './paragraph';
|
|
14
|
+
import { OpenXmlElement } from '../../core/xml/index';
|
|
15
|
+
/**
|
|
16
|
+
* One logical section after partition (internal blocks + page-setup source).
|
|
17
|
+
*
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
export declare type SectionData = {
|
|
21
|
+
readonly items: BlockContent[];
|
|
22
|
+
/** Paragraph- or body-level section properties (XML or live model). */
|
|
23
|
+
readonly properties: SectionPropertiesModel | OpenXmlElement | undefined;
|
|
24
|
+
readonly isFinal: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Optional feature hook: materialize live section properties from `w:sectPr` XML.
|
|
28
|
+
* Installed by the sections feature so core never imports `SectionProperties`.
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
export declare type SectionPropertiesParse = (element: OpenXmlElement) => SectionPropertiesModel | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Optional feature hook: associate a live page-setup model with its owning document
|
|
35
|
+
* (headers/footers WeakMap bridges). Core never imports `SectionProperties`.
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
export declare type SectionPropertiesAttached = (model: SectionPropertiesModel, document: WordDocument) => void;
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
export declare function registerSectionPropertiesParse(parse: SectionPropertiesParse): void;
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
export declare function resetSectionPropertiesParseForTests(): void;
|
|
48
|
+
/**
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
export declare function registerSectionPropertiesAttached(handler: SectionPropertiesAttached): void;
|
|
52
|
+
/**
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
export declare function resetSectionPropertiesAttachedForTests(): void;
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
* Notify the sections feature that a live page-setup model is attached to a document.
|
|
59
|
+
*/
|
|
60
|
+
export declare function notifySectionPropertiesAttached(model: SectionPropertiesModel | undefined, document: WordDocument): void;
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
* Materialize XML `w:sectPr` to a live model when the sections feature is registered.
|
|
64
|
+
*/
|
|
65
|
+
export declare function materializeSectionProperties(source: SectionPropertiesModel | OpenXmlElement | undefined): SectionPropertiesModel | OpenXmlElement | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve paragraph-level section break as model or preserved XML, if any.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
export declare function paragraphSectionBreakSource(paragraph: Paragraph): SectionPropertiesModel | OpenXmlElement | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* True when the paragraph closes a non-final section (has `w:pPr/w:sectPr`).
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
export declare function paragraphClosesSection(paragraph: Paragraph): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Partition ordered body blocks + trailing body-level sectPr into logical sections.
|
|
80
|
+
*
|
|
81
|
+
* Non-final sections close on a paragraph that carries section properties; that
|
|
82
|
+
* paragraph is included in the ending section. The final section uses
|
|
83
|
+
* `trailingSectPr` (may be undefined for an empty/default final).
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
export declare function partitionBodyIntoSections(blocks: ReadonlyArray<BlockContent>, trailingSectPr: SectionPropertiesModel | OpenXmlElement | undefined): SectionData[];
|
|
88
|
+
/**
|
|
89
|
+
* Attach page setup onto the last paragraph of a non-final section for serialize.
|
|
90
|
+
* Clears dual-hold on the paragraph so the section's pageSetup is the source.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
export declare function applyNonFinalSectionBreak(lastParagraph: Paragraph, pageSetup: SectionPropertiesModel | OpenXmlElement | undefined): void;
|
|
95
|
+
/**
|
|
96
|
+
* Ensure a non-final section ends on a paragraph; append empty terminator if needed.
|
|
97
|
+
* Returns the paragraph that will carry section properties.
|
|
98
|
+
*
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
export declare function ensureSectionTerminatorParagraph(items: BlockContent[]): Paragraph;
|
|
102
|
+
/**
|
|
103
|
+
* Flatten logical sections into one ordered body-child list (no trailing body sectPr).
|
|
104
|
+
* Mutates non-final section stores only as needed to ensure terminator paragraphs and
|
|
105
|
+
* attach paragraph-level section properties from each section's pageSetup.
|
|
106
|
+
*
|
|
107
|
+
* Caller appends body-final sectPr from the last section separately.
|
|
108
|
+
*
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
export declare function flattenSectionsToBodyBlocks(sections: ReadonlyArray<{
|
|
112
|
+
readonly listBlocks: () => ReadonlyArray<BlockContent>;
|
|
113
|
+
readonly pageSetup: SectionPropertiesModel | undefined;
|
|
114
|
+
/** Optional raw XML when pageSetup model is absent. */
|
|
115
|
+
readonly pageSetupXml?: OpenXmlElement | undefined;
|
|
116
|
+
readonly replaceItems?: (items: ReadonlyArray<BlockContent>) => void;
|
|
117
|
+
readonly isLast: boolean;
|
|
118
|
+
}>): BlockContent[];
|
|
119
|
+
/**
|
|
120
|
+
* Serialize page setup source to OpenXmlElement for body-final or paragraph sectPr.
|
|
121
|
+
*
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
export declare function sectionPropertiesToOpenXml(source: SectionPropertiesModel | OpenXmlElement | undefined): OpenXmlElement | undefined;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Paragraph } from './paragraph';
|
|
2
|
+
var sectionPropertiesParse;
|
|
3
|
+
var sectionPropertiesAttached;
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
export function registerSectionPropertiesParse(parse) {
|
|
8
|
+
sectionPropertiesParse = parse;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
export function resetSectionPropertiesParseForTests() {
|
|
14
|
+
sectionPropertiesParse = undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
export function registerSectionPropertiesAttached(handler) {
|
|
20
|
+
sectionPropertiesAttached = handler;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
export function resetSectionPropertiesAttachedForTests() {
|
|
26
|
+
sectionPropertiesAttached = undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
* Notify the sections feature that a live page-setup model is attached to a document.
|
|
31
|
+
*/
|
|
32
|
+
export function notifySectionPropertiesAttached(model, document) {
|
|
33
|
+
if (model === undefined || sectionPropertiesAttached === undefined) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
sectionPropertiesAttached(model, document);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
* Materialize XML `w:sectPr` to a live model when the sections feature is registered.
|
|
41
|
+
*/
|
|
42
|
+
export function materializeSectionProperties(source) {
|
|
43
|
+
if (source === undefined) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (typeof source.toOpenXml === 'function') {
|
|
47
|
+
return source;
|
|
48
|
+
}
|
|
49
|
+
if (sectionPropertiesParse === undefined) {
|
|
50
|
+
return source;
|
|
51
|
+
}
|
|
52
|
+
var parsed = sectionPropertiesParse(source);
|
|
53
|
+
return parsed !== undefined ? parsed : source;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve paragraph-level section break as model or preserved XML, if any.
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
export function paragraphSectionBreakSource(paragraph) {
|
|
61
|
+
var model = paragraph.sectionBreakPropertiesModel();
|
|
62
|
+
if (model !== undefined) {
|
|
63
|
+
return model;
|
|
64
|
+
}
|
|
65
|
+
return paragraph.sectionBreakSectPr();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* True when the paragraph closes a non-final section (has `w:pPr/w:sectPr`).
|
|
69
|
+
*
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
export function paragraphClosesSection(paragraph) {
|
|
73
|
+
return paragraphSectionBreakSource(paragraph) !== undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Partition ordered body blocks + trailing body-level sectPr into logical sections.
|
|
77
|
+
*
|
|
78
|
+
* Non-final sections close on a paragraph that carries section properties; that
|
|
79
|
+
* paragraph is included in the ending section. The final section uses
|
|
80
|
+
* `trailingSectPr` (may be undefined for an empty/default final).
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
export function partitionBodyIntoSections(blocks, trailingSectPr) {
|
|
85
|
+
var sections = [];
|
|
86
|
+
var current = [];
|
|
87
|
+
for (var i = 0; i < blocks.length; i += 1) {
|
|
88
|
+
var block = blocks[i];
|
|
89
|
+
current.push(block);
|
|
90
|
+
if (block.type === 'paragraph' && paragraphClosesSection(block.paragraph)) {
|
|
91
|
+
var props = paragraphSectionBreakSource(block.paragraph);
|
|
92
|
+
sections.push({
|
|
93
|
+
items: current,
|
|
94
|
+
properties: props,
|
|
95
|
+
isFinal: false,
|
|
96
|
+
});
|
|
97
|
+
current = [];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
sections.push({
|
|
101
|
+
items: current,
|
|
102
|
+
properties: trailingSectPr,
|
|
103
|
+
isFinal: true,
|
|
104
|
+
});
|
|
105
|
+
// Invariant: at least one section (empty body → single final with optional props).
|
|
106
|
+
return sections;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Attach page setup onto the last paragraph of a non-final section for serialize.
|
|
110
|
+
* Clears dual-hold on the paragraph so the section's pageSetup is the source.
|
|
111
|
+
*
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
export function applyNonFinalSectionBreak(lastParagraph, pageSetup) {
|
|
115
|
+
if (pageSetup === undefined) {
|
|
116
|
+
lastParagraph.replaceSectionBreakPropertiesModel(undefined);
|
|
117
|
+
lastParagraph.replaceSectionBreakSectPr(undefined);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (typeof pageSetup.toOpenXml === 'function') {
|
|
121
|
+
lastParagraph.replaceSectionBreakPropertiesModel(pageSetup);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
lastParagraph.replaceSectionBreakSectPr(pageSetup);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Ensure a non-final section ends on a paragraph; append empty terminator if needed.
|
|
128
|
+
* Returns the paragraph that will carry section properties.
|
|
129
|
+
*
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
export function ensureSectionTerminatorParagraph(items) {
|
|
133
|
+
var last = items[items.length - 1];
|
|
134
|
+
if (last !== undefined && last.type === 'paragraph') {
|
|
135
|
+
return last.paragraph;
|
|
136
|
+
}
|
|
137
|
+
var paragraph = new Paragraph(undefined);
|
|
138
|
+
items.push({ type: 'paragraph', paragraph: paragraph });
|
|
139
|
+
return paragraph;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Flatten logical sections into one ordered body-child list (no trailing body sectPr).
|
|
143
|
+
* Mutates non-final section stores only as needed to ensure terminator paragraphs and
|
|
144
|
+
* attach paragraph-level section properties from each section's pageSetup.
|
|
145
|
+
*
|
|
146
|
+
* Caller appends body-final sectPr from the last section separately.
|
|
147
|
+
*
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
export function flattenSectionsToBodyBlocks(sections) {
|
|
151
|
+
var out = [];
|
|
152
|
+
for (var i = 0; i < sections.length; i += 1) {
|
|
153
|
+
var section = sections[i];
|
|
154
|
+
var isFinal = section.isLast;
|
|
155
|
+
var raw = section.listBlocks().slice();
|
|
156
|
+
var setup = section.pageSetup !== undefined
|
|
157
|
+
? section.pageSetup
|
|
158
|
+
: section.pageSetupXml;
|
|
159
|
+
if (!isFinal) {
|
|
160
|
+
var terminator = ensureSectionTerminatorParagraph(raw);
|
|
161
|
+
// When neither model nor XML page setup is available (sections feature
|
|
162
|
+
// not registered), leave existing paragraph-level sectPr dual-hold alone.
|
|
163
|
+
if (setup !== undefined || section.pageSetup !== undefined || section.pageSetupXml !== undefined) {
|
|
164
|
+
applyNonFinalSectionBreak(terminator, setup);
|
|
165
|
+
}
|
|
166
|
+
else if (!paragraphClosesSection(terminator)) {
|
|
167
|
+
// Terminator was just appended (section ended on non-paragraph) with
|
|
168
|
+
// no properties to attach — still a valid empty closer; properties
|
|
169
|
+
// remain absent (Word may treat as default section mark).
|
|
170
|
+
}
|
|
171
|
+
if (section.replaceItems !== undefined) {
|
|
172
|
+
section.replaceItems(raw);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Final section must not leave paragraph-level sectPr on its last paragraph
|
|
177
|
+
// from a prior dual-hold authoring path when pageSetup is body-level only.
|
|
178
|
+
// Leave any internal paragraph breaks that intentionally closed earlier
|
|
179
|
+
// non-final sections alone — those live in prior sections after partition.
|
|
180
|
+
// Clear break on last paragraph only if it still holds a break that mirrors
|
|
181
|
+
// final props (authoring via lastSection alone should not emit pPr sectPr).
|
|
182
|
+
// Spec: final properties are body-level only.
|
|
183
|
+
var last = raw[raw.length - 1];
|
|
184
|
+
if (last !== undefined && last.type === 'paragraph') {
|
|
185
|
+
// Do not strip if this paragraph was itself a mid-document break —
|
|
186
|
+
// final section items never include those after correct partition.
|
|
187
|
+
// Authoring bridge may still put sectionBreak on a final-section
|
|
188
|
+
// paragraph; strip so body-level sectPr is sole final source.
|
|
189
|
+
if (paragraphClosesSection(last.paragraph)) {
|
|
190
|
+
last.paragraph.replaceSectionBreakPropertiesModel(undefined);
|
|
191
|
+
last.paragraph.replaceSectionBreakSectPr(undefined);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (section.replaceItems !== undefined) {
|
|
195
|
+
section.replaceItems(raw);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
for (var j = 0; j < raw.length; j += 1) {
|
|
199
|
+
out.push(raw[j]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Serialize page setup source to OpenXmlElement for body-final or paragraph sectPr.
|
|
206
|
+
*
|
|
207
|
+
* @private
|
|
208
|
+
*/
|
|
209
|
+
export function sectionPropertiesToOpenXml(source) {
|
|
210
|
+
if (source === undefined) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
if (typeof source.toOpenXml === 'function') {
|
|
214
|
+
return source.toOpenXml();
|
|
215
|
+
}
|
|
216
|
+
return source;
|
|
217
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OpenXmlElement } from '../../core/xml/index';
|
|
2
|
+
/**
|
|
3
|
+
* Duck-typed body-final / paragraph section-break model from the optional sections
|
|
4
|
+
* feature. Core stores the object without importing `PageSetup`.
|
|
5
|
+
*
|
|
6
|
+
* Internal serialization boundary only — never returned as the public type of
|
|
7
|
+
* {@link Section.pageSetup}.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export interface SectionPropertiesModel {
|
|
12
|
+
toOpenXml(): OpenXmlElement;
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Body } from './body';
|
|
2
|
+
import { HeadersFooters } from './headers-footers';
|
|
3
|
+
import { BlockContentControlCollection, ParagraphCollection, TableCollection } from './typed-body-collections';
|
|
4
|
+
import { BlockContent } from './paragraph';
|
|
5
|
+
import { PageSetup } from './page-setup';
|
|
6
|
+
import { SectionPropertiesModel } from './section-properties-model';
|
|
7
|
+
import { WordDocument } from './document';
|
|
8
|
+
/**
|
|
9
|
+
* One document section: body story, page setup, and header/footer slots.
|
|
10
|
+
*
|
|
11
|
+
* Main-story entry is {@link Section.body}.{@link Body.items}. Typed views
|
|
12
|
+
* ({@link Section.paragraphs}, {@link Section.tables},
|
|
13
|
+
* {@link Section.blockContentControls}) filter the same collection.
|
|
14
|
+
*
|
|
15
|
+
* Public {@link pageSetup} is always a live {@link PageSetup} when the sections
|
|
16
|
+
* feature is registered. Core stores the value as
|
|
17
|
+
* {@link SectionPropertiesModel} without importing the feature class.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare class Section {
|
|
22
|
+
private readonly bodyInstance;
|
|
23
|
+
private readonly paragraphsInstance;
|
|
24
|
+
private readonly tablesInstance;
|
|
25
|
+
private readonly blockContentControlsInstance;
|
|
26
|
+
private readonly headersFootersInstance;
|
|
27
|
+
private pageSetupModel;
|
|
28
|
+
private document;
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
constructor(document: WordDocument | undefined, blocks?: ReadonlyArray<BlockContent>, pageSetup?: SectionPropertiesModel);
|
|
33
|
+
/**
|
|
34
|
+
* Section body — sole collection owner for this section's main-story items.
|
|
35
|
+
*/
|
|
36
|
+
readonly body: Body;
|
|
37
|
+
/**
|
|
38
|
+
* Paragraphs in this section body (filtered view over {@link Body.items}).
|
|
39
|
+
*/
|
|
40
|
+
readonly paragraphs: ParagraphCollection;
|
|
41
|
+
/**
|
|
42
|
+
* Tables in this section body (filtered view). Empty until the tables
|
|
43
|
+
* feature registers typed-collection hooks.
|
|
44
|
+
*/
|
|
45
|
+
readonly tables: TableCollection;
|
|
46
|
+
/**
|
|
47
|
+
* Block content controls in this section body (filtered view).
|
|
48
|
+
*/
|
|
49
|
+
readonly blockContentControls: BlockContentControlCollection;
|
|
50
|
+
/**
|
|
51
|
+
* Always-present header/footer slots for this section.
|
|
52
|
+
*
|
|
53
|
+
* Six getters never return `undefined`. Empty slots expose zero child items
|
|
54
|
+
* until content is written; package parts are created lazily.
|
|
55
|
+
*/
|
|
56
|
+
readonly headersFooters: HeadersFooters;
|
|
57
|
+
/**
|
|
58
|
+
* Live section page setup (`w:sectPr` model).
|
|
59
|
+
*
|
|
60
|
+
* Always returns the same {@link PageSetup} instance while the sections
|
|
61
|
+
* feature is registered. Never typed as {@link SectionPropertiesModel}.
|
|
62
|
+
* Serialization stays on the internal model bridge
|
|
63
|
+
* ({@link internalPageSetupModel}).
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
readonly pageSetup: PageSetup;
|
|
68
|
+
/**
|
|
69
|
+
* @private
|
|
70
|
+
* Internal dual-hold / serialize model. Prefer {@link pageSetup} publicly.
|
|
71
|
+
*/
|
|
72
|
+
internalPageSetupModel(): SectionPropertiesModel | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* @private
|
|
75
|
+
* Attach or clear the live page-setup model. Clearing re-seeds a default
|
|
76
|
+
* when the sections feature seed hook is registered so `pageSetup` stays
|
|
77
|
+
* defined for always-on section properties.
|
|
78
|
+
*/
|
|
79
|
+
setPageSetup(value: SectionPropertiesModel | undefined): void;
|
|
80
|
+
/**
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
owningDocument(): WordDocument;
|
|
84
|
+
/**
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
bindDocument(document: WordDocument): void;
|
|
88
|
+
/**
|
|
89
|
+
* @private
|
|
90
|
+
* Refresh typed collection index properties after raw-store load mutations.
|
|
91
|
+
*/
|
|
92
|
+
syncCollections(): void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Body } from './body';
|
|
2
|
+
import { HeadersFooters } from './headers-footers';
|
|
3
|
+
import { createBlockContentControlCollection, createTableCollection, ParagraphCollection, } from './typed-body-collections';
|
|
4
|
+
import { Paragraph } from './paragraph';
|
|
5
|
+
import { currentSectionPageSetupSeed } from './sections';
|
|
6
|
+
import { notifySectionPropertiesAttached } from './section-partition-flatten';
|
|
7
|
+
import { DetachedObjectError } from '../../core/errors/docx-error';
|
|
8
|
+
/**
|
|
9
|
+
* One document section: body story, page setup, and header/footer slots.
|
|
10
|
+
*
|
|
11
|
+
* Main-story entry is {@link Section.body}.{@link Body.items}. Typed views
|
|
12
|
+
* ({@link Section.paragraphs}, {@link Section.tables},
|
|
13
|
+
* {@link Section.blockContentControls}) filter the same collection.
|
|
14
|
+
*
|
|
15
|
+
* Public {@link pageSetup} is always a live {@link PageSetup} when the sections
|
|
16
|
+
* feature is registered. Core stores the value as
|
|
17
|
+
* {@link SectionPropertiesModel} without importing the feature class.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
var Section = /** @class */ (function () {
|
|
22
|
+
/**
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
function Section(document, blocks, pageSetup) {
|
|
26
|
+
if (blocks === void 0) { blocks = []; }
|
|
27
|
+
this.document = document;
|
|
28
|
+
this.bodyInstance = new Body(document, blocks, this);
|
|
29
|
+
this.pageSetupModel = pageSetup;
|
|
30
|
+
if (this.pageSetupModel === undefined) {
|
|
31
|
+
var seed = currentSectionPageSetupSeed();
|
|
32
|
+
if (seed !== undefined) {
|
|
33
|
+
this.pageSetupModel = seed();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.headersFootersInstance = new HeadersFooters(this);
|
|
37
|
+
this.paragraphsInstance = new ParagraphCollection(this.bodyInstance.items, function () { return new Paragraph(undefined); });
|
|
38
|
+
this.tablesInstance = createTableCollection(this.bodyInstance.items);
|
|
39
|
+
this.blockContentControlsInstance = createBlockContentControlCollection(this.bodyInstance.items);
|
|
40
|
+
}
|
|
41
|
+
Object.defineProperty(Section.prototype, "body", {
|
|
42
|
+
/**
|
|
43
|
+
* Section body — sole collection owner for this section's main-story items.
|
|
44
|
+
*/
|
|
45
|
+
get: function () {
|
|
46
|
+
return this.bodyInstance;
|
|
47
|
+
},
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(Section.prototype, "paragraphs", {
|
|
52
|
+
/**
|
|
53
|
+
* Paragraphs in this section body (filtered view over {@link Body.items}).
|
|
54
|
+
*/
|
|
55
|
+
get: function () {
|
|
56
|
+
return this.paragraphsInstance;
|
|
57
|
+
},
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(Section.prototype, "tables", {
|
|
62
|
+
/**
|
|
63
|
+
* Tables in this section body (filtered view). Empty until the tables
|
|
64
|
+
* feature registers typed-collection hooks.
|
|
65
|
+
*/
|
|
66
|
+
get: function () {
|
|
67
|
+
return this.tablesInstance;
|
|
68
|
+
},
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(Section.prototype, "blockContentControls", {
|
|
73
|
+
/**
|
|
74
|
+
* Block content controls in this section body (filtered view).
|
|
75
|
+
*/
|
|
76
|
+
get: function () {
|
|
77
|
+
return this.blockContentControlsInstance;
|
|
78
|
+
},
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(Section.prototype, "headersFooters", {
|
|
83
|
+
/**
|
|
84
|
+
* Always-present header/footer slots for this section.
|
|
85
|
+
*
|
|
86
|
+
* Six getters never return `undefined`. Empty slots expose zero child items
|
|
87
|
+
* until content is written; package parts are created lazily.
|
|
88
|
+
*/
|
|
89
|
+
get: function () {
|
|
90
|
+
return this.headersFootersInstance;
|
|
91
|
+
},
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(Section.prototype, "pageSetup", {
|
|
96
|
+
/**
|
|
97
|
+
* Live section page setup (`w:sectPr` model).
|
|
98
|
+
*
|
|
99
|
+
* Always returns the same {@link PageSetup} instance while the sections
|
|
100
|
+
* feature is registered. Never typed as {@link SectionPropertiesModel}.
|
|
101
|
+
* Serialization stays on the internal model bridge
|
|
102
|
+
* ({@link internalPageSetupModel}).
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
get: function () {
|
|
107
|
+
if (this.pageSetupModel === undefined) {
|
|
108
|
+
var seed = currentSectionPageSetupSeed();
|
|
109
|
+
if (seed !== undefined) {
|
|
110
|
+
this.pageSetupModel = seed();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (this.pageSetupModel === undefined) {
|
|
114
|
+
throw new DetachedObjectError('Section.pageSetup requires the sections feature (import @syncfusion/ej2-docx or @syncfusion/ej2-docx/sections)');
|
|
115
|
+
}
|
|
116
|
+
// Feature PageSetup implements the public PageSetup contract and the
|
|
117
|
+
// internal SectionPropertiesModel serialization boundary. Core cannot
|
|
118
|
+
// import the feature class, so identity is asserted through unknown.
|
|
119
|
+
return this.pageSetupModel;
|
|
120
|
+
},
|
|
121
|
+
enumerable: true,
|
|
122
|
+
configurable: true
|
|
123
|
+
});
|
|
124
|
+
/**
|
|
125
|
+
* @private
|
|
126
|
+
* Internal dual-hold / serialize model. Prefer {@link pageSetup} publicly.
|
|
127
|
+
*/
|
|
128
|
+
Section.prototype.internalPageSetupModel = function () {
|
|
129
|
+
return this.pageSetupModel;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* @private
|
|
133
|
+
* Attach or clear the live page-setup model. Clearing re-seeds a default
|
|
134
|
+
* when the sections feature seed hook is registered so `pageSetup` stays
|
|
135
|
+
* defined for always-on section properties.
|
|
136
|
+
*/
|
|
137
|
+
Section.prototype.setPageSetup = function (value) {
|
|
138
|
+
if (value !== undefined) {
|
|
139
|
+
this.pageSetupModel = value;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
var seed = currentSectionPageSetupSeed();
|
|
143
|
+
this.pageSetupModel = seed !== undefined ? seed() : undefined;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
Section.prototype.owningDocument = function () {
|
|
149
|
+
if (this.document === undefined) {
|
|
150
|
+
throw new DetachedObjectError('Section is not attached to a document');
|
|
151
|
+
}
|
|
152
|
+
return this.document;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
Section.prototype.bindDocument = function (document) {
|
|
158
|
+
this.headersFootersInstance.bindSection(this);
|
|
159
|
+
this.document = document;
|
|
160
|
+
this.bodyInstance.setOwningDocument(document);
|
|
161
|
+
this.bodyInstance.setOwningSection(this);
|
|
162
|
+
if (this.pageSetupModel !== undefined) {
|
|
163
|
+
notifySectionPropertiesAttached(this.pageSetupModel, document);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* @private
|
|
168
|
+
* Refresh typed collection index properties after raw-store load mutations.
|
|
169
|
+
*/
|
|
170
|
+
Section.prototype.syncCollections = function () {
|
|
171
|
+
this.bodyInstance.items.syncFromHost();
|
|
172
|
+
this.paragraphsInstance.syncFromHost();
|
|
173
|
+
this.tablesInstance.syncFromHost();
|
|
174
|
+
this.blockContentControlsInstance.syncFromHost();
|
|
175
|
+
};
|
|
176
|
+
return Section;
|
|
177
|
+
}());
|
|
178
|
+
export { Section };
|