@globalpayments/vega 2.98.0 → 2.99.0
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/dist/cjs/{action-color-accessibility-validator-24498816.js → action-color-accessibility-validator-b8a9ef0f.js} +2 -2
- package/dist/cjs/{app-globals-b3f05631.js → app-globals-a306dce6.js} +10 -10
- package/dist/cjs/{code-block-d78c2b2c.js → code-block-ea1f5eb3.js} +43 -6
- package/dist/cjs/{component-global-style-slimmer-93c5fb50.js → component-global-style-slimmer-ba588eb4.js} +1 -1
- package/dist/cjs/{component-value-history-controller-slimmer.abstract-beb00fea.js → component-value-history-controller-slimmer.abstract-7071b064.js} +24 -5
- package/dist/cjs/{content-state-78a620a9.js → content-state-8d07d530.js} +60 -8
- package/dist/cjs/{dark-mode-style-controller-32d4054a.js → dark-mode-style-controller-f3da3342.js} +2 -2
- package/dist/cjs/{date-required-rule-5250f26d.js → date-required-rule-c0c498ad.js} +1 -1
- package/dist/cjs/{design-token-74674ee7.js → design-token-58bf7fe8.js} +3 -3
- package/dist/cjs/{element-appender-slimmer-597e9e48.js → element-appender-slimmer-a0269315.js} +2 -2
- package/dist/cjs/{form-field-controller-slimmer-a743be34.js → form-field-controller-slimmer-f73f200e.js} +2 -2
- package/dist/cjs/{image-annotation-action-85c4bd83.js → image-annotation-action-2a28038e.js} +3 -3
- package/dist/cjs/{image-extension-260fa69c.js → image-extension-9659708b.js} +2 -2
- package/dist/cjs/{index-592b4052.js → index-5d1adcd1.js} +86 -0
- package/dist/cjs/index.cjs.js +19 -19
- package/dist/cjs/{inject-keyboard-manager-6a6f5c9f.js → inject-keyboard-manager-4fa45f9c.js} +1 -1
- package/dist/cjs/{internal-calendar-period-factory-dfcdd3f6.js → internal-calendar-period-factory-6196bc80.js} +1 -1
- package/dist/cjs/{internal-translation-controller-1dac2df8.js → internal-translation-controller-51f7f865.js} +2 -0
- package/dist/cjs/{keyboard-manager-c56033b1.js → keyboard-manager-482fe257.js} +1 -1
- package/dist/cjs/{keyboard-manager-slimmer-7043a106.js → keyboard-manager-slimmer-a19430dd.js} +1 -1
- package/dist/cjs/{link-extension-220ff6a9.js → link-extension-11340e1c.js} +26 -7
- package/dist/cjs/loader.cjs.js +13 -13
- package/dist/cjs/{month-view-generator-7b704a80.js → month-view-generator-1a534451.js} +1 -1
- package/dist/cjs/{public-rules-5657bce4.js → public-rules-6c77b545.js} +9 -9
- package/dist/cjs/{range-c5afd53a.js → range-22ddd452.js} +1 -1
- package/dist/cjs/{responsive-format-facade-493d1763.js → responsive-format-facade-74e6d791.js} +1 -1
- package/dist/cjs/{rich-text-editor-required-rule-385c1b61.js → rich-text-editor-required-rule-09d1093a.js} +1 -1
- package/dist/cjs/{split-cell-operation-873d5db7.js → split-cell-operation-11bfb305.js} +14 -4
- package/dist/cjs/{state-border-formatter-711c7aaa.js → state-border-formatter-bf4f9f1c.js} +1 -1
- package/dist/cjs/{string-format-strategy.abstract-b61bdcbd.js → string-format-strategy.abstract-bf37b14c.js} +1 -1
- package/dist/cjs/{string-input-formatter-slimmer-ef65cca7.js → string-input-formatter-slimmer-ffeb18a6.js} +1 -1
- package/dist/cjs/{string-mask-strategy-ad3fa0ac.js → string-mask-strategy-7f394726.js} +2 -2
- package/dist/cjs/{style-formatter-8f711cb0.js → style-formatter-4ac63910.js} +2 -2
- package/dist/cjs/{time-required-rule-87417359.js → time-required-rule-e2a50003.js} +1 -1
- package/dist/cjs/{token-extension-78b5a026.js → token-extension-4686cb3b.js} +2920 -157
- package/dist/cjs/{translation-slimmer-77c7f37d.js → translation-slimmer-e4997f8f.js} +1 -1
- package/dist/cjs/{type-guard-a57ef3ac.js → type-guard-b8d7bb3f.js} +1 -1
- package/dist/cjs/{valid-credit-card-number-rule-4c0a3040.js → valid-credit-card-number-rule-f5a6f009.js} +1 -1
- package/dist/cjs/vega-accordion.cjs.entry.js +6 -6
- package/dist/cjs/vega-app-footer.cjs.entry.js +2 -2
- package/dist/cjs/vega-app-header-button.cjs.entry.js +5 -5
- package/dist/cjs/vega-box.cjs.entry.js +7 -7
- package/dist/cjs/vega-brand-logo.cjs.entry.js +2 -2
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +2 -2
- package/dist/cjs/vega-button-circle.cjs.entry.js +6 -6
- package/dist/cjs/vega-button-link.cjs.entry.js +1 -1
- package/dist/cjs/vega-button.cjs.entry.js +4 -4
- package/dist/cjs/vega-calendar_5.cjs.entry.js +21 -10
- package/dist/cjs/vega-card.cjs.entry.js +5 -5
- package/dist/cjs/vega-carousel.cjs.entry.js +3 -3
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-chip.cjs.entry.js +5 -5
- package/dist/cjs/vega-code-block.cjs.entry.js +11 -11
- package/dist/cjs/vega-color-picker.cjs.entry.js +3 -3
- package/dist/cjs/vega-color-swatch-picker.cjs.entry.js +4 -4
- package/dist/cjs/vega-color-swatch.cjs.entry.js +2 -2
- package/dist/cjs/vega-combo-box.cjs.entry.js +9 -9
- package/dist/cjs/vega-counter-badge.cjs.entry.js +2 -2
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +14 -14
- package/dist/cjs/vega-dialog_2.cjs.entry.js +5 -5
- package/dist/cjs/vega-divider.cjs.entry.js +5 -5
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +23 -14
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-field-label.cjs.entry.js +3 -3
- package/dist/cjs/vega-file-uploader.cjs.entry.js +4 -4
- package/dist/cjs/vega-flag-icon.cjs.entry.js +5 -5
- package/dist/cjs/vega-flex.cjs.entry.js +6 -6
- package/dist/cjs/vega-font.cjs.entry.js +5 -5
- package/dist/cjs/vega-form.cjs.entry.js +2 -2
- package/dist/cjs/vega-grid.cjs.entry.js +5 -5
- package/dist/cjs/vega-icon.cjs.entry.js +6 -6
- package/dist/cjs/vega-image-uploader.cjs.entry.js +7 -7
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +7 -7
- package/dist/cjs/vega-input-numeric.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-passcode.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +5 -5
- package/dist/cjs/vega-input-range.cjs.entry.js +4 -4
- package/dist/cjs/vega-input-select.cjs.entry.js +6 -6
- package/dist/cjs/vega-input.cjs.entry.js +7 -7
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +10 -10
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +2 -2
- package/dist/cjs/vega-pagination.cjs.entry.js +4 -4
- package/dist/cjs/vega-popover_2.cjs.entry.js +8 -8
- package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-radio_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +39 -11
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +79 -22
- package/dist/cjs/vega-rich-text-find-replace-panel.cjs.entry.js +1 -1
- package/dist/cjs/vega-rich-text-special-characters-panel.cjs.entry.js +5 -5
- package/dist/cjs/vega-rich-text-table-properties_3.cjs.entry.js +10 -10
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +5 -5
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +3 -3
- package/dist/cjs/vega-signature-capture.cjs.entry.js +8 -8
- package/dist/cjs/vega-stepper.cjs.entry.js +3 -3
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +21 -8
- package/dist/cjs/vega-table_11.cjs.entry.js +81 -45
- package/dist/cjs/vega-textarea.cjs.entry.js +3 -3
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +10 -10
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +3 -3
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +6 -6
- package/dist/cjs/vega.cjs.js +13 -13
- package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-event-item-renderer.js +5 -2
- package/dist/collection/components/vega-calendar/vega-calendar-event-preview/slimmers/renderers/vega-calendar-event-preview-detail-renderer.js +9 -1
- package/dist/collection/components/vega-counter-badge/vega-counter-badge.js +2 -2
- package/dist/collection/components/vega-dropdown/vega-dropdown-group/slimmers/renderers/vega-dropdown-group-renderer.js +6 -4
- package/dist/collection/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.js +10 -2
- package/dist/collection/components/vega-field-label/vega-field-label.css +1 -0
- package/dist/collection/components/vega-rich-text-editor/constants/constant.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-style-default-styles.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +11 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy-registry.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy.abstract.js +5 -2
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/title-heading-node-filter-styles-strategy.js +36 -2
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.js +20 -3
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/block-boundary-registry.js +34 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/extension.abstract.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/action-handler-strategies/insert-function-block-strategy.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/constants.js +8 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/dto/function-block.js +14 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/dto/logic-control-block.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/element-to-dto-strategies/div-containing-function-block-strategy.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/element-to-dto-strategies/div-to-function-block-strategy.js +9 -5
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/element-to-dto-strategies/div-to-function-content-strategy.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/element-to-dto-strategies/div-to-logic-control-block-strategy.js +4 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/function-extension.js +18 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/renderers/function-block-renderer.js +5 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/renderers/logic-control-block-renderer.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/utils.js +36 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/languages/language-extension.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/action-handler-strategies/image-replace-src-strategy.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/actions/image-replace-src-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/paste-image-parser.js +295 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/pending-image-registry.js +116 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/paste-chooser-ui.js +13 -4
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/paste-extension.js +70 -7
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/default-paste-strategy.js +38 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/paste-processing-strategy.abstract.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/paste-strategy-selector.js +59 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/word-paste-strategy.js +416 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-code-block-transformer.js +106 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-image-transformer.js +198 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-list-transformer.js +591 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-paragraph-transformer.js +112 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-table-transformer.js +551 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-transformer.js +7 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-block.js +10 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/tokens/span-to-token-node-strategy.js +4 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-node.js +44 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/extension-controller.js +2 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/text-style-annotation-handler.js +7 -4
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.js +17 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.js +18 -4
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/selection-controller.js +21 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.js +7 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-source-view-renderer.js +5 -2
- package/dist/collection/components/vega-tab-group/slimmers/vega-tab-group/renderers/vega-tab-group-tab-list-renderer.js +14 -7
- package/dist/collection/components/vega-tab-group/vega-tab-group.css +6 -0
- package/dist/collection/components/vega-tab-group/vega-tab-group.js +5 -0
- package/dist/collection/components/vega-table/slimmers/controllers/vega-table-body-col-span-controller.js +31 -1
- package/dist/collection/components/vega-table/slimmers/renderers/vega-table-body-col-span-resolver.js +18 -11
- package/dist/collection/helpers/translation/locales/en.js +2 -0
- package/dist/collection/utils/sanitize/index.js +3 -2
- package/dist/collection/utils/sanitize/strategies/index.js +1 -0
- package/dist/collection/utils/sanitize/strategies/label-sanitize-strategy.js +14 -0
- package/dist/collection/utils/sanitize/strategies/plain-text-sanitize-strategy.js +70 -0
- package/dist/esm/{action-color-accessibility-validator-ce55cb07.js → action-color-accessibility-validator-08877515.js} +2 -2
- package/dist/esm/{app-globals-95c7110a.js → app-globals-c59364c2.js} +10 -10
- package/dist/esm/{code-block-9c513169.js → code-block-e6443949.js} +39 -7
- package/dist/esm/{component-global-style-slimmer-ac703085.js → component-global-style-slimmer-7d60a04a.js} +1 -1
- package/dist/esm/{component-value-history-controller-slimmer.abstract-9cef2a2a.js → component-value-history-controller-slimmer.abstract-ee393213.js} +24 -5
- package/dist/esm/{content-state-25c81c08.js → content-state-43cdacff.js} +60 -9
- package/dist/esm/{dark-mode-style-controller-ca5afd2d.js → dark-mode-style-controller-352f15ff.js} +2 -2
- package/dist/esm/{date-required-rule-85334d0c.js → date-required-rule-b5b67498.js} +1 -1
- package/dist/esm/{design-token-10ff79b5.js → design-token-8319bb59.js} +3 -3
- package/dist/esm/{element-appender-slimmer-8a06ecdd.js → element-appender-slimmer-c81d1fe3.js} +2 -2
- package/dist/esm/{form-field-controller-slimmer-68fc5380.js → form-field-controller-slimmer-511b7ac5.js} +2 -2
- package/dist/esm/{image-annotation-action-d7f2aecc.js → image-annotation-action-d7cb80aa.js} +3 -3
- package/dist/esm/{image-extension-fbd1ed6e.js → image-extension-9b8abd0d.js} +2 -2
- package/dist/esm/{index-3b327f29.js → index-35451d12.js} +86 -1
- package/dist/esm/index.js +19 -19
- package/dist/esm/{inject-keyboard-manager-ea1aad5b.js → inject-keyboard-manager-dd368d56.js} +1 -1
- package/dist/esm/{internal-calendar-period-factory-7b294fb6.js → internal-calendar-period-factory-d58f35c6.js} +1 -1
- package/dist/esm/{internal-translation-controller-fac22598.js → internal-translation-controller-b33430c6.js} +2 -0
- package/dist/esm/{keyboard-manager-50da85d7.js → keyboard-manager-b4a0d97d.js} +1 -1
- package/dist/esm/{keyboard-manager-slimmer-1f7c8bfb.js → keyboard-manager-slimmer-0517fc70.js} +1 -1
- package/dist/esm/{link-extension-e8ee103e.js → link-extension-230bae8d.js} +26 -7
- package/dist/esm/loader.js +13 -13
- package/dist/esm/{month-view-generator-a1a9a4ec.js → month-view-generator-f470caac.js} +1 -1
- package/dist/esm/{public-rules-49de79c7.js → public-rules-28ef32d3.js} +9 -9
- package/dist/esm/{range-b678c693.js → range-efad2578.js} +1 -1
- package/dist/esm/{responsive-format-facade-f19b601c.js → responsive-format-facade-dec87e46.js} +1 -1
- package/dist/esm/{rich-text-editor-required-rule-578e0958.js → rich-text-editor-required-rule-a697e5bd.js} +1 -1
- package/dist/esm/{split-cell-operation-1c8e7585.js → split-cell-operation-89b91a38.js} +14 -4
- package/dist/esm/{state-border-formatter-bfda33aa.js → state-border-formatter-1e900a2f.js} +1 -1
- package/dist/esm/{string-format-strategy.abstract-1f4ff1b3.js → string-format-strategy.abstract-d0ce3f65.js} +1 -1
- package/dist/esm/{string-input-formatter-slimmer-0006a107.js → string-input-formatter-slimmer-6546cfc7.js} +1 -1
- package/dist/esm/{string-mask-strategy-bbbcdbef.js → string-mask-strategy-dd13ae21.js} +2 -2
- package/dist/esm/{style-formatter-e9adc8f4.js → style-formatter-057d7120.js} +2 -2
- package/dist/esm/{time-required-rule-1ce2d0a0.js → time-required-rule-73753a54.js} +1 -1
- package/dist/esm/{token-extension-f2d009e3.js → token-extension-74a0eeb1.js} +2918 -155
- package/dist/esm/{translation-slimmer-ee0f0e76.js → translation-slimmer-ef970ffc.js} +1 -1
- package/dist/esm/{type-guard-f2624334.js → type-guard-6fc96870.js} +1 -1
- package/dist/esm/{valid-credit-card-number-rule-60212b1d.js → valid-credit-card-number-rule-b54a31e7.js} +1 -1
- package/dist/esm/vega-accordion.entry.js +6 -6
- package/dist/esm/vega-app-footer.entry.js +2 -2
- package/dist/esm/vega-app-header-button.entry.js +5 -5
- package/dist/esm/vega-box.entry.js +7 -7
- package/dist/esm/vega-brand-logo.entry.js +2 -2
- package/dist/esm/vega-breadcrumb.entry.js +2 -2
- package/dist/esm/vega-button-circle.entry.js +6 -6
- package/dist/esm/vega-button-link.entry.js +1 -1
- package/dist/esm/vega-button.entry.js +4 -4
- package/dist/esm/vega-calendar_5.entry.js +21 -10
- package/dist/esm/vega-card.entry.js +5 -5
- package/dist/esm/vega-carousel.entry.js +3 -3
- package/dist/esm/vega-checkbox_2.entry.js +3 -3
- package/dist/esm/vega-chip.entry.js +5 -5
- package/dist/esm/vega-code-block.entry.js +11 -11
- package/dist/esm/vega-color-picker.entry.js +3 -3
- package/dist/esm/vega-color-swatch-picker.entry.js +4 -4
- package/dist/esm/vega-color-swatch.entry.js +2 -2
- package/dist/esm/vega-combo-box.entry.js +9 -9
- package/dist/esm/vega-counter-badge.entry.js +2 -2
- package/dist/esm/vega-date-picker_2.entry.js +14 -14
- package/dist/esm/vega-dialog_2.entry.js +5 -5
- package/dist/esm/vega-divider.entry.js +5 -5
- package/dist/esm/vega-dropdown_5.entry.js +23 -14
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-field-label.entry.js +3 -3
- package/dist/esm/vega-file-uploader.entry.js +4 -4
- package/dist/esm/vega-flag-icon.entry.js +5 -5
- package/dist/esm/vega-flex.entry.js +6 -6
- package/dist/esm/vega-font.entry.js +5 -5
- package/dist/esm/vega-form.entry.js +2 -2
- package/dist/esm/vega-grid.entry.js +5 -5
- package/dist/esm/vega-icon.entry.js +6 -6
- package/dist/esm/vega-image-uploader.entry.js +7 -7
- package/dist/esm/vega-input-credit-card.entry.js +7 -7
- package/dist/esm/vega-input-numeric.entry.js +6 -6
- package/dist/esm/vega-input-passcode.entry.js +6 -6
- package/dist/esm/vega-input-phone-number.entry.js +5 -5
- package/dist/esm/vega-input-range.entry.js +4 -4
- package/dist/esm/vega-input-select.entry.js +6 -6
- package/dist/esm/vega-input.entry.js +7 -7
- package/dist/esm/vega-left-nav_5.entry.js +10 -10
- package/dist/esm/vega-loader-wrapper_2.entry.js +3 -3
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +2 -2
- package/dist/esm/vega-pagination.entry.js +4 -4
- package/dist/esm/vega-popover_2.entry.js +8 -8
- package/dist/esm/vega-progress-tracker_2.entry.js +3 -3
- package/dist/esm/vega-radio_2.entry.js +6 -6
- package/dist/esm/vega-rich-text-content.entry.js +39 -11
- package/dist/esm/vega-rich-text-editor_4.entry.js +79 -22
- package/dist/esm/vega-rich-text-find-replace-panel.entry.js +1 -1
- package/dist/esm/vega-rich-text-special-characters-panel.entry.js +5 -5
- package/dist/esm/vega-rich-text-table-properties_3.entry.js +10 -10
- package/dist/esm/vega-selection-chip_2.entry.js +5 -5
- package/dist/esm/vega-selection-tile_2.entry.js +3 -3
- package/dist/esm/vega-sidenav_3.entry.js +3 -3
- package/dist/esm/vega-signature-capture.entry.js +8 -8
- package/dist/esm/vega-stepper.entry.js +3 -3
- package/dist/esm/vega-tab-group_2.entry.js +21 -8
- package/dist/esm/vega-table_11.entry.js +53 -17
- package/dist/esm/vega-textarea.entry.js +3 -3
- package/dist/esm/vega-time-picker_2.entry.js +10 -10
- package/dist/esm/vega-toggle-switch.entry.js +3 -3
- package/dist/esm/vega-tooltip_2.entry.js +6 -6
- package/dist/esm/vega.js +13 -13
- package/dist/sri/vega-sri-manifest.json +349 -349
- package/dist/types/components/vega-calendar/vega-calendar-event-preview/slimmers/renderers/vega-calendar-event-preview-detail-renderer.d.ts +2 -0
- package/dist/types/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/constants/constant.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-style-default-styles.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy-registry.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy.abstract.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/title-heading-node-filter-styles-strategy.d.ts +25 -3
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/extensions/block-boundary-registry.d.ts +21 -0
- package/dist/types/components/vega-rich-text-editor/extensions/extension.abstract.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/extensions/functions/constants.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/extensions/functions/dto/function-block.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/extensions/functions/element-to-dto-strategies/div-containing-function-block-strategy.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/extensions/functions/function-extension.d.ts +6 -0
- package/dist/types/components/vega-rich-text-editor/extensions/functions/utils.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/action-handler-strategies/image-replace-src-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/actions/image-replace-src-action.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/paste-image-parser.d.ts +136 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/pending-image-registry.d.ts +68 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/paste-chooser-ui.d.ts +9 -4
- package/dist/types/components/vega-rich-text-editor/extensions/paste/paste-extension.d.ts +39 -2
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/default-paste-strategy.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/paste-processing-strategy.abstract.d.ts +61 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/paste-strategy-selector.d.ts +45 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/word-paste-strategy.d.ts +186 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-code-block-transformer.d.ts +51 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-image-transformer.d.ts +86 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-list-transformer.d.ts +271 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-paragraph-transformer.d.ts +25 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-table-transformer.d.ts +240 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/word-paste-transformers/word-structure-transformer.d.ts +36 -0
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-block.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/extensions/tokens/span-to-token-node-strategy.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-node.d.ts +19 -1
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/text-style-annotation-handler.d.ts +4 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.d.ts +1 -0
- package/dist/types/components/vega-tab-group/slimmers/vega-tab-group/renderers/vega-tab-group-tab-list-renderer.d.ts +1 -0
- package/dist/types/components/vega-tab-group/types.d.ts +3 -1
- package/dist/types/components/vega-tab-group/vega-tab-group.d.ts +2 -0
- package/dist/types/components/vega-table/interface.d.ts +4 -4
- package/dist/types/components/vega-table/slimmers/controllers/vega-table-body-col-span-controller.d.ts +16 -0
- package/dist/types/components/vega-table/slimmers/renderers/vega-table-body-col-span-resolver.d.ts +8 -10
- package/dist/types/helpers/translation/interface.d.ts +3 -1
- package/dist/types/types/public-api.d.ts +1 -0
- package/dist/types/utils/sanitize/index.d.ts +3 -2
- package/dist/types/utils/sanitize/strategies/index.d.ts +1 -0
- package/dist/types/utils/sanitize/strategies/label-sanitize-strategy.d.ts +9 -0
- package/dist/types/utils/sanitize/strategies/plain-text-sanitize-strategy.d.ts +36 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-0cbf09f7.entry.js → p-024db952.entry.js} +1 -1
- package/dist/vega/p-0b2c4c0b.js +1 -0
- package/dist/vega/{p-c2277448.entry.js → p-0ca3b4bf.entry.js} +1 -1
- package/dist/vega/{p-6f537797.entry.js → p-1a37d63c.entry.js} +1 -1
- package/dist/vega/{p-b622c455.js → p-1fa22fda.js} +1 -1
- package/dist/vega/{p-d609c3fd.js → p-2044eba9.js} +1 -1
- package/dist/vega/{p-56db3323.js → p-22edd3cc.js} +1 -1
- package/dist/vega/{p-5f96e741.entry.js → p-23c1f378.entry.js} +1 -1
- package/dist/vega/{p-6c95a6a3.js → p-2529820e.js} +1 -1
- package/dist/vega/{p-8d96f0e8.entry.js → p-2af1d8b8.entry.js} +1 -1
- package/dist/vega/{p-17c69503.entry.js → p-2f89ee14.entry.js} +1 -1
- package/dist/vega/{p-2bb5a232.js → p-3091b105.js} +1 -1
- package/dist/vega/{p-52c69f9e.entry.js → p-328ebbdb.entry.js} +1 -1
- package/dist/vega/p-35628af4.js +1 -0
- package/dist/vega/{p-9abf7d0a.entry.js → p-35d37477.entry.js} +1 -1
- package/dist/vega/{p-8c56d74d.entry.js → p-3a230d4b.entry.js} +1 -1
- package/dist/vega/{p-4bfe3258.entry.js → p-3c152bad.entry.js} +1 -1
- package/dist/vega/p-3c559c8b.js +1 -0
- package/dist/vega/{p-d470fce2.entry.js → p-3c8421d5.entry.js} +1 -1
- package/dist/vega/{p-7dcd2850.entry.js → p-4022412e.entry.js} +1 -1
- package/dist/vega/{p-c70748f7.entry.js → p-433b1395.entry.js} +1 -1
- package/dist/vega/{p-b98ead05.entry.js → p-4370b954.entry.js} +1 -1
- package/dist/vega/p-444e24c6.js +1 -0
- package/dist/vega/p-4473d8b1.js +3 -0
- package/dist/vega/{p-a484e32d.entry.js → p-44999c88.entry.js} +1 -1
- package/dist/vega/{p-f29ea345.entry.js → p-47a48329.entry.js} +1 -1
- package/dist/vega/{p-0cf3b5c1.entry.js → p-49d7cfed.entry.js} +1 -1
- package/dist/vega/{p-92528dc9.entry.js → p-4afd6715.entry.js} +1 -1
- package/dist/vega/{p-461100b8.entry.js → p-4f6aaac5.entry.js} +1 -1
- package/dist/vega/p-50eda925.js +1 -0
- package/dist/vega/{p-ae2abdfa.js → p-5110c84f.js} +1 -1
- package/dist/vega/{p-2a245138.entry.js → p-5147c30d.entry.js} +1 -1
- package/dist/vega/{p-874e5624.js → p-52878ea9.js} +1 -1
- package/dist/vega/{p-b00ec194.entry.js → p-55dc3053.entry.js} +1 -1
- package/dist/vega/p-5af312f8.js +1 -0
- package/dist/vega/{p-3e09aeed.js → p-5b3c8a56.js} +1 -1
- package/dist/vega/{p-2acf9b42.entry.js → p-5e9e04f3.entry.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-6493f13a.entry.js +1 -0
- package/dist/vega/{p-56598858.entry.js → p-6659c910.entry.js} +1 -1
- package/dist/vega/{p-95c18f79.entry.js → p-66728dd4.entry.js} +1 -1
- package/dist/vega/{p-4cbfc01e.entry.js → p-66a785d0.entry.js} +1 -1
- package/dist/vega/{p-36d9e782.entry.js → p-66fe8b4e.entry.js} +1 -1
- package/dist/vega/p-67e88cd7.entry.js +1 -0
- package/dist/vega/{p-456f678b.js → p-691bdc20.js} +1 -1
- package/dist/vega/{p-94975537.entry.js → p-6d6b4495.entry.js} +1 -1
- package/dist/vega/p-7754b10f.entry.js +1 -0
- package/dist/vega/{p-085d1647.entry.js → p-77fb3971.entry.js} +1 -1
- package/dist/vega/{p-544ce391.entry.js → p-7977352b.entry.js} +1 -1
- package/dist/vega/{p-a91927eb.entry.js → p-7b133734.entry.js} +1 -1
- package/dist/vega/p-7b84a943.entry.js +1 -0
- package/dist/vega/{p-02d3ce79.entry.js → p-840444c9.entry.js} +1 -1
- package/dist/vega/{p-3737b9e2.entry.js → p-860e76f5.entry.js} +1 -1
- package/dist/vega/{p-72fd17a1.entry.js → p-867cc602.entry.js} +1 -1
- package/dist/vega/p-8d2a9012.js +1 -0
- package/dist/vega/{p-7e8fdac4.js → p-8d4be607.js} +1 -1
- package/dist/vega/p-8d77c7cf.js +1 -0
- package/dist/vega/{p-4fd0cf01.js → p-8f3b93db.js} +1 -1
- package/dist/vega/{p-56417ec5.entry.js → p-944e284d.entry.js} +1 -1
- package/dist/vega/{p-6fd4f2c6.js → p-94b54a95.js} +1 -1
- package/dist/vega/p-9c2b3279.js +1 -0
- package/dist/vega/{p-ca3c1317.entry.js → p-9c5289dc.entry.js} +1 -1
- package/dist/vega/{p-810c9c29.js → p-9c9b0629.js} +1 -1
- package/dist/vega/{p-585e4f1c.entry.js → p-9c9ff871.entry.js} +1 -1
- package/dist/vega/{p-2f07d719.entry.js → p-9d90e271.entry.js} +1 -1
- package/dist/vega/{p-d319ebb5.js → p-9e9f49f4.js} +1 -1
- package/dist/vega/{p-dcd3e3a7.js → p-a1f220ca.js} +1 -1
- package/dist/vega/{p-035e2f05.entry.js → p-a4360b7e.entry.js} +1 -1
- package/dist/vega/{p-6d4518d7.entry.js → p-a7517760.entry.js} +1 -1
- package/dist/vega/{p-c5fb8a69.entry.js → p-aa433430.entry.js} +1 -1
- package/dist/vega/{p-1cff027b.entry.js → p-aa914dbd.entry.js} +1 -1
- package/dist/vega/{p-72ab5cd5.entry.js → p-b12de1bf.entry.js} +1 -1
- package/dist/vega/p-b21cc390.entry.js +1 -0
- package/dist/vega/{p-dbb4b1d1.js → p-b3c4943b.js} +1 -1
- package/dist/vega/{p-1aedbfd2.entry.js → p-ba6881da.entry.js} +1 -1
- package/dist/vega/{p-9834d5d4.entry.js → p-bd7725f7.entry.js} +1 -1
- package/dist/vega/{p-a090b2be.js → p-c348eaf5.js} +1 -1
- package/dist/vega/{p-ccbe3f1b.entry.js → p-c8ad7207.entry.js} +1 -1
- package/dist/vega/{p-b3733762.entry.js → p-c8fb3aac.entry.js} +1 -1
- package/dist/vega/p-cc569b54.js +1 -0
- package/dist/vega/{p-c98c2f5f.entry.js → p-ccbed811.entry.js} +1 -1
- package/dist/vega/{p-da867019.entry.js → p-ce82d6bb.entry.js} +1 -1
- package/dist/vega/{p-a81ad3bd.js → p-cede3535.js} +1 -1
- package/dist/vega/p-d35a31a5.entry.js +1 -0
- package/dist/vega/{p-ac94ba1b.entry.js → p-d4d90ce2.entry.js} +1 -1
- package/dist/vega/{p-cb81126a.entry.js → p-d6023dc0.entry.js} +1 -1
- package/dist/vega/{p-a8174ad8.entry.js → p-d62e618a.entry.js} +1 -1
- package/dist/vega/{p-1ea9ad9a.js → p-dd0bd78b.js} +1 -1
- package/dist/vega/{p-36d2df7a.entry.js → p-ded1ecc1.entry.js} +1 -1
- package/dist/vega/p-df63c2fb.entry.js +1 -0
- package/dist/vega/{p-c6d775b8.entry.js → p-e1a65e06.entry.js} +1 -1
- package/dist/vega/{p-39c5054b.js → p-e1c82ca9.js} +1 -1
- package/dist/vega/{p-f6c0e9e7.entry.js → p-e469ba27.entry.js} +1 -1
- package/dist/vega/{p-373541fa.js → p-e4c5cb4f.js} +1 -1
- package/dist/vega/{p-ec64cc59.entry.js → p-f0a0fc77.entry.js} +1 -1
- package/dist/vega/{p-12e8a1b2.js → p-f13b39d8.js} +1 -1
- package/dist/vega/{p-4e065ef7.entry.js → p-f2384411.entry.js} +1 -1
- package/dist/vega/{p-8d2501b2.js → p-f9a3805d.js} +1 -1
- package/dist/vega/{p-1e0a8fd3.js → p-fa5cd8b1.js} +1 -1
- package/dist/vega/{p-2c2e8615.js → p-fcb6b499.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/paste-constants.js +0 -6
- package/dist/types/components/vega-rich-text-editor/extensions/paste/paste-constants.d.ts +0 -6
- package/dist/vega/p-03eeadc1.entry.js +0 -1
- package/dist/vega/p-0eb29065.js +0 -3
- package/dist/vega/p-10d30c03.js +0 -1
- package/dist/vega/p-1250b1ab.entry.js +0 -1
- package/dist/vega/p-1abd3c17.js +0 -1
- package/dist/vega/p-2d158cbd.js +0 -1
- package/dist/vega/p-3d0b4074.js +0 -1
- package/dist/vega/p-56493601.js +0 -1
- package/dist/vega/p-571ec00b.js +0 -1
- package/dist/vega/p-5b1f5e4a.entry.js +0 -1
- package/dist/vega/p-6234852e.entry.js +0 -1
- package/dist/vega/p-781b7a54.js +0 -1
- package/dist/vega/p-cd69aeae.js +0 -1
- package/dist/vega/p-cfe268a8.entry.js +0 -1
- package/dist/vega/p-de8f0d98.js +0 -1
- package/dist/vega/p-f0e828d8.js +0 -1
- package/dist/vega/p-f62c5a20.entry.js +0 -1
- package/dist/vega/p-fa65956c.entry.js +0 -1
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
/** Font families Word uses to render bullet symbols rather than real characters. */
|
|
2
|
+
const BULLET_FONT_PATTERN = /symbol|wingdings|webdings/i;
|
|
3
|
+
/**
|
|
4
|
+
* Matches the paragraph-level Word list marker (`mso-list:l0 level1 lfo1`). The
|
|
5
|
+
* presence of `l<number>` distinguishes a genuine list paragraph from the inner
|
|
6
|
+
* `mso-list:Ignore` marker span.
|
|
7
|
+
*/
|
|
8
|
+
const PARAGRAPH_LIST_PATTERN = /mso-list\s*:\s*l\d+/i;
|
|
9
|
+
/** Extracts the Word nesting depth (`level<number>`) from a list paragraph. */
|
|
10
|
+
const LIST_LEVEL_PATTERN = /mso-list\s*:\s*l\d+\s+level(\d+)/i;
|
|
11
|
+
/** Extracts the abstract Word list template id (`l<number>`). */
|
|
12
|
+
const LIST_TEMPLATE_ID_PATTERN = /mso-list\s*:\s*l(\d+)/i;
|
|
13
|
+
/** Extracts the Word list-format override id (`lfo<number>`), unique per list instance. */
|
|
14
|
+
const LIST_OVERRIDE_ID_PATTERN = /\blfo(\d+)/i;
|
|
15
|
+
/** Matches the inner span that holds the Word-rendered bullet / number glyph. */
|
|
16
|
+
const LIST_IGNORE_PATTERN = /mso-list\s*:\s*ignore/i;
|
|
17
|
+
/** Extracts a `font-family` declaration value from a preserved style string. */
|
|
18
|
+
const FONT_FAMILY_PATTERN = /font-family\s*:\s*([^;]+)/i;
|
|
19
|
+
/** Fallback Word list paragraph class when no `mso-list` style is present. */
|
|
20
|
+
const LIST_PARAGRAPH_CLASS_PATTERN = /MsoListParagraph/i;
|
|
21
|
+
/**
|
|
22
|
+
* CSS `list-style-type` values keyed by the shape of the Word marker token.
|
|
23
|
+
* Decimal markers are intentionally absent: a plain `<ol>` already renders as
|
|
24
|
+
* `1. 2. 3.`, so numeric lists keep the current behavior with no inline style.
|
|
25
|
+
*
|
|
26
|
+
* Roman patterns explicitly accept a lone `i` / `I` (representing 1), which is
|
|
27
|
+
* the typical first item of a Roman-numeral list. Multi-character sequences
|
|
28
|
+
* must contain only Roman letters.
|
|
29
|
+
*/
|
|
30
|
+
const LOWER_ROMAN_PATTERN = /^(i|[ivxlcdm]{2,})$/;
|
|
31
|
+
const UPPER_ROMAN_PATTERN = /^(I|[IVXLCDM]{2,})$/;
|
|
32
|
+
const LOWER_ALPHA_PATTERN = /^[a-z]+$/;
|
|
33
|
+
const UPPER_ALPHA_PATTERN = /^[A-Z]+$/;
|
|
34
|
+
const DECIMAL_PATTERN = /^[0-9]+$/;
|
|
35
|
+
/** Extracts the `list-style-type` value from a preserved style string. */
|
|
36
|
+
const LIST_STYLE_TYPE_PATTERN = /list-style-type\s*:\s*([^;]+)/i;
|
|
37
|
+
/**
|
|
38
|
+
* Maps the HTML `<ol type>` attribute values Word emits on real ordered lists
|
|
39
|
+
* to the equivalent CSS `list-style-type`. Decimal (`type=1`) is intentionally
|
|
40
|
+
* absent: a plain `<ol>` already renders as `1. 2. 3.`, so it needs no inline
|
|
41
|
+
* style (matching the marker-derived handling above).
|
|
42
|
+
*/
|
|
43
|
+
const OL_TYPE_TO_LIST_STYLE_TYPE = {
|
|
44
|
+
a: 'lower-alpha',
|
|
45
|
+
A: 'upper-alpha',
|
|
46
|
+
i: 'lower-roman',
|
|
47
|
+
I: 'upper-roman',
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Rebuilds Word list paragraphs into real `<ul>` / `<ol>` / `<li>` structures.
|
|
51
|
+
*
|
|
52
|
+
* Word does not emit list elements: it emits a flat sequence of `<p>` blocks
|
|
53
|
+
* that each carry an `mso-list:l<id> level<depth> lfo<override>` marker plus an
|
|
54
|
+
* inner `mso-list:Ignore` span that renders the visible bullet or number. This
|
|
55
|
+
* transformer walks every container that hosts list paragraphs (so nested
|
|
56
|
+
* `<div>` / table cells are covered), strips the marker span, decides bullet
|
|
57
|
+
* vs. numbered from the marker text / font, and folds the flat items back into
|
|
58
|
+
* a nested list tree the RTE slimmer can parse.
|
|
59
|
+
*
|
|
60
|
+
* Runs before {@link WordParagraphRoleTransformer} so the converted `<li>`
|
|
61
|
+
* elements are no longer seen as paragraphs during role resolution.
|
|
62
|
+
*/
|
|
63
|
+
export class WordListRoleTransformer {
|
|
64
|
+
/** @inheritDoc */
|
|
65
|
+
apply(root) {
|
|
66
|
+
// Word can also emit real `<ol>` / `<ul>` structures where a nested list
|
|
67
|
+
// is a **sibling** of the preceding `<li>` rather than a child of it (an
|
|
68
|
+
// invalid nesting the HTML parser preserves as-is). Fix that first so the
|
|
69
|
+
// rest of the pipeline sees the standard `<li><ol>…</ol></li>` shape.
|
|
70
|
+
this.nestSiblingLists(root);
|
|
71
|
+
// Word may nest list paragraphs inside containers (e.g. `<div>`, table
|
|
72
|
+
// cells). Group by their direct parent so contiguous siblings in each
|
|
73
|
+
// container are folded together, regardless of where they sit in the tree.
|
|
74
|
+
const containers = new Set();
|
|
75
|
+
Array.from(root.querySelectorAll('p')).forEach((paragraph) => {
|
|
76
|
+
if (this.isWordListParagraph(paragraph) && paragraph.parentElement) {
|
|
77
|
+
containers.add(paragraph.parentElement);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// Include the root itself when it hosts list paragraphs directly.
|
|
81
|
+
if (Array.from(root.children).some((child) => this.isWordListParagraph(child))) {
|
|
82
|
+
containers.add(root);
|
|
83
|
+
}
|
|
84
|
+
containers.forEach((container) => this.processContainer(container));
|
|
85
|
+
// Word also emits real `<ol type=...>` elements whose numbering style lives
|
|
86
|
+
// on the (non-allowlisted) `type` attribute. Fold that into a preserved
|
|
87
|
+
// `list-style-type` so the marker style survives the allowlist pass.
|
|
88
|
+
this.applyOrderedListTypeAttributes(root);
|
|
89
|
+
}
|
|
90
|
+
/** @inheritDoc */
|
|
91
|
+
getAllowedTags() {
|
|
92
|
+
return ['UL', 'OL', 'LI'];
|
|
93
|
+
}
|
|
94
|
+
/** @inheritDoc */
|
|
95
|
+
getAllowedAttributes() {
|
|
96
|
+
return new Map();
|
|
97
|
+
}
|
|
98
|
+
/** @inheritDoc */
|
|
99
|
+
getAllowedStyles() {
|
|
100
|
+
return ['list-style'];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Moves any `<ol>` / `<ul>` that appears as a direct child of another
|
|
104
|
+
* `<ol>` / `<ul>` into the preceding `<li>` sibling, so downstream strategies
|
|
105
|
+
* see a well-formed nested list. Word emits this invalid shape when it uses
|
|
106
|
+
* real list elements (rather than flat `mso-list` paragraphs) — the browser
|
|
107
|
+
* parser keeps the nested list as a sibling of the `<li>` it should belong
|
|
108
|
+
* to, and the RTE's OL/UL block strategy would drop it because its
|
|
109
|
+
* `appendChildBlocks` only keeps `<li>` children.
|
|
110
|
+
*
|
|
111
|
+
* Runs bottom-up so a nested list that also has misplaced children is fixed
|
|
112
|
+
* before its own parent list picks it up.
|
|
113
|
+
*
|
|
114
|
+
* @param {HTMLElement} root Parsed body element.
|
|
115
|
+
*/
|
|
116
|
+
nestSiblingLists(root) {
|
|
117
|
+
const lists = Array.from(root.querySelectorAll('ol, ul'));
|
|
118
|
+
for (let index = lists.length - 1; index >= 0; index--) {
|
|
119
|
+
Array.from(lists[index].children).forEach((child) => {
|
|
120
|
+
if (child.tagName !== 'OL' && child.tagName !== 'UL') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const previousItem = child.previousElementSibling;
|
|
124
|
+
if (previousItem && previousItem.tagName === 'LI') {
|
|
125
|
+
previousItem.appendChild(child);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Converts the HTML `<ol type>` attribute into a preserved
|
|
132
|
+
* `list-style-type` declaration for every ordered list that carries one.
|
|
133
|
+
*
|
|
134
|
+
* Word can paste genuine `<ol>` elements (rather than flat list paragraphs)
|
|
135
|
+
* that encode alpha / Roman numbering via the legacy `type` attribute
|
|
136
|
+
* (`type=a`, `type=i`, `type=I`, …). The `type` attribute is not on the
|
|
137
|
+
* allowlist and would be dropped, losing the numbering style, so it is mapped
|
|
138
|
+
* onto `list-style-type` inside `data-style`. Decimal (`type=1`) lists are
|
|
139
|
+
* left untouched because a bare `<ol>` already renders as `1. 2. 3.`. An
|
|
140
|
+
* existing `list-style-type` declaration wins and is never overwritten.
|
|
141
|
+
*
|
|
142
|
+
* @param {HTMLElement} root Parsed body element.
|
|
143
|
+
*/
|
|
144
|
+
applyOrderedListTypeAttributes(root) {
|
|
145
|
+
Array.from(root.querySelectorAll('ol[type]')).forEach((orderedList) => {
|
|
146
|
+
const type = orderedList.getAttribute('type') || '';
|
|
147
|
+
const listStyleType = OL_TYPE_TO_LIST_STYLE_TYPE[type];
|
|
148
|
+
if (!listStyleType) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const style = orderedList.getAttribute('data-style') || '';
|
|
152
|
+
if (LIST_STYLE_TYPE_PATTERN.test(style)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const prefix = style.trim() === '' ? '' : `${style.replace(/;\s*$/, '')}; `;
|
|
156
|
+
orderedList.setAttribute('data-style', `${prefix}list-style-type: ${listStyleType}`);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Walks a container, folding each contiguous run of Word list paragraphs
|
|
161
|
+
* into a nested list tree in place of the original paragraphs.
|
|
162
|
+
*
|
|
163
|
+
* @param {HTMLElement} container Element whose direct children may include list paragraphs.
|
|
164
|
+
*/
|
|
165
|
+
processContainer(container) {
|
|
166
|
+
const children = Array.from(container.children);
|
|
167
|
+
let index = 0;
|
|
168
|
+
while (index < children.length) {
|
|
169
|
+
if (!this.isWordListParagraph(children[index])) {
|
|
170
|
+
index++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const run = [];
|
|
174
|
+
while (index < children.length && this.isWordListParagraph(children[index])) {
|
|
175
|
+
run.push(children[index]);
|
|
176
|
+
index++;
|
|
177
|
+
}
|
|
178
|
+
this.transformRun(run, container);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Determines whether an element is a Word list paragraph.
|
|
183
|
+
*
|
|
184
|
+
* A paragraph is only treated as a list when it carries a genuine Word list
|
|
185
|
+
* marker: either the `mso-list:l<n>` paragraph style, or the `MsoListParagraph`
|
|
186
|
+
* class **together with** an inner `mso-list:Ignore` marker span. The
|
|
187
|
+
* `MsoListParagraph` class alone is not sufficient — Word also uses that
|
|
188
|
+
* paragraph style for plain indented content (e.g. headings), which must not
|
|
189
|
+
* be folded into a `<ul>` / `<ol>`.
|
|
190
|
+
*
|
|
191
|
+
* @param {HTMLElement} element Candidate element.
|
|
192
|
+
* @returns {boolean} `true` when the element is a `<p>` carrying a Word list marker.
|
|
193
|
+
*/
|
|
194
|
+
isWordListParagraph(element) {
|
|
195
|
+
if (element.tagName !== 'P') {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
const style = element.getAttribute('data-style') || '';
|
|
199
|
+
if (PARAGRAPH_LIST_PATTERN.test(style)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
const className = element.getAttribute('class') || '';
|
|
203
|
+
return LIST_PARAGRAPH_CLASS_PATTERN.test(className) && this.findMarker(element) !== undefined;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Folds a flat run of Word list paragraphs into a nested list tree inserted
|
|
207
|
+
* before the run, then removes the original paragraphs.
|
|
208
|
+
*
|
|
209
|
+
* @param {HTMLElement[]} run Consecutive Word list paragraphs.
|
|
210
|
+
* @param {HTMLElement} container Element hosting the run.
|
|
211
|
+
*/
|
|
212
|
+
transformRun(run, container) {
|
|
213
|
+
const anchor = run[0];
|
|
214
|
+
const stack = [];
|
|
215
|
+
run.forEach((paragraph) => {
|
|
216
|
+
// Compute the marker once per paragraph and thread it through the
|
|
217
|
+
// helpers that need it, so the DOM is not re-queried multiple times.
|
|
218
|
+
const marker = this.findMarker(paragraph);
|
|
219
|
+
const level = this.resolveLevel(paragraph);
|
|
220
|
+
const ordered = marker ? this.isOrderedMarker(marker, paragraph) : false;
|
|
221
|
+
const listId = this.resolveListId(paragraph);
|
|
222
|
+
// Close any lists deeper than the current item.
|
|
223
|
+
while (stack.length > 0 && stack[stack.length - 1].level > level) {
|
|
224
|
+
stack.pop();
|
|
225
|
+
}
|
|
226
|
+
// Resolve the marker style with the same-level list already open in
|
|
227
|
+
// context, so an ambiguous lone "i" / "I" continues an alpha list
|
|
228
|
+
// instead of being misread as Roman 1. The marker text is still on the
|
|
229
|
+
// paragraph here (buildListItem strips it below).
|
|
230
|
+
let top = stack[stack.length - 1];
|
|
231
|
+
const listStyleType = ordered && marker ? this.resolveListStyleType(marker, top, level, listId) : null;
|
|
232
|
+
const listItem = this.buildListItem(paragraph, marker);
|
|
233
|
+
if (!top || top.level < level) {
|
|
234
|
+
top = this.openNestedList(stack, container, anchor, ordered, level, listStyleType, listId);
|
|
235
|
+
}
|
|
236
|
+
else if (this.needsSiblingList(top, ordered, listStyleType, listId)) {
|
|
237
|
+
top = this.openSiblingList(stack, ordered, level, listStyleType, listId);
|
|
238
|
+
}
|
|
239
|
+
top.listEl.appendChild(listItem);
|
|
240
|
+
});
|
|
241
|
+
run.forEach((paragraph) => paragraph.remove());
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Reports whether a same-level item must break out into a new sibling list.
|
|
245
|
+
* A different Word list instance always splits (so two separate lists pasted
|
|
246
|
+
* back-to-back keep independent numbering). Bullet-vs-numbered switches also
|
|
247
|
+
* split, and numbered lists additionally split when the CSS `list-style-type`
|
|
248
|
+
* changes (e.g. `1.` → `a)`).
|
|
249
|
+
*
|
|
250
|
+
* @param {OpenList} top Currently open list at the same nesting depth.
|
|
251
|
+
* @param {boolean} ordered Whether the incoming item is numbered.
|
|
252
|
+
* @param {string | null} listStyleType Incoming numbered list style, if any.
|
|
253
|
+
* @param {string | null} listId Incoming Word list instance id, if any.
|
|
254
|
+
* @returns {boolean} `true` when a new sibling list should be opened.
|
|
255
|
+
*/
|
|
256
|
+
needsSiblingList(top, ordered, listStyleType, listId) {
|
|
257
|
+
// A known change of list instance means the two runs are distinct lists.
|
|
258
|
+
if (top.listId !== null && listId !== null && top.listId !== listId) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
if (top.ordered !== ordered) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
if (!ordered) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return this.readListStyleType(top.listEl) !== listStyleType;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Reads a previously-written `list-style-type` from an open list element.
|
|
271
|
+
*
|
|
272
|
+
* @param {HTMLElement} listEl List element.
|
|
273
|
+
* @returns {string | null} The style value, or `null` when none is set.
|
|
274
|
+
*/
|
|
275
|
+
readListStyleType(listEl) {
|
|
276
|
+
const match = LIST_STYLE_TYPE_PATTERN.exec(listEl.getAttribute('data-style') || '');
|
|
277
|
+
return match ? match[1].trim() : null;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Opens a new list nested one or more levels deeper than the current top.
|
|
281
|
+
* Word occasionally skips indent levels on paste (e.g. jumping from `level1`
|
|
282
|
+
* to `level3`); this walks the gap one level at a time, inserting placeholder
|
|
283
|
+
* lists so the deeper list is nested through empty `<li>` anchors instead of
|
|
284
|
+
* appearing as a sibling of the shallower list.
|
|
285
|
+
*
|
|
286
|
+
* @param {OpenList[]} stack Stack of currently open lists.
|
|
287
|
+
* @param {HTMLElement} container Host element for the top-level list.
|
|
288
|
+
* @param {HTMLElement} anchor Element the top-level list is inserted before.
|
|
289
|
+
* @param {boolean} ordered Whether the new list is numbered.
|
|
290
|
+
* @param {number} level Word nesting depth for the new list.
|
|
291
|
+
* @param {string | null} listStyleType CSS `list-style-type` for ordered lists.
|
|
292
|
+
* @param {string | null} listId Word list instance id for the new list.
|
|
293
|
+
* @returns {OpenList} The newly opened list.
|
|
294
|
+
*/
|
|
295
|
+
openNestedList(stack, container, anchor, ordered, level, listStyleType, listId) {
|
|
296
|
+
let currentTop = stack[stack.length - 1];
|
|
297
|
+
let currentLevel = currentTop ? currentTop.level : 0;
|
|
298
|
+
while (currentLevel < level - 1) {
|
|
299
|
+
const bridge = this.createListElement(container, ordered, null);
|
|
300
|
+
this.attachList(bridge, currentTop, container, anchor);
|
|
301
|
+
// Empty `<li>` anchor so the next deeper list can be nested inside it.
|
|
302
|
+
bridge.appendChild(bridge.ownerDocument.createElement('li'));
|
|
303
|
+
stack.push({ level: currentLevel + 1, ordered, listId, listEl: bridge });
|
|
304
|
+
currentTop = stack[stack.length - 1];
|
|
305
|
+
currentLevel = currentTop.level;
|
|
306
|
+
}
|
|
307
|
+
const parent = stack[stack.length - 1];
|
|
308
|
+
const listEl = this.createListElement(container, ordered, listStyleType);
|
|
309
|
+
this.attachList(listEl, parent, container, anchor);
|
|
310
|
+
const opened = { level, ordered, listId, listEl };
|
|
311
|
+
stack.push(opened);
|
|
312
|
+
return opened;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Replaces the current top list with a sibling list at the same nesting
|
|
316
|
+
* depth. Used when the list flavor (bullet vs. numbered, or the ordered
|
|
317
|
+
* marker style) flips between two consecutive same-level items.
|
|
318
|
+
*
|
|
319
|
+
* @param {OpenList[]} stack Stack of currently open lists.
|
|
320
|
+
* @param {boolean} ordered Whether the sibling list is numbered.
|
|
321
|
+
* @param {number} level Word nesting depth for the sibling list.
|
|
322
|
+
* @param {string | null} listStyleType CSS `list-style-type` for ordered lists.
|
|
323
|
+
* @param {string | null} listId Word list instance id for the sibling list.
|
|
324
|
+
* @returns {OpenList} The newly opened sibling list.
|
|
325
|
+
*/
|
|
326
|
+
openSiblingList(stack, ordered, level, listStyleType, listId) {
|
|
327
|
+
const current = stack[stack.length - 1];
|
|
328
|
+
const listEl = this.createListElement(current.listEl, ordered, listStyleType);
|
|
329
|
+
const parentNode = current.listEl.parentNode;
|
|
330
|
+
if (parentNode) {
|
|
331
|
+
parentNode.insertBefore(listEl, current.listEl.nextSibling);
|
|
332
|
+
}
|
|
333
|
+
stack.pop();
|
|
334
|
+
const opened = { level, ordered, listId, listEl };
|
|
335
|
+
stack.push(opened);
|
|
336
|
+
return opened;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Attaches a freshly created list element either inside the last item of the
|
|
340
|
+
* parent list (for nested lists) or before the run anchor (top-level lists).
|
|
341
|
+
*
|
|
342
|
+
* @param {HTMLElement} listEl List element to attach.
|
|
343
|
+
* @param {OpenList | undefined} parent Currently open parent list, if any.
|
|
344
|
+
* @param {HTMLElement} container Host element used for top-level insertion.
|
|
345
|
+
* @param {HTMLElement} anchor Element the top-level list is inserted before.
|
|
346
|
+
*/
|
|
347
|
+
attachList(listEl, parent, container, anchor) {
|
|
348
|
+
if (parent) {
|
|
349
|
+
const parentItem = parent.listEl.lastElementChild;
|
|
350
|
+
(parentItem || parent.listEl).appendChild(listEl);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
container.insertBefore(listEl, anchor);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Creates an empty `<ol>` or `<ul>` element, tagging ordered lists with a
|
|
358
|
+
* `list-style-type` when their markers are not plain decimals.
|
|
359
|
+
*
|
|
360
|
+
* @param {HTMLElement} reference Element whose document creates the list.
|
|
361
|
+
* @param {boolean} ordered Whether to create a numbered list.
|
|
362
|
+
* @param {string | null} listStyleType CSS `list-style-type` for ordered lists.
|
|
363
|
+
* @returns {HTMLElement} The new list element.
|
|
364
|
+
*/
|
|
365
|
+
createListElement(reference, ordered, listStyleType) {
|
|
366
|
+
const listEl = reference.ownerDocument.createElement(ordered ? 'ol' : 'ul');
|
|
367
|
+
if (ordered && listStyleType) {
|
|
368
|
+
// Styles are preserved as `data-style` across the DOMParser boundary and
|
|
369
|
+
// restored to `style` after the allowlist pass.
|
|
370
|
+
listEl.setAttribute('data-style', `list-style-type: ${listStyleType}`);
|
|
371
|
+
}
|
|
372
|
+
return listEl;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Converts a Word list paragraph into an `<li>` element: the marker span is
|
|
376
|
+
* removed and the remaining content is moved into the list item.
|
|
377
|
+
*
|
|
378
|
+
* @param {HTMLElement} paragraph Word list paragraph.
|
|
379
|
+
* @param {HTMLElement | undefined} marker Pre-resolved `mso-list:Ignore` span.
|
|
380
|
+
* @returns {HTMLLIElement} The populated list item.
|
|
381
|
+
*/
|
|
382
|
+
buildListItem(paragraph, marker) {
|
|
383
|
+
const listItem = paragraph.ownerDocument.createElement('li');
|
|
384
|
+
if (marker) {
|
|
385
|
+
this.preserveMarkerPlaceholderImages(marker, paragraph);
|
|
386
|
+
this.removeMarker(marker, paragraph);
|
|
387
|
+
}
|
|
388
|
+
while (paragraph.firstChild) {
|
|
389
|
+
listItem.appendChild(paragraph.firstChild);
|
|
390
|
+
}
|
|
391
|
+
return listItem;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Moves any local (`file://`) images out of the marker span so they survive
|
|
395
|
+
* marker removal as list-item placeholders.
|
|
396
|
+
*
|
|
397
|
+
* Word renders a picture bullet as an `<img>` inside the `mso-list:Ignore`
|
|
398
|
+
* marker span. That bullet still occupies one image slot in the clipboard RTF,
|
|
399
|
+
* so silently dropping it here would leave its RTF blip unconsumed and shift
|
|
400
|
+
* every following image onto the wrong file. Keeping the bullet as a `file://`
|
|
401
|
+
* placeholder inside the `<li>` lets downstream preview pairing consume its RTF
|
|
402
|
+
* slot and then drop it (list images have no editor representation), keeping the
|
|
403
|
+
* remaining images aligned with their files. Non-local bullet images have no RTF
|
|
404
|
+
* counterpart and are left in the marker to be removed with it.
|
|
405
|
+
*
|
|
406
|
+
* @param {HTMLElement} marker Marker span holding the bullet glyph / image.
|
|
407
|
+
* @param {HTMLElement} paragraph Owning list paragraph (placeholder host).
|
|
408
|
+
*/
|
|
409
|
+
preserveMarkerPlaceholderImages(marker, paragraph) {
|
|
410
|
+
const localImages = Array.from(marker.querySelectorAll('img')).filter((image) => (image.getAttribute('src') || '').startsWith('file://'));
|
|
411
|
+
// Capture the original first child once so images land ahead of the list
|
|
412
|
+
// content in their document order (repeated inserts before a stable anchor).
|
|
413
|
+
const anchor = paragraph.firstChild;
|
|
414
|
+
localImages.forEach((image) => {
|
|
415
|
+
paragraph.insertBefore(image, anchor);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Removes the `mso-list:Ignore` marker span and any wrapper elements it
|
|
420
|
+
* leaves empty behind.
|
|
421
|
+
*
|
|
422
|
+
* @param {HTMLElement} marker Marker span to remove.
|
|
423
|
+
* @param {HTMLElement} paragraph Owning list paragraph (stop boundary).
|
|
424
|
+
*/
|
|
425
|
+
removeMarker(marker, paragraph) {
|
|
426
|
+
let current = marker;
|
|
427
|
+
while (current !== paragraph) {
|
|
428
|
+
const parent = current.parentElement;
|
|
429
|
+
current.remove();
|
|
430
|
+
if (!parent || parent === paragraph || !this.isEmptyElement(parent)) {
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
current = parent;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Finds the `mso-list:Ignore` marker span within a list paragraph.
|
|
438
|
+
*
|
|
439
|
+
* @param {HTMLElement} paragraph Word list paragraph.
|
|
440
|
+
* @returns {HTMLElement | undefined} The marker span, if present.
|
|
441
|
+
*/
|
|
442
|
+
findMarker(paragraph) {
|
|
443
|
+
return Array.from(paragraph.querySelectorAll('span')).find((span) => LIST_IGNORE_PATTERN.test(span.getAttribute('data-style') || ''));
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Reports whether an element has no meaningful (non-whitespace) content left.
|
|
447
|
+
*
|
|
448
|
+
* @param {HTMLElement} element Element to inspect.
|
|
449
|
+
* @returns {boolean} `true` when only whitespace remains.
|
|
450
|
+
*/
|
|
451
|
+
isEmptyElement(element) {
|
|
452
|
+
return (element.textContent || '').replace(/[\s\u00A0]/g, '') === '';
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Resolves the Word nesting depth for a list paragraph (defaults to 1).
|
|
456
|
+
*
|
|
457
|
+
* @param {HTMLElement} paragraph Word list paragraph.
|
|
458
|
+
* @returns {number} One-based nesting depth.
|
|
459
|
+
*/
|
|
460
|
+
resolveLevel(paragraph) {
|
|
461
|
+
const style = paragraph.getAttribute('data-style') || '';
|
|
462
|
+
const match = LIST_LEVEL_PATTERN.exec(style);
|
|
463
|
+
return match ? parseInt(match[1], 10) : 1;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Resolves the Word list instance id for a paragraph. Prefers the list-format
|
|
467
|
+
* override (`lfo<n>`), which is unique per pasted list, and falls back to the
|
|
468
|
+
* abstract list template id (`l<n>`). Returns `null` when neither is present
|
|
469
|
+
* (e.g. the `MsoListParagraph` class fallback).
|
|
470
|
+
*
|
|
471
|
+
* @param {HTMLElement} paragraph Word list paragraph.
|
|
472
|
+
* @returns {string | null} The list instance id, or `null` when unknown.
|
|
473
|
+
*/
|
|
474
|
+
resolveListId(paragraph) {
|
|
475
|
+
const style = paragraph.getAttribute('data-style') || '';
|
|
476
|
+
const override = LIST_OVERRIDE_ID_PATTERN.exec(style);
|
|
477
|
+
if (override) {
|
|
478
|
+
return `lfo${override[1]}`;
|
|
479
|
+
}
|
|
480
|
+
const template = LIST_TEMPLATE_ID_PATTERN.exec(style);
|
|
481
|
+
return template ? `l${template[1]}` : null;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Decides whether a resolved marker span represents a numbered (`<ol>`) or
|
|
485
|
+
* bulleted (`<ul>`) item based on its text and font.
|
|
486
|
+
*
|
|
487
|
+
* @param {HTMLElement} marker Marker span.
|
|
488
|
+
* @param {HTMLElement} paragraph Owning list paragraph.
|
|
489
|
+
* @returns {boolean} `true` for numbered items, `false` for bulleted items.
|
|
490
|
+
*/
|
|
491
|
+
isOrderedMarker(marker, paragraph) {
|
|
492
|
+
const markerText = marker.textContent.replace(/[\s\u00A0]/g, '');
|
|
493
|
+
if (BULLET_FONT_PATTERN.test(this.resolveMarkerFont(marker, paragraph))) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
// Numbered markers are alphanumeric sequences ("1.", "a)", "iv)");
|
|
497
|
+
// bullet markers are standalone symbols.
|
|
498
|
+
return /[0-9]/.test(markerText) || /^[a-z]+[.)]/i.test(markerText);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Resolves the CSS `list-style-type` for a numbered list marker.
|
|
502
|
+
* Plain decimal markers ("1.", "2.") return `null` so a bare `<ol>` is used;
|
|
503
|
+
* alphabetic and Roman markers map to the matching CSS value so their marker
|
|
504
|
+
* style is preserved.
|
|
505
|
+
*
|
|
506
|
+
* A lone `i` / `I` is ambiguous: it is both Roman numeral 1 and the 9th
|
|
507
|
+
* letter of the alphabet. When the same-level list already open for this
|
|
508
|
+
* instance is alpha, the marker is kept alpha so a long `a) ... h) i) j)`
|
|
509
|
+
* run does not split into a Roman sibling at item 9; otherwise the lone
|
|
510
|
+
* marker is treated as Roman 1 (the first item of a Roman list).
|
|
511
|
+
*
|
|
512
|
+
* @param {HTMLElement} marker Marker span.
|
|
513
|
+
* @param {OpenList | undefined} openList Same-depth list already open, if any.
|
|
514
|
+
* @param {number} level Word nesting depth of the incoming item.
|
|
515
|
+
* @param {string | null} listId Word list instance id of the incoming item.
|
|
516
|
+
* @returns {string | null} The CSS `list-style-type`, or `null` for decimals.
|
|
517
|
+
*/
|
|
518
|
+
resolveListStyleType(marker, openList, level, listId) {
|
|
519
|
+
// Drop surrounding whitespace and the trailing "." / ")" separator to
|
|
520
|
+
// isolate the numbering token (e.g. "a)" -> "a", "iv." -> "iv").
|
|
521
|
+
const token = marker.textContent.replace(/[\s\u00A0]/g, '').replace(/[.)]+$/, '');
|
|
522
|
+
if (DECIMAL_PATTERN.test(token)) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
// Disambiguate a lone "i" / "I" from list context before the Roman check:
|
|
526
|
+
// if the current same-level list is already alpha, continue it.
|
|
527
|
+
if (token === 'i' || token === 'I') {
|
|
528
|
+
const alphaStyle = token === 'i' ? 'lower-alpha' : 'upper-alpha';
|
|
529
|
+
if (this.continuesAlphaList(openList, level, listId, alphaStyle)) {
|
|
530
|
+
return alphaStyle;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
// Roman tokens are checked before alpha so "i" / "I" (Roman numeral 1) and
|
|
534
|
+
// multi-character sequences like "ii" / "IV" are not mistaken for letters.
|
|
535
|
+
if (LOWER_ROMAN_PATTERN.test(token)) {
|
|
536
|
+
return 'lower-roman';
|
|
537
|
+
}
|
|
538
|
+
if (UPPER_ROMAN_PATTERN.test(token)) {
|
|
539
|
+
return 'upper-roman';
|
|
540
|
+
}
|
|
541
|
+
if (LOWER_ALPHA_PATTERN.test(token)) {
|
|
542
|
+
return 'lower-alpha';
|
|
543
|
+
}
|
|
544
|
+
if (UPPER_ALPHA_PATTERN.test(token)) {
|
|
545
|
+
return 'upper-alpha';
|
|
546
|
+
}
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Reports whether a lone `i` / `I` marker continues an already-open alpha
|
|
551
|
+
* list rather than starting a Roman one. True only when the same-depth list
|
|
552
|
+
* is a matching alpha `<ol>` for the same Word list instance, so an ambiguous
|
|
553
|
+
* marker at item 9 stays part of the surrounding `lower-alpha` / `upper-alpha`
|
|
554
|
+
* run instead of opening a Roman sibling.
|
|
555
|
+
*
|
|
556
|
+
* @param {OpenList | undefined} openList Same-depth list already open, if any.
|
|
557
|
+
* @param {number} level Word nesting depth of the incoming item.
|
|
558
|
+
* @param {string | null} listId Word list instance id of the incoming item.
|
|
559
|
+
* @param {string} alphaStyle The alpha style the marker would continue.
|
|
560
|
+
* @returns {boolean} `true` when the marker should be treated as alpha.
|
|
561
|
+
*/
|
|
562
|
+
continuesAlphaList(openList, level, listId, alphaStyle) {
|
|
563
|
+
if (!openList || !openList.ordered || openList.level !== level) {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
// Distinct Word list instances are separate lists; do not carry style over.
|
|
567
|
+
if (openList.listId !== null && listId !== null && openList.listId !== listId) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
return this.readListStyleType(openList.listEl) === alphaStyle;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Resolves the effective `font-family` for a marker by walking up to the
|
|
574
|
+
* paragraph, so Word's `Symbol` / `Wingdings` bullet fonts can be detected.
|
|
575
|
+
*
|
|
576
|
+
* @param {HTMLElement} marker Marker span.
|
|
577
|
+
* @param {HTMLElement} paragraph Owning list paragraph.
|
|
578
|
+
* @returns {string} The resolved font family, or an empty string.
|
|
579
|
+
*/
|
|
580
|
+
resolveMarkerFont(marker, paragraph) {
|
|
581
|
+
let node = marker;
|
|
582
|
+
while (node && node !== paragraph.parentElement) {
|
|
583
|
+
const match = FONT_FAMILY_PATTERN.exec(node.getAttribute('data-style') || '');
|
|
584
|
+
if (match) {
|
|
585
|
+
return match[1];
|
|
586
|
+
}
|
|
587
|
+
node = node.parentElement;
|
|
588
|
+
}
|
|
589
|
+
return '';
|
|
590
|
+
}
|
|
591
|
+
}
|