@syncfusion/ej2-docx 0.0.0-stage → 35.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitleaksignore +35 -0
- package/README.md +68 -2
- package/core.js +4 -0
- package/dist/ej2-docx.umd.min.js +11 -0
- package/dist/ej2-docx.umd.min.js.map +1 -0
- package/dist/es6/ej2-docx.es2015.js +66697 -0
- package/dist/es6/ej2-docx.es2015.js.map +1 -0
- package/dist/es6/ej2-docx.es5.js +77568 -0
- package/dist/es6/ej2-docx.es5.js.map +1 -0
- package/dist/global/ej2-docx.min.js +11 -0
- package/dist/global/ej2-docx.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/features.js +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +30 -3
- package/src/all.d.ts +50 -0
- package/src/all.js +147 -0
- package/src/core/compat/base64.d.ts +13 -0
- package/src/core/compat/base64.js +90 -0
- package/src/core/compat/object-compat.d.ts +30 -0
- package/src/core/compat/object-compat.js +40 -0
- package/src/core/compat/sha256.d.ts +9 -0
- package/src/core/compat/sha256.js +98 -0
- package/src/core/errors/docx-error.d.ts +89 -0
- package/src/core/errors/docx-error.js +138 -0
- package/src/core/errors/error-codes.d.ts +8 -0
- package/src/core/errors/error-codes.js +0 -0
- package/src/core/errors/index.d.ts +10 -0
- package/src/core/errors/index.js +9 -0
- package/src/core/index.d.ts +12 -0
- package/src/core/index.js +12 -0
- package/src/core/mc/alternate-content.d.ts +7 -0
- package/src/core/mc/alternate-content.js +67 -0
- package/src/core/mc/attributes.d.ts +24 -0
- package/src/core/mc/attributes.js +82 -0
- package/src/core/mc/index.d.ts +7 -0
- package/src/core/mc/index.js +5 -0
- package/src/core/mc/inspect.d.ts +16 -0
- package/src/core/mc/inspect.js +148 -0
- package/src/core/mc/namespaces.d.ts +4 -0
- package/src/core/mc/namespaces.js +4 -0
- package/src/core/mc/scope.d.ts +6 -0
- package/src/core/mc/scope.js +47 -0
- package/src/core/opc/content-types.d.ts +34 -0
- package/src/core/opc/content-types.js +162 -0
- package/src/core/opc/index.d.ts +8 -0
- package/src/core/opc/index.js +4 -0
- package/src/core/opc/package.d.ts +49 -0
- package/src/core/opc/package.js +324 -0
- package/src/core/opc/part-name.d.ts +47 -0
- package/src/core/opc/part-name.js +205 -0
- package/src/core/opc/relationships.d.ts +46 -0
- package/src/core/opc/relationships.js +212 -0
- package/src/core/preservation/index.d.ts +2 -0
- package/src/core/preservation/index.js +1 -0
- package/src/core/preservation/opaque-body.d.ts +16 -0
- package/src/core/preservation/opaque-body.js +69 -0
- package/src/core/registry/block-handlers.d.ts +30 -0
- package/src/core/registry/block-handlers.js +36 -0
- package/src/core/registry/create-defaults.d.ts +39 -0
- package/src/core/registry/create-defaults.js +42 -0
- package/src/core/registry/feature-registry.d.ts +20 -0
- package/src/core/registry/feature-registry.js +29 -0
- package/src/core/registry/index.d.ts +9 -0
- package/src/core/registry/index.js +8 -0
- package/src/core/registry/inline-handlers.d.ts +20 -0
- package/src/core/registry/inline-handlers.js +30 -0
- package/src/core/registry/materialize-handlers.d.ts +35 -0
- package/src/core/registry/materialize-handlers.js +75 -0
- package/src/core/registry/multi-part-handlers.d.ts +37 -0
- package/src/core/registry/multi-part-handlers.js +206 -0
- package/src/core/registry/package-part-handlers.d.ts +28 -0
- package/src/core/registry/package-part-handlers.js +190 -0
- package/src/core/registry/part-handlers.d.ts +24 -0
- package/src/core/registry/part-handlers.js +172 -0
- package/src/core/registry/run-leaf-handlers.d.ts +26 -0
- package/src/core/registry/run-leaf-handlers.js +72 -0
- package/src/core/security/limits.d.ts +40 -0
- package/src/core/security/limits.js +26 -0
- package/src/core/xml/index.d.ts +7 -0
- package/src/core/xml/index.js +3 -0
- package/src/core/xml/model.d.ts +66 -0
- package/src/core/xml/model.js +17 -0
- package/src/core/xml/parse.d.ts +12 -0
- package/src/core/xml/parse.js +382 -0
- package/src/core/xml/serialize.d.ts +6 -0
- package/src/core/xml/serialize.js +93 -0
- package/src/core/zip/crc32.d.ts +2 -0
- package/src/core/zip/crc32.js +25 -0
- package/src/core/zip/deflate.d.ts +6 -0
- package/src/core/zip/deflate.js +6 -0
- package/src/core/zip/index.d.ts +10 -0
- package/src/core/zip/index.js +4 -0
- package/src/core/zip/inflate-raw.d.ts +17 -0
- package/src/core/zip/inflate-raw.js +450 -0
- package/src/core/zip/names.d.ts +6 -0
- package/src/core/zip/names.js +52 -0
- package/src/core/zip/read.d.ts +8 -0
- package/src/core/zip/read.js +262 -0
- package/src/core/zip/write.d.ts +7 -0
- package/src/core/zip/write.js +189 -0
- package/src/core/zip/zip-entry.d.ts +4 -0
- package/src/core/zip/zip-entry.js +0 -0
- package/src/features/bibliography/index.d.ts +100 -0
- package/src/features/bibliography/index.js +290 -0
- package/src/features/bookmarks/index.d.ts +331 -0
- package/src/features/bookmarks/index.js +1009 -0
- package/src/features/comments/comment-extensions.d.ts +157 -0
- package/src/features/comments/comment-extensions.js +356 -0
- package/src/features/comments/index.d.ts +579 -0
- package/src/features/comments/index.js +1727 -0
- package/src/features/content-controls/index.d.ts +821 -0
- package/src/features/content-controls/index.js +2857 -0
- package/src/features/custom-xml/index.d.ts +236 -0
- package/src/features/custom-xml/index.js +661 -0
- package/src/features/document/alignment.d.ts +23 -0
- package/src/features/document/alignment.js +36 -0
- package/src/features/document/alt-chunk.d.ts +103 -0
- package/src/features/document/alt-chunk.js +221 -0
- package/src/features/document/assert-never.d.ts +1 -0
- package/src/features/document/assert-never.js +4 -0
- package/src/features/document/augmentations.d.ts +578 -0
- package/src/features/document/augmentations.js +0 -0
- package/src/features/document/body-always-on.d.ts +36 -0
- package/src/features/document/body-always-on.js +66 -0
- package/src/features/document/body-blocks.d.ts +7 -0
- package/src/features/document/body-blocks.js +78 -0
- package/src/features/document/body-item-adapters.d.ts +62 -0
- package/src/features/document/body-item-adapters.js +97 -0
- package/src/features/document/body-item-collection.d.ts +151 -0
- package/src/features/document/body-item-collection.js +440 -0
- package/src/features/document/body-item.d.ts +35 -0
- package/src/features/document/body-item.js +8 -0
- package/src/features/document/body.d.ts +150 -0
- package/src/features/document/body.js +263 -0
- package/src/features/document/character-format.d.ts +413 -0
- package/src/features/document/character-format.js +2054 -0
- package/src/features/document/color.d.ts +178 -0
- package/src/features/document/color.js +495 -0
- package/src/features/document/document.d.ts +410 -0
- package/src/features/document/document.js +1049 -0
- package/src/features/document/element-type.d.ts +68 -0
- package/src/features/document/element-type.js +133 -0
- package/src/features/document/entity-type.d.ts +92 -0
- package/src/features/document/entity-type.js +93 -0
- package/src/features/document/feature-block.d.ts +16 -0
- package/src/features/document/feature-block.js +0 -0
- package/src/features/document/feature-inline.d.ts +13 -0
- package/src/features/document/feature-inline.js +0 -0
- package/src/features/document/feature-multi-package-part.d.ts +19 -0
- package/src/features/document/feature-multi-package-part.js +8 -0
- package/src/features/document/feature-package-level-part.d.ts +18 -0
- package/src/features/document/feature-package-level-part.js +8 -0
- package/src/features/document/feature-package-part.d.ts +14 -0
- package/src/features/document/feature-package-part.js +0 -0
- package/src/features/document/feature-run-leaf.d.ts +9 -0
- package/src/features/document/feature-run-leaf.js +0 -0
- package/src/features/document/headers-footers.d.ts +206 -0
- package/src/features/document/headers-footers.js +384 -0
- package/src/features/document/index.d.ts +41 -0
- package/src/features/document/index.js +34 -0
- package/src/features/document/length.d.ts +152 -0
- package/src/features/document/length.js +245 -0
- package/src/features/document/load-options.d.ts +14 -0
- package/src/features/document/load-options.js +0 -0
- package/src/features/document/locale-ids.d.ts +227 -0
- package/src/features/document/locale-ids.js +485 -0
- package/src/features/document/on-off.d.ts +9 -0
- package/src/features/document/on-off.js +27 -0
- package/src/features/document/page-setup.d.ts +339 -0
- package/src/features/document/page-setup.js +244 -0
- package/src/features/document/paragraph-format.d.ts +880 -0
- package/src/features/document/paragraph-format.js +2807 -0
- package/src/features/document/paragraph-item-collection.d.ts +162 -0
- package/src/features/document/paragraph-item-collection.js +363 -0
- package/src/features/document/paragraph-item.d.ts +83 -0
- package/src/features/document/paragraph-item.js +103 -0
- package/src/features/document/paragraph.d.ts +435 -0
- package/src/features/document/paragraph.js +888 -0
- package/src/features/document/run.d.ts +1 -0
- package/src/features/document/run.js +768 -0
- package/src/features/document/section-partition-flatten.d.ts +124 -0
- package/src/features/document/section-partition-flatten.js +217 -0
- package/src/features/document/section-properties-model.d.ts +13 -0
- package/src/features/document/section-properties-model.js +0 -0
- package/src/features/document/section.d.ts +93 -0
- package/src/features/document/section.js +178 -0
- package/src/features/document/sections.d.ts +103 -0
- package/src/features/document/sections.js +217 -0
- package/src/features/document/sub-super-script.d.ts +23 -0
- package/src/features/document/sub-super-script.js +43 -0
- package/src/features/document/text-range.d.ts +445 -0
- package/src/features/document/text-range.js +1156 -0
- package/src/features/document/typed-body-collections.d.ts +162 -0
- package/src/features/document/typed-body-collections.js +371 -0
- package/src/features/document/underline-style.d.ts +38 -0
- package/src/features/document/underline-style.js +126 -0
- package/src/features/document/units.d.ts +8 -0
- package/src/features/document/units.js +7 -0
- package/src/features/document/wml.d.ts +16 -0
- package/src/features/document/wml.js +67 -0
- package/src/features/drawing/authoring.d.ts +27 -0
- package/src/features/drawing/authoring.js +271 -0
- package/src/features/drawing/body-pr.d.ts +271 -0
- package/src/features/drawing/body-pr.js +663 -0
- package/src/features/drawing/drawing-shape.d.ts +1192 -0
- package/src/features/drawing/drawing-shape.js +3239 -0
- package/src/features/drawing/encode-builders.d.ts +176 -0
- package/src/features/drawing/encode-builders.js +390 -0
- package/src/features/drawing/fill-format.d.ts +52 -0
- package/src/features/drawing/fill-format.js +124 -0
- package/src/features/drawing/host-codec.d.ts +632 -0
- package/src/features/drawing/host-codec.js +2595 -0
- package/src/features/drawing/index.d.ts +13 -0
- package/src/features/drawing/index.js +33 -0
- package/src/features/drawing/line-format.d.ts +76 -0
- package/src/features/drawing/line-format.js +343 -0
- package/src/features/drawing/parse-register.d.ts +50 -0
- package/src/features/drawing/parse-register.js +257 -0
- package/src/features/drawing/residual-utils.d.ts +47 -0
- package/src/features/drawing/residual-utils.js +290 -0
- package/src/features/drawing/shape-types.d.ts +433 -0
- package/src/features/drawing/shape-types.js +437 -0
- package/src/features/drawing/sp-pr.d.ts +396 -0
- package/src/features/drawing/sp-pr.js +610 -0
- package/src/features/drawing/text-frame.d.ts +90 -0
- package/src/features/drawing/text-frame.js +152 -0
- package/src/features/drawing/types.d.ts +352 -0
- package/src/features/drawing/types.js +60 -0
- package/src/features/drawing/wrap-format.d.ts +62 -0
- package/src/features/drawing/wrap-format.js +114 -0
- package/src/features/editable-ranges/index.d.ts +494 -0
- package/src/features/editable-ranges/index.js +1348 -0
- package/src/features/fields/index.d.ts +428 -0
- package/src/features/fields/index.js +2148 -0
- package/src/features/fields/paragraph-field.d.ts +187 -0
- package/src/features/fields/paragraph-field.js +692 -0
- package/src/features/font-table/font-substitution-table.d.ts +75 -0
- package/src/features/font-table/font-substitution-table.js +257 -0
- package/src/features/font-table/font-table-entry.d.ts +255 -0
- package/src/features/font-table/font-table-entry.js +823 -0
- package/src/features/font-table/font-table.d.ts +128 -0
- package/src/features/font-table/font-table.js +313 -0
- package/src/features/font-table/index.d.ts +27 -0
- package/src/features/font-table/index.js +48 -0
- package/src/features/glossary/index.d.ts +97 -0
- package/src/features/glossary/index.js +286 -0
- package/src/features/headers-footers/index.d.ts +506 -0
- package/src/features/headers-footers/index.js +1666 -0
- package/src/features/hyperlinks/index.d.ts +230 -0
- package/src/features/hyperlinks/index.js +685 -0
- package/src/features/images/caption-authoring-api.d.ts +33 -0
- package/src/features/images/caption-authoring-api.js +33 -0
- package/src/features/images/caption-enums.d.ts +52 -0
- package/src/features/images/caption-enums.js +141 -0
- package/src/features/images/caption-host.d.ts +10 -0
- package/src/features/images/caption-host.js +21 -0
- package/src/features/images/captions.d.ts +13 -0
- package/src/features/images/captions.js +142 -0
- package/src/features/images/host-codec.d.ts +103 -0
- package/src/features/images/host-codec.js +720 -0
- package/src/features/images/image-sniff.d.ts +21 -0
- package/src/features/images/image-sniff.js +71 -0
- package/src/features/images/index.d.ts +506 -0
- package/src/features/images/index.js +1429 -0
- package/src/features/images/layout-types.d.ts +232 -0
- package/src/features/images/layout-types.js +294 -0
- package/src/features/images/public-entry.d.ts +9 -0
- package/src/features/images/public-entry.js +9 -0
- package/src/features/index.d.ts +35 -0
- package/src/features/index.js +36 -0
- package/src/features/mail-merge/index.d.ts +113 -0
- package/src/features/mail-merge/index.js +315 -0
- package/src/features/notes/index.d.ts +573 -0
- package/src/features/notes/index.js +1725 -0
- package/src/features/numbering/abstract-numbering.d.ts +90 -0
- package/src/features/numbering/abstract-numbering.js +292 -0
- package/src/features/numbering/index.d.ts +182 -0
- package/src/features/numbering/index.js +668 -0
- package/src/features/numbering/list-format.d.ts +158 -0
- package/src/features/numbering/list-format.js +590 -0
- package/src/features/numbering/list-string.d.ts +7 -0
- package/src/features/numbering/list-string.js +423 -0
- package/src/features/numbering/list-style.d.ts +204 -0
- package/src/features/numbering/list-style.js +1084 -0
- package/src/features/numbering/numbering-instance.d.ts +101 -0
- package/src/features/numbering/numbering-instance.js +329 -0
- package/src/features/numbering/numbering-level.d.ts +118 -0
- package/src/features/numbering/numbering-level.js +501 -0
- package/src/features/numbering/picture-bullet.d.ts +34 -0
- package/src/features/numbering/picture-bullet.js +88 -0
- package/src/features/ole-object/catalog.d.ts +300 -0
- package/src/features/ole-object/catalog.js +908 -0
- package/src/features/ole-object/index.d.ts +526 -0
- package/src/features/ole-object/index.js +1421 -0
- package/src/features/ole-object/relationship.d.ts +27 -0
- package/src/features/ole-object/relationship.js +27 -0
- package/src/features/ole-object/typed-dom.d.ts +186 -0
- package/src/features/ole-object/typed-dom.js +595 -0
- package/src/features/properties/index.d.ts +205 -0
- package/src/features/properties/index.js +549 -0
- package/src/features/revisions/index.d.ts +204 -0
- package/src/features/revisions/index.js +695 -0
- package/src/features/sections/column-collection.d.ts +119 -0
- package/src/features/sections/column-collection.js +478 -0
- package/src/features/sections/column.d.ts +15 -0
- package/src/features/sections/column.js +37 -0
- package/src/features/sections/index.d.ts +91 -0
- package/src/features/sections/index.js +1096 -0
- package/src/features/sections/margins.d.ts +40 -0
- package/src/features/sections/margins.js +105 -0
- package/src/features/sections/page-number-style.d.ts +21 -0
- package/src/features/sections/page-number-style.js +62 -0
- package/src/features/sections/page-orientation.d.ts +10 -0
- package/src/features/sections/page-orientation.js +10 -0
- package/src/features/sections/page-setup.d.ts +435 -0
- package/src/features/sections/page-setup.js +1479 -0
- package/src/features/sections/page-size.d.ts +59 -0
- package/src/features/sections/page-size.js +68 -0
- package/src/features/sections/section-break-code.d.ts +27 -0
- package/src/features/sections/section-break-code.js +60 -0
- package/src/features/sections/section-document-association.d.ts +18 -0
- package/src/features/sections/section-document-association.js +31 -0
- package/src/features/sections/section-validation.d.ts +43 -0
- package/src/features/sections/section-validation.js +97 -0
- package/src/features/settings/attached-template.d.ts +35 -0
- package/src/features/settings/attached-template.js +98 -0
- package/src/features/settings/compat-settings.d.ts +216 -0
- package/src/features/settings/compat-settings.js +508 -0
- package/src/features/settings/document-background.d.ts +59 -0
- package/src/features/settings/document-background.js +131 -0
- package/src/features/settings/document-protection.d.ts +65 -0
- package/src/features/settings/document-protection.js +157 -0
- package/src/features/settings/document-settings-facades.d.ts +108 -0
- package/src/features/settings/document-settings-facades.js +312 -0
- package/src/features/settings/document-settings-values.d.ts +43 -0
- package/src/features/settings/document-settings-values.js +60 -0
- package/src/features/settings/footnote-properties.d.ts +211 -0
- package/src/features/settings/footnote-properties.js +591 -0
- package/src/features/settings/index.d.ts +356 -0
- package/src/features/settings/index.js +829 -0
- package/src/features/settings/settings-children.d.ts +151 -0
- package/src/features/settings/settings-children.js +505 -0
- package/src/features/settings/web-settings.d.ts +88 -0
- package/src/features/settings/web-settings.js +227 -0
- package/src/features/settings/zoom.d.ts +79 -0
- package/src/features/settings/zoom.js +147 -0
- package/src/features/styles/builtin-catalog.d.ts +159 -0
- package/src/features/styles/builtin-catalog.js +963 -0
- package/src/features/styles/builtin-resolver.d.ts +49 -0
- package/src/features/styles/builtin-resolver.js +165 -0
- package/src/features/styles/default-styles.d.ts +37 -0
- package/src/features/styles/default-styles.js +186 -0
- package/src/features/styles/default-theme.d.ts +13 -0
- package/src/features/styles/default-theme.js +13 -0
- package/src/features/styles/doc-defaults.d.ts +58 -0
- package/src/features/styles/doc-defaults.js +178 -0
- package/src/features/styles/formatting-resolver.d.ts +27 -0
- package/src/features/styles/formatting-resolver.js +72 -0
- package/src/features/styles/index.d.ts +256 -0
- package/src/features/styles/index.js +1325 -0
- package/src/features/styles/latent-styles.d.ts +68 -0
- package/src/features/styles/latent-styles.js +305 -0
- package/src/features/styles/paragraph-properties.d.ts +71 -0
- package/src/features/styles/paragraph-properties.js +237 -0
- package/src/features/styles/run-properties.d.ts +93 -0
- package/src/features/styles/run-properties.js +516 -0
- package/src/features/styles/style-base.d.ts +402 -0
- package/src/features/styles/style-base.js +1026 -0
- package/src/features/styles/style-collection.d.ts +264 -0
- package/src/features/styles/style-collection.js +714 -0
- package/src/features/styles/style-format-bridge.d.ts +64 -0
- package/src/features/styles/style-format-bridge.js +100 -0
- package/src/features/styles/style.d.ts +84 -0
- package/src/features/styles/style.js +375 -0
- package/src/features/styles/styles-with-effects.d.ts +71 -0
- package/src/features/styles/styles-with-effects.js +180 -0
- package/src/features/styles/table-style.d.ts +272 -0
- package/src/features/styles/table-style.js +1226 -0
- package/src/features/styles/theme.d.ts +126 -0
- package/src/features/styles/theme.js +377 -0
- package/src/features/tables/border-style-map.d.ts +24 -0
- package/src/features/tables/border-style-map.js +81 -0
- package/src/features/tables/borders.d.ts +126 -0
- package/src/features/tables/borders.js +527 -0
- package/src/features/tables/collections.d.ts +113 -0
- package/src/features/tables/collections.js +261 -0
- package/src/features/tables/format.d.ts +208 -0
- package/src/features/tables/format.js +716 -0
- package/src/features/tables/index.d.ts +597 -0
- package/src/features/tables/index.js +2386 -0
- package/src/features/tables/paddings.d.ts +41 -0
- package/src/features/tables/paddings.js +97 -0
- package/src/features/tables/tbl-pr-positioning.d.ts +27 -0
- package/src/features/tables/tbl-pr-positioning.js +178 -0
- package/src/features/tables/tbl-pr.d.ts +528 -0
- package/src/features/tables/tbl-pr.js +1208 -0
- package/src/features/tables/tc-pr.d.ts +168 -0
- package/src/features/tables/tc-pr.js +553 -0
- package/src/features/tables/tr-pr.d.ts +60 -0
- package/src/features/tables/tr-pr.js +215 -0
- package/src/features/watermark/detect.d.ts +76 -0
- package/src/features/watermark/detect.js +219 -0
- package/src/features/watermark/index.d.ts +28 -0
- package/src/features/watermark/index.js +91 -0
- package/src/features/watermark/logical-store.d.ts +29 -0
- package/src/features/watermark/logical-store.js +31 -0
- package/src/features/watermark/model.d.ts +285 -0
- package/src/features/watermark/model.js +597 -0
- package/src/features/watermark/parse.d.ts +84 -0
- package/src/features/watermark/parse.js +815 -0
- package/src/features/watermark/serialize.d.ts +98 -0
- package/src/features/watermark/serialize.js +1517 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
|
@@ -0,0 +1,1084 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom list styles: ListStyle / ListLevel facades over numbering abstracts + styles.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
import { DocxError, InvalidArgumentError } from '../../core/errors/docx-error';
|
|
7
|
+
import { WordDocument } from '../document/document';
|
|
8
|
+
import { CharacterFormat, parseCharacterFormat, } from '../document/character-format';
|
|
9
|
+
import { emptyParagraphFormatSnapshot, ParagraphFormat, } from '../document/paragraph-format';
|
|
10
|
+
import { pointToTwips, twipsToPoint } from '../document/length';
|
|
11
|
+
import { elementChildren, isWml, wmlAttr, wmlElement, wValAttribute } from '../document/wml';
|
|
12
|
+
import { createDefaultAbstractNumbering } from './abstract-numbering';
|
|
13
|
+
import { numberingFor } from './index';
|
|
14
|
+
import { characterSnapshotFromRPr, paragraphSnapshotFromPPr, } from '../styles/style-format-bridge';
|
|
15
|
+
import { DocxStyle } from '../styles/style';
|
|
16
|
+
import { styleCollectionFor } from '../styles/index';
|
|
17
|
+
function numberingCatalog(document) {
|
|
18
|
+
return numberingFor(document);
|
|
19
|
+
}
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Enums
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* High-level list category for {@link WordDocument.addListStyle}.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export var ListType;
|
|
29
|
+
(function (ListType) {
|
|
30
|
+
ListType["Bulleted"] = "bulleted";
|
|
31
|
+
ListType["Numbered"] = "numbered";
|
|
32
|
+
})(ListType || (ListType = {}));
|
|
33
|
+
/**
|
|
34
|
+
* Number / bullet pattern for a list level (`w:numFmt`).
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export var ListPatternType;
|
|
39
|
+
(function (ListPatternType) {
|
|
40
|
+
ListPatternType["Arabic"] = "arabic";
|
|
41
|
+
ListPatternType["LeadingZero"] = "leadingZero";
|
|
42
|
+
ListPatternType["Letter"] = "letter";
|
|
43
|
+
ListPatternType["LetterLow"] = "letterLow";
|
|
44
|
+
ListPatternType["Roman"] = "roman";
|
|
45
|
+
ListPatternType["RomanLow"] = "romanLow";
|
|
46
|
+
ListPatternType["Ordinal"] = "ordinal";
|
|
47
|
+
ListPatternType["OrdinalText"] = "ordinalText";
|
|
48
|
+
ListPatternType["CardinalText"] = "cardinalText";
|
|
49
|
+
ListPatternType["Bullet"] = "bullet";
|
|
50
|
+
ListPatternType["NoNumber"] = "noNumber";
|
|
51
|
+
ListPatternType["FarEast"] = "farEast";
|
|
52
|
+
ListPatternType["Special"] = "special";
|
|
53
|
+
ListPatternType["Hebrew1"] = "hebrew1";
|
|
54
|
+
ListPatternType["Hebrew2"] = "hebrew2";
|
|
55
|
+
ListPatternType["HindiArabic"] = "hindiArabic";
|
|
56
|
+
ListPatternType["HindiCardinalText"] = "hindiCardinalText";
|
|
57
|
+
ListPatternType["HindiLetter1"] = "hindiLetter1";
|
|
58
|
+
ListPatternType["HindiLetter2"] = "hindiLetter2";
|
|
59
|
+
ListPatternType["ChineseCounting"] = "chineseCounting";
|
|
60
|
+
ListPatternType["ChineseCountingThousand"] = "chineseCountingThousand";
|
|
61
|
+
ListPatternType["ChineseLegalSimplified"] = "chineseLegalSimplified";
|
|
62
|
+
ListPatternType["JapaneseCounting"] = "japaneseCounting";
|
|
63
|
+
ListPatternType["JapaneseDigitalTenThousand"] = "japaneseDigitalTenThousand";
|
|
64
|
+
ListPatternType["JapaneseLegal"] = "japaneseLegal";
|
|
65
|
+
ListPatternType["KoreanCounting"] = "koreanCounting";
|
|
66
|
+
ListPatternType["KoreanDigital"] = "koreanDigital";
|
|
67
|
+
ListPatternType["KoreanDigital2"] = "koreanDigital2";
|
|
68
|
+
ListPatternType["KoreanLegal"] = "koreanLegal";
|
|
69
|
+
ListPatternType["Aiueo"] = "aiueo";
|
|
70
|
+
ListPatternType["AiueoFullWidth"] = "aiueoFullWidth";
|
|
71
|
+
ListPatternType["Iroha"] = "iroha";
|
|
72
|
+
ListPatternType["IrohaFullWidth"] = "irohaFullWidth";
|
|
73
|
+
ListPatternType["Ganada"] = "ganada";
|
|
74
|
+
ListPatternType["Chosung"] = "chosung";
|
|
75
|
+
ListPatternType["DecimalEnclosedCircle"] = "decimalEnclosedCircle";
|
|
76
|
+
ListPatternType["DecimalFullWidth"] = "decimalFullWidth";
|
|
77
|
+
ListPatternType["DecimalHalfWidth"] = "decimalHalfWidth";
|
|
78
|
+
ListPatternType["DecimalEnclosedFullstop"] = "decimalEnclosedFullstop";
|
|
79
|
+
ListPatternType["DecimalEnclosedParen"] = "decimalEnclosedParen";
|
|
80
|
+
ListPatternType["DecimalEnclosedCircleChinese"] = "decimalEnclosedCircleChinese";
|
|
81
|
+
ListPatternType["IdeographEnclosedCircle"] = "ideographEnclosedCircle";
|
|
82
|
+
ListPatternType["IdeographTraditional"] = "ideographTraditional";
|
|
83
|
+
ListPatternType["IdeographZodiac"] = "ideographZodiac";
|
|
84
|
+
ListPatternType["IdeographZodiacTraditional"] = "ideographZodiacTraditional";
|
|
85
|
+
ListPatternType["TaiwaneseCounting"] = "taiwaneseCounting";
|
|
86
|
+
ListPatternType["TaiwaneseCountingThousand"] = "taiwaneseCountingThousand";
|
|
87
|
+
ListPatternType["TaiwaneseDigital"] = "taiwaneseDigital";
|
|
88
|
+
ListPatternType["None"] = "none";
|
|
89
|
+
ListPatternType["Custom"] = "custom";
|
|
90
|
+
})(ListPatternType || (ListPatternType = {}));
|
|
91
|
+
/**
|
|
92
|
+
* Character inserted after the list label (`w:suff`).
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export var FollowCharacterType;
|
|
97
|
+
(function (FollowCharacterType) {
|
|
98
|
+
FollowCharacterType["Tab"] = "tab";
|
|
99
|
+
FollowCharacterType["Space"] = "space";
|
|
100
|
+
FollowCharacterType["Nothing"] = "nothing";
|
|
101
|
+
})(FollowCharacterType || (FollowCharacterType = {}));
|
|
102
|
+
/**
|
|
103
|
+
* Horizontal alignment of the list number (`w:lvlJc`).
|
|
104
|
+
*
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export var ListNumberAlignment;
|
|
108
|
+
(function (ListNumberAlignment) {
|
|
109
|
+
ListNumberAlignment["Left"] = "left";
|
|
110
|
+
ListNumberAlignment["Center"] = "center";
|
|
111
|
+
ListNumberAlignment["Right"] = "right";
|
|
112
|
+
})(ListNumberAlignment || (ListNumberAlignment = {}));
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// Pattern / wire maps
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
var PATTERN_TO_NUMFMT = {
|
|
117
|
+
arabic: 'decimal',
|
|
118
|
+
leadingZero: 'decimalZero',
|
|
119
|
+
letter: 'upperLetter',
|
|
120
|
+
letterLow: 'lowerLetter',
|
|
121
|
+
roman: 'upperRoman',
|
|
122
|
+
romanLow: 'lowerRoman',
|
|
123
|
+
ordinal: 'ordinal',
|
|
124
|
+
ordinalText: 'ordinalText',
|
|
125
|
+
cardinalText: 'cardinalText',
|
|
126
|
+
bullet: 'bullet',
|
|
127
|
+
noNumber: 'none',
|
|
128
|
+
none: 'none',
|
|
129
|
+
hebrew1: 'hebrew1',
|
|
130
|
+
hebrew2: 'hebrew2',
|
|
131
|
+
hindiArabic: 'hindiNumbers',
|
|
132
|
+
hindiCardinalText: 'hindiCounting',
|
|
133
|
+
hindiLetter1: 'hindiVowels',
|
|
134
|
+
hindiLetter2: 'hindiConsonants',
|
|
135
|
+
chineseCounting: 'chineseCounting',
|
|
136
|
+
chineseCountingThousand: 'chineseCountingThousand',
|
|
137
|
+
chineseLegalSimplified: 'chineseLegalSimplified',
|
|
138
|
+
japaneseCounting: 'japaneseCounting',
|
|
139
|
+
japaneseDigitalTenThousand: 'japaneseDigitalTenThousand',
|
|
140
|
+
japaneseLegal: 'japaneseLegal',
|
|
141
|
+
koreanCounting: 'koreanCounting',
|
|
142
|
+
koreanDigital: 'koreanDigital',
|
|
143
|
+
koreanDigital2: 'koreanDigital2',
|
|
144
|
+
koreanLegal: 'koreanLegal',
|
|
145
|
+
aiueo: 'aiueo',
|
|
146
|
+
aiueoFullWidth: 'aiueoFullWidth',
|
|
147
|
+
iroha: 'iroha',
|
|
148
|
+
irohaFullWidth: 'irohaFullWidth',
|
|
149
|
+
ganada: 'ganada',
|
|
150
|
+
chosung: 'chosung',
|
|
151
|
+
decimalEnclosedCircle: 'decimalEnclosedCircle',
|
|
152
|
+
decimalFullWidth: 'decimalFullWidth',
|
|
153
|
+
decimalHalfWidth: 'decimalHalfWidth',
|
|
154
|
+
decimalEnclosedFullstop: 'decimalEnclosedFullstop',
|
|
155
|
+
decimalEnclosedParen: 'decimalEnclosedParen',
|
|
156
|
+
decimalEnclosedCircleChinese: 'decimalEnclosedCircleChinese',
|
|
157
|
+
ideographEnclosedCircle: 'ideographEnclosedCircle',
|
|
158
|
+
ideographTraditional: 'ideographTraditional',
|
|
159
|
+
ideographZodiac: 'ideographZodiac',
|
|
160
|
+
ideographZodiacTraditional: 'ideographZodiacTraditional',
|
|
161
|
+
taiwaneseCounting: 'taiwaneseCounting',
|
|
162
|
+
taiwaneseCountingThousand: 'taiwaneseCountingThousand',
|
|
163
|
+
taiwaneseDigital: 'taiwaneseDigital',
|
|
164
|
+
farEast: 'ideographTraditional',
|
|
165
|
+
special: 'bullet',
|
|
166
|
+
custom: 'decimal',
|
|
167
|
+
};
|
|
168
|
+
var NUMFMT_TO_PATTERN = {
|
|
169
|
+
decimal: ListPatternType.Arabic,
|
|
170
|
+
decimalZero: ListPatternType.LeadingZero,
|
|
171
|
+
upperLetter: ListPatternType.Letter,
|
|
172
|
+
lowerLetter: ListPatternType.LetterLow,
|
|
173
|
+
upperRoman: ListPatternType.Roman,
|
|
174
|
+
lowerRoman: ListPatternType.RomanLow,
|
|
175
|
+
ordinal: ListPatternType.Ordinal,
|
|
176
|
+
ordinalText: ListPatternType.OrdinalText,
|
|
177
|
+
cardinalText: ListPatternType.CardinalText,
|
|
178
|
+
bullet: ListPatternType.Bullet,
|
|
179
|
+
none: ListPatternType.None,
|
|
180
|
+
hebrew1: ListPatternType.Hebrew1,
|
|
181
|
+
hebrew2: ListPatternType.Hebrew2,
|
|
182
|
+
hindiNumbers: ListPatternType.HindiArabic,
|
|
183
|
+
hindiCounting: ListPatternType.HindiCardinalText,
|
|
184
|
+
hindiVowels: ListPatternType.HindiLetter1,
|
|
185
|
+
hindiConsonants: ListPatternType.HindiLetter2,
|
|
186
|
+
chineseCounting: ListPatternType.ChineseCounting,
|
|
187
|
+
chineseCountingThousand: ListPatternType.ChineseCountingThousand,
|
|
188
|
+
chineseLegalSimplified: ListPatternType.ChineseLegalSimplified,
|
|
189
|
+
japaneseCounting: ListPatternType.JapaneseCounting,
|
|
190
|
+
japaneseDigitalTenThousand: ListPatternType.JapaneseDigitalTenThousand,
|
|
191
|
+
japaneseLegal: ListPatternType.JapaneseLegal,
|
|
192
|
+
koreanCounting: ListPatternType.KoreanCounting,
|
|
193
|
+
koreanDigital: ListPatternType.KoreanDigital,
|
|
194
|
+
koreanDigital2: ListPatternType.KoreanDigital2,
|
|
195
|
+
koreanLegal: ListPatternType.KoreanLegal,
|
|
196
|
+
aiueo: ListPatternType.Aiueo,
|
|
197
|
+
aiueoFullWidth: ListPatternType.AiueoFullWidth,
|
|
198
|
+
iroha: ListPatternType.Iroha,
|
|
199
|
+
irohaFullWidth: ListPatternType.IrohaFullWidth,
|
|
200
|
+
ganada: ListPatternType.Ganada,
|
|
201
|
+
chosung: ListPatternType.Chosung,
|
|
202
|
+
decimalEnclosedCircle: ListPatternType.DecimalEnclosedCircle,
|
|
203
|
+
decimalFullWidth: ListPatternType.DecimalFullWidth,
|
|
204
|
+
decimalHalfWidth: ListPatternType.DecimalHalfWidth,
|
|
205
|
+
decimalEnclosedFullstop: ListPatternType.DecimalEnclosedFullstop,
|
|
206
|
+
decimalEnclosedParen: ListPatternType.DecimalEnclosedParen,
|
|
207
|
+
decimalEnclosedCircleChinese: ListPatternType.DecimalEnclosedCircleChinese,
|
|
208
|
+
ideographEnclosedCircle: ListPatternType.IdeographEnclosedCircle,
|
|
209
|
+
ideographTraditional: ListPatternType.IdeographTraditional,
|
|
210
|
+
ideographZodiac: ListPatternType.IdeographZodiac,
|
|
211
|
+
ideographZodiacTraditional: ListPatternType.IdeographZodiacTraditional,
|
|
212
|
+
taiwaneseCounting: ListPatternType.TaiwaneseCounting,
|
|
213
|
+
taiwaneseCountingThousand: ListPatternType.TaiwaneseCountingThousand,
|
|
214
|
+
taiwaneseDigital: ListPatternType.TaiwaneseDigital,
|
|
215
|
+
};
|
|
216
|
+
function patternToNumFmt(pattern) {
|
|
217
|
+
var mapped = PATTERN_TO_NUMFMT[pattern];
|
|
218
|
+
if (mapped !== undefined) {
|
|
219
|
+
return mapped;
|
|
220
|
+
}
|
|
221
|
+
return 'decimal';
|
|
222
|
+
}
|
|
223
|
+
function numFmtToPattern(numFmt) {
|
|
224
|
+
if (numFmt === undefined || numFmt.length === 0) {
|
|
225
|
+
return ListPatternType.Arabic;
|
|
226
|
+
}
|
|
227
|
+
var mapped = NUMFMT_TO_PATTERN[numFmt];
|
|
228
|
+
if (mapped !== undefined) {
|
|
229
|
+
return mapped;
|
|
230
|
+
}
|
|
231
|
+
return ListPatternType.Custom;
|
|
232
|
+
}
|
|
233
|
+
function isListType(value) {
|
|
234
|
+
return value === ListType.Bulleted || value === ListType.Numbered;
|
|
235
|
+
}
|
|
236
|
+
function isListPatternType(value) {
|
|
237
|
+
for (var key in ListPatternType) {
|
|
238
|
+
if (!Object.prototype.hasOwnProperty.call(ListPatternType, key)) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (ListPatternType[key] === value) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
function isFollowCharacterType(value) {
|
|
248
|
+
return (value === FollowCharacterType.Tab ||
|
|
249
|
+
value === FollowCharacterType.Space ||
|
|
250
|
+
value === FollowCharacterType.Nothing);
|
|
251
|
+
}
|
|
252
|
+
function isListNumberAlignment(value) {
|
|
253
|
+
return (value === ListNumberAlignment.Left ||
|
|
254
|
+
value === ListNumberAlignment.Center ||
|
|
255
|
+
value === ListNumberAlignment.Right);
|
|
256
|
+
}
|
|
257
|
+
function assertFiniteNumber(name, value) {
|
|
258
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
259
|
+
throw new InvalidArgumentError(name + ' must be a finite number');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function assertNonNegativePoints(name, value) {
|
|
263
|
+
assertFiniteNumber(name, value);
|
|
264
|
+
if (value < 0) {
|
|
265
|
+
throw new InvalidArgumentError(name + ' must be a non-negative number of points');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function twipAttr(el, localName) {
|
|
269
|
+
if (el === undefined) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
for (var i = 0; i < el.attributes.length; i += 1) {
|
|
273
|
+
var attr = el.attributes[i];
|
|
274
|
+
if (attr !== undefined && attr.localName === localName) {
|
|
275
|
+
var n = parseInt(attr.value, 10);
|
|
276
|
+
if (Number.isFinite(n)) {
|
|
277
|
+
return n;
|
|
278
|
+
}
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
function setTwipAttr(el, localName, twips) {
|
|
285
|
+
var attrs = el.attributes.slice();
|
|
286
|
+
var found = false;
|
|
287
|
+
for (var i = 0; i < attrs.length; i += 1) {
|
|
288
|
+
var attr = attrs[i];
|
|
289
|
+
if (attr !== undefined && attr.localName === localName) {
|
|
290
|
+
attrs[i] = wmlAttr(localName, String(twips));
|
|
291
|
+
found = true;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (!found) {
|
|
296
|
+
attrs.push(wmlAttr(localName, String(twips)));
|
|
297
|
+
}
|
|
298
|
+
return wmlElement(el.localName, {
|
|
299
|
+
attributes: attrs,
|
|
300
|
+
children: el.children.slice(),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function ensureIndInPPr(pPr) {
|
|
304
|
+
if (pPr === undefined) {
|
|
305
|
+
return wmlElement('pPr', {
|
|
306
|
+
children: [wmlElement('ind', { attributes: [] })],
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
var kids = elementChildren(pPr).slice();
|
|
310
|
+
var hasInd = false;
|
|
311
|
+
for (var i = 0; i < kids.length; i += 1) {
|
|
312
|
+
if (isWml(kids[i], 'ind')) {
|
|
313
|
+
hasInd = true;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (!hasInd) {
|
|
318
|
+
kids.push(wmlElement('ind', { attributes: [] }));
|
|
319
|
+
}
|
|
320
|
+
return wmlElement('pPr', {
|
|
321
|
+
attributes: pPr.attributes.slice(),
|
|
322
|
+
children: kids,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
function findInd(pPr) {
|
|
326
|
+
if (pPr === undefined) {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
var kids = elementChildren(pPr);
|
|
330
|
+
for (var i = 0; i < kids.length; i += 1) {
|
|
331
|
+
if (isWml(kids[i], 'ind')) {
|
|
332
|
+
return kids[i];
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
function replaceInd(pPr, ind) {
|
|
338
|
+
var kids = elementChildren(pPr).slice();
|
|
339
|
+
var replaced = false;
|
|
340
|
+
for (var i = 0; i < kids.length; i += 1) {
|
|
341
|
+
if (isWml(kids[i], 'ind')) {
|
|
342
|
+
kids[i] = ind;
|
|
343
|
+
replaced = true;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (!replaced) {
|
|
348
|
+
kids.push(ind);
|
|
349
|
+
}
|
|
350
|
+
return wmlElement('pPr', {
|
|
351
|
+
attributes: pPr.attributes.slice(),
|
|
352
|
+
children: kids,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Split `w:lvlText` around this level's own token (`%(ilvl+1)`).
|
|
357
|
+
* Nested prior-level tokens (`%1` in level 2's `%1.%2.%3.`) belong in the prefix.
|
|
358
|
+
* When `levelNumber` is omitted, falls back to the first `%n` (legacy).
|
|
359
|
+
*/
|
|
360
|
+
function splitLevelText(lvlText, levelNumber) {
|
|
361
|
+
if (lvlText === undefined || lvlText.length === 0) {
|
|
362
|
+
return { prefix: '', body: '', suffix: '' };
|
|
363
|
+
}
|
|
364
|
+
var match = null;
|
|
365
|
+
if (levelNumber !== undefined && levelNumber >= 0 && levelNumber <= 8) {
|
|
366
|
+
var token = '%' + String(levelNumber + 1);
|
|
367
|
+
var idx = lvlText.indexOf(token);
|
|
368
|
+
if (idx >= 0) {
|
|
369
|
+
return {
|
|
370
|
+
prefix: lvlText.substring(0, idx),
|
|
371
|
+
body: token,
|
|
372
|
+
suffix: lvlText.substring(idx + token.length),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
match = /%([1-9])/.exec(lvlText);
|
|
377
|
+
if (match === null || match.index === undefined) {
|
|
378
|
+
return { prefix: '', body: lvlText, suffix: '' };
|
|
379
|
+
}
|
|
380
|
+
var start = match.index;
|
|
381
|
+
var end = start + match[0].length;
|
|
382
|
+
return {
|
|
383
|
+
prefix: lvlText.substring(0, start),
|
|
384
|
+
body: lvlText.substring(start, end),
|
|
385
|
+
suffix: lvlText.substring(end),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function rebuildLevelText(prefix, body, suffix) {
|
|
389
|
+
return prefix + body + suffix;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* DocIO encodes prior-level placeholders in `NumberPrefix`/`NumberSuffix` as
|
|
393
|
+
* U+0000..U+0008 (level 0..8). OOXML `w:lvlText` uses `%1`..`%9`. Raw NULs are
|
|
394
|
+
* illegal in XML 1.0 attributes and corrupt the package — convert both ways.
|
|
395
|
+
*/
|
|
396
|
+
function docioLevelPlaceholdersToOoxml(value) {
|
|
397
|
+
var result = '';
|
|
398
|
+
for (var i = 0; i < value.length; i++) {
|
|
399
|
+
var code = value.charCodeAt(i);
|
|
400
|
+
if (code >= 0 && code <= 8) {
|
|
401
|
+
result += '%' + String(code + 1);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
result += value.charAt(i);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
function ooxmlLevelPlaceholdersToDocio(value) {
|
|
410
|
+
var result = '';
|
|
411
|
+
var i = 0;
|
|
412
|
+
while (i < value.length) {
|
|
413
|
+
if (value.charAt(i) === '%' && i + 1 < value.length) {
|
|
414
|
+
var digit = value.charAt(i + 1);
|
|
415
|
+
if (digit >= '1' && digit <= '9') {
|
|
416
|
+
result += String.fromCharCode(digit.charCodeAt(0) - '1'.charCodeAt(0));
|
|
417
|
+
i += 2;
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
result += value.charAt(i);
|
|
422
|
+
i += 1;
|
|
423
|
+
}
|
|
424
|
+
return result;
|
|
425
|
+
}
|
|
426
|
+
// ---------------------------------------------------------------------------
|
|
427
|
+
// ListLevel
|
|
428
|
+
// ---------------------------------------------------------------------------
|
|
429
|
+
/**
|
|
430
|
+
* Live list level facade over a {@link NumberingLevel}.
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
*/
|
|
434
|
+
var ListLevel = /** @class */ (function () {
|
|
435
|
+
/**
|
|
436
|
+
* @private
|
|
437
|
+
*/
|
|
438
|
+
function ListLevel(owner, level) {
|
|
439
|
+
this.owner = owner;
|
|
440
|
+
this.level = level;
|
|
441
|
+
this.suppressDirty = false;
|
|
442
|
+
this.characterFormatValue = new CharacterFormat(this);
|
|
443
|
+
this.paragraphFormatValue = new ParagraphFormat(this);
|
|
444
|
+
this.hydrateFormatsFromLevel();
|
|
445
|
+
}
|
|
446
|
+
Object.defineProperty(ListLevel.prototype, "listStyle", {
|
|
447
|
+
/** Owning list style. */
|
|
448
|
+
get: function () {
|
|
449
|
+
return this.owner;
|
|
450
|
+
},
|
|
451
|
+
enumerable: true,
|
|
452
|
+
configurable: true
|
|
453
|
+
});
|
|
454
|
+
Object.defineProperty(ListLevel.prototype, "levelNumber", {
|
|
455
|
+
/** Zero-based level index. */
|
|
456
|
+
get: function () {
|
|
457
|
+
return this.level.ilvl;
|
|
458
|
+
},
|
|
459
|
+
enumerable: true,
|
|
460
|
+
configurable: true
|
|
461
|
+
});
|
|
462
|
+
Object.defineProperty(ListLevel.prototype, "patternType", {
|
|
463
|
+
get: function () {
|
|
464
|
+
return numFmtToPattern(this.level.numFmt);
|
|
465
|
+
},
|
|
466
|
+
set: function (value) {
|
|
467
|
+
if (typeof value !== 'string' || !isListPatternType(value)) {
|
|
468
|
+
throw new InvalidArgumentError('patternType must be a ListPatternType value');
|
|
469
|
+
}
|
|
470
|
+
this.level.setNumFmt(patternToNumFmt(value));
|
|
471
|
+
if (value === ListPatternType.Bullet) {
|
|
472
|
+
var text = this.level.lvlText;
|
|
473
|
+
if (text === undefined || text.indexOf('%') >= 0) {
|
|
474
|
+
this.level.setLvlText('\uf0b7');
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
else if (value !== ListPatternType.NoNumber && value !== ListPatternType.None) {
|
|
478
|
+
var parts = splitLevelText(this.level.lvlText, this.level.ilvl);
|
|
479
|
+
if (parts.body.length === 0 || parts.body.indexOf('%') < 0) {
|
|
480
|
+
var token = '%' + String(this.level.ilvl + 1);
|
|
481
|
+
this.level.setLvlText(rebuildLevelText(parts.prefix, token, parts.suffix.length > 0 ? parts.suffix : '.'));
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
this.markDirty();
|
|
485
|
+
},
|
|
486
|
+
enumerable: true,
|
|
487
|
+
configurable: true
|
|
488
|
+
});
|
|
489
|
+
Object.defineProperty(ListLevel.prototype, "startAt", {
|
|
490
|
+
get: function () {
|
|
491
|
+
var s = this.level.start;
|
|
492
|
+
return s !== undefined ? s : 1;
|
|
493
|
+
},
|
|
494
|
+
set: function (value) {
|
|
495
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || Math.floor(value) !== value || value < 0) {
|
|
496
|
+
throw new InvalidArgumentError('startAt must be a non-negative integer');
|
|
497
|
+
}
|
|
498
|
+
this.level.setStart(value);
|
|
499
|
+
this.markDirty();
|
|
500
|
+
},
|
|
501
|
+
enumerable: true,
|
|
502
|
+
configurable: true
|
|
503
|
+
});
|
|
504
|
+
Object.defineProperty(ListLevel.prototype, "levelText", {
|
|
505
|
+
get: function () {
|
|
506
|
+
var t = this.level.lvlText;
|
|
507
|
+
return t !== undefined ? t : '';
|
|
508
|
+
},
|
|
509
|
+
set: function (value) {
|
|
510
|
+
if (typeof value !== 'string') {
|
|
511
|
+
throw new InvalidArgumentError('levelText must be a string');
|
|
512
|
+
}
|
|
513
|
+
this.level.setLvlText(value);
|
|
514
|
+
this.markDirty();
|
|
515
|
+
},
|
|
516
|
+
enumerable: true,
|
|
517
|
+
configurable: true
|
|
518
|
+
});
|
|
519
|
+
Object.defineProperty(ListLevel.prototype, "numberPrefix", {
|
|
520
|
+
get: function () {
|
|
521
|
+
return ooxmlLevelPlaceholdersToDocio(splitLevelText(this.level.lvlText, this.level.ilvl).prefix);
|
|
522
|
+
},
|
|
523
|
+
set: function (value) {
|
|
524
|
+
if (typeof value !== 'string') {
|
|
525
|
+
throw new InvalidArgumentError('numberPrefix must be a string');
|
|
526
|
+
}
|
|
527
|
+
var parts = splitLevelText(this.level.lvlText, this.level.ilvl);
|
|
528
|
+
var body = parts.body;
|
|
529
|
+
if (body.length === 0 || body.indexOf('%') < 0) {
|
|
530
|
+
body = this.level.numFmt === 'bullet' ? '\uf0b7' : '%' + String(this.level.ilvl + 1);
|
|
531
|
+
}
|
|
532
|
+
var prefix = docioLevelPlaceholdersToOoxml(value);
|
|
533
|
+
this.level.setLvlText(rebuildLevelText(prefix, body, parts.suffix));
|
|
534
|
+
this.markDirty();
|
|
535
|
+
},
|
|
536
|
+
enumerable: true,
|
|
537
|
+
configurable: true
|
|
538
|
+
});
|
|
539
|
+
Object.defineProperty(ListLevel.prototype, "numberSuffix", {
|
|
540
|
+
get: function () {
|
|
541
|
+
return ooxmlLevelPlaceholdersToDocio(splitLevelText(this.level.lvlText, this.level.ilvl).suffix);
|
|
542
|
+
},
|
|
543
|
+
set: function (value) {
|
|
544
|
+
if (typeof value !== 'string') {
|
|
545
|
+
throw new InvalidArgumentError('numberSuffix must be a string');
|
|
546
|
+
}
|
|
547
|
+
var parts = splitLevelText(this.level.lvlText, this.level.ilvl);
|
|
548
|
+
var body = parts.body;
|
|
549
|
+
if (body.length === 0 || body.indexOf('%') < 0) {
|
|
550
|
+
body = this.level.numFmt === 'bullet' ? '\uf0b7' : '%' + String(this.level.ilvl + 1);
|
|
551
|
+
}
|
|
552
|
+
var suffix = docioLevelPlaceholdersToOoxml(value);
|
|
553
|
+
this.level.setLvlText(rebuildLevelText(parts.prefix, body, suffix));
|
|
554
|
+
this.markDirty();
|
|
555
|
+
},
|
|
556
|
+
enumerable: true,
|
|
557
|
+
configurable: true
|
|
558
|
+
});
|
|
559
|
+
Object.defineProperty(ListLevel.prototype, "bulletCharacter", {
|
|
560
|
+
get: function () {
|
|
561
|
+
if (this.level.numFmt !== 'bullet') {
|
|
562
|
+
return '';
|
|
563
|
+
}
|
|
564
|
+
var t = this.level.lvlText;
|
|
565
|
+
return t !== undefined ? t : '';
|
|
566
|
+
},
|
|
567
|
+
set: function (value) {
|
|
568
|
+
if (typeof value !== 'string') {
|
|
569
|
+
throw new InvalidArgumentError('bulletCharacter must be a string');
|
|
570
|
+
}
|
|
571
|
+
this.level.setNumFmt('bullet');
|
|
572
|
+
this.level.setLvlText(value);
|
|
573
|
+
this.markDirty();
|
|
574
|
+
},
|
|
575
|
+
enumerable: true,
|
|
576
|
+
configurable: true
|
|
577
|
+
});
|
|
578
|
+
Object.defineProperty(ListLevel.prototype, "followCharacter", {
|
|
579
|
+
get: function () {
|
|
580
|
+
var suff = this.level.findExtra('suff');
|
|
581
|
+
var val = suff !== undefined ? wValAttribute(suff) : undefined;
|
|
582
|
+
if (val === 'space') {
|
|
583
|
+
return FollowCharacterType.Space;
|
|
584
|
+
}
|
|
585
|
+
if (val === 'nothing') {
|
|
586
|
+
return FollowCharacterType.Nothing;
|
|
587
|
+
}
|
|
588
|
+
return FollowCharacterType.Tab;
|
|
589
|
+
},
|
|
590
|
+
set: function (value) {
|
|
591
|
+
if (typeof value !== 'string' || !isFollowCharacterType(value)) {
|
|
592
|
+
throw new InvalidArgumentError('followCharacter must be a FollowCharacterType value');
|
|
593
|
+
}
|
|
594
|
+
var wire = 'tab';
|
|
595
|
+
if (value === FollowCharacterType.Space) {
|
|
596
|
+
wire = 'space';
|
|
597
|
+
}
|
|
598
|
+
else if (value === FollowCharacterType.Nothing) {
|
|
599
|
+
wire = 'nothing';
|
|
600
|
+
}
|
|
601
|
+
this.level.setExtraElement('suff', wmlElement('suff', { attributes: [wmlAttr('val', wire)] }));
|
|
602
|
+
this.markDirty();
|
|
603
|
+
},
|
|
604
|
+
enumerable: true,
|
|
605
|
+
configurable: true
|
|
606
|
+
});
|
|
607
|
+
Object.defineProperty(ListLevel.prototype, "numberAlignment", {
|
|
608
|
+
get: function () {
|
|
609
|
+
var jc = this.level.lvlJc;
|
|
610
|
+
if (jc === 'center') {
|
|
611
|
+
return ListNumberAlignment.Center;
|
|
612
|
+
}
|
|
613
|
+
if (jc === 'right') {
|
|
614
|
+
return ListNumberAlignment.Right;
|
|
615
|
+
}
|
|
616
|
+
return ListNumberAlignment.Left;
|
|
617
|
+
},
|
|
618
|
+
set: function (value) {
|
|
619
|
+
if (typeof value !== 'string' || !isListNumberAlignment(value)) {
|
|
620
|
+
throw new InvalidArgumentError('numberAlignment must be a ListNumberAlignment value');
|
|
621
|
+
}
|
|
622
|
+
this.level.setLvlJc(value);
|
|
623
|
+
this.markDirty();
|
|
624
|
+
},
|
|
625
|
+
enumerable: true,
|
|
626
|
+
configurable: true
|
|
627
|
+
});
|
|
628
|
+
Object.defineProperty(ListLevel.prototype, "tabSpaceAfter", {
|
|
629
|
+
get: function () {
|
|
630
|
+
var pPr = this.level.findExtra('pPr');
|
|
631
|
+
if (pPr === undefined) {
|
|
632
|
+
return 0;
|
|
633
|
+
}
|
|
634
|
+
var tabs = elementChildren(pPr);
|
|
635
|
+
for (var i = 0; i < tabs.length; i += 1) {
|
|
636
|
+
var child = tabs[i];
|
|
637
|
+
if (!isWml(child, 'tabs')) {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
var tabKids = elementChildren(child);
|
|
641
|
+
for (var j = 0; j < tabKids.length; j += 1) {
|
|
642
|
+
var tab = tabKids[j];
|
|
643
|
+
if (!isWml(tab, 'tab')) {
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
var pos = twipAttr(tab, 'pos');
|
|
647
|
+
if (pos !== undefined) {
|
|
648
|
+
return twipsToPoint(pos);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return 0;
|
|
653
|
+
},
|
|
654
|
+
set: function (value) {
|
|
655
|
+
assertNonNegativePoints('tabSpaceAfter', value);
|
|
656
|
+
var twips = pointToTwips(value);
|
|
657
|
+
var pPr = this.level.findExtra('pPr');
|
|
658
|
+
if (pPr === undefined) {
|
|
659
|
+
pPr = wmlElement('pPr', { children: [] });
|
|
660
|
+
}
|
|
661
|
+
var kids = elementChildren(pPr).slice().filter(function (el) { return !isWml(el, 'tabs'); });
|
|
662
|
+
kids.push(wmlElement('tabs', {
|
|
663
|
+
children: [
|
|
664
|
+
wmlElement('tab', {
|
|
665
|
+
attributes: [wmlAttr('val', 'left'), wmlAttr('pos', String(twips))],
|
|
666
|
+
}),
|
|
667
|
+
],
|
|
668
|
+
}));
|
|
669
|
+
this.level.setExtraElement('pPr', wmlElement('pPr', { attributes: pPr.attributes.slice(), children: kids }));
|
|
670
|
+
this.suppressDirty = true;
|
|
671
|
+
try {
|
|
672
|
+
this.paragraphFormatValue.hydrate(paragraphSnapshotFromPPr(this.level.findExtra('pPr')));
|
|
673
|
+
}
|
|
674
|
+
finally {
|
|
675
|
+
this.suppressDirty = false;
|
|
676
|
+
}
|
|
677
|
+
this.markDirty();
|
|
678
|
+
},
|
|
679
|
+
enumerable: true,
|
|
680
|
+
configurable: true
|
|
681
|
+
});
|
|
682
|
+
Object.defineProperty(ListLevel.prototype, "numberPosition", {
|
|
683
|
+
get: function () {
|
|
684
|
+
var ind = findInd(this.level.findExtra('pPr'));
|
|
685
|
+
var left = twipAttr(ind, 'left');
|
|
686
|
+
var hanging = twipAttr(ind, 'hanging');
|
|
687
|
+
if (left === undefined) {
|
|
688
|
+
return 0;
|
|
689
|
+
}
|
|
690
|
+
var hang = hanging !== undefined ? hanging : 0;
|
|
691
|
+
return twipsToPoint(left - hang);
|
|
692
|
+
},
|
|
693
|
+
set: function (value) {
|
|
694
|
+
assertFiniteNumber('numberPosition', value);
|
|
695
|
+
var numberTwips = pointToTwips(value);
|
|
696
|
+
var pPr = ensureIndInPPr(this.level.findExtra('pPr'));
|
|
697
|
+
var ind = findInd(pPr);
|
|
698
|
+
var hanging = twipAttr(ind, 'hanging');
|
|
699
|
+
var hang = hanging !== undefined ? hanging : 0;
|
|
700
|
+
ind = setTwipAttr(ind, 'left', numberTwips + hang);
|
|
701
|
+
pPr = replaceInd(pPr, ind);
|
|
702
|
+
this.level.setExtraElement('pPr', pPr);
|
|
703
|
+
this.suppressDirty = true;
|
|
704
|
+
try {
|
|
705
|
+
this.paragraphFormatValue.hydrate(paragraphSnapshotFromPPr(pPr));
|
|
706
|
+
}
|
|
707
|
+
finally {
|
|
708
|
+
this.suppressDirty = false;
|
|
709
|
+
}
|
|
710
|
+
this.markDirty();
|
|
711
|
+
},
|
|
712
|
+
enumerable: true,
|
|
713
|
+
configurable: true
|
|
714
|
+
});
|
|
715
|
+
Object.defineProperty(ListLevel.prototype, "textPosition", {
|
|
716
|
+
get: function () {
|
|
717
|
+
var ind = findInd(this.level.findExtra('pPr'));
|
|
718
|
+
var left = twipAttr(ind, 'left');
|
|
719
|
+
return left !== undefined ? twipsToPoint(left) : 0;
|
|
720
|
+
},
|
|
721
|
+
set: function (value) {
|
|
722
|
+
assertFiniteNumber('textPosition', value);
|
|
723
|
+
var leftTwips = pointToTwips(value);
|
|
724
|
+
var pPr = ensureIndInPPr(this.level.findExtra('pPr'));
|
|
725
|
+
var ind = findInd(pPr);
|
|
726
|
+
var numberPosTwips = pointToTwips(this.numberPosition);
|
|
727
|
+
var hanging = leftTwips - numberPosTwips;
|
|
728
|
+
if (hanging < 0) {
|
|
729
|
+
hanging = 0;
|
|
730
|
+
}
|
|
731
|
+
ind = setTwipAttr(ind, 'left', leftTwips);
|
|
732
|
+
ind = setTwipAttr(ind, 'hanging', hanging);
|
|
733
|
+
pPr = replaceInd(pPr, ind);
|
|
734
|
+
this.level.setExtraElement('pPr', pPr);
|
|
735
|
+
this.suppressDirty = true;
|
|
736
|
+
try {
|
|
737
|
+
this.paragraphFormatValue.hydrate(paragraphSnapshotFromPPr(pPr));
|
|
738
|
+
}
|
|
739
|
+
finally {
|
|
740
|
+
this.suppressDirty = false;
|
|
741
|
+
}
|
|
742
|
+
this.markDirty();
|
|
743
|
+
},
|
|
744
|
+
enumerable: true,
|
|
745
|
+
configurable: true
|
|
746
|
+
});
|
|
747
|
+
Object.defineProperty(ListLevel.prototype, "restartLevel", {
|
|
748
|
+
get: function () {
|
|
749
|
+
var el = this.level.findExtra('lvlRestart');
|
|
750
|
+
var val = el !== undefined ? wValAttribute(el) : undefined;
|
|
751
|
+
if (val === undefined || !/^\d+$/.test(val)) {
|
|
752
|
+
return this.level.ilvl;
|
|
753
|
+
}
|
|
754
|
+
return parseInt(val, 10);
|
|
755
|
+
},
|
|
756
|
+
set: function (value) {
|
|
757
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || Math.floor(value) !== value || value < 0 || value > 8) {
|
|
758
|
+
throw new InvalidArgumentError('restartLevel must be an integer from 0 through 8');
|
|
759
|
+
}
|
|
760
|
+
this.level.setExtraElement('lvlRestart', wmlElement('lvlRestart', { attributes: [wmlAttr('val', String(value))] }));
|
|
761
|
+
this.markDirty();
|
|
762
|
+
},
|
|
763
|
+
enumerable: true,
|
|
764
|
+
configurable: true
|
|
765
|
+
});
|
|
766
|
+
Object.defineProperty(ListLevel.prototype, "isLegalStyleNumbering", {
|
|
767
|
+
get: function () {
|
|
768
|
+
return this.level.isLgl === true;
|
|
769
|
+
},
|
|
770
|
+
set: function (value) {
|
|
771
|
+
if (typeof value !== 'boolean') {
|
|
772
|
+
throw new InvalidArgumentError('isLegalStyleNumbering must be a boolean');
|
|
773
|
+
}
|
|
774
|
+
this.level.setIsLgl(value ? true : undefined);
|
|
775
|
+
this.markDirty();
|
|
776
|
+
},
|
|
777
|
+
enumerable: true,
|
|
778
|
+
configurable: true
|
|
779
|
+
});
|
|
780
|
+
Object.defineProperty(ListLevel.prototype, "linkedParagraphStyleName", {
|
|
781
|
+
get: function () {
|
|
782
|
+
var el = this.level.findExtra('pStyle');
|
|
783
|
+
var val = el !== undefined ? wValAttribute(el) : undefined;
|
|
784
|
+
return val !== undefined ? val : '';
|
|
785
|
+
},
|
|
786
|
+
set: function (value) {
|
|
787
|
+
if (typeof value !== 'string') {
|
|
788
|
+
throw new InvalidArgumentError('linkedParagraphStyleName must be a string');
|
|
789
|
+
}
|
|
790
|
+
var trimmed = value.trim();
|
|
791
|
+
if (trimmed.length === 0) {
|
|
792
|
+
this.level.setExtraElement('pStyle', undefined);
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
this.level.setExtraElement('pStyle', wmlElement('pStyle', { attributes: [wmlAttr('val', trimmed)] }));
|
|
796
|
+
}
|
|
797
|
+
this.markDirty();
|
|
798
|
+
},
|
|
799
|
+
enumerable: true,
|
|
800
|
+
configurable: true
|
|
801
|
+
});
|
|
802
|
+
Object.defineProperty(ListLevel.prototype, "characterFormat", {
|
|
803
|
+
get: function () {
|
|
804
|
+
return this.characterFormatValue;
|
|
805
|
+
},
|
|
806
|
+
enumerable: true,
|
|
807
|
+
configurable: true
|
|
808
|
+
});
|
|
809
|
+
Object.defineProperty(ListLevel.prototype, "paragraphFormat", {
|
|
810
|
+
get: function () {
|
|
811
|
+
return this.paragraphFormatValue;
|
|
812
|
+
},
|
|
813
|
+
enumerable: true,
|
|
814
|
+
configurable: true
|
|
815
|
+
});
|
|
816
|
+
/** @private */
|
|
817
|
+
ListLevel.prototype.notifyCharacterFormatMutation = function () {
|
|
818
|
+
if (this.suppressDirty) {
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
var children = this.characterFormatValue.buildRPrChildren
|
|
822
|
+
? this.characterFormatValue.buildRPrChildren()
|
|
823
|
+
: undefined;
|
|
824
|
+
var rPrChildren = [];
|
|
825
|
+
if (children !== undefined) {
|
|
826
|
+
rPrChildren = children;
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
var snap = this.characterFormatValue.snapshot
|
|
830
|
+
? this.characterFormatValue.snapshot()
|
|
831
|
+
: undefined;
|
|
832
|
+
if (snap !== undefined) {
|
|
833
|
+
// Fall back: serialize via temporary rPr using existing parse path reverse
|
|
834
|
+
rPrChildren = buildRPrChildrenSafe(this.characterFormatValue);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
if (rPrChildren.length === 0) {
|
|
838
|
+
this.level.setExtraElement('rPr', undefined);
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
this.level.setExtraElement('rPr', wmlElement('rPr', { children: rPrChildren }));
|
|
842
|
+
}
|
|
843
|
+
this.markDirty();
|
|
844
|
+
};
|
|
845
|
+
/** @private */
|
|
846
|
+
ListLevel.prototype.notifyParagraphFormatMutation = function () {
|
|
847
|
+
if (this.suppressDirty) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
var children = this.paragraphFormatValue.buildPPrChildren();
|
|
851
|
+
if (children.length === 0) {
|
|
852
|
+
this.level.setExtraElement('pPr', undefined);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
this.level.setExtraElement('pPr', wmlElement('pPr', { children: children }));
|
|
856
|
+
}
|
|
857
|
+
this.markDirty();
|
|
858
|
+
};
|
|
859
|
+
ListLevel.prototype.hydrateFormatsFromLevel = function () {
|
|
860
|
+
this.suppressDirty = true;
|
|
861
|
+
try {
|
|
862
|
+
var rPr = this.level.findExtra('rPr');
|
|
863
|
+
this.characterFormatValue.hydrate(rPr !== undefined ? characterSnapshotFromRPr(rPr) : parseCharacterFormat(wmlElement('rPr')));
|
|
864
|
+
var pPr = this.level.findExtra('pPr');
|
|
865
|
+
this.paragraphFormatValue.hydrate(pPr !== undefined ? paragraphSnapshotFromPPr(pPr) : emptyParagraphFormatSnapshot());
|
|
866
|
+
}
|
|
867
|
+
finally {
|
|
868
|
+
this.suppressDirty = false;
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
ListLevel.prototype.markDirty = function () {
|
|
872
|
+
this.owner.markNumberingDirty();
|
|
873
|
+
};
|
|
874
|
+
return ListLevel;
|
|
875
|
+
}());
|
|
876
|
+
export { ListLevel };
|
|
877
|
+
function buildRPrChildrenSafe(cf) {
|
|
878
|
+
// CharacterFormat exposes buildRPrChildrenFromSnapshot on the class in this codebase.
|
|
879
|
+
var anyCf = cf;
|
|
880
|
+
if (typeof anyCf.buildRPrChildren === 'function') {
|
|
881
|
+
return anyCf.buildRPrChildren();
|
|
882
|
+
}
|
|
883
|
+
if (typeof anyCf.snapshot === 'function' && typeof anyCf.constructor.buildRPrChildrenFromSnapshot === 'function') {
|
|
884
|
+
return anyCf.constructor.buildRPrChildrenFromSnapshot(anyCf.snapshot());
|
|
885
|
+
}
|
|
886
|
+
// Try module-level pattern used elsewhere: serialize by re-reading after hydrate path
|
|
887
|
+
return [];
|
|
888
|
+
}
|
|
889
|
+
// ---------------------------------------------------------------------------
|
|
890
|
+
// ListLevelCollection / ListStyle
|
|
891
|
+
// ---------------------------------------------------------------------------
|
|
892
|
+
/**
|
|
893
|
+
* Nine-level collection for a {@link ListStyle}.
|
|
894
|
+
*
|
|
895
|
+
* @public
|
|
896
|
+
*/
|
|
897
|
+
var ListLevelCollection = /** @class */ (function () {
|
|
898
|
+
/**
|
|
899
|
+
* @private
|
|
900
|
+
*/
|
|
901
|
+
function ListLevelCollection(items) {
|
|
902
|
+
this.items = items;
|
|
903
|
+
}
|
|
904
|
+
Object.defineProperty(ListLevelCollection.prototype, "count", {
|
|
905
|
+
get: function () {
|
|
906
|
+
return this.items.length;
|
|
907
|
+
},
|
|
908
|
+
enumerable: true,
|
|
909
|
+
configurable: true
|
|
910
|
+
});
|
|
911
|
+
ListLevelCollection.prototype.getItem = function (index) {
|
|
912
|
+
if (typeof index !== 'number' || !Number.isFinite(index) || Math.floor(index) !== index || index < 0 || index > 8) {
|
|
913
|
+
throw new InvalidArgumentError('level index must be an integer from 0 through 8');
|
|
914
|
+
}
|
|
915
|
+
var item = this.items[index];
|
|
916
|
+
if (item === undefined) {
|
|
917
|
+
throw new DocxError('content/invalid-num-id', 'List level ' + String(index) + ' is not defined');
|
|
918
|
+
}
|
|
919
|
+
return item;
|
|
920
|
+
};
|
|
921
|
+
return ListLevelCollection;
|
|
922
|
+
}());
|
|
923
|
+
export { ListLevelCollection };
|
|
924
|
+
/**
|
|
925
|
+
* Public custom list style facade.
|
|
926
|
+
*
|
|
927
|
+
* @public
|
|
928
|
+
*/
|
|
929
|
+
var ListStyle = /** @class */ (function () {
|
|
930
|
+
/**
|
|
931
|
+
* @private
|
|
932
|
+
*/
|
|
933
|
+
function ListStyle(init) {
|
|
934
|
+
this.document = init.document;
|
|
935
|
+
this.styleIdValue = init.styleId;
|
|
936
|
+
this.displayName = init.displayName;
|
|
937
|
+
this.listTypeValue = init.listType;
|
|
938
|
+
this.abstractNumId = init.abstractNumId;
|
|
939
|
+
this.levelsValue = new ListLevelCollection(init.levels);
|
|
940
|
+
}
|
|
941
|
+
Object.defineProperty(ListStyle.prototype, "name", {
|
|
942
|
+
get: function () {
|
|
943
|
+
return this.displayName;
|
|
944
|
+
},
|
|
945
|
+
enumerable: true,
|
|
946
|
+
configurable: true
|
|
947
|
+
});
|
|
948
|
+
Object.defineProperty(ListStyle.prototype, "listType", {
|
|
949
|
+
get: function () {
|
|
950
|
+
return this.listTypeValue;
|
|
951
|
+
},
|
|
952
|
+
enumerable: true,
|
|
953
|
+
configurable: true
|
|
954
|
+
});
|
|
955
|
+
Object.defineProperty(ListStyle.prototype, "levels", {
|
|
956
|
+
get: function () {
|
|
957
|
+
return this.levelsValue;
|
|
958
|
+
},
|
|
959
|
+
enumerable: true,
|
|
960
|
+
configurable: true
|
|
961
|
+
});
|
|
962
|
+
Object.defineProperty(ListStyle.prototype, "styleId", {
|
|
963
|
+
/** @private */
|
|
964
|
+
get: function () {
|
|
965
|
+
return this.styleIdValue;
|
|
966
|
+
},
|
|
967
|
+
enumerable: true,
|
|
968
|
+
configurable: true
|
|
969
|
+
});
|
|
970
|
+
Object.defineProperty(ListStyle.prototype, "abstractId", {
|
|
971
|
+
/** @private */
|
|
972
|
+
get: function () {
|
|
973
|
+
return this.abstractNumId;
|
|
974
|
+
},
|
|
975
|
+
enumerable: true,
|
|
976
|
+
configurable: true
|
|
977
|
+
});
|
|
978
|
+
/** @private */
|
|
979
|
+
ListStyle.prototype.markNumberingDirty = function () {
|
|
980
|
+
numberingCatalog(this.document).markDirty();
|
|
981
|
+
};
|
|
982
|
+
return ListStyle;
|
|
983
|
+
}());
|
|
984
|
+
export { ListStyle };
|
|
985
|
+
var listStyleByAbstract = new WeakMap();
|
|
986
|
+
/**
|
|
987
|
+
* Create a custom list style on the document.
|
|
988
|
+
*
|
|
989
|
+
* @public
|
|
990
|
+
*/
|
|
991
|
+
export function addListStyle(document, listType, styleName) {
|
|
992
|
+
if (typeof listType !== 'string' || !isListType(listType)) {
|
|
993
|
+
throw new InvalidArgumentError('listType must be ListType.Bulleted or ListType.Numbered');
|
|
994
|
+
}
|
|
995
|
+
if (typeof styleName !== 'string' || styleName.trim().length === 0) {
|
|
996
|
+
throw new InvalidArgumentError('styleName must be a non-empty string');
|
|
997
|
+
}
|
|
998
|
+
var name = styleName.trim();
|
|
999
|
+
var styles = styleCollectionFor(document);
|
|
1000
|
+
if (styles.findByName(name) !== undefined || styles.getStyle(name) !== undefined) {
|
|
1001
|
+
throw new DocxError('styles/duplicate-style', 'A style named "' + name + '" already exists');
|
|
1002
|
+
}
|
|
1003
|
+
var styleId = sanitizeStyleIdPublic(name);
|
|
1004
|
+
if (styleId.length === 0) {
|
|
1005
|
+
styleId = 'ListStyle';
|
|
1006
|
+
}
|
|
1007
|
+
if (styles.getStyle(styleId) !== undefined) {
|
|
1008
|
+
throw new DocxError('styles/duplicate-style', 'A style with id "' + styleId + '" already exists');
|
|
1009
|
+
}
|
|
1010
|
+
var numbering = numberingCatalog(document);
|
|
1011
|
+
var abstractNumId = numbering.allocateAbstractNumId();
|
|
1012
|
+
var format = listType === ListType.Bulleted ? 'bullet' : 'decimal';
|
|
1013
|
+
var abstract = createDefaultAbstractNumbering(abstractNumId, format);
|
|
1014
|
+
abstract.setName(name);
|
|
1015
|
+
abstract.setStyleLink(styleId);
|
|
1016
|
+
numbering.registerAbstract(abstract);
|
|
1017
|
+
var shell = new DocxStyle(styleId, 'numbering', undefined, true, [
|
|
1018
|
+
wmlElement('name', { attributes: [wmlAttr('val', name)] }),
|
|
1019
|
+
]);
|
|
1020
|
+
// Force OpaqueStyle numbering entry via addStyle
|
|
1021
|
+
styles.addStyle(shell);
|
|
1022
|
+
var live = styles.getStyle(styleId);
|
|
1023
|
+
if (live === undefined) {
|
|
1024
|
+
// addStyle may no-op if race; ensure via direct path
|
|
1025
|
+
throw new DocxError('styles/undefined-style', 'Failed to register list style "' + name + '"');
|
|
1026
|
+
}
|
|
1027
|
+
var levelFacades = [];
|
|
1028
|
+
var listStyle = new ListStyle({
|
|
1029
|
+
document: document,
|
|
1030
|
+
styleId: styleId,
|
|
1031
|
+
displayName: name,
|
|
1032
|
+
listType: listType,
|
|
1033
|
+
abstractNumId: abstractNumId,
|
|
1034
|
+
levels: levelFacades,
|
|
1035
|
+
});
|
|
1036
|
+
for (var i = 0; i < abstract.levels.length; i += 1) {
|
|
1037
|
+
var lvl = abstract.levels[i];
|
|
1038
|
+
levelFacades.push(new ListLevel(listStyle, lvl));
|
|
1039
|
+
}
|
|
1040
|
+
// Rebuild collection with filled levels
|
|
1041
|
+
listStyle.levelsValue = new ListLevelCollection(levelFacades);
|
|
1042
|
+
listStyleByAbstract.set(abstract, listStyle);
|
|
1043
|
+
return listStyle;
|
|
1044
|
+
}
|
|
1045
|
+
function sanitizeStyleIdPublic(name) {
|
|
1046
|
+
var out = '';
|
|
1047
|
+
for (var i = 0; i < name.length; i += 1) {
|
|
1048
|
+
var ch = name.charAt(i);
|
|
1049
|
+
var code = name.charCodeAt(i);
|
|
1050
|
+
var isLetter = (code >= 65 && code <= 90) ||
|
|
1051
|
+
(code >= 97 && code <= 122) ||
|
|
1052
|
+
code > 127;
|
|
1053
|
+
var isDigit = code >= 48 && code <= 57;
|
|
1054
|
+
if (isLetter || isDigit) {
|
|
1055
|
+
out += ch;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return out;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Resolve abstract num id for a numbering style (styleLink / name).
|
|
1062
|
+
*
|
|
1063
|
+
* @private
|
|
1064
|
+
*/
|
|
1065
|
+
export function findAbstractForListStyle(numbering, styleId, displayName) {
|
|
1066
|
+
for (var i = 0; i < numbering.abstractNumberings.length; i += 1) {
|
|
1067
|
+
var abs = numbering.abstractNumberings[i];
|
|
1068
|
+
if (abs.styleLink === styleId || (displayName !== undefined && abs.styleLink === displayName)) {
|
|
1069
|
+
return abs.abstractNumId;
|
|
1070
|
+
}
|
|
1071
|
+
if (abs.name === styleId || (displayName !== undefined && abs.name === displayName)) {
|
|
1072
|
+
return abs.abstractNumId;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return undefined;
|
|
1076
|
+
}
|
|
1077
|
+
// Wire WordDocument.addListStyle without importing numbering/index at module top.
|
|
1078
|
+
Object.defineProperty(WordDocument.prototype, 'addListStyle', {
|
|
1079
|
+
value: function (listType, styleName) {
|
|
1080
|
+
return addListStyle(this, listType, styleName);
|
|
1081
|
+
},
|
|
1082
|
+
writable: true,
|
|
1083
|
+
configurable: true,
|
|
1084
|
+
});
|