@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,112 @@
|
|
|
1
|
+
import { WORD_SANITIZE_ALL_TAGS_KEY } from './word-structure-transformer';
|
|
2
|
+
/** CSS class prefix used by the RTE to encode text-style roles on elements. */
|
|
3
|
+
const RTE_TEXT_STYLE_CLASS_PREFIX = 'v-rte--text-style-';
|
|
4
|
+
/**
|
|
5
|
+
* Maps Word title / subtitle / heading paragraph style class names onto RTE
|
|
6
|
+
* CSS text-style classes. Any pre-existing `data-type` attributes are stripped
|
|
7
|
+
* first so only trusted values remain. Using a class instead of a custom
|
|
8
|
+
* attribute prevents the value from leaking into the DTO's custom-attribute
|
|
9
|
+
* annotation and subsequently into the serialized HTML output.
|
|
10
|
+
*/
|
|
11
|
+
export class WordParagraphRoleTransformer {
|
|
12
|
+
/** @inheritDoc */
|
|
13
|
+
apply(root) {
|
|
14
|
+
// Strip any pre-existing data-type attributes so untrusted source values
|
|
15
|
+
// can never influence the role resolution.
|
|
16
|
+
Array.from(root.querySelectorAll('[data-type]')).forEach((element) => {
|
|
17
|
+
element.removeAttribute('data-type');
|
|
18
|
+
});
|
|
19
|
+
Array.from(root.querySelectorAll('p')).forEach((paragraph) => {
|
|
20
|
+
const rawClass = paragraph.getAttribute('class');
|
|
21
|
+
const role = this.resolveRole(rawClass);
|
|
22
|
+
// Drop the Word paragraph class once its role has been extracted so
|
|
23
|
+
// that Word artifacts (e.g. `MsoTitle`, `MsoNormal`) never leak into
|
|
24
|
+
// the sanitized output.
|
|
25
|
+
if (rawClass !== null) {
|
|
26
|
+
paragraph.removeAttribute('class');
|
|
27
|
+
}
|
|
28
|
+
if (role) {
|
|
29
|
+
// Encode the role as an RTE text-style CSS class so the downstream
|
|
30
|
+
// DTO processor can resolve it via getElementTypeByClassName().
|
|
31
|
+
paragraph.classList.add(`${RTE_TEXT_STYLE_CLASS_PREFIX}${role}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** @inheritDoc */
|
|
36
|
+
getAllowedTags() {
|
|
37
|
+
return [
|
|
38
|
+
'P',
|
|
39
|
+
'BR',
|
|
40
|
+
'SPAN',
|
|
41
|
+
'STRONG',
|
|
42
|
+
'B',
|
|
43
|
+
'EM',
|
|
44
|
+
'I',
|
|
45
|
+
'U',
|
|
46
|
+
'S',
|
|
47
|
+
'STRIKE',
|
|
48
|
+
'DEL',
|
|
49
|
+
'H1',
|
|
50
|
+
'H2',
|
|
51
|
+
'H3',
|
|
52
|
+
'H4',
|
|
53
|
+
'H5',
|
|
54
|
+
'H6',
|
|
55
|
+
'A',
|
|
56
|
+
// Inline `<code>` is treated as an inline text annotation (like
|
|
57
|
+
// STRONG/EM/U) and therefore lives with the paragraph/inline
|
|
58
|
+
// allowlist. Block-level `<pre>` code blocks are owned by
|
|
59
|
+
// {@link WordCodeBlockTransformer}.
|
|
60
|
+
'CODE',
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
/** @inheritDoc */
|
|
64
|
+
getAllowedAttributes() {
|
|
65
|
+
// `class` must be preserved so this transformer can parse Word paragraph
|
|
66
|
+
// roles (e.g., MsoTitle, MsoSubtitle, MsoHeadingN) in Phase 1. These classes
|
|
67
|
+
// are ultimately stripped when pasting in autoMatchFormat mode.
|
|
68
|
+
return new Map([
|
|
69
|
+
[WORD_SANITIZE_ALL_TAGS_KEY, ['class', 'style']],
|
|
70
|
+
['A', ['href', 'target', 'title']],
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
/** @inheritDoc */
|
|
74
|
+
getAllowedStyles() {
|
|
75
|
+
return [
|
|
76
|
+
'color',
|
|
77
|
+
'background',
|
|
78
|
+
'text-align',
|
|
79
|
+
'text-indent',
|
|
80
|
+
'text-decoration',
|
|
81
|
+
'margin',
|
|
82
|
+
'padding',
|
|
83
|
+
'font',
|
|
84
|
+
'line-height',
|
|
85
|
+
'letter-spacing',
|
|
86
|
+
'vertical-align',
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolves the RTE text style for a Word paragraph class name.
|
|
91
|
+
*
|
|
92
|
+
* @param {string | null} className Raw `class` attribute value.
|
|
93
|
+
* @returns {WordParagraphRole | null} Matched role or `null`.
|
|
94
|
+
*/
|
|
95
|
+
resolveRole(className) {
|
|
96
|
+
if (!className) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const normalized = className.toLowerCase();
|
|
100
|
+
const headingMatch = /msoheading([1-6])/.exec(normalized);
|
|
101
|
+
if (headingMatch) {
|
|
102
|
+
return `heading-${headingMatch[1]}`;
|
|
103
|
+
}
|
|
104
|
+
if (/msosubtitle/.test(normalized)) {
|
|
105
|
+
return 'subtitle';
|
|
106
|
+
}
|
|
107
|
+
if (/msotitle/.test(normalized)) {
|
|
108
|
+
return 'title';
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute that carries inline styles after `StylePreservator` renamed `style`
|
|
3
|
+
* to `data-style`. All style reads/writes in Phase 1 target this name so the
|
|
4
|
+
* declarations survive the CSP-sensitive `DOMParser` boundary (mirrors the
|
|
5
|
+
* handling in {@link WordListRoleTransformer}).
|
|
6
|
+
*/
|
|
7
|
+
const PRESERVED_STYLE_ATTR = 'data-style';
|
|
8
|
+
/** Table structural tags Word decorates with `Mso*` class artifacts. */
|
|
9
|
+
const TABLE_SECTION_SELECTOR = 'thead, tbody, tfoot, caption, tr';
|
|
10
|
+
/**
|
|
11
|
+
* Table containers whose direct text children are always layout whitespace.
|
|
12
|
+
* Word exports newlines and indentation between structural tags; those text
|
|
13
|
+
* nodes are not valid table content and must be dropped so they do not surface
|
|
14
|
+
* as stray spaces in the pasted table.
|
|
15
|
+
*/
|
|
16
|
+
const TABLE_CONTAINER_SELECTOR = 'thead, tbody, tfoot, tr';
|
|
17
|
+
/** Cell tags that may carry Word presentational attributes and span markers. */
|
|
18
|
+
const TABLE_CELL_SELECTOR = 'td, th';
|
|
19
|
+
/**
|
|
20
|
+
* Block-level tags that mark a cell as containing block content. When a cell
|
|
21
|
+
* holds one of these, any whitespace-only text node sitting beside it is Word
|
|
22
|
+
* indentation (layout whitespace) rather than meaningful inline text.
|
|
23
|
+
*/
|
|
24
|
+
const CELL_BLOCK_CHILD_TAGS = new Set([
|
|
25
|
+
'P',
|
|
26
|
+
'DIV',
|
|
27
|
+
'UL',
|
|
28
|
+
'OL',
|
|
29
|
+
'LI',
|
|
30
|
+
'H1',
|
|
31
|
+
'H2',
|
|
32
|
+
'H3',
|
|
33
|
+
'H4',
|
|
34
|
+
'H5',
|
|
35
|
+
'H6',
|
|
36
|
+
'TABLE',
|
|
37
|
+
'BLOCKQUOTE',
|
|
38
|
+
'PRE',
|
|
39
|
+
]);
|
|
40
|
+
/** Span attributes whose value must be a positive integer greater than one. */
|
|
41
|
+
const SPAN_ATTRIBUTES = ['colspan', 'rowspan'];
|
|
42
|
+
/** Strict span values Word should emit after normalization. */
|
|
43
|
+
const SPAN_VALUE_PATTERN = /^\d+$/;
|
|
44
|
+
/**
|
|
45
|
+
* Matches the border box-model declarations (shorthand, per-side, and the
|
|
46
|
+
* width/style/color long-hands) that Word writes with point/centimeter units
|
|
47
|
+
* and system color keywords the RTE table model cannot parse. Word also emits
|
|
48
|
+
* per-side `border-*: none` resets to avoid double borders in its own layout,
|
|
49
|
+
* which would leave the pasted table with inconsistent cell borders. All of
|
|
50
|
+
* these are removed so the editor applies its uniform default border.
|
|
51
|
+
* `border-collapse` / `border-spacing` are intentionally excluded so table
|
|
52
|
+
* collapsing is preserved.
|
|
53
|
+
*/
|
|
54
|
+
const BORDER_BOX_STYLE_PATTERN = /^border(-(top|right|bottom|left))?(-(width|style|color))?$/;
|
|
55
|
+
/**
|
|
56
|
+
* Matches padding declarations (shorthand and per-side) that Word writes with
|
|
57
|
+
* point/centimeter units the RTE cannot parse. Removed so the editor applies
|
|
58
|
+
* its default cell padding.
|
|
59
|
+
*/
|
|
60
|
+
const PADDING_STYLE_PATTERN = /^padding(-(top|right|bottom|left))?$/;
|
|
61
|
+
/**
|
|
62
|
+
* Matches the standalone `width` declaration (not `min-width` / `max-width`).
|
|
63
|
+
* Word writes cell widths in points, so the point-based declaration is removed
|
|
64
|
+
* and replaced with the clean pixel value carried by the `width` attribute.
|
|
65
|
+
*/
|
|
66
|
+
const WIDTH_STYLE_PATTERN = /^width$/;
|
|
67
|
+
/** Numeric zero (with optional decimal and optional unit suffix). */
|
|
68
|
+
const ZERO_LENGTH_PATTERN = /^0+(\.0+)?([a-z%]+)?$/i;
|
|
69
|
+
/**
|
|
70
|
+
* Maps Word cell presentational attributes onto the CSS declarations the RTE
|
|
71
|
+
* table cell annotation understands. These attributes are not on the paste
|
|
72
|
+
* allowlist, so migrating them into `data-style` is the only way to preserve
|
|
73
|
+
* the author's intent (shading, alignment) through sanitization. Only
|
|
74
|
+
* properties whose prefix is retained by the sanitizer are migrated, so
|
|
75
|
+
* fixed-width/height artifacts are intentionally dropped.
|
|
76
|
+
*/
|
|
77
|
+
const CELL_ATTRIBUTE_STYLE_MAP = [
|
|
78
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
79
|
+
{ attribute: 'valign', property: 'vertical-align' },
|
|
80
|
+
{ attribute: 'align', property: 'text-align' },
|
|
81
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
82
|
+
{ attribute: 'bgcolor', property: 'background-color' },
|
|
83
|
+
];
|
|
84
|
+
/**
|
|
85
|
+
* Normalizes Microsoft Word table markup into clean, RTE-friendly tables.
|
|
86
|
+
*
|
|
87
|
+
* Word emits real `<table>/<tr>/<td>` elements, so the paste allowlist already
|
|
88
|
+
* keeps the structure. What it cannot fix is the Word-specific decoration that
|
|
89
|
+
* rides along:
|
|
90
|
+
* - `Mso*` class names (e.g. `MsoTableGrid`) survive because `class` is globally
|
|
91
|
+
* allowed; they are Word artifacts and must not leak into the output.
|
|
92
|
+
* - Cell shading and alignment live in presentational attributes (`bgcolor`,
|
|
93
|
+
* `align`, `valign`) that the allowlist strips, losing the formatting; they
|
|
94
|
+
* are migrated into `data-style` so the RTE cell annotation can read them.
|
|
95
|
+
* - `colspan`/`rowspan` may carry redundant `1` values or non-numeric junk that
|
|
96
|
+
* is normalized so span tables map cleanly onto the RTE table model.
|
|
97
|
+
* - Table and cell borders/padding are written with point/centimeter units,
|
|
98
|
+
* system color keywords, and per-side `border-*: none` resets that the RTE
|
|
99
|
+
* cannot parse and that render inconsistent borders; they are stripped so the
|
|
100
|
+
* editor applies its uniform default border and padding.
|
|
101
|
+
* - Cell widths arrive both as a point-based `width` style (which the RTE cannot
|
|
102
|
+
* parse) and a pixel `width` attribute; the point style is dropped and the
|
|
103
|
+
* attribute is migrated into a clean pixel `width` declaration.
|
|
104
|
+
*/
|
|
105
|
+
export class WordTableTransformer {
|
|
106
|
+
/** @inheritDoc */
|
|
107
|
+
apply(root) {
|
|
108
|
+
Array.from(root.querySelectorAll('table')).forEach((table) => this.normalizeTable(table));
|
|
109
|
+
}
|
|
110
|
+
/** @inheritDoc */
|
|
111
|
+
getAllowedTags() {
|
|
112
|
+
return ['TABLE', 'THEAD', 'TBODY', 'TR', 'TH', 'TD', 'CAPTION'];
|
|
113
|
+
}
|
|
114
|
+
/** @inheritDoc */
|
|
115
|
+
getAllowedAttributes() {
|
|
116
|
+
return new Map([
|
|
117
|
+
['TD', ['colspan', 'rowspan']],
|
|
118
|
+
['TH', ['colspan', 'rowspan']],
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
/** @inheritDoc */
|
|
122
|
+
getAllowedStyles() {
|
|
123
|
+
return ['border', 'width'];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Strips Word class artifacts from a table and its structural descendants,
|
|
127
|
+
* then normalizes every cell's span attributes and presentational styling.
|
|
128
|
+
*
|
|
129
|
+
* @param {HTMLTableElement} table Word table element to normalize in place.
|
|
130
|
+
*/
|
|
131
|
+
normalizeTable(table) {
|
|
132
|
+
this.removeStructuralWhitespace(table);
|
|
133
|
+
this.stripClass(table);
|
|
134
|
+
this.removeBorderAndPaddingStyles(table);
|
|
135
|
+
Array.from(table.querySelectorAll(TABLE_SECTION_SELECTOR)).forEach((section) => this.stripClass(section));
|
|
136
|
+
this.removeHiddenMisalignedCells(table);
|
|
137
|
+
this.mergeFooterIntoBody(table);
|
|
138
|
+
this.promoteHeadCells(table);
|
|
139
|
+
Array.from(table.querySelectorAll(TABLE_CELL_SELECTOR)).forEach((cell) => {
|
|
140
|
+
this.removeCellLayoutWhitespace(cell);
|
|
141
|
+
this.stripClass(cell);
|
|
142
|
+
this.normalizeSpanAttributes(cell);
|
|
143
|
+
this.migrateCellAttributes(cell);
|
|
144
|
+
this.migrateCellWidth(cell);
|
|
145
|
+
this.removeBorderAndPaddingStyles(cell);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Removes Word's hidden `!supportMisalignedRows` placeholder cell. Word
|
|
150
|
+
* appends it as a zero-width trailing cell to keep legacy layout engines
|
|
151
|
+
* aligned, but it is not real content and should not survive paste as an
|
|
152
|
+
* extra visible column. Only the row's last cell is considered so an
|
|
153
|
+
* intentional interior zero-width cell is never dropped, and only rows that
|
|
154
|
+
* belong to this table (not a nested one) are touched.
|
|
155
|
+
*
|
|
156
|
+
* @param {HTMLTableElement} table Word table element.
|
|
157
|
+
*/
|
|
158
|
+
removeHiddenMisalignedCells(table) {
|
|
159
|
+
Array.from(table.querySelectorAll('tr'))
|
|
160
|
+
.filter((row) => this.isRowOfTable(table, row))
|
|
161
|
+
.forEach((row) => {
|
|
162
|
+
const lastCell = row.lastElementChild;
|
|
163
|
+
if (lastCell &&
|
|
164
|
+
(lastCell.tagName === 'TD' || lastCell.tagName === 'TH') &&
|
|
165
|
+
this.isHiddenMisalignedCell(lastCell)) {
|
|
166
|
+
row.removeChild(lastCell);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Reports whether a row belongs directly to the given table rather than to a
|
|
172
|
+
* nested table, so the recursive `tr` query never reaches into a child table.
|
|
173
|
+
*
|
|
174
|
+
* @param {HTMLTableElement} table Table being normalized.
|
|
175
|
+
* @param {HTMLTableRowElement} row Row to test.
|
|
176
|
+
* @returns {boolean} `true` when the row's nearest ancestor table is `table`.
|
|
177
|
+
*/
|
|
178
|
+
isRowOfTable(table, row) {
|
|
179
|
+
let ancestor = row.parentElement;
|
|
180
|
+
while (ancestor && ancestor.tagName !== 'BODY') {
|
|
181
|
+
if (ancestor.tagName === 'TABLE') {
|
|
182
|
+
return ancestor === table;
|
|
183
|
+
}
|
|
184
|
+
ancestor = ancestor.parentElement;
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Detects Word's hidden misaligned-row placeholder cell.
|
|
190
|
+
*
|
|
191
|
+
* @param {HTMLTableCellElement} cell Cell to inspect.
|
|
192
|
+
* @returns {boolean} `true` when the cell is a hidden placeholder.
|
|
193
|
+
*/
|
|
194
|
+
isHiddenMisalignedCell(cell) {
|
|
195
|
+
if (this.hasExplicitSpan(cell)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
if (!this.hasZeroWidthMarker(cell)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return !this.hasMeaningfulCellContent(cell);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Reports whether a cell explicitly spans rows/columns.
|
|
205
|
+
*
|
|
206
|
+
* @param {HTMLTableCellElement} cell Cell to inspect.
|
|
207
|
+
* @returns {boolean} `true` when colspan/rowspan is present.
|
|
208
|
+
*/
|
|
209
|
+
hasExplicitSpan(cell) {
|
|
210
|
+
return SPAN_ATTRIBUTES.some((attribute) => cell.hasAttribute(attribute));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Reports whether a cell is explicitly marked with zero width via attribute
|
|
214
|
+
* or preserved inline style.
|
|
215
|
+
*
|
|
216
|
+
* @param {HTMLTableCellElement} cell Cell to inspect.
|
|
217
|
+
* @returns {boolean} `true` when width is explicitly zero.
|
|
218
|
+
*/
|
|
219
|
+
hasZeroWidthMarker(cell) {
|
|
220
|
+
const widthAttribute = cell.getAttribute('width');
|
|
221
|
+
if (widthAttribute !== null && ZERO_LENGTH_PATTERN.test(widthAttribute.trim())) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const style = cell.getAttribute(PRESERVED_STYLE_ATTR);
|
|
225
|
+
if (style === null) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
const widthDeclarationValue = this.readStyleDeclaration(style, 'width');
|
|
229
|
+
return widthDeclarationValue !== null && ZERO_LENGTH_PATTERN.test(widthDeclarationValue);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Reports whether a cell has meaningful text content. `trim()` already treats
|
|
233
|
+
* the non-breaking space Word emits as blank, so a zero-width cell holding
|
|
234
|
+
* only markup (including an image) is intentionally treated as empty and
|
|
235
|
+
* removed.
|
|
236
|
+
*
|
|
237
|
+
* @param {HTMLTableCellElement} cell Cell to inspect.
|
|
238
|
+
* @returns {boolean} `true` when the cell has meaningful text.
|
|
239
|
+
*/
|
|
240
|
+
hasMeaningfulCellContent(cell) {
|
|
241
|
+
return (cell.textContent || '').trim() !== '';
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Reads one declaration value from a style string.
|
|
245
|
+
*
|
|
246
|
+
* @param {string} style Preserved style text.
|
|
247
|
+
* @param {string} property CSS property name to read.
|
|
248
|
+
* @returns {string | null} Declaration value when present.
|
|
249
|
+
*/
|
|
250
|
+
readStyleDeclaration(style, property) {
|
|
251
|
+
const declarations = style
|
|
252
|
+
.split(';')
|
|
253
|
+
.map((declaration) => declaration.trim())
|
|
254
|
+
.filter((declaration) => declaration !== '');
|
|
255
|
+
for (const declaration of declarations) {
|
|
256
|
+
const separator = declaration.indexOf(':');
|
|
257
|
+
if (separator === -1) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const name = declaration.slice(0, separator).trim().toLowerCase();
|
|
261
|
+
if (name !== property.toLowerCase()) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const value = declaration.slice(separator + 1).trim();
|
|
265
|
+
return value === '' ? null : value;
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Collapses every `<tfoot>` into the table body because the RTE table model
|
|
271
|
+
* has no footer section. Left in place, an unsupported `<tfoot>` is unwrapped
|
|
272
|
+
* by the paste sanitizer into a bare `<tr>` under `<table>`, so its rows lose
|
|
273
|
+
* their section placement. When the table already has a `<tbody>`, the
|
|
274
|
+
* footer's rows are appended to the last body so they stay in document order;
|
|
275
|
+
* otherwise the `<tfoot>` itself is renamed to `<tbody>` so its rows survive
|
|
276
|
+
* as body content.
|
|
277
|
+
*
|
|
278
|
+
* @param {HTMLTableElement} table Word table element.
|
|
279
|
+
*/
|
|
280
|
+
mergeFooterIntoBody(table) {
|
|
281
|
+
const footers = Array.from(table.children).filter((child) => child.tagName === 'TFOOT');
|
|
282
|
+
footers.forEach((footer) => {
|
|
283
|
+
const bodies = Array.from(table.children).filter((child) => child.tagName === 'TBODY');
|
|
284
|
+
const targetBody = bodies[bodies.length - 1];
|
|
285
|
+
if (targetBody) {
|
|
286
|
+
while (footer.firstChild) {
|
|
287
|
+
targetBody.appendChild(footer.firstChild);
|
|
288
|
+
}
|
|
289
|
+
if (footer.parentNode) {
|
|
290
|
+
footer.parentNode.removeChild(footer);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
this.replaceElementTag(footer, 'tbody');
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Promotes `<td>` cells that Word places directly inside a `<thead>` row to
|
|
300
|
+
* `<th>`. The RTE identifies header cells solely by the `TH` tag, so without
|
|
301
|
+
* this the head row would be parsed as ordinary body cells and lose its
|
|
302
|
+
* header annotations and rendering. Only direct `thead > tr > td` cells are
|
|
303
|
+
* converted so cells of a nested table are never touched.
|
|
304
|
+
*
|
|
305
|
+
* @param {HTMLTableElement} table Word table element.
|
|
306
|
+
*/
|
|
307
|
+
promoteHeadCells(table) {
|
|
308
|
+
Array.from(table.querySelectorAll('thead')).forEach((head) => {
|
|
309
|
+
Array.from(head.children).forEach((row) => {
|
|
310
|
+
if (row.tagName !== 'TR') {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
Array.from(row.children).forEach((cell) => {
|
|
314
|
+
if (cell.tagName === 'TD') {
|
|
315
|
+
this.renameCell(cell, 'th');
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Replaces a table cell element with an equivalent cell of a different tag,
|
|
323
|
+
* preserving its attributes and child nodes.
|
|
324
|
+
*
|
|
325
|
+
* @param {HTMLTableCellElement} cell Cell to replace.
|
|
326
|
+
* @param {string} tagName Target cell tag name (`th` / `td`).
|
|
327
|
+
*/
|
|
328
|
+
renameCell(cell, tagName) {
|
|
329
|
+
this.replaceElementTag(cell, tagName);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Replaces an element with an equivalent element of a different tag,
|
|
333
|
+
* preserving its attributes and child nodes and its position in the tree.
|
|
334
|
+
*
|
|
335
|
+
* @param {Element} element Element to replace.
|
|
336
|
+
* @param {string} tagName Target tag name.
|
|
337
|
+
* @returns {HTMLElement} The replacement element.
|
|
338
|
+
*/
|
|
339
|
+
replaceElementTag(element, tagName) {
|
|
340
|
+
const replacement = element.ownerDocument.createElement(tagName);
|
|
341
|
+
Array.from(element.attributes).forEach((attr) => {
|
|
342
|
+
replacement.setAttribute(attr.name, attr.value);
|
|
343
|
+
});
|
|
344
|
+
while (element.firstChild) {
|
|
345
|
+
replacement.appendChild(element.firstChild);
|
|
346
|
+
}
|
|
347
|
+
if (element.parentNode) {
|
|
348
|
+
element.parentNode.replaceChild(replacement, element);
|
|
349
|
+
}
|
|
350
|
+
return replacement;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Removes the `class` attribute so Word style class names cannot leak into
|
|
354
|
+
* the sanitized output (the global allowlist keeps `class` on every tag).
|
|
355
|
+
*
|
|
356
|
+
* @param {HTMLElement} element Table structural element.
|
|
357
|
+
*/
|
|
358
|
+
stripClass(element) {
|
|
359
|
+
if (element.hasAttribute('class')) {
|
|
360
|
+
element.removeAttribute('class');
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Drops whitespace-only text nodes that sit directly inside the table and its
|
|
365
|
+
* row containers. Word exports newlines/indentation between structural tags,
|
|
366
|
+
* which are invalid as table content and would otherwise render as stray
|
|
367
|
+
* spaces once the table is pasted.
|
|
368
|
+
*
|
|
369
|
+
* @param {HTMLTableElement} table Word table element.
|
|
370
|
+
*/
|
|
371
|
+
removeStructuralWhitespace(table) {
|
|
372
|
+
const containers = [
|
|
373
|
+
table,
|
|
374
|
+
...Array.from(table.querySelectorAll(TABLE_CONTAINER_SELECTOR)),
|
|
375
|
+
];
|
|
376
|
+
containers.forEach((container) => {
|
|
377
|
+
Array.from(container.childNodes).forEach((node) => {
|
|
378
|
+
if (node.nodeType === Node.TEXT_NODE && (node.textContent || '').trim() === '') {
|
|
379
|
+
container.removeChild(node);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Drops whitespace-only text nodes that sit directly inside a cell whose
|
|
386
|
+
* content is block-level (e.g. Word wraps every cell's text in `<p>`). Word
|
|
387
|
+
* indents its markup, so these text nodes are pure layout whitespace; left in
|
|
388
|
+
* place each one is wrapped into its own paragraph by the RTE, producing the
|
|
389
|
+
* stray empty lines seen above and below the real cell content. Cells that
|
|
390
|
+
* only hold inline content are skipped so meaningful spaces between inline
|
|
391
|
+
* runs are never merged.
|
|
392
|
+
*
|
|
393
|
+
* @param {HTMLTableCellElement} cell Table cell element.
|
|
394
|
+
*/
|
|
395
|
+
removeCellLayoutWhitespace(cell) {
|
|
396
|
+
const hasBlockChild = Array.from(cell.children).some((child) => CELL_BLOCK_CHILD_TAGS.has(child.tagName));
|
|
397
|
+
if (!hasBlockChild) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
Array.from(cell.childNodes).forEach((node) => {
|
|
401
|
+
if (node.nodeType === Node.TEXT_NODE && (node.textContent || '').trim() === '') {
|
|
402
|
+
cell.removeChild(node);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Normalizes `colspan` / `rowspan` values: a redundant span of `1` or any
|
|
408
|
+
* non-numeric value is removed, and valid spans are rewritten as a clean
|
|
409
|
+
* integer so the RTE table model reads them consistently.
|
|
410
|
+
*
|
|
411
|
+
* @param {HTMLTableCellElement} cell Table cell element.
|
|
412
|
+
*/
|
|
413
|
+
normalizeSpanAttributes(cell) {
|
|
414
|
+
SPAN_ATTRIBUTES.forEach((attribute) => {
|
|
415
|
+
const raw = cell.getAttribute(attribute);
|
|
416
|
+
if (raw === null) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const value = Number(raw);
|
|
420
|
+
if (!SPAN_VALUE_PATTERN.test(raw) || value <= 1) {
|
|
421
|
+
cell.removeAttribute(attribute);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
cell.setAttribute(attribute, String(value));
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Migrates Word cell presentational attributes into `data-style` so the RTE
|
|
430
|
+
* cell annotation can read the shading and alignment, then removes the
|
|
431
|
+
* original attributes. An existing declaration for the same property always
|
|
432
|
+
* wins and is never overwritten.
|
|
433
|
+
*
|
|
434
|
+
* @param {HTMLTableCellElement} cell Table cell element.
|
|
435
|
+
*/
|
|
436
|
+
migrateCellAttributes(cell) {
|
|
437
|
+
CELL_ATTRIBUTE_STYLE_MAP.forEach(({ attribute, property }) => {
|
|
438
|
+
const value = cell.getAttribute(attribute);
|
|
439
|
+
if (value && value.trim() !== '') {
|
|
440
|
+
this.appendStyleDeclaration(cell, property, value.trim().toLowerCase());
|
|
441
|
+
}
|
|
442
|
+
cell.removeAttribute(attribute);
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Converts a cell's `width` attribute into a `width` style declaration. Word
|
|
447
|
+
* emits the width both as a point-based inline style (which the RTE cannot
|
|
448
|
+
* parse) and as a pixel `width` attribute; the point style is dropped and the
|
|
449
|
+
* attribute value becomes a clean pixel `width` declaration (a bare number is
|
|
450
|
+
* treated as pixels, any explicit unit such as `%` is kept as-is).
|
|
451
|
+
*
|
|
452
|
+
* @param {HTMLTableCellElement} cell Table cell element.
|
|
453
|
+
*/
|
|
454
|
+
migrateCellWidth(cell) {
|
|
455
|
+
const attributeWidth = cell.getAttribute('width');
|
|
456
|
+
cell.removeAttribute('width');
|
|
457
|
+
// Drop Word's point-based width so it cannot survive as an unparseable value.
|
|
458
|
+
this.removeMatchingStyleDeclarations(cell, (property) => WIDTH_STYLE_PATTERN.test(property));
|
|
459
|
+
const cssWidth = this.toCssWidth(attributeWidth);
|
|
460
|
+
if (cssWidth !== null) {
|
|
461
|
+
this.appendStyleDeclaration(cell, 'width', cssWidth);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Normalizes a cell `width` attribute value into a CSS width value. A bare
|
|
466
|
+
* number is treated as pixels; any value carrying an explicit unit (e.g. `%`)
|
|
467
|
+
* is kept as-is. An empty or missing value yields `null`.
|
|
468
|
+
*
|
|
469
|
+
* @param {string | null} value Raw `width` attribute value.
|
|
470
|
+
* @returns {string | null} CSS width value, or `null` when there is nothing to migrate.
|
|
471
|
+
*/
|
|
472
|
+
toCssWidth(value) {
|
|
473
|
+
if (value === null || value.trim() === '') {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
const trimmed = value.trim();
|
|
477
|
+
return /^\d+(\.\d+)?$/.test(trimmed) ? `${trimmed}px` : trimmed;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Appends a `property: value` declaration to the preserved style attribute
|
|
481
|
+
* unless the property is already declared.
|
|
482
|
+
*
|
|
483
|
+
* @param {HTMLElement} element Element receiving the declaration.
|
|
484
|
+
* @param {string} property CSS property name.
|
|
485
|
+
* @param {string} value CSS value.
|
|
486
|
+
*/
|
|
487
|
+
appendStyleDeclaration(element, property, value) {
|
|
488
|
+
const existing = element.getAttribute(PRESERVED_STYLE_ATTR) || '';
|
|
489
|
+
if (this.styleHasProperty(existing, property)) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const prefix = existing.trim() === '' ? '' : `${existing.replace(/;\s*$/, '')}; `;
|
|
493
|
+
element.setAttribute(PRESERVED_STYLE_ATTR, `${prefix}${property}: ${value}`);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Removes every border box-model and padding declaration from the preserved
|
|
497
|
+
* style so Word's point/centimeter units, system color keywords, and per-side
|
|
498
|
+
* `border-*: none` resets cannot reach the RTE. Once these are gone the table
|
|
499
|
+
* and cell annotations fall back to the editor's default border
|
|
500
|
+
* (`solid 1px #ddd`) and padding (`12px`), giving every pasted cell a uniform
|
|
501
|
+
* border. `border-collapse` / `border-spacing` are preserved so table
|
|
502
|
+
* collapsing is unaffected.
|
|
503
|
+
*
|
|
504
|
+
* @param {HTMLElement} element Table or cell element to normalize.
|
|
505
|
+
*/
|
|
506
|
+
removeBorderAndPaddingStyles(element) {
|
|
507
|
+
this.removeMatchingStyleDeclarations(element, (property) => BORDER_BOX_STYLE_PATTERN.test(property) || PADDING_STYLE_PATTERN.test(property));
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Removes every preserved-style declaration whose property name matches the
|
|
511
|
+
* given predicate, rewriting (or dropping) the `data-style` attribute.
|
|
512
|
+
*
|
|
513
|
+
* @param {HTMLElement} element Element whose preserved style is filtered.
|
|
514
|
+
* @param {(property: string) => boolean} shouldRemove Predicate that returns
|
|
515
|
+
* `true` for property names to drop (receives the lower-cased name).
|
|
516
|
+
*/
|
|
517
|
+
removeMatchingStyleDeclarations(element, shouldRemove) {
|
|
518
|
+
const raw = element.getAttribute(PRESERVED_STYLE_ATTR);
|
|
519
|
+
if (raw === null || raw.trim() === '') {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const kept = raw
|
|
523
|
+
.split(';')
|
|
524
|
+
.map((declaration) => declaration.trim())
|
|
525
|
+
.filter((declaration) => declaration !== '')
|
|
526
|
+
.filter((declaration) => {
|
|
527
|
+
const separator = declaration.indexOf(':');
|
|
528
|
+
if (separator === -1) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
const property = declaration.slice(0, separator).trim().toLowerCase();
|
|
532
|
+
return !shouldRemove(property);
|
|
533
|
+
});
|
|
534
|
+
if (kept.length > 0) {
|
|
535
|
+
element.setAttribute(PRESERVED_STYLE_ATTR, kept.join('; '));
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
element.removeAttribute(PRESERVED_STYLE_ATTR);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Reports whether a preserved style string already declares a property.
|
|
543
|
+
*
|
|
544
|
+
* @param {string} style Preserved style attribute value.
|
|
545
|
+
* @param {string} property CSS property name.
|
|
546
|
+
* @returns {boolean} `true` when the property is already present.
|
|
547
|
+
*/
|
|
548
|
+
styleHasProperty(style, property) {
|
|
549
|
+
return new RegExp(`(^|;)\\s*${property}\\s*:`, 'i').test(style);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract for Word DOM structure transformers. Each transformer is responsible
|
|
3
|
+
* for one structural concern (list markers, paragraph roles, tables, images…).
|
|
4
|
+
* Register new transformers in {@link WordPasteProcessingStrategy.STRUCTURE_TRANSFORMERS}
|
|
5
|
+
* to extend Word paste support without touching the core pipeline.
|
|
6
|
+
*/
|
|
7
|
+
export const WORD_SANITIZE_ALL_TAGS_KEY = '*';
|
package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-block.js
CHANGED
|
@@ -44,6 +44,16 @@ export class RTETableBlock extends RTEBlock {
|
|
|
44
44
|
getLastNode() {
|
|
45
45
|
return this.children[this.children.length - 1].getLastNode();
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The table is an atomic caret boundary: resolving a caret on its boundary must keep
|
|
49
|
+
* it anchored to the table block (so paragraph-insertion before/after works) rather
|
|
50
|
+
* than descending into a cell.
|
|
51
|
+
*
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
allowsCaretDescend() {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
47
57
|
/**
|
|
48
58
|
* Get the first node of the table block.
|
|
49
59
|
*
|