@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,2807 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __values = (this && this.__values) || function (o) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
14
|
+
if (m) return m.call(o);
|
|
15
|
+
return {
|
|
16
|
+
next: function () {
|
|
17
|
+
if (o && i >= o.length) o = void 0;
|
|
18
|
+
return { value: o && o[i++], done: !o };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
import { pointToTwips, twipsToPoint } from './length';
|
|
23
|
+
import { objectValues } from '../../core/compat/object-compat';
|
|
24
|
+
import { DocxError } from '../../core/errors/docx-error';
|
|
25
|
+
import { alignmentFromJc, jcForNewAlignment } from './alignment';
|
|
26
|
+
import { colorToHexWire } from './color';
|
|
27
|
+
import { parseOnOff, serializeOnOff } from './on-off';
|
|
28
|
+
import { BorderStyle as BorderStyleEnum } from './page-setup';
|
|
29
|
+
import { elementChildren, isWml, wValAttribute, wmlAttr, wmlElement, } from './wml';
|
|
30
|
+
import { cnfStyleIsEmpty, normalizeCnfStyle, parseCnfStyle, serializeCnfStyle, } from '../tables/tbl-pr';
|
|
31
|
+
/**
|
|
32
|
+
* Tab stop justification / alignment (`ST_TabJc`). §17.18.83
|
|
33
|
+
*
|
|
34
|
+
* Prefer named members such as {@link TabJustification.Left} in authoring APIs.
|
|
35
|
+
* Wire tokens are the member values and are unchanged for serialization.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export var TabJustification = {
|
|
40
|
+
Left: 'left',
|
|
41
|
+
Center: 'center',
|
|
42
|
+
Right: 'right',
|
|
43
|
+
Decimal: 'decimal',
|
|
44
|
+
Bar: 'bar',
|
|
45
|
+
Clear: 'clear',
|
|
46
|
+
Num: 'num',
|
|
47
|
+
Start: 'start',
|
|
48
|
+
End: 'end',
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Tab stop leader character (`ST_TabTlc`). §17.18.84
|
|
52
|
+
*
|
|
53
|
+
* Prefer named members such as {@link TabLeader.Dot} / {@link TabLeader.NoLeader}.
|
|
54
|
+
* Wire tokens are the member values and are unchanged for serialization.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export var TabLeader = {
|
|
59
|
+
NoLeader: 'none',
|
|
60
|
+
Dot: 'dot',
|
|
61
|
+
Heavy: 'heavy',
|
|
62
|
+
Hyphen: 'hyphen',
|
|
63
|
+
MiddleDot: 'middleDot',
|
|
64
|
+
Single: 'single',
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Mutable DocIO-style tab-stop entry backed by {@link TabStop} storage.
|
|
68
|
+
* Distinct from run-level `w:r/w:tab` ({@link import('./text-range').Tab}).
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
var ParagraphTabStop = /** @class */ (function () {
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
function ParagraphTabStop(position, justification, leader) {
|
|
77
|
+
if (position === void 0) { position = 0; }
|
|
78
|
+
if (justification === void 0) { justification = TabJustification.Left; }
|
|
79
|
+
if (leader === void 0) { leader = TabLeader.NoLeader; }
|
|
80
|
+
this.positionValue = position;
|
|
81
|
+
this.justificationValue = justification;
|
|
82
|
+
this.leaderValue = leader;
|
|
83
|
+
}
|
|
84
|
+
Object.defineProperty(ParagraphTabStop.prototype, "position", {
|
|
85
|
+
/** Position in points. */
|
|
86
|
+
get: function () {
|
|
87
|
+
return this.positionValue;
|
|
88
|
+
},
|
|
89
|
+
set: function (value) {
|
|
90
|
+
this.positionValue = value;
|
|
91
|
+
},
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(ParagraphTabStop.prototype, "justification", {
|
|
96
|
+
/** Alignment / justification (`@w:val`). */
|
|
97
|
+
get: function () {
|
|
98
|
+
return this.justificationValue;
|
|
99
|
+
},
|
|
100
|
+
set: function (value) {
|
|
101
|
+
this.justificationValue = value;
|
|
102
|
+
},
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(ParagraphTabStop.prototype, "alignment", {
|
|
107
|
+
/** Alias of {@link ParagraphTabStop.justification}. */
|
|
108
|
+
get: function () {
|
|
109
|
+
return this.justificationValue;
|
|
110
|
+
},
|
|
111
|
+
set: function (value) {
|
|
112
|
+
this.justificationValue = value;
|
|
113
|
+
},
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(ParagraphTabStop.prototype, "leader", {
|
|
118
|
+
/** Leader character. */
|
|
119
|
+
get: function () {
|
|
120
|
+
return this.leaderValue;
|
|
121
|
+
},
|
|
122
|
+
set: function (value) {
|
|
123
|
+
this.leaderValue = value;
|
|
124
|
+
},
|
|
125
|
+
enumerable: true,
|
|
126
|
+
configurable: true
|
|
127
|
+
});
|
|
128
|
+
/** @private */
|
|
129
|
+
ParagraphTabStop.prototype.toBagStop = function () {
|
|
130
|
+
var stop = {
|
|
131
|
+
position: this.positionValue,
|
|
132
|
+
alignment: this.justificationValue,
|
|
133
|
+
};
|
|
134
|
+
if (this.leaderValue !== TabLeader.NoLeader) {
|
|
135
|
+
return { position: this.positionValue, alignment: this.justificationValue, leader: this.leaderValue };
|
|
136
|
+
}
|
|
137
|
+
return stop;
|
|
138
|
+
};
|
|
139
|
+
/** @private */
|
|
140
|
+
ParagraphTabStop.fromTabStop = function (stop) {
|
|
141
|
+
return new ParagraphTabStop(stop.position, stop.alignment, stop.leader !== undefined ? stop.leader : TabLeader.NoLeader);
|
|
142
|
+
};
|
|
143
|
+
return ParagraphTabStop;
|
|
144
|
+
}());
|
|
145
|
+
export { ParagraphTabStop };
|
|
146
|
+
/**
|
|
147
|
+
* Live collection over paragraph tab stops. Mirrors bag {@link ParagraphFormat.tabStops}.
|
|
148
|
+
*
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
var TabCollection = /** @class */ (function () {
|
|
152
|
+
/** @private */
|
|
153
|
+
function TabCollection(owner) {
|
|
154
|
+
this.owner = owner;
|
|
155
|
+
}
|
|
156
|
+
Object.defineProperty(TabCollection.prototype, "count", {
|
|
157
|
+
/** Number of tab stops. */
|
|
158
|
+
get: function () {
|
|
159
|
+
var stops = this.owner.tabStops;
|
|
160
|
+
return stops !== undefined ? stops.length : 0;
|
|
161
|
+
},
|
|
162
|
+
enumerable: true,
|
|
163
|
+
configurable: true
|
|
164
|
+
});
|
|
165
|
+
/**
|
|
166
|
+
* Tab stop at index, or `undefined`.
|
|
167
|
+
*/
|
|
168
|
+
TabCollection.prototype.item = function (index) {
|
|
169
|
+
var stops = this.owner.tabStops;
|
|
170
|
+
if (stops === undefined || index < 0 || index >= stops.length) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return ParagraphTabStop.fromTabStop(stops[index]);
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Add a tab stop (points / justification / leader).
|
|
177
|
+
* Prefer {@link TabCollection.addTab} for DocIO-aligned naming.
|
|
178
|
+
*/
|
|
179
|
+
TabCollection.prototype.add = function (position, justification, leader) {
|
|
180
|
+
return this.addTab(position, justification, leader);
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* DocIO-aligned add. Zero-arg adds a default left stop at position `0`.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* pf.tabs.addTab();
|
|
188
|
+
* pf.tabs.addTab(36);
|
|
189
|
+
* pf.tabs.addTab(72, TabJustification.Right, TabLeader.Dot);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
TabCollection.prototype.addTab = function (position, justification, leader) {
|
|
193
|
+
var entry = new ParagraphTabStop(position !== undefined ? position : 0, justification !== undefined ? justification : TabJustification.Left, leader !== undefined ? leader : TabLeader.NoLeader);
|
|
194
|
+
var current = this.owner.tabStops;
|
|
195
|
+
var next = current !== undefined ? current.slice() : [];
|
|
196
|
+
next.push(entry.toBagStop());
|
|
197
|
+
this.owner.tabStops = next;
|
|
198
|
+
return entry;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Remove the tab stop at `index` (`0…count-1`).
|
|
202
|
+
* @throws RangeError when the index is out of range.
|
|
203
|
+
*/
|
|
204
|
+
TabCollection.prototype.removeAt = function (index) {
|
|
205
|
+
var stops = this.owner.tabStops;
|
|
206
|
+
if (stops === undefined || index < 0 || index >= stops.length) {
|
|
207
|
+
throw new RangeError('TabCollection.removeAt: index out of range');
|
|
208
|
+
}
|
|
209
|
+
if (stops.length === 1) {
|
|
210
|
+
this.owner.tabStops = undefined;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
var next = stops.slice();
|
|
214
|
+
next.splice(index, 1);
|
|
215
|
+
this.owner.tabStops = next;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Remove the first tab stop whose position equals `position` (points).
|
|
219
|
+
* No-op when no matching stop exists.
|
|
220
|
+
*/
|
|
221
|
+
TabCollection.prototype.removeByPosition = function (position) {
|
|
222
|
+
var stops = this.owner.tabStops;
|
|
223
|
+
if (stops === undefined) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
var found = -1;
|
|
227
|
+
for (var i = 0; i < stops.length; i++) {
|
|
228
|
+
if (stops[i].position === position) {
|
|
229
|
+
found = i;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (found < 0) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.removeAt(found);
|
|
237
|
+
};
|
|
238
|
+
/** Remove all tab stops. */
|
|
239
|
+
TabCollection.prototype.clear = function () {
|
|
240
|
+
this.owner.tabStops = undefined;
|
|
241
|
+
};
|
|
242
|
+
return TabCollection;
|
|
243
|
+
}());
|
|
244
|
+
export { TabCollection };
|
|
245
|
+
/**
|
|
246
|
+
* Live single paragraph border edge (`w:pBdr` child).
|
|
247
|
+
*
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
var ParagraphBorderFace = /** @class */ (function () {
|
|
251
|
+
/** @private */
|
|
252
|
+
function ParagraphBorderFace(owner, edge) {
|
|
253
|
+
this.owner = owner;
|
|
254
|
+
this.edge = edge;
|
|
255
|
+
}
|
|
256
|
+
ParagraphBorderFace.prototype.read = function () {
|
|
257
|
+
var bag = this.owner.readBordersBag();
|
|
258
|
+
return bag !== undefined ? bag[this.edge] : undefined;
|
|
259
|
+
};
|
|
260
|
+
ParagraphBorderFace.prototype.write = function (next) {
|
|
261
|
+
var existing = this.owner.readBordersBag();
|
|
262
|
+
var bag = existing !== undefined ? __assign({}, existing) : {};
|
|
263
|
+
if (next === undefined) {
|
|
264
|
+
delete bag[this.edge];
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
bag[this.edge] = next;
|
|
268
|
+
}
|
|
269
|
+
var empty = bag.top === undefined
|
|
270
|
+
&& bag.left === undefined
|
|
271
|
+
&& bag.bottom === undefined
|
|
272
|
+
&& bag.right === undefined
|
|
273
|
+
&& bag.between === undefined
|
|
274
|
+
&& bag.bar === undefined;
|
|
275
|
+
this.owner.writeBordersBag(empty ? undefined : bag);
|
|
276
|
+
};
|
|
277
|
+
Object.defineProperty(ParagraphBorderFace.prototype, "borderType", {
|
|
278
|
+
/** Line style. */
|
|
279
|
+
get: function () {
|
|
280
|
+
var e = this.read();
|
|
281
|
+
return e !== undefined ? e.style : 'none';
|
|
282
|
+
},
|
|
283
|
+
set: function (value) {
|
|
284
|
+
var cur = this.read();
|
|
285
|
+
this.write({
|
|
286
|
+
style: value,
|
|
287
|
+
color: cur !== undefined ? cur.color : undefined,
|
|
288
|
+
size: cur !== undefined ? cur.size : undefined,
|
|
289
|
+
space: cur !== undefined ? cur.space : undefined,
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
enumerable: true,
|
|
293
|
+
configurable: true
|
|
294
|
+
});
|
|
295
|
+
Object.defineProperty(ParagraphBorderFace.prototype, "color", {
|
|
296
|
+
/** Hex RGB or `'auto'`. Setter also accepts a {@link Color} enum value. */
|
|
297
|
+
get: function () {
|
|
298
|
+
var e = this.read();
|
|
299
|
+
return e !== undefined && e.color !== undefined ? e.color : 'auto';
|
|
300
|
+
},
|
|
301
|
+
set: function (value) {
|
|
302
|
+
var cur = this.read();
|
|
303
|
+
this.write({
|
|
304
|
+
style: cur !== undefined ? cur.style : 'single',
|
|
305
|
+
color: borderColorToWire(value),
|
|
306
|
+
size: cur !== undefined ? cur.size : undefined,
|
|
307
|
+
space: cur !== undefined ? cur.space : undefined,
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
enumerable: true,
|
|
311
|
+
configurable: true
|
|
312
|
+
});
|
|
313
|
+
Object.defineProperty(ParagraphBorderFace.prototype, "lineWidth", {
|
|
314
|
+
/** Thickness in points (public); stored as eighths of a point. */
|
|
315
|
+
get: function () {
|
|
316
|
+
var e = this.read();
|
|
317
|
+
return e !== undefined && e.size !== undefined ? e.size / 8 : 0;
|
|
318
|
+
},
|
|
319
|
+
set: function (value) {
|
|
320
|
+
var cur = this.read();
|
|
321
|
+
this.write({
|
|
322
|
+
style: cur !== undefined ? cur.style : 'single',
|
|
323
|
+
color: cur !== undefined ? cur.color : undefined,
|
|
324
|
+
size: Math.round(value * 8),
|
|
325
|
+
space: cur !== undefined ? cur.space : undefined,
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
enumerable: true,
|
|
329
|
+
configurable: true
|
|
330
|
+
});
|
|
331
|
+
Object.defineProperty(ParagraphBorderFace.prototype, "space", {
|
|
332
|
+
/** Space from text in points. */
|
|
333
|
+
get: function () {
|
|
334
|
+
var e = this.read();
|
|
335
|
+
return e !== undefined && e.space !== undefined ? e.space : 0;
|
|
336
|
+
},
|
|
337
|
+
set: function (value) {
|
|
338
|
+
var cur = this.read();
|
|
339
|
+
this.write({
|
|
340
|
+
style: cur !== undefined ? cur.style : 'single',
|
|
341
|
+
color: cur !== undefined ? cur.color : undefined,
|
|
342
|
+
size: cur !== undefined ? cur.size : undefined,
|
|
343
|
+
space: value,
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
enumerable: true,
|
|
347
|
+
configurable: true
|
|
348
|
+
});
|
|
349
|
+
return ParagraphBorderFace;
|
|
350
|
+
}());
|
|
351
|
+
export { ParagraphBorderFace };
|
|
352
|
+
/**
|
|
353
|
+
* Live paragraph borders with per-edge access. Whole-bag assign/clear via
|
|
354
|
+
* {@link ParagraphFormat.setBorders}.
|
|
355
|
+
*
|
|
356
|
+
* @public
|
|
357
|
+
*/
|
|
358
|
+
var ParagraphBordersFace = /** @class */ (function () {
|
|
359
|
+
/** @private */
|
|
360
|
+
function ParagraphBordersFace(owner) {
|
|
361
|
+
this.owner = owner;
|
|
362
|
+
}
|
|
363
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "top", {
|
|
364
|
+
get: function () {
|
|
365
|
+
if (this.topFace === undefined) {
|
|
366
|
+
this.topFace = new ParagraphBorderFace(this.owner, 'top');
|
|
367
|
+
}
|
|
368
|
+
return this.topFace;
|
|
369
|
+
},
|
|
370
|
+
enumerable: true,
|
|
371
|
+
configurable: true
|
|
372
|
+
});
|
|
373
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "left", {
|
|
374
|
+
get: function () {
|
|
375
|
+
if (this.leftFace === undefined) {
|
|
376
|
+
this.leftFace = new ParagraphBorderFace(this.owner, 'left');
|
|
377
|
+
}
|
|
378
|
+
return this.leftFace;
|
|
379
|
+
},
|
|
380
|
+
enumerable: true,
|
|
381
|
+
configurable: true
|
|
382
|
+
});
|
|
383
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "bottom", {
|
|
384
|
+
get: function () {
|
|
385
|
+
if (this.bottomFace === undefined) {
|
|
386
|
+
this.bottomFace = new ParagraphBorderFace(this.owner, 'bottom');
|
|
387
|
+
}
|
|
388
|
+
return this.bottomFace;
|
|
389
|
+
},
|
|
390
|
+
enumerable: true,
|
|
391
|
+
configurable: true
|
|
392
|
+
});
|
|
393
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "right", {
|
|
394
|
+
get: function () {
|
|
395
|
+
if (this.rightFace === undefined) {
|
|
396
|
+
this.rightFace = new ParagraphBorderFace(this.owner, 'right');
|
|
397
|
+
}
|
|
398
|
+
return this.rightFace;
|
|
399
|
+
},
|
|
400
|
+
enumerable: true,
|
|
401
|
+
configurable: true
|
|
402
|
+
});
|
|
403
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "between", {
|
|
404
|
+
get: function () {
|
|
405
|
+
if (this.betweenFace === undefined) {
|
|
406
|
+
this.betweenFace = new ParagraphBorderFace(this.owner, 'between');
|
|
407
|
+
}
|
|
408
|
+
return this.betweenFace;
|
|
409
|
+
},
|
|
410
|
+
enumerable: true,
|
|
411
|
+
configurable: true
|
|
412
|
+
});
|
|
413
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "bar", {
|
|
414
|
+
get: function () {
|
|
415
|
+
if (this.barFace === undefined) {
|
|
416
|
+
this.barFace = new ParagraphBorderFace(this.owner, 'bar');
|
|
417
|
+
}
|
|
418
|
+
return this.barFace;
|
|
419
|
+
},
|
|
420
|
+
enumerable: true,
|
|
421
|
+
configurable: true
|
|
422
|
+
});
|
|
423
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "borderType", {
|
|
424
|
+
/** Stamp line style onto all outer edges. */
|
|
425
|
+
set: function (value) {
|
|
426
|
+
this.top.borderType = value;
|
|
427
|
+
this.left.borderType = value;
|
|
428
|
+
this.bottom.borderType = value;
|
|
429
|
+
this.right.borderType = value;
|
|
430
|
+
},
|
|
431
|
+
enumerable: true,
|
|
432
|
+
configurable: true
|
|
433
|
+
});
|
|
434
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "color", {
|
|
435
|
+
/** Stamp color onto all outer edges (hex/`'auto'` or {@link Color}). */
|
|
436
|
+
set: function (value) {
|
|
437
|
+
this.top.color = value;
|
|
438
|
+
this.left.color = value;
|
|
439
|
+
this.bottom.color = value;
|
|
440
|
+
this.right.color = value;
|
|
441
|
+
},
|
|
442
|
+
enumerable: true,
|
|
443
|
+
configurable: true
|
|
444
|
+
});
|
|
445
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "lineWidth", {
|
|
446
|
+
/** Stamp line width (points) onto all outer edges. */
|
|
447
|
+
set: function (value) {
|
|
448
|
+
this.top.lineWidth = value;
|
|
449
|
+
this.left.lineWidth = value;
|
|
450
|
+
this.bottom.lineWidth = value;
|
|
451
|
+
this.right.lineWidth = value;
|
|
452
|
+
},
|
|
453
|
+
enumerable: true,
|
|
454
|
+
configurable: true
|
|
455
|
+
});
|
|
456
|
+
Object.defineProperty(ParagraphBordersFace.prototype, "space", {
|
|
457
|
+
/** Stamp space from text (points) onto all outer edges. */
|
|
458
|
+
set: function (value) {
|
|
459
|
+
this.top.space = value;
|
|
460
|
+
this.left.space = value;
|
|
461
|
+
this.bottom.space = value;
|
|
462
|
+
this.right.space = value;
|
|
463
|
+
},
|
|
464
|
+
enumerable: true,
|
|
465
|
+
configurable: true
|
|
466
|
+
});
|
|
467
|
+
return ParagraphBordersFace;
|
|
468
|
+
}());
|
|
469
|
+
export { ParagraphBordersFace };
|
|
470
|
+
/**
|
|
471
|
+
* Normalize border color input to wire hex / `'auto'`.
|
|
472
|
+
* @private
|
|
473
|
+
*/
|
|
474
|
+
function borderColorToWire(value) {
|
|
475
|
+
if (typeof value === 'number') {
|
|
476
|
+
var hex = colorToHexWire(value);
|
|
477
|
+
return hex.length > 0 ? hex : 'auto';
|
|
478
|
+
}
|
|
479
|
+
return value;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Normalize shading fill/pattern-color input to wire hex / `'auto'`.
|
|
483
|
+
* {@link Color} enum values become OOXML hex; {@link Color.Transparent}
|
|
484
|
+
* maps to `'auto'`. Plain strings pass through for load-path compatibility.
|
|
485
|
+
* @private
|
|
486
|
+
*/
|
|
487
|
+
function shadingColorToWire(value) {
|
|
488
|
+
if (typeof value === 'number') {
|
|
489
|
+
var hex = colorToHexWire(value);
|
|
490
|
+
return hex.length > 0 ? hex : 'auto';
|
|
491
|
+
}
|
|
492
|
+
return value;
|
|
493
|
+
}
|
|
494
|
+
/** @private Legal `ST_TextDirection` tokens (12, wml.xsd 798–813). */
|
|
495
|
+
var TEXT_DIRECTIONS = new Set([
|
|
496
|
+
'lr',
|
|
497
|
+
'rl',
|
|
498
|
+
'tb',
|
|
499
|
+
'tbV',
|
|
500
|
+
'rlV',
|
|
501
|
+
'lrV',
|
|
502
|
+
'btLr',
|
|
503
|
+
'lrTb',
|
|
504
|
+
'lrTbV',
|
|
505
|
+
'tbLrV',
|
|
506
|
+
'tbRl',
|
|
507
|
+
'tbRlV',
|
|
508
|
+
]);
|
|
509
|
+
/** @private Legal `ST_TextAlignment` tokens (wml.xsd 817–825). */
|
|
510
|
+
var BASELINE_ALIGNMENTS = new Set([
|
|
511
|
+
'auto',
|
|
512
|
+
'top',
|
|
513
|
+
'center',
|
|
514
|
+
'baseline',
|
|
515
|
+
'bottom',
|
|
516
|
+
]);
|
|
517
|
+
/** @private Shading patterns accepted for authored writes (§17.18.78 subset). */
|
|
518
|
+
var SHADING_PATTERNS = new Set([
|
|
519
|
+
'clear', 'solid', 'horzStripe', 'vertStripe', 'reverseDiagStripe', 'diagStripe',
|
|
520
|
+
'horzCross', 'diagCross', 'thinHorzStripe', 'thinVertStripe', 'thinReverseDiagStripe',
|
|
521
|
+
'thinDiagStripe', 'thinHorzCross', 'thinDiagCross', 'pct5', 'pct10', 'pct12', 'pct15',
|
|
522
|
+
'pct20', 'pct25', 'pct30', 'pct35', 'pct37', 'pct40', 'pct45', 'pct50', 'pct55',
|
|
523
|
+
'pct60', 'pct62', 'pct65', 'pct70', 'pct75', 'pct80', 'pct85', 'pct87', 'pct90', 'pct95',
|
|
524
|
+
]);
|
|
525
|
+
/**
|
|
526
|
+
* @private
|
|
527
|
+
* Known `ST_Border` wire tokens for paragraph borders — derived from the
|
|
528
|
+
* page-setup `BorderStyle` enum so the set stays single-sourced.
|
|
529
|
+
*/
|
|
530
|
+
var BORDER_STYLES = new Set(objectValues(BorderStyleEnum));
|
|
531
|
+
/**
|
|
532
|
+
* @private
|
|
533
|
+
* Empty snapshot factory.
|
|
534
|
+
*/
|
|
535
|
+
export function emptyParagraphFormatSnapshot() {
|
|
536
|
+
return {
|
|
537
|
+
pPrExtra: [],
|
|
538
|
+
jcRaw: undefined,
|
|
539
|
+
keepNextValue: undefined,
|
|
540
|
+
keepLinesValue: undefined,
|
|
541
|
+
pageBreakBeforeValue: undefined,
|
|
542
|
+
pageBreakAfterValue: undefined,
|
|
543
|
+
widowControlValue: undefined,
|
|
544
|
+
bidiValue: undefined,
|
|
545
|
+
outlineLevelValue: undefined,
|
|
546
|
+
indentsValue: undefined,
|
|
547
|
+
spacingValue: undefined,
|
|
548
|
+
tabStopsValue: undefined,
|
|
549
|
+
bordersValue: undefined,
|
|
550
|
+
shadingValue: undefined,
|
|
551
|
+
suppressAutoHyphensValue: undefined,
|
|
552
|
+
suppressLineNumbersValue: undefined,
|
|
553
|
+
contextualSpacingValue: undefined,
|
|
554
|
+
mirrorIndentsValue: undefined,
|
|
555
|
+
adjustRightIndentValue: undefined,
|
|
556
|
+
textDirectionValue: undefined,
|
|
557
|
+
textDirectionRaw: undefined,
|
|
558
|
+
baselineAlignmentValue: undefined,
|
|
559
|
+
baselineAlignmentRaw: undefined,
|
|
560
|
+
snapToGridValue: undefined,
|
|
561
|
+
wordWrapValue: undefined,
|
|
562
|
+
overflowPunctuationValue: undefined,
|
|
563
|
+
autoSpaceDEValue: undefined,
|
|
564
|
+
autoSpaceDNValue: undefined,
|
|
565
|
+
kinsokuValue: undefined,
|
|
566
|
+
topLinePunctuationValue: undefined,
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
// ---------------------------------------------------------------------------
|
|
570
|
+
// Validation helpers (ADR D9 taxonomy: RangeError for numeric ranges,
|
|
571
|
+
// DocxError('content/…') for tokens; unknown loaded values never throw).
|
|
572
|
+
// ---------------------------------------------------------------------------
|
|
573
|
+
function validateSignedExtentPoints(name, value) {
|
|
574
|
+
if (value < -1584 || value > 1584) {
|
|
575
|
+
throw new RangeError(name + ' must be in [-1584, 1584] points, got ' + String(value));
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function validateNonNegativeExtentPoints(name, value) {
|
|
579
|
+
if (value < 0 || value > 1584) {
|
|
580
|
+
throw new RangeError(name + ' must be in [0, 1584] points, got ' + String(value));
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function validateLineSpacingPoints(value) {
|
|
584
|
+
if (value < 0.7 || value > 1584) {
|
|
585
|
+
throw new RangeError('lineSpacing must be in [0.7, 1584] points, got ' + String(value));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function validateOutlineLevel(value) {
|
|
589
|
+
if (!isFinite(value) || Math.floor(value) !== value || value < 0 || value > 9) {
|
|
590
|
+
throw new RangeError('outlineLevel must be an integer 0–9, got ' + String(value));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
function validateHexColor(name, value) {
|
|
594
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(value) && value !== 'auto') {
|
|
595
|
+
throw new DocxError('content/invalid-shading-pattern', name + ' must be a six-digit hex color (RRGGBB) or "auto", got "' + value + '"');
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
/** Ensure the internal indents record exists (does not notify). */
|
|
599
|
+
function ensureIndents(record) {
|
|
600
|
+
return record === undefined ? {} : record;
|
|
601
|
+
}
|
|
602
|
+
function indentsRecordIsEmpty(record) {
|
|
603
|
+
return record.left === undefined
|
|
604
|
+
&& record.right === undefined
|
|
605
|
+
&& record.firstLine === undefined
|
|
606
|
+
&& record.hanging === undefined
|
|
607
|
+
&& record.start === undefined
|
|
608
|
+
&& record.end === undefined
|
|
609
|
+
&& record.leftChars === undefined
|
|
610
|
+
&& record.rightChars === undefined
|
|
611
|
+
&& record.firstLineChars === undefined
|
|
612
|
+
&& record.hangingChars === undefined;
|
|
613
|
+
}
|
|
614
|
+
/** Ensure the internal spacing record exists (does not notify). */
|
|
615
|
+
function ensureSpacing(record) {
|
|
616
|
+
return record === undefined ? {} : record;
|
|
617
|
+
}
|
|
618
|
+
function spacingRecordIsEmpty(record) {
|
|
619
|
+
return record.before === undefined
|
|
620
|
+
&& record.after === undefined
|
|
621
|
+
&& record.line === undefined
|
|
622
|
+
&& record.lineRule === undefined
|
|
623
|
+
&& record.beforeAutospacing === undefined
|
|
624
|
+
&& record.afterAutospacing === undefined
|
|
625
|
+
&& record.beforeLines === undefined
|
|
626
|
+
&& record.afterLines === undefined;
|
|
627
|
+
}
|
|
628
|
+
var PARAGRAPH_FORMAT_DEFAULTS = {
|
|
629
|
+
horizontalAlignment: 'start',
|
|
630
|
+
keepFollow: false,
|
|
631
|
+
keepLines: false,
|
|
632
|
+
pageBreakBefore: false,
|
|
633
|
+
pageBreakAfter: false,
|
|
634
|
+
widowControl: true,
|
|
635
|
+
bidi: false,
|
|
636
|
+
outlineLevel: 9,
|
|
637
|
+
leftIndent: 0,
|
|
638
|
+
rightIndent: 0,
|
|
639
|
+
firstLineIndent: 0,
|
|
640
|
+
beforeSpacing: 0,
|
|
641
|
+
afterSpacing: 0,
|
|
642
|
+
beforeAutospacing: false,
|
|
643
|
+
afterAutospacing: false,
|
|
644
|
+
beforeLines: 0,
|
|
645
|
+
afterLines: 0,
|
|
646
|
+
lineSpacing: 12,
|
|
647
|
+
lineSpacingRule: 'auto',
|
|
648
|
+
lineSpacingCount: 1,
|
|
649
|
+
backColor: '',
|
|
650
|
+
foreColor: '',
|
|
651
|
+
suppressAutoHyphens: false,
|
|
652
|
+
suppressLineNumbers: false,
|
|
653
|
+
contextualSpacing: false,
|
|
654
|
+
mirrorIndents: false,
|
|
655
|
+
adjustRightIndent: false,
|
|
656
|
+
baselineAlignment: 'auto',
|
|
657
|
+
snapToGrid: true,
|
|
658
|
+
wordWrap: true,
|
|
659
|
+
overflowPunctuation: true,
|
|
660
|
+
autoSpaceDE: false,
|
|
661
|
+
autoSpaceDN: false,
|
|
662
|
+
};
|
|
663
|
+
/**
|
|
664
|
+
* Direct paragraph formatting (`w:p/w:pPr`) — the only public
|
|
665
|
+
* paragraph-formatting surface. One live instance per
|
|
666
|
+
* {@link Paragraph}, lazily created via `paragraph.paragraphFormat`,
|
|
667
|
+
* never null. Mirrors the .NET DocIO `WParagraphFormat` flat property
|
|
668
|
+
* surface (ADR `docs/adr/2026-09-24-paragraph-format-facade.md`).
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```ts
|
|
672
|
+
* paragraph.paragraphFormat.beforeSpacing = 18;
|
|
673
|
+
* paragraph.paragraphFormat.lineSpacing = 10;
|
|
674
|
+
* paragraph.paragraphFormat.firstLineIndent = 10; // negative = hanging
|
|
675
|
+
* paragraph.paragraphFormat.backColor = 'D3D3D3';
|
|
676
|
+
* paragraph.paragraphFormat.horizontalAlignment = 'end';
|
|
677
|
+
* ```
|
|
678
|
+
*
|
|
679
|
+
* @public
|
|
680
|
+
*/
|
|
681
|
+
var ParagraphFormat = /** @class */ (function () {
|
|
682
|
+
/**
|
|
683
|
+
* @private
|
|
684
|
+
*/
|
|
685
|
+
function ParagraphFormat(host) {
|
|
686
|
+
this.pPrExtra = [];
|
|
687
|
+
this.host = host;
|
|
688
|
+
}
|
|
689
|
+
ParagraphFormat.prototype.mutate = function () {
|
|
690
|
+
this.host.notifyParagraphFormatMutation();
|
|
691
|
+
};
|
|
692
|
+
ParagraphFormat.prototype.effective = function (key) {
|
|
693
|
+
var resolve = this.host.resolveEffectiveParagraphValue;
|
|
694
|
+
var value = resolve !== undefined ? resolve.call(this.host, key) : undefined;
|
|
695
|
+
return value !== undefined ? value : undefined;
|
|
696
|
+
};
|
|
697
|
+
ParagraphFormat.prototype.effectiveOrDefault = function (key, defaultValue) {
|
|
698
|
+
var value = this.effective(key);
|
|
699
|
+
return value !== undefined ? value : defaultValue;
|
|
700
|
+
};
|
|
701
|
+
Object.defineProperty(ParagraphFormat.prototype, "horizontalAlignment", {
|
|
702
|
+
// ---- Group A: alignment (§2) ----
|
|
703
|
+
/**
|
|
704
|
+
* Horizontal alignment of the paragraph (`w:jc`). `undefined` = inherit.
|
|
705
|
+
*
|
|
706
|
+
* Loaded directional `left`/`right` wording is surfaced as the neutral
|
|
707
|
+
* `start`/`end` without rewriting the stored value on a no-op save;
|
|
708
|
+
* unknown `w:jc` values (distribute-family) round-trip verbatim and this
|
|
709
|
+
* getter returns `undefined` for them.
|
|
710
|
+
*
|
|
711
|
+
* @public
|
|
712
|
+
*/
|
|
713
|
+
get: function () {
|
|
714
|
+
if (this.jcRaw !== undefined) {
|
|
715
|
+
var value = alignmentFromJc(this.jcRaw);
|
|
716
|
+
if (value !== undefined) {
|
|
717
|
+
return value;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
return this.effective('horizontalAlignment');
|
|
721
|
+
},
|
|
722
|
+
set: function (value) {
|
|
723
|
+
if (value === undefined) {
|
|
724
|
+
this.jcRaw = undefined;
|
|
725
|
+
this.mutate();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
var current = this.jcRaw === undefined ? undefined : alignmentFromJc(this.jcRaw);
|
|
729
|
+
if (current === value) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
this.jcRaw = jcForNewAlignment(value);
|
|
733
|
+
this.mutate();
|
|
734
|
+
},
|
|
735
|
+
enumerable: true,
|
|
736
|
+
configurable: true
|
|
737
|
+
});
|
|
738
|
+
Object.defineProperty(ParagraphFormat.prototype, "keepFollow", {
|
|
739
|
+
// ---- Group A: keeps and breaks (§9) ----
|
|
740
|
+
/** Keep paragraph with the next (`w:keepNext`). `undefined` = inherit. */
|
|
741
|
+
get: function () {
|
|
742
|
+
if (this.keepNextValue !== undefined) {
|
|
743
|
+
return this.keepNextValue;
|
|
744
|
+
}
|
|
745
|
+
return this.effective('keepFollow');
|
|
746
|
+
},
|
|
747
|
+
set: function (value) {
|
|
748
|
+
this.keepNextValue = value;
|
|
749
|
+
this.mutate();
|
|
750
|
+
},
|
|
751
|
+
enumerable: true,
|
|
752
|
+
configurable: true
|
|
753
|
+
});
|
|
754
|
+
Object.defineProperty(ParagraphFormat.prototype, "keepLines", {
|
|
755
|
+
/** Keep all lines of the paragraph on one page (`w:keepLines`). */
|
|
756
|
+
get: function () {
|
|
757
|
+
if (this.keepLinesValue !== undefined) {
|
|
758
|
+
return this.keepLinesValue;
|
|
759
|
+
}
|
|
760
|
+
return this.effective('keepLines');
|
|
761
|
+
},
|
|
762
|
+
set: function (value) {
|
|
763
|
+
this.keepLinesValue = value;
|
|
764
|
+
this.mutate();
|
|
765
|
+
},
|
|
766
|
+
enumerable: true,
|
|
767
|
+
configurable: true
|
|
768
|
+
});
|
|
769
|
+
Object.defineProperty(ParagraphFormat.prototype, "pageBreakBefore", {
|
|
770
|
+
/** Force this paragraph onto a new page (`w:pageBreakBefore`). */
|
|
771
|
+
get: function () {
|
|
772
|
+
if (this.pageBreakBeforeValue !== undefined) {
|
|
773
|
+
return this.pageBreakBeforeValue;
|
|
774
|
+
}
|
|
775
|
+
return this.effective('pageBreakBefore');
|
|
776
|
+
},
|
|
777
|
+
set: function (value) {
|
|
778
|
+
this.pageBreakBeforeValue = value;
|
|
779
|
+
this.mutate();
|
|
780
|
+
},
|
|
781
|
+
enumerable: true,
|
|
782
|
+
configurable: true
|
|
783
|
+
});
|
|
784
|
+
Object.defineProperty(ParagraphFormat.prototype, "pageBreakAfter", {
|
|
785
|
+
/**
|
|
786
|
+
* DocIO-aligned page-break-after flag.
|
|
787
|
+
*
|
|
788
|
+
* There is no ECMA-376 `w:pageBreakAfter` on `w:pPr` (see
|
|
789
|
+
* `docs/specs/paragraph-formatting.md` § deliberate omissions). The typed flag
|
|
790
|
+
* is still stored for assign / clear / style resolve. On serialize, when the
|
|
791
|
+
* direct value is `true`, body writers emit a **following** paragraph whose
|
|
792
|
+
* only content is `w:r/w:br/@w:type="page"` after the content `w:p` — without
|
|
793
|
+
* inventing a non-schema pPr child and without placing the break run inside
|
|
794
|
+
* the content paragraph.
|
|
795
|
+
*/
|
|
796
|
+
get: function () {
|
|
797
|
+
if (this.pageBreakAfterValue !== undefined) {
|
|
798
|
+
return this.pageBreakAfterValue;
|
|
799
|
+
}
|
|
800
|
+
return this.effective('pageBreakAfter');
|
|
801
|
+
},
|
|
802
|
+
set: function (value) {
|
|
803
|
+
this.pageBreakAfterValue = value;
|
|
804
|
+
this.mutate();
|
|
805
|
+
},
|
|
806
|
+
enumerable: true,
|
|
807
|
+
configurable: true
|
|
808
|
+
});
|
|
809
|
+
Object.defineProperty(ParagraphFormat.prototype, "widowControl", {
|
|
810
|
+
/** Widow/orphan line control (`w:widowControl`). */
|
|
811
|
+
get: function () {
|
|
812
|
+
if (this.widowControlValue !== undefined) {
|
|
813
|
+
return this.widowControlValue;
|
|
814
|
+
}
|
|
815
|
+
return this.effective('widowControl');
|
|
816
|
+
},
|
|
817
|
+
set: function (value) {
|
|
818
|
+
this.widowControlValue = value;
|
|
819
|
+
this.mutate();
|
|
820
|
+
},
|
|
821
|
+
enumerable: true,
|
|
822
|
+
configurable: true
|
|
823
|
+
});
|
|
824
|
+
Object.defineProperty(ParagraphFormat.prototype, "bidi", {
|
|
825
|
+
/** Right-to-left base flow (`w:bidi`). */
|
|
826
|
+
get: function () {
|
|
827
|
+
if (this.bidiValue !== undefined) {
|
|
828
|
+
return this.bidiValue;
|
|
829
|
+
}
|
|
830
|
+
return this.effective('bidi');
|
|
831
|
+
},
|
|
832
|
+
set: function (value) {
|
|
833
|
+
this.bidiValue = value;
|
|
834
|
+
this.mutate();
|
|
835
|
+
},
|
|
836
|
+
enumerable: true,
|
|
837
|
+
configurable: true
|
|
838
|
+
});
|
|
839
|
+
Object.defineProperty(ParagraphFormat.prototype, "outlineLevel", {
|
|
840
|
+
/**
|
|
841
|
+
* Outline/navigation level (`w:outlineLvl`): 0–8 = Heading 1–9,
|
|
842
|
+
* 9 = body text. `undefined` = inherit. Authoring an integer outside
|
|
843
|
+
* 0–9 throws `RangeError` (no silent clamp).
|
|
844
|
+
*/
|
|
845
|
+
get: function () {
|
|
846
|
+
if (this.outlineLevelValue !== undefined) {
|
|
847
|
+
return this.outlineLevelValue;
|
|
848
|
+
}
|
|
849
|
+
return this.effective('outlineLevel');
|
|
850
|
+
},
|
|
851
|
+
set: function (value) {
|
|
852
|
+
if (value === undefined) {
|
|
853
|
+
this.outlineLevelValue = undefined;
|
|
854
|
+
this.mutate();
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
validateOutlineLevel(value);
|
|
858
|
+
this.outlineLevelValue = value;
|
|
859
|
+
this.mutate();
|
|
860
|
+
},
|
|
861
|
+
enumerable: true,
|
|
862
|
+
configurable: true
|
|
863
|
+
});
|
|
864
|
+
Object.defineProperty(ParagraphFormat.prototype, "leftIndent", {
|
|
865
|
+
// ---- Group A: indents (§7; ADR D1/D2/D3) ----
|
|
866
|
+
/**
|
|
867
|
+
* Left-of-flow indent in points (`w:ind/@w:left` authored; loaded
|
|
868
|
+
* `@w:start` preserved). Signed: negative values are legal outdents.
|
|
869
|
+
* Range ±1584 points; out-of-range throws `RangeError`.
|
|
870
|
+
* Setting a value drops a loaded `start`/`leftChars` twin (ADR D11).
|
|
871
|
+
*/
|
|
872
|
+
get: function () {
|
|
873
|
+
if (this.indentsValue !== undefined) {
|
|
874
|
+
if (this.indentsValue.left !== undefined) {
|
|
875
|
+
return twipsToPoint(this.indentsValue.left);
|
|
876
|
+
}
|
|
877
|
+
if (this.indentsValue.start !== undefined) {
|
|
878
|
+
return twipsToPoint(this.indentsValue.start);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return this.effective('leftIndent');
|
|
882
|
+
},
|
|
883
|
+
set: function (value) {
|
|
884
|
+
var indents = ensureIndents(this.indentsValue);
|
|
885
|
+
if (value === undefined) {
|
|
886
|
+
indents.left = undefined;
|
|
887
|
+
this.indentsValue = indentsRecordIsEmpty(indents) ? undefined : indents;
|
|
888
|
+
this.mutate();
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
validateSignedExtentPoints('leftIndent', value);
|
|
892
|
+
indents.left = Math.round(value * 20);
|
|
893
|
+
// Authored write supersedes loaded twins (ADR D11).
|
|
894
|
+
indents.start = undefined;
|
|
895
|
+
indents.leftChars = undefined;
|
|
896
|
+
this.indentsValue = indentsRecordIsEmpty(indents) ? undefined : indents;
|
|
897
|
+
this.mutate();
|
|
898
|
+
},
|
|
899
|
+
enumerable: true,
|
|
900
|
+
configurable: true
|
|
901
|
+
});
|
|
902
|
+
Object.defineProperty(ParagraphFormat.prototype, "rightIndent", {
|
|
903
|
+
/**
|
|
904
|
+
* Right-of-flow indent in points (`@w:right` authored; loaded `@w:end`
|
|
905
|
+
* preserved). Signed; range ±1584 points. Setting a value drops a loaded
|
|
906
|
+
* `end`/`rightChars` twin.
|
|
907
|
+
*/
|
|
908
|
+
get: function () {
|
|
909
|
+
if (this.indentsValue !== undefined) {
|
|
910
|
+
if (this.indentsValue.right !== undefined) {
|
|
911
|
+
return twipsToPoint(this.indentsValue.right);
|
|
912
|
+
}
|
|
913
|
+
if (this.indentsValue.end !== undefined) {
|
|
914
|
+
return twipsToPoint(this.indentsValue.end);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return this.effective('rightIndent');
|
|
918
|
+
},
|
|
919
|
+
set: function (value) {
|
|
920
|
+
var indents = ensureIndents(this.indentsValue);
|
|
921
|
+
if (value === undefined) {
|
|
922
|
+
indents.right = undefined;
|
|
923
|
+
this.indentsValue = indentsRecordIsEmpty(indents) ? undefined : indents;
|
|
924
|
+
this.mutate();
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
validateSignedExtentPoints('rightIndent', value);
|
|
928
|
+
indents.right = Math.round(value * 20);
|
|
929
|
+
indents.end = undefined;
|
|
930
|
+
indents.rightChars = undefined;
|
|
931
|
+
this.indentsValue = indentsRecordIsEmpty(indents) ? undefined : indents;
|
|
932
|
+
this.mutate();
|
|
933
|
+
},
|
|
934
|
+
enumerable: true,
|
|
935
|
+
configurable: true
|
|
936
|
+
});
|
|
937
|
+
Object.defineProperty(ParagraphFormat.prototype, "firstLineIndent", {
|
|
938
|
+
/**
|
|
939
|
+
* First-line indent in points, **signed** (ADR D3): positive = first-line
|
|
940
|
+
* indent (`@w:firstLine`); negative = hanging indent (`@w:hanging`,
|
|
941
|
+
* emitted as the absolute twips). Range ±1584 points. Setting a value
|
|
942
|
+
* drops a loaded `firstLineChars` twin. Loading a legacy `w:ind` that
|
|
943
|
+
* carries both `@w:firstLine` and `@w:hanging` is deterministic
|
|
944
|
+
* (firstLine wins) — the pair cannot be co-authored through this API.
|
|
945
|
+
*/
|
|
946
|
+
get: function () {
|
|
947
|
+
if (this.indentsValue !== undefined) {
|
|
948
|
+
if (this.indentsValue.firstLine !== undefined) {
|
|
949
|
+
return twipsToPoint(this.indentsValue.firstLine);
|
|
950
|
+
}
|
|
951
|
+
if (this.indentsValue.hanging !== undefined) {
|
|
952
|
+
return -twipsToPoint(this.indentsValue.hanging);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
return this.effective('firstLineIndent');
|
|
956
|
+
},
|
|
957
|
+
set: function (value) {
|
|
958
|
+
var indents = ensureIndents(this.indentsValue);
|
|
959
|
+
if (value === undefined) {
|
|
960
|
+
indents.firstLine = undefined;
|
|
961
|
+
indents.hanging = undefined;
|
|
962
|
+
this.indentsValue = indentsRecordIsEmpty(indents) ? undefined : indents;
|
|
963
|
+
this.mutate();
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
validateSignedExtentPoints('firstLineIndent', value);
|
|
967
|
+
if (value < 0) {
|
|
968
|
+
indents.firstLine = undefined;
|
|
969
|
+
indents.hanging = Math.round(-value * 20);
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
indents.firstLine = Math.round(value * 20);
|
|
973
|
+
indents.hanging = undefined;
|
|
974
|
+
}
|
|
975
|
+
indents.firstLineChars = undefined;
|
|
976
|
+
this.indentsValue = indentsRecordIsEmpty(indents) ? undefined : indents;
|
|
977
|
+
this.mutate();
|
|
978
|
+
},
|
|
979
|
+
enumerable: true,
|
|
980
|
+
configurable: true
|
|
981
|
+
});
|
|
982
|
+
Object.defineProperty(ParagraphFormat.prototype, "beforeSpacing", {
|
|
983
|
+
// ---- Group A: spacing (§8; ADR D4) ----
|
|
984
|
+
/**
|
|
985
|
+
* Space above the paragraph in points (`@w:before`). Range 0–1584.
|
|
986
|
+
* User-set clears an explicit `beforeAutospacing` (set-path only, never
|
|
987
|
+
* on load). Setting a value drops a loaded `@w:beforeLines` twin.
|
|
988
|
+
*/
|
|
989
|
+
get: function () {
|
|
990
|
+
if (this.spacingValue !== undefined && this.spacingValue.before !== undefined) {
|
|
991
|
+
return twipsToPoint(this.spacingValue.before);
|
|
992
|
+
}
|
|
993
|
+
return this.effective('beforeSpacing');
|
|
994
|
+
},
|
|
995
|
+
set: function (value) {
|
|
996
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
997
|
+
if (value === undefined) {
|
|
998
|
+
spacing.before = undefined;
|
|
999
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1000
|
+
this.mutate();
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
validateNonNegativeExtentPoints('beforeSpacing', value);
|
|
1004
|
+
spacing.before = Math.round(value * 20);
|
|
1005
|
+
if (spacing.beforeAutospacing === true) {
|
|
1006
|
+
spacing.beforeAutospacing = undefined;
|
|
1007
|
+
}
|
|
1008
|
+
spacing.beforeLines = undefined;
|
|
1009
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1010
|
+
this.mutate();
|
|
1011
|
+
},
|
|
1012
|
+
enumerable: true,
|
|
1013
|
+
configurable: true
|
|
1014
|
+
});
|
|
1015
|
+
Object.defineProperty(ParagraphFormat.prototype, "afterSpacing", {
|
|
1016
|
+
/**
|
|
1017
|
+
* Space below the paragraph in points (`@w:after`). Range 0–1584.
|
|
1018
|
+
* User-set clears an explicit `afterAutospacing` and drops a loaded
|
|
1019
|
+
* `@w:afterLines` twin.
|
|
1020
|
+
*/
|
|
1021
|
+
get: function () {
|
|
1022
|
+
if (this.spacingValue !== undefined && this.spacingValue.after !== undefined) {
|
|
1023
|
+
return twipsToPoint(this.spacingValue.after);
|
|
1024
|
+
}
|
|
1025
|
+
return this.effective('afterSpacing');
|
|
1026
|
+
},
|
|
1027
|
+
set: function (value) {
|
|
1028
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1029
|
+
if (value === undefined) {
|
|
1030
|
+
spacing.after = undefined;
|
|
1031
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1032
|
+
this.mutate();
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
validateNonNegativeExtentPoints('afterSpacing', value);
|
|
1036
|
+
spacing.after = Math.round(value * 20);
|
|
1037
|
+
if (spacing.afterAutospacing === true) {
|
|
1038
|
+
spacing.afterAutospacing = undefined;
|
|
1039
|
+
}
|
|
1040
|
+
spacing.afterLines = undefined;
|
|
1041
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1042
|
+
this.mutate();
|
|
1043
|
+
},
|
|
1044
|
+
enumerable: true,
|
|
1045
|
+
configurable: true
|
|
1046
|
+
});
|
|
1047
|
+
Object.defineProperty(ParagraphFormat.prototype, "beforeAutospacing", {
|
|
1048
|
+
/** Automatic spacing above (`@w:beforeAutospacing`). */
|
|
1049
|
+
get: function () {
|
|
1050
|
+
if (this.spacingValue !== undefined && this.spacingValue.beforeAutospacing !== undefined) {
|
|
1051
|
+
return this.spacingValue.beforeAutospacing;
|
|
1052
|
+
}
|
|
1053
|
+
return this.effective('beforeAutospacing');
|
|
1054
|
+
},
|
|
1055
|
+
set: function (value) {
|
|
1056
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1057
|
+
spacing.beforeAutospacing = value;
|
|
1058
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1059
|
+
this.mutate();
|
|
1060
|
+
},
|
|
1061
|
+
enumerable: true,
|
|
1062
|
+
configurable: true
|
|
1063
|
+
});
|
|
1064
|
+
Object.defineProperty(ParagraphFormat.prototype, "afterAutospacing", {
|
|
1065
|
+
/** Automatic spacing below (`@w:afterAutospacing`). */
|
|
1066
|
+
get: function () {
|
|
1067
|
+
if (this.spacingValue !== undefined && this.spacingValue.afterAutospacing !== undefined) {
|
|
1068
|
+
return this.spacingValue.afterAutospacing;
|
|
1069
|
+
}
|
|
1070
|
+
return this.effective('afterAutospacing');
|
|
1071
|
+
},
|
|
1072
|
+
set: function (value) {
|
|
1073
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1074
|
+
spacing.afterAutospacing = value;
|
|
1075
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1076
|
+
this.mutate();
|
|
1077
|
+
},
|
|
1078
|
+
enumerable: true,
|
|
1079
|
+
configurable: true
|
|
1080
|
+
});
|
|
1081
|
+
Object.defineProperty(ParagraphFormat.prototype, "beforeLines", {
|
|
1082
|
+
/**
|
|
1083
|
+
* Line-grid spacing above in hundredths of a line (`@w:beforeLines`),
|
|
1084
|
+
* round-trip slot for the East-Asian line-grid authoring style. Authored
|
|
1085
|
+
* `beforeSpacing` drops a loaded twin.
|
|
1086
|
+
*/
|
|
1087
|
+
get: function () {
|
|
1088
|
+
if (this.spacingValue !== undefined && this.spacingValue.beforeLines !== undefined) {
|
|
1089
|
+
return this.spacingValue.beforeLines;
|
|
1090
|
+
}
|
|
1091
|
+
return this.effective('beforeLines');
|
|
1092
|
+
},
|
|
1093
|
+
set: function (value) {
|
|
1094
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1095
|
+
spacing.beforeLines = value;
|
|
1096
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1097
|
+
this.mutate();
|
|
1098
|
+
},
|
|
1099
|
+
enumerable: true,
|
|
1100
|
+
configurable: true
|
|
1101
|
+
});
|
|
1102
|
+
Object.defineProperty(ParagraphFormat.prototype, "afterLines", {
|
|
1103
|
+
/** Line-grid spacing below in hundredths of a line (`@w:afterLines`). */
|
|
1104
|
+
get: function () {
|
|
1105
|
+
if (this.spacingValue !== undefined && this.spacingValue.afterLines !== undefined) {
|
|
1106
|
+
return this.spacingValue.afterLines;
|
|
1107
|
+
}
|
|
1108
|
+
return this.effective('afterLines');
|
|
1109
|
+
},
|
|
1110
|
+
set: function (value) {
|
|
1111
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1112
|
+
spacing.afterLines = value;
|
|
1113
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1114
|
+
this.mutate();
|
|
1115
|
+
},
|
|
1116
|
+
enumerable: true,
|
|
1117
|
+
configurable: true
|
|
1118
|
+
});
|
|
1119
|
+
Object.defineProperty(ParagraphFormat.prototype, "lineSpacing", {
|
|
1120
|
+
/**
|
|
1121
|
+
* Fixed/minimum line spacing in points (`@w:line` with
|
|
1122
|
+
* `lineSpacingRule` `'atLeast'` or `'exact'`). Range 0.7–1584 points.
|
|
1123
|
+
* Setting it clears {@link lineSpacingCount} — both are views of one
|
|
1124
|
+
* `@line` slot (ADR D4).
|
|
1125
|
+
*/
|
|
1126
|
+
get: function () {
|
|
1127
|
+
if (this.spacingValue !== undefined && this.spacingValue.line !== undefined
|
|
1128
|
+
&& this.spacingValue.lineRule !== 'auto') {
|
|
1129
|
+
return twipsToPoint(this.spacingValue.line);
|
|
1130
|
+
}
|
|
1131
|
+
return this.effective('lineSpacing');
|
|
1132
|
+
},
|
|
1133
|
+
set: function (value) {
|
|
1134
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1135
|
+
if (value === undefined) {
|
|
1136
|
+
spacing.line = undefined;
|
|
1137
|
+
if (spacing.lineRule === 'exact' || spacing.lineRule === 'atLeast') {
|
|
1138
|
+
spacing.lineRule = undefined;
|
|
1139
|
+
}
|
|
1140
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1141
|
+
this.mutate();
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
validateLineSpacingPoints(value);
|
|
1145
|
+
spacing.line = Math.round(value * 20);
|
|
1146
|
+
// ADR D4: points view leaves auto-count; default rule is exact unless
|
|
1147
|
+
// the author already chose atLeast.
|
|
1148
|
+
spacing.lineRule = spacing.lineRule === 'atLeast' ? 'atLeast' : 'exact';
|
|
1149
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1150
|
+
this.mutate();
|
|
1151
|
+
},
|
|
1152
|
+
enumerable: true,
|
|
1153
|
+
configurable: true
|
|
1154
|
+
});
|
|
1155
|
+
Object.defineProperty(ParagraphFormat.prototype, "lineSpacingRule", {
|
|
1156
|
+
/**
|
|
1157
|
+
* Interpretation rule for `@w:line`: `'auto'` (multiple of single
|
|
1158
|
+
* spacing — use {@link lineSpacingCount}), `'exact'` (exactly the given
|
|
1159
|
+
* height), `'atLeast'` (at least the given height). Default when
|
|
1160
|
+
* `lineSpacing` is authored without a rule: `'exact'`.
|
|
1161
|
+
*/
|
|
1162
|
+
get: function () {
|
|
1163
|
+
if (this.spacingValue !== undefined && this.spacingValue.lineRule !== undefined) {
|
|
1164
|
+
return this.spacingValue.lineRule;
|
|
1165
|
+
}
|
|
1166
|
+
return this.effective('lineSpacingRule');
|
|
1167
|
+
},
|
|
1168
|
+
set: function (value) {
|
|
1169
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1170
|
+
spacing.lineRule = value;
|
|
1171
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1172
|
+
this.mutate();
|
|
1173
|
+
},
|
|
1174
|
+
enumerable: true,
|
|
1175
|
+
configurable: true
|
|
1176
|
+
});
|
|
1177
|
+
Object.defineProperty(ParagraphFormat.prototype, "lineSpacingCount", {
|
|
1178
|
+
/**
|
|
1179
|
+
* Multiple-of-single line spacing (authoring view over
|
|
1180
|
+
* `@line = round(n × 240)` + `@lineRule="auto"`), e.g. `1.5` or `2`.
|
|
1181
|
+
* Range 0–100; mutually clears with {@link lineSpacing} (ADR D4).
|
|
1182
|
+
* Getter returns `n` only when the stored rule is `'auto'` and `@line`
|
|
1183
|
+
* is set; otherwise `undefined` (effective style may still resolve).
|
|
1184
|
+
*/
|
|
1185
|
+
get: function () {
|
|
1186
|
+
if (this.spacingValue !== undefined
|
|
1187
|
+
&& this.spacingValue.lineRule === 'auto'
|
|
1188
|
+
&& this.spacingValue.line !== undefined) {
|
|
1189
|
+
return this.spacingValue.line / 240;
|
|
1190
|
+
}
|
|
1191
|
+
return this.effective('lineSpacingCount');
|
|
1192
|
+
},
|
|
1193
|
+
set: function (value) {
|
|
1194
|
+
var spacing = ensureSpacing(this.spacingValue);
|
|
1195
|
+
if (value === undefined) {
|
|
1196
|
+
if (spacing.lineRule === 'auto') {
|
|
1197
|
+
spacing.line = undefined;
|
|
1198
|
+
spacing.lineRule = undefined;
|
|
1199
|
+
}
|
|
1200
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1201
|
+
this.mutate();
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (value < 0 || value > 100) {
|
|
1205
|
+
throw new RangeError('lineSpacingCount must be in [0, 100], got ' + String(value));
|
|
1206
|
+
}
|
|
1207
|
+
spacing.line = Math.round(value * 240);
|
|
1208
|
+
spacing.lineRule = 'auto';
|
|
1209
|
+
this.spacingValue = spacingRecordIsEmpty(spacing) ? undefined : spacing;
|
|
1210
|
+
this.mutate();
|
|
1211
|
+
},
|
|
1212
|
+
enumerable: true,
|
|
1213
|
+
configurable: true
|
|
1214
|
+
});
|
|
1215
|
+
Object.defineProperty(ParagraphFormat.prototype, "tabStops", {
|
|
1216
|
+
// ---- Group A: tabs (§11), borders (§12), shading (§13) ----
|
|
1217
|
+
/**
|
|
1218
|
+
* Custom tab stops (`w:tabs`), assigned whole as an array. `undefined`
|
|
1219
|
+
* clears explicit stops (style/default resolution may still supply some).
|
|
1220
|
+
*/
|
|
1221
|
+
get: function () {
|
|
1222
|
+
if (this.tabStopsValue !== undefined) {
|
|
1223
|
+
return this.tabStopsValue;
|
|
1224
|
+
}
|
|
1225
|
+
return this.effective('tabStops');
|
|
1226
|
+
},
|
|
1227
|
+
set: function (value) {
|
|
1228
|
+
this.tabStopsValue = value;
|
|
1229
|
+
this.mutate();
|
|
1230
|
+
},
|
|
1231
|
+
enumerable: true,
|
|
1232
|
+
configurable: true
|
|
1233
|
+
});
|
|
1234
|
+
Object.defineProperty(ParagraphFormat.prototype, "tabs", {
|
|
1235
|
+
/**
|
|
1236
|
+
* Live DocIO-style tab-stop collection. Mutates the same storage as
|
|
1237
|
+
* {@link ParagraphFormat.tabStops}.
|
|
1238
|
+
*/
|
|
1239
|
+
get: function () {
|
|
1240
|
+
if (this.tabsCollection === undefined) {
|
|
1241
|
+
this.tabsCollection = new TabCollection(this);
|
|
1242
|
+
}
|
|
1243
|
+
return this.tabsCollection;
|
|
1244
|
+
},
|
|
1245
|
+
enumerable: true,
|
|
1246
|
+
configurable: true
|
|
1247
|
+
});
|
|
1248
|
+
Object.defineProperty(ParagraphFormat.prototype, "borders", {
|
|
1249
|
+
/**
|
|
1250
|
+
* Live paragraph borders (`w:pBdr`) facade — always a
|
|
1251
|
+
* {@link ParagraphBordersFace} (aggregate `borderType` / `color` /
|
|
1252
|
+
* `lineWidth` / `space`, plus `top` / `left` / `bottom` / `right` /
|
|
1253
|
+
* `horizontal` / `vertical`). Never `undefined` and never a plain bag.
|
|
1254
|
+
*
|
|
1255
|
+
* Whole-bag replace or clear: {@link ParagraphFormat.setBorders}.
|
|
1256
|
+
*/
|
|
1257
|
+
get: function () {
|
|
1258
|
+
if (this.bordersFace === undefined) {
|
|
1259
|
+
this.bordersFace = new ParagraphBordersFace(this);
|
|
1260
|
+
}
|
|
1261
|
+
return this.bordersFace;
|
|
1262
|
+
},
|
|
1263
|
+
enumerable: true,
|
|
1264
|
+
configurable: true
|
|
1265
|
+
});
|
|
1266
|
+
/**
|
|
1267
|
+
* Replace or clear the whole paragraph-borders bag (`w:pBdr`).
|
|
1268
|
+
* Pass `undefined` to clear authored borders. Per-edge edits use
|
|
1269
|
+
* {@link ParagraphFormat.borders}.
|
|
1270
|
+
*/
|
|
1271
|
+
ParagraphFormat.prototype.setBorders = function (value) {
|
|
1272
|
+
this.bordersValue = value;
|
|
1273
|
+
this.mutate();
|
|
1274
|
+
};
|
|
1275
|
+
/**
|
|
1276
|
+
* @private
|
|
1277
|
+
* Direct bag read for facades / serializers (avoids face getter recursion).
|
|
1278
|
+
*/
|
|
1279
|
+
ParagraphFormat.prototype.readBordersBag = function () {
|
|
1280
|
+
if (this.bordersValue !== undefined) {
|
|
1281
|
+
return this.bordersValue;
|
|
1282
|
+
}
|
|
1283
|
+
return this.effective('borders');
|
|
1284
|
+
};
|
|
1285
|
+
/**
|
|
1286
|
+
* @private
|
|
1287
|
+
*/
|
|
1288
|
+
ParagraphFormat.prototype.writeBordersBag = function (value) {
|
|
1289
|
+
this.bordersValue = value;
|
|
1290
|
+
this.mutate();
|
|
1291
|
+
};
|
|
1292
|
+
Object.defineProperty(ParagraphFormat.prototype, "backColor", {
|
|
1293
|
+
/**
|
|
1294
|
+
* Background fill color (`w:shd/@w:fill`).
|
|
1295
|
+
*
|
|
1296
|
+
* - **Get (runtime)**: OOXML wire string — hex `RRGGBB`, `'auto'`, or the
|
|
1297
|
+
* default `''` when unset. Loaded wire values are preserved (never a
|
|
1298
|
+
* {@link Color} enum).
|
|
1299
|
+
* - **Set**: hex string / `'auto'`, a {@link Color} enum value (converted to
|
|
1300
|
+
* hex immediately), or `undefined` to clear the authored fill.
|
|
1301
|
+
*
|
|
1302
|
+
* TypeScript 3.3 requires identical get/set types, so the declared type is
|
|
1303
|
+
* `string | Color | undefined`; the getter always returns a string.
|
|
1304
|
+
*/
|
|
1305
|
+
get: function () {
|
|
1306
|
+
if (this.shadingValue !== undefined && this.shadingValue.fill !== undefined) {
|
|
1307
|
+
return this.shadingValue.fill;
|
|
1308
|
+
}
|
|
1309
|
+
return this.effectiveOrDefault('backColor', PARAGRAPH_FORMAT_DEFAULTS.backColor);
|
|
1310
|
+
},
|
|
1311
|
+
set: function (value) {
|
|
1312
|
+
var shading = this.shadingValue === undefined ? {} : __assign({}, this.shadingValue);
|
|
1313
|
+
if (value === undefined) {
|
|
1314
|
+
shading.fill = undefined;
|
|
1315
|
+
}
|
|
1316
|
+
else {
|
|
1317
|
+
var wire = shadingColorToWire(value);
|
|
1318
|
+
validateHexColor('backColor', wire);
|
|
1319
|
+
shading.fill = wire;
|
|
1320
|
+
}
|
|
1321
|
+
this.shadingValue = shadingHasEntries(shading) ? shading : undefined;
|
|
1322
|
+
this.mutate();
|
|
1323
|
+
},
|
|
1324
|
+
enumerable: true,
|
|
1325
|
+
configurable: true
|
|
1326
|
+
});
|
|
1327
|
+
Object.defineProperty(ParagraphFormat.prototype, "foreColor", {
|
|
1328
|
+
/**
|
|
1329
|
+
* Pattern foreground color (`w:shd/@w:color`).
|
|
1330
|
+
*
|
|
1331
|
+
* - **Get (runtime)**: OOXML wire string — hex `RRGGBB`, `'auto'`, or the
|
|
1332
|
+
* default `''` when unset. Loaded wire values are preserved (never a
|
|
1333
|
+
* {@link Color} enum).
|
|
1334
|
+
* - **Set**: hex string / `'auto'`, a {@link Color} enum value (converted to
|
|
1335
|
+
* hex immediately), or `undefined` to clear.
|
|
1336
|
+
*
|
|
1337
|
+
* TypeScript 3.3 requires identical get/set types, so the declared type is
|
|
1338
|
+
* `string | Color | undefined`; the getter always returns a string.
|
|
1339
|
+
*/
|
|
1340
|
+
get: function () {
|
|
1341
|
+
if (this.shadingValue !== undefined && this.shadingValue.color !== undefined) {
|
|
1342
|
+
return this.shadingValue.color;
|
|
1343
|
+
}
|
|
1344
|
+
return this.effectiveOrDefault('foreColor', PARAGRAPH_FORMAT_DEFAULTS.foreColor);
|
|
1345
|
+
},
|
|
1346
|
+
set: function (value) {
|
|
1347
|
+
var shading = this.shadingValue === undefined ? {} : __assign({}, this.shadingValue);
|
|
1348
|
+
if (value === undefined) {
|
|
1349
|
+
shading.color = undefined;
|
|
1350
|
+
}
|
|
1351
|
+
else {
|
|
1352
|
+
var wire = shadingColorToWire(value);
|
|
1353
|
+
validateHexColor('foreColor', wire);
|
|
1354
|
+
shading.color = wire;
|
|
1355
|
+
}
|
|
1356
|
+
this.shadingValue = shadingHasEntries(shading) ? shading : undefined;
|
|
1357
|
+
this.mutate();
|
|
1358
|
+
},
|
|
1359
|
+
enumerable: true,
|
|
1360
|
+
configurable: true
|
|
1361
|
+
});
|
|
1362
|
+
Object.defineProperty(ParagraphFormat.prototype, "shadingPattern", {
|
|
1363
|
+
/**
|
|
1364
|
+
* Shading pattern (`w:shd/@w:val`). Authoring an out-of-subset token
|
|
1365
|
+
* throws `DocxError('content/invalid-shading-pattern', …)`; unknown
|
|
1366
|
+
* loaded tokens round-trip via the parked-element path (never throw).
|
|
1367
|
+
*/
|
|
1368
|
+
get: function () {
|
|
1369
|
+
if (this.shadingValue !== undefined && this.shadingValue.pattern !== undefined) {
|
|
1370
|
+
return this.shadingValue.pattern;
|
|
1371
|
+
}
|
|
1372
|
+
return this.effective('shadingPattern');
|
|
1373
|
+
},
|
|
1374
|
+
set: function (value) {
|
|
1375
|
+
var shading = this.shadingValue === undefined ? {} : __assign({}, this.shadingValue);
|
|
1376
|
+
if (value === undefined) {
|
|
1377
|
+
shading.pattern = undefined;
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
if (!SHADING_PATTERNS.has(value)) {
|
|
1381
|
+
throw new DocxError('content/invalid-shading-pattern', 'shadingPattern must be an ST_Shd pattern token, got "' + value + '"');
|
|
1382
|
+
}
|
|
1383
|
+
shading.pattern = value;
|
|
1384
|
+
}
|
|
1385
|
+
this.shadingValue = shadingHasEntries(shading) ? shading : undefined;
|
|
1386
|
+
this.mutate();
|
|
1387
|
+
},
|
|
1388
|
+
enumerable: true,
|
|
1389
|
+
configurable: true
|
|
1390
|
+
});
|
|
1391
|
+
Object.defineProperty(ParagraphFormat.prototype, "suppressAutoHyphens", {
|
|
1392
|
+
// ---- Group A: misc on/off flags ----
|
|
1393
|
+
/**
|
|
1394
|
+
* Suppress automatic hyphenation for this paragraph
|
|
1395
|
+
* (`w:suppressAutoHyphens`, ECMA-376-1 §17.3.1.34 — the only
|
|
1396
|
+
* hyphenation element; ADR D5). Foreign `w:suppressHyphenation` markup
|
|
1397
|
+
* (not an ECMA-376 element) parks verbatim in `pPrExtra`.
|
|
1398
|
+
*/
|
|
1399
|
+
get: function () {
|
|
1400
|
+
if (this.suppressAutoHyphensValue !== undefined) {
|
|
1401
|
+
return this.suppressAutoHyphensValue;
|
|
1402
|
+
}
|
|
1403
|
+
return this.effectiveOrDefault('suppressAutoHyphens', PARAGRAPH_FORMAT_DEFAULTS.suppressAutoHyphens);
|
|
1404
|
+
},
|
|
1405
|
+
set: function (value) {
|
|
1406
|
+
this.suppressAutoHyphensValue = value;
|
|
1407
|
+
this.mutate();
|
|
1408
|
+
},
|
|
1409
|
+
enumerable: true,
|
|
1410
|
+
configurable: true
|
|
1411
|
+
});
|
|
1412
|
+
Object.defineProperty(ParagraphFormat.prototype, "suppressLineNumbers", {
|
|
1413
|
+
/** Exclude this paragraph from line numbering (`w:suppressLineNumbers`). */
|
|
1414
|
+
get: function () {
|
|
1415
|
+
if (this.suppressLineNumbersValue !== undefined) {
|
|
1416
|
+
return this.suppressLineNumbersValue;
|
|
1417
|
+
}
|
|
1418
|
+
return this.effectiveOrDefault('suppressLineNumbers', PARAGRAPH_FORMAT_DEFAULTS.suppressLineNumbers);
|
|
1419
|
+
},
|
|
1420
|
+
set: function (value) {
|
|
1421
|
+
this.suppressLineNumbersValue = value;
|
|
1422
|
+
this.mutate();
|
|
1423
|
+
},
|
|
1424
|
+
enumerable: true,
|
|
1425
|
+
configurable: true
|
|
1426
|
+
});
|
|
1427
|
+
Object.defineProperty(ParagraphFormat.prototype, "contextualSpacing", {
|
|
1428
|
+
/** Ignore before/after spacing between same-style paragraphs (`w:contextualSpacing`). */
|
|
1429
|
+
get: function () {
|
|
1430
|
+
if (this.contextualSpacingValue !== undefined) {
|
|
1431
|
+
return this.contextualSpacingValue;
|
|
1432
|
+
}
|
|
1433
|
+
return this.effectiveOrDefault('contextualSpacing', PARAGRAPH_FORMAT_DEFAULTS.contextualSpacing);
|
|
1434
|
+
},
|
|
1435
|
+
set: function (value) {
|
|
1436
|
+
this.contextualSpacingValue = value;
|
|
1437
|
+
this.mutate();
|
|
1438
|
+
},
|
|
1439
|
+
enumerable: true,
|
|
1440
|
+
configurable: true
|
|
1441
|
+
});
|
|
1442
|
+
Object.defineProperty(ParagraphFormat.prototype, "mirrorIndents", {
|
|
1443
|
+
/** Treat left/right indents as inside/outside for mirrored margins (`w:mirrorIndents`). */
|
|
1444
|
+
get: function () {
|
|
1445
|
+
if (this.mirrorIndentsValue !== undefined) {
|
|
1446
|
+
return this.mirrorIndentsValue;
|
|
1447
|
+
}
|
|
1448
|
+
return this.effectiveOrDefault('mirrorIndents', PARAGRAPH_FORMAT_DEFAULTS.mirrorIndents);
|
|
1449
|
+
},
|
|
1450
|
+
set: function (value) {
|
|
1451
|
+
this.mirrorIndentsValue = value;
|
|
1452
|
+
this.mutate();
|
|
1453
|
+
},
|
|
1454
|
+
enumerable: true,
|
|
1455
|
+
configurable: true
|
|
1456
|
+
});
|
|
1457
|
+
Object.defineProperty(ParagraphFormat.prototype, "adjustRightIndent", {
|
|
1458
|
+
/** Auto-adjust right indent against the document grid (`w:adjustRightInd`). */
|
|
1459
|
+
get: function () {
|
|
1460
|
+
if (this.adjustRightIndentValue !== undefined) {
|
|
1461
|
+
return this.adjustRightIndentValue;
|
|
1462
|
+
}
|
|
1463
|
+
return this.effectiveOrDefault('adjustRightIndent', PARAGRAPH_FORMAT_DEFAULTS.adjustRightIndent);
|
|
1464
|
+
},
|
|
1465
|
+
set: function (value) {
|
|
1466
|
+
this.adjustRightIndentValue = value;
|
|
1467
|
+
this.mutate();
|
|
1468
|
+
},
|
|
1469
|
+
enumerable: true,
|
|
1470
|
+
configurable: true
|
|
1471
|
+
});
|
|
1472
|
+
Object.defineProperty(ParagraphFormat.prototype, "textDirection", {
|
|
1473
|
+
// ---- Group A: text direction (§15; ADR D11: 12 tokens) ----
|
|
1474
|
+
/**
|
|
1475
|
+
* Physical text flow direction (`w:textDirection`,
|
|
1476
|
+
* `ST_TextDirection` — all 12 tokens). Unknown loaded tokens round-trip
|
|
1477
|
+
* verbatim (raw slot) and the getter returns `undefined` for them;
|
|
1478
|
+
* authoring an invalid token throws
|
|
1479
|
+
* `DocxError('content/invalid-text-direction', …)`.
|
|
1480
|
+
*/
|
|
1481
|
+
get: function () {
|
|
1482
|
+
if (this.textDirectionValue !== undefined) {
|
|
1483
|
+
return this.textDirectionValue;
|
|
1484
|
+
}
|
|
1485
|
+
return this.effective('textDirection');
|
|
1486
|
+
},
|
|
1487
|
+
set: function (value) {
|
|
1488
|
+
if (value === undefined) {
|
|
1489
|
+
this.textDirectionValue = undefined;
|
|
1490
|
+
this.textDirectionRaw = undefined;
|
|
1491
|
+
this.mutate();
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
if (!TEXT_DIRECTIONS.has(value)) {
|
|
1495
|
+
throw new DocxError('content/invalid-text-direction', 'textDirection must be an ST_TextDirection token, got "' + value + '"');
|
|
1496
|
+
}
|
|
1497
|
+
this.textDirectionValue = value;
|
|
1498
|
+
this.textDirectionRaw = undefined;
|
|
1499
|
+
this.mutate();
|
|
1500
|
+
},
|
|
1501
|
+
enumerable: true,
|
|
1502
|
+
configurable: true
|
|
1503
|
+
});
|
|
1504
|
+
Object.defineProperty(ParagraphFormat.prototype, "baselineAlignment", {
|
|
1505
|
+
// ---- Group B: baseline alignment (§16; ADR D6) ----
|
|
1506
|
+
/**
|
|
1507
|
+
* How characters of different sizes align vertically on a line
|
|
1508
|
+
* (`w:textAlignment`, `ST_TextAlignment`). Unknown loaded tokens
|
|
1509
|
+
* round-trip verbatim and the getter returns `undefined` for them;
|
|
1510
|
+
* authoring an invalid token throws
|
|
1511
|
+
* `DocxError('content/invalid-baseline-alignment', …)`.
|
|
1512
|
+
*/
|
|
1513
|
+
get: function () {
|
|
1514
|
+
if (this.baselineAlignmentValue !== undefined) {
|
|
1515
|
+
return this.baselineAlignmentValue;
|
|
1516
|
+
}
|
|
1517
|
+
return this.effective('baselineAlignment');
|
|
1518
|
+
},
|
|
1519
|
+
set: function (value) {
|
|
1520
|
+
if (value === undefined) {
|
|
1521
|
+
this.baselineAlignmentValue = undefined;
|
|
1522
|
+
this.baselineAlignmentRaw = undefined;
|
|
1523
|
+
this.mutate();
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
if (!BASELINE_ALIGNMENTS.has(value)) {
|
|
1527
|
+
throw new DocxError('content/invalid-baseline-alignment', 'baselineAlignment must be an ST_TextAlignment token, got "' + value + '"');
|
|
1528
|
+
}
|
|
1529
|
+
this.baselineAlignmentValue = value;
|
|
1530
|
+
this.baselineAlignmentRaw = undefined;
|
|
1531
|
+
this.mutate();
|
|
1532
|
+
},
|
|
1533
|
+
enumerable: true,
|
|
1534
|
+
configurable: true
|
|
1535
|
+
});
|
|
1536
|
+
Object.defineProperty(ParagraphFormat.prototype, "snapToGrid", {
|
|
1537
|
+
// ---- Group B: East-Asian / grid flags ----
|
|
1538
|
+
/** Use document grid line pitch (`w:snapToGrid`). */
|
|
1539
|
+
get: function () {
|
|
1540
|
+
if (this.snapToGridValue !== undefined) {
|
|
1541
|
+
return this.snapToGridValue;
|
|
1542
|
+
}
|
|
1543
|
+
return this.effectiveOrDefault('snapToGrid', PARAGRAPH_FORMAT_DEFAULTS.snapToGrid);
|
|
1544
|
+
},
|
|
1545
|
+
set: function (value) {
|
|
1546
|
+
this.snapToGridValue = value;
|
|
1547
|
+
this.mutate();
|
|
1548
|
+
},
|
|
1549
|
+
enumerable: true,
|
|
1550
|
+
configurable: true
|
|
1551
|
+
});
|
|
1552
|
+
Object.defineProperty(ParagraphFormat.prototype, "wordWrap", {
|
|
1553
|
+
/** Break lines on word level (`w:wordWrap`). */
|
|
1554
|
+
get: function () {
|
|
1555
|
+
if (this.wordWrapValue !== undefined) {
|
|
1556
|
+
return this.wordWrapValue;
|
|
1557
|
+
}
|
|
1558
|
+
return this.effectiveOrDefault('wordWrap', PARAGRAPH_FORMAT_DEFAULTS.wordWrap);
|
|
1559
|
+
},
|
|
1560
|
+
set: function (value) {
|
|
1561
|
+
this.wordWrapValue = value;
|
|
1562
|
+
this.mutate();
|
|
1563
|
+
},
|
|
1564
|
+
enumerable: true,
|
|
1565
|
+
configurable: true
|
|
1566
|
+
});
|
|
1567
|
+
Object.defineProperty(ParagraphFormat.prototype, "overflowPunctuation", {
|
|
1568
|
+
/** Allow trailing punctuation to extend beyond the line (`w:overflowPunct`). */
|
|
1569
|
+
get: function () {
|
|
1570
|
+
if (this.overflowPunctuationValue !== undefined) {
|
|
1571
|
+
return this.overflowPunctuationValue;
|
|
1572
|
+
}
|
|
1573
|
+
return this.effectiveOrDefault('overflowPunctuation', PARAGRAPH_FORMAT_DEFAULTS.overflowPunctuation);
|
|
1574
|
+
},
|
|
1575
|
+
set: function (value) {
|
|
1576
|
+
this.overflowPunctuationValue = value;
|
|
1577
|
+
this.mutate();
|
|
1578
|
+
},
|
|
1579
|
+
enumerable: true,
|
|
1580
|
+
configurable: true
|
|
1581
|
+
});
|
|
1582
|
+
Object.defineProperty(ParagraphFormat.prototype, "autoSpaceDE", {
|
|
1583
|
+
/** Auto space between East-Asian and Latin text (`w:autoSpaceDE`). */
|
|
1584
|
+
get: function () {
|
|
1585
|
+
if (this.autoSpaceDEValue !== undefined) {
|
|
1586
|
+
return this.autoSpaceDEValue;
|
|
1587
|
+
}
|
|
1588
|
+
return this.effectiveOrDefault('autoSpaceDE', PARAGRAPH_FORMAT_DEFAULTS.autoSpaceDE);
|
|
1589
|
+
},
|
|
1590
|
+
set: function (value) {
|
|
1591
|
+
this.autoSpaceDEValue = value;
|
|
1592
|
+
this.mutate();
|
|
1593
|
+
},
|
|
1594
|
+
enumerable: true,
|
|
1595
|
+
configurable: true
|
|
1596
|
+
});
|
|
1597
|
+
Object.defineProperty(ParagraphFormat.prototype, "autoSpaceDN", {
|
|
1598
|
+
/** Auto space between East-Asian text and numbers (`w:autoSpaceDN`). */
|
|
1599
|
+
get: function () {
|
|
1600
|
+
if (this.autoSpaceDNValue !== undefined) {
|
|
1601
|
+
return this.autoSpaceDNValue;
|
|
1602
|
+
}
|
|
1603
|
+
return this.effectiveOrDefault('autoSpaceDN', PARAGRAPH_FORMAT_DEFAULTS.autoSpaceDN);
|
|
1604
|
+
},
|
|
1605
|
+
set: function (value) {
|
|
1606
|
+
this.autoSpaceDNValue = value;
|
|
1607
|
+
this.mutate();
|
|
1608
|
+
},
|
|
1609
|
+
enumerable: true,
|
|
1610
|
+
configurable: true
|
|
1611
|
+
});
|
|
1612
|
+
Object.defineProperty(ParagraphFormat.prototype, "kinsoku", {
|
|
1613
|
+
// ---- Group B: internal round-trip members (@private) ----
|
|
1614
|
+
/**
|
|
1615
|
+
* @private
|
|
1616
|
+
* `w:kinsoku` — East-Asian line-breaking rules (round-trip only).
|
|
1617
|
+
*/
|
|
1618
|
+
get: function () {
|
|
1619
|
+
return this.kinsokuValue;
|
|
1620
|
+
},
|
|
1621
|
+
/** @private */
|
|
1622
|
+
set: function (value) {
|
|
1623
|
+
this.kinsokuValue = value;
|
|
1624
|
+
this.mutate();
|
|
1625
|
+
},
|
|
1626
|
+
enumerable: true,
|
|
1627
|
+
configurable: true
|
|
1628
|
+
});
|
|
1629
|
+
Object.defineProperty(ParagraphFormat.prototype, "topLinePunctuation", {
|
|
1630
|
+
/**
|
|
1631
|
+
* @private
|
|
1632
|
+
* `w:topLinePunct` — punctuation at line start preference (round-trip only).
|
|
1633
|
+
*/
|
|
1634
|
+
get: function () {
|
|
1635
|
+
return this.topLinePunctuationValue;
|
|
1636
|
+
},
|
|
1637
|
+
/** @private */
|
|
1638
|
+
set: function (value) {
|
|
1639
|
+
this.topLinePunctuationValue = value;
|
|
1640
|
+
this.mutate();
|
|
1641
|
+
},
|
|
1642
|
+
enumerable: true,
|
|
1643
|
+
configurable: true
|
|
1644
|
+
});
|
|
1645
|
+
/**
|
|
1646
|
+
* @private
|
|
1647
|
+
* Raw loaded `w:textDirection/@w:val` for tokens outside the public union.
|
|
1648
|
+
*/
|
|
1649
|
+
ParagraphFormat.prototype.textDirectionRawValue = function () {
|
|
1650
|
+
return this.textDirectionRaw;
|
|
1651
|
+
};
|
|
1652
|
+
/**
|
|
1653
|
+
* @private
|
|
1654
|
+
* Raw loaded `w:textAlignment/@w:val` for tokens outside the public union.
|
|
1655
|
+
*/
|
|
1656
|
+
ParagraphFormat.prototype.baselineAlignmentRawValue = function () {
|
|
1657
|
+
return this.baselineAlignmentRaw;
|
|
1658
|
+
};
|
|
1659
|
+
// ---- Lifecycle ----
|
|
1660
|
+
/**
|
|
1661
|
+
* Apply a partial delta. Uses setters — cross-property effects
|
|
1662
|
+
* (autospacing clearing, mutual line-slot clearing) apply.
|
|
1663
|
+
* @public
|
|
1664
|
+
*/
|
|
1665
|
+
ParagraphFormat.prototype.assign = function (delta) {
|
|
1666
|
+
if (delta.horizontalAlignment !== undefined) {
|
|
1667
|
+
this.horizontalAlignment = delta.horizontalAlignment;
|
|
1668
|
+
}
|
|
1669
|
+
if (delta.keepFollow !== undefined) {
|
|
1670
|
+
this.keepFollow = delta.keepFollow;
|
|
1671
|
+
}
|
|
1672
|
+
if (delta.keepLines !== undefined) {
|
|
1673
|
+
this.keepLines = delta.keepLines;
|
|
1674
|
+
}
|
|
1675
|
+
if (delta.pageBreakBefore !== undefined) {
|
|
1676
|
+
this.pageBreakBefore = delta.pageBreakBefore;
|
|
1677
|
+
}
|
|
1678
|
+
if (delta.pageBreakAfter !== undefined) {
|
|
1679
|
+
this.pageBreakAfter = delta.pageBreakAfter;
|
|
1680
|
+
}
|
|
1681
|
+
if (delta.widowControl !== undefined) {
|
|
1682
|
+
this.widowControl = delta.widowControl;
|
|
1683
|
+
}
|
|
1684
|
+
if (delta.bidi !== undefined) {
|
|
1685
|
+
this.bidi = delta.bidi;
|
|
1686
|
+
}
|
|
1687
|
+
if (delta.outlineLevel !== undefined) {
|
|
1688
|
+
this.outlineLevel = delta.outlineLevel;
|
|
1689
|
+
}
|
|
1690
|
+
if (delta.leftIndent !== undefined) {
|
|
1691
|
+
this.leftIndent = delta.leftIndent;
|
|
1692
|
+
}
|
|
1693
|
+
if (delta.rightIndent !== undefined) {
|
|
1694
|
+
this.rightIndent = delta.rightIndent;
|
|
1695
|
+
}
|
|
1696
|
+
if (delta.firstLineIndent !== undefined) {
|
|
1697
|
+
this.firstLineIndent = delta.firstLineIndent;
|
|
1698
|
+
}
|
|
1699
|
+
if (delta.beforeSpacing !== undefined) {
|
|
1700
|
+
this.beforeSpacing = delta.beforeSpacing;
|
|
1701
|
+
}
|
|
1702
|
+
if (delta.afterSpacing !== undefined) {
|
|
1703
|
+
this.afterSpacing = delta.afterSpacing;
|
|
1704
|
+
}
|
|
1705
|
+
if (delta.beforeAutospacing !== undefined) {
|
|
1706
|
+
this.beforeAutospacing = delta.beforeAutospacing;
|
|
1707
|
+
}
|
|
1708
|
+
if (delta.afterAutospacing !== undefined) {
|
|
1709
|
+
this.afterAutospacing = delta.afterAutospacing;
|
|
1710
|
+
}
|
|
1711
|
+
if (delta.beforeLines !== undefined) {
|
|
1712
|
+
this.beforeLines = delta.beforeLines;
|
|
1713
|
+
}
|
|
1714
|
+
if (delta.afterLines !== undefined) {
|
|
1715
|
+
this.afterLines = delta.afterLines;
|
|
1716
|
+
}
|
|
1717
|
+
if (delta.lineSpacing !== undefined) {
|
|
1718
|
+
this.lineSpacing = delta.lineSpacing;
|
|
1719
|
+
}
|
|
1720
|
+
if (delta.lineSpacingRule !== undefined) {
|
|
1721
|
+
this.lineSpacingRule = delta.lineSpacingRule;
|
|
1722
|
+
}
|
|
1723
|
+
if (delta.lineSpacingCount !== undefined) {
|
|
1724
|
+
this.lineSpacingCount = delta.lineSpacingCount;
|
|
1725
|
+
}
|
|
1726
|
+
if (delta.tabStops !== undefined) {
|
|
1727
|
+
this.tabStops = delta.tabStops;
|
|
1728
|
+
}
|
|
1729
|
+
if (delta.borders !== undefined) {
|
|
1730
|
+
this.setBorders(delta.borders);
|
|
1731
|
+
}
|
|
1732
|
+
if (delta.backColor !== undefined) {
|
|
1733
|
+
this.backColor = delta.backColor;
|
|
1734
|
+
}
|
|
1735
|
+
if (delta.foreColor !== undefined) {
|
|
1736
|
+
this.foreColor = delta.foreColor;
|
|
1737
|
+
}
|
|
1738
|
+
if (delta.shadingPattern !== undefined) {
|
|
1739
|
+
this.shadingPattern = delta.shadingPattern;
|
|
1740
|
+
}
|
|
1741
|
+
if (delta.suppressAutoHyphens !== undefined) {
|
|
1742
|
+
this.suppressAutoHyphens = delta.suppressAutoHyphens;
|
|
1743
|
+
}
|
|
1744
|
+
if (delta.suppressLineNumbers !== undefined) {
|
|
1745
|
+
this.suppressLineNumbers = delta.suppressLineNumbers;
|
|
1746
|
+
}
|
|
1747
|
+
if (delta.contextualSpacing !== undefined) {
|
|
1748
|
+
this.contextualSpacing = delta.contextualSpacing;
|
|
1749
|
+
}
|
|
1750
|
+
if (delta.mirrorIndents !== undefined) {
|
|
1751
|
+
this.mirrorIndents = delta.mirrorIndents;
|
|
1752
|
+
}
|
|
1753
|
+
if (delta.adjustRightIndent !== undefined) {
|
|
1754
|
+
this.adjustRightIndent = delta.adjustRightIndent;
|
|
1755
|
+
}
|
|
1756
|
+
if (delta.textDirection !== undefined) {
|
|
1757
|
+
this.textDirection = delta.textDirection;
|
|
1758
|
+
}
|
|
1759
|
+
if (delta.baselineAlignment !== undefined) {
|
|
1760
|
+
this.baselineAlignment = delta.baselineAlignment;
|
|
1761
|
+
}
|
|
1762
|
+
if (delta.snapToGrid !== undefined) {
|
|
1763
|
+
this.snapToGrid = delta.snapToGrid;
|
|
1764
|
+
}
|
|
1765
|
+
if (delta.wordWrap !== undefined) {
|
|
1766
|
+
this.wordWrap = delta.wordWrap;
|
|
1767
|
+
}
|
|
1768
|
+
if (delta.overflowPunctuation !== undefined) {
|
|
1769
|
+
this.overflowPunctuation = delta.overflowPunctuation;
|
|
1770
|
+
}
|
|
1771
|
+
if (delta.autoSpaceDE !== undefined) {
|
|
1772
|
+
this.autoSpaceDE = delta.autoSpaceDE;
|
|
1773
|
+
}
|
|
1774
|
+
if (delta.autoSpaceDN !== undefined) {
|
|
1775
|
+
this.autoSpaceDN = delta.autoSpaceDN;
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
/**
|
|
1779
|
+
* Clear all typed formatting. Does not clear `pPrExtra`.
|
|
1780
|
+
* @public
|
|
1781
|
+
*/
|
|
1782
|
+
ParagraphFormat.prototype.clear = function () {
|
|
1783
|
+
this.jcRaw = undefined;
|
|
1784
|
+
this.keepNextValue = undefined;
|
|
1785
|
+
this.keepLinesValue = undefined;
|
|
1786
|
+
this.pageBreakBeforeValue = undefined;
|
|
1787
|
+
this.pageBreakAfterValue = undefined;
|
|
1788
|
+
this.widowControlValue = undefined;
|
|
1789
|
+
this.bidiValue = undefined;
|
|
1790
|
+
this.outlineLevelValue = undefined;
|
|
1791
|
+
this.indentsValue = undefined;
|
|
1792
|
+
this.spacingValue = undefined;
|
|
1793
|
+
this.tabStopsValue = undefined;
|
|
1794
|
+
this.bordersValue = undefined;
|
|
1795
|
+
this.shadingValue = undefined;
|
|
1796
|
+
this.suppressAutoHyphensValue = undefined;
|
|
1797
|
+
this.suppressLineNumbersValue = undefined;
|
|
1798
|
+
this.contextualSpacingValue = undefined;
|
|
1799
|
+
this.mirrorIndentsValue = undefined;
|
|
1800
|
+
this.adjustRightIndentValue = undefined;
|
|
1801
|
+
this.textDirectionValue = undefined;
|
|
1802
|
+
this.textDirectionRaw = undefined;
|
|
1803
|
+
this.baselineAlignmentValue = undefined;
|
|
1804
|
+
this.baselineAlignmentRaw = undefined;
|
|
1805
|
+
this.snapToGridValue = undefined;
|
|
1806
|
+
this.wordWrapValue = undefined;
|
|
1807
|
+
this.overflowPunctuationValue = undefined;
|
|
1808
|
+
this.autoSpaceDEValue = undefined;
|
|
1809
|
+
this.autoSpaceDNValue = undefined;
|
|
1810
|
+
this.kinsokuValue = undefined;
|
|
1811
|
+
this.topLinePunctuationValue = undefined;
|
|
1812
|
+
this.mutate();
|
|
1813
|
+
};
|
|
1814
|
+
/**
|
|
1815
|
+
* @private
|
|
1816
|
+
* Load a snapshot without set-path cross-property effects.
|
|
1817
|
+
*/
|
|
1818
|
+
ParagraphFormat.prototype.hydrate = function (data) {
|
|
1819
|
+
this.pPrExtra = data.pPrExtra;
|
|
1820
|
+
this.jcRaw = data.jcRaw;
|
|
1821
|
+
this.keepNextValue = data.keepNextValue;
|
|
1822
|
+
this.keepLinesValue = data.keepLinesValue;
|
|
1823
|
+
this.pageBreakAfterValue = data.pageBreakAfterValue;
|
|
1824
|
+
this.pageBreakBeforeValue = data.pageBreakBeforeValue;
|
|
1825
|
+
this.widowControlValue = data.widowControlValue;
|
|
1826
|
+
this.bidiValue = data.bidiValue;
|
|
1827
|
+
this.outlineLevelValue = data.outlineLevelValue;
|
|
1828
|
+
this.indentsValue = data.indentsValue;
|
|
1829
|
+
this.spacingValue = data.spacingValue;
|
|
1830
|
+
this.tabStopsValue = data.tabStopsValue;
|
|
1831
|
+
this.bordersValue = data.bordersValue;
|
|
1832
|
+
this.shadingValue = data.shadingValue;
|
|
1833
|
+
this.suppressAutoHyphensValue = data.suppressAutoHyphensValue;
|
|
1834
|
+
this.suppressLineNumbersValue = data.suppressLineNumbersValue;
|
|
1835
|
+
this.contextualSpacingValue = data.contextualSpacingValue;
|
|
1836
|
+
this.mirrorIndentsValue = data.mirrorIndentsValue;
|
|
1837
|
+
this.adjustRightIndentValue = data.adjustRightIndentValue;
|
|
1838
|
+
this.textDirectionValue = data.textDirectionValue;
|
|
1839
|
+
this.textDirectionRaw = data.textDirectionRaw;
|
|
1840
|
+
this.baselineAlignmentValue = data.baselineAlignmentValue;
|
|
1841
|
+
this.baselineAlignmentRaw = data.baselineAlignmentRaw;
|
|
1842
|
+
this.snapToGridValue = data.snapToGridValue;
|
|
1843
|
+
this.wordWrapValue = data.wordWrapValue;
|
|
1844
|
+
this.overflowPunctuationValue = data.overflowPunctuationValue;
|
|
1845
|
+
this.autoSpaceDEValue = data.autoSpaceDEValue;
|
|
1846
|
+
this.autoSpaceDNValue = data.autoSpaceDNValue;
|
|
1847
|
+
this.kinsokuValue = data.kinsokuValue;
|
|
1848
|
+
this.topLinePunctuationValue = data.topLinePunctuationValue;
|
|
1849
|
+
};
|
|
1850
|
+
/**
|
|
1851
|
+
* @private
|
|
1852
|
+
*/
|
|
1853
|
+
ParagraphFormat.prototype.snapshot = function () {
|
|
1854
|
+
return {
|
|
1855
|
+
pPrExtra: this.pPrExtra,
|
|
1856
|
+
jcRaw: this.jcRaw,
|
|
1857
|
+
keepNextValue: this.keepNextValue,
|
|
1858
|
+
keepLinesValue: this.keepLinesValue,
|
|
1859
|
+
pageBreakAfterValue: this.pageBreakAfterValue,
|
|
1860
|
+
pageBreakBeforeValue: this.pageBreakBeforeValue,
|
|
1861
|
+
widowControlValue: this.widowControlValue,
|
|
1862
|
+
bidiValue: this.bidiValue,
|
|
1863
|
+
outlineLevelValue: this.outlineLevelValue,
|
|
1864
|
+
indentsValue: this.indentsValue,
|
|
1865
|
+
spacingValue: this.spacingValue,
|
|
1866
|
+
tabStopsValue: this.tabStopsValue,
|
|
1867
|
+
bordersValue: this.bordersValue,
|
|
1868
|
+
shadingValue: this.shadingValue,
|
|
1869
|
+
suppressAutoHyphensValue: this.suppressAutoHyphensValue,
|
|
1870
|
+
suppressLineNumbersValue: this.suppressLineNumbersValue,
|
|
1871
|
+
contextualSpacingValue: this.contextualSpacingValue,
|
|
1872
|
+
mirrorIndentsValue: this.mirrorIndentsValue,
|
|
1873
|
+
adjustRightIndentValue: this.adjustRightIndentValue,
|
|
1874
|
+
textDirectionValue: this.textDirectionValue,
|
|
1875
|
+
textDirectionRaw: this.textDirectionRaw,
|
|
1876
|
+
baselineAlignmentValue: this.baselineAlignmentValue,
|
|
1877
|
+
baselineAlignmentRaw: this.baselineAlignmentRaw,
|
|
1878
|
+
snapToGridValue: this.snapToGridValue,
|
|
1879
|
+
wordWrapValue: this.wordWrapValue,
|
|
1880
|
+
overflowPunctuationValue: this.overflowPunctuationValue,
|
|
1881
|
+
autoSpaceDEValue: this.autoSpaceDEValue,
|
|
1882
|
+
autoSpaceDNValue: this.autoSpaceDNValue,
|
|
1883
|
+
kinsokuValue: this.kinsokuValue,
|
|
1884
|
+
topLinePunctuationValue: this.topLinePunctuationValue,
|
|
1885
|
+
};
|
|
1886
|
+
};
|
|
1887
|
+
/**
|
|
1888
|
+
* @private
|
|
1889
|
+
* Parked children (`framePr`, `pPrChange`, unknowns, foreign invalid markup).
|
|
1890
|
+
* Mark `w:rPr` is owned by {@link Paragraph.breakCharacterFormat}, not parked here.
|
|
1891
|
+
* Read/write for the paragraph-owned serializer.
|
|
1892
|
+
*/
|
|
1893
|
+
ParagraphFormat.prototype.extraChildren = function () {
|
|
1894
|
+
return this.pPrExtra;
|
|
1895
|
+
};
|
|
1896
|
+
/**
|
|
1897
|
+
* @private
|
|
1898
|
+
* Paragraph conditional formatting membership (`w:pPr/w:cnfStyle`).
|
|
1899
|
+
*/
|
|
1900
|
+
ParagraphFormat.prototype.readCnfStyle = function () {
|
|
1901
|
+
for (var i = 0; i < this.pPrExtra.length; i += 1) {
|
|
1902
|
+
var child = this.pPrExtra[i];
|
|
1903
|
+
if (isWml(child, 'cnfStyle')) {
|
|
1904
|
+
var state = parseCnfStyle(child);
|
|
1905
|
+
return cnfStyleIsEmpty(state) ? undefined : state;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
return undefined;
|
|
1909
|
+
};
|
|
1910
|
+
/**
|
|
1911
|
+
* @private
|
|
1912
|
+
* Write or clear paragraph `w:cnfStyle` in parked extra children.
|
|
1913
|
+
* `undefined` removes the element; a supplied state always writes
|
|
1914
|
+
* (including all-false normalized form).
|
|
1915
|
+
*/
|
|
1916
|
+
ParagraphFormat.prototype.writeCnfStyle = function (state) {
|
|
1917
|
+
// Table updateConditionalFormatting may run before every paragraph is
|
|
1918
|
+
// body-attached; mutate only when the host is already bound.
|
|
1919
|
+
try {
|
|
1920
|
+
this.mutate();
|
|
1921
|
+
}
|
|
1922
|
+
catch (_e) {
|
|
1923
|
+
// Detached dual-hold: still update parked cnfStyle markup.
|
|
1924
|
+
}
|
|
1925
|
+
var existing;
|
|
1926
|
+
var existingIndex = -1;
|
|
1927
|
+
for (var i = 0; i < this.pPrExtra.length; i += 1) {
|
|
1928
|
+
var child = this.pPrExtra[i];
|
|
1929
|
+
if (isWml(child, 'cnfStyle')) {
|
|
1930
|
+
existing = child;
|
|
1931
|
+
existingIndex = i;
|
|
1932
|
+
break;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
if (state === undefined) {
|
|
1936
|
+
if (existingIndex >= 0) {
|
|
1937
|
+
this.pPrExtra.splice(existingIndex, 1);
|
|
1938
|
+
}
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
var written = serializeCnfStyle(normalizeCnfStyle(state), existing);
|
|
1942
|
+
if (existingIndex >= 0) {
|
|
1943
|
+
this.pPrExtra[existingIndex] = written;
|
|
1944
|
+
}
|
|
1945
|
+
else {
|
|
1946
|
+
this.pPrExtra.push(written);
|
|
1947
|
+
}
|
|
1948
|
+
};
|
|
1949
|
+
/**
|
|
1950
|
+
* @private
|
|
1951
|
+
* Materialize `w:pPr` children owned by this format (CT_PPrBase order).
|
|
1952
|
+
* Does not emit `pStyle` / `numPr` / `rPr` / `sectPr` — those stay on {@link Paragraph}.
|
|
1953
|
+
*/
|
|
1954
|
+
ParagraphFormat.prototype.buildPPrChildren = function (inject) {
|
|
1955
|
+
return buildPPrChildrenFromSnapshot(this.snapshot(), inject);
|
|
1956
|
+
};
|
|
1957
|
+
return ParagraphFormat;
|
|
1958
|
+
}());
|
|
1959
|
+
export { ParagraphFormat };
|
|
1960
|
+
/** @private `true` when the shading record carries any authored entry. */
|
|
1961
|
+
function shadingHasEntries(shading) {
|
|
1962
|
+
return shading.fill !== undefined
|
|
1963
|
+
|| shading.color !== undefined
|
|
1964
|
+
|| shading.pattern !== undefined;
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Modeled `w:pPr` children owned by {@link ParagraphFormat}.
|
|
1968
|
+
* `pStyle` / `numPr` / `sectPr` stay on {@link Paragraph}.
|
|
1969
|
+
* Foreign non-schema `suppressHyphenation` is NOT modeled (parked).
|
|
1970
|
+
* @private
|
|
1971
|
+
*/
|
|
1972
|
+
var MODELED_PPR = new Set([
|
|
1973
|
+
'keepNext',
|
|
1974
|
+
'keepLines',
|
|
1975
|
+
'pageBreakBefore',
|
|
1976
|
+
'widowControl',
|
|
1977
|
+
'bidi',
|
|
1978
|
+
'jc',
|
|
1979
|
+
'outlineLvl',
|
|
1980
|
+
'ind',
|
|
1981
|
+
'spacing',
|
|
1982
|
+
'tabs',
|
|
1983
|
+
'pBdr',
|
|
1984
|
+
'shd',
|
|
1985
|
+
'suppressLineNumbers',
|
|
1986
|
+
'suppressAutoHyphens',
|
|
1987
|
+
'contextualSpacing',
|
|
1988
|
+
'textDirection',
|
|
1989
|
+
'textAlignment',
|
|
1990
|
+
'adjustRightInd',
|
|
1991
|
+
'overflowPunct',
|
|
1992
|
+
'autoSpaceDE',
|
|
1993
|
+
'autoSpaceDN',
|
|
1994
|
+
'snapToGrid',
|
|
1995
|
+
'wordWrap',
|
|
1996
|
+
'mirrorIndents',
|
|
1997
|
+
'kinsoku',
|
|
1998
|
+
'topLinePunct',
|
|
1999
|
+
]);
|
|
2000
|
+
/**
|
|
2001
|
+
* Schema-known children that stay parked in `pPrExtra` (deferred features /
|
|
2002
|
+
* markup-compat). Drain into schema slots on serialize.
|
|
2003
|
+
* Mark `w:rPr` is owned by {@link Paragraph.breakCharacterFormat} (not parked).
|
|
2004
|
+
* @private
|
|
2005
|
+
*/
|
|
2006
|
+
var PPR_EXTRA_ONLY = new Set([
|
|
2007
|
+
'framePr',
|
|
2008
|
+
'suppressOverlap',
|
|
2009
|
+
'textboxTightWrap',
|
|
2010
|
+
'divId',
|
|
2011
|
+
'cnfStyle',
|
|
2012
|
+
'pPrChange',
|
|
2013
|
+
]);
|
|
2014
|
+
var TAB_ALIGNMENTS = new Set([
|
|
2015
|
+
'left',
|
|
2016
|
+
'center',
|
|
2017
|
+
'right',
|
|
2018
|
+
'decimal',
|
|
2019
|
+
'bar',
|
|
2020
|
+
'clear',
|
|
2021
|
+
'num',
|
|
2022
|
+
'start',
|
|
2023
|
+
'end',
|
|
2024
|
+
]);
|
|
2025
|
+
var TAB_LEADERS = new Set([
|
|
2026
|
+
'none',
|
|
2027
|
+
'dot',
|
|
2028
|
+
'heavy',
|
|
2029
|
+
'hyphen',
|
|
2030
|
+
'middleDot',
|
|
2031
|
+
'underscore',
|
|
2032
|
+
]);
|
|
2033
|
+
function parseDecimalVal(raw) {
|
|
2034
|
+
if (raw === undefined || !/^-?\d+$/.test(raw)) {
|
|
2035
|
+
return undefined;
|
|
2036
|
+
}
|
|
2037
|
+
return Number.parseInt(raw, 10);
|
|
2038
|
+
}
|
|
2039
|
+
function wmlAttrVal(el, localName) {
|
|
2040
|
+
var __ts33_0;
|
|
2041
|
+
return ((__ts33_0 = el.attributes.find(function (a) {
|
|
2042
|
+
return a.localName === localName && (a.prefix === 'w' || a.prefix === '');
|
|
2043
|
+
})), __ts33_0 == null ? undefined : __ts33_0.value);
|
|
2044
|
+
}
|
|
2045
|
+
function parseSignedTwipsAttr(el, attrName) {
|
|
2046
|
+
return parseDecimalVal(wmlAttrVal(el, attrName));
|
|
2047
|
+
}
|
|
2048
|
+
function parseNonNegTwipsAttr(el, attrName) {
|
|
2049
|
+
var n = parseDecimalVal(wmlAttrVal(el, attrName));
|
|
2050
|
+
if (n === undefined || n < 0) {
|
|
2051
|
+
return undefined;
|
|
2052
|
+
}
|
|
2053
|
+
return n;
|
|
2054
|
+
}
|
|
2055
|
+
function parseOnOffAttr(el, attrName) {
|
|
2056
|
+
var raw = wmlAttrVal(el, attrName);
|
|
2057
|
+
if (raw === '1' || raw === 'true') {
|
|
2058
|
+
return true;
|
|
2059
|
+
}
|
|
2060
|
+
if (raw === '0' || raw === 'false') {
|
|
2061
|
+
return false;
|
|
2062
|
+
}
|
|
2063
|
+
return undefined;
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Parse `w:ind` into a wire-twips {@link ParagraphIndentsRecord}.
|
|
2067
|
+
* Preserves `@start`/`@end`/`*Chars` for D2 round-trip.
|
|
2068
|
+
* @private
|
|
2069
|
+
*/
|
|
2070
|
+
export function parseIndentsRecord(el) {
|
|
2071
|
+
var ind = {};
|
|
2072
|
+
var left = parseSignedTwipsAttr(el, 'left');
|
|
2073
|
+
var right = parseSignedTwipsAttr(el, 'right');
|
|
2074
|
+
var firstLine = parseNonNegTwipsAttr(el, 'firstLine');
|
|
2075
|
+
var hanging = parseNonNegTwipsAttr(el, 'hanging');
|
|
2076
|
+
var start = parseSignedTwipsAttr(el, 'start');
|
|
2077
|
+
var end = parseSignedTwipsAttr(el, 'end');
|
|
2078
|
+
var leftChars = parseNonNegTwipsAttr(el, 'leftChars');
|
|
2079
|
+
var rightChars = parseNonNegTwipsAttr(el, 'rightChars');
|
|
2080
|
+
var firstLineChars = parseNonNegTwipsAttr(el, 'firstLineChars');
|
|
2081
|
+
var hangingChars = parseNonNegTwipsAttr(el, 'hangingChars');
|
|
2082
|
+
if (left !== undefined) {
|
|
2083
|
+
ind.left = left;
|
|
2084
|
+
}
|
|
2085
|
+
if (right !== undefined) {
|
|
2086
|
+
ind.right = right;
|
|
2087
|
+
}
|
|
2088
|
+
if (firstLine !== undefined) {
|
|
2089
|
+
ind.firstLine = firstLine;
|
|
2090
|
+
}
|
|
2091
|
+
if (hanging !== undefined) {
|
|
2092
|
+
ind.hanging = hanging;
|
|
2093
|
+
}
|
|
2094
|
+
if (start !== undefined) {
|
|
2095
|
+
ind.start = start;
|
|
2096
|
+
}
|
|
2097
|
+
if (end !== undefined) {
|
|
2098
|
+
ind.end = end;
|
|
2099
|
+
}
|
|
2100
|
+
if (leftChars !== undefined) {
|
|
2101
|
+
ind.leftChars = leftChars;
|
|
2102
|
+
}
|
|
2103
|
+
if (rightChars !== undefined) {
|
|
2104
|
+
ind.rightChars = rightChars;
|
|
2105
|
+
}
|
|
2106
|
+
if (firstLineChars !== undefined) {
|
|
2107
|
+
ind.firstLineChars = firstLineChars;
|
|
2108
|
+
}
|
|
2109
|
+
if (hangingChars !== undefined) {
|
|
2110
|
+
ind.hangingChars = hangingChars;
|
|
2111
|
+
}
|
|
2112
|
+
if (indentsRecordIsEmpty(ind)) {
|
|
2113
|
+
return undefined;
|
|
2114
|
+
}
|
|
2115
|
+
return ind;
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* Parse `w:spacing` into a wire-unit {@link ParagraphSpacingRecord}.
|
|
2119
|
+
* Preserves `@beforeLines`/`@afterLines` for round-trip.
|
|
2120
|
+
* @private
|
|
2121
|
+
*/
|
|
2122
|
+
export function parseSpacingRecord(el) {
|
|
2123
|
+
var sp = {};
|
|
2124
|
+
var before = parseNonNegTwipsAttr(el, 'before');
|
|
2125
|
+
var after = parseNonNegTwipsAttr(el, 'after');
|
|
2126
|
+
var line = parseNonNegTwipsAttr(el, 'line');
|
|
2127
|
+
var lineRuleRaw = wmlAttrVal(el, 'lineRule');
|
|
2128
|
+
var lineRule = lineRuleRaw === 'auto' || lineRuleRaw === 'exact' || lineRuleRaw === 'atLeast'
|
|
2129
|
+
? lineRuleRaw
|
|
2130
|
+
: undefined;
|
|
2131
|
+
var beforeAutospacing = parseOnOffAttr(el, 'beforeAutospacing');
|
|
2132
|
+
var afterAutospacing = parseOnOffAttr(el, 'afterAutospacing');
|
|
2133
|
+
var beforeLines = parseSignedTwipsAttr(el, 'beforeLines');
|
|
2134
|
+
var afterLines = parseSignedTwipsAttr(el, 'afterLines');
|
|
2135
|
+
if (before !== undefined) {
|
|
2136
|
+
sp.before = before;
|
|
2137
|
+
}
|
|
2138
|
+
if (after !== undefined) {
|
|
2139
|
+
sp.after = after;
|
|
2140
|
+
}
|
|
2141
|
+
if (line !== undefined) {
|
|
2142
|
+
sp.line = line;
|
|
2143
|
+
}
|
|
2144
|
+
if (lineRule !== undefined) {
|
|
2145
|
+
sp.lineRule = lineRule;
|
|
2146
|
+
}
|
|
2147
|
+
if (beforeAutospacing !== undefined) {
|
|
2148
|
+
sp.beforeAutospacing = beforeAutospacing;
|
|
2149
|
+
}
|
|
2150
|
+
if (afterAutospacing !== undefined) {
|
|
2151
|
+
sp.afterAutospacing = afterAutospacing;
|
|
2152
|
+
}
|
|
2153
|
+
if (beforeLines !== undefined) {
|
|
2154
|
+
sp.beforeLines = beforeLines;
|
|
2155
|
+
}
|
|
2156
|
+
if (afterLines !== undefined) {
|
|
2157
|
+
sp.afterLines = afterLines;
|
|
2158
|
+
}
|
|
2159
|
+
if (spacingRecordIsEmpty(sp)) {
|
|
2160
|
+
return undefined;
|
|
2161
|
+
}
|
|
2162
|
+
return sp;
|
|
2163
|
+
}
|
|
2164
|
+
function parseTabs(el) {
|
|
2165
|
+
var e_1, _a;
|
|
2166
|
+
var __ts33_1;
|
|
2167
|
+
var stops = [];
|
|
2168
|
+
try {
|
|
2169
|
+
for (var _b = __values(elementChildren(el)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2170
|
+
var child = _c.value;
|
|
2171
|
+
if (!isWml(child, 'tab')) {
|
|
2172
|
+
continue;
|
|
2173
|
+
}
|
|
2174
|
+
var posRaw = wmlAttrVal(child, 'pos');
|
|
2175
|
+
var n = parseDecimalVal(posRaw);
|
|
2176
|
+
if (n === undefined) {
|
|
2177
|
+
continue;
|
|
2178
|
+
}
|
|
2179
|
+
var val = ((__ts33_1 = wmlAttrVal(child, 'val')), __ts33_1 != null ? __ts33_1 : 'left');
|
|
2180
|
+
var alignment = TAB_ALIGNMENTS.has(val)
|
|
2181
|
+
? val
|
|
2182
|
+
: 'left';
|
|
2183
|
+
var leaderRaw = wmlAttrVal(child, 'leader');
|
|
2184
|
+
var leader = leaderRaw !== undefined && TAB_LEADERS.has(leaderRaw)
|
|
2185
|
+
? leaderRaw
|
|
2186
|
+
: undefined;
|
|
2187
|
+
stops.push(__assign({ position: twipsToPoint(n), alignment: alignment }, (leader !== undefined ? { leader: leader } : {})));
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2191
|
+
finally {
|
|
2192
|
+
try {
|
|
2193
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2194
|
+
}
|
|
2195
|
+
finally { if (e_1) throw e_1.error; }
|
|
2196
|
+
}
|
|
2197
|
+
return stops;
|
|
2198
|
+
}
|
|
2199
|
+
function parseBorderEdge(el) {
|
|
2200
|
+
var styleRaw = wmlAttrVal(el, 'val');
|
|
2201
|
+
if (styleRaw === undefined) {
|
|
2202
|
+
return undefined;
|
|
2203
|
+
}
|
|
2204
|
+
// Known tokens match BorderStyle (BORDER_STYLES is single-sourced from the
|
|
2205
|
+
// page-setup BorderStyle enum). Unknown loaded ST_Border values are still
|
|
2206
|
+
// stored so serialize can round-trip; load never throws (ADR D9).
|
|
2207
|
+
var style = BORDER_STYLES.has(styleRaw)
|
|
2208
|
+
? styleRaw
|
|
2209
|
+
: styleRaw;
|
|
2210
|
+
var colorRaw = wmlAttrVal(el, 'color');
|
|
2211
|
+
var szRaw = wmlAttrVal(el, 'sz');
|
|
2212
|
+
var sz = szRaw !== undefined ? parseDecimalVal(szRaw) : undefined;
|
|
2213
|
+
var spaceRaw = wmlAttrVal(el, 'space');
|
|
2214
|
+
var space = spaceRaw !== undefined ? parseDecimalVal(spaceRaw) : undefined;
|
|
2215
|
+
return __assign({ style: style }, (colorRaw !== undefined ? { color: colorRaw } : {}), (sz !== undefined ? { size: sz } : {}), (space !== undefined ? { space: space } : {}));
|
|
2216
|
+
}
|
|
2217
|
+
function parsePBdr(el) {
|
|
2218
|
+
var e_2, _a;
|
|
2219
|
+
var top;
|
|
2220
|
+
var left;
|
|
2221
|
+
var bottom;
|
|
2222
|
+
var right;
|
|
2223
|
+
var between;
|
|
2224
|
+
var bar;
|
|
2225
|
+
try {
|
|
2226
|
+
for (var _b = __values(elementChildren(el)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2227
|
+
var child = _c.value;
|
|
2228
|
+
if (!isWml(child, child.localName)) {
|
|
2229
|
+
continue;
|
|
2230
|
+
}
|
|
2231
|
+
var edge = parseBorderEdge(child);
|
|
2232
|
+
if (edge === undefined) {
|
|
2233
|
+
continue;
|
|
2234
|
+
}
|
|
2235
|
+
if (child.localName === 'top') {
|
|
2236
|
+
top = edge;
|
|
2237
|
+
}
|
|
2238
|
+
else if (child.localName === 'left') {
|
|
2239
|
+
left = edge;
|
|
2240
|
+
}
|
|
2241
|
+
else if (child.localName === 'bottom') {
|
|
2242
|
+
bottom = edge;
|
|
2243
|
+
}
|
|
2244
|
+
else if (child.localName === 'right') {
|
|
2245
|
+
right = edge;
|
|
2246
|
+
}
|
|
2247
|
+
else if (child.localName === 'between') {
|
|
2248
|
+
between = edge;
|
|
2249
|
+
}
|
|
2250
|
+
else if (child.localName === 'bar') {
|
|
2251
|
+
bar = edge;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2256
|
+
finally {
|
|
2257
|
+
try {
|
|
2258
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2259
|
+
}
|
|
2260
|
+
finally { if (e_2) throw e_2.error; }
|
|
2261
|
+
}
|
|
2262
|
+
return __assign({}, (top !== undefined ? { top: top } : {}), (left !== undefined ? { left: left } : {}), (bottom !== undefined ? { bottom: bottom } : {}), (right !== undefined ? { right: right } : {}), (between !== undefined ? { between: between } : {}), (bar !== undefined ? { bar: bar } : {}));
|
|
2263
|
+
}
|
|
2264
|
+
function parseShd(el) {
|
|
2265
|
+
var fillRaw = wmlAttrVal(el, 'fill');
|
|
2266
|
+
var colorRaw = wmlAttrVal(el, 'color');
|
|
2267
|
+
var valRaw = wmlAttrVal(el, 'val');
|
|
2268
|
+
var pattern = valRaw !== undefined && SHADING_PATTERNS.has(valRaw)
|
|
2269
|
+
? valRaw
|
|
2270
|
+
: undefined;
|
|
2271
|
+
return __assign({}, (fillRaw !== undefined ? { fill: fillRaw } : {}), (colorRaw !== undefined ? { color: colorRaw } : {}), (pattern !== undefined ? { pattern: pattern } : {}));
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* Parse `w:pPr` children into a {@link ParagraphFormatSnapshot}.
|
|
2275
|
+
* Invalid / unmodeled markup is parked in `pPrExtra` (never throws on load).
|
|
2276
|
+
* Does not consume `pStyle` / `numPr` / `rPr` / `sectPr` — callers handle those.
|
|
2277
|
+
*
|
|
2278
|
+
* @private
|
|
2279
|
+
*/
|
|
2280
|
+
export function parseParagraphFormat(pPrElement) {
|
|
2281
|
+
var e_3, _a;
|
|
2282
|
+
var snap = emptyParagraphFormatSnapshot();
|
|
2283
|
+
var pPrExtra = [];
|
|
2284
|
+
try {
|
|
2285
|
+
for (var _b = __values(elementChildren(pPrElement)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2286
|
+
var prop = _c.value;
|
|
2287
|
+
// Paragraph-owned children — skip (caller already handled, or ignore if orphan).
|
|
2288
|
+
if (isWml(prop, 'pStyle') || isWml(prop, 'numPr') || isWml(prop, 'rPr') || isWml(prop, 'sectPr')) {
|
|
2289
|
+
continue;
|
|
2290
|
+
}
|
|
2291
|
+
if (!isWml(prop, prop.localName)) {
|
|
2292
|
+
pPrExtra.push(prop);
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
if (PPR_EXTRA_ONLY.has(prop.localName)) {
|
|
2296
|
+
pPrExtra.push(prop);
|
|
2297
|
+
continue;
|
|
2298
|
+
}
|
|
2299
|
+
// D5: foreign non-schema `w:suppressHyphenation` parks; never models.
|
|
2300
|
+
if (prop.localName === 'suppressHyphenation') {
|
|
2301
|
+
pPrExtra.push(prop);
|
|
2302
|
+
continue;
|
|
2303
|
+
}
|
|
2304
|
+
if (!MODELED_PPR.has(prop.localName)) {
|
|
2305
|
+
pPrExtra.push(prop);
|
|
2306
|
+
continue;
|
|
2307
|
+
}
|
|
2308
|
+
if (prop.localName === 'jc') {
|
|
2309
|
+
snap.jcRaw = wValAttribute(prop);
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
if (prop.localName === 'outlineLvl') {
|
|
2313
|
+
var raw = wValAttribute(prop);
|
|
2314
|
+
if (raw !== undefined && /^-?\d+$/.test(raw)) {
|
|
2315
|
+
snap.outlineLevelValue = Number.parseInt(raw, 10);
|
|
2316
|
+
}
|
|
2317
|
+
else {
|
|
2318
|
+
pPrExtra.push(prop);
|
|
2319
|
+
}
|
|
2320
|
+
continue;
|
|
2321
|
+
}
|
|
2322
|
+
if (prop.localName === 'ind') {
|
|
2323
|
+
var parsed = parseIndentsRecord(prop);
|
|
2324
|
+
if (parsed === undefined) {
|
|
2325
|
+
pPrExtra.push(prop);
|
|
2326
|
+
}
|
|
2327
|
+
else {
|
|
2328
|
+
snap.indentsValue = parsed;
|
|
2329
|
+
}
|
|
2330
|
+
continue;
|
|
2331
|
+
}
|
|
2332
|
+
if (prop.localName === 'spacing') {
|
|
2333
|
+
var parsed = parseSpacingRecord(prop);
|
|
2334
|
+
if (parsed === undefined) {
|
|
2335
|
+
pPrExtra.push(prop);
|
|
2336
|
+
}
|
|
2337
|
+
else {
|
|
2338
|
+
snap.spacingValue = parsed;
|
|
2339
|
+
}
|
|
2340
|
+
continue;
|
|
2341
|
+
}
|
|
2342
|
+
if (prop.localName === 'tabs') {
|
|
2343
|
+
snap.tabStopsValue = parseTabs(prop);
|
|
2344
|
+
continue;
|
|
2345
|
+
}
|
|
2346
|
+
if (prop.localName === 'pBdr') {
|
|
2347
|
+
snap.bordersValue = parsePBdr(prop);
|
|
2348
|
+
continue;
|
|
2349
|
+
}
|
|
2350
|
+
if (prop.localName === 'shd') {
|
|
2351
|
+
snap.shadingValue = parseShd(prop);
|
|
2352
|
+
continue;
|
|
2353
|
+
}
|
|
2354
|
+
if (prop.localName === 'textDirection') {
|
|
2355
|
+
var raw = wValAttribute(prop);
|
|
2356
|
+
if (raw === undefined) {
|
|
2357
|
+
pPrExtra.push(prop);
|
|
2358
|
+
continue;
|
|
2359
|
+
}
|
|
2360
|
+
if (TEXT_DIRECTIONS.has(raw)) {
|
|
2361
|
+
snap.textDirectionValue = raw;
|
|
2362
|
+
snap.textDirectionRaw = undefined;
|
|
2363
|
+
}
|
|
2364
|
+
else {
|
|
2365
|
+
// Unknown token: keep raw for RT; typed getter returns undefined.
|
|
2366
|
+
snap.textDirectionValue = undefined;
|
|
2367
|
+
snap.textDirectionRaw = raw;
|
|
2368
|
+
}
|
|
2369
|
+
continue;
|
|
2370
|
+
}
|
|
2371
|
+
if (prop.localName === 'textAlignment') {
|
|
2372
|
+
var raw = wValAttribute(prop);
|
|
2373
|
+
if (raw === undefined) {
|
|
2374
|
+
pPrExtra.push(prop);
|
|
2375
|
+
continue;
|
|
2376
|
+
}
|
|
2377
|
+
if (BASELINE_ALIGNMENTS.has(raw)) {
|
|
2378
|
+
snap.baselineAlignmentValue = raw;
|
|
2379
|
+
snap.baselineAlignmentRaw = undefined;
|
|
2380
|
+
}
|
|
2381
|
+
else {
|
|
2382
|
+
snap.baselineAlignmentValue = undefined;
|
|
2383
|
+
snap.baselineAlignmentRaw = raw;
|
|
2384
|
+
}
|
|
2385
|
+
continue;
|
|
2386
|
+
}
|
|
2387
|
+
var flag = parseOnOff(prop);
|
|
2388
|
+
if (flag === undefined) {
|
|
2389
|
+
pPrExtra.push(prop);
|
|
2390
|
+
continue;
|
|
2391
|
+
}
|
|
2392
|
+
if (prop.localName === 'keepNext') {
|
|
2393
|
+
snap.keepNextValue = flag;
|
|
2394
|
+
}
|
|
2395
|
+
else if (prop.localName === 'keepLines') {
|
|
2396
|
+
snap.keepLinesValue = flag;
|
|
2397
|
+
}
|
|
2398
|
+
else if (prop.localName === 'pageBreakBefore') {
|
|
2399
|
+
snap.pageBreakBeforeValue = flag;
|
|
2400
|
+
}
|
|
2401
|
+
else if (prop.localName === 'widowControl') {
|
|
2402
|
+
snap.widowControlValue = flag;
|
|
2403
|
+
}
|
|
2404
|
+
else if (prop.localName === 'bidi') {
|
|
2405
|
+
snap.bidiValue = flag;
|
|
2406
|
+
}
|
|
2407
|
+
else if (prop.localName === 'suppressLineNumbers') {
|
|
2408
|
+
snap.suppressLineNumbersValue = flag;
|
|
2409
|
+
}
|
|
2410
|
+
else if (prop.localName === 'suppressAutoHyphens') {
|
|
2411
|
+
snap.suppressAutoHyphensValue = flag;
|
|
2412
|
+
}
|
|
2413
|
+
else if (prop.localName === 'contextualSpacing') {
|
|
2414
|
+
snap.contextualSpacingValue = flag;
|
|
2415
|
+
}
|
|
2416
|
+
else if (prop.localName === 'adjustRightInd') {
|
|
2417
|
+
snap.adjustRightIndentValue = flag;
|
|
2418
|
+
}
|
|
2419
|
+
else if (prop.localName === 'overflowPunct') {
|
|
2420
|
+
snap.overflowPunctuationValue = flag;
|
|
2421
|
+
}
|
|
2422
|
+
else if (prop.localName === 'autoSpaceDE') {
|
|
2423
|
+
snap.autoSpaceDEValue = flag;
|
|
2424
|
+
}
|
|
2425
|
+
else if (prop.localName === 'autoSpaceDN') {
|
|
2426
|
+
snap.autoSpaceDNValue = flag;
|
|
2427
|
+
}
|
|
2428
|
+
else if (prop.localName === 'snapToGrid') {
|
|
2429
|
+
snap.snapToGridValue = flag;
|
|
2430
|
+
}
|
|
2431
|
+
else if (prop.localName === 'wordWrap') {
|
|
2432
|
+
snap.wordWrapValue = flag;
|
|
2433
|
+
}
|
|
2434
|
+
else if (prop.localName === 'mirrorIndents') {
|
|
2435
|
+
snap.mirrorIndentsValue = flag;
|
|
2436
|
+
}
|
|
2437
|
+
else if (prop.localName === 'kinsoku') {
|
|
2438
|
+
snap.kinsokuValue = flag;
|
|
2439
|
+
}
|
|
2440
|
+
else if (prop.localName === 'topLinePunct') {
|
|
2441
|
+
snap.topLinePunctuationValue = flag;
|
|
2442
|
+
}
|
|
2443
|
+
else {
|
|
2444
|
+
pPrExtra.push(prop);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2449
|
+
finally {
|
|
2450
|
+
try {
|
|
2451
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2452
|
+
}
|
|
2453
|
+
finally { if (e_3) throw e_3.error; }
|
|
2454
|
+
}
|
|
2455
|
+
snap.pPrExtra = pPrExtra;
|
|
2456
|
+
return snap;
|
|
2457
|
+
}
|
|
2458
|
+
// ---------------------------------------------------------------------------
|
|
2459
|
+
// Serialize helpers (wire units)
|
|
2460
|
+
// ---------------------------------------------------------------------------
|
|
2461
|
+
function pushOnOff(children, localName, value) {
|
|
2462
|
+
if (value === undefined) {
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
children.push(serializeOnOff(localName, value));
|
|
2466
|
+
}
|
|
2467
|
+
function pushParkedNamed(children, remaining, localName) {
|
|
2468
|
+
var kept = [];
|
|
2469
|
+
for (var i = 0; i < remaining.length; i++) {
|
|
2470
|
+
var el = remaining[i];
|
|
2471
|
+
if (isWml(el, localName)) {
|
|
2472
|
+
children.push(el);
|
|
2473
|
+
}
|
|
2474
|
+
else {
|
|
2475
|
+
kept.push(el);
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
return kept;
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* Serialize wire-twips indents record → `w:ind`.
|
|
2482
|
+
* D2: authored `left`/`right` plus any RT `start`/`end`/`*Chars` slots.
|
|
2483
|
+
* @private
|
|
2484
|
+
*/
|
|
2485
|
+
export function serializeIndentsRecord(ind) {
|
|
2486
|
+
var attrs = [];
|
|
2487
|
+
if (ind.left !== undefined) {
|
|
2488
|
+
attrs.push(wmlAttr('left', String(ind.left)));
|
|
2489
|
+
}
|
|
2490
|
+
if (ind.right !== undefined) {
|
|
2491
|
+
attrs.push(wmlAttr('right', String(ind.right)));
|
|
2492
|
+
}
|
|
2493
|
+
if (ind.start !== undefined) {
|
|
2494
|
+
attrs.push(wmlAttr('start', String(ind.start)));
|
|
2495
|
+
}
|
|
2496
|
+
if (ind.end !== undefined) {
|
|
2497
|
+
attrs.push(wmlAttr('end', String(ind.end)));
|
|
2498
|
+
}
|
|
2499
|
+
if (ind.hanging !== undefined) {
|
|
2500
|
+
attrs.push(wmlAttr('hanging', String(ind.hanging)));
|
|
2501
|
+
}
|
|
2502
|
+
if (ind.firstLine !== undefined) {
|
|
2503
|
+
attrs.push(wmlAttr('firstLine', String(ind.firstLine)));
|
|
2504
|
+
}
|
|
2505
|
+
if (ind.leftChars !== undefined) {
|
|
2506
|
+
attrs.push(wmlAttr('leftChars', String(ind.leftChars)));
|
|
2507
|
+
}
|
|
2508
|
+
if (ind.rightChars !== undefined) {
|
|
2509
|
+
attrs.push(wmlAttr('rightChars', String(ind.rightChars)));
|
|
2510
|
+
}
|
|
2511
|
+
if (ind.firstLineChars !== undefined) {
|
|
2512
|
+
attrs.push(wmlAttr('firstLineChars', String(ind.firstLineChars)));
|
|
2513
|
+
}
|
|
2514
|
+
if (ind.hangingChars !== undefined) {
|
|
2515
|
+
attrs.push(wmlAttr('hangingChars', String(ind.hangingChars)));
|
|
2516
|
+
}
|
|
2517
|
+
return wmlElement('ind', { attributes: attrs });
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* Serialize wire-unit spacing record → `w:spacing`.
|
|
2521
|
+
* @private
|
|
2522
|
+
*/
|
|
2523
|
+
export function serializeSpacingRecord(sp) {
|
|
2524
|
+
var attrs = [];
|
|
2525
|
+
if (sp.before !== undefined) {
|
|
2526
|
+
attrs.push(wmlAttr('before', String(sp.before)));
|
|
2527
|
+
}
|
|
2528
|
+
if (sp.after !== undefined) {
|
|
2529
|
+
attrs.push(wmlAttr('after', String(sp.after)));
|
|
2530
|
+
}
|
|
2531
|
+
if (sp.beforeLines !== undefined) {
|
|
2532
|
+
attrs.push(wmlAttr('beforeLines', String(sp.beforeLines)));
|
|
2533
|
+
}
|
|
2534
|
+
if (sp.afterLines !== undefined) {
|
|
2535
|
+
attrs.push(wmlAttr('afterLines', String(sp.afterLines)));
|
|
2536
|
+
}
|
|
2537
|
+
if (sp.line !== undefined) {
|
|
2538
|
+
attrs.push(wmlAttr('line', String(sp.line)));
|
|
2539
|
+
// Schema default is auto; emit explicitly so consumers do not have to
|
|
2540
|
+
// apply the XSD default when @line is present without @lineRule.
|
|
2541
|
+
attrs.push(wmlAttr('lineRule', sp.lineRule !== undefined ? sp.lineRule : 'auto'));
|
|
2542
|
+
}
|
|
2543
|
+
else if (sp.lineRule !== undefined) {
|
|
2544
|
+
attrs.push(wmlAttr('lineRule', sp.lineRule));
|
|
2545
|
+
}
|
|
2546
|
+
if (sp.beforeAutospacing !== undefined) {
|
|
2547
|
+
attrs.push(wmlAttr('beforeAutospacing', sp.beforeAutospacing ? '1' : '0'));
|
|
2548
|
+
}
|
|
2549
|
+
if (sp.afterAutospacing !== undefined) {
|
|
2550
|
+
attrs.push(wmlAttr('afterAutospacing', sp.afterAutospacing ? '1' : '0'));
|
|
2551
|
+
}
|
|
2552
|
+
return wmlElement('spacing', { attributes: attrs });
|
|
2553
|
+
}
|
|
2554
|
+
function serializeTabs(stops) {
|
|
2555
|
+
var children = stops.map(function (s) {
|
|
2556
|
+
var attrs = [
|
|
2557
|
+
wmlAttr('val', s.alignment),
|
|
2558
|
+
wmlAttr('pos', String(pointToTwips(s.position))),
|
|
2559
|
+
];
|
|
2560
|
+
if (s.leader !== undefined) {
|
|
2561
|
+
attrs.push(wmlAttr('leader', s.leader));
|
|
2562
|
+
}
|
|
2563
|
+
return wmlElement('tab', { attributes: attrs });
|
|
2564
|
+
});
|
|
2565
|
+
return wmlElement('tabs', { children: children });
|
|
2566
|
+
}
|
|
2567
|
+
function serializeBorderEdge(localName, edge) {
|
|
2568
|
+
var attrs = [wmlAttr('val', edge.style)];
|
|
2569
|
+
if (edge.color !== undefined) {
|
|
2570
|
+
attrs.push(wmlAttr('color', edge.color));
|
|
2571
|
+
}
|
|
2572
|
+
if (edge.size !== undefined) {
|
|
2573
|
+
attrs.push(wmlAttr('sz', String(edge.size)));
|
|
2574
|
+
}
|
|
2575
|
+
if (edge.space !== undefined) {
|
|
2576
|
+
attrs.push(wmlAttr('space', String(edge.space)));
|
|
2577
|
+
}
|
|
2578
|
+
return wmlElement(localName, { attributes: attrs });
|
|
2579
|
+
}
|
|
2580
|
+
function serializePBdr(borders) {
|
|
2581
|
+
var children = [];
|
|
2582
|
+
if (borders.top !== undefined) {
|
|
2583
|
+
children.push(serializeBorderEdge('top', borders.top));
|
|
2584
|
+
}
|
|
2585
|
+
if (borders.left !== undefined) {
|
|
2586
|
+
children.push(serializeBorderEdge('left', borders.left));
|
|
2587
|
+
}
|
|
2588
|
+
if (borders.bottom !== undefined) {
|
|
2589
|
+
children.push(serializeBorderEdge('bottom', borders.bottom));
|
|
2590
|
+
}
|
|
2591
|
+
if (borders.right !== undefined) {
|
|
2592
|
+
children.push(serializeBorderEdge('right', borders.right));
|
|
2593
|
+
}
|
|
2594
|
+
if (borders.between !== undefined) {
|
|
2595
|
+
children.push(serializeBorderEdge('between', borders.between));
|
|
2596
|
+
}
|
|
2597
|
+
if (borders.bar !== undefined) {
|
|
2598
|
+
children.push(serializeBorderEdge('bar', borders.bar));
|
|
2599
|
+
}
|
|
2600
|
+
return wmlElement('pBdr', { children: children });
|
|
2601
|
+
}
|
|
2602
|
+
function serializeShd(shd) {
|
|
2603
|
+
var attrs = [];
|
|
2604
|
+
if (shd.pattern !== undefined) {
|
|
2605
|
+
attrs.push(wmlAttr('val', shd.pattern));
|
|
2606
|
+
}
|
|
2607
|
+
if (shd.color !== undefined) {
|
|
2608
|
+
attrs.push(wmlAttr('color', shd.color));
|
|
2609
|
+
}
|
|
2610
|
+
if (shd.fill !== undefined) {
|
|
2611
|
+
attrs.push(wmlAttr('fill', shd.fill));
|
|
2612
|
+
}
|
|
2613
|
+
return wmlElement('shd', { attributes: attrs });
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Materialize format-owned `w:pPr` children in CT_PPrBase / CT_PPr order.
|
|
2617
|
+
* Inject optional paragraph-owned `numPr` / `sectPr` at schema positions.
|
|
2618
|
+
* D5: never emits `w:suppressHyphenation` from typed state.
|
|
2619
|
+
*
|
|
2620
|
+
* @private
|
|
2621
|
+
*/
|
|
2622
|
+
export function buildPPrChildrenFromSnapshot(snap, inject) {
|
|
2623
|
+
var children = [];
|
|
2624
|
+
var remaining = snap.pPrExtra.slice();
|
|
2625
|
+
pushOnOff(children, 'keepNext', snap.keepNextValue);
|
|
2626
|
+
pushOnOff(children, 'keepLines', snap.keepLinesValue);
|
|
2627
|
+
pushOnOff(children, 'pageBreakBefore', snap.pageBreakBeforeValue);
|
|
2628
|
+
remaining = pushParkedNamed(children, remaining, 'framePr');
|
|
2629
|
+
pushOnOff(children, 'widowControl', snap.widowControlValue);
|
|
2630
|
+
if (inject !== undefined && inject.numPr !== undefined) {
|
|
2631
|
+
children.push(inject.numPr);
|
|
2632
|
+
}
|
|
2633
|
+
pushOnOff(children, 'suppressLineNumbers', snap.suppressLineNumbersValue);
|
|
2634
|
+
if (snap.bordersValue !== undefined) {
|
|
2635
|
+
children.push(serializePBdr(snap.bordersValue));
|
|
2636
|
+
}
|
|
2637
|
+
if (snap.shadingValue !== undefined && shadingHasEntries(snap.shadingValue)) {
|
|
2638
|
+
children.push(serializeShd(snap.shadingValue));
|
|
2639
|
+
}
|
|
2640
|
+
if (snap.tabStopsValue !== undefined && snap.tabStopsValue.length > 0) {
|
|
2641
|
+
children.push(serializeTabs(snap.tabStopsValue));
|
|
2642
|
+
}
|
|
2643
|
+
// D5: only schema `w:suppressAutoHyphens` — never author-emit suppressHyphenation.
|
|
2644
|
+
pushOnOff(children, 'suppressAutoHyphens', snap.suppressAutoHyphensValue);
|
|
2645
|
+
pushOnOff(children, 'kinsoku', snap.kinsokuValue);
|
|
2646
|
+
pushOnOff(children, 'wordWrap', snap.wordWrapValue);
|
|
2647
|
+
pushOnOff(children, 'overflowPunct', snap.overflowPunctuationValue);
|
|
2648
|
+
pushOnOff(children, 'topLinePunct', snap.topLinePunctuationValue);
|
|
2649
|
+
pushOnOff(children, 'autoSpaceDE', snap.autoSpaceDEValue);
|
|
2650
|
+
pushOnOff(children, 'autoSpaceDN', snap.autoSpaceDNValue);
|
|
2651
|
+
pushOnOff(children, 'bidi', snap.bidiValue);
|
|
2652
|
+
pushOnOff(children, 'adjustRightInd', snap.adjustRightIndentValue);
|
|
2653
|
+
pushOnOff(children, 'snapToGrid', snap.snapToGridValue);
|
|
2654
|
+
if (snap.spacingValue !== undefined && !spacingRecordIsEmpty(snap.spacingValue)) {
|
|
2655
|
+
children.push(serializeSpacingRecord(snap.spacingValue));
|
|
2656
|
+
}
|
|
2657
|
+
if (snap.indentsValue !== undefined && !indentsRecordIsEmpty(snap.indentsValue)) {
|
|
2658
|
+
children.push(serializeIndentsRecord(snap.indentsValue));
|
|
2659
|
+
}
|
|
2660
|
+
pushOnOff(children, 'contextualSpacing', snap.contextualSpacingValue);
|
|
2661
|
+
pushOnOff(children, 'mirrorIndents', snap.mirrorIndentsValue);
|
|
2662
|
+
remaining = pushParkedNamed(children, remaining, 'suppressOverlap');
|
|
2663
|
+
if (snap.jcRaw !== undefined) {
|
|
2664
|
+
children.push(wmlElement('jc', { attributes: [wmlAttr('val', snap.jcRaw)] }));
|
|
2665
|
+
}
|
|
2666
|
+
// Prefer typed token; else raw unknown for RT.
|
|
2667
|
+
if (snap.textDirectionValue !== undefined) {
|
|
2668
|
+
children.push(wmlElement('textDirection', {
|
|
2669
|
+
attributes: [wmlAttr('val', snap.textDirectionValue)],
|
|
2670
|
+
}));
|
|
2671
|
+
}
|
|
2672
|
+
else if (snap.textDirectionRaw !== undefined) {
|
|
2673
|
+
children.push(wmlElement('textDirection', {
|
|
2674
|
+
attributes: [wmlAttr('val', snap.textDirectionRaw)],
|
|
2675
|
+
}));
|
|
2676
|
+
}
|
|
2677
|
+
if (snap.baselineAlignmentValue !== undefined) {
|
|
2678
|
+
children.push(wmlElement('textAlignment', {
|
|
2679
|
+
attributes: [wmlAttr('val', snap.baselineAlignmentValue)],
|
|
2680
|
+
}));
|
|
2681
|
+
}
|
|
2682
|
+
else if (snap.baselineAlignmentRaw !== undefined) {
|
|
2683
|
+
children.push(wmlElement('textAlignment', {
|
|
2684
|
+
attributes: [wmlAttr('val', snap.baselineAlignmentRaw)],
|
|
2685
|
+
}));
|
|
2686
|
+
}
|
|
2687
|
+
remaining = pushParkedNamed(children, remaining, 'textboxTightWrap');
|
|
2688
|
+
remaining = pushParkedNamed(children, remaining, 'divId');
|
|
2689
|
+
remaining = pushParkedNamed(children, remaining, 'cnfStyle');
|
|
2690
|
+
if (snap.outlineLevelValue !== undefined) {
|
|
2691
|
+
children.push(wmlElement('outlineLvl', {
|
|
2692
|
+
attributes: [wmlAttr('val', String(snap.outlineLevelValue))],
|
|
2693
|
+
}));
|
|
2694
|
+
}
|
|
2695
|
+
// Mark rPr is paragraph-owned (breakCharacterFormat); inject replaces parking.
|
|
2696
|
+
if (inject !== undefined && inject.rPr !== undefined) {
|
|
2697
|
+
children.push(inject.rPr);
|
|
2698
|
+
}
|
|
2699
|
+
if (inject !== undefined && inject.sectPr !== undefined) {
|
|
2700
|
+
children.push(inject.sectPr);
|
|
2701
|
+
}
|
|
2702
|
+
remaining = pushParkedNamed(children, remaining, 'pPrChange');
|
|
2703
|
+
// Any remaining parked / unknown / foreign (incl. suppressHyphenation if still present) at end.
|
|
2704
|
+
for (var i = 0; i < remaining.length; i++) {
|
|
2705
|
+
children.push(remaining[i]);
|
|
2706
|
+
}
|
|
2707
|
+
return children;
|
|
2708
|
+
}
|
|
2709
|
+
// ---------------------------------------------------------------------------
|
|
2710
|
+
// Styles-surface helpers (points bags + lineSpacing alias) — shared codecs
|
|
2711
|
+
// ---------------------------------------------------------------------------
|
|
2712
|
+
/**
|
|
2713
|
+
* Wire `w:spacing` → public points {@link ParagraphSpacing} with `lineSpacing` key.
|
|
2714
|
+
* Used by the styles feature; preserves prior payload shape.
|
|
2715
|
+
* @private
|
|
2716
|
+
*/
|
|
2717
|
+
export function parseParagraphSpacingPoints(el) {
|
|
2718
|
+
if (!isWml(el, 'spacing')) {
|
|
2719
|
+
return undefined;
|
|
2720
|
+
}
|
|
2721
|
+
var record = parseSpacingRecord(el);
|
|
2722
|
+
if (record === undefined) {
|
|
2723
|
+
return undefined;
|
|
2724
|
+
}
|
|
2725
|
+
// Styles surface historically omitted autospacing / *Lines; keep that shape.
|
|
2726
|
+
if (record.before === undefined
|
|
2727
|
+
&& record.after === undefined
|
|
2728
|
+
&& record.line === undefined
|
|
2729
|
+
&& record.lineRule === undefined) {
|
|
2730
|
+
return undefined;
|
|
2731
|
+
}
|
|
2732
|
+
return __assign({}, (record.before !== undefined ? { before: twipsToPoint(record.before) } : {}), (record.after !== undefined ? { after: twipsToPoint(record.after) } : {}), (record.line !== undefined ? { lineSpacing: twipsToPoint(record.line) } : {}), (record.lineRule !== undefined ? { lineRule: record.lineRule } : {}));
|
|
2733
|
+
}
|
|
2734
|
+
/**
|
|
2735
|
+
* Wire `w:ind` → public points {@link ParagraphIndentation}.
|
|
2736
|
+
* @private
|
|
2737
|
+
*/
|
|
2738
|
+
export function parseParagraphIndentationPoints(el) {
|
|
2739
|
+
if (!isWml(el, 'ind')) {
|
|
2740
|
+
return undefined;
|
|
2741
|
+
}
|
|
2742
|
+
var record = parseIndentsRecord(el);
|
|
2743
|
+
if (record === undefined) {
|
|
2744
|
+
return undefined;
|
|
2745
|
+
}
|
|
2746
|
+
// Styles surface: physical left/right only (matches prior codec).
|
|
2747
|
+
var left = record.left !== undefined
|
|
2748
|
+
? twipsToPoint(record.left)
|
|
2749
|
+
: undefined;
|
|
2750
|
+
var right = record.right !== undefined
|
|
2751
|
+
? twipsToPoint(record.right)
|
|
2752
|
+
: undefined;
|
|
2753
|
+
if (left === undefined && right === undefined
|
|
2754
|
+
&& record.firstLine === undefined && record.hanging === undefined) {
|
|
2755
|
+
return undefined;
|
|
2756
|
+
}
|
|
2757
|
+
return __assign({}, (left !== undefined ? { left: left } : {}), (right !== undefined ? { right: right } : {}), (record.firstLine !== undefined ? { firstLine: twipsToPoint(record.firstLine) } : {}), (record.hanging !== undefined ? { hanging: twipsToPoint(record.hanging) } : {}));
|
|
2758
|
+
}
|
|
2759
|
+
/**
|
|
2760
|
+
* Points {@link ParagraphSpacing} → `w:spacing` (styles `lineSpacing` key).
|
|
2761
|
+
* @private
|
|
2762
|
+
*/
|
|
2763
|
+
export function serializeParagraphSpacingPoints(spacing) {
|
|
2764
|
+
var record = {};
|
|
2765
|
+
if (spacing.before !== undefined) {
|
|
2766
|
+
record.before = pointToTwips(spacing.before);
|
|
2767
|
+
}
|
|
2768
|
+
if (spacing.after !== undefined) {
|
|
2769
|
+
record.after = pointToTwips(spacing.after);
|
|
2770
|
+
}
|
|
2771
|
+
var line = spacing.lineSpacing !== undefined
|
|
2772
|
+
? spacing.lineSpacing
|
|
2773
|
+
: spacing.line;
|
|
2774
|
+
if (line !== undefined) {
|
|
2775
|
+
record.line = pointToTwips(line);
|
|
2776
|
+
}
|
|
2777
|
+
if (spacing.lineRule !== undefined) {
|
|
2778
|
+
record.lineRule = spacing.lineRule;
|
|
2779
|
+
}
|
|
2780
|
+
if (spacing.beforeAutospacing !== undefined) {
|
|
2781
|
+
record.beforeAutospacing = spacing.beforeAutospacing;
|
|
2782
|
+
}
|
|
2783
|
+
if (spacing.afterAutospacing !== undefined) {
|
|
2784
|
+
record.afterAutospacing = spacing.afterAutospacing;
|
|
2785
|
+
}
|
|
2786
|
+
return serializeSpacingRecord(record);
|
|
2787
|
+
}
|
|
2788
|
+
/**
|
|
2789
|
+
* Points {@link ParagraphIndentation} → `w:ind` (D2 left/right spellings).
|
|
2790
|
+
* @private
|
|
2791
|
+
*/
|
|
2792
|
+
export function serializeParagraphIndentationPoints(indentation) {
|
|
2793
|
+
var record = {};
|
|
2794
|
+
if (indentation.left !== undefined) {
|
|
2795
|
+
record.left = pointToTwips(indentation.left);
|
|
2796
|
+
}
|
|
2797
|
+
if (indentation.right !== undefined) {
|
|
2798
|
+
record.right = pointToTwips(indentation.right);
|
|
2799
|
+
}
|
|
2800
|
+
if (indentation.firstLine !== undefined) {
|
|
2801
|
+
record.firstLine = pointToTwips(indentation.firstLine);
|
|
2802
|
+
}
|
|
2803
|
+
if (indentation.hanging !== undefined) {
|
|
2804
|
+
record.hanging = pointToTwips(indentation.hanging);
|
|
2805
|
+
}
|
|
2806
|
+
return serializeIndentsRecord(record);
|
|
2807
|
+
}
|