@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,1727 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
var __values = (this && this.__values) || function (o) {
|
|
22
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
23
|
+
if (m) return m.call(o);
|
|
24
|
+
return {
|
|
25
|
+
next: function () {
|
|
26
|
+
if (o && i >= o.length) o = void 0;
|
|
27
|
+
return { value: o && o[i++], done: !o };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
32
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
33
|
+
if (!m) return o;
|
|
34
|
+
var i = m.call(o), r, ar = [], e;
|
|
35
|
+
try {
|
|
36
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
37
|
+
}
|
|
38
|
+
catch (error) { e = { error: error }; }
|
|
39
|
+
finally {
|
|
40
|
+
try {
|
|
41
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
42
|
+
}
|
|
43
|
+
finally { if (e) throw e.error; }
|
|
44
|
+
}
|
|
45
|
+
return ar;
|
|
46
|
+
};
|
|
47
|
+
var __spread = (this && this.__spread) || function () {
|
|
48
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
export * from './comment-extensions';
|
|
52
|
+
import { DetachedObjectError, DocxError } from '../../core/errors/docx-error';
|
|
53
|
+
import { registerAlwaysOnBodyFeatureBootstrap } from '../document/body-always-on';
|
|
54
|
+
import { parseBodyBlocks, serializeBodyBlocks } from '../document/body-blocks';
|
|
55
|
+
import { WordDocument } from '../document/document';
|
|
56
|
+
import { Paragraph } from '../document/paragraph';
|
|
57
|
+
import { FeatureInlineParagraphItem, FeatureRunParagraphItem, TextRange, WireRunGroup, } from '../document/text-range';
|
|
58
|
+
import { elementChildren, isWml, wmlAttr, wmlElement } from '../document/wml';
|
|
59
|
+
import { allocateRelationshipId } from '../../core/opc/relationships';
|
|
60
|
+
import { partByName, relationshipsForPart } from '../../core/opc/package';
|
|
61
|
+
import { partName, partNameKey, resolveInternalTarget } from '../../core/opc/part-name';
|
|
62
|
+
import { featureId, isFeatureRegistered, registerFeature, registerFeatureInlineHandler, registerFeatureMultiPartHandler, registerFeatureRunLeafHandler, } from '../../core/registry/index';
|
|
63
|
+
import { replaceOrAddPackagePart } from '../../core/registry/multi-part-handlers';
|
|
64
|
+
import { parseXml, serializeXml, WML_TRANSITIONAL_NAMESPACE } from '../../core/xml/index';
|
|
65
|
+
import { WORDML_2010_NAMESPACE } from '../content-controls/index';
|
|
66
|
+
import { CommentExtensionParts, loadCommentExtensionMetadata } from './comment-extensions';
|
|
67
|
+
var COMMENTS = featureId('comments');
|
|
68
|
+
var WML = WML_TRANSITIONAL_NAMESPACE;
|
|
69
|
+
var utf8Decoder = new TextDecoder('utf-8');
|
|
70
|
+
var utf8 = new TextEncoder();
|
|
71
|
+
/**
|
|
72
|
+
* @private Transitional comments relationship (ECMA-376-4). */
|
|
73
|
+
export var COMMENTS_RELATIONSHIP_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments';
|
|
74
|
+
/**
|
|
75
|
+
* @private Strict comments relationship. */
|
|
76
|
+
export var STRICT_COMMENTS_RELATIONSHIP_TYPE = 'http://purl.oclc.org/ooxml/officeDocument/relationships/comments';
|
|
77
|
+
/** @private */
|
|
78
|
+
export var COMMENTS_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml';
|
|
79
|
+
var COMMENTS_RELATIONSHIP_TYPES = [
|
|
80
|
+
COMMENTS_RELATIONSHIP_TYPE,
|
|
81
|
+
STRICT_COMMENTS_RELATIONSHIP_TYPE,
|
|
82
|
+
];
|
|
83
|
+
function wmlAttribute(el, localName) {
|
|
84
|
+
var __ts33_0;
|
|
85
|
+
return ((__ts33_0 = el.attributes.find(function (a) { return a.localName === localName && (a.namespaceUri === '' || a.prefix === 'w'); })), __ts33_0 == null ? undefined : __ts33_0.value);
|
|
86
|
+
}
|
|
87
|
+
function parseCommentId(raw) {
|
|
88
|
+
if (raw === undefined || !/^\d+$/.test(raw)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return Number.parseInt(raw, 10);
|
|
92
|
+
}
|
|
93
|
+
var detachedParagraphOwner = {
|
|
94
|
+
assertAttachedParagraph: function () {
|
|
95
|
+
return;
|
|
96
|
+
},
|
|
97
|
+
owningDocument: function () {
|
|
98
|
+
throw new DetachedObjectError('Comment content is not in a WordDocument');
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
/** Ephemeral owner for building default elevated comment reference formatting. */
|
|
102
|
+
var detachedTextRangeOwner = {
|
|
103
|
+
assertAttachedItem: function () {
|
|
104
|
+
return;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
/** Word character style commonly applied to sole-purpose `w:commentReference` runs. */
|
|
108
|
+
var COMMENT_REFERENCE_STYLE_ID = 'CommentReference';
|
|
109
|
+
function formattingFromWireGroup(group) {
|
|
110
|
+
var cf = group.snapshotCharacterFormat();
|
|
111
|
+
return {
|
|
112
|
+
extraAttributes: group.extraAttributes,
|
|
113
|
+
rPrExtra: cf.rPrExtra,
|
|
114
|
+
styleIdValue: cf.styleIdValue,
|
|
115
|
+
boldValue: cf.boldValue,
|
|
116
|
+
italicValue: cf.italicValue,
|
|
117
|
+
strikeValue: cf.strikeValue,
|
|
118
|
+
doubleStrikeValue: cf.doubleStrikeValue,
|
|
119
|
+
vanishValue: cf.vanishValue,
|
|
120
|
+
legacyHiddenValue: cf.legacyHiddenValue,
|
|
121
|
+
noProofValue: cf.noProofValue,
|
|
122
|
+
fontSizeValue: cf.fontSizeValue,
|
|
123
|
+
fontSizeBidiValue: cf.fontSizeBidiValue,
|
|
124
|
+
textColorValue: cf.textColorValue,
|
|
125
|
+
textColorTheme: cf.textColorTheme,
|
|
126
|
+
highlightValue: cf.highlightValue,
|
|
127
|
+
shadingValue: cf.shadingValue,
|
|
128
|
+
underlineStyleValue: cf.underlineStyleValue,
|
|
129
|
+
underlineColorValue: cf.underlineColorValue,
|
|
130
|
+
vertAlignValue: cf.vertAlignValue,
|
|
131
|
+
smallCapsValue: cf.smallCapsValue,
|
|
132
|
+
allCapsValue: cf.allCapsValue,
|
|
133
|
+
fontsValue: cf.fontsValue,
|
|
134
|
+
characterScaleValue: cf.characterScaleValue,
|
|
135
|
+
kerningValue: cf.kerningValue,
|
|
136
|
+
characterSpacingValue: cf.characterSpacingValue,
|
|
137
|
+
positionValue: cf.positionValue,
|
|
138
|
+
borderValue: cf.borderValue,
|
|
139
|
+
languageValue: cf.languageValue,
|
|
140
|
+
embossValue: cf.embossValue,
|
|
141
|
+
imprintValue: cf.imprintValue,
|
|
142
|
+
outlineValue: cf.outlineValue,
|
|
143
|
+
shadowValue: cf.shadowValue,
|
|
144
|
+
webHiddenValue: cf.webHiddenValue,
|
|
145
|
+
bidiValue: cf.bidiValue,
|
|
146
|
+
complexScriptValue: cf.complexScriptValue,
|
|
147
|
+
boldBidiValue: cf.boldBidiValue,
|
|
148
|
+
italicBidiValue: cf.italicBidiValue,
|
|
149
|
+
emphasisValue: cf.emphasisValue,
|
|
150
|
+
textEffectValue: cf.textEffectValue,
|
|
151
|
+
specVanishValue: cf.specVanishValue,
|
|
152
|
+
snapToGridValue: cf.snapToGridValue,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function emptyReferenceRunFormatting(styleId) {
|
|
156
|
+
var group = new WireRunGroup();
|
|
157
|
+
// Attach a transient TextRange so CharacterFormat host paths stay consistent.
|
|
158
|
+
void new TextRange(detachedTextRangeOwner, group);
|
|
159
|
+
if (styleId !== undefined) {
|
|
160
|
+
group.characterFormat.characterStyle = styleId;
|
|
161
|
+
}
|
|
162
|
+
return formattingFromWireGroup(group);
|
|
163
|
+
}
|
|
164
|
+
function serializeElevatedCommentReference(commentId, formatting) {
|
|
165
|
+
var group = new WireRunGroup(formatting.extraAttributes);
|
|
166
|
+
var _extraAttributes = formatting.extraAttributes, characterFormatData = __rest(formatting, ["extraAttributes"]);
|
|
167
|
+
void _extraAttributes;
|
|
168
|
+
group.hydrateCharacterFormat(characterFormatData);
|
|
169
|
+
var rPrChildren = group.characterFormat.buildRPrChildren();
|
|
170
|
+
var children = [];
|
|
171
|
+
if (rPrChildren.length > 0) {
|
|
172
|
+
children.push(wmlElement('rPr', { children: rPrChildren }));
|
|
173
|
+
}
|
|
174
|
+
children.push(wmlElement('commentReference', { attributes: [wmlAttr('id', String(commentId))] }));
|
|
175
|
+
return wmlElement('r', { attributes: group.extraAttributes, children: children });
|
|
176
|
+
}
|
|
177
|
+
function blocksWithSimpleText(text) {
|
|
178
|
+
var paragraph = wmlElement('p', {
|
|
179
|
+
children: [wmlElement('r', { children: [wmlElement('t', { children: [{ kind: 'text', value: text }] })] })],
|
|
180
|
+
});
|
|
181
|
+
return parseBodyBlocks([paragraph], detachedParagraphOwner);
|
|
182
|
+
}
|
|
183
|
+
function firstParagraphText(blocks) {
|
|
184
|
+
var e_1, _a, e_2, _b;
|
|
185
|
+
try {
|
|
186
|
+
for (var blocks_1 = __values(blocks), blocks_1_1 = blocks_1.next(); !blocks_1_1.done; blocks_1_1 = blocks_1.next()) {
|
|
187
|
+
var block = blocks_1_1.value;
|
|
188
|
+
if (block.type !== 'paragraph') {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
for (var _c = __values(block.paragraph.items), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
193
|
+
var inline = _d.value;
|
|
194
|
+
if (inline instanceof TextRange) {
|
|
195
|
+
var text = inline.text;
|
|
196
|
+
if (text.length > 0) {
|
|
197
|
+
return text;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
203
|
+
finally {
|
|
204
|
+
try {
|
|
205
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
206
|
+
}
|
|
207
|
+
finally { if (e_2) throw e_2.error; }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
212
|
+
finally {
|
|
213
|
+
try {
|
|
214
|
+
if (blocks_1_1 && !blocks_1_1.done && (_a = blocks_1.return)) _a.call(blocks_1);
|
|
215
|
+
}
|
|
216
|
+
finally { if (e_1) throw e_1.error; }
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Parse a Comments-part `w:date` / ST_DateTime string into a `Date`.
|
|
222
|
+
*
|
|
223
|
+
* Returns `undefined` when the value is missing, empty, or not parseable.
|
|
224
|
+
*/
|
|
225
|
+
function parseCommentDateTime(value) {
|
|
226
|
+
if (value === undefined || value.length === 0) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
var ms = Date.parse(value);
|
|
230
|
+
if (Number.isNaN(ms)) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
return new Date(ms);
|
|
234
|
+
}
|
|
235
|
+
function relativeTarget(partNameValue) {
|
|
236
|
+
return partNameValue.slice('/word/'.length);
|
|
237
|
+
}
|
|
238
|
+
function kindForRelationshipType(type) {
|
|
239
|
+
return COMMENTS_RELATIONSHIP_TYPES.indexOf(type) !== -1;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Comment range start marker (`w:commentRangeStart`).
|
|
243
|
+
*
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
var CommentRangeStart = /** @class */ (function () {
|
|
247
|
+
/** @private */
|
|
248
|
+
function CommentRangeStart(commentId) {
|
|
249
|
+
this.commentId = commentId;
|
|
250
|
+
}
|
|
251
|
+
/** @private */
|
|
252
|
+
CommentRangeStart.prototype.releaseContent = function () {
|
|
253
|
+
return;
|
|
254
|
+
};
|
|
255
|
+
/** @private */
|
|
256
|
+
CommentRangeStart.prototype.toOpenXml = function () {
|
|
257
|
+
return wmlElement('commentRangeStart', { attributes: [wmlAttr('id', String(this.commentId))] });
|
|
258
|
+
};
|
|
259
|
+
return CommentRangeStart;
|
|
260
|
+
}());
|
|
261
|
+
export { CommentRangeStart };
|
|
262
|
+
/**
|
|
263
|
+
* Comment range end marker (`w:commentRangeEnd`).
|
|
264
|
+
*
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
var CommentRangeEnd = /** @class */ (function () {
|
|
268
|
+
/** @private */
|
|
269
|
+
function CommentRangeEnd(commentId) {
|
|
270
|
+
this.commentId = commentId;
|
|
271
|
+
}
|
|
272
|
+
/** @private */
|
|
273
|
+
CommentRangeEnd.prototype.releaseContent = function () {
|
|
274
|
+
return;
|
|
275
|
+
};
|
|
276
|
+
/** @private */
|
|
277
|
+
CommentRangeEnd.prototype.toOpenXml = function () {
|
|
278
|
+
return wmlElement('commentRangeEnd', { attributes: [wmlAttr('id', String(this.commentId))] });
|
|
279
|
+
};
|
|
280
|
+
return CommentRangeEnd;
|
|
281
|
+
}());
|
|
282
|
+
export { CommentRangeEnd };
|
|
283
|
+
/**
|
|
284
|
+
* Comment reference run leaf (`w:commentReference`).
|
|
285
|
+
*
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
288
|
+
var CommentReference = /** @class */ (function () {
|
|
289
|
+
/** @private */
|
|
290
|
+
function CommentReference(commentId) {
|
|
291
|
+
this.commentId = commentId;
|
|
292
|
+
}
|
|
293
|
+
/** @private */
|
|
294
|
+
CommentReference.prototype.toOpenXml = function () {
|
|
295
|
+
return wmlElement('commentReference', { attributes: [wmlAttr('id', String(this.commentId))] });
|
|
296
|
+
};
|
|
297
|
+
return CommentReference;
|
|
298
|
+
}());
|
|
299
|
+
export { CommentReference };
|
|
300
|
+
/**
|
|
301
|
+
* A comment anchor in a paragraph linked to a Comments part entry.
|
|
302
|
+
*
|
|
303
|
+
* Range markers and the reference leaf share the same internal comment id with the
|
|
304
|
+
* matching {@link Comment} body in the Comments part.
|
|
305
|
+
*
|
|
306
|
+
* @private
|
|
307
|
+
*/
|
|
308
|
+
var CommentAnchor = /** @class */ (function () {
|
|
309
|
+
/** @private */
|
|
310
|
+
function CommentAnchor(commentId, author, date, anchorRuns, reference) {
|
|
311
|
+
this.commentId = commentId;
|
|
312
|
+
this.author = author;
|
|
313
|
+
this.date = typeof date === 'string' ? parseCommentDateTime(date) : date;
|
|
314
|
+
this.anchorRuns = anchorRuns;
|
|
315
|
+
this.reference = reference;
|
|
316
|
+
}
|
|
317
|
+
return CommentAnchor;
|
|
318
|
+
}());
|
|
319
|
+
export { CommentAnchor };
|
|
320
|
+
/**
|
|
321
|
+
* Live view of a comment body in the Comments part (`w:comment`).
|
|
322
|
+
*
|
|
323
|
+
* Bound to a WordDocument and comment id; reads go through {@link CommentsCollection}.
|
|
324
|
+
* Does not expose raw OOXML. Opaque/`preservedXml` entries yield empty paragraphs
|
|
325
|
+
* until a later modeling slice.
|
|
326
|
+
*
|
|
327
|
+
* After main-story elevation (TASK-8055), the same interned instance may also
|
|
328
|
+
* appear in `paragraph.items` as a feature inline at the former
|
|
329
|
+
* `w:commentReference` position. Serialize emits one `w:r` + optional `w:rPr` +
|
|
330
|
+
* `w:commentReference` (ECMA-376-1 §17.13.4.5 / `CT_Markup` in `EG_RunInnerContent`).
|
|
331
|
+
*
|
|
332
|
+
* **Identity:** {@link commentFor}, {@link commentForAnchor},
|
|
333
|
+
* {@link CommentsCollection.comments}, {@link Comment.ancestor}, and elevated
|
|
334
|
+
* `paragraph.items` slots return the same interned instance per modeled
|
|
335
|
+
* `(WordDocument, commentId)` for the lifetime of that collection entry (`===` holds).
|
|
336
|
+
*
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
var Comment = /** @class */ (function () {
|
|
340
|
+
/** @private */
|
|
341
|
+
function Comment(WordDocument, commentId) {
|
|
342
|
+
this.WordDocument = WordDocument;
|
|
343
|
+
this.id = commentId;
|
|
344
|
+
}
|
|
345
|
+
Object.defineProperty(Comment.prototype, "commentId", {
|
|
346
|
+
/**
|
|
347
|
+
* Comment id matching range markers and {@link CommentReference.commentId}.
|
|
348
|
+
*
|
|
349
|
+
* @private
|
|
350
|
+
*/
|
|
351
|
+
get: function () {
|
|
352
|
+
return this.id;
|
|
353
|
+
},
|
|
354
|
+
enumerable: true,
|
|
355
|
+
configurable: true
|
|
356
|
+
});
|
|
357
|
+
Object.defineProperty(Comment.prototype, "author", {
|
|
358
|
+
/**
|
|
359
|
+
* Author of this comment (`w:comment/@w:author`).
|
|
360
|
+
*
|
|
361
|
+
* Returns the modeled attribute value when the Comments part entry is known;
|
|
362
|
+
* empty string when the entry is missing or opaque.
|
|
363
|
+
* Read-only — set author at insert via {@link appendComment} / {@link insertComment}.
|
|
364
|
+
*/
|
|
365
|
+
get: function () {
|
|
366
|
+
var __ts33_1, __ts33_2;
|
|
367
|
+
return ((__ts33_2 = ((__ts33_1 = commentsFor(this.WordDocument).entryFor(this.id)), __ts33_1 == null ? undefined : __ts33_1.author)), __ts33_2 != null ? __ts33_2 : '');
|
|
368
|
+
},
|
|
369
|
+
enumerable: true,
|
|
370
|
+
configurable: true
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(Comment.prototype, "initials", {
|
|
373
|
+
/**
|
|
374
|
+
* Optional `w:comment/@w:initials` (`ST_String`) when present on a modeled entry.
|
|
375
|
+
*
|
|
376
|
+
* Undefined when the attribute is absent or the entry is opaque/preserved.
|
|
377
|
+
* Empty-string values are treated as absent on serialize.
|
|
378
|
+
*/
|
|
379
|
+
get: function () {
|
|
380
|
+
var __ts33_3;
|
|
381
|
+
return ((__ts33_3 = commentsFor(this.WordDocument).entryFor(this.id)), __ts33_3 == null ? undefined : __ts33_3.initials);
|
|
382
|
+
},
|
|
383
|
+
enumerable: true,
|
|
384
|
+
configurable: true
|
|
385
|
+
});
|
|
386
|
+
Object.defineProperty(Comment.prototype, "date", {
|
|
387
|
+
/**
|
|
388
|
+
* Optional comment timestamp (`w:comment/@w:date`, ST_DateTime) as a `Date`.
|
|
389
|
+
*
|
|
390
|
+
* `undefined` when the attribute is absent, the entry is opaque, or the stored
|
|
391
|
+
* value is not parseable. Package storage remains the original ST_DateTime
|
|
392
|
+
* string for round-trip; this getter does not expose the raw attribute.
|
|
393
|
+
* Read-only — supply `date` on {@link AppendCommentOptions} when authoring.
|
|
394
|
+
*/
|
|
395
|
+
get: function () {
|
|
396
|
+
var __ts33_4;
|
|
397
|
+
return parseCommentDateTime(((__ts33_4 = commentsFor(this.WordDocument).entryFor(this.id)), __ts33_4 == null ? undefined : __ts33_4.date));
|
|
398
|
+
},
|
|
399
|
+
enumerable: true,
|
|
400
|
+
configurable: true
|
|
401
|
+
});
|
|
402
|
+
Object.defineProperty(Comment.prototype, "paragraphs", {
|
|
403
|
+
/**
|
|
404
|
+
* Modeled body paragraphs for this comment (`EG_BlockLevelElts` paragraph children).
|
|
405
|
+
*
|
|
406
|
+
* Empty when the entry is missing or preserved as opaque XML. Paragraph content
|
|
407
|
+
* is live — mutate via {@link Paragraph} APIs on the returned instances; there is
|
|
408
|
+
* no separate setter on this property.
|
|
409
|
+
*/
|
|
410
|
+
get: function () {
|
|
411
|
+
return commentsFor(this.WordDocument).paragraphsFor(this.id);
|
|
412
|
+
},
|
|
413
|
+
enumerable: true,
|
|
414
|
+
configurable: true
|
|
415
|
+
});
|
|
416
|
+
Object.defineProperty(Comment.prototype, "ancestor", {
|
|
417
|
+
/**
|
|
418
|
+
* Parent comment when this comment is a reply (`commentsExtended` / `commentEx/@paraIdParent`).
|
|
419
|
+
*
|
|
420
|
+
* Top-level comments and replies whose parent cannot be resolved return `undefined`.
|
|
421
|
+
* Read-only; DocIO-aligned (`WComment.Ancestor`). The returned instance is the
|
|
422
|
+
* collection-interned {@link Comment} for the parent id when resolved.
|
|
423
|
+
*/
|
|
424
|
+
get: function () {
|
|
425
|
+
return commentsFor(this.WordDocument).ancestorFor(this.WordDocument, this.id);
|
|
426
|
+
},
|
|
427
|
+
enumerable: true,
|
|
428
|
+
configurable: true
|
|
429
|
+
});
|
|
430
|
+
Object.defineProperty(Comment.prototype, "done", {
|
|
431
|
+
/**
|
|
432
|
+
* Whether this comment is marked done (`commentsExtended` / `commentEx/@done`).
|
|
433
|
+
*
|
|
434
|
+
* Joined from `[MS-DOCX]` `CT_CommentEx/@done` (`ST_OnOff`) onto the same interned
|
|
435
|
+
* {@link Comment} used by {@link commentFor}. After join: attribute absent or `"0"` →
|
|
436
|
+
* `false`; other present values → `true`. No matching `commentEx` row → `false`
|
|
437
|
+
* (MS default 0). Read-only in this slice; mutation is `comments-resolved-state`.
|
|
438
|
+
*/
|
|
439
|
+
get: function () {
|
|
440
|
+
var __ts33_5, __ts33_6;
|
|
441
|
+
return ((__ts33_6 = ((__ts33_5 = commentsFor(this.WordDocument).entryFor(this.id)), __ts33_5 == null ? undefined : __ts33_5.done)), __ts33_6 != null ? __ts33_6 : false);
|
|
442
|
+
},
|
|
443
|
+
enumerable: true,
|
|
444
|
+
configurable: true
|
|
445
|
+
});
|
|
446
|
+
/**
|
|
447
|
+
* Capture `w:rPr` from the wire group of the featureRun being elevated.
|
|
448
|
+
*
|
|
449
|
+
* @private
|
|
450
|
+
*/
|
|
451
|
+
Comment.prototype.captureReferenceRunFormatting = function (group) {
|
|
452
|
+
this.referenceRunFormatting = formattingFromWireGroup(group);
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* Default character style for newly authored elevated references.
|
|
456
|
+
*
|
|
457
|
+
* @private
|
|
458
|
+
*/
|
|
459
|
+
Comment.prototype.applyDefaultReferenceRunStyle = function () {
|
|
460
|
+
if (this.referenceRunFormatting === undefined) {
|
|
461
|
+
this.referenceRunFormatting = emptyReferenceRunFormatting(COMMENT_REFERENCE_STYLE_ID);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
/** @private */
|
|
465
|
+
Comment.prototype.releaseContent = function () {
|
|
466
|
+
return;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* @private
|
|
470
|
+
* Serialize as `w:r` + modeled `w:rPr` + `w:commentReference` (D6). Does not emit a
|
|
471
|
+
* dual legacy leaf for the same elevated occurrence (D10).
|
|
472
|
+
*/
|
|
473
|
+
Comment.prototype.toOpenXml = function () {
|
|
474
|
+
var formatting = this.referenceRunFormatting != null ? this.referenceRunFormatting : emptyReferenceRunFormatting();
|
|
475
|
+
return serializeElevatedCommentReference(this.id, formatting);
|
|
476
|
+
};
|
|
477
|
+
return Comment;
|
|
478
|
+
}());
|
|
479
|
+
export { Comment };
|
|
480
|
+
function optionalNonEmptyAttribute(value) {
|
|
481
|
+
return value !== undefined && value.length > 0 ? value : undefined;
|
|
482
|
+
}
|
|
483
|
+
function serializeCommentsPart(state) {
|
|
484
|
+
var e_3, _a;
|
|
485
|
+
var children = [];
|
|
486
|
+
try {
|
|
487
|
+
for (var _b = __values(state.entries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
488
|
+
var entry = _c.value;
|
|
489
|
+
if (entry.preservedXml !== undefined) {
|
|
490
|
+
children.push(entry.preservedXml);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
var attributes = [wmlAttr('id', String(entry.commentId)), wmlAttr('author', entry.author)];
|
|
494
|
+
var initials = optionalNonEmptyAttribute(entry.initials);
|
|
495
|
+
if (initials !== undefined) {
|
|
496
|
+
attributes.push(wmlAttr('initials', initials));
|
|
497
|
+
}
|
|
498
|
+
var date = optionalNonEmptyAttribute(entry.date);
|
|
499
|
+
if (date !== undefined) {
|
|
500
|
+
attributes.push(wmlAttr('date', date));
|
|
501
|
+
}
|
|
502
|
+
children.push(wmlElement('comment', {
|
|
503
|
+
attributes: attributes,
|
|
504
|
+
children: serializeBodyBlocks(entry.blocks),
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
509
|
+
finally {
|
|
510
|
+
try {
|
|
511
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
512
|
+
}
|
|
513
|
+
finally { if (e_3) throw e_3.error; }
|
|
514
|
+
}
|
|
515
|
+
var root = wmlElement('comments', {
|
|
516
|
+
attributes: state.rootExtra.attributes,
|
|
517
|
+
namespaceDeclarations: state.rootExtra.namespaceDeclarations.length > 0
|
|
518
|
+
? state.rootExtra.namespaceDeclarations
|
|
519
|
+
: [{ prefix: 'w', namespaceUri: WML }],
|
|
520
|
+
children: children,
|
|
521
|
+
});
|
|
522
|
+
return utf8.encode(serializeXml(root));
|
|
523
|
+
}
|
|
524
|
+
function parseCommentsPart(part, relationship) {
|
|
525
|
+
var e_4, _a;
|
|
526
|
+
var root = parseXml(utf8Decoder.decode(part.data));
|
|
527
|
+
if (!isWml(root, 'comments')) {
|
|
528
|
+
return undefined;
|
|
529
|
+
}
|
|
530
|
+
var entries = [];
|
|
531
|
+
try {
|
|
532
|
+
for (var _b = __values(elementChildren(root)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
533
|
+
var child = _c.value;
|
|
534
|
+
if (!isWml(child, 'comment')) {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
var commentId = parseCommentId(wmlAttribute(child, 'id'));
|
|
538
|
+
var author = wmlAttribute(child, 'author');
|
|
539
|
+
var initials = optionalNonEmptyAttribute(wmlAttribute(child, 'initials'));
|
|
540
|
+
var date = optionalNonEmptyAttribute(wmlAttribute(child, 'date'));
|
|
541
|
+
if (commentId === undefined || author === undefined || author.length === 0) {
|
|
542
|
+
entries.push({
|
|
543
|
+
commentId: commentId != null ? commentId : -1,
|
|
544
|
+
author: author != null ? author : '',
|
|
545
|
+
initials: initials,
|
|
546
|
+
date: date,
|
|
547
|
+
blocks: [],
|
|
548
|
+
preservedXml: child,
|
|
549
|
+
lastParaId: undefined,
|
|
550
|
+
parentParaId: undefined,
|
|
551
|
+
done: undefined,
|
|
552
|
+
});
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
var blocks = parseBodyBlocks(child.children, detachedParagraphOwner);
|
|
556
|
+
entries.push({
|
|
557
|
+
commentId: commentId,
|
|
558
|
+
author: author,
|
|
559
|
+
initials: initials,
|
|
560
|
+
date: date,
|
|
561
|
+
blocks: blocks,
|
|
562
|
+
preservedXml: undefined,
|
|
563
|
+
lastParaId: lastParagraphParaId(blocks),
|
|
564
|
+
parentParaId: undefined,
|
|
565
|
+
done: undefined,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
570
|
+
finally {
|
|
571
|
+
try {
|
|
572
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
573
|
+
}
|
|
574
|
+
finally { if (e_4) throw e_4.error; }
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
partName: part.name,
|
|
578
|
+
relationshipId: relationship.id,
|
|
579
|
+
relationshipType: relationship.type,
|
|
580
|
+
rootExtra: {
|
|
581
|
+
attributes: root.attributes,
|
|
582
|
+
namespaceDeclarations: root.namespaceDeclarations.length > 0
|
|
583
|
+
? root.namespaceDeclarations
|
|
584
|
+
: [{ prefix: 'w', namespaceUri: WML }],
|
|
585
|
+
},
|
|
586
|
+
entries: entries,
|
|
587
|
+
dirty: false,
|
|
588
|
+
pendingRelationship: undefined,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function allocatePartName(used) {
|
|
592
|
+
var primary = partName('/word/comments.xml');
|
|
593
|
+
if (!used.has(partNameKey(primary))) {
|
|
594
|
+
return primary;
|
|
595
|
+
}
|
|
596
|
+
var index = 2;
|
|
597
|
+
while (used.has(partNameKey(partName("/word/comments" + String(index) + ".xml")))) {
|
|
598
|
+
index += 1;
|
|
599
|
+
}
|
|
600
|
+
return partName("/word/comments" + String(index) + ".xml");
|
|
601
|
+
}
|
|
602
|
+
function allocateCommentId(entries, WordDocument) {
|
|
603
|
+
var e_5, _a, e_6, _b;
|
|
604
|
+
var used = new Set();
|
|
605
|
+
try {
|
|
606
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
607
|
+
var entry = entries_1_1.value;
|
|
608
|
+
if (entry.commentId >= 0) {
|
|
609
|
+
used.add(entry.commentId);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
614
|
+
finally {
|
|
615
|
+
try {
|
|
616
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
617
|
+
}
|
|
618
|
+
finally { if (e_5) throw e_5.error; }
|
|
619
|
+
}
|
|
620
|
+
try {
|
|
621
|
+
for (var _c = __values(WordDocument.listParagraphs()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
622
|
+
var paragraph = _d.value;
|
|
623
|
+
collectCommentIdsInParagraph(paragraph, used);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
627
|
+
finally {
|
|
628
|
+
try {
|
|
629
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
630
|
+
}
|
|
631
|
+
finally { if (e_6) throw e_6.error; }
|
|
632
|
+
}
|
|
633
|
+
var candidate = 0;
|
|
634
|
+
while (used.has(candidate)) {
|
|
635
|
+
candidate += 1;
|
|
636
|
+
}
|
|
637
|
+
return candidate;
|
|
638
|
+
}
|
|
639
|
+
function collectCommentIdsInParagraph(paragraph, used) {
|
|
640
|
+
var e_7, _a;
|
|
641
|
+
try {
|
|
642
|
+
for (var _b = __values(paragraph.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
643
|
+
var inline = _c.value;
|
|
644
|
+
if (inline instanceof FeatureInlineParagraphItem) {
|
|
645
|
+
if (inline.value instanceof CommentRangeStart ||
|
|
646
|
+
inline.value instanceof CommentRangeEnd ||
|
|
647
|
+
inline.value instanceof Comment) {
|
|
648
|
+
used.add(inline.value.commentId);
|
|
649
|
+
}
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
if (inline instanceof FeatureRunParagraphItem &&
|
|
653
|
+
inline.value instanceof CommentReference) {
|
|
654
|
+
used.add(inline.value.commentId);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
659
|
+
finally {
|
|
660
|
+
try {
|
|
661
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
662
|
+
}
|
|
663
|
+
finally { if (e_7) throw e_7.error; }
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function isModeledElevatableComment(catalog, commentId) {
|
|
667
|
+
var entry = catalog.entryFor(commentId);
|
|
668
|
+
return entry !== undefined && entry.preservedXml === undefined;
|
|
669
|
+
}
|
|
670
|
+
function isElevatableCommentReferenceItem(item, catalog, elevatedIds) {
|
|
671
|
+
return (item instanceof FeatureRunParagraphItem &&
|
|
672
|
+
item.value instanceof CommentReference &&
|
|
673
|
+
isModeledElevatableComment(catalog, item.value.commentId) &&
|
|
674
|
+
!elevatedIds.has(item.value.commentId));
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Elevate modeled main-story `w:commentReference` featureRun items to live
|
|
678
|
+
* {@link Comment} featureInlines. Parse already flattens each `w:r` child into
|
|
679
|
+
* sibling paragraph items sharing a {@link WireRunGroup}, so residual siblings
|
|
680
|
+
* stay in place without cloning runs.
|
|
681
|
+
*/
|
|
682
|
+
function elevateCommentReferencesInParagraph(WordDocument, paragraph, catalog, elevatedIds) {
|
|
683
|
+
var nextItems = [];
|
|
684
|
+
var changed = false;
|
|
685
|
+
// Use storage wrappers (snapshot), not projected public leaves — projected
|
|
686
|
+
// Picture/Shape values are not ParagraphItems and have no attach().
|
|
687
|
+
var stored = paragraph.snapshot().items;
|
|
688
|
+
for (var i = 0; i < stored.length; i += 1) {
|
|
689
|
+
var item = stored[i];
|
|
690
|
+
if (!isElevatableCommentReferenceItem(item, catalog, elevatedIds)) {
|
|
691
|
+
nextItems.push(item);
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
var commentId = item.value.commentId;
|
|
695
|
+
var comment = catalog.commentInstanceFor(WordDocument, commentId);
|
|
696
|
+
comment.captureReferenceRunFormatting(item.wireGroup);
|
|
697
|
+
elevatedIds.add(commentId);
|
|
698
|
+
changed = true;
|
|
699
|
+
nextItems.push(new FeatureInlineParagraphItem(COMMENTS, comment));
|
|
700
|
+
}
|
|
701
|
+
if (!changed) {
|
|
702
|
+
return false;
|
|
703
|
+
}
|
|
704
|
+
paragraph.hydrate(__assign({}, paragraph.snapshot(), { items: nextItems }));
|
|
705
|
+
return true;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Elevate modeled comment references across the main story.
|
|
709
|
+
*
|
|
710
|
+
* @private
|
|
711
|
+
*/
|
|
712
|
+
export function elevateCommentReferencesInDocument(WordDocument) {
|
|
713
|
+
var catalog = commentsFor(WordDocument);
|
|
714
|
+
catalog.elevateMainStoryReferences(WordDocument);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Type guard: paragraph feature-inline value is an elevated {@link Comment}.
|
|
718
|
+
*
|
|
719
|
+
* @private
|
|
720
|
+
*/
|
|
721
|
+
export function isCommentInline(inline) {
|
|
722
|
+
return (inline instanceof FeatureInlineParagraphItem &&
|
|
723
|
+
inline.featureId === COMMENTS &&
|
|
724
|
+
inline.value instanceof Comment);
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Comments part linked from the Main WordDocument.
|
|
728
|
+
*
|
|
729
|
+
* @private
|
|
730
|
+
*/
|
|
731
|
+
var CommentsCollection = /** @class */ (function () {
|
|
732
|
+
/** @private */
|
|
733
|
+
function CommentsCollection(state, extensionParts) {
|
|
734
|
+
/** Interned live Comment views keyed by comment id (per collection / WordDocument). */
|
|
735
|
+
this.commentViews = new Map();
|
|
736
|
+
this.state = state;
|
|
737
|
+
this.extensionParts = extensionParts;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* MS-DOCX comment extension metadata discovered from Main WordDocument relationships.
|
|
741
|
+
*
|
|
742
|
+
* @private
|
|
743
|
+
*/
|
|
744
|
+
CommentsCollection.prototype.extensions = function () {
|
|
745
|
+
return this.extensionParts;
|
|
746
|
+
};
|
|
747
|
+
/**
|
|
748
|
+
* Main-story `commentReference` → elevated {@link Comment} (TASK-8055 / D14).
|
|
749
|
+
*
|
|
750
|
+
* Invoked from {@link WordDocument.fromPackage} via duck-typed `afterMainDocumentLoad`
|
|
751
|
+
* so core/document does not value-import this module (avoids Paragraph TDZ cycles).
|
|
752
|
+
*
|
|
753
|
+
* @private
|
|
754
|
+
*/
|
|
755
|
+
CommentsCollection.prototype.elevateMainStoryReferences = function (WordDocument) {
|
|
756
|
+
var e_8, _a;
|
|
757
|
+
var elevatedIds = new Set();
|
|
758
|
+
try {
|
|
759
|
+
for (var _b = __values(WordDocument.listParagraphs()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
760
|
+
var paragraph = _c.value;
|
|
761
|
+
elevateCommentReferencesInParagraph(WordDocument, paragraph, this, elevatedIds);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
765
|
+
finally {
|
|
766
|
+
try {
|
|
767
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
768
|
+
}
|
|
769
|
+
finally { if (e_8) throw e_8.error; }
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* Post-load hook for {@link WordDocument.fromPackage} (duck-typed on feature parts).
|
|
774
|
+
*
|
|
775
|
+
* @private
|
|
776
|
+
*/
|
|
777
|
+
CommentsCollection.prototype.afterMainDocumentLoad = function (WordDocument) {
|
|
778
|
+
this.elevateMainStoryReferences(WordDocument);
|
|
779
|
+
};
|
|
780
|
+
/**
|
|
781
|
+
* Interned live {@link Comment} for a modeled comment id.
|
|
782
|
+
*
|
|
783
|
+
* @private
|
|
784
|
+
*/
|
|
785
|
+
CommentsCollection.prototype.commentInstanceFor = function (WordDocument, commentId) {
|
|
786
|
+
var existing = this.commentViews.get(commentId);
|
|
787
|
+
if (existing !== undefined) {
|
|
788
|
+
return existing;
|
|
789
|
+
}
|
|
790
|
+
var created = new Comment(WordDocument, commentId);
|
|
791
|
+
this.commentViews.set(commentId, created);
|
|
792
|
+
return created;
|
|
793
|
+
};
|
|
794
|
+
/** @private */
|
|
795
|
+
CommentsCollection.prototype.isDirty = function () {
|
|
796
|
+
return (this.state == null ? undefined : this.state.dirty) === true || (this.state == null ? undefined : this.state.pendingRelationship) !== undefined;
|
|
797
|
+
};
|
|
798
|
+
/** @private */
|
|
799
|
+
CommentsCollection.prototype.applyToPackage = function (pkg, mainPartName) {
|
|
800
|
+
var part = this.state;
|
|
801
|
+
if (part === undefined || (!part.dirty && part.pendingRelationship === undefined)) {
|
|
802
|
+
return pkg;
|
|
803
|
+
}
|
|
804
|
+
var data = serializeCommentsPart(part);
|
|
805
|
+
var rel = part.pendingRelationship != null ? part.pendingRelationship : relationshipsForPart(pkg, mainPartName).items.find(function (item) { return item.id === part.relationshipId; });
|
|
806
|
+
var next = replaceOrAddPackagePart(pkg, mainPartName, part.partName, COMMENTS_CONTENT_TYPE, data, rel);
|
|
807
|
+
part.dirty = false;
|
|
808
|
+
part.pendingRelationship = undefined;
|
|
809
|
+
return next;
|
|
810
|
+
};
|
|
811
|
+
/** @private */
|
|
812
|
+
CommentsCollection.prototype.ensurePart = function (usedRelIds, usedPartNames) {
|
|
813
|
+
if (this.state !== undefined) {
|
|
814
|
+
return this.state;
|
|
815
|
+
}
|
|
816
|
+
var partNameValue = allocatePartName(usedPartNames);
|
|
817
|
+
var relId = allocateRelationshipId(usedRelIds);
|
|
818
|
+
var created = {
|
|
819
|
+
partName: partNameValue,
|
|
820
|
+
relationshipId: relId,
|
|
821
|
+
relationshipType: COMMENTS_RELATIONSHIP_TYPE,
|
|
822
|
+
rootExtra: {
|
|
823
|
+
attributes: [],
|
|
824
|
+
namespaceDeclarations: [{ prefix: 'w', namespaceUri: WML }],
|
|
825
|
+
},
|
|
826
|
+
entries: [],
|
|
827
|
+
dirty: true,
|
|
828
|
+
pendingRelationship: {
|
|
829
|
+
id: relId,
|
|
830
|
+
type: COMMENTS_RELATIONSHIP_TYPE,
|
|
831
|
+
target: relativeTarget(partNameValue),
|
|
832
|
+
extraAttributes: [],
|
|
833
|
+
children: [],
|
|
834
|
+
},
|
|
835
|
+
};
|
|
836
|
+
this.state = created;
|
|
837
|
+
return created;
|
|
838
|
+
};
|
|
839
|
+
/**
|
|
840
|
+
* Allocate a new modeled comment entry (unique id) and mark the part dirty.
|
|
841
|
+
*
|
|
842
|
+
* @param WordDocument - Owning WordDocument (id allocation scans main-story markers).
|
|
843
|
+
* @param author - `w:author` (may be empty string).
|
|
844
|
+
* @param commentText - Initial body text (first paragraph / first run).
|
|
845
|
+
* @param date - Optional `w:date` (ST_DateTime string); empty/omitted → attribute absent.
|
|
846
|
+
* @param initials - Optional `w:initials`; empty/omitted → attribute absent.
|
|
847
|
+
* @private
|
|
848
|
+
*/
|
|
849
|
+
CommentsCollection.prototype.addEntry = function (WordDocument, author, commentText, date, initials) {
|
|
850
|
+
var part = this.state;
|
|
851
|
+
if (part === undefined) {
|
|
852
|
+
throw new DocxError('content/unknown-comment', 'Comments part is not loaded');
|
|
853
|
+
}
|
|
854
|
+
var commentId = allocateCommentId(part.entries, WordDocument);
|
|
855
|
+
part.entries = __spread(part.entries, [
|
|
856
|
+
{
|
|
857
|
+
commentId: commentId,
|
|
858
|
+
author: author,
|
|
859
|
+
initials: optionalNonEmptyAttribute(initials),
|
|
860
|
+
date: optionalNonEmptyAttribute(date),
|
|
861
|
+
blocks: blocksWithSimpleText(commentText),
|
|
862
|
+
preservedXml: undefined,
|
|
863
|
+
done: undefined,
|
|
864
|
+
lastParaId: undefined,
|
|
865
|
+
parentParaId: undefined,
|
|
866
|
+
},
|
|
867
|
+
]);
|
|
868
|
+
part.dirty = true;
|
|
869
|
+
return commentId;
|
|
870
|
+
};
|
|
871
|
+
/** @private */
|
|
872
|
+
CommentsCollection.prototype.entryFor = function (commentId) {
|
|
873
|
+
return (this.state == null ? undefined : this.state.entries).find(function (entry) { return entry.commentId === commentId; });
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* Resolve parent comment via DocIO-aligned reverse scan on prior Comments part entries.
|
|
877
|
+
*
|
|
878
|
+
* @private
|
|
879
|
+
*/
|
|
880
|
+
CommentsCollection.prototype.ancestorFor = function (WordDocument, commentId) {
|
|
881
|
+
var part = this.state;
|
|
882
|
+
if (part === undefined) {
|
|
883
|
+
return undefined;
|
|
884
|
+
}
|
|
885
|
+
var index = part.entries.findIndex(function (entry) { return entry.commentId === commentId; });
|
|
886
|
+
if (index < 0) {
|
|
887
|
+
return undefined;
|
|
888
|
+
}
|
|
889
|
+
var parentParaId = part.entries[index] == null ? undefined : part.entries[index].parentParaId;
|
|
890
|
+
if (parentParaId === undefined || parentParaId.length === 0) {
|
|
891
|
+
return undefined;
|
|
892
|
+
}
|
|
893
|
+
for (var prior = index - 1; prior >= 0; prior -= 1) {
|
|
894
|
+
var candidate = part.entries[prior];
|
|
895
|
+
if (candidate === undefined || candidate.preservedXml !== undefined) {
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
if (candidate.lastParaId === parentParaId) {
|
|
899
|
+
return this.commentInstanceFor(WordDocument, candidate.commentId);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return undefined;
|
|
903
|
+
};
|
|
904
|
+
/**
|
|
905
|
+
* Modeled comment ids in Comments part order (opaque preserved entries omitted).
|
|
906
|
+
*
|
|
907
|
+
* @private
|
|
908
|
+
*/
|
|
909
|
+
CommentsCollection.prototype.commentIds = function () {
|
|
910
|
+
var e_9, _a;
|
|
911
|
+
if (this.state === undefined) {
|
|
912
|
+
return [];
|
|
913
|
+
}
|
|
914
|
+
var ids = [];
|
|
915
|
+
try {
|
|
916
|
+
for (var _b = __values(this.state.entries), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
917
|
+
var entry = _c.value;
|
|
918
|
+
if (entry.preservedXml !== undefined) {
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
ids.push(entry.commentId);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
925
|
+
finally {
|
|
926
|
+
try {
|
|
927
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
928
|
+
}
|
|
929
|
+
finally { if (e_9) throw e_9.error; }
|
|
930
|
+
}
|
|
931
|
+
return ids;
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* Live {@link Comment} views for every modeled Comments part entry, in part order.
|
|
935
|
+
*
|
|
936
|
+
* Each id is interned: repeated collection / lookup APIs return the same instance.
|
|
937
|
+
*
|
|
938
|
+
* @private
|
|
939
|
+
*/
|
|
940
|
+
CommentsCollection.prototype.comments = function (WordDocument) {
|
|
941
|
+
var _this = this;
|
|
942
|
+
return this.commentIds().map(function (commentId) { return _this.commentInstanceFor(WordDocument, commentId); });
|
|
943
|
+
};
|
|
944
|
+
/**
|
|
945
|
+
* Body paragraphs of a modeled comment, when present.
|
|
946
|
+
*
|
|
947
|
+
* @private
|
|
948
|
+
*/
|
|
949
|
+
CommentsCollection.prototype.paragraphsFor = function (commentId) {
|
|
950
|
+
var e_10, _a;
|
|
951
|
+
var entry = this.entryFor(commentId);
|
|
952
|
+
if (entry === undefined || entry.preservedXml !== undefined) {
|
|
953
|
+
return [];
|
|
954
|
+
}
|
|
955
|
+
var paragraphs = [];
|
|
956
|
+
try {
|
|
957
|
+
for (var _b = __values(entry.blocks), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
958
|
+
var block = _c.value;
|
|
959
|
+
if (block.type === 'paragraph') {
|
|
960
|
+
paragraphs.push(block.paragraph);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
965
|
+
finally {
|
|
966
|
+
try {
|
|
967
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
968
|
+
}
|
|
969
|
+
finally { if (e_10) throw e_10.error; }
|
|
970
|
+
}
|
|
971
|
+
return paragraphs;
|
|
972
|
+
};
|
|
973
|
+
/** @private */
|
|
974
|
+
CommentsCollection.prototype.textFor = function (commentId) {
|
|
975
|
+
var entry = this.entryFor(commentId);
|
|
976
|
+
if (entry === undefined || entry.preservedXml !== undefined) {
|
|
977
|
+
return undefined;
|
|
978
|
+
}
|
|
979
|
+
return firstParagraphText(entry.blocks);
|
|
980
|
+
};
|
|
981
|
+
/** @private */
|
|
982
|
+
CommentsCollection.prototype.removeEntry = function (commentId) {
|
|
983
|
+
var part = this.state;
|
|
984
|
+
if (part === undefined) {
|
|
985
|
+
throw new DocxError('content/unknown-comment', 'Comments part is not loaded');
|
|
986
|
+
}
|
|
987
|
+
var next = part.entries.filter(function (entry) { return entry.commentId !== commentId; });
|
|
988
|
+
if (next.length === part.entries.length) {
|
|
989
|
+
throw new DocxError('content/unknown-comment', "Comment id " + String(commentId) + " is not in this WordDocument");
|
|
990
|
+
}
|
|
991
|
+
part.entries = next;
|
|
992
|
+
this.commentViews.delete(commentId);
|
|
993
|
+
part.dirty = true;
|
|
994
|
+
};
|
|
995
|
+
return CommentsCollection;
|
|
996
|
+
}());
|
|
997
|
+
export { CommentsCollection };
|
|
998
|
+
/**
|
|
999
|
+
* Read `w14:paraId` (Word 2010) from paragraph OpenXml attributes.
|
|
1000
|
+
* Matches DocIO `WParagraph.ParaId` used to join `commentEx`.
|
|
1001
|
+
*/
|
|
1002
|
+
function paragraphParaIdFromAttributes(attributes) {
|
|
1003
|
+
var found = attributes.find(function (attribute) { return attribute.localName === 'paraId' &&
|
|
1004
|
+
(attribute.namespaceUri === WORDML_2010_NAMESPACE ||
|
|
1005
|
+
attribute.namespaceUri === '' ||
|
|
1006
|
+
attribute.prefix === 'w14'); });
|
|
1007
|
+
var value = found == null ? undefined : found.value;
|
|
1008
|
+
return value !== undefined && value.length > 0 ? value : undefined;
|
|
1009
|
+
}
|
|
1010
|
+
function lastParagraphParaId(blocks) {
|
|
1011
|
+
for (var index = blocks.length - 1; index >= 0; index -= 1) {
|
|
1012
|
+
var block = blocks[index];
|
|
1013
|
+
// TS 3.3 does not narrow through `(x == null ? undefined : x.type)`.
|
|
1014
|
+
if (block === undefined || block.type !== 'paragraph') {
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
return paragraphParaIdFromAttributes(block.paragraph.toOpenXml().attributes);
|
|
1018
|
+
}
|
|
1019
|
+
return undefined;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Join Comments part entries to `commentsExtended` rows by last body paragraph paraId
|
|
1023
|
+
* (DocIO `SetParentParaIdAndIsResolved`).
|
|
1024
|
+
*
|
|
1025
|
+
* Copies `paraIdParent` and `done` onto the same catalog entry used by interned
|
|
1026
|
+
* {@link Comment} views. Read default for absent `@done` after join is `false`
|
|
1027
|
+
* (`[MS-DOCX]` §2.5.3.1 default 0).
|
|
1028
|
+
*/
|
|
1029
|
+
function applyCommentExRelationships(entries, extendedEntries) {
|
|
1030
|
+
var e_11, _a, e_12, _b;
|
|
1031
|
+
if (extendedEntries.length === 0) {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
var byParaId = new Map();
|
|
1035
|
+
try {
|
|
1036
|
+
for (var extendedEntries_1 = __values(extendedEntries), extendedEntries_1_1 = extendedEntries_1.next(); !extendedEntries_1_1.done; extendedEntries_1_1 = extendedEntries_1.next()) {
|
|
1037
|
+
var extended = extendedEntries_1_1.value;
|
|
1038
|
+
byParaId.set(extended.paraId, extended);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1042
|
+
finally {
|
|
1043
|
+
try {
|
|
1044
|
+
if (extendedEntries_1_1 && !extendedEntries_1_1.done && (_a = extendedEntries_1.return)) _a.call(extendedEntries_1);
|
|
1045
|
+
}
|
|
1046
|
+
finally { if (e_11) throw e_11.error; }
|
|
1047
|
+
}
|
|
1048
|
+
try {
|
|
1049
|
+
for (var entries_2 = __values(entries), entries_2_1 = entries_2.next(); !entries_2_1.done; entries_2_1 = entries_2.next()) {
|
|
1050
|
+
var entry = entries_2_1.value;
|
|
1051
|
+
if (entry.preservedXml !== undefined || entry.lastParaId === undefined) {
|
|
1052
|
+
continue;
|
|
1053
|
+
}
|
|
1054
|
+
var extended = byParaId.get(entry.lastParaId);
|
|
1055
|
+
if (extended === undefined) {
|
|
1056
|
+
continue;
|
|
1057
|
+
}
|
|
1058
|
+
// Parse keeps raw absent as undefined on CommentExEntry; read API defaults to false.
|
|
1059
|
+
entry.done = extended.done === undefined ? false : extended.done;
|
|
1060
|
+
entry.parentParaId = extended.paraIdParent;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1064
|
+
finally {
|
|
1065
|
+
try {
|
|
1066
|
+
if (entries_2_1 && !entries_2_1.done && (_b = entries_2.return)) _b.call(entries_2);
|
|
1067
|
+
}
|
|
1068
|
+
finally { if (e_12) throw e_12.error; }
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function loadCatalog(pkg, mainPartName) {
|
|
1072
|
+
var e_13, _a;
|
|
1073
|
+
var extensionParts = new CommentExtensionParts(loadCommentExtensionMetadata(pkg, mainPartName));
|
|
1074
|
+
try {
|
|
1075
|
+
for (var _b = __values(relationshipsForPart(pkg, mainPartName).items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1076
|
+
var rel = _c.value;
|
|
1077
|
+
if (!kindForRelationshipType(rel.type)) {
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
var target = resolveInternalTarget(rel.target, mainPartName);
|
|
1081
|
+
var part = partByName(pkg, target);
|
|
1082
|
+
if (part === undefined) {
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
var parsed = parseCommentsPart(part, rel);
|
|
1086
|
+
if (parsed !== undefined) {
|
|
1087
|
+
applyCommentExRelationships(parsed.entries, extensionParts.extendedEntries());
|
|
1088
|
+
return new CommentsCollection(parsed, extensionParts);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1093
|
+
finally {
|
|
1094
|
+
try {
|
|
1095
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1096
|
+
}
|
|
1097
|
+
finally { if (e_13) throw e_13.error; }
|
|
1098
|
+
}
|
|
1099
|
+
return new CommentsCollection(undefined, extensionParts);
|
|
1100
|
+
}
|
|
1101
|
+
function usedRelationshipIds(WordDocument) {
|
|
1102
|
+
var e_14, _a;
|
|
1103
|
+
var main = partName('/word/WordDocument.xml');
|
|
1104
|
+
var used = new Set();
|
|
1105
|
+
try {
|
|
1106
|
+
for (var _b = __values(relationshipsForPart(WordDocument.opcPackage(), main).items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1107
|
+
var rel = _c.value;
|
|
1108
|
+
used.add(rel.id);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1112
|
+
finally {
|
|
1113
|
+
try {
|
|
1114
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1115
|
+
}
|
|
1116
|
+
finally { if (e_14) throw e_14.error; }
|
|
1117
|
+
}
|
|
1118
|
+
return used;
|
|
1119
|
+
}
|
|
1120
|
+
function usedPartNameKeys(WordDocument) {
|
|
1121
|
+
var e_15, _a;
|
|
1122
|
+
var used = new Set();
|
|
1123
|
+
try {
|
|
1124
|
+
for (var _b = __values(WordDocument.opcPackage().parts), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1125
|
+
var part = _c.value;
|
|
1126
|
+
used.add(partNameKey(part.name));
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1130
|
+
finally {
|
|
1131
|
+
try {
|
|
1132
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1133
|
+
}
|
|
1134
|
+
finally { if (e_15) throw e_15.error; }
|
|
1135
|
+
}
|
|
1136
|
+
return used;
|
|
1137
|
+
}
|
|
1138
|
+
function anchorRunsForReference(content, referenceIndex, commentId) {
|
|
1139
|
+
var startIndex = -1;
|
|
1140
|
+
for (var index = referenceIndex - 1; index >= 0; index -= 1) {
|
|
1141
|
+
var inline = content[index];
|
|
1142
|
+
// TS 3.3 does not narrow InlineContent through `(x == null ? undefined : x.type)`.
|
|
1143
|
+
if (inline === undefined ||
|
|
1144
|
+
!(inline instanceof FeatureInlineParagraphItem) ||
|
|
1145
|
+
!(inline.value instanceof CommentRangeEnd)) {
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
if (inline.value.commentId !== commentId) {
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
for (var scan = index - 1; scan >= 0; scan -= 1) {
|
|
1152
|
+
var candidate = content[scan];
|
|
1153
|
+
if (candidate === undefined ||
|
|
1154
|
+
!(candidate instanceof FeatureInlineParagraphItem) ||
|
|
1155
|
+
!(candidate.value instanceof CommentRangeStart) ||
|
|
1156
|
+
candidate.value.commentId !== commentId) {
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1159
|
+
startIndex = scan;
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
if (startIndex < 0) {
|
|
1165
|
+
return [];
|
|
1166
|
+
}
|
|
1167
|
+
var runs = [];
|
|
1168
|
+
for (var index = startIndex + 1; index < referenceIndex; index += 1) {
|
|
1169
|
+
var inline = content[index];
|
|
1170
|
+
if (inline === undefined || !(inline instanceof TextRange)) {
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
runs.push(inline);
|
|
1174
|
+
}
|
|
1175
|
+
return runs;
|
|
1176
|
+
}
|
|
1177
|
+
function findAnchorsInParagraph(paragraph, catalog) {
|
|
1178
|
+
var __ts33_7, __ts33_8;
|
|
1179
|
+
var found = [];
|
|
1180
|
+
var content = paragraph.items.toArray();
|
|
1181
|
+
for (var index = 0; index < content.length; index += 1) {
|
|
1182
|
+
var inline = content[index];
|
|
1183
|
+
// TS 3.3 does not narrow InlineContent through `(x == null ? undefined : x.type)`.
|
|
1184
|
+
if (inline !== undefined &&
|
|
1185
|
+
inline instanceof FeatureInlineParagraphItem &&
|
|
1186
|
+
inline.value instanceof Comment) {
|
|
1187
|
+
var commentId = inline.value.commentId;
|
|
1188
|
+
var entry_1 = catalog.entryFor(commentId);
|
|
1189
|
+
var reference_1 = new CommentReference(commentId);
|
|
1190
|
+
found.push(new CommentAnchor(commentId, ((__ts33_7 = entry_1 == null ? undefined : entry_1.author), __ts33_7 != null ? __ts33_7 : ''), entry_1 == null ? undefined : entry_1.date, anchorRunsForReference(content, index, commentId), reference_1));
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
if (inline === undefined ||
|
|
1194
|
+
!(inline instanceof FeatureRunParagraphItem) ||
|
|
1195
|
+
!(inline.value instanceof CommentReference)) {
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
var reference = inline.value;
|
|
1199
|
+
var entry = catalog.entryFor(reference.commentId);
|
|
1200
|
+
found.push(new CommentAnchor(reference.commentId, ((__ts33_8 = entry == null ? undefined : entry.author), __ts33_8 != null ? __ts33_8 : ''), entry == null ? undefined : entry.date, anchorRunsForReference(content, index, reference.commentId), reference));
|
|
1201
|
+
}
|
|
1202
|
+
return found;
|
|
1203
|
+
}
|
|
1204
|
+
function removeRangeMarkers(paragraph, commentId) {
|
|
1205
|
+
var e_16, _a, e_17, _b;
|
|
1206
|
+
var toRemove = [];
|
|
1207
|
+
try {
|
|
1208
|
+
for (var _c = __values(paragraph.items), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1209
|
+
var inline = _d.value;
|
|
1210
|
+
if (!(inline instanceof FeatureInlineParagraphItem)) {
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
if ((inline.value instanceof CommentRangeStart || inline.value instanceof CommentRangeEnd) &&
|
|
1214
|
+
inline.value.commentId === commentId) {
|
|
1215
|
+
toRemove.push(inline.value);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
1220
|
+
finally {
|
|
1221
|
+
try {
|
|
1222
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1223
|
+
}
|
|
1224
|
+
finally { if (e_16) throw e_16.error; }
|
|
1225
|
+
}
|
|
1226
|
+
try {
|
|
1227
|
+
for (var toRemove_1 = __values(toRemove), toRemove_1_1 = toRemove_1.next(); !toRemove_1_1.done; toRemove_1_1 = toRemove_1.next()) {
|
|
1228
|
+
var marker = toRemove_1_1.value;
|
|
1229
|
+
paragraph.removeFeatureInline(marker);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1233
|
+
finally {
|
|
1234
|
+
try {
|
|
1235
|
+
if (toRemove_1_1 && !toRemove_1_1.done && (_b = toRemove_1.return)) _b.call(toRemove_1);
|
|
1236
|
+
}
|
|
1237
|
+
finally { if (e_17) throw e_17.error; }
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function removeReferenceRun(paragraph, reference) {
|
|
1241
|
+
var e_18, _a;
|
|
1242
|
+
try {
|
|
1243
|
+
for (var _b = __values(paragraph.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1244
|
+
var inline = _c.value;
|
|
1245
|
+
if (inline instanceof FeatureInlineParagraphItem && inline.value instanceof Comment) {
|
|
1246
|
+
if (inline.value.commentId === reference.commentId) {
|
|
1247
|
+
paragraph.removeFeatureInline(inline.value);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
continue;
|
|
1251
|
+
}
|
|
1252
|
+
if (inline instanceof FeatureRunParagraphItem &&
|
|
1253
|
+
inline.featureId === COMMENTS &&
|
|
1254
|
+
inline.value instanceof CommentReference &&
|
|
1255
|
+
inline.value.commentId === reference.commentId) {
|
|
1256
|
+
paragraph.removeFeatureRunItem(inline.value);
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
1262
|
+
finally {
|
|
1263
|
+
try {
|
|
1264
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1265
|
+
}
|
|
1266
|
+
finally { if (e_18) throw e_18.error; }
|
|
1267
|
+
}
|
|
1268
|
+
throw new DocxError('content/unknown-comment', 'Comment reference is not in this paragraph');
|
|
1269
|
+
}
|
|
1270
|
+
var registered = false;
|
|
1271
|
+
/** @private Test hook */
|
|
1272
|
+
export function resetCommentsFeatureForTests() {
|
|
1273
|
+
registered = false;
|
|
1274
|
+
}
|
|
1275
|
+
/** @private Register comment inline, run-leaf, and comments-part handlers. Idempotent. */
|
|
1276
|
+
export function registerCommentsFeature() {
|
|
1277
|
+
if (registered) {
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
registered = true;
|
|
1281
|
+
registerFeature({ id: COMMENTS });
|
|
1282
|
+
registerFeatureMultiPartHandler({
|
|
1283
|
+
featureId: COMMENTS,
|
|
1284
|
+
relationshipTypes: COMMENTS_RELATIONSHIP_TYPES,
|
|
1285
|
+
loadParts: function (pkg, ctx) {
|
|
1286
|
+
return loadCatalog(pkg, ctx.mainPartName);
|
|
1287
|
+
},
|
|
1288
|
+
});
|
|
1289
|
+
registerFeatureInlineHandler({
|
|
1290
|
+
featureId: COMMENTS,
|
|
1291
|
+
wmlLocalName: 'commentRangeStart',
|
|
1292
|
+
tryParse: function (element) {
|
|
1293
|
+
if (!isWml(element, 'commentRangeStart')) {
|
|
1294
|
+
return undefined;
|
|
1295
|
+
}
|
|
1296
|
+
var commentId = parseCommentId(wmlAttribute(element, 'id'));
|
|
1297
|
+
if (commentId === undefined) {
|
|
1298
|
+
return undefined;
|
|
1299
|
+
}
|
|
1300
|
+
return new CommentRangeStart(commentId);
|
|
1301
|
+
},
|
|
1302
|
+
});
|
|
1303
|
+
registerFeatureInlineHandler({
|
|
1304
|
+
featureId: COMMENTS,
|
|
1305
|
+
wmlLocalName: 'commentRangeEnd',
|
|
1306
|
+
tryParse: function (element) {
|
|
1307
|
+
if (!isWml(element, 'commentRangeEnd')) {
|
|
1308
|
+
return undefined;
|
|
1309
|
+
}
|
|
1310
|
+
var commentId = parseCommentId(wmlAttribute(element, 'id'));
|
|
1311
|
+
if (commentId === undefined) {
|
|
1312
|
+
return undefined;
|
|
1313
|
+
}
|
|
1314
|
+
return new CommentRangeEnd(commentId);
|
|
1315
|
+
},
|
|
1316
|
+
});
|
|
1317
|
+
registerFeatureRunLeafHandler({
|
|
1318
|
+
featureId: COMMENTS,
|
|
1319
|
+
wmlLocalName: 'commentReference',
|
|
1320
|
+
tryParse: function (element) {
|
|
1321
|
+
if (!isWml(element, 'commentReference')) {
|
|
1322
|
+
return undefined;
|
|
1323
|
+
}
|
|
1324
|
+
var commentId = parseCommentId(wmlAttribute(element, 'id'));
|
|
1325
|
+
if (commentId === undefined) {
|
|
1326
|
+
return undefined;
|
|
1327
|
+
}
|
|
1328
|
+
return new CommentReference(commentId);
|
|
1329
|
+
},
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Public comments collection for a {@link WordDocument}.
|
|
1334
|
+
*
|
|
1335
|
+
* Stable per-document identity. Members are the same interned {@link Comment}
|
|
1336
|
+
* instances returned from {@link Paragraph.appendComment} and the internal
|
|
1337
|
+
* comments catalog.
|
|
1338
|
+
*
|
|
1339
|
+
* Supports `count`, numeric index access, and iteration.
|
|
1340
|
+
*
|
|
1341
|
+
* @public
|
|
1342
|
+
*/
|
|
1343
|
+
var CommentCollection = /** @class */ (function () {
|
|
1344
|
+
/**
|
|
1345
|
+
* @private
|
|
1346
|
+
*/
|
|
1347
|
+
function CommentCollection(document) {
|
|
1348
|
+
this.cachedLength = 0;
|
|
1349
|
+
this.document = document;
|
|
1350
|
+
}
|
|
1351
|
+
Object.defineProperty(CommentCollection.prototype, "count", {
|
|
1352
|
+
/**
|
|
1353
|
+
* Number of modeled comment bodies in the Comments part.
|
|
1354
|
+
*
|
|
1355
|
+
* @public
|
|
1356
|
+
*/
|
|
1357
|
+
get: function () {
|
|
1358
|
+
this.rebuildIndexProperties();
|
|
1359
|
+
return this.cachedLength;
|
|
1360
|
+
},
|
|
1361
|
+
enumerable: true,
|
|
1362
|
+
configurable: true
|
|
1363
|
+
});
|
|
1364
|
+
/**
|
|
1365
|
+
* Comment at zero-based `index`, or `undefined` when out of range.
|
|
1366
|
+
*
|
|
1367
|
+
* @public
|
|
1368
|
+
*/
|
|
1369
|
+
CommentCollection.prototype.itemAt = function (index) {
|
|
1370
|
+
var comments = commentsFor(this.document).comments(this.document);
|
|
1371
|
+
return comments[index];
|
|
1372
|
+
};
|
|
1373
|
+
CommentCollection.prototype[Symbol.iterator] = function () {
|
|
1374
|
+
var items = commentsFor(this.document).comments(this.document).slice();
|
|
1375
|
+
var i = 0;
|
|
1376
|
+
return {
|
|
1377
|
+
next: function () {
|
|
1378
|
+
if (i >= items.length) {
|
|
1379
|
+
return { done: true, value: undefined };
|
|
1380
|
+
}
|
|
1381
|
+
var value = items[i];
|
|
1382
|
+
i += 1;
|
|
1383
|
+
return { done: false, value: value };
|
|
1384
|
+
},
|
|
1385
|
+
};
|
|
1386
|
+
};
|
|
1387
|
+
/**
|
|
1388
|
+
* Refresh numeric index properties from the catalog (part order).
|
|
1389
|
+
*
|
|
1390
|
+
* @private
|
|
1391
|
+
*/
|
|
1392
|
+
CommentCollection.prototype.rebuildIndexProperties = function () {
|
|
1393
|
+
var items = commentsFor(this.document).comments(this.document);
|
|
1394
|
+
var nextLen = items.length;
|
|
1395
|
+
var prevLen = this.cachedLength;
|
|
1396
|
+
var limit = prevLen > nextLen ? prevLen : nextLen;
|
|
1397
|
+
for (var i = 0; i < limit; i += 1) {
|
|
1398
|
+
var key = String(i);
|
|
1399
|
+
if (i < nextLen) {
|
|
1400
|
+
Object.defineProperty(this, key, {
|
|
1401
|
+
value: items[i],
|
|
1402
|
+
writable: false,
|
|
1403
|
+
enumerable: true,
|
|
1404
|
+
configurable: true,
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
delete this[key];
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
this.cachedLength = nextLen;
|
|
1412
|
+
};
|
|
1413
|
+
return CommentCollection;
|
|
1414
|
+
}());
|
|
1415
|
+
export { CommentCollection };
|
|
1416
|
+
var commentCollections = new WeakMap();
|
|
1417
|
+
/**
|
|
1418
|
+
* Stable public {@link CommentCollection} for `document`.
|
|
1419
|
+
*
|
|
1420
|
+
* @private
|
|
1421
|
+
*/
|
|
1422
|
+
export function commentCollectionFor(document) {
|
|
1423
|
+
registerCommentsFeature();
|
|
1424
|
+
var cached = commentCollections.get(document);
|
|
1425
|
+
if (cached !== undefined) {
|
|
1426
|
+
cached.rebuildIndexProperties();
|
|
1427
|
+
return cached;
|
|
1428
|
+
}
|
|
1429
|
+
var created = new CommentCollection(document);
|
|
1430
|
+
created.rebuildIndexProperties();
|
|
1431
|
+
commentCollections.set(document, created);
|
|
1432
|
+
return created;
|
|
1433
|
+
}
|
|
1434
|
+
Object.defineProperty(WordDocument.prototype, 'comments', {
|
|
1435
|
+
configurable: true,
|
|
1436
|
+
enumerable: false,
|
|
1437
|
+
get: function () {
|
|
1438
|
+
return commentCollectionFor(this);
|
|
1439
|
+
},
|
|
1440
|
+
});
|
|
1441
|
+
/**
|
|
1442
|
+
* Comments collection for a WordDocument.
|
|
1443
|
+
*
|
|
1444
|
+
* On a loaded package this is the collection built from the Main WordDocument comments
|
|
1445
|
+
* relationship when the feature was registered before load. On
|
|
1446
|
+
* {@link WordDocument.create} (or a package with no comments part) attaches an empty
|
|
1447
|
+
* collection on first use when the feature is registered.
|
|
1448
|
+
*
|
|
1449
|
+
* The returned {@link CommentsCollection} surface is internal; public callers use
|
|
1450
|
+
* {@link commentsInDocument}, {@link commentFor}, and related helpers.
|
|
1451
|
+
*
|
|
1452
|
+
* @throws DocxError `feature/not-registered` when the module was not registered
|
|
1453
|
+
* or feature state was replaced with an unexpected part type.
|
|
1454
|
+
*
|
|
1455
|
+
* @private
|
|
1456
|
+
*/
|
|
1457
|
+
export function commentsFor(WordDocument) {
|
|
1458
|
+
var part = WordDocument.featurePart(COMMENTS);
|
|
1459
|
+
if (part instanceof CommentsCollection) {
|
|
1460
|
+
return part;
|
|
1461
|
+
}
|
|
1462
|
+
if (part !== undefined) {
|
|
1463
|
+
throw new DocxError('feature/not-registered', 'Comments feature state was replaced with an unexpected part type');
|
|
1464
|
+
}
|
|
1465
|
+
if (!isFeatureRegistered(COMMENTS)) {
|
|
1466
|
+
throw new DocxError('feature/not-registered', 'Comments feature is not registered; call registerCommentsFeature() before use');
|
|
1467
|
+
}
|
|
1468
|
+
var created = new CommentsCollection(undefined, new CommentExtensionParts({
|
|
1469
|
+
extended: undefined,
|
|
1470
|
+
people: undefined,
|
|
1471
|
+
ids: undefined,
|
|
1472
|
+
extensible: undefined,
|
|
1473
|
+
}));
|
|
1474
|
+
WordDocument.setFeaturePart(COMMENTS, created);
|
|
1475
|
+
return created;
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* MS-DOCX comment extension metadata for a loaded WordDocument.
|
|
1479
|
+
*
|
|
1480
|
+
* @private
|
|
1481
|
+
*/
|
|
1482
|
+
export function commentExtensionsFor(WordDocument) {
|
|
1483
|
+
return commentsFor(WordDocument).extensions();
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Live {@link Comment} body for a Comments part id.
|
|
1487
|
+
*
|
|
1488
|
+
* Returns the catalog-interned instance for `(WordDocument, commentId)` so repeated
|
|
1489
|
+
* lookups share object identity (`===`).
|
|
1490
|
+
*
|
|
1491
|
+
* @private
|
|
1492
|
+
*/
|
|
1493
|
+
export function commentFor(WordDocument, commentId) {
|
|
1494
|
+
return commentsFor(WordDocument).commentInstanceFor(WordDocument, commentId);
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Live {@link Comment} body linked from a paragraph anchor.
|
|
1498
|
+
*
|
|
1499
|
+
* Same interned instance as {@link commentFor} for `anchor.commentId`.
|
|
1500
|
+
*
|
|
1501
|
+
* @private
|
|
1502
|
+
*/
|
|
1503
|
+
export function commentForAnchor(WordDocument, anchor) {
|
|
1504
|
+
return commentsFor(WordDocument).commentInstanceFor(WordDocument, anchor.commentId);
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Modeled comment bodies in the Comments part, in part order.
|
|
1508
|
+
*
|
|
1509
|
+
* Opaque preserved entries are omitted. Prefer this for a full catalog list;
|
|
1510
|
+
* {@link commentsInParagraph} lists anchors in the main story.
|
|
1511
|
+
*
|
|
1512
|
+
* @private
|
|
1513
|
+
*/
|
|
1514
|
+
export function commentsInDocument(WordDocument) {
|
|
1515
|
+
return commentsFor(WordDocument).comments(WordDocument);
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Comment anchors in a paragraph, in WordDocument order.
|
|
1519
|
+
*
|
|
1520
|
+
* @private
|
|
1521
|
+
*/
|
|
1522
|
+
export function commentsInParagraph(WordDocument, paragraph) {
|
|
1523
|
+
return findAnchorsInParagraph(paragraph, commentsFor(WordDocument));
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Visible text of a comment body, when loaded (first non-empty run of the first paragraph).
|
|
1527
|
+
*
|
|
1528
|
+
* @private
|
|
1529
|
+
*/
|
|
1530
|
+
export function commentBody(WordDocument, anchor) {
|
|
1531
|
+
return commentsFor(WordDocument).textFor(anchor.commentId);
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Modeled body paragraphs of a comment linked from an anchor.
|
|
1535
|
+
*
|
|
1536
|
+
* @private
|
|
1537
|
+
*/
|
|
1538
|
+
export function commentParagraphs(WordDocument, anchor) {
|
|
1539
|
+
return commentsFor(WordDocument).paragraphsFor(anchor.commentId);
|
|
1540
|
+
}
|
|
1541
|
+
function normalizeCommentDateAttribute(date, defaultNow) {
|
|
1542
|
+
if (date === undefined) {
|
|
1543
|
+
return defaultNow ? new Date().toISOString() : undefined;
|
|
1544
|
+
}
|
|
1545
|
+
if (typeof date === 'string') {
|
|
1546
|
+
return optionalNonEmptyAttribute(date);
|
|
1547
|
+
}
|
|
1548
|
+
return date.toISOString();
|
|
1549
|
+
}
|
|
1550
|
+
function assertCommentRangeIndices(paragraph, rangeStart, rangeEnd) {
|
|
1551
|
+
var length = paragraph.items.length;
|
|
1552
|
+
if (!Number.isInteger(rangeStart) ||
|
|
1553
|
+
!Number.isInteger(rangeEnd) ||
|
|
1554
|
+
rangeStart < 0 ||
|
|
1555
|
+
rangeEnd < rangeStart ||
|
|
1556
|
+
rangeEnd > length) {
|
|
1557
|
+
throw new RangeError("Comment range indices out of range: start=" + String(rangeStart) + " end=" + String(rangeEnd) + " length=" + String(length));
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Resolve optional range indices for append authoring (D15).
|
|
1562
|
+
*
|
|
1563
|
+
* Both omitted → collapsed at current content end. One omitted → collapsed at
|
|
1564
|
+
* the provided index. Validated before any mutation.
|
|
1565
|
+
*/
|
|
1566
|
+
function resolveAppendCommentRange(paragraph, rangeStart, rangeEnd) {
|
|
1567
|
+
var length = paragraph.items.length;
|
|
1568
|
+
var start;
|
|
1569
|
+
var end;
|
|
1570
|
+
if (rangeStart === undefined && rangeEnd === undefined) {
|
|
1571
|
+
start = length;
|
|
1572
|
+
end = length;
|
|
1573
|
+
}
|
|
1574
|
+
else if (rangeStart === undefined) {
|
|
1575
|
+
// One-sided: collapse at the provided end index.
|
|
1576
|
+
start = rangeEnd != null ? rangeEnd : length;
|
|
1577
|
+
end = start;
|
|
1578
|
+
}
|
|
1579
|
+
else if (rangeEnd === undefined) {
|
|
1580
|
+
start = rangeStart;
|
|
1581
|
+
end = rangeStart;
|
|
1582
|
+
}
|
|
1583
|
+
else {
|
|
1584
|
+
start = rangeStart;
|
|
1585
|
+
end = rangeEnd;
|
|
1586
|
+
}
|
|
1587
|
+
assertCommentRangeIndices(paragraph, start, end);
|
|
1588
|
+
return { start: start, end: end };
|
|
1589
|
+
}
|
|
1590
|
+
/**
|
|
1591
|
+
* Insert range markers and one elevated {@link Comment} after the end marker.
|
|
1592
|
+
*
|
|
1593
|
+
* Indices are pre-insert content positions (editable-range style): start at
|
|
1594
|
+
* `rangeStart`, end at `rangeEnd + 1` after the start push, Comment at
|
|
1595
|
+
* `rangeEnd + 2`.
|
|
1596
|
+
*/
|
|
1597
|
+
function insertCommentMarkersAndReference(paragraph, commentId, comment, rangeStart, rangeEnd) {
|
|
1598
|
+
paragraph.insertFeatureInlineAt(rangeStart, COMMENTS, new CommentRangeStart(commentId));
|
|
1599
|
+
paragraph.insertFeatureInlineAt(rangeEnd + 1, COMMENTS, new CommentRangeEnd(commentId));
|
|
1600
|
+
paragraph.insertFeatureInlineAt(rangeEnd + 2, COMMENTS, comment);
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Create a new comments-part entry, intern {@link Comment}, ensure part/rel.
|
|
1604
|
+
*
|
|
1605
|
+
* Always allocates a **new** unique id (never a second reference for an existing id).
|
|
1606
|
+
*/
|
|
1607
|
+
function createNewCommentEntry(WordDocument, author, commentText, options) {
|
|
1608
|
+
var catalog = commentsFor(WordDocument);
|
|
1609
|
+
catalog.ensurePart(usedRelationshipIds(WordDocument), usedPartNameKeys(WordDocument));
|
|
1610
|
+
var date = normalizeCommentDateAttribute(options.date, options.defaultDateNow);
|
|
1611
|
+
var commentId = catalog.addEntry(WordDocument, author, commentText, date, options.initials);
|
|
1612
|
+
var comment = catalog.commentInstanceFor(WordDocument, commentId);
|
|
1613
|
+
comment.applyDefaultReferenceRunStyle();
|
|
1614
|
+
return comment;
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Append a new comment to a paragraph (range markers + elevated {@link Comment}).
|
|
1618
|
+
*
|
|
1619
|
+
* Primary shape: `appendComment(paragraph, text, options?)`. Options-only overload
|
|
1620
|
+
* accepts {@link AppendCommentOptions} with required `text`.
|
|
1621
|
+
*
|
|
1622
|
+
* Behavior (locked D7/D8/D15/D16):
|
|
1623
|
+
* - Comments feature must be registered (`feature/not-registered` otherwise).
|
|
1624
|
+
* - Paragraph must be attached (`DetachedObjectError` via {@link Paragraph.owningDocument}).
|
|
1625
|
+
* - Range indices validated **before** mutation (`RangeError` when invalid/reversed).
|
|
1626
|
+
* - New unique comment id; one catalog entry; one elevated `Comment` after end marker.
|
|
1627
|
+
* - When both range indices omitted: collapsed markers at append point (still emitted).
|
|
1628
|
+
* - Public DOM has no empty sole-purpose `CommentReference` Run.
|
|
1629
|
+
*
|
|
1630
|
+
* @param paragraph - Host paragraph in the main story.
|
|
1631
|
+
* @param textOrOptions - Body text, or full options object.
|
|
1632
|
+
* @param options - Optional metadata / range when the first argument is text.
|
|
1633
|
+
* @returns Interned {@link Comment} (`===` content slot and {@link commentFor}).
|
|
1634
|
+
* @public
|
|
1635
|
+
*/
|
|
1636
|
+
export function appendComment(paragraph, textOrOptions, options) {
|
|
1637
|
+
var resolved = typeof textOrOptions === 'string'
|
|
1638
|
+
? __assign({ text: textOrOptions }, options) : textOrOptions;
|
|
1639
|
+
// Ownership check before any catalog mutation.
|
|
1640
|
+
var WordDocument = paragraph.owningDocument();
|
|
1641
|
+
var range = resolveAppendCommentRange(paragraph, resolved.rangeStart, resolved.rangeEnd);
|
|
1642
|
+
var author = resolved.author != null ? resolved.author : '';
|
|
1643
|
+
var comment = createNewCommentEntry(WordDocument, author, resolved.text, __assign({}, (resolved.date !== undefined ? { date: resolved.date } : {}), (resolved.initials !== undefined ? { initials: resolved.initials } : {}), { defaultDateNow: true }));
|
|
1644
|
+
insertCommentMarkersAndReference(paragraph, comment.commentId, comment, range.start, range.end);
|
|
1645
|
+
return comment;
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Insert a comment with optional anchor text at the end of a paragraph.
|
|
1649
|
+
*
|
|
1650
|
+
* Places an elevated {@link Comment} feature-inline (not a public empty
|
|
1651
|
+
* CommentReference Run). When `anchorText` is non-empty, range markers wrap the
|
|
1652
|
+
* new anchor run before the Comment. When empty, only the elevated Comment is
|
|
1653
|
+
* appended (legacy insert path; prefer {@link appendComment} for D15 markers).
|
|
1654
|
+
*
|
|
1655
|
+
* @private
|
|
1656
|
+
*/
|
|
1657
|
+
export function insertComment(WordDocument, paragraph, author, commentText, anchorText) {
|
|
1658
|
+
if (anchorText === void 0) { anchorText = ''; }
|
|
1659
|
+
var __ts33_9;
|
|
1660
|
+
var comment = createNewCommentEntry(WordDocument, author, commentText, {
|
|
1661
|
+
defaultDateNow: false,
|
|
1662
|
+
});
|
|
1663
|
+
var commentId = comment.commentId;
|
|
1664
|
+
var reference = new CommentReference(commentId);
|
|
1665
|
+
var anchorRuns = [];
|
|
1666
|
+
if (anchorText.length > 0) {
|
|
1667
|
+
paragraph.appendFeatureInline(COMMENTS, new CommentRangeStart(commentId));
|
|
1668
|
+
var anchorRun = paragraph.appendText(anchorText);
|
|
1669
|
+
anchorRuns.push(anchorRun);
|
|
1670
|
+
paragraph.appendFeatureInline(COMMENTS, new CommentRangeEnd(commentId));
|
|
1671
|
+
}
|
|
1672
|
+
// Elevated Comment feature-inline at the former sole-purpose reference run (D1/D5).
|
|
1673
|
+
paragraph.appendFeatureInline(COMMENTS, comment);
|
|
1674
|
+
var entry = commentsFor(WordDocument).entryFor(commentId);
|
|
1675
|
+
return new CommentAnchor(commentId, ((__ts33_9 = entry == null ? undefined : entry.author), __ts33_9 != null ? __ts33_9 : author), entry == null ? undefined : entry.date, anchorRuns, reference);
|
|
1676
|
+
}
|
|
1677
|
+
// Safe once WordDocument.ts no longer value-imports this module (TASK-8056 cycle fix).
|
|
1678
|
+
Paragraph.prototype.appendComment = function (textOrOptions, options) {
|
|
1679
|
+
return appendComment(this, textOrOptions, options);
|
|
1680
|
+
};
|
|
1681
|
+
/**
|
|
1682
|
+
* Remove a comment anchor, range markers, and comments part entry.
|
|
1683
|
+
*
|
|
1684
|
+
* @private
|
|
1685
|
+
*/
|
|
1686
|
+
export function removeComment(WordDocument, paragraph, anchor) {
|
|
1687
|
+
removeRangeMarkers(paragraph, anchor.commentId);
|
|
1688
|
+
removeReferenceRun(paragraph, anchor.reference);
|
|
1689
|
+
commentsFor(WordDocument).removeEntry(anchor.commentId);
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Whether paragraph inline content is a modeled comment range start from this module.
|
|
1693
|
+
*
|
|
1694
|
+
* @private
|
|
1695
|
+
*/
|
|
1696
|
+
export function isCommentRangeStartInline(inline) {
|
|
1697
|
+
return (inline instanceof FeatureInlineParagraphItem &&
|
|
1698
|
+
inline.featureId === COMMENTS &&
|
|
1699
|
+
inline.value instanceof CommentRangeStart);
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Whether paragraph inline content is a modeled comment range end from this module.
|
|
1703
|
+
*
|
|
1704
|
+
* @private
|
|
1705
|
+
*/
|
|
1706
|
+
export function isCommentRangeEndInline(inline) {
|
|
1707
|
+
return (inline instanceof FeatureInlineParagraphItem &&
|
|
1708
|
+
inline.featureId === COMMENTS &&
|
|
1709
|
+
inline.value instanceof CommentRangeEnd);
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Whether a paragraph item is a residual modeled comment reference featureRun.
|
|
1713
|
+
*
|
|
1714
|
+
* @private
|
|
1715
|
+
*/
|
|
1716
|
+
export function isCommentReferenceLeaf(leaf) {
|
|
1717
|
+
return (leaf instanceof FeatureRunParagraphItem &&
|
|
1718
|
+
leaf.featureId === COMMENTS &&
|
|
1719
|
+
leaf.value instanceof CommentReference);
|
|
1720
|
+
}
|
|
1721
|
+
// Always-on on the main `@syncfusion/ej2-docx` entry: comment range/reference handlers +
|
|
1722
|
+
// comments multi-part catalog re-arm after test handler resets via
|
|
1723
|
+
// WordDocument.create / fromPackage.
|
|
1724
|
+
registerAlwaysOnBodyFeatureBootstrap(function () {
|
|
1725
|
+
registerCommentsFeature();
|
|
1726
|
+
});
|
|
1727
|
+
registerCommentsFeature();
|