@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,2857 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __values = (this && this.__values) || function (o) {
|
|
15
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
16
|
+
if (m) return m.call(o);
|
|
17
|
+
return {
|
|
18
|
+
next: function () {
|
|
19
|
+
if (o && i >= o.length) o = void 0;
|
|
20
|
+
return { value: o && o[i++], done: !o };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
+
if (!m) return o;
|
|
27
|
+
var i = m.call(o), r, ar = [], e;
|
|
28
|
+
try {
|
|
29
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) { e = { error: error }; }
|
|
32
|
+
finally {
|
|
33
|
+
try {
|
|
34
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
+
}
|
|
36
|
+
finally { if (e) throw e.error; }
|
|
37
|
+
}
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
var __spread = (this && this.__spread) || function () {
|
|
41
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
import { registerAlwaysOnBodyFeatureBootstrap } from '../document/body-always-on';
|
|
45
|
+
import { parseBodyBlocks, serializeBodyBlocks } from '../document/body-blocks';
|
|
46
|
+
import { DetachedObjectError } from '../../core/errors/docx-error';
|
|
47
|
+
import { WordDocument, Body } from '../document/document';
|
|
48
|
+
import { Paragraph } from '../document/paragraph';
|
|
49
|
+
import { projectBlockToBodyItem, registerBodyItemAdapter } from '../document/body-item-adapters';
|
|
50
|
+
import { registerTypedCollectionHooks } from '../document/typed-body-collections';
|
|
51
|
+
import { CharacterFormat, parseCharacterFormat, } from '../document/character-format';
|
|
52
|
+
import { colorFromWire, colorToHexWire } from '../document/color';
|
|
53
|
+
import { EntityType } from '../document/entity-type';
|
|
54
|
+
import { localeIdFromBcp47, localeIdToBcp47 } from '../document/locale-ids';
|
|
55
|
+
import { ParagraphItemCollection } from '../document/paragraph-item-collection';
|
|
56
|
+
import { FeatureInlineParagraphItem, OpaqueParagraphItem, serializeRun, serializeParagraphItems, TextRange, } from '../document/text-range';
|
|
57
|
+
import { elementChildren, isWml, isWmlNamespace, wmlAttr, wmlElement } from '../document/wml';
|
|
58
|
+
import { featureId, registerFeature, registerFeatureBlockHandler, registerFeatureBlockParagraphWalker, registerFeatureInlineHandler, visitBlocksInDocumentOrder, } from '../../core/registry/index';
|
|
59
|
+
import { detachedBodyBlockParseContext } from '../../core/registry/block-handlers';
|
|
60
|
+
import { serializeFeatureInline, tryParseFeatureInline, } from '../../core/registry/inline-handlers';
|
|
61
|
+
var CONTENT_CONTROLS = featureId('content-controls');
|
|
62
|
+
/**
|
|
63
|
+
* @private
|
|
64
|
+
* [MS-DOCX] WordprocessingML 2010 extension namespace
|
|
65
|
+
* (`http://schemas.microsoft.com/office/word/2010/wordml`) — checkbox / `w14`.
|
|
66
|
+
*/
|
|
67
|
+
export var WORDML_2010_NAMESPACE = 'http://schemas.microsoft.com/office/word/2010/wordml';
|
|
68
|
+
/**
|
|
69
|
+
* @private
|
|
70
|
+
* [MS-DOCX] WordprocessingML 2012 extension namespace
|
|
71
|
+
* (`http://schemas.microsoft.com/office/word/2012/wordml`) — appearance / color.
|
|
72
|
+
*/
|
|
73
|
+
export var WORDML_2012_NAMESPACE = 'http://schemas.microsoft.com/office/word/2012/wordml';
|
|
74
|
+
var W14_PREFIX = 'w14';
|
|
75
|
+
var W15_PREFIX = 'w15';
|
|
76
|
+
var DEFAULT_CHECKBOX_FONT = 'Segoe UI Symbol';
|
|
77
|
+
var DEFAULT_CHECKED_SYMBOL = '2612';
|
|
78
|
+
var DEFAULT_UNCHECKED_SYMBOL = '2610';
|
|
79
|
+
var DEFAULT_CHECKED_SYMBOL_TEXT = '\u2612';
|
|
80
|
+
var DEFAULT_UNCHECKED_SYMBOL_TEXT = '\u2610';
|
|
81
|
+
/**
|
|
82
|
+
* Runtime values for {@link ContentControlType}.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export var ContentControlType = {
|
|
86
|
+
RichText: 'richText',
|
|
87
|
+
Text: 'plainText',
|
|
88
|
+
Picture: 'picture',
|
|
89
|
+
ComboBox: 'comboBox',
|
|
90
|
+
DropDownList: 'dropDownList',
|
|
91
|
+
Date: 'date',
|
|
92
|
+
CheckBox: 'checkbox',
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Runtime values for {@link ContentControlAppearance}.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export var ContentControlAppearance = {
|
|
99
|
+
BoundingBox: 'boundingBox',
|
|
100
|
+
Tags: 'tags',
|
|
101
|
+
Hidden: 'hidden',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Runtime values for {@link CalendarType}.
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export var CalendarType = {
|
|
108
|
+
Gregorian: 'gregorian',
|
|
109
|
+
Hijri: 'hijri',
|
|
110
|
+
Hebrew: 'hebrew',
|
|
111
|
+
Taiwan: 'taiwan',
|
|
112
|
+
Japan: 'japan',
|
|
113
|
+
Thai: 'thai',
|
|
114
|
+
Korea: 'korea',
|
|
115
|
+
Saka: 'saka',
|
|
116
|
+
GregorianArabic: 'gregorianArabic',
|
|
117
|
+
GregorianMiddleEastFrench: 'gregorianMiddleEastFrench',
|
|
118
|
+
GregorianTransliteratedEnglish: 'gregorianTransliteratedEnglish',
|
|
119
|
+
GregorianTransliteratedFrench: 'gregorianTransliteratedFrench',
|
|
120
|
+
GregorianUsLocale: 'gregorianUsLocale',
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Runtime values for {@link ContentControlDateStorageFormat}.
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export var ContentControlDateStorageFormat = {
|
|
127
|
+
DateStorageDate: 'date',
|
|
128
|
+
DateStorageDateTime: 'dateTime',
|
|
129
|
+
DateStorageText: 'text',
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Checkbox symbol (`w14:checkedState` / `w14:uncheckedState`) — mutable stable identity.
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
var ContentControlCheckBoxState = /** @class */ (function () {
|
|
136
|
+
/** @private */
|
|
137
|
+
function ContentControlCheckBoxState(init) {
|
|
138
|
+
this.fontValue = init != null ? init.font : undefined;
|
|
139
|
+
this.valueValue = init != null ? init.value : undefined;
|
|
140
|
+
this.onChange = undefined;
|
|
141
|
+
}
|
|
142
|
+
/** @private */
|
|
143
|
+
ContentControlCheckBoxState.prototype.bind = function (onChange) {
|
|
144
|
+
this.onChange = onChange;
|
|
145
|
+
};
|
|
146
|
+
ContentControlCheckBoxState.prototype.dirty = function () {
|
|
147
|
+
if (this.onChange !== undefined) {
|
|
148
|
+
this.onChange();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
Object.defineProperty(ContentControlCheckBoxState.prototype, "font", {
|
|
152
|
+
/** Font name for the checkbox glyph. @public */
|
|
153
|
+
get: function () {
|
|
154
|
+
return this.fontValue;
|
|
155
|
+
},
|
|
156
|
+
set: function (value) {
|
|
157
|
+
this.fontValue = value;
|
|
158
|
+
this.dirty();
|
|
159
|
+
},
|
|
160
|
+
enumerable: true,
|
|
161
|
+
configurable: true
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(ContentControlCheckBoxState.prototype, "value", {
|
|
164
|
+
/** Glyph code point / short-hex value. @public */
|
|
165
|
+
get: function () {
|
|
166
|
+
return this.valueValue;
|
|
167
|
+
},
|
|
168
|
+
set: function (value) {
|
|
169
|
+
this.valueValue = value;
|
|
170
|
+
this.dirty();
|
|
171
|
+
},
|
|
172
|
+
enumerable: true,
|
|
173
|
+
configurable: true
|
|
174
|
+
});
|
|
175
|
+
return ContentControlCheckBoxState;
|
|
176
|
+
}());
|
|
177
|
+
export { ContentControlCheckBoxState };
|
|
178
|
+
/**
|
|
179
|
+
* Combo-box or drop-down list entry.
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
var ContentControlListItem = /** @class */ (function () {
|
|
183
|
+
/** @public */
|
|
184
|
+
function ContentControlListItem() {
|
|
185
|
+
this.displayTextValue = undefined;
|
|
186
|
+
this.valueValue = undefined;
|
|
187
|
+
this.onChange = undefined;
|
|
188
|
+
}
|
|
189
|
+
/** @private */
|
|
190
|
+
ContentControlListItem.prototype.bind = function (onChange) {
|
|
191
|
+
this.onChange = onChange;
|
|
192
|
+
};
|
|
193
|
+
ContentControlListItem.prototype.dirty = function () {
|
|
194
|
+
if (this.onChange !== undefined) {
|
|
195
|
+
this.onChange();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
Object.defineProperty(ContentControlListItem.prototype, "displayText", {
|
|
199
|
+
/** Display label. @public */
|
|
200
|
+
get: function () {
|
|
201
|
+
return this.displayTextValue;
|
|
202
|
+
},
|
|
203
|
+
set: function (value) {
|
|
204
|
+
this.displayTextValue = value;
|
|
205
|
+
this.dirty();
|
|
206
|
+
},
|
|
207
|
+
enumerable: true,
|
|
208
|
+
configurable: true
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(ContentControlListItem.prototype, "value", {
|
|
211
|
+
/** Stored value. @public */
|
|
212
|
+
get: function () {
|
|
213
|
+
return this.valueValue;
|
|
214
|
+
},
|
|
215
|
+
set: function (value) {
|
|
216
|
+
this.valueValue = value;
|
|
217
|
+
this.dirty();
|
|
218
|
+
},
|
|
219
|
+
enumerable: true,
|
|
220
|
+
configurable: true
|
|
221
|
+
});
|
|
222
|
+
return ContentControlListItem;
|
|
223
|
+
}());
|
|
224
|
+
export { ContentControlListItem };
|
|
225
|
+
/**
|
|
226
|
+
* Mutable list of {@link ContentControlListItem} with stable identity.
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
var ContentControlListItemCollection = /** @class */ (function () {
|
|
230
|
+
/** @private */
|
|
231
|
+
function ContentControlListItemCollection(items) {
|
|
232
|
+
this.items = items != null ? items.slice() : [];
|
|
233
|
+
this.onChange = undefined;
|
|
234
|
+
}
|
|
235
|
+
/** @private */
|
|
236
|
+
ContentControlListItemCollection.prototype.bind = function (onChange) {
|
|
237
|
+
this.onChange = onChange;
|
|
238
|
+
for (var i = 0; i < this.items.length; i++) {
|
|
239
|
+
this.items[i].bind(onChange);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
ContentControlListItemCollection.prototype.dirty = function () {
|
|
243
|
+
if (this.onChange !== undefined) {
|
|
244
|
+
this.onChange();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
Object.defineProperty(ContentControlListItemCollection.prototype, "count", {
|
|
248
|
+
/** Number of list items. @public */
|
|
249
|
+
get: function () {
|
|
250
|
+
return this.items.length;
|
|
251
|
+
},
|
|
252
|
+
enumerable: true,
|
|
253
|
+
configurable: true
|
|
254
|
+
});
|
|
255
|
+
/** Item at zero-based index. @public */
|
|
256
|
+
ContentControlListItemCollection.prototype.getItem = function (index) {
|
|
257
|
+
if (index < 0 || index >= this.items.length) {
|
|
258
|
+
throw new RangeError('List item index out of range');
|
|
259
|
+
}
|
|
260
|
+
return this.items[index];
|
|
261
|
+
};
|
|
262
|
+
/** Snapshot array (copy). @public */
|
|
263
|
+
ContentControlListItemCollection.prototype.toArray = function () {
|
|
264
|
+
return this.items.slice();
|
|
265
|
+
};
|
|
266
|
+
/** Add a list item. @public */
|
|
267
|
+
ContentControlListItemCollection.prototype.add = function (item) {
|
|
268
|
+
if (this.onChange !== undefined) {
|
|
269
|
+
item.bind(this.onChange);
|
|
270
|
+
}
|
|
271
|
+
this.items.push(item);
|
|
272
|
+
this.dirty();
|
|
273
|
+
};
|
|
274
|
+
/** Remove all items. @public */
|
|
275
|
+
ContentControlListItemCollection.prototype.clear = function () {
|
|
276
|
+
this.items.length = 0;
|
|
277
|
+
this.dirty();
|
|
278
|
+
};
|
|
279
|
+
/** @private */
|
|
280
|
+
ContentControlListItemCollection.prototype.asReadonly = function () {
|
|
281
|
+
return this.items;
|
|
282
|
+
};
|
|
283
|
+
return ContentControlListItemCollection;
|
|
284
|
+
}());
|
|
285
|
+
export { ContentControlListItemCollection };
|
|
286
|
+
function locksFromWire(lock) {
|
|
287
|
+
if (lock === 'sdtLocked') {
|
|
288
|
+
return { lockContentControl: true, lockContents: false };
|
|
289
|
+
}
|
|
290
|
+
if (lock === 'contentLocked') {
|
|
291
|
+
return { lockContentControl: false, lockContents: true };
|
|
292
|
+
}
|
|
293
|
+
if (lock === 'sdtContentLocked') {
|
|
294
|
+
return { lockContentControl: true, lockContents: true };
|
|
295
|
+
}
|
|
296
|
+
return { lockContentControl: false, lockContents: false };
|
|
297
|
+
}
|
|
298
|
+
function locksToWire(lockContentControl, lockContents) {
|
|
299
|
+
if (lockContentControl && lockContents) {
|
|
300
|
+
return 'sdtContentLocked';
|
|
301
|
+
}
|
|
302
|
+
if (lockContentControl) {
|
|
303
|
+
return 'sdtLocked';
|
|
304
|
+
}
|
|
305
|
+
if (lockContents) {
|
|
306
|
+
return 'contentLocked';
|
|
307
|
+
}
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Structured document tag properties (`w:sdtPr`).
|
|
312
|
+
*
|
|
313
|
+
* @public
|
|
314
|
+
*/
|
|
315
|
+
var ContentControlProperties = /** @class */ (function () {
|
|
316
|
+
/**
|
|
317
|
+
* @private
|
|
318
|
+
*/
|
|
319
|
+
function ContentControlProperties(init) {
|
|
320
|
+
var _this = this;
|
|
321
|
+
var src = init != null ? init : {};
|
|
322
|
+
this.tagValue = src.tag;
|
|
323
|
+
this.titleValue = src.title;
|
|
324
|
+
this.idValue = src.id;
|
|
325
|
+
var fromLock = src.lock !== undefined
|
|
326
|
+
? locksFromWire(src.lock)
|
|
327
|
+
: {
|
|
328
|
+
lockContentControl: src.lockContentControl === true,
|
|
329
|
+
lockContents: src.lockContents === true,
|
|
330
|
+
};
|
|
331
|
+
this.lockContentControlValue = fromLock.lockContentControl;
|
|
332
|
+
this.lockContentsValue = fromLock.lockContents;
|
|
333
|
+
this.placeholderDocPartValue = src.placeholderDocPart;
|
|
334
|
+
this.dataBindingValue = src.dataBinding;
|
|
335
|
+
this.typeValue = src.type;
|
|
336
|
+
this.temporaryValue = src.temporary === true;
|
|
337
|
+
this.appearanceValue = src.appearance;
|
|
338
|
+
this.colorValue = src.color;
|
|
339
|
+
this.themeColorValue = src.themeColor;
|
|
340
|
+
this.themeTintValue = src.themeTint;
|
|
341
|
+
this.themeShadeValue = src.themeShade;
|
|
342
|
+
this.isCheckedValue = src.isChecked === true;
|
|
343
|
+
this.checkedStateValue =
|
|
344
|
+
src.checkedState != null
|
|
345
|
+
? src.checkedState
|
|
346
|
+
: new ContentControlCheckBoxState(src.type === 'checkbox'
|
|
347
|
+
? { font: DEFAULT_CHECKBOX_FONT, value: DEFAULT_CHECKED_SYMBOL }
|
|
348
|
+
: undefined);
|
|
349
|
+
this.uncheckedStateValue =
|
|
350
|
+
src.uncheckedState != null
|
|
351
|
+
? src.uncheckedState
|
|
352
|
+
: new ContentControlCheckBoxState(src.type === 'checkbox'
|
|
353
|
+
? { font: DEFAULT_CHECKBOX_FONT, value: DEFAULT_UNCHECKED_SYMBOL }
|
|
354
|
+
: undefined);
|
|
355
|
+
this.fullDateValue = src.fullDate;
|
|
356
|
+
this.dateDisplayFormatValue = src.dateDisplayFormat;
|
|
357
|
+
this.dateDisplayLocaleValue = src.dateDisplayLocale;
|
|
358
|
+
this.dateStorageFormatValue = src.dateStorageFormat;
|
|
359
|
+
this.dateCalendarTypeValue = src.dateCalendarType;
|
|
360
|
+
this.contentControlListItemsValue = new ContentControlListItemCollection(src.listItems);
|
|
361
|
+
this.lastValueValue = src.lastValue;
|
|
362
|
+
this.multilineValue = src.multiline;
|
|
363
|
+
this.residualChildrenValue = src.residualChildren != null ? src.residualChildren : [];
|
|
364
|
+
this.leftoverAttributesValue =
|
|
365
|
+
src.leftoverAttributes != null ? src.leftoverAttributes : [];
|
|
366
|
+
this.namespaceDeclarationsValue =
|
|
367
|
+
src.namespaceDeclarations != null ? src.namespaceDeclarations : [];
|
|
368
|
+
this.owner = undefined;
|
|
369
|
+
var mark = function () {
|
|
370
|
+
_this.markDirty();
|
|
371
|
+
};
|
|
372
|
+
this.checkedStateValue.bind(mark);
|
|
373
|
+
this.uncheckedStateValue.bind(mark);
|
|
374
|
+
this.contentControlListItemsValue.bind(mark);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* @private
|
|
378
|
+
* Bind owning control so property sets rebuild `sdtPr` on save.
|
|
379
|
+
*/
|
|
380
|
+
ContentControlProperties.prototype.bindOwner = function (owner) {
|
|
381
|
+
this.owner = owner;
|
|
382
|
+
};
|
|
383
|
+
ContentControlProperties.prototype.markDirty = function () {
|
|
384
|
+
if (this.owner !== undefined) {
|
|
385
|
+
this.owner.markSdtPrDirty();
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Drop type-specific payloads that do not belong to `type`.
|
|
390
|
+
*/
|
|
391
|
+
ContentControlProperties.prototype.clearPayloadsForType = function (type) {
|
|
392
|
+
if (type !== 'checkbox') {
|
|
393
|
+
this.isCheckedValue = false;
|
|
394
|
+
this.checkedStateValue.font = undefined;
|
|
395
|
+
this.checkedStateValue.value = undefined;
|
|
396
|
+
this.uncheckedStateValue.font = undefined;
|
|
397
|
+
this.uncheckedStateValue.value = undefined;
|
|
398
|
+
}
|
|
399
|
+
if (type !== 'date') {
|
|
400
|
+
this.fullDateValue = undefined;
|
|
401
|
+
this.dateDisplayFormatValue = undefined;
|
|
402
|
+
this.dateDisplayLocaleValue = undefined;
|
|
403
|
+
this.dateStorageFormatValue = undefined;
|
|
404
|
+
this.dateCalendarTypeValue = undefined;
|
|
405
|
+
}
|
|
406
|
+
if (type !== 'comboBox' && type !== 'dropDownList') {
|
|
407
|
+
this.contentControlListItemsValue.clear();
|
|
408
|
+
this.lastValueValue = undefined;
|
|
409
|
+
}
|
|
410
|
+
if (type !== 'plainText') {
|
|
411
|
+
this.multilineValue = undefined;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
Object.defineProperty(ContentControlProperties.prototype, "tag", {
|
|
415
|
+
/**
|
|
416
|
+
* Gets or sets the programmatic tag used to identify this content control in code.
|
|
417
|
+
*
|
|
418
|
+
* If undefined, no tag is explicitly specified.
|
|
419
|
+
*
|
|
420
|
+
* @public
|
|
421
|
+
*/
|
|
422
|
+
get: function () {
|
|
423
|
+
return this.tagValue;
|
|
424
|
+
},
|
|
425
|
+
set: function (value) {
|
|
426
|
+
this.tagValue = value;
|
|
427
|
+
this.markDirty();
|
|
428
|
+
},
|
|
429
|
+
enumerable: true,
|
|
430
|
+
configurable: true
|
|
431
|
+
});
|
|
432
|
+
Object.defineProperty(ContentControlProperties.prototype, "title", {
|
|
433
|
+
/**
|
|
434
|
+
* Gets or sets the friendly display name shown as the content-control title in Word.
|
|
435
|
+
*
|
|
436
|
+
* If undefined, no title is explicitly specified.
|
|
437
|
+
*
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
get: function () {
|
|
441
|
+
return this.titleValue;
|
|
442
|
+
},
|
|
443
|
+
set: function (value) {
|
|
444
|
+
this.titleValue = value;
|
|
445
|
+
this.markDirty();
|
|
446
|
+
},
|
|
447
|
+
enumerable: true,
|
|
448
|
+
configurable: true
|
|
449
|
+
});
|
|
450
|
+
Object.defineProperty(ContentControlProperties.prototype, "id", {
|
|
451
|
+
/**
|
|
452
|
+
* @private
|
|
453
|
+
* Numeric id (`w:sdtPr/w:id/@w:val`). Preserve-only identity from load or
|
|
454
|
+
* author options — not a general post-create editing knob.
|
|
455
|
+
*/
|
|
456
|
+
get: function () {
|
|
457
|
+
return this.idValue;
|
|
458
|
+
},
|
|
459
|
+
enumerable: true,
|
|
460
|
+
configurable: true
|
|
461
|
+
});
|
|
462
|
+
Object.defineProperty(ContentControlProperties.prototype, "lockContentControl", {
|
|
463
|
+
/**
|
|
464
|
+
* Gets or sets whether the content-control definition is locked.
|
|
465
|
+
* @public
|
|
466
|
+
*/
|
|
467
|
+
get: function () {
|
|
468
|
+
return this.lockContentControlValue;
|
|
469
|
+
},
|
|
470
|
+
set: function (value) {
|
|
471
|
+
this.lockContentControlValue = value === true;
|
|
472
|
+
if (this.lockContentControlValue) {
|
|
473
|
+
this.temporaryValue = false;
|
|
474
|
+
}
|
|
475
|
+
this.markDirty();
|
|
476
|
+
},
|
|
477
|
+
enumerable: true,
|
|
478
|
+
configurable: true
|
|
479
|
+
});
|
|
480
|
+
Object.defineProperty(ContentControlProperties.prototype, "lockContents", {
|
|
481
|
+
/**
|
|
482
|
+
* Gets or sets whether the content inside the control is locked.
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
485
|
+
get: function () {
|
|
486
|
+
return this.lockContentsValue;
|
|
487
|
+
},
|
|
488
|
+
set: function (value) {
|
|
489
|
+
this.lockContentsValue = value === true;
|
|
490
|
+
this.markDirty();
|
|
491
|
+
},
|
|
492
|
+
enumerable: true,
|
|
493
|
+
configurable: true
|
|
494
|
+
});
|
|
495
|
+
Object.defineProperty(ContentControlProperties.prototype, "lockWire", {
|
|
496
|
+
/**
|
|
497
|
+
* @private
|
|
498
|
+
* Combined ST_Lock wire value for serialize.
|
|
499
|
+
*/
|
|
500
|
+
get: function () {
|
|
501
|
+
return locksToWire(this.lockContentControlValue, this.lockContentsValue);
|
|
502
|
+
},
|
|
503
|
+
enumerable: true,
|
|
504
|
+
configurable: true
|
|
505
|
+
});
|
|
506
|
+
Object.defineProperty(ContentControlProperties.prototype, "placeholderDocPart", {
|
|
507
|
+
/**
|
|
508
|
+
* @private
|
|
509
|
+
* Placeholder document-part name
|
|
510
|
+
* (`w:sdtPr/w:placeholder/w:docPart/@w:val`).
|
|
511
|
+
*/
|
|
512
|
+
get: function () {
|
|
513
|
+
return this.placeholderDocPartValue;
|
|
514
|
+
},
|
|
515
|
+
set: function (value) {
|
|
516
|
+
this.placeholderDocPartValue = value;
|
|
517
|
+
this.markDirty();
|
|
518
|
+
},
|
|
519
|
+
enumerable: true,
|
|
520
|
+
configurable: true
|
|
521
|
+
});
|
|
522
|
+
Object.defineProperty(ContentControlProperties.prototype, "dataBinding", {
|
|
523
|
+
/**
|
|
524
|
+
* @private
|
|
525
|
+
* Custom XML data binding metadata. Detect/preserve only — never resolved
|
|
526
|
+
* against a store or network; no public setter.
|
|
527
|
+
*/
|
|
528
|
+
get: function () {
|
|
529
|
+
return this.dataBindingValue;
|
|
530
|
+
},
|
|
531
|
+
enumerable: true,
|
|
532
|
+
configurable: true
|
|
533
|
+
});
|
|
534
|
+
Object.defineProperty(ContentControlProperties.prototype, "type", {
|
|
535
|
+
/**
|
|
536
|
+
* Gets or sets the content-control kind.
|
|
537
|
+
* @public
|
|
538
|
+
*/
|
|
539
|
+
get: function () {
|
|
540
|
+
return this.typeValue;
|
|
541
|
+
},
|
|
542
|
+
set: function (value) {
|
|
543
|
+
requireAuthorableType(value);
|
|
544
|
+
this.typeValue = value;
|
|
545
|
+
this.clearPayloadsForType(value);
|
|
546
|
+
this.markDirty();
|
|
547
|
+
},
|
|
548
|
+
enumerable: true,
|
|
549
|
+
configurable: true
|
|
550
|
+
});
|
|
551
|
+
Object.defineProperty(ContentControlProperties.prototype, "isTemporary", {
|
|
552
|
+
/**
|
|
553
|
+
* Gets or sets whether the control is removed after contents are edited once (`w:temporary`).
|
|
554
|
+
* @public
|
|
555
|
+
*/
|
|
556
|
+
get: function () {
|
|
557
|
+
return this.temporaryValue;
|
|
558
|
+
},
|
|
559
|
+
set: function (value) {
|
|
560
|
+
this.temporaryValue = value === true;
|
|
561
|
+
if (this.temporaryValue) {
|
|
562
|
+
this.lockContentControlValue = false;
|
|
563
|
+
}
|
|
564
|
+
this.markDirty();
|
|
565
|
+
},
|
|
566
|
+
enumerable: true,
|
|
567
|
+
configurable: true
|
|
568
|
+
});
|
|
569
|
+
Object.defineProperty(ContentControlProperties.prototype, "temporary", {
|
|
570
|
+
/**
|
|
571
|
+
* @private Compatibility alias for load/serialize paths that used `temporary`.
|
|
572
|
+
*/
|
|
573
|
+
get: function () {
|
|
574
|
+
return this.temporaryValue;
|
|
575
|
+
},
|
|
576
|
+
set: function (value) {
|
|
577
|
+
this.isTemporary = value === true;
|
|
578
|
+
},
|
|
579
|
+
enumerable: true,
|
|
580
|
+
configurable: true
|
|
581
|
+
});
|
|
582
|
+
Object.defineProperty(ContentControlProperties.prototype, "appearance", {
|
|
583
|
+
/**
|
|
584
|
+
* Gets or sets how the control chrome is shown.
|
|
585
|
+
* @public
|
|
586
|
+
*/
|
|
587
|
+
get: function () {
|
|
588
|
+
return this.appearanceValue;
|
|
589
|
+
},
|
|
590
|
+
set: function (value) {
|
|
591
|
+
this.appearanceValue = value;
|
|
592
|
+
this.markDirty();
|
|
593
|
+
},
|
|
594
|
+
enumerable: true,
|
|
595
|
+
configurable: true
|
|
596
|
+
});
|
|
597
|
+
Object.defineProperty(ContentControlProperties.prototype, "color", {
|
|
598
|
+
/**
|
|
599
|
+
* Gets or sets the border/chrome color (`Color` API).
|
|
600
|
+
* @public
|
|
601
|
+
*/
|
|
602
|
+
get: function () {
|
|
603
|
+
return this.colorValue;
|
|
604
|
+
},
|
|
605
|
+
set: function (value) {
|
|
606
|
+
this.colorValue = value;
|
|
607
|
+
this.markDirty();
|
|
608
|
+
},
|
|
609
|
+
enumerable: true,
|
|
610
|
+
configurable: true
|
|
611
|
+
});
|
|
612
|
+
Object.defineProperty(ContentControlProperties.prototype, "themeColor", {
|
|
613
|
+
/** @private */
|
|
614
|
+
get: function () {
|
|
615
|
+
return this.themeColorValue;
|
|
616
|
+
},
|
|
617
|
+
enumerable: true,
|
|
618
|
+
configurable: true
|
|
619
|
+
});
|
|
620
|
+
Object.defineProperty(ContentControlProperties.prototype, "themeTint", {
|
|
621
|
+
/** @private */
|
|
622
|
+
get: function () {
|
|
623
|
+
return this.themeTintValue;
|
|
624
|
+
},
|
|
625
|
+
enumerable: true,
|
|
626
|
+
configurable: true
|
|
627
|
+
});
|
|
628
|
+
Object.defineProperty(ContentControlProperties.prototype, "themeShade", {
|
|
629
|
+
/** @private */
|
|
630
|
+
get: function () {
|
|
631
|
+
return this.themeShadeValue;
|
|
632
|
+
},
|
|
633
|
+
enumerable: true,
|
|
634
|
+
configurable: true
|
|
635
|
+
});
|
|
636
|
+
Object.defineProperty(ContentControlProperties.prototype, "isChecked", {
|
|
637
|
+
/**
|
|
638
|
+
* Gets or sets whether a checkbox control is checked.
|
|
639
|
+
* @public
|
|
640
|
+
*/
|
|
641
|
+
get: function () {
|
|
642
|
+
return this.isCheckedValue;
|
|
643
|
+
},
|
|
644
|
+
set: function (value) {
|
|
645
|
+
this.isCheckedValue = value === true;
|
|
646
|
+
if (this.typeValue !== 'checkbox') {
|
|
647
|
+
this.typeValue = 'checkbox';
|
|
648
|
+
this.clearPayloadsForType('checkbox');
|
|
649
|
+
this.isCheckedValue = value === true;
|
|
650
|
+
}
|
|
651
|
+
this.markDirty();
|
|
652
|
+
if (this.owner !== undefined) {
|
|
653
|
+
this.owner.synchronizeCheckboxContent();
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
enumerable: true,
|
|
657
|
+
configurable: true
|
|
658
|
+
});
|
|
659
|
+
Object.defineProperty(ContentControlProperties.prototype, "checkedState", {
|
|
660
|
+
/**
|
|
661
|
+
* Checked-state symbol (stable identity).
|
|
662
|
+
* @public
|
|
663
|
+
*/
|
|
664
|
+
get: function () {
|
|
665
|
+
return this.checkedStateValue;
|
|
666
|
+
},
|
|
667
|
+
enumerable: true,
|
|
668
|
+
configurable: true
|
|
669
|
+
});
|
|
670
|
+
Object.defineProperty(ContentControlProperties.prototype, "uncheckedState", {
|
|
671
|
+
/**
|
|
672
|
+
* Unchecked-state symbol (stable identity).
|
|
673
|
+
* @public
|
|
674
|
+
*/
|
|
675
|
+
get: function () {
|
|
676
|
+
return this.uncheckedStateValue;
|
|
677
|
+
},
|
|
678
|
+
enumerable: true,
|
|
679
|
+
configurable: true
|
|
680
|
+
});
|
|
681
|
+
Object.defineProperty(ContentControlProperties.prototype, "fullDate", {
|
|
682
|
+
/**
|
|
683
|
+
* Full date/time stored value.
|
|
684
|
+
* @public
|
|
685
|
+
*/
|
|
686
|
+
get: function () {
|
|
687
|
+
return this.fullDateValue;
|
|
688
|
+
},
|
|
689
|
+
set: function (value) {
|
|
690
|
+
this.fullDateValue = value;
|
|
691
|
+
if (value !== undefined && this.typeValue !== 'date') {
|
|
692
|
+
this.typeValue = 'date';
|
|
693
|
+
this.clearPayloadsForType('date');
|
|
694
|
+
this.fullDateValue = value;
|
|
695
|
+
}
|
|
696
|
+
this.markDirty();
|
|
697
|
+
},
|
|
698
|
+
enumerable: true,
|
|
699
|
+
configurable: true
|
|
700
|
+
});
|
|
701
|
+
Object.defineProperty(ContentControlProperties.prototype, "dateDisplayFormat", {
|
|
702
|
+
/**
|
|
703
|
+
* Display format pattern for the date.
|
|
704
|
+
* @public
|
|
705
|
+
*/
|
|
706
|
+
get: function () {
|
|
707
|
+
return this.dateDisplayFormatValue;
|
|
708
|
+
},
|
|
709
|
+
set: function (value) {
|
|
710
|
+
this.dateDisplayFormatValue = value;
|
|
711
|
+
if (value !== undefined && this.typeValue !== 'date') {
|
|
712
|
+
this.typeValue = 'date';
|
|
713
|
+
this.clearPayloadsForType('date');
|
|
714
|
+
this.dateDisplayFormatValue = value;
|
|
715
|
+
}
|
|
716
|
+
this.markDirty();
|
|
717
|
+
},
|
|
718
|
+
enumerable: true,
|
|
719
|
+
configurable: true
|
|
720
|
+
});
|
|
721
|
+
Object.defineProperty(ContentControlProperties.prototype, "dateDisplayLocale", {
|
|
722
|
+
/**
|
|
723
|
+
* Locale used for date display.
|
|
724
|
+
* @public
|
|
725
|
+
*/
|
|
726
|
+
get: function () {
|
|
727
|
+
return this.dateDisplayLocaleValue;
|
|
728
|
+
},
|
|
729
|
+
set: function (value) {
|
|
730
|
+
this.dateDisplayLocaleValue = value;
|
|
731
|
+
if (value !== undefined && this.typeValue !== 'date') {
|
|
732
|
+
this.typeValue = 'date';
|
|
733
|
+
this.clearPayloadsForType('date');
|
|
734
|
+
this.dateDisplayLocaleValue = value;
|
|
735
|
+
}
|
|
736
|
+
this.markDirty();
|
|
737
|
+
},
|
|
738
|
+
enumerable: true,
|
|
739
|
+
configurable: true
|
|
740
|
+
});
|
|
741
|
+
Object.defineProperty(ContentControlProperties.prototype, "dateStorageFormat", {
|
|
742
|
+
/**
|
|
743
|
+
* How mapped date data is stored.
|
|
744
|
+
* @public
|
|
745
|
+
*/
|
|
746
|
+
get: function () {
|
|
747
|
+
return this.dateStorageFormatValue;
|
|
748
|
+
},
|
|
749
|
+
set: function (value) {
|
|
750
|
+
this.dateStorageFormatValue = value;
|
|
751
|
+
if (value !== undefined && this.typeValue !== 'date') {
|
|
752
|
+
this.typeValue = 'date';
|
|
753
|
+
this.clearPayloadsForType('date');
|
|
754
|
+
this.dateStorageFormatValue = value;
|
|
755
|
+
}
|
|
756
|
+
this.markDirty();
|
|
757
|
+
},
|
|
758
|
+
enumerable: true,
|
|
759
|
+
configurable: true
|
|
760
|
+
});
|
|
761
|
+
Object.defineProperty(ContentControlProperties.prototype, "dateCalendarType", {
|
|
762
|
+
/**
|
|
763
|
+
* Calendar system for the date control.
|
|
764
|
+
* @public
|
|
765
|
+
*/
|
|
766
|
+
get: function () {
|
|
767
|
+
return this.dateCalendarTypeValue;
|
|
768
|
+
},
|
|
769
|
+
set: function (value) {
|
|
770
|
+
this.dateCalendarTypeValue = value;
|
|
771
|
+
if (value !== undefined && this.typeValue !== 'date') {
|
|
772
|
+
this.typeValue = 'date';
|
|
773
|
+
this.clearPayloadsForType('date');
|
|
774
|
+
this.dateCalendarTypeValue = value;
|
|
775
|
+
}
|
|
776
|
+
this.markDirty();
|
|
777
|
+
},
|
|
778
|
+
enumerable: true,
|
|
779
|
+
configurable: true
|
|
780
|
+
});
|
|
781
|
+
Object.defineProperty(ContentControlProperties.prototype, "contentControlListItems", {
|
|
782
|
+
/**
|
|
783
|
+
* Combo-box / drop-down list items (stable identity).
|
|
784
|
+
* @public
|
|
785
|
+
*/
|
|
786
|
+
get: function () {
|
|
787
|
+
return this.contentControlListItemsValue;
|
|
788
|
+
},
|
|
789
|
+
enumerable: true,
|
|
790
|
+
configurable: true
|
|
791
|
+
});
|
|
792
|
+
Object.defineProperty(ContentControlProperties.prototype, "lastValue", {
|
|
793
|
+
/**
|
|
794
|
+
* Last selected list value.
|
|
795
|
+
* @public
|
|
796
|
+
*/
|
|
797
|
+
get: function () {
|
|
798
|
+
return this.lastValueValue;
|
|
799
|
+
},
|
|
800
|
+
set: function (value) {
|
|
801
|
+
this.lastValueValue = value;
|
|
802
|
+
if (value !== undefined) {
|
|
803
|
+
if (this.typeValue !== 'comboBox' && this.typeValue !== 'dropDownList') {
|
|
804
|
+
this.typeValue = 'dropDownList';
|
|
805
|
+
this.clearPayloadsForType(this.typeValue);
|
|
806
|
+
this.lastValueValue = value;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
this.markDirty();
|
|
810
|
+
},
|
|
811
|
+
enumerable: true,
|
|
812
|
+
configurable: true
|
|
813
|
+
});
|
|
814
|
+
Object.defineProperty(ContentControlProperties.prototype, "multiline", {
|
|
815
|
+
/**
|
|
816
|
+
* Whether a plain-text control accepts multiple lines (`w:text/@w:multiLine`).
|
|
817
|
+
* @public
|
|
818
|
+
*/
|
|
819
|
+
get: function () {
|
|
820
|
+
return this.multilineValue;
|
|
821
|
+
},
|
|
822
|
+
set: function (value) {
|
|
823
|
+
this.multilineValue = value;
|
|
824
|
+
if (value !== undefined) {
|
|
825
|
+
this.typeValue = 'plainText';
|
|
826
|
+
this.clearPayloadsForType('plainText');
|
|
827
|
+
this.multilineValue = value;
|
|
828
|
+
}
|
|
829
|
+
this.markDirty();
|
|
830
|
+
},
|
|
831
|
+
enumerable: true,
|
|
832
|
+
configurable: true
|
|
833
|
+
});
|
|
834
|
+
Object.defineProperty(ContentControlProperties.prototype, "residualChildren", {
|
|
835
|
+
/**
|
|
836
|
+
* @private
|
|
837
|
+
* Unmodeled `sdtPr` children (including extra kind markers). */
|
|
838
|
+
get: function () {
|
|
839
|
+
return this.residualChildrenValue;
|
|
840
|
+
},
|
|
841
|
+
enumerable: true,
|
|
842
|
+
configurable: true
|
|
843
|
+
});
|
|
844
|
+
Object.defineProperty(ContentControlProperties.prototype, "leftoverAttributes", {
|
|
845
|
+
/**
|
|
846
|
+
* @private
|
|
847
|
+
* Leftover attributes on `sdtPr` itself. */
|
|
848
|
+
get: function () {
|
|
849
|
+
return this.leftoverAttributesValue;
|
|
850
|
+
},
|
|
851
|
+
enumerable: true,
|
|
852
|
+
configurable: true
|
|
853
|
+
});
|
|
854
|
+
Object.defineProperty(ContentControlProperties.prototype, "namespaceDeclarations", {
|
|
855
|
+
/**
|
|
856
|
+
* @private
|
|
857
|
+
* Namespace declarations on `sdtPr`. */
|
|
858
|
+
get: function () {
|
|
859
|
+
return this.namespaceDeclarationsValue;
|
|
860
|
+
},
|
|
861
|
+
enumerable: true,
|
|
862
|
+
configurable: true
|
|
863
|
+
});
|
|
864
|
+
return ContentControlProperties;
|
|
865
|
+
}());
|
|
866
|
+
export { ContentControlProperties };
|
|
867
|
+
// ── XML helpers ─────────────────────────────────────────────────────────────
|
|
868
|
+
function isWordMl2010(el, localName) {
|
|
869
|
+
return el.namespaceUri === WORDML_2010_NAMESPACE && el.localName === localName;
|
|
870
|
+
}
|
|
871
|
+
function isWordMl2012(el, localName) {
|
|
872
|
+
return el.namespaceUri === WORDML_2012_NAMESPACE && el.localName === localName;
|
|
873
|
+
}
|
|
874
|
+
function attributeByLocalName(el, localName) {
|
|
875
|
+
var __ts33_0;
|
|
876
|
+
return ((__ts33_0 = el.attributes.find(function (a) { return a.localName === localName; })), __ts33_0 == null ? undefined : __ts33_0.value);
|
|
877
|
+
}
|
|
878
|
+
function wmlAttribute(el, localName) {
|
|
879
|
+
var __ts33_1;
|
|
880
|
+
return ((__ts33_1 = el.attributes.find(function (a) { return a.localName === localName &&
|
|
881
|
+
(a.namespaceUri === '' || isWmlNamespace(a.namespaceUri) || a.prefix === 'w'); })), __ts33_1 == null ? undefined : __ts33_1.value);
|
|
882
|
+
}
|
|
883
|
+
function wValAttribute(el) {
|
|
884
|
+
return wmlAttribute(el, 'val');
|
|
885
|
+
}
|
|
886
|
+
function anyValAttribute(el) {
|
|
887
|
+
return attributeByLocalName(el, 'val');
|
|
888
|
+
}
|
|
889
|
+
function parseStOnOff(raw) {
|
|
890
|
+
if (raw === undefined || raw.length === 0) {
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
893
|
+
var normalized = raw.trim().toLowerCase();
|
|
894
|
+
if (normalized === 'true' || normalized === '1' || normalized === 'on') {
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
if (normalized === 'false' || normalized === '0' || normalized === 'off') {
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
900
|
+
return undefined;
|
|
901
|
+
}
|
|
902
|
+
function parseDecimalId(raw) {
|
|
903
|
+
if (raw === undefined || !/^\d+$/.test(raw)) {
|
|
904
|
+
return undefined;
|
|
905
|
+
}
|
|
906
|
+
return Number.parseInt(raw, 10);
|
|
907
|
+
}
|
|
908
|
+
function parseLockWire(raw) {
|
|
909
|
+
if (raw === 'sdtLocked' ||
|
|
910
|
+
raw === 'contentLocked' ||
|
|
911
|
+
raw === 'unlocked' ||
|
|
912
|
+
raw === 'sdtContentLocked') {
|
|
913
|
+
return raw;
|
|
914
|
+
}
|
|
915
|
+
return undefined;
|
|
916
|
+
}
|
|
917
|
+
function parseAppearance(raw) {
|
|
918
|
+
if (raw === 'boundingBox' || raw === 'tags' || raw === 'hidden') {
|
|
919
|
+
return raw;
|
|
920
|
+
}
|
|
921
|
+
return undefined;
|
|
922
|
+
}
|
|
923
|
+
function parseDateStorageFormat(raw) {
|
|
924
|
+
if (raw === 'text' || raw === 'date' || raw === 'dateTime') {
|
|
925
|
+
return raw;
|
|
926
|
+
}
|
|
927
|
+
return undefined;
|
|
928
|
+
}
|
|
929
|
+
function parseCalendarType(raw) {
|
|
930
|
+
if (raw === 'gregorian' ||
|
|
931
|
+
raw === 'hijri' ||
|
|
932
|
+
raw === 'hebrew' ||
|
|
933
|
+
raw === 'taiwan' ||
|
|
934
|
+
raw === 'japan' ||
|
|
935
|
+
raw === 'thai' ||
|
|
936
|
+
raw === 'korea' ||
|
|
937
|
+
raw === 'saka' ||
|
|
938
|
+
raw === 'gregorianArabic' ||
|
|
939
|
+
raw === 'gregorianMiddleEastFrench' ||
|
|
940
|
+
raw === 'gregorianTransliteratedEnglish' ||
|
|
941
|
+
raw === 'gregorianTransliteratedFrench' ||
|
|
942
|
+
raw === 'gregorianUsLocale') {
|
|
943
|
+
return raw;
|
|
944
|
+
}
|
|
945
|
+
return undefined;
|
|
946
|
+
}
|
|
947
|
+
function unqualifiedAttribute(el, localName) {
|
|
948
|
+
var __ts33_2;
|
|
949
|
+
return ((__ts33_2 = el.attributes.find(function (a) { return a.localName === localName &&
|
|
950
|
+
(a.namespaceUri === '' ||
|
|
951
|
+
a.prefix === 'w' ||
|
|
952
|
+
a.namespaceUri.includes('wordprocessingml') ||
|
|
953
|
+
a.namespaceUri === WORDML_2010_NAMESPACE ||
|
|
954
|
+
a.namespaceUri === WORDML_2012_NAMESPACE); })), __ts33_2 == null ? undefined : __ts33_2.value);
|
|
955
|
+
}
|
|
956
|
+
function parseDataBinding(element) {
|
|
957
|
+
if (!isWml(element, 'dataBinding')) {
|
|
958
|
+
return undefined;
|
|
959
|
+
}
|
|
960
|
+
var xpath = unqualifiedAttribute(element, 'xpath');
|
|
961
|
+
var storeItemID = unqualifiedAttribute(element, 'storeItemID');
|
|
962
|
+
if (xpath === undefined || xpath.length === 0 || storeItemID === undefined || storeItemID.length === 0) {
|
|
963
|
+
return undefined;
|
|
964
|
+
}
|
|
965
|
+
var prefixMappings = unqualifiedAttribute(element, 'prefixMappings');
|
|
966
|
+
return { prefixMappings: prefixMappings, xpath: xpath, storeItemID: storeItemID };
|
|
967
|
+
}
|
|
968
|
+
function nsAttr(namespaceUri, prefix, localName, value) {
|
|
969
|
+
return { namespaceUri: namespaceUri, localName: localName, prefix: prefix, value: value };
|
|
970
|
+
}
|
|
971
|
+
function nsElement(namespaceUri, prefix, localName, options) {
|
|
972
|
+
var __ts33_3, __ts33_4, __ts33_5;
|
|
973
|
+
return {
|
|
974
|
+
kind: 'element',
|
|
975
|
+
namespaceUri: namespaceUri,
|
|
976
|
+
localName: localName,
|
|
977
|
+
prefix: prefix,
|
|
978
|
+
attributes: ((__ts33_3 = options == null ? undefined : options.attributes), __ts33_3 != null ? __ts33_3 : []),
|
|
979
|
+
namespaceDeclarations: ((__ts33_4 = options == null ? undefined : options.namespaceDeclarations), __ts33_4 != null ? __ts33_4 : []),
|
|
980
|
+
children: ((__ts33_5 = options == null ? undefined : options.children), __ts33_5 != null ? __ts33_5 : []),
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
function serializeOnOffWml(localName, value) {
|
|
984
|
+
if (value) {
|
|
985
|
+
return wmlElement(localName);
|
|
986
|
+
}
|
|
987
|
+
return wmlElement(localName, { attributes: [wmlAttr('val', 'false')] });
|
|
988
|
+
}
|
|
989
|
+
function serializeOnOffNs(namespaceUri, prefix, localName, value) {
|
|
990
|
+
if (value) {
|
|
991
|
+
return nsElement(namespaceUri, prefix, localName);
|
|
992
|
+
}
|
|
993
|
+
return nsElement(namespaceUri, prefix, localName, {
|
|
994
|
+
attributes: [nsAttr(namespaceUri, prefix, 'val', '0')],
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
// ── Kind local-name maps ────────────────────────────────────────────────────
|
|
998
|
+
/** Authorable kinds only — public ContentControlType. */
|
|
999
|
+
var WML_TYPE_LOCAL_TO_TYPE = new Map([
|
|
1000
|
+
['comboBox', 'comboBox'],
|
|
1001
|
+
['date', 'date'],
|
|
1002
|
+
['dropDownList', 'dropDownList'],
|
|
1003
|
+
['picture', 'picture'],
|
|
1004
|
+
['richText', 'richText'],
|
|
1005
|
+
['text', 'plainText'],
|
|
1006
|
+
]);
|
|
1007
|
+
var TYPE_TO_WML_LOCAL = new Map([
|
|
1008
|
+
['comboBox', 'comboBox'],
|
|
1009
|
+
['date', 'date'],
|
|
1010
|
+
['dropDownList', 'dropDownList'],
|
|
1011
|
+
['picture', 'picture'],
|
|
1012
|
+
['richText', 'richText'],
|
|
1013
|
+
['plainText', 'text'],
|
|
1014
|
+
['checkbox', 'checkbox'],
|
|
1015
|
+
]);
|
|
1016
|
+
/** Non-authorable WML kind local names preserved as residual. */
|
|
1017
|
+
var NON_AUTHORABLE_KIND_LOCALS = new Set([
|
|
1018
|
+
'equation',
|
|
1019
|
+
'docPartObj',
|
|
1020
|
+
'docPartList',
|
|
1021
|
+
'citation',
|
|
1022
|
+
'group',
|
|
1023
|
+
'bibliography',
|
|
1024
|
+
]);
|
|
1025
|
+
var AUTHORABLE_TYPES = new Set([
|
|
1026
|
+
'comboBox',
|
|
1027
|
+
'date',
|
|
1028
|
+
'dropDownList',
|
|
1029
|
+
'picture',
|
|
1030
|
+
'richText',
|
|
1031
|
+
'plainText',
|
|
1032
|
+
'checkbox',
|
|
1033
|
+
]);
|
|
1034
|
+
function isWmlTypeLocalName(localName) {
|
|
1035
|
+
return WML_TYPE_LOCAL_TO_TYPE.has(localName) || NON_AUTHORABLE_KIND_LOCALS.has(localName);
|
|
1036
|
+
}
|
|
1037
|
+
function requireAuthorableType(value) {
|
|
1038
|
+
if (value === undefined) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
if (!AUTHORABLE_TYPES.has(value)) {
|
|
1042
|
+
throw new Error("Content control type '" + value + "' is not authorable.");
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
// ── Kind-specific parsers ───────────────────────────────────────────────────
|
|
1046
|
+
function parseListItems(kindEl) {
|
|
1047
|
+
var e_1, _a;
|
|
1048
|
+
var items = [];
|
|
1049
|
+
try {
|
|
1050
|
+
for (var _b = __values(elementChildren(kindEl)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1051
|
+
var child = _c.value;
|
|
1052
|
+
if (!isWml(child, 'listItem')) {
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
var item = new ContentControlListItem();
|
|
1056
|
+
item.displayText = unqualifiedAttribute(child, 'displayText');
|
|
1057
|
+
item.value = unqualifiedAttribute(child, 'value');
|
|
1058
|
+
items.push(item);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1062
|
+
finally {
|
|
1063
|
+
try {
|
|
1064
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1065
|
+
}
|
|
1066
|
+
finally { if (e_1) throw e_1.error; }
|
|
1067
|
+
}
|
|
1068
|
+
return {
|
|
1069
|
+
items: items,
|
|
1070
|
+
lastValue: unqualifiedAttribute(kindEl, 'lastValue'),
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
function parseDateFields(kindEl) {
|
|
1074
|
+
var e_2, _a;
|
|
1075
|
+
var dateDisplayFormat;
|
|
1076
|
+
var dateDisplayLocale;
|
|
1077
|
+
var dateStorageFormat;
|
|
1078
|
+
var dateCalendarType;
|
|
1079
|
+
try {
|
|
1080
|
+
for (var _b = __values(elementChildren(kindEl)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1081
|
+
var child = _c.value;
|
|
1082
|
+
if (isWml(child, 'dateFormat')) {
|
|
1083
|
+
dateDisplayFormat = wValAttribute(child);
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
if (isWml(child, 'lid')) {
|
|
1087
|
+
var lid = wValAttribute(child);
|
|
1088
|
+
if (lid !== undefined) {
|
|
1089
|
+
dateDisplayLocale = localeIdFromBcp47(lid);
|
|
1090
|
+
}
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (isWml(child, 'storeMappedDataAs')) {
|
|
1094
|
+
dateStorageFormat = parseDateStorageFormat(wValAttribute(child));
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
if (isWml(child, 'calendar')) {
|
|
1098
|
+
dateCalendarType = parseCalendarType(wValAttribute(child));
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1103
|
+
finally {
|
|
1104
|
+
try {
|
|
1105
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1106
|
+
}
|
|
1107
|
+
finally { if (e_2) throw e_2.error; }
|
|
1108
|
+
}
|
|
1109
|
+
return {
|
|
1110
|
+
fullDate: unqualifiedAttribute(kindEl, 'fullDate'),
|
|
1111
|
+
dateDisplayFormat: dateDisplayFormat,
|
|
1112
|
+
dateDisplayLocale: dateDisplayLocale,
|
|
1113
|
+
dateStorageFormat: dateStorageFormat,
|
|
1114
|
+
dateCalendarType: dateCalendarType,
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
function parseCheckboxState(el) {
|
|
1118
|
+
return new ContentControlCheckBoxState({
|
|
1119
|
+
font: attributeByLocalName(el, 'font'),
|
|
1120
|
+
value: attributeByLocalName(el, 'val'),
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
function parseCheckboxFields(kindEl) {
|
|
1124
|
+
var e_3, _a;
|
|
1125
|
+
var isChecked = false;
|
|
1126
|
+
var checkedState = new ContentControlCheckBoxState();
|
|
1127
|
+
var uncheckedState = new ContentControlCheckBoxState();
|
|
1128
|
+
try {
|
|
1129
|
+
for (var _b = __values(elementChildren(kindEl)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1130
|
+
var child = _c.value;
|
|
1131
|
+
if (isWordMl2010(child, 'checked')) {
|
|
1132
|
+
var parsed = parseStOnOff(anyValAttribute(child));
|
|
1133
|
+
isChecked = parsed != null ? parsed : true;
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
if (isWordMl2010(child, 'checkedState')) {
|
|
1137
|
+
checkedState = parseCheckboxState(child);
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
if (isWordMl2010(child, 'uncheckedState')) {
|
|
1141
|
+
uncheckedState = parseCheckboxState(child);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1146
|
+
finally {
|
|
1147
|
+
try {
|
|
1148
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1149
|
+
}
|
|
1150
|
+
finally { if (e_3) throw e_3.error; }
|
|
1151
|
+
}
|
|
1152
|
+
return { isChecked: isChecked, checkedState: checkedState, uncheckedState: uncheckedState };
|
|
1153
|
+
}
|
|
1154
|
+
function parseColorFields(el) {
|
|
1155
|
+
var val = attributeByLocalName(el, 'val');
|
|
1156
|
+
return {
|
|
1157
|
+
color: val !== undefined && val.length > 0 ? colorFromWire(val) : undefined,
|
|
1158
|
+
themeColor: attributeByLocalName(el, 'themeColor'),
|
|
1159
|
+
themeTint: attributeByLocalName(el, 'themeTint'),
|
|
1160
|
+
themeShade: attributeByLocalName(el, 'themeShade'),
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
function parseContentControlProperties(sdtPr) {
|
|
1164
|
+
var e_4, _a, e_5, _b;
|
|
1165
|
+
if (sdtPr === undefined || !isWml(sdtPr, 'sdtPr')) {
|
|
1166
|
+
return undefined;
|
|
1167
|
+
}
|
|
1168
|
+
var tag;
|
|
1169
|
+
var title;
|
|
1170
|
+
var id;
|
|
1171
|
+
var lock;
|
|
1172
|
+
var placeholderDocPart;
|
|
1173
|
+
var dataBinding;
|
|
1174
|
+
var type;
|
|
1175
|
+
var temporary;
|
|
1176
|
+
var appearance;
|
|
1177
|
+
var color;
|
|
1178
|
+
var themeColor;
|
|
1179
|
+
var themeTint;
|
|
1180
|
+
var themeShade;
|
|
1181
|
+
var isChecked;
|
|
1182
|
+
var checkedState;
|
|
1183
|
+
var uncheckedState;
|
|
1184
|
+
var fullDate;
|
|
1185
|
+
var dateDisplayFormat;
|
|
1186
|
+
var dateDisplayLocale;
|
|
1187
|
+
var dateStorageFormat;
|
|
1188
|
+
var dateCalendarType;
|
|
1189
|
+
var listItems;
|
|
1190
|
+
var lastValue;
|
|
1191
|
+
var multiline;
|
|
1192
|
+
var residualChildren = [];
|
|
1193
|
+
var sawAlias = false;
|
|
1194
|
+
var sawTag = false;
|
|
1195
|
+
var sawId = false;
|
|
1196
|
+
var sawLock = false;
|
|
1197
|
+
var sawPlaceholder = false;
|
|
1198
|
+
var sawTemporary = false;
|
|
1199
|
+
var sawDataBinding = false;
|
|
1200
|
+
var sawAppearance = false;
|
|
1201
|
+
var sawColor = false;
|
|
1202
|
+
var sawKind = false;
|
|
1203
|
+
try {
|
|
1204
|
+
for (var _c = __values(elementChildren(sdtPr)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1205
|
+
var child = _d.value;
|
|
1206
|
+
if (isWml(child, 'alias') && !sawAlias) {
|
|
1207
|
+
sawAlias = true;
|
|
1208
|
+
title = wValAttribute(child);
|
|
1209
|
+
continue;
|
|
1210
|
+
}
|
|
1211
|
+
if (isWml(child, 'tag') && !sawTag) {
|
|
1212
|
+
sawTag = true;
|
|
1213
|
+
tag = wValAttribute(child);
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1216
|
+
if (isWml(child, 'id') && !sawId) {
|
|
1217
|
+
sawId = true;
|
|
1218
|
+
id = parseDecimalId(wValAttribute(child));
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
if (isWml(child, 'lock') && !sawLock) {
|
|
1222
|
+
sawLock = true;
|
|
1223
|
+
lock = parseLockWire(wValAttribute(child));
|
|
1224
|
+
continue;
|
|
1225
|
+
}
|
|
1226
|
+
if (isWml(child, 'placeholder') && !sawPlaceholder) {
|
|
1227
|
+
sawPlaceholder = true;
|
|
1228
|
+
try {
|
|
1229
|
+
for (var _e = __values(elementChildren(child)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1230
|
+
var placeholderChild = _f.value;
|
|
1231
|
+
if (isWml(placeholderChild, 'docPart')) {
|
|
1232
|
+
placeholderDocPart = wValAttribute(placeholderChild);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1237
|
+
finally {
|
|
1238
|
+
try {
|
|
1239
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
1240
|
+
}
|
|
1241
|
+
finally { if (e_5) throw e_5.error; }
|
|
1242
|
+
}
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
if (isWml(child, 'temporary') && !sawTemporary) {
|
|
1246
|
+
sawTemporary = true;
|
|
1247
|
+
var parsed = parseStOnOff(wValAttribute(child));
|
|
1248
|
+
temporary = parsed != null ? parsed : true;
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
if (isWml(child, 'dataBinding') && !sawDataBinding) {
|
|
1252
|
+
sawDataBinding = true;
|
|
1253
|
+
var binding = parseDataBinding(child);
|
|
1254
|
+
if (binding !== undefined) {
|
|
1255
|
+
dataBinding = binding;
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
residualChildren.push(child);
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
if (isWordMl2012(child, 'appearance') && !sawAppearance) {
|
|
1262
|
+
sawAppearance = true;
|
|
1263
|
+
var parsed = parseAppearance(anyValAttribute(child));
|
|
1264
|
+
if (parsed !== undefined) {
|
|
1265
|
+
appearance = parsed;
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
residualChildren.push(child);
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
if (isWordMl2012(child, 'color') && !sawColor) {
|
|
1272
|
+
sawColor = true;
|
|
1273
|
+
var parsed = parseColorFields(child);
|
|
1274
|
+
if (parsed.color !== undefined ||
|
|
1275
|
+
parsed.themeColor !== undefined ||
|
|
1276
|
+
parsed.themeTint !== undefined ||
|
|
1277
|
+
parsed.themeShade !== undefined) {
|
|
1278
|
+
color = parsed.color;
|
|
1279
|
+
themeColor = parsed.themeColor;
|
|
1280
|
+
themeTint = parsed.themeTint;
|
|
1281
|
+
themeShade = parsed.themeShade;
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
residualChildren.push(child);
|
|
1285
|
+
continue;
|
|
1286
|
+
}
|
|
1287
|
+
if (isWordMl2010(child, 'checkbox')) {
|
|
1288
|
+
if (!sawKind) {
|
|
1289
|
+
sawKind = true;
|
|
1290
|
+
type = 'checkbox';
|
|
1291
|
+
var cb = parseCheckboxFields(child);
|
|
1292
|
+
isChecked = cb.isChecked;
|
|
1293
|
+
checkedState = cb.checkedState;
|
|
1294
|
+
uncheckedState = cb.uncheckedState;
|
|
1295
|
+
continue;
|
|
1296
|
+
}
|
|
1297
|
+
residualChildren.push(child);
|
|
1298
|
+
continue;
|
|
1299
|
+
}
|
|
1300
|
+
if (isWmlNamespace(child.namespaceUri) && isWmlTypeLocalName(child.localName)) {
|
|
1301
|
+
if (!sawKind) {
|
|
1302
|
+
sawKind = true;
|
|
1303
|
+
if (NON_AUTHORABLE_KIND_LOCALS.has(child.localName)) {
|
|
1304
|
+
residualChildren.push(child);
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
var mapped = WML_TYPE_LOCAL_TO_TYPE.get(child.localName);
|
|
1308
|
+
if (mapped === undefined) {
|
|
1309
|
+
residualChildren.push(child);
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
type = mapped;
|
|
1313
|
+
if (mapped === 'plainText') {
|
|
1314
|
+
multiline = parseStOnOff(wmlAttribute(child, 'multiLine'));
|
|
1315
|
+
}
|
|
1316
|
+
else if (mapped === 'date') {
|
|
1317
|
+
var d = parseDateFields(child);
|
|
1318
|
+
fullDate = d.fullDate;
|
|
1319
|
+
dateDisplayFormat = d.dateDisplayFormat;
|
|
1320
|
+
dateDisplayLocale = d.dateDisplayLocale;
|
|
1321
|
+
dateStorageFormat = d.dateStorageFormat;
|
|
1322
|
+
dateCalendarType = d.dateCalendarType;
|
|
1323
|
+
}
|
|
1324
|
+
else if (mapped === 'comboBox' || mapped === 'dropDownList') {
|
|
1325
|
+
var list = parseListItems(child);
|
|
1326
|
+
listItems = list.items;
|
|
1327
|
+
lastValue = list.lastValue;
|
|
1328
|
+
}
|
|
1329
|
+
continue;
|
|
1330
|
+
}
|
|
1331
|
+
residualChildren.push(child);
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
residualChildren.push(child);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1338
|
+
finally {
|
|
1339
|
+
try {
|
|
1340
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1341
|
+
}
|
|
1342
|
+
finally { if (e_4) throw e_4.error; }
|
|
1343
|
+
}
|
|
1344
|
+
return new ContentControlProperties({
|
|
1345
|
+
tag: tag,
|
|
1346
|
+
title: title,
|
|
1347
|
+
id: id,
|
|
1348
|
+
lock: lock,
|
|
1349
|
+
placeholderDocPart: placeholderDocPart,
|
|
1350
|
+
dataBinding: dataBinding,
|
|
1351
|
+
type: type,
|
|
1352
|
+
temporary: temporary,
|
|
1353
|
+
appearance: appearance,
|
|
1354
|
+
color: color,
|
|
1355
|
+
themeColor: themeColor,
|
|
1356
|
+
themeTint: themeTint,
|
|
1357
|
+
themeShade: themeShade,
|
|
1358
|
+
isChecked: isChecked,
|
|
1359
|
+
checkedState: checkedState,
|
|
1360
|
+
uncheckedState: uncheckedState,
|
|
1361
|
+
fullDate: fullDate,
|
|
1362
|
+
dateDisplayFormat: dateDisplayFormat,
|
|
1363
|
+
dateDisplayLocale: dateDisplayLocale,
|
|
1364
|
+
dateStorageFormat: dateStorageFormat,
|
|
1365
|
+
dateCalendarType: dateCalendarType,
|
|
1366
|
+
listItems: listItems,
|
|
1367
|
+
lastValue: lastValue,
|
|
1368
|
+
multiline: multiline,
|
|
1369
|
+
residualChildren: residualChildren,
|
|
1370
|
+
leftoverAttributes: __spread(sdtPr.attributes),
|
|
1371
|
+
namespaceDeclarations: sdtPr.namespaceDeclarations,
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
// ── Serialize modeled sdtPr ─────────────────────────────────────────────────
|
|
1375
|
+
function serializeListItem(item) {
|
|
1376
|
+
var attributes = [];
|
|
1377
|
+
if (item.displayText !== undefined) {
|
|
1378
|
+
attributes.push(wmlAttr('displayText', item.displayText));
|
|
1379
|
+
}
|
|
1380
|
+
if (item.value !== undefined) {
|
|
1381
|
+
attributes.push(wmlAttr('value', item.value));
|
|
1382
|
+
}
|
|
1383
|
+
return wmlElement('listItem', { attributes: attributes });
|
|
1384
|
+
}
|
|
1385
|
+
function serializeDateElement(properties) {
|
|
1386
|
+
var children = [];
|
|
1387
|
+
if (properties.dateDisplayFormat !== undefined) {
|
|
1388
|
+
children.push(wmlElement('dateFormat', { attributes: [wmlAttr('val', properties.dateDisplayFormat)] }));
|
|
1389
|
+
}
|
|
1390
|
+
if (properties.dateDisplayLocale !== undefined) {
|
|
1391
|
+
var bcp47 = localeIdToBcp47(properties.dateDisplayLocale);
|
|
1392
|
+
if (bcp47 !== undefined) {
|
|
1393
|
+
children.push(wmlElement('lid', { attributes: [wmlAttr('val', bcp47)] }));
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
if (properties.dateStorageFormat !== undefined) {
|
|
1397
|
+
children.push(wmlElement('storeMappedDataAs', {
|
|
1398
|
+
attributes: [wmlAttr('val', properties.dateStorageFormat)],
|
|
1399
|
+
}));
|
|
1400
|
+
}
|
|
1401
|
+
if (properties.dateCalendarType !== undefined) {
|
|
1402
|
+
children.push(wmlElement('calendar', { attributes: [wmlAttr('val', properties.dateCalendarType)] }));
|
|
1403
|
+
}
|
|
1404
|
+
var attributes = [];
|
|
1405
|
+
if (properties.fullDate !== undefined) {
|
|
1406
|
+
attributes.push(wmlAttr('fullDate', properties.fullDate));
|
|
1407
|
+
}
|
|
1408
|
+
return wmlElement('date', { attributes: attributes, children: children });
|
|
1409
|
+
}
|
|
1410
|
+
function serializeCheckboxStateElement(localName, state) {
|
|
1411
|
+
var attrs = [];
|
|
1412
|
+
if (state.font !== undefined) {
|
|
1413
|
+
attrs.push(nsAttr(WORDML_2010_NAMESPACE, W14_PREFIX, 'font', state.font));
|
|
1414
|
+
}
|
|
1415
|
+
if (state.value !== undefined) {
|
|
1416
|
+
attrs.push(nsAttr(WORDML_2010_NAMESPACE, W14_PREFIX, 'val', state.value));
|
|
1417
|
+
}
|
|
1418
|
+
return nsElement(WORDML_2010_NAMESPACE, W14_PREFIX, localName, { attributes: attrs });
|
|
1419
|
+
}
|
|
1420
|
+
function serializeCheckboxElement(properties) {
|
|
1421
|
+
var children = [
|
|
1422
|
+
nsElement(WORDML_2010_NAMESPACE, W14_PREFIX, 'checked', {
|
|
1423
|
+
attributes: [
|
|
1424
|
+
nsAttr(WORDML_2010_NAMESPACE, W14_PREFIX, 'val', properties.isChecked ? '1' : '0'),
|
|
1425
|
+
],
|
|
1426
|
+
}),
|
|
1427
|
+
serializeCheckboxStateElement('checkedState', properties.checkedState),
|
|
1428
|
+
serializeCheckboxStateElement('uncheckedState', properties.uncheckedState),
|
|
1429
|
+
];
|
|
1430
|
+
return nsElement(WORDML_2010_NAMESPACE, W14_PREFIX, 'checkbox', { children: children });
|
|
1431
|
+
}
|
|
1432
|
+
function serializeTypeElement(properties) {
|
|
1433
|
+
var type = properties.type;
|
|
1434
|
+
if (type === undefined) {
|
|
1435
|
+
return undefined;
|
|
1436
|
+
}
|
|
1437
|
+
if (type === 'checkbox') {
|
|
1438
|
+
return serializeCheckboxElement(properties);
|
|
1439
|
+
}
|
|
1440
|
+
if (type === 'date') {
|
|
1441
|
+
return serializeDateElement(properties);
|
|
1442
|
+
}
|
|
1443
|
+
if (type === 'comboBox' || type === 'dropDownList') {
|
|
1444
|
+
var localName_1 = type === 'comboBox' ? 'comboBox' : 'dropDownList';
|
|
1445
|
+
var children = properties.contentControlListItems.asReadonly().map(serializeListItem);
|
|
1446
|
+
var attributes = [];
|
|
1447
|
+
if (properties.lastValue !== undefined) {
|
|
1448
|
+
attributes.push(wmlAttr('lastValue', properties.lastValue));
|
|
1449
|
+
}
|
|
1450
|
+
return wmlElement(localName_1, { attributes: attributes, children: children });
|
|
1451
|
+
}
|
|
1452
|
+
if (type === 'plainText') {
|
|
1453
|
+
var attributes = [];
|
|
1454
|
+
if (properties.multiline !== undefined) {
|
|
1455
|
+
attributes.push(wmlAttr('multiLine', properties.multiline ? '1' : '0'));
|
|
1456
|
+
}
|
|
1457
|
+
return wmlElement('text', { attributes: attributes });
|
|
1458
|
+
}
|
|
1459
|
+
var localName = TYPE_TO_WML_LOCAL.get(type);
|
|
1460
|
+
if (localName === undefined) {
|
|
1461
|
+
return undefined;
|
|
1462
|
+
}
|
|
1463
|
+
return wmlElement(localName);
|
|
1464
|
+
}
|
|
1465
|
+
function serializeDataBinding(binding) {
|
|
1466
|
+
var attributes = [];
|
|
1467
|
+
if (binding.prefixMappings !== undefined) {
|
|
1468
|
+
attributes.push(wmlAttr('prefixMappings', binding.prefixMappings));
|
|
1469
|
+
}
|
|
1470
|
+
attributes.push(wmlAttr('xpath', binding.xpath));
|
|
1471
|
+
attributes.push(wmlAttr('storeItemID', binding.storeItemID));
|
|
1472
|
+
return wmlElement('dataBinding', { attributes: attributes });
|
|
1473
|
+
}
|
|
1474
|
+
function serializeAppearance(appearance) {
|
|
1475
|
+
return nsElement(WORDML_2012_NAMESPACE, W15_PREFIX, 'appearance', {
|
|
1476
|
+
attributes: [nsAttr(WORDML_2012_NAMESPACE, W15_PREFIX, 'val', appearance)],
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
function serializeColor(properties) {
|
|
1480
|
+
var hex = properties.color !== undefined ? colorToHexWire(properties.color) : undefined;
|
|
1481
|
+
var themeColor = properties.themeColor;
|
|
1482
|
+
var themeTint = properties.themeTint;
|
|
1483
|
+
var themeShade = properties.themeShade;
|
|
1484
|
+
if (hex === undefined && themeColor === undefined && themeTint === undefined && themeShade === undefined) {
|
|
1485
|
+
return undefined;
|
|
1486
|
+
}
|
|
1487
|
+
var attributes = [];
|
|
1488
|
+
if (hex !== undefined) {
|
|
1489
|
+
attributes.push(wmlAttr('val', hex));
|
|
1490
|
+
}
|
|
1491
|
+
if (themeColor !== undefined) {
|
|
1492
|
+
attributes.push(nsAttr(WORDML_2012_NAMESPACE, W15_PREFIX, 'themeColor', themeColor));
|
|
1493
|
+
}
|
|
1494
|
+
if (themeTint !== undefined) {
|
|
1495
|
+
attributes.push(nsAttr(WORDML_2012_NAMESPACE, W15_PREFIX, 'themeTint', themeTint));
|
|
1496
|
+
}
|
|
1497
|
+
if (themeShade !== undefined) {
|
|
1498
|
+
attributes.push(nsAttr(WORDML_2012_NAMESPACE, W15_PREFIX, 'themeShade', themeShade));
|
|
1499
|
+
}
|
|
1500
|
+
return nsElement(WORDML_2012_NAMESPACE, W15_PREFIX, 'color', { attributes: attributes });
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Build `w:sdtPr` from modeled properties + residual.
|
|
1504
|
+
*
|
|
1505
|
+
* Child order follows Transitional `CT_SdtPr` sequence for WML members, with
|
|
1506
|
+
* MS `appearance`/`color` after `temporary` and the kind choice last among
|
|
1507
|
+
* modeled members, then residual unknowns.
|
|
1508
|
+
*/
|
|
1509
|
+
function buildSdtPrFromProperties(properties) {
|
|
1510
|
+
var e_6, _a;
|
|
1511
|
+
var children = [];
|
|
1512
|
+
if (properties.title !== undefined) {
|
|
1513
|
+
children.push(wmlElement('alias', { attributes: [wmlAttr('val', properties.title)] }));
|
|
1514
|
+
}
|
|
1515
|
+
if (properties.tag !== undefined) {
|
|
1516
|
+
children.push(wmlElement('tag', { attributes: [wmlAttr('val', properties.tag)] }));
|
|
1517
|
+
}
|
|
1518
|
+
if (properties.id !== undefined) {
|
|
1519
|
+
children.push(wmlElement('id', { attributes: [wmlAttr('val', String(properties.id))] }));
|
|
1520
|
+
}
|
|
1521
|
+
var lockWire = properties.lockWire;
|
|
1522
|
+
if (lockWire !== undefined) {
|
|
1523
|
+
children.push(wmlElement('lock', { attributes: [wmlAttr('val', lockWire)] }));
|
|
1524
|
+
}
|
|
1525
|
+
if (properties.placeholderDocPart !== undefined) {
|
|
1526
|
+
children.push(wmlElement('placeholder', {
|
|
1527
|
+
children: [
|
|
1528
|
+
wmlElement('docPart', {
|
|
1529
|
+
attributes: [wmlAttr('val', properties.placeholderDocPart)],
|
|
1530
|
+
}),
|
|
1531
|
+
],
|
|
1532
|
+
}));
|
|
1533
|
+
}
|
|
1534
|
+
if (properties.isTemporary) {
|
|
1535
|
+
children.push(serializeOnOffWml('temporary', true));
|
|
1536
|
+
}
|
|
1537
|
+
if (properties.appearance !== undefined) {
|
|
1538
|
+
children.push(serializeAppearance(properties.appearance));
|
|
1539
|
+
}
|
|
1540
|
+
var colorEl = serializeColor(properties);
|
|
1541
|
+
if (colorEl !== undefined) {
|
|
1542
|
+
children.push(colorEl);
|
|
1543
|
+
}
|
|
1544
|
+
if (properties.dataBinding !== undefined) {
|
|
1545
|
+
children.push(serializeDataBinding(properties.dataBinding));
|
|
1546
|
+
}
|
|
1547
|
+
var kindEl = serializeTypeElement(properties);
|
|
1548
|
+
if (kindEl !== undefined) {
|
|
1549
|
+
children.push(kindEl);
|
|
1550
|
+
}
|
|
1551
|
+
try {
|
|
1552
|
+
for (var _b = __values(properties.residualChildren), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1553
|
+
var residual = _c.value;
|
|
1554
|
+
children.push(residual);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1558
|
+
finally {
|
|
1559
|
+
try {
|
|
1560
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1561
|
+
}
|
|
1562
|
+
finally { if (e_6) throw e_6.error; }
|
|
1563
|
+
}
|
|
1564
|
+
var namespaceDeclarations = __spread(properties.namespaceDeclarations);
|
|
1565
|
+
var needW14 = properties.type === 'checkbox' ||
|
|
1566
|
+
namespaceDeclarations.some(function (d) { return d.namespaceUri === WORDML_2010_NAMESPACE; });
|
|
1567
|
+
var needW15 = properties.appearance !== undefined ||
|
|
1568
|
+
properties.color !== undefined ||
|
|
1569
|
+
properties.themeColor !== undefined ||
|
|
1570
|
+
namespaceDeclarations.some(function (d) { return d.namespaceUri === WORDML_2012_NAMESPACE; });
|
|
1571
|
+
if (needW14 && !namespaceDeclarations.some(function (d) { return d.namespaceUri === WORDML_2010_NAMESPACE; })) {
|
|
1572
|
+
namespaceDeclarations.push({ prefix: W14_PREFIX, namespaceUri: WORDML_2010_NAMESPACE });
|
|
1573
|
+
}
|
|
1574
|
+
if (needW15 && !namespaceDeclarations.some(function (d) { return d.namespaceUri === WORDML_2012_NAMESPACE; })) {
|
|
1575
|
+
namespaceDeclarations.push({ prefix: W15_PREFIX, namespaceUri: WORDML_2012_NAMESPACE });
|
|
1576
|
+
}
|
|
1577
|
+
return wmlElement('sdtPr', {
|
|
1578
|
+
attributes: properties.leftoverAttributes,
|
|
1579
|
+
namespaceDeclarations: namespaceDeclarations,
|
|
1580
|
+
children: children,
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
var detachedRunOwner = {
|
|
1584
|
+
assertAttachedItem: function () {
|
|
1585
|
+
return;
|
|
1586
|
+
},
|
|
1587
|
+
};
|
|
1588
|
+
function parseInlineContent(children, owner) {
|
|
1589
|
+
var e_7, _a;
|
|
1590
|
+
var inlines = [];
|
|
1591
|
+
try {
|
|
1592
|
+
for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
|
|
1593
|
+
var child = children_1_1.value;
|
|
1594
|
+
if (child.kind !== 'element') {
|
|
1595
|
+
continue;
|
|
1596
|
+
}
|
|
1597
|
+
var element = child;
|
|
1598
|
+
if (isWml(element, 'r')) {
|
|
1599
|
+
inlines.push({ type: 'textRange', run: TextRange.fromXml(element, owner) });
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
var feature = tryParseFeatureInline(element);
|
|
1603
|
+
if (feature !== undefined) {
|
|
1604
|
+
inlines.push(feature);
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
inlines.push({ type: 'opaque', xml: element });
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1611
|
+
finally {
|
|
1612
|
+
try {
|
|
1613
|
+
if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
|
|
1614
|
+
}
|
|
1615
|
+
finally { if (e_7) throw e_7.error; }
|
|
1616
|
+
}
|
|
1617
|
+
return inlines;
|
|
1618
|
+
}
|
|
1619
|
+
function serializeInlineContent(inlines) {
|
|
1620
|
+
var e_8, _a;
|
|
1621
|
+
var out = [];
|
|
1622
|
+
try {
|
|
1623
|
+
for (var inlines_1 = __values(inlines), inlines_1_1 = inlines_1.next(); !inlines_1_1.done; inlines_1_1 = inlines_1.next()) {
|
|
1624
|
+
var inline = inlines_1_1.value;
|
|
1625
|
+
if (inline.type === 'textRange') {
|
|
1626
|
+
out.push(serializeRun(inline.run));
|
|
1627
|
+
}
|
|
1628
|
+
else if (inline.type === 'feature') {
|
|
1629
|
+
out.push(serializeFeatureInline(inline));
|
|
1630
|
+
}
|
|
1631
|
+
else {
|
|
1632
|
+
out.push(inline.xml);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1637
|
+
finally {
|
|
1638
|
+
try {
|
|
1639
|
+
if (inlines_1_1 && !inlines_1_1.done && (_a = inlines_1.return)) _a.call(inlines_1);
|
|
1640
|
+
}
|
|
1641
|
+
finally { if (e_8) throw e_8.error; }
|
|
1642
|
+
}
|
|
1643
|
+
return out;
|
|
1644
|
+
}
|
|
1645
|
+
function releaseBlockContent(blocks) {
|
|
1646
|
+
var e_9, _a;
|
|
1647
|
+
try {
|
|
1648
|
+
for (var blocks_1 = __values(blocks), blocks_1_1 = blocks_1.next(); !blocks_1_1.done; blocks_1_1 = blocks_1.next()) {
|
|
1649
|
+
var block = blocks_1_1.value;
|
|
1650
|
+
if (block.type === 'feature' && block.value instanceof ContentControl) {
|
|
1651
|
+
block.value.releaseContent();
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1656
|
+
finally {
|
|
1657
|
+
try {
|
|
1658
|
+
if (blocks_1_1 && !blocks_1_1.done && (_a = blocks_1.return)) _a.call(blocks_1);
|
|
1659
|
+
}
|
|
1660
|
+
finally { if (e_9) throw e_9.error; }
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function releaseInlineContent(inlines) {
|
|
1664
|
+
var e_10, _a;
|
|
1665
|
+
try {
|
|
1666
|
+
for (var inlines_2 = __values(inlines), inlines_2_1 = inlines_2.next(); !inlines_2_1.done; inlines_2_1 = inlines_2.next()) {
|
|
1667
|
+
var inline = inlines_2_1.value;
|
|
1668
|
+
if (inline.type === 'feature' && inline.value instanceof ContentControl) {
|
|
1669
|
+
inline.value.releaseContent();
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1674
|
+
finally {
|
|
1675
|
+
try {
|
|
1676
|
+
if (inlines_2_1 && !inlines_2_1.done && (_a = inlines_2.return)) _a.call(inlines_2);
|
|
1677
|
+
}
|
|
1678
|
+
finally { if (e_10) throw e_10.error; }
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
// ── ContentControl ───────────────────────────────────────────────────
|
|
1682
|
+
/**
|
|
1683
|
+
* Structured document tag (`w:sdt`) base — shared properties, facades, and
|
|
1684
|
+
* serialize hooks for block and inline content controls.
|
|
1685
|
+
*
|
|
1686
|
+
* Prefer {@link BlockContentControl} / {@link InlineContentControl} for new
|
|
1687
|
+
* code. This class remains the shared base and legacy facade surface.
|
|
1688
|
+
*
|
|
1689
|
+
* @public
|
|
1690
|
+
*/
|
|
1691
|
+
var ContentControl = /** @class */ (function () {
|
|
1692
|
+
/**
|
|
1693
|
+
* @private
|
|
1694
|
+
*/
|
|
1695
|
+
function ContentControl(properties, sdtPr, sdtEndPr, preservedXml, rebuildSdtPr) {
|
|
1696
|
+
if (rebuildSdtPr === void 0) { rebuildSdtPr = false; }
|
|
1697
|
+
this.propertiesValue = properties;
|
|
1698
|
+
this.sdtPr = sdtPr;
|
|
1699
|
+
this.sdtEndPrRaw = sdtEndPr;
|
|
1700
|
+
this.preservedXml = preservedXml;
|
|
1701
|
+
this.documentOwner = undefined;
|
|
1702
|
+
this.rebuildSdtPr = rebuildSdtPr;
|
|
1703
|
+
this.rebuildSdtEndPr = false;
|
|
1704
|
+
this.breakFormatDirty = false;
|
|
1705
|
+
this.breakCharacterFormatInstance = new CharacterFormat(this);
|
|
1706
|
+
if (sdtEndPr !== undefined) {
|
|
1707
|
+
this.hydrateBreakCharacterFormat(sdtEndPr);
|
|
1708
|
+
}
|
|
1709
|
+
if (this.propertiesValue !== undefined) {
|
|
1710
|
+
this.propertiesValue.bindOwner(this);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
Object.defineProperty(ContentControl.prototype, "contentControlProperties", {
|
|
1714
|
+
/**
|
|
1715
|
+
* Always-defined typed property bag (created on first access when missing).
|
|
1716
|
+
*
|
|
1717
|
+
* @public
|
|
1718
|
+
*/
|
|
1719
|
+
get: function () {
|
|
1720
|
+
return this.ensureProperties();
|
|
1721
|
+
},
|
|
1722
|
+
enumerable: true,
|
|
1723
|
+
configurable: true
|
|
1724
|
+
});
|
|
1725
|
+
Object.defineProperty(ContentControl.prototype, "properties", {
|
|
1726
|
+
/**
|
|
1727
|
+
* Gets the typed property bag for this content control.
|
|
1728
|
+
*
|
|
1729
|
+
* @public
|
|
1730
|
+
*/
|
|
1731
|
+
get: function () {
|
|
1732
|
+
return this.propertiesValue;
|
|
1733
|
+
},
|
|
1734
|
+
enumerable: true,
|
|
1735
|
+
configurable: true
|
|
1736
|
+
});
|
|
1737
|
+
Object.defineProperty(ContentControl.prototype, "breakCharacterFormat", {
|
|
1738
|
+
/**
|
|
1739
|
+
* Character formatting for the SDT end mark (`w:sdtEndPr/w:rPr`).
|
|
1740
|
+
*
|
|
1741
|
+
* @public
|
|
1742
|
+
*/
|
|
1743
|
+
get: function () {
|
|
1744
|
+
return this.breakCharacterFormatInstance;
|
|
1745
|
+
},
|
|
1746
|
+
enumerable: true,
|
|
1747
|
+
configurable: true
|
|
1748
|
+
});
|
|
1749
|
+
/**
|
|
1750
|
+
* @private
|
|
1751
|
+
*/
|
|
1752
|
+
ContentControl.prototype.notifyCharacterFormatMutation = function () {
|
|
1753
|
+
this.breakFormatDirty = true;
|
|
1754
|
+
this.rebuildSdtEndPr = true;
|
|
1755
|
+
};
|
|
1756
|
+
ContentControl.prototype.hydrateBreakCharacterFormat = function (sdtEndPr) {
|
|
1757
|
+
var e_11, _a;
|
|
1758
|
+
try {
|
|
1759
|
+
for (var _b = __values(elementChildren(sdtEndPr)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1760
|
+
var child = _c.value;
|
|
1761
|
+
if (isWml(child, 'rPr')) {
|
|
1762
|
+
var snap = parseCharacterFormat(child);
|
|
1763
|
+
this.breakCharacterFormatInstance.hydrate(snap);
|
|
1764
|
+
this.breakFormatDirty = false;
|
|
1765
|
+
this.rebuildSdtEndPr = false;
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1771
|
+
finally {
|
|
1772
|
+
try {
|
|
1773
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1774
|
+
}
|
|
1775
|
+
finally { if (e_11) throw e_11.error; }
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
ContentControl.prototype.serializeSdtEndPr = function () {
|
|
1779
|
+
if (this.rebuildSdtEndPr || this.breakFormatDirty) {
|
|
1780
|
+
var rPrChildren = this.breakCharacterFormatInstance.buildRPrChildren();
|
|
1781
|
+
if (rPrChildren.length === 0 && this.sdtEndPrRaw === undefined) {
|
|
1782
|
+
return undefined;
|
|
1783
|
+
}
|
|
1784
|
+
return wmlElement('sdtEndPr', {
|
|
1785
|
+
children: [wmlElement('rPr', { children: rPrChildren })],
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
return this.sdtEndPrRaw;
|
|
1789
|
+
};
|
|
1790
|
+
/**
|
|
1791
|
+
* @private
|
|
1792
|
+
* Prefer modeled rebuild after any user-facing property write.
|
|
1793
|
+
*/
|
|
1794
|
+
ContentControl.prototype.markSdtPrDirty = function () {
|
|
1795
|
+
this.rebuildSdtPr = true;
|
|
1796
|
+
};
|
|
1797
|
+
/** @private */
|
|
1798
|
+
ContentControl.prototype.synchronizeCheckboxContent = function () {
|
|
1799
|
+
return;
|
|
1800
|
+
};
|
|
1801
|
+
/**
|
|
1802
|
+
* Ensure a properties bag exists so facade setters can write fields on
|
|
1803
|
+
* controls that loaded without a complete `sdtPr` model.
|
|
1804
|
+
*/
|
|
1805
|
+
ContentControl.prototype.ensureProperties = function () {
|
|
1806
|
+
if (this.propertiesValue === undefined) {
|
|
1807
|
+
this.propertiesValue = new ContentControlProperties({});
|
|
1808
|
+
this.propertiesValue.bindOwner(this);
|
|
1809
|
+
}
|
|
1810
|
+
return this.propertiesValue;
|
|
1811
|
+
};
|
|
1812
|
+
Object.defineProperty(ContentControl.prototype, "title", {
|
|
1813
|
+
/**
|
|
1814
|
+
* Gets or sets the friendly display name shown as the content-control title in Word.
|
|
1815
|
+
*
|
|
1816
|
+
* @public
|
|
1817
|
+
*/
|
|
1818
|
+
get: function () {
|
|
1819
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.title;
|
|
1820
|
+
},
|
|
1821
|
+
set: function (value) {
|
|
1822
|
+
this.ensureProperties().title = value;
|
|
1823
|
+
},
|
|
1824
|
+
enumerable: true,
|
|
1825
|
+
configurable: true
|
|
1826
|
+
});
|
|
1827
|
+
Object.defineProperty(ContentControl.prototype, "tag", {
|
|
1828
|
+
/**
|
|
1829
|
+
* Gets or sets the programmatic tag used to identify this content control in code.
|
|
1830
|
+
*
|
|
1831
|
+
* @public
|
|
1832
|
+
*/
|
|
1833
|
+
get: function () {
|
|
1834
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.tag;
|
|
1835
|
+
},
|
|
1836
|
+
set: function (value) {
|
|
1837
|
+
this.ensureProperties().tag = value;
|
|
1838
|
+
},
|
|
1839
|
+
enumerable: true,
|
|
1840
|
+
configurable: true
|
|
1841
|
+
});
|
|
1842
|
+
Object.defineProperty(ContentControl.prototype, "lockContentControl", {
|
|
1843
|
+
/**
|
|
1844
|
+
* Gets or sets whether the content-control definition is locked.
|
|
1845
|
+
*
|
|
1846
|
+
* @public
|
|
1847
|
+
*/
|
|
1848
|
+
get: function () {
|
|
1849
|
+
return this.ensureProperties().lockContentControl;
|
|
1850
|
+
},
|
|
1851
|
+
set: function (value) {
|
|
1852
|
+
this.ensureProperties().lockContentControl = value;
|
|
1853
|
+
},
|
|
1854
|
+
enumerable: true,
|
|
1855
|
+
configurable: true
|
|
1856
|
+
});
|
|
1857
|
+
Object.defineProperty(ContentControl.prototype, "lockContents", {
|
|
1858
|
+
/**
|
|
1859
|
+
* Gets or sets whether the content inside the control is locked.
|
|
1860
|
+
*
|
|
1861
|
+
* @public
|
|
1862
|
+
*/
|
|
1863
|
+
get: function () {
|
|
1864
|
+
return this.ensureProperties().lockContents;
|
|
1865
|
+
},
|
|
1866
|
+
set: function (value) {
|
|
1867
|
+
this.ensureProperties().lockContents = value;
|
|
1868
|
+
},
|
|
1869
|
+
enumerable: true,
|
|
1870
|
+
configurable: true
|
|
1871
|
+
});
|
|
1872
|
+
Object.defineProperty(ContentControl.prototype, "placeholderText", {
|
|
1873
|
+
/**
|
|
1874
|
+
* Gets or sets the placeholder document-part name used when the control shows placeholder content.
|
|
1875
|
+
*
|
|
1876
|
+
* @public
|
|
1877
|
+
*/
|
|
1878
|
+
get: function () {
|
|
1879
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.placeholderDocPart;
|
|
1880
|
+
},
|
|
1881
|
+
set: function (value) {
|
|
1882
|
+
this.ensureProperties().placeholderDocPart = value;
|
|
1883
|
+
},
|
|
1884
|
+
enumerable: true,
|
|
1885
|
+
configurable: true
|
|
1886
|
+
});
|
|
1887
|
+
Object.defineProperty(ContentControl.prototype, "type", {
|
|
1888
|
+
/**
|
|
1889
|
+
* Gets or sets the content-control kind.
|
|
1890
|
+
*
|
|
1891
|
+
* @public
|
|
1892
|
+
*/
|
|
1893
|
+
get: function () {
|
|
1894
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.type;
|
|
1895
|
+
},
|
|
1896
|
+
set: function (value) {
|
|
1897
|
+
this.ensureProperties().type = value;
|
|
1898
|
+
},
|
|
1899
|
+
enumerable: true,
|
|
1900
|
+
configurable: true
|
|
1901
|
+
});
|
|
1902
|
+
Object.defineProperty(ContentControl.prototype, "isTemporary", {
|
|
1903
|
+
/**
|
|
1904
|
+
* Gets or sets whether the control is removed after its contents are edited once.
|
|
1905
|
+
*
|
|
1906
|
+
* @public
|
|
1907
|
+
*/
|
|
1908
|
+
get: function () {
|
|
1909
|
+
return this.ensureProperties().isTemporary;
|
|
1910
|
+
},
|
|
1911
|
+
set: function (value) {
|
|
1912
|
+
this.ensureProperties().isTemporary = value;
|
|
1913
|
+
},
|
|
1914
|
+
enumerable: true,
|
|
1915
|
+
configurable: true
|
|
1916
|
+
});
|
|
1917
|
+
Object.defineProperty(ContentControl.prototype, "appearance", {
|
|
1918
|
+
/**
|
|
1919
|
+
* Gets or sets how the control chrome is shown.
|
|
1920
|
+
*
|
|
1921
|
+
* @public
|
|
1922
|
+
*/
|
|
1923
|
+
get: function () {
|
|
1924
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.appearance;
|
|
1925
|
+
},
|
|
1926
|
+
set: function (value) {
|
|
1927
|
+
this.ensureProperties().appearance = value;
|
|
1928
|
+
},
|
|
1929
|
+
enumerable: true,
|
|
1930
|
+
configurable: true
|
|
1931
|
+
});
|
|
1932
|
+
Object.defineProperty(ContentControl.prototype, "color", {
|
|
1933
|
+
/**
|
|
1934
|
+
* Gets or sets the border/chrome color for the content control.
|
|
1935
|
+
*
|
|
1936
|
+
* @public
|
|
1937
|
+
*/
|
|
1938
|
+
get: function () {
|
|
1939
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.color;
|
|
1940
|
+
},
|
|
1941
|
+
set: function (value) {
|
|
1942
|
+
this.ensureProperties().color = value;
|
|
1943
|
+
},
|
|
1944
|
+
enumerable: true,
|
|
1945
|
+
configurable: true
|
|
1946
|
+
});
|
|
1947
|
+
Object.defineProperty(ContentControl.prototype, "isChecked", {
|
|
1948
|
+
/**
|
|
1949
|
+
* Gets or sets whether a checkbox control is checked.
|
|
1950
|
+
*
|
|
1951
|
+
* @public
|
|
1952
|
+
*/
|
|
1953
|
+
get: function () {
|
|
1954
|
+
return this.ensureProperties().isChecked;
|
|
1955
|
+
},
|
|
1956
|
+
set: function (value) {
|
|
1957
|
+
this.ensureProperties().isChecked = value;
|
|
1958
|
+
},
|
|
1959
|
+
enumerable: true,
|
|
1960
|
+
configurable: true
|
|
1961
|
+
});
|
|
1962
|
+
Object.defineProperty(ContentControl.prototype, "checkedState", {
|
|
1963
|
+
/**
|
|
1964
|
+
* Checked-state symbol (stable identity).
|
|
1965
|
+
*
|
|
1966
|
+
* @public
|
|
1967
|
+
*/
|
|
1968
|
+
get: function () {
|
|
1969
|
+
return this.ensureProperties().checkedState;
|
|
1970
|
+
},
|
|
1971
|
+
enumerable: true,
|
|
1972
|
+
configurable: true
|
|
1973
|
+
});
|
|
1974
|
+
Object.defineProperty(ContentControl.prototype, "uncheckedState", {
|
|
1975
|
+
/**
|
|
1976
|
+
* Unchecked-state symbol (stable identity).
|
|
1977
|
+
*
|
|
1978
|
+
* @public
|
|
1979
|
+
*/
|
|
1980
|
+
get: function () {
|
|
1981
|
+
return this.ensureProperties().uncheckedState;
|
|
1982
|
+
},
|
|
1983
|
+
enumerable: true,
|
|
1984
|
+
configurable: true
|
|
1985
|
+
});
|
|
1986
|
+
Object.defineProperty(ContentControl.prototype, "fullDate", {
|
|
1987
|
+
/**
|
|
1988
|
+
* Full date/time stored value.
|
|
1989
|
+
*
|
|
1990
|
+
* @public
|
|
1991
|
+
*/
|
|
1992
|
+
get: function () {
|
|
1993
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.fullDate;
|
|
1994
|
+
},
|
|
1995
|
+
set: function (value) {
|
|
1996
|
+
this.ensureProperties().fullDate = value;
|
|
1997
|
+
},
|
|
1998
|
+
enumerable: true,
|
|
1999
|
+
configurable: true
|
|
2000
|
+
});
|
|
2001
|
+
Object.defineProperty(ContentControl.prototype, "dateDisplayFormat", {
|
|
2002
|
+
/**
|
|
2003
|
+
* Display format pattern for the date.
|
|
2004
|
+
*
|
|
2005
|
+
* @public
|
|
2006
|
+
*/
|
|
2007
|
+
get: function () {
|
|
2008
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.dateDisplayFormat;
|
|
2009
|
+
},
|
|
2010
|
+
set: function (value) {
|
|
2011
|
+
this.ensureProperties().dateDisplayFormat = value;
|
|
2012
|
+
},
|
|
2013
|
+
enumerable: true,
|
|
2014
|
+
configurable: true
|
|
2015
|
+
});
|
|
2016
|
+
Object.defineProperty(ContentControl.prototype, "dateDisplayLocale", {
|
|
2017
|
+
/**
|
|
2018
|
+
* Locale used for date display.
|
|
2019
|
+
*
|
|
2020
|
+
* @public
|
|
2021
|
+
*/
|
|
2022
|
+
get: function () {
|
|
2023
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.dateDisplayLocale;
|
|
2024
|
+
},
|
|
2025
|
+
set: function (value) {
|
|
2026
|
+
this.ensureProperties().dateDisplayLocale = value;
|
|
2027
|
+
},
|
|
2028
|
+
enumerable: true,
|
|
2029
|
+
configurable: true
|
|
2030
|
+
});
|
|
2031
|
+
Object.defineProperty(ContentControl.prototype, "dateStorageFormat", {
|
|
2032
|
+
/**
|
|
2033
|
+
* How mapped date data is stored.
|
|
2034
|
+
*
|
|
2035
|
+
* @public
|
|
2036
|
+
*/
|
|
2037
|
+
get: function () {
|
|
2038
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.dateStorageFormat;
|
|
2039
|
+
},
|
|
2040
|
+
set: function (value) {
|
|
2041
|
+
this.ensureProperties().dateStorageFormat = value;
|
|
2042
|
+
},
|
|
2043
|
+
enumerable: true,
|
|
2044
|
+
configurable: true
|
|
2045
|
+
});
|
|
2046
|
+
Object.defineProperty(ContentControl.prototype, "dateCalendarType", {
|
|
2047
|
+
/**
|
|
2048
|
+
* Calendar system for the date control.
|
|
2049
|
+
*
|
|
2050
|
+
* @public
|
|
2051
|
+
*/
|
|
2052
|
+
get: function () {
|
|
2053
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.dateCalendarType;
|
|
2054
|
+
},
|
|
2055
|
+
set: function (value) {
|
|
2056
|
+
this.ensureProperties().dateCalendarType = value;
|
|
2057
|
+
},
|
|
2058
|
+
enumerable: true,
|
|
2059
|
+
configurable: true
|
|
2060
|
+
});
|
|
2061
|
+
Object.defineProperty(ContentControl.prototype, "contentControlListItems", {
|
|
2062
|
+
/**
|
|
2063
|
+
* Combo-box / drop-down list items (stable identity).
|
|
2064
|
+
*
|
|
2065
|
+
* @public
|
|
2066
|
+
*/
|
|
2067
|
+
get: function () {
|
|
2068
|
+
return this.ensureProperties().contentControlListItems;
|
|
2069
|
+
},
|
|
2070
|
+
enumerable: true,
|
|
2071
|
+
configurable: true
|
|
2072
|
+
});
|
|
2073
|
+
Object.defineProperty(ContentControl.prototype, "lastValue", {
|
|
2074
|
+
/**
|
|
2075
|
+
* Gets or sets the last selected value for a combo-box or drop-down list control.
|
|
2076
|
+
*
|
|
2077
|
+
* @public
|
|
2078
|
+
*/
|
|
2079
|
+
get: function () {
|
|
2080
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.lastValue;
|
|
2081
|
+
},
|
|
2082
|
+
set: function (value) {
|
|
2083
|
+
this.ensureProperties().lastValue = value;
|
|
2084
|
+
},
|
|
2085
|
+
enumerable: true,
|
|
2086
|
+
configurable: true
|
|
2087
|
+
});
|
|
2088
|
+
Object.defineProperty(ContentControl.prototype, "multiline", {
|
|
2089
|
+
/**
|
|
2090
|
+
* Gets or sets whether a plain-text content control accepts multiple lines of text.
|
|
2091
|
+
*
|
|
2092
|
+
* @public
|
|
2093
|
+
*/
|
|
2094
|
+
get: function () {
|
|
2095
|
+
return this.propertiesValue == null ? undefined : this.propertiesValue.multiline;
|
|
2096
|
+
},
|
|
2097
|
+
set: function (value) {
|
|
2098
|
+
this.ensureProperties().multiline = value;
|
|
2099
|
+
},
|
|
2100
|
+
enumerable: true,
|
|
2101
|
+
configurable: true
|
|
2102
|
+
});
|
|
2103
|
+
Object.defineProperty(ContentControl.prototype, "blockContentControl", {
|
|
2104
|
+
/**
|
|
2105
|
+
* Compatibility: block children projected as BodyItem[] (block controls only).
|
|
2106
|
+
*
|
|
2107
|
+
* @public
|
|
2108
|
+
*/
|
|
2109
|
+
get: function () {
|
|
2110
|
+
return undefined;
|
|
2111
|
+
},
|
|
2112
|
+
enumerable: true,
|
|
2113
|
+
configurable: true
|
|
2114
|
+
});
|
|
2115
|
+
Object.defineProperty(ContentControl.prototype, "inlineContentControl", {
|
|
2116
|
+
/**
|
|
2117
|
+
* Compatibility: inline bag children (inline controls only).
|
|
2118
|
+
*
|
|
2119
|
+
* @public
|
|
2120
|
+
*/
|
|
2121
|
+
get: function () {
|
|
2122
|
+
return undefined;
|
|
2123
|
+
},
|
|
2124
|
+
enumerable: true,
|
|
2125
|
+
configurable: true
|
|
2126
|
+
});
|
|
2127
|
+
/**
|
|
2128
|
+
* @private
|
|
2129
|
+
*/
|
|
2130
|
+
ContentControl.prototype.releaseContent = function () {
|
|
2131
|
+
return;
|
|
2132
|
+
};
|
|
2133
|
+
/**
|
|
2134
|
+
* @private
|
|
2135
|
+
* Bind owning document so nested content can mutate.
|
|
2136
|
+
*/
|
|
2137
|
+
ContentControl.prototype.bindDocument = function (document) {
|
|
2138
|
+
this.documentOwner = document;
|
|
2139
|
+
};
|
|
2140
|
+
/**
|
|
2141
|
+
* @private
|
|
2142
|
+
*/
|
|
2143
|
+
ContentControl.prototype.owningDocument = function () {
|
|
2144
|
+
if (this.documentOwner === undefined) {
|
|
2145
|
+
throw new DetachedObjectError('This content control is not bound to a document');
|
|
2146
|
+
}
|
|
2147
|
+
return this.documentOwner;
|
|
2148
|
+
};
|
|
2149
|
+
/**
|
|
2150
|
+
* @private
|
|
2151
|
+
*/
|
|
2152
|
+
ContentControl.prototype.buildSdtShell = function (contentChildren) {
|
|
2153
|
+
if (this.preservedXml !== undefined) {
|
|
2154
|
+
return this.preservedXml;
|
|
2155
|
+
}
|
|
2156
|
+
var children = [];
|
|
2157
|
+
if (this.rebuildSdtPr && this.propertiesValue !== undefined) {
|
|
2158
|
+
children.push(buildSdtPrFromProperties(this.propertiesValue));
|
|
2159
|
+
}
|
|
2160
|
+
else if (this.sdtPr !== undefined) {
|
|
2161
|
+
children.push(this.sdtPr);
|
|
2162
|
+
}
|
|
2163
|
+
else if (this.propertiesValue !== undefined) {
|
|
2164
|
+
children.push(buildSdtPrFromProperties(this.propertiesValue));
|
|
2165
|
+
}
|
|
2166
|
+
var endPr = this.serializeSdtEndPr();
|
|
2167
|
+
if (endPr !== undefined) {
|
|
2168
|
+
children.push(endPr);
|
|
2169
|
+
}
|
|
2170
|
+
children.push(wmlElement('sdtContent', { children: contentChildren }));
|
|
2171
|
+
return wmlElement('sdt', { children: children });
|
|
2172
|
+
};
|
|
2173
|
+
/**
|
|
2174
|
+
* @private
|
|
2175
|
+
*/
|
|
2176
|
+
ContentControl.prototype.toOpenXml = function () {
|
|
2177
|
+
return this.buildSdtShell([]);
|
|
2178
|
+
};
|
|
2179
|
+
return ContentControl;
|
|
2180
|
+
}());
|
|
2181
|
+
export { ContentControl };
|
|
2182
|
+
/**
|
|
2183
|
+
* Block-level structured document tag (`w:sdt` / `CT_SdtBlock`).
|
|
2184
|
+
*
|
|
2185
|
+
* Owns a nested {@link Body} whose {@link Body.items} are the live DOM for
|
|
2186
|
+
* `w:sdtContent` children. Public identity is this instance (BodyItem).
|
|
2187
|
+
*
|
|
2188
|
+
* @public
|
|
2189
|
+
*/
|
|
2190
|
+
var BlockContentControl = /** @class */ (function (_super) {
|
|
2191
|
+
__extends(BlockContentControl, _super);
|
|
2192
|
+
/**
|
|
2193
|
+
* @private
|
|
2194
|
+
*/
|
|
2195
|
+
function BlockContentControl(properties, sdtPr, sdtEndPr, blocks, preservedXml, rebuildSdtPr, document) {
|
|
2196
|
+
var e_12, _a;
|
|
2197
|
+
if (rebuildSdtPr === void 0) { rebuildSdtPr = false; }
|
|
2198
|
+
var _this = _super.call(this, properties, sdtPr, sdtEndPr, preservedXml, rebuildSdtPr) || this;
|
|
2199
|
+
_this.isBlockLevel = true;
|
|
2200
|
+
_this.bodyInstance = new Body(document, blocks != null ? blocks : []);
|
|
2201
|
+
try {
|
|
2202
|
+
// Nested body paragraphs attach via Body constructor; re-bind CC as owner for assertAttached.
|
|
2203
|
+
for (var _b = __values(_this.bodyInstance.rawBlocks()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2204
|
+
var block = _c.value;
|
|
2205
|
+
if (block.type === 'paragraph') {
|
|
2206
|
+
block.paragraph.attach(_this);
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
2211
|
+
finally {
|
|
2212
|
+
try {
|
|
2213
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2214
|
+
}
|
|
2215
|
+
finally { if (e_12) throw e_12.error; }
|
|
2216
|
+
}
|
|
2217
|
+
return _this;
|
|
2218
|
+
}
|
|
2219
|
+
Object.defineProperty(BlockContentControl.prototype, "body", {
|
|
2220
|
+
/**
|
|
2221
|
+
* Nested body for block content-control children (`w:sdtContent`).
|
|
2222
|
+
*
|
|
2223
|
+
* @public
|
|
2224
|
+
*/
|
|
2225
|
+
get: function () {
|
|
2226
|
+
return this.bodyInstance;
|
|
2227
|
+
},
|
|
2228
|
+
enumerable: true,
|
|
2229
|
+
configurable: true
|
|
2230
|
+
});
|
|
2231
|
+
Object.defineProperty(BlockContentControl.prototype, "blockContentControl", {
|
|
2232
|
+
/**
|
|
2233
|
+
* Projected public children (compat with prior APIs).
|
|
2234
|
+
*
|
|
2235
|
+
* @public
|
|
2236
|
+
*/
|
|
2237
|
+
get: function () {
|
|
2238
|
+
var e_13, _a;
|
|
2239
|
+
var out = [];
|
|
2240
|
+
try {
|
|
2241
|
+
for (var _b = __values(this.bodyInstance.rawBlocks()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2242
|
+
var block = _c.value;
|
|
2243
|
+
var item = projectBlockToBodyItem(block);
|
|
2244
|
+
if (item !== undefined) {
|
|
2245
|
+
out.push(item);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
2250
|
+
finally {
|
|
2251
|
+
try {
|
|
2252
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2253
|
+
}
|
|
2254
|
+
finally { if (e_13) throw e_13.error; }
|
|
2255
|
+
}
|
|
2256
|
+
return out;
|
|
2257
|
+
},
|
|
2258
|
+
enumerable: true,
|
|
2259
|
+
configurable: true
|
|
2260
|
+
});
|
|
2261
|
+
/**
|
|
2262
|
+
* @private
|
|
2263
|
+
*/
|
|
2264
|
+
BlockContentControl.prototype.releaseContent = function () {
|
|
2265
|
+
releaseBlockContent(this.bodyInstance.rawBlocks());
|
|
2266
|
+
};
|
|
2267
|
+
/**
|
|
2268
|
+
* @private
|
|
2269
|
+
*/
|
|
2270
|
+
BlockContentControl.prototype.bindDocument = function (document) {
|
|
2271
|
+
var e_14, _a;
|
|
2272
|
+
_super.prototype.bindDocument.call(this, document);
|
|
2273
|
+
this.bodyInstance.setOwningDocument(document);
|
|
2274
|
+
try {
|
|
2275
|
+
for (var _b = __values(this.bodyInstance.rawBlocks()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2276
|
+
var block = _c.value;
|
|
2277
|
+
if (block.type === 'paragraph') {
|
|
2278
|
+
block.paragraph.attach(this);
|
|
2279
|
+
}
|
|
2280
|
+
if (block.type === 'feature' && block.value instanceof ContentControl) {
|
|
2281
|
+
block.value.bindDocument(document);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
2286
|
+
finally {
|
|
2287
|
+
try {
|
|
2288
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2289
|
+
}
|
|
2290
|
+
finally { if (e_14) throw e_14.error; }
|
|
2291
|
+
}
|
|
2292
|
+
};
|
|
2293
|
+
/**
|
|
2294
|
+
* @private
|
|
2295
|
+
*/
|
|
2296
|
+
BlockContentControl.prototype.assertAttachedParagraph = function (target) {
|
|
2297
|
+
var e_15, _a;
|
|
2298
|
+
var found = false;
|
|
2299
|
+
try {
|
|
2300
|
+
for (var _b = __values(this.bodyInstance.rawBlocks()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2301
|
+
var block = _c.value;
|
|
2302
|
+
if (block.type === 'paragraph' && block.paragraph === target) {
|
|
2303
|
+
found = true;
|
|
2304
|
+
break;
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
2309
|
+
finally {
|
|
2310
|
+
try {
|
|
2311
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2312
|
+
}
|
|
2313
|
+
finally { if (e_15) throw e_15.error; }
|
|
2314
|
+
}
|
|
2315
|
+
if (!found) {
|
|
2316
|
+
throw new DetachedObjectError('Paragraph is not in this content control');
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
/**
|
|
2320
|
+
* @private
|
|
2321
|
+
*/
|
|
2322
|
+
BlockContentControl.prototype.toOpenXml = function () {
|
|
2323
|
+
return this.buildSdtShell(serializeBodyBlocks(this.bodyInstance.rawBlocks()));
|
|
2324
|
+
};
|
|
2325
|
+
return BlockContentControl;
|
|
2326
|
+
}(ContentControl));
|
|
2327
|
+
export { BlockContentControl };
|
|
2328
|
+
/**
|
|
2329
|
+
* Inline (run-level) structured document tag (`w:sdt` / `CT_SdtRun`).
|
|
2330
|
+
*
|
|
2331
|
+
* Owns a {@link ParagraphItemCollection} for `w:sdtContent` children.
|
|
2332
|
+
* Projected as a public paragraph item via EntityType unwrap.
|
|
2333
|
+
*
|
|
2334
|
+
* @public
|
|
2335
|
+
*/
|
|
2336
|
+
var InlineContentControl = /** @class */ (function (_super) {
|
|
2337
|
+
__extends(InlineContentControl, _super);
|
|
2338
|
+
/**
|
|
2339
|
+
* @private
|
|
2340
|
+
*/
|
|
2341
|
+
function InlineContentControl(properties, sdtPr, sdtEndPr, initialItems, preservedXml, rebuildSdtPr) {
|
|
2342
|
+
if (rebuildSdtPr === void 0) { rebuildSdtPr = false; }
|
|
2343
|
+
var _this = _super.call(this, properties, sdtPr, sdtEndPr, preservedXml, rebuildSdtPr) || this;
|
|
2344
|
+
/**
|
|
2345
|
+
* Discriminator for paragraph-item projection (`projectPublicItem`).
|
|
2346
|
+
*
|
|
2347
|
+
* @public
|
|
2348
|
+
*/
|
|
2349
|
+
_this.entityType = EntityType.InlineContentControl;
|
|
2350
|
+
_this.paragraphItemsInstance = new ParagraphItemCollection(_this);
|
|
2351
|
+
_this.itemOwner = undefined;
|
|
2352
|
+
if (initialItems !== undefined && initialItems.length > 0) {
|
|
2353
|
+
_this.paragraphItemsInstance.hydrate(initialItems);
|
|
2354
|
+
}
|
|
2355
|
+
return _this;
|
|
2356
|
+
}
|
|
2357
|
+
Object.defineProperty(InlineContentControl.prototype, "paragraphItems", {
|
|
2358
|
+
/**
|
|
2359
|
+
* Live paragraph items inside this inline content control.
|
|
2360
|
+
*
|
|
2361
|
+
* @public
|
|
2362
|
+
*/
|
|
2363
|
+
get: function () {
|
|
2364
|
+
return this.paragraphItemsInstance;
|
|
2365
|
+
},
|
|
2366
|
+
enumerable: true,
|
|
2367
|
+
configurable: true
|
|
2368
|
+
});
|
|
2369
|
+
Object.defineProperty(InlineContentControl.prototype, "inlineContentControl", {
|
|
2370
|
+
/**
|
|
2371
|
+
* Compatibility bags for legacy tests (`{ type:'textRange', run }`).
|
|
2372
|
+
*
|
|
2373
|
+
* @public
|
|
2374
|
+
*/
|
|
2375
|
+
get: function () {
|
|
2376
|
+
var e_16, _a;
|
|
2377
|
+
var out = [];
|
|
2378
|
+
try {
|
|
2379
|
+
for (var _b = __values(this.paragraphItemsInstance), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2380
|
+
var item = _c.value;
|
|
2381
|
+
if (item instanceof TextRange) {
|
|
2382
|
+
out.push({ type: 'textRange', run: item });
|
|
2383
|
+
}
|
|
2384
|
+
else if (item instanceof FeatureInlineParagraphItem) {
|
|
2385
|
+
out.push({
|
|
2386
|
+
type: 'feature',
|
|
2387
|
+
featureId: item.featureId,
|
|
2388
|
+
value: item.value,
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
2391
|
+
else if (item instanceof OpaqueParagraphItem) {
|
|
2392
|
+
out.push({ type: 'opaque', xml: item.xml });
|
|
2393
|
+
}
|
|
2394
|
+
else if (typeof item.toOpenXml === 'function') {
|
|
2395
|
+
out.push({ type: 'opaque', xml: item.toOpenXml() });
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2400
|
+
finally {
|
|
2401
|
+
try {
|
|
2402
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2403
|
+
}
|
|
2404
|
+
finally { if (e_16) throw e_16.error; }
|
|
2405
|
+
}
|
|
2406
|
+
return out;
|
|
2407
|
+
},
|
|
2408
|
+
enumerable: true,
|
|
2409
|
+
configurable: true
|
|
2410
|
+
});
|
|
2411
|
+
Object.defineProperty(InlineContentControl.prototype, "owner", {
|
|
2412
|
+
/**
|
|
2413
|
+
* @private
|
|
2414
|
+
*/
|
|
2415
|
+
get: function () {
|
|
2416
|
+
return this.itemOwner;
|
|
2417
|
+
},
|
|
2418
|
+
enumerable: true,
|
|
2419
|
+
configurable: true
|
|
2420
|
+
});
|
|
2421
|
+
/**
|
|
2422
|
+
* @private
|
|
2423
|
+
*/
|
|
2424
|
+
InlineContentControl.prototype.attach = function (owner) {
|
|
2425
|
+
this.itemOwner = owner;
|
|
2426
|
+
this.paragraphItemsInstance.reattachAll();
|
|
2427
|
+
};
|
|
2428
|
+
/**
|
|
2429
|
+
* @private
|
|
2430
|
+
*/
|
|
2431
|
+
InlineContentControl.prototype.detach = function () {
|
|
2432
|
+
this.paragraphItemsInstance.detachAll();
|
|
2433
|
+
this.itemOwner = undefined;
|
|
2434
|
+
};
|
|
2435
|
+
/**
|
|
2436
|
+
* @private
|
|
2437
|
+
*/
|
|
2438
|
+
InlineContentControl.prototype.assertAttachedItem = function (target) {
|
|
2439
|
+
if (!this.paragraphItemsInstance.containsIdentity(target)) {
|
|
2440
|
+
throw new DetachedObjectError('Paragraph item is not in this content control');
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
/**
|
|
2444
|
+
* @private
|
|
2445
|
+
*/
|
|
2446
|
+
InlineContentControl.prototype.assertMutable = function () {
|
|
2447
|
+
return;
|
|
2448
|
+
};
|
|
2449
|
+
/**
|
|
2450
|
+
* @private
|
|
2451
|
+
*/
|
|
2452
|
+
InlineContentControl.prototype.releaseContent = function () {
|
|
2453
|
+
var e_17, _a;
|
|
2454
|
+
try {
|
|
2455
|
+
for (var _b = __values(this.paragraphItemsInstance), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2456
|
+
var item = _c.value;
|
|
2457
|
+
if (item instanceof InlineContentControl) {
|
|
2458
|
+
item.releaseContent();
|
|
2459
|
+
}
|
|
2460
|
+
else if (item instanceof FeatureInlineParagraphItem && item.value instanceof ContentControl) {
|
|
2461
|
+
item.value.releaseContent();
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
2466
|
+
finally {
|
|
2467
|
+
try {
|
|
2468
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2469
|
+
}
|
|
2470
|
+
finally { if (e_17) throw e_17.error; }
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
/** @private */
|
|
2474
|
+
InlineContentControl.prototype.synchronizeCheckboxContent = function () {
|
|
2475
|
+
var properties = this.properties;
|
|
2476
|
+
if (properties === undefined || properties.type !== 'checkbox') {
|
|
2477
|
+
return;
|
|
2478
|
+
}
|
|
2479
|
+
var state = properties.isChecked ? properties.checkedState : properties.uncheckedState;
|
|
2480
|
+
var fallback = properties.isChecked
|
|
2481
|
+
? DEFAULT_CHECKED_SYMBOL_TEXT
|
|
2482
|
+
: DEFAULT_UNCHECKED_SYMBOL_TEXT;
|
|
2483
|
+
var symbol = fallback;
|
|
2484
|
+
if (state.value !== undefined && /^[0-9A-Fa-f]{1,6}$/.test(state.value)) {
|
|
2485
|
+
var codePoint = Number.parseInt(state.value, 16);
|
|
2486
|
+
if (codePoint <= 0x10FFFF) {
|
|
2487
|
+
symbol = String.fromCodePoint(codePoint);
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
var items = __spread(this.paragraphItemsInstance);
|
|
2491
|
+
var first = items.length === 1 ? items[0] : undefined;
|
|
2492
|
+
if (first instanceof TextRange) {
|
|
2493
|
+
first.text = symbol;
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
if (items.length !== 0) {
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2499
|
+
try {
|
|
2500
|
+
var run = new TextRange(this.owningDocument());
|
|
2501
|
+
run.text = symbol;
|
|
2502
|
+
this.paragraphItemsInstance.add(run);
|
|
2503
|
+
}
|
|
2504
|
+
catch (_a) {
|
|
2505
|
+
// Initialize later when the detached control is bound to a document.
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
/**
|
|
2509
|
+
* @private
|
|
2510
|
+
*/
|
|
2511
|
+
InlineContentControl.prototype.bindDocument = function (document) {
|
|
2512
|
+
var e_18, _a;
|
|
2513
|
+
_super.prototype.bindDocument.call(this, document);
|
|
2514
|
+
try {
|
|
2515
|
+
for (var _b = __values(this.paragraphItemsInstance), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2516
|
+
var item = _c.value;
|
|
2517
|
+
if (item instanceof ContentControl) {
|
|
2518
|
+
item.bindDocument(document);
|
|
2519
|
+
}
|
|
2520
|
+
else if (item instanceof FeatureInlineParagraphItem && item.value instanceof ContentControl) {
|
|
2521
|
+
item.value.bindDocument(document);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
2526
|
+
finally {
|
|
2527
|
+
try {
|
|
2528
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2529
|
+
}
|
|
2530
|
+
finally { if (e_18) throw e_18.error; }
|
|
2531
|
+
}
|
|
2532
|
+
this.synchronizeCheckboxContent();
|
|
2533
|
+
};
|
|
2534
|
+
/**
|
|
2535
|
+
* @private
|
|
2536
|
+
*/
|
|
2537
|
+
InlineContentControl.prototype.toOpenXml = function () {
|
|
2538
|
+
return this.buildSdtShell(serializeParagraphItems(__spread(this.paragraphItemsInstance)));
|
|
2539
|
+
};
|
|
2540
|
+
return InlineContentControl;
|
|
2541
|
+
}(ContentControl));
|
|
2542
|
+
export { InlineContentControl };
|
|
2543
|
+
function bagsToParagraphItems(inlines) {
|
|
2544
|
+
var e_19, _a;
|
|
2545
|
+
var items = [];
|
|
2546
|
+
try {
|
|
2547
|
+
for (var inlines_3 = __values(inlines), inlines_3_1 = inlines_3.next(); !inlines_3_1.done; inlines_3_1 = inlines_3.next()) {
|
|
2548
|
+
var inline = inlines_3_1.value;
|
|
2549
|
+
if (inline.type === 'textRange') {
|
|
2550
|
+
items.push(inline.run);
|
|
2551
|
+
continue;
|
|
2552
|
+
}
|
|
2553
|
+
if (inline.type === 'feature') {
|
|
2554
|
+
items.push(new FeatureInlineParagraphItem(inline.featureId, inline.value));
|
|
2555
|
+
continue;
|
|
2556
|
+
}
|
|
2557
|
+
items.push(new OpaqueParagraphItem(inline.xml));
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
2561
|
+
finally {
|
|
2562
|
+
try {
|
|
2563
|
+
if (inlines_3_1 && !inlines_3_1.done && (_a = inlines_3.return)) _a.call(inlines_3);
|
|
2564
|
+
}
|
|
2565
|
+
finally { if (e_19) throw e_19.error; }
|
|
2566
|
+
}
|
|
2567
|
+
return items;
|
|
2568
|
+
}
|
|
2569
|
+
function splitSdtChildren(element) {
|
|
2570
|
+
var e_20, _a;
|
|
2571
|
+
var sdtPr;
|
|
2572
|
+
var sdtEndPr;
|
|
2573
|
+
var sdtContent;
|
|
2574
|
+
try {
|
|
2575
|
+
for (var _b = __values(elementChildren(element)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2576
|
+
var child = _c.value;
|
|
2577
|
+
if (isWml(child, 'sdtPr')) {
|
|
2578
|
+
sdtPr = child;
|
|
2579
|
+
}
|
|
2580
|
+
else if (isWml(child, 'sdtEndPr')) {
|
|
2581
|
+
sdtEndPr = child;
|
|
2582
|
+
}
|
|
2583
|
+
else if (isWml(child, 'sdtContent')) {
|
|
2584
|
+
sdtContent = child;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
2589
|
+
finally {
|
|
2590
|
+
try {
|
|
2591
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2592
|
+
}
|
|
2593
|
+
finally { if (e_20) throw e_20.error; }
|
|
2594
|
+
}
|
|
2595
|
+
return { sdtPr: sdtPr, sdtEndPr: sdtEndPr, sdtContent: sdtContent };
|
|
2596
|
+
}
|
|
2597
|
+
function parseContentControl(element, mode, ctx) {
|
|
2598
|
+
if (!isWml(element, 'sdt')) {
|
|
2599
|
+
return undefined;
|
|
2600
|
+
}
|
|
2601
|
+
var _a = splitSdtChildren(element), sdtPr = _a.sdtPr, sdtEndPr = _a.sdtEndPr, sdtContent = _a.sdtContent;
|
|
2602
|
+
var properties = parseContentControlProperties(sdtPr);
|
|
2603
|
+
if (sdtContent === undefined && sdtPr === undefined && sdtEndPr === undefined) {
|
|
2604
|
+
if (mode === 'block') {
|
|
2605
|
+
return new BlockContentControl(undefined, undefined, undefined, [], element);
|
|
2606
|
+
}
|
|
2607
|
+
return new InlineContentControl(undefined, undefined, undefined, [], element);
|
|
2608
|
+
}
|
|
2609
|
+
if (mode === 'block') {
|
|
2610
|
+
var blocks = sdtContent !== undefined ? parseBodyBlocks(sdtContent.children, ctx) : [];
|
|
2611
|
+
return new BlockContentControl(properties, sdtPr, sdtEndPr, blocks, undefined);
|
|
2612
|
+
}
|
|
2613
|
+
var inlines = sdtContent !== undefined ? parseInlineContent(sdtContent.children, detachedRunOwner) : [];
|
|
2614
|
+
return new InlineContentControl(properties, sdtPr, sdtEndPr, bagsToParagraphItems(inlines), undefined);
|
|
2615
|
+
}
|
|
2616
|
+
function contentControlsFromBlocks(blocks) {
|
|
2617
|
+
var e_21, _a;
|
|
2618
|
+
var found = [];
|
|
2619
|
+
try {
|
|
2620
|
+
for (var blocks_2 = __values(blocks), blocks_2_1 = blocks_2.next(); !blocks_2_1.done; blocks_2_1 = blocks_2.next()) {
|
|
2621
|
+
var block = blocks_2_1.value;
|
|
2622
|
+
if (block instanceof ContentControl) {
|
|
2623
|
+
found.push(block);
|
|
2624
|
+
continue;
|
|
2625
|
+
}
|
|
2626
|
+
if (typeof block === 'object' && block !== null && 'type' in block) {
|
|
2627
|
+
var candidate = block;
|
|
2628
|
+
if (candidate.type === 'feature' && candidate.value instanceof ContentControl) {
|
|
2629
|
+
found.push(candidate.value);
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
2635
|
+
finally {
|
|
2636
|
+
try {
|
|
2637
|
+
if (blocks_2_1 && !blocks_2_1.done && (_a = blocks_2.return)) _a.call(blocks_2);
|
|
2638
|
+
}
|
|
2639
|
+
finally { if (e_21) throw e_21.error; }
|
|
2640
|
+
}
|
|
2641
|
+
return found;
|
|
2642
|
+
}
|
|
2643
|
+
function contentControlsFromInlines(inlines) {
|
|
2644
|
+
var e_22, _a;
|
|
2645
|
+
var found = [];
|
|
2646
|
+
try {
|
|
2647
|
+
for (var inlines_4 = __values(inlines), inlines_4_1 = inlines_4.next(); !inlines_4_1.done; inlines_4_1 = inlines_4.next()) {
|
|
2648
|
+
var inline = inlines_4_1.value;
|
|
2649
|
+
if (inline instanceof InlineContentControl) {
|
|
2650
|
+
found.push(inline);
|
|
2651
|
+
continue;
|
|
2652
|
+
}
|
|
2653
|
+
if (inline instanceof FeatureInlineParagraphItem && inline.value instanceof ContentControl) {
|
|
2654
|
+
found.push(inline.value);
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
2659
|
+
finally {
|
|
2660
|
+
try {
|
|
2661
|
+
if (inlines_4_1 && !inlines_4_1.done && (_a = inlines_4.return)) _a.call(inlines_4);
|
|
2662
|
+
}
|
|
2663
|
+
finally { if (e_22) throw e_22.error; }
|
|
2664
|
+
}
|
|
2665
|
+
return found;
|
|
2666
|
+
}
|
|
2667
|
+
// ── Authoring ───────────────────────────────────────────────────────────────
|
|
2668
|
+
/**
|
|
2669
|
+
* Create a detached block-level content control (`w:sdt`) ready for append.
|
|
2670
|
+
*
|
|
2671
|
+
* @private
|
|
2672
|
+
*/
|
|
2673
|
+
export function createBlockContentControl(type) {
|
|
2674
|
+
requireAuthorableType(type);
|
|
2675
|
+
var properties = type !== undefined ? new ContentControlProperties({ type: type }) : undefined;
|
|
2676
|
+
var sdtPr = properties !== undefined ? buildSdtPrFromProperties(properties) : undefined;
|
|
2677
|
+
var paragraph = new Paragraph(undefined);
|
|
2678
|
+
var sdt = new BlockContentControl(properties, sdtPr, undefined, [{ type: 'paragraph', paragraph: paragraph }], undefined, true);
|
|
2679
|
+
paragraph.attach(sdt);
|
|
2680
|
+
return sdt;
|
|
2681
|
+
}
|
|
2682
|
+
/**
|
|
2683
|
+
* Create a detached run-level content control (`w:sdt`) ready for append.
|
|
2684
|
+
*
|
|
2685
|
+
* @private
|
|
2686
|
+
*/
|
|
2687
|
+
export function createInlineContentControl(type) {
|
|
2688
|
+
requireAuthorableType(type);
|
|
2689
|
+
var properties = type !== undefined ? new ContentControlProperties({ type: type }) : undefined;
|
|
2690
|
+
var sdtPr = properties !== undefined ? buildSdtPrFromProperties(properties) : undefined;
|
|
2691
|
+
return new InlineContentControl(properties, sdtPr, undefined, [], undefined, true);
|
|
2692
|
+
}
|
|
2693
|
+
Object.defineProperty(Body.prototype, 'addBlockContentControl', {
|
|
2694
|
+
value: function (type) {
|
|
2695
|
+
var sdt = createBlockContentControl(type);
|
|
2696
|
+
this.appendRawBlock({ type: 'feature', featureId: CONTENT_CONTROLS, value: sdt });
|
|
2697
|
+
sdt.bindDocument(this.owningDocument());
|
|
2698
|
+
return sdt;
|
|
2699
|
+
},
|
|
2700
|
+
writable: true,
|
|
2701
|
+
configurable: true,
|
|
2702
|
+
});
|
|
2703
|
+
Object.defineProperty(WordDocument.prototype, 'addBlockContentControl', {
|
|
2704
|
+
value: function (type) {
|
|
2705
|
+
var body = this.firstSectionBody();
|
|
2706
|
+
return body.addBlockContentControl(type);
|
|
2707
|
+
},
|
|
2708
|
+
writable: true,
|
|
2709
|
+
configurable: true,
|
|
2710
|
+
});
|
|
2711
|
+
Object.defineProperty(Paragraph.prototype, 'appendInlineContentControl', {
|
|
2712
|
+
value: function (type) {
|
|
2713
|
+
var sdt = createInlineContentControl(type);
|
|
2714
|
+
this.appendFeatureInline(CONTENT_CONTROLS, sdt);
|
|
2715
|
+
try {
|
|
2716
|
+
sdt.bindDocument(this.owningDocument());
|
|
2717
|
+
}
|
|
2718
|
+
catch (_a) {
|
|
2719
|
+
// Detached paragraph — bind later when the paragraph attaches.
|
|
2720
|
+
}
|
|
2721
|
+
return sdt;
|
|
2722
|
+
},
|
|
2723
|
+
writable: true,
|
|
2724
|
+
configurable: true,
|
|
2725
|
+
});
|
|
2726
|
+
var registered = false;
|
|
2727
|
+
/**
|
|
2728
|
+
* @private
|
|
2729
|
+
* Test hook */
|
|
2730
|
+
export function resetContentControlsFeatureForTests() {
|
|
2731
|
+
registered = false;
|
|
2732
|
+
}
|
|
2733
|
+
/**
|
|
2734
|
+
* @private
|
|
2735
|
+
* Register structured document tag handlers. Idempotent. */
|
|
2736
|
+
export function registerContentControlsFeature() {
|
|
2737
|
+
if (registered) {
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
registered = true;
|
|
2741
|
+
registerFeature({ id: CONTENT_CONTROLS });
|
|
2742
|
+
registerFeatureInlineHandler({
|
|
2743
|
+
featureId: CONTENT_CONTROLS,
|
|
2744
|
+
wmlLocalName: 'sdt',
|
|
2745
|
+
tryParse: function (element) {
|
|
2746
|
+
return parseContentControl(element, 'inline', detachedBodyBlockParseContext());
|
|
2747
|
+
},
|
|
2748
|
+
});
|
|
2749
|
+
registerFeatureBlockHandler({
|
|
2750
|
+
featureId: CONTENT_CONTROLS,
|
|
2751
|
+
wmlLocalName: 'sdt',
|
|
2752
|
+
tryParse: function (element, ctx) {
|
|
2753
|
+
return parseContentControl(element, 'block', ctx);
|
|
2754
|
+
},
|
|
2755
|
+
});
|
|
2756
|
+
registerFeatureBlockParagraphWalker({
|
|
2757
|
+
featureId: CONTENT_CONTROLS,
|
|
2758
|
+
visitParagraphs: function (block, visit) {
|
|
2759
|
+
if (block instanceof BlockContentControl) {
|
|
2760
|
+
visitBlocksInDocumentOrder(block.body.rawBlocks(), visit);
|
|
2761
|
+
}
|
|
2762
|
+
},
|
|
2763
|
+
});
|
|
2764
|
+
registerBodyItemAdapter({
|
|
2765
|
+
project: function (block) {
|
|
2766
|
+
if (block.featureId === CONTENT_CONTROLS && block.value instanceof ContentControl) {
|
|
2767
|
+
return block.value;
|
|
2768
|
+
}
|
|
2769
|
+
return undefined;
|
|
2770
|
+
},
|
|
2771
|
+
toBlock: function (item) {
|
|
2772
|
+
if (item instanceof ContentControl) {
|
|
2773
|
+
return { type: 'feature', featureId: CONTENT_CONTROLS, value: item };
|
|
2774
|
+
}
|
|
2775
|
+
return undefined;
|
|
2776
|
+
},
|
|
2777
|
+
isInstance: function (item) {
|
|
2778
|
+
return item instanceof BlockContentControl || item instanceof ContentControl;
|
|
2779
|
+
},
|
|
2780
|
+
});
|
|
2781
|
+
registerTypedCollectionHooks({
|
|
2782
|
+
isBlockContentControl: function (item) {
|
|
2783
|
+
return item instanceof BlockContentControl || (item instanceof ContentControl && item.isBlockLevel === true);
|
|
2784
|
+
},
|
|
2785
|
+
createBlockContentControl: function () {
|
|
2786
|
+
return createBlockContentControl();
|
|
2787
|
+
},
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
/**
|
|
2791
|
+
* Block-level SDTs in a block list, in document order.
|
|
2792
|
+
*
|
|
2793
|
+
* @private
|
|
2794
|
+
*/
|
|
2795
|
+
export function structuredDocumentTagsInBlocks(blocks) {
|
|
2796
|
+
return contentControlsFromBlocks(blocks);
|
|
2797
|
+
}
|
|
2798
|
+
/**
|
|
2799
|
+
* Run-level SDTs in a paragraph, in document order.
|
|
2800
|
+
*
|
|
2801
|
+
* @private
|
|
2802
|
+
*/
|
|
2803
|
+
export function structuredDocumentTagsInParagraph(paragraph) {
|
|
2804
|
+
return contentControlsFromInlines(paragraph.items.toArray());
|
|
2805
|
+
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Whether inline content is a modeled SDT from this module.
|
|
2808
|
+
*
|
|
2809
|
+
* @private
|
|
2810
|
+
*/
|
|
2811
|
+
export function isStructuredDocumentTagInline(inline) {
|
|
2812
|
+
return (inline instanceof FeatureInlineParagraphItem &&
|
|
2813
|
+
inline.featureId === CONTENT_CONTROLS &&
|
|
2814
|
+
inline.value instanceof ContentControl);
|
|
2815
|
+
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Feature id constant for the content-controls module (used by host features
|
|
2818
|
+
* that embed SDT blocks, e.g. text box bodies in the drawing module).
|
|
2819
|
+
*
|
|
2820
|
+
* @private
|
|
2821
|
+
*/
|
|
2822
|
+
export var CONTENT_CONTROLS_FEATURE_ID = CONTENT_CONTROLS;
|
|
2823
|
+
/**
|
|
2824
|
+
* Whether a body block is a modeled block-level SDT (`w:sdt`) from this module.
|
|
2825
|
+
*
|
|
2826
|
+
* Prefer with {@link elementTypeOf} when branching on body children:
|
|
2827
|
+
* `elementTypeOf(item) === 'blockContentControl'` then narrow with this guard.
|
|
2828
|
+
*
|
|
2829
|
+
* @param block - Body child to test.
|
|
2830
|
+
* @returns `true` when `block` is a modeled block {@link ContentControl}.
|
|
2831
|
+
*
|
|
2832
|
+
* @private
|
|
2833
|
+
*/
|
|
2834
|
+
export function isBlockContentControl(block) {
|
|
2835
|
+
if (block instanceof BlockContentControl) {
|
|
2836
|
+
return true;
|
|
2837
|
+
}
|
|
2838
|
+
if (block instanceof ContentControl && block.isBlockLevel === true) {
|
|
2839
|
+
return true;
|
|
2840
|
+
}
|
|
2841
|
+
if (typeof block !== 'object' || block === null) {
|
|
2842
|
+
return false;
|
|
2843
|
+
}
|
|
2844
|
+
var candidate = block;
|
|
2845
|
+
return (candidate.type === 'feature' &&
|
|
2846
|
+
candidate.featureId === CONTENT_CONTROLS &&
|
|
2847
|
+
candidate.value instanceof ContentControl &&
|
|
2848
|
+
(candidate.value instanceof BlockContentControl || candidate.value.isBlockLevel === true));
|
|
2849
|
+
}
|
|
2850
|
+
/** True when `value` is a public block ContentControl body item. */
|
|
2851
|
+
export function isBlockContentControlBodyItem(value) {
|
|
2852
|
+
return value instanceof BlockContentControl || (value instanceof ContentControl && value.isBlockLevel === true);
|
|
2853
|
+
}
|
|
2854
|
+
registerAlwaysOnBodyFeatureBootstrap(function () {
|
|
2855
|
+
registerContentControlsFeature();
|
|
2856
|
+
});
|
|
2857
|
+
registerContentControlsFeature();
|