@syncfusion/ej2-docx 0.0.0-stage → 35.1.39
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/README.md +68 -2
- package/core.js +4 -0
- package/dist/ej2-docx.umd.min.js +2 -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 +2 -0
- package/dist/global/ej2-docx.min.js.map +1 -0
- package/dist/global/index.d.ts +5 -0
- package/features.js +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +31 -4
- 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,1156 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
var __values = (this && this.__values) || function (o) {
|
|
24
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
25
|
+
if (m) return m.call(o);
|
|
26
|
+
return {
|
|
27
|
+
next: function () {
|
|
28
|
+
if (o && i >= o.length) o = void 0;
|
|
29
|
+
return { value: o && o[i++], done: !o };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
import { DocxError, SecurityError } from '../../core/errors/docx-error';
|
|
34
|
+
import { serializeFeatureRunLeaf, tryParseFeatureRunLeaf, } from '../../core/registry/run-leaf-handlers';
|
|
35
|
+
import { DEFAULT_RESOURCE_LIMITS } from '../../core/security/limits';
|
|
36
|
+
import { CharacterFormat, parseCharacterFormat, } from './character-format';
|
|
37
|
+
import { ParagraphItem } from './paragraph-item';
|
|
38
|
+
export { ParagraphItem } from './paragraph-item';
|
|
39
|
+
import { EntityType } from './entity-type';
|
|
40
|
+
import { elementChildren, isWml, textContent, wmlAttr, wmlElement, xmlSpaceIsPreserve, xmlSpacePreserve, } from './wml';
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Break leaf — ECMA-376-1 §17.3.3.1–2; CT_Br / ST_BrType / ST_BrClear
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
/**
|
|
45
|
+
* Break kind for `w:br` (`ST_BrType` plus the Line default).
|
|
46
|
+
*
|
|
47
|
+
* OOXML has no `@w:type="line"` value: a line break is a bare `w:br` (type omitted).
|
|
48
|
+
* Text-wrapping breaks use `@w:type="textWrapping"`.
|
|
49
|
+
*
|
|
50
|
+
* Citation: ECMA-376-1 §17.3.3.1–2; transitional `wml.xsd` `CT_Br` / `ST_BrType`.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export var BreakType = {
|
|
55
|
+
/**
|
|
56
|
+
* Page break. Maps to `w:br` with `@w:type="page"`.
|
|
57
|
+
*/
|
|
58
|
+
PageBreak: 'page',
|
|
59
|
+
/**
|
|
60
|
+
* Column break. Maps to `w:br` with `@w:type="column"`.
|
|
61
|
+
*/
|
|
62
|
+
ColumnBreak: 'column',
|
|
63
|
+
/**
|
|
64
|
+
* Line break (Shift+Enter / soft break). Maps to a bare `w:br` (type omitted).
|
|
65
|
+
*/
|
|
66
|
+
LineBreak: 'line',
|
|
67
|
+
/**
|
|
68
|
+
* Text-wrapping break. Maps to `w:br` with `@w:type="textWrapping"`.
|
|
69
|
+
*/
|
|
70
|
+
TextWrappingBreak: 'textWrapping',
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Text-wrapping clear for a line or text-wrapping break (`ST_BrClear`).
|
|
74
|
+
* Internal / parse-serialize only — not part of the public Break API surface.
|
|
75
|
+
*
|
|
76
|
+
* Citation: ECMA-376-1 §17.3.3.2; transitional `wml.xsd` `ST_BrClear`.
|
|
77
|
+
*
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
export var BreakClearType = {
|
|
81
|
+
None: 'none',
|
|
82
|
+
Left: 'left',
|
|
83
|
+
Right: 'right',
|
|
84
|
+
All: 'all',
|
|
85
|
+
};
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// Wire group — private shared w:r character format + attributes
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
/**
|
|
90
|
+
* @private
|
|
91
|
+
* Shared identity for paragraph items that serialize inside one physical `w:r`.
|
|
92
|
+
* Owns `w:rPr` ({@link CharacterFormat}) and unmodeled `w:r` attributes.
|
|
93
|
+
*/
|
|
94
|
+
var WireRunGroup = /** @class */ (function () {
|
|
95
|
+
function WireRunGroup(extraAttributes) {
|
|
96
|
+
this.extraAttributesValue = extraAttributes != null ? extraAttributes : [];
|
|
97
|
+
}
|
|
98
|
+
Object.defineProperty(WireRunGroup.prototype, "characterFormat", {
|
|
99
|
+
get: function () {
|
|
100
|
+
if (this.characterFormatField === undefined) {
|
|
101
|
+
this.characterFormatField = new CharacterFormat(this);
|
|
102
|
+
}
|
|
103
|
+
return this.characterFormatField;
|
|
104
|
+
},
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(WireRunGroup.prototype, "extraAttributes", {
|
|
109
|
+
get: function () {
|
|
110
|
+
return this.extraAttributesValue;
|
|
111
|
+
},
|
|
112
|
+
enumerable: true,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
WireRunGroup.prototype.setExtraAttributes = function (attrs) {
|
|
116
|
+
this.extraAttributesValue = attrs;
|
|
117
|
+
};
|
|
118
|
+
WireRunGroup.prototype.notifyCharacterFormatMutation = function () {
|
|
119
|
+
// Host is paragraph-owned; mutation is gated by the item owner.
|
|
120
|
+
};
|
|
121
|
+
WireRunGroup.prototype.hydrateCharacterFormat = function (data) {
|
|
122
|
+
this.characterFormat.hydrate(data);
|
|
123
|
+
};
|
|
124
|
+
WireRunGroup.prototype.snapshotCharacterFormat = function () {
|
|
125
|
+
return this.characterFormat.snapshot();
|
|
126
|
+
};
|
|
127
|
+
return WireRunGroup;
|
|
128
|
+
}());
|
|
129
|
+
export { WireRunGroup };
|
|
130
|
+
/**
|
|
131
|
+
* @private Base for run-level items that share a WireRunGroup + CharacterFormatHost.
|
|
132
|
+
*/
|
|
133
|
+
var WireRunParagraphItem = /** @class */ (function (_super) {
|
|
134
|
+
__extends(WireRunParagraphItem, _super);
|
|
135
|
+
function WireRunParagraphItem(wireGroup) {
|
|
136
|
+
var _this = _super.call(this) || this;
|
|
137
|
+
_this.wireGroupValue = wireGroup != null ? wireGroup : new WireRunGroup();
|
|
138
|
+
return _this;
|
|
139
|
+
}
|
|
140
|
+
Object.defineProperty(WireRunParagraphItem.prototype, "wireGroup", {
|
|
141
|
+
/**
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
get: function () {
|
|
145
|
+
return this.wireGroupValue;
|
|
146
|
+
},
|
|
147
|
+
enumerable: true,
|
|
148
|
+
configurable: true
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(WireRunParagraphItem.prototype, "characterFormat", {
|
|
151
|
+
/**
|
|
152
|
+
* Character formatting for this item (`w:rPr`), shared with siblings from the same `w:r`.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
get: function () {
|
|
156
|
+
return this.wireGroupValue.characterFormat;
|
|
157
|
+
},
|
|
158
|
+
enumerable: true,
|
|
159
|
+
configurable: true
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
164
|
+
WireRunParagraphItem.prototype.notifyCharacterFormatMutation = function () {
|
|
165
|
+
this.mutate();
|
|
166
|
+
};
|
|
167
|
+
return WireRunParagraphItem;
|
|
168
|
+
}(ParagraphItem));
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
// Concrete paragraph items
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
/**
|
|
173
|
+
* Tab stop character in a paragraph (`w:r/w:tab`).
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
var Tab = /** @class */ (function (_super) {
|
|
177
|
+
__extends(Tab, _super);
|
|
178
|
+
/** @private */
|
|
179
|
+
function Tab(wireGroup) {
|
|
180
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
181
|
+
/**
|
|
182
|
+
* Discriminant for {@link Paragraph.items} / {@link paragraphElementTypeOf}.
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
_this.type = EntityType.AbsoluteTab;
|
|
186
|
+
return _this;
|
|
187
|
+
}
|
|
188
|
+
return Tab;
|
|
189
|
+
}(WireRunParagraphItem));
|
|
190
|
+
export { Tab };
|
|
191
|
+
/**
|
|
192
|
+
* Carriage return in a paragraph (`w:r/w:cr`).
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
var CarriageReturn = /** @class */ (function (_super) {
|
|
196
|
+
__extends(CarriageReturn, _super);
|
|
197
|
+
/** @private */
|
|
198
|
+
function CarriageReturn(wireGroup) {
|
|
199
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
200
|
+
/**
|
|
201
|
+
* Discriminant for {@link Paragraph.items} / {@link paragraphElementTypeOf}.
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
_this.type = 'carriageReturn';
|
|
205
|
+
return _this;
|
|
206
|
+
}
|
|
207
|
+
return CarriageReturn;
|
|
208
|
+
}(WireRunParagraphItem));
|
|
209
|
+
export { CarriageReturn };
|
|
210
|
+
/**
|
|
211
|
+
* Symbol character in a paragraph (`w:r/w:sym`).
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
var Symbol = /** @class */ (function (_super) {
|
|
215
|
+
__extends(Symbol, _super);
|
|
216
|
+
/**
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
function Symbol(font, char, wireGroup) {
|
|
220
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
221
|
+
/**
|
|
222
|
+
* Discriminant for {@link Paragraph.items} / {@link paragraphElementTypeOf}.
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
_this.type = EntityType.Symbol;
|
|
226
|
+
_this.fontValue = font;
|
|
227
|
+
_this.charValue = char;
|
|
228
|
+
return _this;
|
|
229
|
+
}
|
|
230
|
+
Object.defineProperty(Symbol.prototype, "font", {
|
|
231
|
+
/**
|
|
232
|
+
* Symbol font name (`w:font`).
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
get: function () {
|
|
236
|
+
return this.fontValue;
|
|
237
|
+
},
|
|
238
|
+
set: function (value) {
|
|
239
|
+
this.mutate();
|
|
240
|
+
this.fontValue = value;
|
|
241
|
+
},
|
|
242
|
+
enumerable: true,
|
|
243
|
+
configurable: true
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(Symbol.prototype, "char", {
|
|
246
|
+
/**
|
|
247
|
+
* Character code as `ST_ShortHexNumber` hex digits (`w:char`).
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
get: function () {
|
|
251
|
+
return this.charValue;
|
|
252
|
+
},
|
|
253
|
+
set: function (value) {
|
|
254
|
+
this.mutate();
|
|
255
|
+
this.charValue = value;
|
|
256
|
+
},
|
|
257
|
+
enumerable: true,
|
|
258
|
+
configurable: true
|
|
259
|
+
});
|
|
260
|
+
return Symbol;
|
|
261
|
+
}(WireRunParagraphItem));
|
|
262
|
+
export { Symbol };
|
|
263
|
+
/**
|
|
264
|
+
* Break in a paragraph (`w:r/w:br` / `CT_Br`).
|
|
265
|
+
*
|
|
266
|
+
* Always serialized as run content (`w:r/w:br`). Clear and extras are internal
|
|
267
|
+
* round-trip state — not part of the public authoring API.
|
|
268
|
+
*
|
|
269
|
+
* Citation: ECMA-376-1 §17.3.3.1–2; transitional `wml.xsd` `CT_Br`.
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
var Break = /** @class */ (function (_super) {
|
|
274
|
+
__extends(Break, _super);
|
|
275
|
+
/**
|
|
276
|
+
* @private
|
|
277
|
+
*/
|
|
278
|
+
function Break(breakType, clear, extras, wireGroup) {
|
|
279
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
280
|
+
/**
|
|
281
|
+
* Discriminant for {@link Paragraph.items} / {@link paragraphElementTypeOf}.
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
_this.type = EntityType.Break;
|
|
285
|
+
_this.breakTypeValue = breakType;
|
|
286
|
+
if (clear !== undefined && clear !== BreakClearType.None) {
|
|
287
|
+
_this.clearValue = clear;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
_this.clearValue = undefined;
|
|
291
|
+
}
|
|
292
|
+
_this.extrasValue = extras != null ? extras : [];
|
|
293
|
+
return _this;
|
|
294
|
+
}
|
|
295
|
+
Object.defineProperty(Break.prototype, "breakType", {
|
|
296
|
+
/**
|
|
297
|
+
* Break kind (`ST_BrType` plus the Line default).
|
|
298
|
+
* @public
|
|
299
|
+
*/
|
|
300
|
+
get: function () {
|
|
301
|
+
return this.breakTypeValue;
|
|
302
|
+
},
|
|
303
|
+
set: function (value) {
|
|
304
|
+
this.mutate();
|
|
305
|
+
this.breakTypeValue = value;
|
|
306
|
+
},
|
|
307
|
+
enumerable: true,
|
|
308
|
+
configurable: true
|
|
309
|
+
});
|
|
310
|
+
Object.defineProperty(Break.prototype, "clear", {
|
|
311
|
+
/**
|
|
312
|
+
* @private
|
|
313
|
+
*/
|
|
314
|
+
get: function () {
|
|
315
|
+
return this.clearValue;
|
|
316
|
+
},
|
|
317
|
+
enumerable: true,
|
|
318
|
+
configurable: true
|
|
319
|
+
});
|
|
320
|
+
Object.defineProperty(Break.prototype, "extras", {
|
|
321
|
+
/**
|
|
322
|
+
* @private
|
|
323
|
+
*/
|
|
324
|
+
get: function () {
|
|
325
|
+
return this.extrasValue;
|
|
326
|
+
},
|
|
327
|
+
enumerable: true,
|
|
328
|
+
configurable: true
|
|
329
|
+
});
|
|
330
|
+
return Break;
|
|
331
|
+
}(WireRunParagraphItem));
|
|
332
|
+
export { Break };
|
|
333
|
+
/**
|
|
334
|
+
* Feature-owned run-level content promoted onto {@link Paragraph.items}
|
|
335
|
+
* (for example images). Storage uses a private tag; public classifiers map
|
|
336
|
+
* to domain types.
|
|
337
|
+
*
|
|
338
|
+
* @private
|
|
339
|
+
*/
|
|
340
|
+
var FeatureRunParagraphItem = /** @class */ (function (_super) {
|
|
341
|
+
__extends(FeatureRunParagraphItem, _super);
|
|
342
|
+
/** @private */
|
|
343
|
+
function FeatureRunParagraphItem(featureId, value, wireGroup) {
|
|
344
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
345
|
+
_this.type = 'featureRun';
|
|
346
|
+
_this.featureId = featureId;
|
|
347
|
+
_this.value = value;
|
|
348
|
+
return _this;
|
|
349
|
+
}
|
|
350
|
+
return FeatureRunParagraphItem;
|
|
351
|
+
}(WireRunParagraphItem));
|
|
352
|
+
export { FeatureRunParagraphItem };
|
|
353
|
+
/**
|
|
354
|
+
* Opaque unmodeled run child preserved for round-trip (`w:r/*`).
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
var OpaqueRunItem = /** @class */ (function (_super) {
|
|
358
|
+
__extends(OpaqueRunItem, _super);
|
|
359
|
+
/** @private */
|
|
360
|
+
function OpaqueRunItem(xml, wireGroup) {
|
|
361
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
362
|
+
_this.type = 'opaqueRun';
|
|
363
|
+
_this.xml = xml;
|
|
364
|
+
return _this;
|
|
365
|
+
}
|
|
366
|
+
return OpaqueRunItem;
|
|
367
|
+
}(WireRunParagraphItem));
|
|
368
|
+
export { OpaqueRunItem };
|
|
369
|
+
/**
|
|
370
|
+
* Feature-owned inline sibling of runs (for example `w:hyperlink`).
|
|
371
|
+
* Storage uses a private tag; public classifiers map to domain types.
|
|
372
|
+
*
|
|
373
|
+
* Concrete feature classes may extend {@link ParagraphItem} directly in a
|
|
374
|
+
* later cut; this wrapper preserves FeatureInline payloads during migration.
|
|
375
|
+
*
|
|
376
|
+
* @private
|
|
377
|
+
*/
|
|
378
|
+
var FeatureInlineParagraphItem = /** @class */ (function (_super) {
|
|
379
|
+
__extends(FeatureInlineParagraphItem, _super);
|
|
380
|
+
/** @private */
|
|
381
|
+
function FeatureInlineParagraphItem(featureId, value) {
|
|
382
|
+
var _this = _super.call(this) || this;
|
|
383
|
+
_this.type = 'featureInline';
|
|
384
|
+
_this.featureId = featureId;
|
|
385
|
+
_this.value = value;
|
|
386
|
+
return _this;
|
|
387
|
+
}
|
|
388
|
+
/** @private */
|
|
389
|
+
FeatureInlineParagraphItem.prototype.onDetached = function () {
|
|
390
|
+
if (this.value.releaseContent != null) {
|
|
391
|
+
this.value.releaseContent();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
return FeatureInlineParagraphItem;
|
|
395
|
+
}(ParagraphItem));
|
|
396
|
+
export { FeatureInlineParagraphItem };
|
|
397
|
+
/**
|
|
398
|
+
* Opaque unmodeled paragraph child preserved for round-trip.
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
401
|
+
var OpaqueParagraphItem = /** @class */ (function (_super) {
|
|
402
|
+
__extends(OpaqueParagraphItem, _super);
|
|
403
|
+
/** @private */
|
|
404
|
+
function OpaqueParagraphItem(xml) {
|
|
405
|
+
var _this = _super.call(this) || this;
|
|
406
|
+
_this.type = 'opaque';
|
|
407
|
+
_this.xml = xml;
|
|
408
|
+
return _this;
|
|
409
|
+
}
|
|
410
|
+
return OpaqueParagraphItem;
|
|
411
|
+
}(ParagraphItem));
|
|
412
|
+
export { OpaqueParagraphItem };
|
|
413
|
+
export function needsXmlSpacePreserve(text) {
|
|
414
|
+
return text.startsWith(' ') || text.endsWith(' ') || text.includes(' ') || text.includes('\n');
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* WordprocessingML text range — public face of text + character formatting.
|
|
418
|
+
*
|
|
419
|
+
* Physical OOXML remains `w:r` with optional `w:rPr` and `w:t`. Non-text run
|
|
420
|
+
* children (breaks, tabs, symbols, images, …) appear as sibling
|
|
421
|
+
* {@link ParagraphItem}s sharing a private {@link WireRunGroup} so serialization
|
|
422
|
+
* can reconstruct the original run.
|
|
423
|
+
*
|
|
424
|
+
* Character formatting lives on {@link TextRange.characterFormat} only
|
|
425
|
+
* (`docs/specs/run-character-format.md` Rev 2 / TASK-9019).
|
|
426
|
+
*
|
|
427
|
+
* @public
|
|
428
|
+
*/
|
|
429
|
+
var TextRange = /** @class */ (function (_super) {
|
|
430
|
+
__extends(TextRange, _super);
|
|
431
|
+
/**
|
|
432
|
+
* Create a text range. Prefer `new TextRange(document)` so property setters
|
|
433
|
+
* work before the range is appended to a paragraph. Passing a paragraph-item
|
|
434
|
+
* owner attaches immediately (internal / load paths).
|
|
435
|
+
*
|
|
436
|
+
* @public
|
|
437
|
+
*/
|
|
438
|
+
function TextRange(ownerOrDocument, wireGroup) {
|
|
439
|
+
var _this = _super.call(this, wireGroup) || this;
|
|
440
|
+
/**
|
|
441
|
+
* Discriminant for {@link Paragraph.items} / {@link paragraphElementTypeOf}.
|
|
442
|
+
* @public
|
|
443
|
+
*/
|
|
444
|
+
_this.type = EntityType.TextRange;
|
|
445
|
+
_this.textValue = '';
|
|
446
|
+
_this.xmlSpacePreserveValue = false;
|
|
447
|
+
if (ownerOrDocument === undefined) {
|
|
448
|
+
return _this;
|
|
449
|
+
}
|
|
450
|
+
var candidate = ownerOrDocument;
|
|
451
|
+
if (typeof candidate.assertAttachedItem === 'function') {
|
|
452
|
+
_this.attach(candidate);
|
|
453
|
+
return _this;
|
|
454
|
+
}
|
|
455
|
+
_this.setDocumentContext(ownerOrDocument);
|
|
456
|
+
return _this;
|
|
457
|
+
}
|
|
458
|
+
Object.defineProperty(TextRange.prototype, "text", {
|
|
459
|
+
/**
|
|
460
|
+
* Plain text of this range (`w:t`). Setter replaces the text content.
|
|
461
|
+
* @public
|
|
462
|
+
*/
|
|
463
|
+
get: function () {
|
|
464
|
+
return this.textValue;
|
|
465
|
+
},
|
|
466
|
+
set: function (value) {
|
|
467
|
+
this.mutate();
|
|
468
|
+
if (value.length > DEFAULT_RESOURCE_LIMITS.textNodeLength) {
|
|
469
|
+
throw new SecurityError('security/limit-exceeded', 'w:t exceeds the text node length limit');
|
|
470
|
+
}
|
|
471
|
+
this.textValue = value;
|
|
472
|
+
this.xmlSpacePreserveValue = needsXmlSpacePreserve(value);
|
|
473
|
+
},
|
|
474
|
+
enumerable: true,
|
|
475
|
+
configurable: true
|
|
476
|
+
});
|
|
477
|
+
/**
|
|
478
|
+
* Apply character formatting onto this range (DocIO-aligned).
|
|
479
|
+
*
|
|
480
|
+
* - {@link CharacterFormatDelta}: merges listed properties (`assign`).
|
|
481
|
+
* - {@link CharacterFormat}: copies the full snapshot into this range's `rPr`.
|
|
482
|
+
*
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
485
|
+
TextRange.prototype.applyCharacterFormat = function (source) {
|
|
486
|
+
if (source instanceof CharacterFormat) {
|
|
487
|
+
this.characterFormat.hydrate(source.snapshot());
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
this.characterFormat.assign(source);
|
|
491
|
+
};
|
|
492
|
+
Object.defineProperty(TextRange.prototype, "xmlSpacePreserve", {
|
|
493
|
+
/**
|
|
494
|
+
* @private
|
|
495
|
+
*/
|
|
496
|
+
get: function () {
|
|
497
|
+
return this.xmlSpacePreserveValue;
|
|
498
|
+
},
|
|
499
|
+
enumerable: true,
|
|
500
|
+
configurable: true
|
|
501
|
+
});
|
|
502
|
+
/**
|
|
503
|
+
* @private Set text during parse without owner mutation checks or CF wipe.
|
|
504
|
+
*/
|
|
505
|
+
TextRange.prototype.setTextFromParse = function (text, preserveSpace) {
|
|
506
|
+
this.textValue = text;
|
|
507
|
+
this.xmlSpacePreserveValue = preserveSpace;
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* @private
|
|
511
|
+
* Advanced hatch: `w:r` tree for a lone text range. Unstable; prefer semantic properties.
|
|
512
|
+
*/
|
|
513
|
+
TextRange.prototype.toOpenXml = function () {
|
|
514
|
+
return serializeTextRange(this);
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* @private
|
|
518
|
+
*/
|
|
519
|
+
TextRange.fromXml = function (el, owner) {
|
|
520
|
+
var e_1, _a;
|
|
521
|
+
var items = parseTextRangeGroup(el, owner);
|
|
522
|
+
for (var i = 0; i < items.length; i += 1) {
|
|
523
|
+
if (items[i] instanceof TextRange) {
|
|
524
|
+
return items[i];
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
var group = new WireRunGroup(el.attributes);
|
|
528
|
+
var characterFormatData;
|
|
529
|
+
try {
|
|
530
|
+
for (var _b = __values(elementChildren(el)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
531
|
+
var child = _c.value;
|
|
532
|
+
if (isWml(child, 'rPr')) {
|
|
533
|
+
characterFormatData = parseCharacterFormat(child);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
538
|
+
finally {
|
|
539
|
+
try {
|
|
540
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
541
|
+
}
|
|
542
|
+
finally { if (e_1) throw e_1.error; }
|
|
543
|
+
}
|
|
544
|
+
var tr = new TextRange(owner, group);
|
|
545
|
+
if (characterFormatData !== undefined) {
|
|
546
|
+
group.hydrateCharacterFormat(characterFormatData);
|
|
547
|
+
}
|
|
548
|
+
return tr;
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* @private
|
|
552
|
+
*/
|
|
553
|
+
TextRange.prototype.hydrate = function (data) {
|
|
554
|
+
this.wireGroup.setExtraAttributes(data.extraAttributes);
|
|
555
|
+
this.textValue = data.text;
|
|
556
|
+
this.xmlSpacePreserveValue = data.xmlSpacePreserve;
|
|
557
|
+
var _extraAttributes = data.extraAttributes, _text = data.text, _xmlSpacePreserve = data.xmlSpacePreserve, characterFormatData = __rest(data, ["extraAttributes", "text", "xmlSpacePreserve"]);
|
|
558
|
+
void _extraAttributes;
|
|
559
|
+
void _text;
|
|
560
|
+
void _xmlSpacePreserve;
|
|
561
|
+
this.wireGroup.hydrateCharacterFormat(characterFormatData);
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* @private
|
|
565
|
+
*/
|
|
566
|
+
TextRange.prototype.snapshot = function () {
|
|
567
|
+
var cf = this.characterFormat.snapshot();
|
|
568
|
+
return {
|
|
569
|
+
extraAttributes: this.wireGroup.extraAttributes,
|
|
570
|
+
text: this.textValue,
|
|
571
|
+
xmlSpacePreserve: this.xmlSpacePreserveValue,
|
|
572
|
+
rPrExtra: cf.rPrExtra,
|
|
573
|
+
styleIdValue: cf.styleIdValue,
|
|
574
|
+
boldValue: cf.boldValue,
|
|
575
|
+
italicValue: cf.italicValue,
|
|
576
|
+
strikeValue: cf.strikeValue,
|
|
577
|
+
doubleStrikeValue: cf.doubleStrikeValue,
|
|
578
|
+
vanishValue: cf.vanishValue,
|
|
579
|
+
legacyHiddenValue: cf.legacyHiddenValue,
|
|
580
|
+
noProofValue: cf.noProofValue,
|
|
581
|
+
fontSizeValue: cf.fontSizeValue,
|
|
582
|
+
fontSizeBidiValue: cf.fontSizeBidiValue,
|
|
583
|
+
textColorValue: cf.textColorValue,
|
|
584
|
+
textColorTheme: cf.textColorTheme,
|
|
585
|
+
highlightValue: cf.highlightValue,
|
|
586
|
+
shadingValue: cf.shadingValue,
|
|
587
|
+
underlineStyleValue: cf.underlineStyleValue,
|
|
588
|
+
underlineColorValue: cf.underlineColorValue,
|
|
589
|
+
vertAlignValue: cf.vertAlignValue,
|
|
590
|
+
smallCapsValue: cf.smallCapsValue,
|
|
591
|
+
allCapsValue: cf.allCapsValue,
|
|
592
|
+
fontsValue: cf.fontsValue,
|
|
593
|
+
characterScaleValue: cf.characterScaleValue,
|
|
594
|
+
kerningValue: cf.kerningValue,
|
|
595
|
+
characterSpacingValue: cf.characterSpacingValue,
|
|
596
|
+
positionValue: cf.positionValue,
|
|
597
|
+
borderValue: cf.borderValue,
|
|
598
|
+
languageValue: cf.languageValue,
|
|
599
|
+
embossValue: cf.embossValue,
|
|
600
|
+
imprintValue: cf.imprintValue,
|
|
601
|
+
outlineValue: cf.outlineValue,
|
|
602
|
+
shadowValue: cf.shadowValue,
|
|
603
|
+
webHiddenValue: cf.webHiddenValue,
|
|
604
|
+
bidiValue: cf.bidiValue,
|
|
605
|
+
complexScriptValue: cf.complexScriptValue,
|
|
606
|
+
boldBidiValue: cf.boldBidiValue,
|
|
607
|
+
italicBidiValue: cf.italicBidiValue,
|
|
608
|
+
emphasisValue: cf.emphasisValue,
|
|
609
|
+
textEffectValue: cf.textEffectValue,
|
|
610
|
+
specVanishValue: cf.specVanishValue,
|
|
611
|
+
snapToGridValue: cf.snapToGridValue,
|
|
612
|
+
};
|
|
613
|
+
};
|
|
614
|
+
return TextRange;
|
|
615
|
+
}(WireRunParagraphItem));
|
|
616
|
+
export { TextRange };
|
|
617
|
+
// Re-export base types for consumers that import from text-range.
|
|
618
|
+
// ---------------------------------------------------------------------------
|
|
619
|
+
// Break helpers
|
|
620
|
+
// ---------------------------------------------------------------------------
|
|
621
|
+
function isWrappingBreakType(type) {
|
|
622
|
+
return type === BreakType.LineBreak || type === BreakType.TextWrappingBreak;
|
|
623
|
+
}
|
|
624
|
+
function createBreakItem(group, type, clear, extras) {
|
|
625
|
+
if (clear === void 0) { clear = BreakClearType.None; }
|
|
626
|
+
if (clear !== BreakClearType.None && !isWrappingBreakType(type)) {
|
|
627
|
+
throw new DocxError('content/invalid-break', 'w:br @w:clear is only valid with a line / text-wrapping break');
|
|
628
|
+
}
|
|
629
|
+
return new Break(type, clear, extras, group);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* @private Author a break item under a new wire group (single-item run).
|
|
633
|
+
*/
|
|
634
|
+
export function createStandaloneBreakItem(type, clear) {
|
|
635
|
+
return createBreakItem(new WireRunGroup(), type, clear != null ? clear : BreakClearType.None);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* @private Author a symbol item under a new wire group.
|
|
639
|
+
*/
|
|
640
|
+
export function createStandaloneSymbolItem(font, char) {
|
|
641
|
+
return new Symbol(font, char, new WireRunGroup());
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* @private Author a tab item under a new wire group.
|
|
645
|
+
*/
|
|
646
|
+
export function createStandaloneTabItem() {
|
|
647
|
+
return new Tab(new WireRunGroup());
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Split plain text on U+0009 into {@link TextRange} and {@link Tab} items that
|
|
651
|
+
* share one {@link WireRunGroup} (one physical `w:r` with interleaved `w:t` /
|
|
652
|
+
* `w:tab`). Empty segments around tabs are omitted. Text with no tab characters
|
|
653
|
+
* yields a single {@link TextRange} (possibly empty). Tab-only text yields only
|
|
654
|
+
* {@link Tab} items.
|
|
655
|
+
*
|
|
656
|
+
* Citation: ECMA-376-1 `EG_RunInnerContent` / `w:tab` (run-level tab character).
|
|
657
|
+
*
|
|
658
|
+
* @private
|
|
659
|
+
*/
|
|
660
|
+
export function createTextAndTabItems(text, wireGroup) {
|
|
661
|
+
var group = wireGroup != null ? wireGroup : new WireRunGroup();
|
|
662
|
+
if (text.indexOf('\t') < 0) {
|
|
663
|
+
return [createDetachedTextRange(text, group)];
|
|
664
|
+
}
|
|
665
|
+
var parts = text.split('\t');
|
|
666
|
+
var items = [];
|
|
667
|
+
for (var i = 0; i < parts.length; i += 1) {
|
|
668
|
+
var part = parts[i];
|
|
669
|
+
if (part !== undefined && part.length > 0) {
|
|
670
|
+
items.push(createDetachedTextRange(part, group));
|
|
671
|
+
}
|
|
672
|
+
if (i < parts.length - 1) {
|
|
673
|
+
items.push(new Tab(group));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return items;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Author a detached {@link TextRange} with text set without owner mutation
|
|
680
|
+
* (items are not yet on a paragraph). Enforces the same text-node length limit
|
|
681
|
+
* as the public {@link TextRange.text} setter.
|
|
682
|
+
*
|
|
683
|
+
* @private
|
|
684
|
+
*/
|
|
685
|
+
function createDetachedTextRange(text, group) {
|
|
686
|
+
if (text.length > DEFAULT_RESOURCE_LIMITS.textNodeLength) {
|
|
687
|
+
throw new SecurityError('security/limit-exceeded', 'w:t exceeds the text node length limit');
|
|
688
|
+
}
|
|
689
|
+
var tr = new TextRange(undefined, group);
|
|
690
|
+
tr.setTextFromParse(text, needsXmlSpacePreserve(text));
|
|
691
|
+
return tr;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Emit run-level children for plain text that may contain U+0009.
|
|
695
|
+
* Tab characters become dedicated `w:tab` elements; text segments become `w:t`
|
|
696
|
+
* (or `w:instrText` when `isFieldInstruction` is true — tabs stay in the string
|
|
697
|
+
* there so field codes are not rewritten as run leaves).
|
|
698
|
+
*
|
|
699
|
+
* @private
|
|
700
|
+
*/
|
|
701
|
+
function appendSerializedTextLeaves(text, isFieldInstruction, into) {
|
|
702
|
+
if (isFieldInstruction || text.indexOf('\t') < 0) {
|
|
703
|
+
var attributes = isFieldInstruction || needsXmlSpacePreserve(text) ? [xmlSpacePreserve()] : [];
|
|
704
|
+
var name_1 = isFieldInstruction ? 'instrText' : 't';
|
|
705
|
+
into.push(wmlElement(name_1, {
|
|
706
|
+
attributes: attributes,
|
|
707
|
+
children: [{ kind: 'text', value: text }],
|
|
708
|
+
}));
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
var parts = text.split('\t');
|
|
712
|
+
for (var i = 0; i < parts.length; i += 1) {
|
|
713
|
+
var part = parts[i];
|
|
714
|
+
if (part !== undefined && part.length > 0) {
|
|
715
|
+
var attributes = needsXmlSpacePreserve(part) ? [xmlSpacePreserve()] : [];
|
|
716
|
+
into.push(wmlElement('t', {
|
|
717
|
+
attributes: attributes,
|
|
718
|
+
children: [{ kind: 'text', value: part }],
|
|
719
|
+
}));
|
|
720
|
+
}
|
|
721
|
+
if (i < parts.length - 1) {
|
|
722
|
+
into.push(wmlElement('tab'));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
// ---------------------------------------------------------------------------
|
|
727
|
+
// Parse w:r → flat paragraph items sharing one WireRunGroup
|
|
728
|
+
// ---------------------------------------------------------------------------
|
|
729
|
+
/**
|
|
730
|
+
* Parse a physical `w:r` into one or more flattened {@link ParagraphItem}s that
|
|
731
|
+
* share character formatting via {@link WireRunGroup}.
|
|
732
|
+
*
|
|
733
|
+
* @private
|
|
734
|
+
*/
|
|
735
|
+
export function parseTextRangeGroup(el, owner) {
|
|
736
|
+
var e_2, _a;
|
|
737
|
+
var group = new WireRunGroup(el.attributes);
|
|
738
|
+
var items = [];
|
|
739
|
+
var characterFormatData;
|
|
740
|
+
try {
|
|
741
|
+
for (var _b = __values(elementChildren(el)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
742
|
+
var child = _c.value;
|
|
743
|
+
if (isWml(child, 'rPr')) {
|
|
744
|
+
characterFormatData = parseCharacterFormat(child);
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
items.push(parseRunChildToItem(child, group, owner));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
751
|
+
finally {
|
|
752
|
+
try {
|
|
753
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
754
|
+
}
|
|
755
|
+
finally { if (e_2) throw e_2.error; }
|
|
756
|
+
}
|
|
757
|
+
if (characterFormatData !== undefined) {
|
|
758
|
+
group.hydrateCharacterFormat(characterFormatData);
|
|
759
|
+
}
|
|
760
|
+
if (items.length === 0) {
|
|
761
|
+
var empty = new TextRange(owner, group);
|
|
762
|
+
items.push(empty);
|
|
763
|
+
}
|
|
764
|
+
return items;
|
|
765
|
+
}
|
|
766
|
+
function parseRunChildToItem(child, group, owner) {
|
|
767
|
+
if (isWml(child, 't')) {
|
|
768
|
+
var text = textContent(child);
|
|
769
|
+
var tr = new TextRange(owner, group);
|
|
770
|
+
tr.setTextFromParse(text, xmlSpaceIsPreserve(child) || needsXmlSpacePreserve(text));
|
|
771
|
+
return tr;
|
|
772
|
+
}
|
|
773
|
+
if (isWml(child, 'tab')) {
|
|
774
|
+
return new Tab(group);
|
|
775
|
+
}
|
|
776
|
+
if (isWml(child, 'br')) {
|
|
777
|
+
return parseBreakItem(child, group);
|
|
778
|
+
}
|
|
779
|
+
if (isWml(child, 'cr')) {
|
|
780
|
+
return new CarriageReturn(group);
|
|
781
|
+
}
|
|
782
|
+
if (isWml(child, 'sym')) {
|
|
783
|
+
return parseSymItem(child, group);
|
|
784
|
+
}
|
|
785
|
+
var feature = tryParseFeatureRunLeaf(child);
|
|
786
|
+
if (feature !== undefined) {
|
|
787
|
+
return new FeatureRunParagraphItem(feature.featureId, feature.value, group);
|
|
788
|
+
}
|
|
789
|
+
return new OpaqueRunItem(child, group);
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Parse `w:br` (`CT_Br`: optional `w:type`, `w:clear`).
|
|
793
|
+
*/
|
|
794
|
+
function parseBreakItem(child, group) {
|
|
795
|
+
var e_3, _a;
|
|
796
|
+
var breakType = BreakType.LineBreak;
|
|
797
|
+
var clear;
|
|
798
|
+
var knownType = false;
|
|
799
|
+
var knownClear = false;
|
|
800
|
+
var typeRaw = wmlAttrValLocal(child, 'type');
|
|
801
|
+
if (typeRaw === 'page') {
|
|
802
|
+
breakType = BreakType.PageBreak;
|
|
803
|
+
knownType = true;
|
|
804
|
+
}
|
|
805
|
+
else if (typeRaw === 'column') {
|
|
806
|
+
breakType = BreakType.ColumnBreak;
|
|
807
|
+
knownType = true;
|
|
808
|
+
}
|
|
809
|
+
else if (typeRaw === 'textWrapping') {
|
|
810
|
+
breakType = BreakType.TextWrappingBreak;
|
|
811
|
+
knownType = true;
|
|
812
|
+
}
|
|
813
|
+
else if (typeRaw === undefined) {
|
|
814
|
+
knownType = true;
|
|
815
|
+
}
|
|
816
|
+
else if (typeRaw === 'line') {
|
|
817
|
+
breakType = BreakType.LineBreak;
|
|
818
|
+
knownType = true;
|
|
819
|
+
}
|
|
820
|
+
var clearRaw = wmlAttrValLocal(child, 'clear');
|
|
821
|
+
if (breakType === BreakType.LineBreak || breakType === BreakType.TextWrappingBreak) {
|
|
822
|
+
if (clearRaw === 'left') {
|
|
823
|
+
clear = BreakClearType.Left;
|
|
824
|
+
knownClear = true;
|
|
825
|
+
}
|
|
826
|
+
else if (clearRaw === 'right') {
|
|
827
|
+
clear = BreakClearType.Right;
|
|
828
|
+
knownClear = true;
|
|
829
|
+
}
|
|
830
|
+
else if (clearRaw === 'all') {
|
|
831
|
+
clear = BreakClearType.All;
|
|
832
|
+
knownClear = true;
|
|
833
|
+
}
|
|
834
|
+
else if (clearRaw === 'none') {
|
|
835
|
+
knownClear = false;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
var extras = [];
|
|
839
|
+
try {
|
|
840
|
+
for (var _b = __values(child.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
841
|
+
var attr = _c.value;
|
|
842
|
+
var isWmlAttr = attr.prefix === 'w' || attr.prefix === '';
|
|
843
|
+
if (isWmlAttr && attr.localName === 'type') {
|
|
844
|
+
if (knownType) {
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
extras.push(attr);
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
if (isWmlAttr && attr.localName === 'clear') {
|
|
851
|
+
if (knownClear) {
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
extras.push(attr);
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
extras.push(attr);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
861
|
+
finally {
|
|
862
|
+
try {
|
|
863
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
864
|
+
}
|
|
865
|
+
finally { if (e_3) throw e_3.error; }
|
|
866
|
+
}
|
|
867
|
+
return new Break(breakType, clear, extras, group);
|
|
868
|
+
}
|
|
869
|
+
function serializeBreakItem(leaf) {
|
|
870
|
+
var e_4, _a;
|
|
871
|
+
var attributes = [];
|
|
872
|
+
if (leaf.breakType === BreakType.PageBreak) {
|
|
873
|
+
attributes.push(wmlAttr('type', 'page'));
|
|
874
|
+
}
|
|
875
|
+
else if (leaf.breakType === BreakType.ColumnBreak) {
|
|
876
|
+
attributes.push(wmlAttr('type', 'column'));
|
|
877
|
+
}
|
|
878
|
+
else if (leaf.breakType === BreakType.TextWrappingBreak) {
|
|
879
|
+
attributes.push(wmlAttr('type', 'textWrapping'));
|
|
880
|
+
if (leaf.clear !== undefined) {
|
|
881
|
+
attributes.push(wmlAttr('clear', leaf.clear));
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
else if (leaf.clear !== undefined) {
|
|
885
|
+
attributes.push(wmlAttr('type', 'textWrapping'));
|
|
886
|
+
attributes.push(wmlAttr('clear', leaf.clear));
|
|
887
|
+
}
|
|
888
|
+
try {
|
|
889
|
+
for (var _b = __values(leaf.extras), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
890
|
+
var extra = _c.value;
|
|
891
|
+
attributes.push(extra);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
895
|
+
finally {
|
|
896
|
+
try {
|
|
897
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
898
|
+
}
|
|
899
|
+
finally { if (e_4) throw e_4.error; }
|
|
900
|
+
}
|
|
901
|
+
return wmlElement('br', { attributes: attributes });
|
|
902
|
+
}
|
|
903
|
+
function parseSymItem(child, group) {
|
|
904
|
+
var e_5, _a;
|
|
905
|
+
try {
|
|
906
|
+
for (var _b = __values(child.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
907
|
+
var attr = _c.value;
|
|
908
|
+
if (attr.localName === 'font' || attr.localName === 'char') {
|
|
909
|
+
if (attr.prefix !== 'w' && attr.prefix !== '') {
|
|
910
|
+
return new OpaqueRunItem(child, group);
|
|
911
|
+
}
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
return new OpaqueRunItem(child, group);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
918
|
+
finally {
|
|
919
|
+
try {
|
|
920
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
921
|
+
}
|
|
922
|
+
finally { if (e_5) throw e_5.error; }
|
|
923
|
+
}
|
|
924
|
+
if (child.children.length > 0) {
|
|
925
|
+
return new OpaqueRunItem(child, group);
|
|
926
|
+
}
|
|
927
|
+
var font = wmlAttrValLocal(child, 'font');
|
|
928
|
+
var char = wmlAttrValLocal(child, 'char');
|
|
929
|
+
if (font === undefined || char === undefined) {
|
|
930
|
+
return new OpaqueRunItem(child, group);
|
|
931
|
+
}
|
|
932
|
+
if (!/^[0-9A-Fa-f]{4}$/.test(char)) {
|
|
933
|
+
return new OpaqueRunItem(child, group);
|
|
934
|
+
}
|
|
935
|
+
return new Symbol(font, char, group);
|
|
936
|
+
}
|
|
937
|
+
function serializeRunLevelItem(item, isFieldInstruction) {
|
|
938
|
+
if (isFieldInstruction === void 0) { isFieldInstruction = false; }
|
|
939
|
+
if (item instanceof TextRange) {
|
|
940
|
+
// Prefer appendSerializedTextLeaves via serializeWireGroupItems for tab expansion.
|
|
941
|
+
// Single-leaf path (no U+0009, or field instruction): one w:t / w:instrText.
|
|
942
|
+
if (!isFieldInstruction && item.text.indexOf('\t') >= 0) {
|
|
943
|
+
return undefined;
|
|
944
|
+
}
|
|
945
|
+
var attributes = item.xmlSpacePreserve || isFieldInstruction ? [xmlSpacePreserve()] : [];
|
|
946
|
+
// If this TextRange is field instruction text, emit w:instrText instead of w:t
|
|
947
|
+
if (isFieldInstruction) {
|
|
948
|
+
return wmlElement('instrText', {
|
|
949
|
+
attributes: attributes,
|
|
950
|
+
children: [{ kind: 'text', value: item.text }],
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
return wmlElement('t', {
|
|
954
|
+
attributes: attributes,
|
|
955
|
+
children: [{ kind: 'text', value: item.text }],
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
if (item instanceof Tab) {
|
|
959
|
+
return wmlElement('tab');
|
|
960
|
+
}
|
|
961
|
+
if (item instanceof Break) {
|
|
962
|
+
return serializeBreakItem(item);
|
|
963
|
+
}
|
|
964
|
+
if (item instanceof CarriageReturn) {
|
|
965
|
+
return wmlElement('cr');
|
|
966
|
+
}
|
|
967
|
+
if (item instanceof Symbol) {
|
|
968
|
+
return wmlElement('sym', {
|
|
969
|
+
attributes: [wmlAttr('font', item.font), wmlAttr('char', item.char)],
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
// Field begin / FieldMark separator|end: emit w:fldChar as run child.
|
|
973
|
+
if (typeof item === 'object' && item !== null && 'toOpenXml' in item &&
|
|
974
|
+
('fieldType' in item || 'fieldMarkType' in item)) {
|
|
975
|
+
return item.toOpenXml();
|
|
976
|
+
}
|
|
977
|
+
if (item instanceof FeatureRunParagraphItem) {
|
|
978
|
+
return serializeFeatureRunLeaf({
|
|
979
|
+
type: 'feature',
|
|
980
|
+
featureId: item.featureId,
|
|
981
|
+
value: item.value,
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
if (item instanceof OpaqueRunItem) {
|
|
985
|
+
return item.xml;
|
|
986
|
+
}
|
|
987
|
+
return undefined;
|
|
988
|
+
}
|
|
989
|
+
function wmlAttrValLocal(el, localName) {
|
|
990
|
+
var __ts33_0;
|
|
991
|
+
return ((__ts33_0 = el.attributes.find(function (a) {
|
|
992
|
+
return a.localName === localName && (a.prefix === 'w' || a.prefix === '');
|
|
993
|
+
})),
|
|
994
|
+
__ts33_0 == null ? undefined : __ts33_0.value);
|
|
995
|
+
}
|
|
996
|
+
function isWireRunMember(item) {
|
|
997
|
+
if (item instanceof WireRunParagraphItem) {
|
|
998
|
+
return true;
|
|
999
|
+
}
|
|
1000
|
+
// Field / FieldMark implement WireRunMember without extending WireRunParagraphItem.
|
|
1001
|
+
return typeof item === 'object' && item !== null && 'wireGroup' in item;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Serialize a lone {@link TextRange} as a complete `w:r` (rPr + single w:t).
|
|
1005
|
+
* Prefer {@link serializeParagraphItems} when emitting a full paragraph.
|
|
1006
|
+
*
|
|
1007
|
+
* @private
|
|
1008
|
+
*/
|
|
1009
|
+
export function serializeTextRange(textRange) {
|
|
1010
|
+
return serializeWireGroupItems(textRange.wireGroup, [textRange]);
|
|
1011
|
+
}
|
|
1012
|
+
function serializeWireGroupItems(group, members, instructionMap) {
|
|
1013
|
+
var e_6, _a;
|
|
1014
|
+
var rPrChildren = group.characterFormat.buildRPrChildren();
|
|
1015
|
+
var children = [];
|
|
1016
|
+
if (rPrChildren.length > 0) {
|
|
1017
|
+
children.push(wmlElement('rPr', { children: rPrChildren }));
|
|
1018
|
+
}
|
|
1019
|
+
try {
|
|
1020
|
+
for (var members_1 = __values(members), members_1_1 = members_1.next(); !members_1_1.done; members_1_1 = members_1.next()) {
|
|
1021
|
+
var member = members_1_1.value;
|
|
1022
|
+
var isInstruction = instructionMap !== undefined && instructionMap.get(member) === true;
|
|
1023
|
+
if (member instanceof TextRange && !isInstruction && member.text.indexOf('\t') >= 0) {
|
|
1024
|
+
// Safety net: residual U+0009 in modeled text becomes w:tab leaves.
|
|
1025
|
+
appendSerializedTextLeaves(member.text, false, children);
|
|
1026
|
+
continue;
|
|
1027
|
+
}
|
|
1028
|
+
var el = serializeRunLevelItem(member, isInstruction);
|
|
1029
|
+
if (el !== undefined) {
|
|
1030
|
+
children.push(el);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1035
|
+
finally {
|
|
1036
|
+
try {
|
|
1037
|
+
if (members_1_1 && !members_1_1.done && (_a = members_1.return)) _a.call(members_1);
|
|
1038
|
+
}
|
|
1039
|
+
finally { if (e_6) throw e_6.error; }
|
|
1040
|
+
}
|
|
1041
|
+
return wmlElement('r', { attributes: group.extraAttributes, children: children });
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Build a map of TextRange items that are field instruction text.
|
|
1045
|
+
* Uses depth-aware field stack to classify items by their structural position.
|
|
1046
|
+
*
|
|
1047
|
+
* @private
|
|
1048
|
+
*/
|
|
1049
|
+
function buildFieldInstructionMap(items) {
|
|
1050
|
+
var instructionMap = new Map();
|
|
1051
|
+
var fieldStack = [];
|
|
1052
|
+
for (var i = 0; i < items.length; i++) {
|
|
1053
|
+
var item = items[i];
|
|
1054
|
+
if (item === undefined) {
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
// Check if this is a Field (has fieldType property)
|
|
1058
|
+
if (typeof item === 'object' && 'fieldType' in item) {
|
|
1059
|
+
fieldStack.push({ phase: 'instruction' });
|
|
1060
|
+
continue;
|
|
1061
|
+
}
|
|
1062
|
+
// Check if this is a FieldMark (has fieldMarkType property)
|
|
1063
|
+
if (typeof item === 'object' && 'fieldMarkType' in item) {
|
|
1064
|
+
var fieldMarkType = item.fieldMarkType;
|
|
1065
|
+
if (fieldMarkType === 'separate') {
|
|
1066
|
+
// Update the active field state to result phase
|
|
1067
|
+
if (fieldStack.length > 0) {
|
|
1068
|
+
fieldStack[fieldStack.length - 1].phase = 'result';
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
else if (fieldMarkType === 'end') {
|
|
1072
|
+
// Pop the active field
|
|
1073
|
+
if (fieldStack.length > 0) {
|
|
1074
|
+
fieldStack.pop();
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
// For TextRange items, record whether they're instruction text
|
|
1080
|
+
if (item instanceof TextRange) {
|
|
1081
|
+
var isInstruction = fieldStack.length > 0 && fieldStack[fieldStack.length - 1].phase === 'instruction';
|
|
1082
|
+
instructionMap.set(item, isInstruction);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
return instructionMap;
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Serialize flattened paragraph items, regrouping consecutive wire-run members
|
|
1089
|
+
* that share the same {@link WireRunGroup} into physical `w:r` elements.
|
|
1090
|
+
* Field and FieldMark items serialize directly.
|
|
1091
|
+
* TextRange items in field instruction regions serialize as w:instrText.
|
|
1092
|
+
*
|
|
1093
|
+
* @private
|
|
1094
|
+
*/
|
|
1095
|
+
export function serializeParagraphItems(items) {
|
|
1096
|
+
var out = [];
|
|
1097
|
+
var instructionMap = buildFieldInstructionMap(items);
|
|
1098
|
+
var i = 0;
|
|
1099
|
+
while (i < items.length) {
|
|
1100
|
+
var item = items[i];
|
|
1101
|
+
if (item === undefined) {
|
|
1102
|
+
i += 1;
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
if (item instanceof FeatureInlineParagraphItem) {
|
|
1106
|
+
out.push(item.value.toOpenXml());
|
|
1107
|
+
i += 1;
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
if (item instanceof OpaqueParagraphItem) {
|
|
1111
|
+
out.push(item.xml);
|
|
1112
|
+
i += 1;
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
// Field / FieldMark / TextRange / breaks share WireRunGroup → under w:r
|
|
1116
|
+
if (!isWireRunMember(item)) {
|
|
1117
|
+
i += 1;
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
var group = item.wireGroup;
|
|
1121
|
+
var members = [item];
|
|
1122
|
+
var j = i + 1;
|
|
1123
|
+
while (j < items.length) {
|
|
1124
|
+
var next = items[j];
|
|
1125
|
+
if (next === undefined || !isWireRunMember(next) || next.wireGroup !== group) {
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
members.push(next);
|
|
1129
|
+
j += 1;
|
|
1130
|
+
}
|
|
1131
|
+
out.push(serializeWireGroupItems(group, members, instructionMap));
|
|
1132
|
+
i = j;
|
|
1133
|
+
}
|
|
1134
|
+
return out;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* @deprecated Prefer {@link TextRange}.
|
|
1138
|
+
* @private
|
|
1139
|
+
*/
|
|
1140
|
+
export var Run = TextRange;
|
|
1141
|
+
/**
|
|
1142
|
+
* @deprecated Prefer {@link serializeTextRange}.
|
|
1143
|
+
* @private
|
|
1144
|
+
*/
|
|
1145
|
+
export var serializeRun = serializeTextRange;
|
|
1146
|
+
/**
|
|
1147
|
+
* Public break view (no extras / wireGroup).
|
|
1148
|
+
* @private
|
|
1149
|
+
*/
|
|
1150
|
+
export function toBreakLeafView(leaf) {
|
|
1151
|
+
return {
|
|
1152
|
+
type: 'break',
|
|
1153
|
+
breakType: leaf.breakType,
|
|
1154
|
+
clear: leaf.clear !== undefined ? leaf.clear : BreakClearType.None,
|
|
1155
|
+
};
|
|
1156
|
+
}
|