@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,590 @@
|
|
|
1
|
+
import { DocxError, InvalidArgumentError } from '../../core/errors/docx-error';
|
|
2
|
+
import { visitParagraphsInDocumentOrder } from '../../core/registry/index';
|
|
3
|
+
import { ListType } from './list-style';
|
|
4
|
+
import { numberingFor } from './index';
|
|
5
|
+
var MAX_LIST_LEVEL = 8;
|
|
6
|
+
var stylesLookupFactory;
|
|
7
|
+
/**
|
|
8
|
+
* @private Registered by the styles feature so applyStyle avoids CJS require under Vitest.
|
|
9
|
+
*/
|
|
10
|
+
export function setStylesLookupFactory(factory) {
|
|
11
|
+
stylesLookupFactory = factory;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @private Test-only reset.
|
|
15
|
+
*/
|
|
16
|
+
export function resetStylesLookupFactoryForTests() {
|
|
17
|
+
stylesLookupFactory = undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Live paragraph list formatting (`w:pPr/w:numPr` + document numbering catalog).
|
|
21
|
+
*
|
|
22
|
+
* Obtained via {@link Paragraph.listFormat}. The same logical instance is returned
|
|
23
|
+
* for repeated access on the same paragraph; mutations update the paragraph and
|
|
24
|
+
* numbering definitions immediately.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
var ListFormat = /** @class */ (function () {
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
function ListFormat(paragraph) {
|
|
33
|
+
this.paragraph = paragraph;
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(ListFormat.prototype, "ownerParagraph", {
|
|
36
|
+
/** Owning paragraph. */
|
|
37
|
+
get: function () {
|
|
38
|
+
return this.paragraph;
|
|
39
|
+
},
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(ListFormat.prototype, "listId", {
|
|
44
|
+
/** Numbering instance id (`w:num/@w:numId`), when the paragraph is in a list. */
|
|
45
|
+
get: function () {
|
|
46
|
+
return this.paragraph.numId;
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Assign an existing numbering instance id, or clear with `undefined`.
|
|
50
|
+
* Prefer {@link applyDefBulletStyle} / {@link applyDefNumberedStyle} for new lists.
|
|
51
|
+
*
|
|
52
|
+
* Does not fabricate a default definition for unknown ids.
|
|
53
|
+
*/
|
|
54
|
+
set: function (value) {
|
|
55
|
+
if (value === undefined) {
|
|
56
|
+
this.removeList();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 1 || Math.floor(value) !== value) {
|
|
60
|
+
throw new InvalidArgumentError('listId must be a positive integer');
|
|
61
|
+
}
|
|
62
|
+
var numbering = this.catalog();
|
|
63
|
+
var resolved = numbering.getNumbering(value);
|
|
64
|
+
if (resolved === undefined) {
|
|
65
|
+
if (numbering.hasInstance(value)) {
|
|
66
|
+
// Pending authoring id (createBulletInstance / createDecimalInstance) — keep pending.
|
|
67
|
+
numbering.registerPendingInstance(value);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new DocxError('content/invalid-num-id', 'Numbering instance ' + String(value) + ' is not defined in this document');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
numbering.registerPendingInstance(value);
|
|
75
|
+
}
|
|
76
|
+
this.paragraph.numId = value;
|
|
77
|
+
if (this.paragraph.listLevel === undefined) {
|
|
78
|
+
this.paragraph.listLevel = 0;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(ListFormat.prototype, "listLevelNumber", {
|
|
85
|
+
/** Zero-based indent level (`w:ilvl`), when present. */
|
|
86
|
+
get: function () {
|
|
87
|
+
return this.paragraph.listLevel;
|
|
88
|
+
},
|
|
89
|
+
set: function (value) {
|
|
90
|
+
if (value === undefined) {
|
|
91
|
+
if (this.paragraph.numId === undefined) {
|
|
92
|
+
this.paragraph.listLevel = undefined;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
throw new InvalidArgumentError('listLevelNumber cannot be cleared while the paragraph remains in a list');
|
|
96
|
+
}
|
|
97
|
+
this.assertLevel(value);
|
|
98
|
+
this.assertLevelExistsOnAbstract(value);
|
|
99
|
+
this.paragraph.listLevel = value;
|
|
100
|
+
},
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(ListFormat.prototype, "isList", {
|
|
105
|
+
/** Whether the paragraph is assigned to a numbering instance. */
|
|
106
|
+
get: function () {
|
|
107
|
+
return this.paragraph.numId !== undefined;
|
|
108
|
+
},
|
|
109
|
+
enumerable: true,
|
|
110
|
+
configurable: true
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(ListFormat.prototype, "listType", {
|
|
113
|
+
/**
|
|
114
|
+
* Broad list category from the resolved active level's `numFmt`.
|
|
115
|
+
* {@link ListType.Bulleted} when `numFmt` is `bullet`; otherwise {@link ListType.Numbered}.
|
|
116
|
+
*/
|
|
117
|
+
get: function () {
|
|
118
|
+
var numberFormat = this.numberFormat;
|
|
119
|
+
if (numberFormat === undefined) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
if (numberFormat === 'bullet') {
|
|
123
|
+
return ListType.Bulleted;
|
|
124
|
+
}
|
|
125
|
+
return ListType.Numbered;
|
|
126
|
+
},
|
|
127
|
+
enumerable: true,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(ListFormat.prototype, "numberFormat", {
|
|
131
|
+
/** Number format token at the active level (`w:numFmt/@w:val`). */
|
|
132
|
+
get: function () {
|
|
133
|
+
var level = this.resolvedListLevel;
|
|
134
|
+
return level === undefined ? undefined : level.numFmt;
|
|
135
|
+
},
|
|
136
|
+
enumerable: true,
|
|
137
|
+
configurable: true
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(ListFormat.prototype, "levelText", {
|
|
140
|
+
/** Level text pattern (`w:lvlText/@w:val`) at the active level. */
|
|
141
|
+
get: function () {
|
|
142
|
+
var level = this.resolvedListLevel;
|
|
143
|
+
return level === undefined ? undefined : level.lvlText;
|
|
144
|
+
},
|
|
145
|
+
enumerable: true,
|
|
146
|
+
configurable: true
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(ListFormat.prototype, "listStyleName", {
|
|
149
|
+
/** Named list style applied via {@link applyStyle}, when set. */
|
|
150
|
+
get: function () {
|
|
151
|
+
return this.listStyleNameValue;
|
|
152
|
+
},
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(ListFormat.prototype, "startAt", {
|
|
157
|
+
/** Start value at the active level (override or abstract level). */
|
|
158
|
+
get: function () {
|
|
159
|
+
var listId = this.paragraph.numId;
|
|
160
|
+
if (listId === undefined) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
var level = this.activeLevelIndex();
|
|
164
|
+
try {
|
|
165
|
+
var part = this.catalog();
|
|
166
|
+
var instance = part.getNumbering(listId);
|
|
167
|
+
if (instance !== undefined) {
|
|
168
|
+
var override = instance.levelOverrides.find(function (entry) { return entry.ilvl === level; });
|
|
169
|
+
if (override !== undefined && override.startOverride !== undefined) {
|
|
170
|
+
return override.startOverride;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (_a) {
|
|
175
|
+
// catalog unavailable
|
|
176
|
+
}
|
|
177
|
+
var levelDef = this.resolvedListLevel;
|
|
178
|
+
return levelDef === undefined ? undefined : levelDef.start;
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Set a start override for the active level on the concrete numbering instance.
|
|
182
|
+
* Does not mutate the shared abstract definition.
|
|
183
|
+
*/
|
|
184
|
+
set: function (value) {
|
|
185
|
+
if (value === undefined) {
|
|
186
|
+
throw new InvalidArgumentError('startAt cannot be cleared; pass a non-negative integer');
|
|
187
|
+
}
|
|
188
|
+
this.assertStartAt(value);
|
|
189
|
+
var listId = this.paragraph.numId;
|
|
190
|
+
if (listId === undefined) {
|
|
191
|
+
throw new DocxError('content/not-in-list', 'Paragraph is not in a list; apply a list style before setting startAt');
|
|
192
|
+
}
|
|
193
|
+
var numbering = this.catalog();
|
|
194
|
+
// Materialize pending so overrides can be stored on a concrete instance.
|
|
195
|
+
if (numbering.getNumbering(listId) === undefined) {
|
|
196
|
+
var format = this.inferEnsureFormat();
|
|
197
|
+
numbering.ensureInstance(listId, format);
|
|
198
|
+
}
|
|
199
|
+
var existing = numbering.getNumbering(listId);
|
|
200
|
+
if (existing === undefined) {
|
|
201
|
+
throw new DocxError('content/invalid-num-id', 'Numbering instance ' + String(listId) + ' could not be resolved');
|
|
202
|
+
}
|
|
203
|
+
existing.setStartOverride(this.activeLevelIndex(), value);
|
|
204
|
+
numbering.markDirty();
|
|
205
|
+
},
|
|
206
|
+
enumerable: true,
|
|
207
|
+
configurable: true
|
|
208
|
+
});
|
|
209
|
+
Object.defineProperty(ListFormat.prototype, "abstractNumId", {
|
|
210
|
+
/**
|
|
211
|
+
* @private
|
|
212
|
+
* Abstract numbering definition id when the instance is resolved.
|
|
213
|
+
*/
|
|
214
|
+
get: function () {
|
|
215
|
+
var resolved = this.resolvedList;
|
|
216
|
+
return resolved === undefined ? undefined : resolved.abstractNumId;
|
|
217
|
+
},
|
|
218
|
+
enumerable: true,
|
|
219
|
+
configurable: true
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(ListFormat.prototype, "multiLevelType", {
|
|
222
|
+
/** Abstract multi-level type token, when available. */
|
|
223
|
+
get: function () {
|
|
224
|
+
var abs = this.resolvedAbstractList;
|
|
225
|
+
return abs === undefined ? undefined : abs.multiLevelType;
|
|
226
|
+
},
|
|
227
|
+
enumerable: true,
|
|
228
|
+
configurable: true
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(ListFormat.prototype, "name", {
|
|
231
|
+
/** Abstract definition name, when present. */
|
|
232
|
+
get: function () {
|
|
233
|
+
var abs = this.resolvedAbstractList;
|
|
234
|
+
return abs === undefined ? undefined : abs.name;
|
|
235
|
+
},
|
|
236
|
+
enumerable: true,
|
|
237
|
+
configurable: true
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(ListFormat.prototype, "resolvedList", {
|
|
240
|
+
/** Resolved numbering instance (`w:num`), when available. */
|
|
241
|
+
get: function () {
|
|
242
|
+
var listId = this.paragraph.numId;
|
|
243
|
+
if (listId === undefined) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
return this.catalog().getNumbering(listId);
|
|
248
|
+
}
|
|
249
|
+
catch (_a) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
enumerable: true,
|
|
254
|
+
configurable: true
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(ListFormat.prototype, "resolvedAbstractList", {
|
|
257
|
+
/** Resolved abstract numbering definition, when available. */
|
|
258
|
+
get: function () {
|
|
259
|
+
var instance = this.resolvedList;
|
|
260
|
+
if (instance === undefined) {
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
return this.catalog().getAbstractNumbering(instance.abstractNumId);
|
|
265
|
+
}
|
|
266
|
+
catch (_a) {
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
enumerable: true,
|
|
271
|
+
configurable: true
|
|
272
|
+
});
|
|
273
|
+
Object.defineProperty(ListFormat.prototype, "resolvedListLevel", {
|
|
274
|
+
/** Resolved active list level definition, when available. */
|
|
275
|
+
get: function () {
|
|
276
|
+
var listId = this.paragraph.numId;
|
|
277
|
+
if (listId === undefined) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
var level = this.activeLevelIndex();
|
|
281
|
+
try {
|
|
282
|
+
return resolveLevelDefinition(this.catalog(), listId, level);
|
|
283
|
+
}
|
|
284
|
+
catch (_a) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
enumerable: true,
|
|
289
|
+
configurable: true
|
|
290
|
+
});
|
|
291
|
+
/**
|
|
292
|
+
* Apply the default nine-level bullet list and set level `0`.
|
|
293
|
+
*/
|
|
294
|
+
ListFormat.prototype.applyDefBulletStyle = function () {
|
|
295
|
+
var numbering = this.catalog();
|
|
296
|
+
var listId = numbering.createBulletInstance();
|
|
297
|
+
this.paragraph.numId = listId;
|
|
298
|
+
this.paragraph.listLevel = 0;
|
|
299
|
+
this.listStyleNameValue = undefined;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Apply the default nine-level numbered (decimal hybrid) list and set level `0`.
|
|
303
|
+
*/
|
|
304
|
+
ListFormat.prototype.applyDefNumberedStyle = function () {
|
|
305
|
+
var numbering = this.catalog();
|
|
306
|
+
var listId = numbering.createDecimalInstance();
|
|
307
|
+
this.paragraph.numId = listId;
|
|
308
|
+
this.paragraph.listLevel = 0;
|
|
309
|
+
this.listStyleNameValue = undefined;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Apply a named numbering style from the document styles part.
|
|
313
|
+
*
|
|
314
|
+
* Resolves `type="numbering"` styles by style id or display name, then binds a
|
|
315
|
+
* numbering instance linked through `w:styleLink` / abstract name, or creates
|
|
316
|
+
* a new instance from a matching abstract definition.
|
|
317
|
+
*
|
|
318
|
+
* @param styleName - Non-empty style id or display name.
|
|
319
|
+
* @throws InvalidArgumentError when `styleName` is empty.
|
|
320
|
+
* @throws DocxError when the style is missing or not a numbering style.
|
|
321
|
+
*/
|
|
322
|
+
ListFormat.prototype.applyStyle = function (styleName) {
|
|
323
|
+
if (typeof styleName !== 'string' || styleName.trim() === '') {
|
|
324
|
+
throw new InvalidArgumentError('styleName must be a non-empty string');
|
|
325
|
+
}
|
|
326
|
+
var name = styleName.trim();
|
|
327
|
+
var doc = this.paragraph.owningDocument();
|
|
328
|
+
if (stylesLookupFactory === undefined) {
|
|
329
|
+
throw new DocxError('feature/not-registered', 'Styles part is required to apply a list style; ensure styles are registered');
|
|
330
|
+
}
|
|
331
|
+
var styles;
|
|
332
|
+
try {
|
|
333
|
+
styles = stylesLookupFactory(doc);
|
|
334
|
+
}
|
|
335
|
+
catch (err) {
|
|
336
|
+
throw new DocxError('feature/not-registered', 'Styles part is required to apply a list style; ensure styles are registered', err instanceof Error ? { cause: err } : undefined);
|
|
337
|
+
}
|
|
338
|
+
var style = styles.getStyle(name) !== undefined
|
|
339
|
+
? styles.getStyle(name)
|
|
340
|
+
: styles.findStyleByDisplayName(name);
|
|
341
|
+
if (style === undefined) {
|
|
342
|
+
throw new DocxError('styles/undefined-style', "Style \"" + name + "\" is not defined in this document");
|
|
343
|
+
}
|
|
344
|
+
if (style.type !== 'numbering') {
|
|
345
|
+
throw new DocxError('styles/invalid-type-for-target', "Style \"" + style.styleId + "\" is a " + String(style.type) + " style and cannot be used as a numbering style");
|
|
346
|
+
}
|
|
347
|
+
var numbering = this.catalog();
|
|
348
|
+
var listId = resolveNumberingStyleToInstance(numbering, style.styleId, style.name);
|
|
349
|
+
this.paragraph.numId = listId;
|
|
350
|
+
this.paragraph.listLevel = 0;
|
|
351
|
+
this.listStyleNameValue = style.name !== undefined ? style.name : style.styleId;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Continue the nearest preceding list in document order.
|
|
355
|
+
* Reuses that paragraph's numbering instance; keeps this paragraph's level when set.
|
|
356
|
+
*
|
|
357
|
+
* @throws DocxError when no preceding list paragraph exists in the document.
|
|
358
|
+
*/
|
|
359
|
+
ListFormat.prototype.continueListNumbering = function () {
|
|
360
|
+
var _this = this;
|
|
361
|
+
var doc = this.paragraph.owningDocument();
|
|
362
|
+
var previous;
|
|
363
|
+
var foundSelf = false;
|
|
364
|
+
visitParagraphsInDocumentOrder(doc, function (p) {
|
|
365
|
+
if (foundSelf) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (p === _this.paragraph) {
|
|
369
|
+
foundSelf = true;
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (p.numId !== undefined) {
|
|
373
|
+
previous = p;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
if (previous === undefined || previous.numId === undefined) {
|
|
377
|
+
throw new DocxError('content/no-preceding-list', 'No preceding list paragraph is available to continue');
|
|
378
|
+
}
|
|
379
|
+
var level = this.paragraph.listLevel !== undefined
|
|
380
|
+
? this.paragraph.listLevel
|
|
381
|
+
: previous.listLevel !== undefined
|
|
382
|
+
? previous.listLevel
|
|
383
|
+
: 0;
|
|
384
|
+
this.paragraph.numId = previous.numId;
|
|
385
|
+
this.paragraph.listLevel = level;
|
|
386
|
+
try {
|
|
387
|
+
this.catalog().registerPendingInstance(previous.numId);
|
|
388
|
+
}
|
|
389
|
+
catch (_a) {
|
|
390
|
+
// ignore if catalog not attached yet
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Restart numbering as a new list instance that reuses the current abstract definition.
|
|
395
|
+
*
|
|
396
|
+
* @param startAt - Optional start value for the active level (`w:startOverride`).
|
|
397
|
+
*/
|
|
398
|
+
ListFormat.prototype.restartNumbering = function (startAt) {
|
|
399
|
+
var listId = this.paragraph.numId;
|
|
400
|
+
if (listId === undefined) {
|
|
401
|
+
throw new DocxError('content/not-in-list', 'Paragraph is not in a list; apply a list style before restarting');
|
|
402
|
+
}
|
|
403
|
+
if (startAt !== undefined) {
|
|
404
|
+
this.assertStartAt(startAt);
|
|
405
|
+
}
|
|
406
|
+
var numbering = this.catalog();
|
|
407
|
+
// Materialize pending so abstract id is known.
|
|
408
|
+
if (numbering.getNumbering(listId) === undefined) {
|
|
409
|
+
numbering.ensureInstance(listId, this.inferEnsureFormat());
|
|
410
|
+
}
|
|
411
|
+
var existing = numbering.getNumbering(listId);
|
|
412
|
+
if (existing === undefined) {
|
|
413
|
+
throw new DocxError('content/invalid-num-id', "Numbering instance " + String(listId) + " could not be resolved");
|
|
414
|
+
}
|
|
415
|
+
var level = this.activeLevelIndex();
|
|
416
|
+
var start = startAt !== undefined ? startAt : 1;
|
|
417
|
+
var newId = numbering.createInstanceFromAbstract(existing.abstractNumId);
|
|
418
|
+
var restarted = numbering.getNumbering(newId);
|
|
419
|
+
if (restarted === undefined) {
|
|
420
|
+
throw new DocxError('content/invalid-num-id', "Failed to create restarted numbering instance");
|
|
421
|
+
}
|
|
422
|
+
restarted.setStartOverride(level, start);
|
|
423
|
+
numbering.markDirty();
|
|
424
|
+
this.paragraph.numId = newId;
|
|
425
|
+
this.paragraph.listLevel = level;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* Increase the active list level by one (max 8). No-op when not in a list or already at 8.
|
|
429
|
+
*/
|
|
430
|
+
ListFormat.prototype.increaseIndentLevel = function () {
|
|
431
|
+
if (this.paragraph.numId === undefined) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
var current = this.activeLevelIndex();
|
|
435
|
+
if (current >= MAX_LIST_LEVEL) {
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
this.paragraph.listLevel = current + 1;
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Decrease the active list level by one (min 0). No-op when not in a list or already at 0.
|
|
442
|
+
* Does not remove list membership at level 0.
|
|
443
|
+
*/
|
|
444
|
+
ListFormat.prototype.decreaseIndentLevel = function () {
|
|
445
|
+
if (this.paragraph.numId === undefined) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
var current = this.activeLevelIndex();
|
|
449
|
+
if (current <= 0) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
this.paragraph.listLevel = current - 1;
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* Remove list membership (`w:numPr` / numId and ilvl) without deleting catalog definitions.
|
|
456
|
+
*/
|
|
457
|
+
ListFormat.prototype.removeList = function () {
|
|
458
|
+
this.paragraph.numId = undefined;
|
|
459
|
+
this.paragraph.listLevel = undefined;
|
|
460
|
+
this.listStyleNameValue = undefined;
|
|
461
|
+
};
|
|
462
|
+
ListFormat.prototype.catalog = function () {
|
|
463
|
+
return numberingFor(this.paragraph.owningDocument());
|
|
464
|
+
};
|
|
465
|
+
ListFormat.prototype.activeLevelIndex = function () {
|
|
466
|
+
var level = this.paragraph.listLevel;
|
|
467
|
+
return level !== undefined ? level : 0;
|
|
468
|
+
};
|
|
469
|
+
ListFormat.prototype.assertLevel = function (value) {
|
|
470
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || Math.floor(value) !== value) {
|
|
471
|
+
throw new InvalidArgumentError('list level must be an integer from 0 through 8');
|
|
472
|
+
}
|
|
473
|
+
if (value < 0 || value > MAX_LIST_LEVEL) {
|
|
474
|
+
throw new InvalidArgumentError('list level must be an integer from 0 through 8');
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
ListFormat.prototype.assertStartAt = function (value) {
|
|
478
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || Math.floor(value) !== value) {
|
|
479
|
+
throw new InvalidArgumentError('startAt must be a finite integer');
|
|
480
|
+
}
|
|
481
|
+
if (value < 0) {
|
|
482
|
+
throw new InvalidArgumentError('startAt must be a non-negative integer');
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* When abstract is already resolved, ensure `ilvl` exists; pending lists skip (nine levels on materialize).
|
|
487
|
+
*/
|
|
488
|
+
ListFormat.prototype.assertLevelExistsOnAbstract = function (level) {
|
|
489
|
+
var listId = this.paragraph.numId;
|
|
490
|
+
if (listId === undefined) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
var part = this.catalog();
|
|
495
|
+
var instance = part.getNumbering(listId);
|
|
496
|
+
if (instance === undefined) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
var abstract = part.getAbstractNumbering(instance.abstractNumId);
|
|
500
|
+
if (abstract === undefined) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
var override = instance.levelOverrides.find(function (entry) { return entry.ilvl === level; });
|
|
504
|
+
if (override !== undefined && override.level !== undefined) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
var fromAbstract = abstract.levels.find(function (entry) { return entry.ilvl === level; });
|
|
508
|
+
if (fromAbstract === undefined) {
|
|
509
|
+
throw new DocxError('content/invalid-list-level', 'List level ' + String(level) + ' does not exist on numbering instance ' + String(listId));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
catch (err) {
|
|
513
|
+
if (err instanceof DocxError || err instanceof InvalidArgumentError) {
|
|
514
|
+
throw err;
|
|
515
|
+
}
|
|
516
|
+
// catalog unavailable — skip existence check
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
/** Map pending decimal ids to decimal ensure format; default bullet. */
|
|
520
|
+
ListFormat.prototype.inferEnsureFormat = function () {
|
|
521
|
+
var listId = this.paragraph.numId;
|
|
522
|
+
if (listId === undefined) {
|
|
523
|
+
return 'bullet';
|
|
524
|
+
}
|
|
525
|
+
try {
|
|
526
|
+
var part = this.catalog();
|
|
527
|
+
if (part.isPendingDecimal(listId)) {
|
|
528
|
+
return 'decimal';
|
|
529
|
+
}
|
|
530
|
+
var numberFormat = this.numberFormat;
|
|
531
|
+
if (numberFormat !== undefined && numberFormat !== 'bullet') {
|
|
532
|
+
return 'decimal';
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch (_a) {
|
|
536
|
+
// ignore
|
|
537
|
+
}
|
|
538
|
+
return 'bullet';
|
|
539
|
+
};
|
|
540
|
+
return ListFormat;
|
|
541
|
+
}());
|
|
542
|
+
export { ListFormat };
|
|
543
|
+
/**
|
|
544
|
+
* @private
|
|
545
|
+
*/
|
|
546
|
+
export function resolveLevelDefinition(part, numId, level) {
|
|
547
|
+
var instance = part.getNumbering(numId);
|
|
548
|
+
if (instance === undefined) {
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
var abstract = part.getAbstractNumbering(instance.abstractNumId);
|
|
552
|
+
if (abstract === undefined) {
|
|
553
|
+
return undefined;
|
|
554
|
+
}
|
|
555
|
+
var override = instance.levelOverrides.find(function (entry) { return entry.ilvl === level; });
|
|
556
|
+
if (override !== undefined && override.level !== undefined) {
|
|
557
|
+
return override.level;
|
|
558
|
+
}
|
|
559
|
+
var fromAbstract = abstract.levels.find(function (entry) { return entry.ilvl === level; });
|
|
560
|
+
if (fromAbstract !== undefined) {
|
|
561
|
+
return fromAbstract;
|
|
562
|
+
}
|
|
563
|
+
// Do not silently fall back to level 0 when the requested level is missing.
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
function resolveNumberingStyleToInstance(numbering, styleId, displayName) {
|
|
567
|
+
for (var i = 0; i < numbering.abstractNumberings.length; i += 1) {
|
|
568
|
+
var abs = numbering.abstractNumberings[i];
|
|
569
|
+
var matchesStyle = abs.styleLink === styleId ||
|
|
570
|
+
(displayName !== undefined && abs.styleLink === displayName) ||
|
|
571
|
+
abs.name === styleId ||
|
|
572
|
+
(displayName !== undefined && abs.name === displayName);
|
|
573
|
+
if (!matchesStyle) {
|
|
574
|
+
if (abs.numStyleLink === styleId || (displayName !== undefined && abs.numStyleLink === displayName)) {
|
|
575
|
+
// External numStyleLink without a local abstract binding — keep searching.
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
// Reuse an existing w:num for this abstract so continued applyStyle shares counters.
|
|
581
|
+
for (var j = 0; j < numbering.numberings.length; j += 1) {
|
|
582
|
+
var inst = numbering.numberings[j];
|
|
583
|
+
if (inst.abstractNumId === abs.abstractNumId) {
|
|
584
|
+
return inst.numId;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return numbering.createInstanceFromAbstract(abs.abstractNumId);
|
|
588
|
+
}
|
|
589
|
+
throw new DocxError('content/unresolved-numbering-style', 'No numbering definition is linked to style "' + styleId + '"');
|
|
590
|
+
}
|