@heartlandone/vega 2.79.0 → 2.81.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/app-globals-25e1bfac.js +430 -0
- package/dist/cjs/aria-dialog-focusable-trap-slimmer-ced9566d.js +217 -0
- package/dist/cjs/child-nodes-notify-observer-slimmer-2631c381.js +90 -0
- package/dist/cjs/code-block-24b3d0e7.js +5262 -0
- package/dist/cjs/component-value-history-controller-slimmer.abstract-bd662b32.js +714 -0
- package/dist/cjs/content-state-0f26036c.js +4962 -0
- package/dist/cjs/date-required-rule-4377217a.js +92 -0
- package/dist/cjs/design-token-40276b11.js +402 -0
- package/dist/cjs/dom-node-subject-observer-factory-9110cb94.js +141 -0
- package/dist/cjs/element-appender-slimmer-be1b4d57.js +1974 -0
- package/dist/cjs/event-emit-slimmer-bee6b676.js +267 -0
- package/dist/cjs/form-field-controller-slimmer-982dbfe4.js +1266 -0
- package/dist/cjs/image-annotation-action-e0df5a20.js +285 -0
- package/dist/cjs/index.cjs.js +16 -15
- package/dist/cjs/inject-keyboard-manager-12b65e98.js +37 -0
- package/dist/cjs/keyboard-manager-c89a66d3.js +148 -0
- package/dist/cjs/keyboard-manager-slimmer-93fcbf46.js +39 -0
- package/dist/cjs/loader.cjs.js +11 -11
- package/dist/cjs/month-view-generator-0d25e950.js +101 -0
- package/dist/cjs/page-size-option-utils-d038dd3a.js +68 -0
- package/dist/cjs/public-rules-652ec269.js +46 -0
- package/dist/cjs/range-cdd61881.js +178 -0
- package/dist/cjs/responsive-format-facade-9cae7f27.js +944 -0
- package/dist/cjs/rich-text-editor-required-rule-4b919054.js +64 -0
- package/dist/cjs/split-cell-operation-3596f738.js +2446 -0
- package/dist/cjs/string-format-strategy.abstract-ebdb2573.js +63 -0
- package/dist/cjs/string-input-formatter-slimmer-9b6a8399.js +230 -0
- package/dist/cjs/string-mask-strategy-6cc9f391.js +203 -0
- package/dist/cjs/style-formatter-18289c4d.js +34 -0
- package/dist/cjs/sub-state-notify-slimmer-39bfcfe3.js +81 -0
- package/dist/cjs/sub-state-observer-slimmer-e5b50cbf.js +134 -0
- package/dist/cjs/time-required-rule-3517beff.js +141 -0
- package/dist/cjs/token-extension-addc97c1.js +7612 -0
- package/dist/cjs/type-guard-362d7da3.js +2056 -0
- package/dist/cjs/ui-ae4ee13d.js +352 -0
- package/dist/cjs/valid-credit-card-number-rule-1d8bf49c.js +173 -0
- package/dist/cjs/vega-accordion.cjs.entry.js +6 -6
- package/dist/cjs/vega-app-header-button.cjs.entry.js +6 -6
- package/dist/cjs/vega-backdrop.cjs.entry.js +1 -1
- package/dist/cjs/vega-banner.cjs.entry.js +5 -4
- package/dist/cjs/vega-box.cjs.entry.js +5 -5
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +27 -10
- package/dist/cjs/vega-button-circle.cjs.entry.js +7 -7
- package/dist/cjs/vega-button-group_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-button-link.cjs.entry.js +3 -3
- package/dist/cjs/vega-button.cjs.entry.js +6 -6
- package/dist/cjs/vega-calendar_4.cjs.entry.js +30 -17
- package/dist/cjs/vega-card.cjs.entry.js +5 -5
- package/dist/cjs/vega-carousel.cjs.entry.js +5 -5
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +7 -7
- package/dist/cjs/vega-chip.cjs.entry.js +7 -7
- package/dist/cjs/vega-code-block.cjs.entry.js +10 -10
- package/dist/cjs/vega-color-picker.cjs.entry.js +6 -6
- package/dist/cjs/vega-combo-box.cjs.entry.js +9 -9
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +343 -285
- package/dist/cjs/vega-dialog_2.cjs.entry.js +74 -10
- package/dist/cjs/vega-divider.cjs.entry.js +5 -5
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +52 -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 +6 -6
- package/dist/cjs/vega-flag-icon.cjs.entry.js +3 -3
- package/dist/cjs/vega-flex.cjs.entry.js +6 -6
- package/dist/cjs/vega-font.cjs.entry.js +4 -4
- package/dist/cjs/vega-form.cjs.entry.js +9 -9
- package/dist/cjs/vega-grid.cjs.entry.js +4 -4
- package/dist/cjs/vega-icon.cjs.entry.js +4 -4
- package/dist/cjs/vega-image-uploader.cjs.entry.js +8 -8
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +10 -10
- package/dist/cjs/vega-input-numeric.cjs.entry.js +10 -10
- package/dist/cjs/vega-input-passcode.cjs.entry.js +9 -9
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +8 -8
- package/dist/cjs/vega-input-range.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-select.cjs.entry.js +8 -8
- package/dist/cjs/vega-input.cjs.entry.js +41 -28
- package/dist/cjs/vega-internal-event-id-a1837fa2.js +126 -0
- package/dist/cjs/vega-item-toggle.cjs.entry.js +3 -3
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +118 -13
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +3 -3
- package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +24 -8
- package/dist/cjs/vega-pagination.cjs.entry.js +44 -20
- package/dist/cjs/vega-popover_2.cjs.entry.js +48 -12
- package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +43 -12
- package/dist/cjs/vega-radio_2.cjs.entry.js +10 -10
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +101 -20
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +30 -19
- package/dist/cjs/vega-rich-text-table-properties_3.cjs.entry.js +9 -9
- package/dist/cjs/vega-section-title.cjs.entry.js +21 -3
- package/dist/cjs/vega-segment-control.cjs.entry.js +3 -3
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +9 -9
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +8 -8
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +8 -8
- package/dist/cjs/vega-signature-capture.cjs.entry.js +9 -9
- package/dist/cjs/vega-stepper.cjs.entry.js +7 -7
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-table_11.cjs.entry.js +8 -8
- package/dist/cjs/vega-text.cjs.entry.js +1 -1
- package/dist/cjs/vega-textarea.cjs.entry.js +6 -6
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +12 -12
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +6 -6
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +8 -8
- package/dist/cjs/vega.cjs.js +11 -11
- package/dist/cjs/wait-for-component-did-render-b6d12d51.js +32 -0
- package/dist/collection/components/vega-banner/slimmers/renderers/vega-banner-renderer.js +1 -0
- package/dist/collection/components/vega-banner/vega-banner.css +36 -0
- package/dist/collection/components/vega-box/vega-box.js +1 -1
- package/dist/collection/components/vega-breadcrumb/slimmers/renderers/vega-breadcrumb-item-renderer.js +9 -6
- package/dist/collection/components/vega-breadcrumb/slimmers/renderers/vega-breadcrumb-renderer.js +4 -0
- package/dist/collection/components/vega-breadcrumb/vega-breadcrumb.css +6 -0
- package/dist/collection/components/vega-breadcrumb/vega-breadcrumb.js +31 -0
- package/dist/collection/components/vega-calendar/vega-calendar-event/slimmers/renderers/vega-calendar-event-renderer.js +4 -4
- package/dist/collection/components/vega-calendar/vega-calendar-event/vega-calendar-event.css +15 -12
- package/dist/collection/components/vega-calendar/vega-calendar-event/vega-calendar-event.js +1 -1
- package/dist/collection/components/vega-calendar/vega-calendar-event-preview/slimmers/renderers/vega-calendar-event-preview-detail-renderer.js +17 -3
- package/dist/collection/components/vega-calendar/vega-calendar.css +1 -1
- package/dist/collection/components/vega-card/vega-card.css +157 -0
- package/dist/collection/components/vega-card/vega-card.js +1 -1
- package/dist/collection/components/vega-chip/vega-chip.js +26 -1
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/controllers/vega-date-picker-calendar-current-period-controller.js +5 -10
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/controllers/vega-date-picker-calendar-is-dual-months-controller.js +64 -0
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-header-render.js +3 -6
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-renderer.js +3 -11
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-year-month-switcher-renderer.js +2 -2
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.js +9 -10
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.css +13 -15
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.js +41 -2
- package/dist/collection/components/vega-dialog/vega-dialog.js +1 -1
- package/dist/collection/components/vega-divider/slimmers/controllers/vega-divider-size-controller.js +1 -1
- package/dist/collection/components/vega-divider/vega-divider.css +157 -0
- package/dist/collection/components/vega-divider/vega-divider.js +1 -1
- package/dist/collection/components/vega-dropdown/slimmers/controllers/vega-dropdown-appender-controller.js +37 -1
- package/dist/collection/components/vega-dropdown/slimmers/renderers/vega-dropdown-renderer.js +4 -1
- package/dist/collection/components/vega-flex/vega-flex.css +157 -0
- package/dist/collection/components/vega-flex/vega-flex.js +1 -1
- package/dist/collection/components/vega-input/slimmers/controllers/vega-input-mask-config-controller.js +13 -12
- package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-renderer.js +4 -1
- package/dist/collection/components/vega-input/vega-input.js +26 -1
- package/dist/collection/components/vega-modal/slimmers/controllers/vega-modal-layout-controller.js +37 -1
- package/dist/collection/components/vega-modal/slimmers/renderers/vega-modal-renderer.js +11 -1
- package/dist/collection/components/vega-modal/vega-modal.css +2683 -7
- package/dist/collection/components/vega-modal/vega-modal.js +75 -0
- package/dist/collection/components/vega-nav/vega-left-nav/slimmers/controllers/vega-left-nav-open-state-controller.js +85 -2
- package/dist/collection/components/vega-nav/vega-left-nav/vega-left-nav.js +23 -0
- package/dist/collection/components/vega-pagination/constants/page-size.js +2 -0
- package/dist/collection/components/vega-pagination/internal/vega-pagination-page-size-selector.js +11 -7
- package/dist/collection/components/vega-pagination/slimmers/controllers/vega-pagination-page-size-observer-controller.js +11 -1
- package/dist/collection/components/vega-pagination/utils/page-size-option-utils.js +57 -0
- package/dist/collection/components/vega-pagination/vega-pagination-page-size-selector-mobile/slimmers/renderers/page-size-selector-mobile-dropdown-renderer.js +15 -5
- package/dist/collection/components/vega-pagination/vega-pagination-page-size-selector-mobile/vega-pagination-page-size-selector-mobile.js +39 -3
- package/dist/collection/components/vega-pagination/vega-pagination.js +32 -11
- package/dist/collection/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.js +25 -1
- package/dist/collection/components/vega-popover/vega-popover-content-box/vega-popover-content-box.js +6 -1
- package/dist/collection/components/vega-popover/vega-popover.js +7 -0
- package/dist/collection/components/vega-progress-tracker/slimmers/controllers/vega-progress-tracker-current-direction-controller.js +34 -3
- package/dist/collection/components/vega-progress-tracker/slimmers/renderers/vega-progress-tracker-renderer.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/constants/constant.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/bold-annotation.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/code-annotation.js +13 -6
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.js +18 -9
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/image-annotation.js +12 -1
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/inline-html-annotation.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/italic-annotation.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-group-annotation.js +20 -3
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/list-annotation.js +12 -4
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-format-default-styles.js +22 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-style-annotation.js +43 -32
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/underline-annotation.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +15 -4
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/code-block.js +6 -2
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/html-block.js +9 -15
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +3 -7
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +50 -9
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +25 -6
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/code-block/code-block-filter-styles-strategy.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/code-block/code-node-filter-styles-strategy.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy-registry.js +64 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy.abstract.js +166 -2
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/image-node/image-filter-styles-strategy.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-block-filter-styles-strategy.js +36 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-heading-item-block-filter-styles-strategy.js +29 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-item-block-filter-styles-strategy.js +51 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-title-item-block-filter-styles-strategy.js +29 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/predicate.js +94 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/alignment-filter-styles-strategy.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/heading-filter-styles-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/paragraph-filter-styles-strategy.js +48 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/title-filter-styles-strategy.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/code-filter-styles-strategy.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/link-filter-styles-strategy.js +69 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/text-format-filter-styles-strategy.js +89 -0
- package/dist/collection/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/title-heading-node-filter-styles-strategy.js +108 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/code-block-node.js +7 -2
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/node.abstract.js +15 -4
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +84 -14
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.js +61 -6
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.js +14 -3
- package/dist/collection/components/vega-rich-text-editor/dto/setup.js +50 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/extension.abstract.js +10 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/languages/language-extension.js +9 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/annotations/table-annotation.js +17 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/table/annotations/table-caption-annotation.js +17 -18
- package/dist/collection/components/vega-rich-text-editor/extensions/table/annotations/table-cell-annotation.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-body-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-caption-block.js +21 -4
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-cell-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-head-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-head-cell-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/dto/table-row-block.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/extensions/table/element-to-dto-strategies/caption-to-caption-block-strategy.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/table/element-to-dto-strategies/td-to-table-cell-block-strategy.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/table/filter-styles-strategies/table-block/table-block-filter-styles-strategy.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/table/filter-styles-strategies/table-caption/table-caption-filter-styles-strategy.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/table/filter-styles-strategies/table-cell/table-cell-filter-styles-strategy.js +63 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/table/table-extension.js +7 -0
- package/dist/collection/components/vega-rich-text-editor/helpers/utils.js +24 -0
- package/dist/collection/components/vega-rich-text-editor/public-api.js +2 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/bold-annotaion-handler.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/custom-style-annotation-handler.js +2 -25
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/html-element-to-annotation-generator.js +47 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/inline-html-annotation-handler.js +30 -53
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/italic-annotation-handler.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/link-annotation-handler.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/strike-through-annotation-handler.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/text-style-annotation-handler.js +4 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/underline-annotation-handler.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.js +85 -17
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.js +12 -5
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/html-block-strategy.js +95 -43
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-element-to-text-node-strategy.js +1 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/predicate.js +29 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/strategy-tags.js +142 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-source-view-renderer.js +12 -2
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +1 -1
- package/dist/collection/components/vega-section-title/slimmers/renderers/vega-section-title-renderer.js +8 -2
- package/dist/collection/components/vega-section-title/vega-section-title.css +35 -0
- package/dist/collection/components/vega-section-title/vega-section-title.js +64 -0
- package/dist/collection/components/vega-stepper/vega-stepper.css +3 -0
- package/dist/collection/helpers/calendar/calendar-date.js +10 -0
- package/dist/collection/helpers/calendar/calendar-view-generator/calendar-view-generator.abstract.js +2 -2
- package/dist/collection/helpers/event-manager/event-id/vega-internal-event-id.js +1 -0
- package/dist/collection/helpers/formatter/responsive-map-formatter/responsive-margin-formatter.js +3 -3
- package/dist/collection/helpers/formatter/string-formatter/custom-formatter-strategy.js +3 -1
- package/dist/collection/helpers/formatter/string-formatter/number-mask-strategy.js +3 -1
- package/dist/collection/helpers/formatter/string-formatter/number-thousand-comma-strategy.js +3 -2
- package/dist/collection/helpers/formatter/string-formatter/string-format-strategy.abstract.js +4 -1
- package/dist/collection/helpers/formatter/string-formatter/string-mask-strategy.js +38 -7
- package/dist/collection/helpers/formatter/string-formatter/thousand-comma-strategy.js +4 -0
- package/dist/collection/helpers/keyboard/keyboard-manager.js +11 -3
- package/dist/collection/helpers/slimmers/aria-dialog-focusable-trap-slimmer.js +67 -68
- package/dist/collection/types/type-guard.js +21 -0
- package/dist/collection/utils/ui.js +76 -2
- package/dist/esm/app-globals-80a7d395.js +428 -0
- package/dist/esm/aria-dialog-focusable-trap-slimmer-cc6a8c3e.js +215 -0
- package/dist/esm/child-nodes-notify-observer-slimmer-a8cb19cf.js +88 -0
- package/dist/esm/code-block-cd913077.js +5189 -0
- package/dist/esm/component-value-history-controller-slimmer.abstract-e595761d.js +709 -0
- package/dist/esm/content-state-89f8eecb.js +4942 -0
- package/dist/esm/date-required-rule-2b08f32c.js +90 -0
- package/dist/esm/design-token-7566d54c.js +388 -0
- package/dist/esm/dom-node-subject-observer-factory-aca0116e.js +138 -0
- package/dist/esm/element-appender-slimmer-df2a2da2.js +1972 -0
- package/dist/esm/event-emit-slimmer-9abc9241.js +265 -0
- package/dist/esm/form-field-controller-slimmer-40fcb5c2.js +1264 -0
- package/dist/esm/image-annotation-action-6048d32e.js +280 -0
- package/dist/esm/index.js +15 -15
- package/dist/esm/inject-keyboard-manager-c6557f50.js +35 -0
- package/dist/esm/keyboard-manager-c7b125d7.js +146 -0
- package/dist/esm/keyboard-manager-slimmer-6109039b.js +37 -0
- package/dist/esm/loader.js +11 -11
- package/dist/esm/month-view-generator-139ace5a.js +97 -0
- package/dist/esm/page-size-option-utils-50afc81a.js +61 -0
- package/dist/esm/public-rules-e42bce9d.js +31 -0
- package/dist/esm/range-b76edec7.js +176 -0
- package/dist/esm/responsive-format-facade-151dbd10.js +940 -0
- package/dist/esm/rich-text-editor-required-rule-1fc7c040.js +62 -0
- package/dist/esm/split-cell-operation-548ea374.js +2395 -0
- package/dist/esm/string-format-strategy.abstract-6488031a.js +61 -0
- package/dist/esm/string-input-formatter-slimmer-625e17a2.js +228 -0
- package/dist/esm/string-mask-strategy-a165d316.js +201 -0
- package/dist/esm/style-formatter-280757ae.js +32 -0
- package/dist/esm/sub-state-notify-slimmer-6c972bb4.js +79 -0
- package/dist/esm/sub-state-observer-slimmer-53643b5c.js +132 -0
- package/dist/esm/time-required-rule-3f5a8822.js +138 -0
- package/dist/esm/token-extension-5ee7a3f1.js +7591 -0
- package/dist/esm/type-guard-f6c9c89d.js +1979 -0
- package/dist/esm/ui-b7600a48.js +335 -0
- package/dist/esm/valid-credit-card-number-rule-3bf19ad6.js +171 -0
- package/dist/esm/vega-accordion.entry.js +6 -6
- package/dist/esm/vega-app-header-button.entry.js +6 -6
- package/dist/esm/vega-backdrop.entry.js +1 -1
- package/dist/esm/vega-banner.entry.js +5 -4
- package/dist/esm/vega-box.entry.js +5 -5
- package/dist/esm/vega-breadcrumb.entry.js +27 -10
- package/dist/esm/vega-button-circle.entry.js +7 -7
- package/dist/esm/vega-button-group_2.entry.js +6 -6
- package/dist/esm/vega-button-link.entry.js +3 -3
- package/dist/esm/vega-button.entry.js +6 -6
- package/dist/esm/vega-calendar_4.entry.js +30 -17
- package/dist/esm/vega-card.entry.js +5 -5
- package/dist/esm/vega-carousel.entry.js +5 -5
- package/dist/esm/vega-checkbox_2.entry.js +7 -7
- package/dist/esm/vega-chip.entry.js +7 -7
- package/dist/esm/vega-code-block.entry.js +10 -10
- package/dist/esm/vega-color-picker.entry.js +6 -6
- package/dist/esm/vega-combo-box.entry.js +9 -9
- package/dist/esm/vega-date-picker_2.entry.js +343 -285
- package/dist/esm/vega-dialog_2.entry.js +74 -10
- package/dist/esm/vega-divider.entry.js +5 -5
- package/dist/esm/vega-dropdown_5.entry.js +53 -15
- 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 +6 -6
- package/dist/esm/vega-flag-icon.entry.js +3 -3
- package/dist/esm/vega-flex.entry.js +6 -6
- package/dist/esm/vega-font.entry.js +4 -4
- package/dist/esm/vega-form.entry.js +9 -9
- package/dist/esm/vega-grid.entry.js +4 -4
- package/dist/esm/vega-icon.entry.js +4 -4
- package/dist/esm/vega-image-uploader.entry.js +8 -8
- package/dist/esm/vega-input-credit-card.entry.js +10 -10
- package/dist/esm/vega-input-numeric.entry.js +10 -10
- package/dist/esm/vega-input-passcode.entry.js +9 -9
- package/dist/esm/vega-input-phone-number.entry.js +8 -8
- package/dist/esm/vega-input-range.entry.js +6 -6
- package/dist/esm/vega-input-select.entry.js +8 -8
- package/dist/esm/vega-input.entry.js +41 -28
- package/dist/esm/vega-internal-event-id-70bd893d.js +73 -0
- package/dist/esm/vega-item-toggle.entry.js +3 -3
- package/dist/esm/vega-left-nav_5.entry.js +118 -13
- package/dist/esm/vega-loader-wrapper_2.entry.js +3 -3
- package/dist/esm/vega-page-notification_2.entry.js +2 -2
- package/dist/esm/vega-pagination-page-selector-mobile.entry.js +3 -3
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +24 -8
- package/dist/esm/vega-pagination.entry.js +44 -20
- package/dist/esm/vega-popover_2.entry.js +48 -12
- package/dist/esm/vega-progress-tracker_2.entry.js +43 -12
- package/dist/esm/vega-radio_2.entry.js +10 -10
- package/dist/esm/vega-rich-text-content.entry.js +101 -20
- package/dist/esm/vega-rich-text-editor_4.entry.js +30 -19
- package/dist/esm/vega-rich-text-table-properties_3.entry.js +9 -9
- package/dist/esm/vega-section-title.entry.js +21 -3
- package/dist/esm/vega-segment-control.entry.js +3 -3
- package/dist/esm/vega-selection-chip_2.entry.js +9 -9
- package/dist/esm/vega-selection-tile_2.entry.js +8 -8
- package/dist/esm/vega-sidenav_3.entry.js +8 -8
- package/dist/esm/vega-signature-capture.entry.js +9 -9
- package/dist/esm/vega-stepper.entry.js +7 -7
- package/dist/esm/vega-tab-group_2.entry.js +3 -3
- package/dist/esm/vega-table_11.entry.js +8 -8
- package/dist/esm/vega-text.entry.js +1 -1
- package/dist/esm/vega-textarea.entry.js +6 -6
- package/dist/esm/vega-time-picker_2.entry.js +12 -12
- package/dist/esm/vega-toggle-switch.entry.js +6 -6
- package/dist/esm/vega-tooltip_2.entry.js +8 -8
- package/dist/esm/vega.js +11 -11
- package/dist/esm/wait-for-component-did-render-6980a1a6.js +30 -0
- package/dist/sri/vega-sri-manifest.json +343 -339
- package/dist/types/components/vega-breadcrumb/slimmers/renderers/vega-breadcrumb-item-renderer.d.ts +1 -0
- package/dist/types/components/vega-breadcrumb/slimmers/renderers/vega-breadcrumb-renderer.d.ts +1 -0
- package/dist/types/components/vega-breadcrumb/vega-breadcrumb.d.ts +10 -0
- package/dist/types/components/vega-calendar/vega-calendar-event-preview/slimmers/renderers/vega-calendar-event-preview-detail-renderer.d.ts +5 -0
- package/dist/types/components/vega-chip/vega-chip.d.ts +9 -0
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/controllers/vega-date-picker-calendar-current-period-controller.d.ts +1 -6
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/controllers/vega-date-picker-calendar-is-dual-months-controller.d.ts +28 -0
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-header-render.d.ts +1 -2
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-renderer.d.ts +1 -2
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-calendar-year-month-switcher-renderer.d.ts +1 -1
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.d.ts +1 -1
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.d.ts +12 -0
- package/dist/types/components/vega-dropdown/slimmers/controllers/vega-dropdown-appender-controller.d.ts +12 -0
- package/dist/types/components/vega-dropdown/slimmers/renderers/vega-dropdown-renderer.d.ts +1 -0
- package/dist/types/components/vega-input/slimmers/controllers/vega-input-mask-config-controller.d.ts +1 -0
- package/dist/types/components/vega-input/slimmers/renderers/vega-input-input-renderer.d.ts +1 -0
- package/dist/types/components/vega-input/types.d.ts +35 -1
- package/dist/types/components/vega-input/vega-input.d.ts +17 -1
- package/dist/types/components/vega-modal/slimmers/controllers/vega-modal-layout-controller.d.ts +9 -0
- package/dist/types/components/vega-modal/slimmers/renderers/vega-modal-renderer.d.ts +3 -0
- package/dist/types/components/vega-modal/vega-modal.d.ts +24 -1
- package/dist/types/components/vega-nav/vega-left-nav/slimmers/controllers/vega-left-nav-open-state-controller.d.ts +17 -0
- package/dist/types/components/vega-pagination/constants/page-size.d.ts +2 -0
- package/dist/types/components/vega-pagination/internal/vega-pagination-page-size-selector.d.ts +3 -2
- package/dist/types/components/vega-pagination/slimmers/controllers/vega-pagination-page-size-observer-controller.d.ts +2 -0
- package/dist/types/components/vega-pagination/types.d.ts +9 -0
- package/dist/types/components/vega-pagination/utils/page-size-option-utils.d.ts +42 -0
- package/dist/types/components/vega-pagination/vega-pagination-page-size-selector-mobile/slimmers/renderers/page-size-selector-mobile-dropdown-renderer.d.ts +2 -0
- package/dist/types/components/vega-pagination/vega-pagination-page-size-selector-mobile/vega-pagination-page-size-selector-mobile.d.ts +9 -2
- package/dist/types/components/vega-pagination/vega-pagination.d.ts +8 -3
- package/dist/types/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.d.ts +6 -0
- package/dist/types/components/vega-progress-tracker/slimmers/controllers/vega-progress-tracker-current-direction-controller.d.ts +14 -2
- package/dist/types/components/vega-progress-tracker/slimmers/renderers/vega-progress-tracker-renderer.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/constants/constant.d.ts +5 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/code-annotation.d.ts +6 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/image-annotation.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/inline-html-annotation.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-group-annotation.d.ts +15 -2
- package/dist/types/components/vega-rich-text-editor/dto/annotations/list-annotation.d.ts +6 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-format-default-styles.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-style-annotation.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +4 -2
- package/dist/types/components/vega-rich-text-editor/dto/blocks/code-block.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/dto/blocks/html-block.d.ts +1 -11
- package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +15 -2
- package/dist/types/components/vega-rich-text-editor/dto/content-state.d.ts +9 -3
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/code-block/code-block-filter-styles-strategy.d.ts +27 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/code-block/code-node-filter-styles-strategy.d.ts +27 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy-registry.d.ts +27 -1
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/filter-styles-strategy.abstract.d.ts +104 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/image-node/image-filter-styles-strategy.d.ts +28 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-block-filter-styles-strategy.d.ts +23 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-heading-item-block-filter-styles-strategy.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-item-block-filter-styles-strategy.d.ts +34 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/list-block/list-title-item-block-filter-styles-strategy.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/predicate.d.ts +72 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/alignment-filter-styles-strategy.d.ts +27 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/heading-filter-styles-strategy.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/paragraph-filter-styles-strategy.d.ts +34 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-block/title-filter-styles-strategy.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/code-filter-styles-strategy.d.ts +40 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/link-filter-styles-strategy.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/text-format-filter-styles-strategy.d.ts +41 -0
- package/dist/types/components/vega-rich-text-editor/dto/filter-styles-strategies/text-node/title-heading-node-filter-styles-strategy.d.ts +62 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/code-block-node.d.ts +7 -3
- package/dist/types/components/vega-rich-text-editor/dto/nodes/image-node.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/dto/nodes/node.abstract.d.ts +5 -3
- package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +43 -4
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.d.ts +25 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.d.ts +5 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/extensions/extension.abstract.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/extensions/table/annotations/table-annotation.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/extensions/table/annotations/table-caption-annotation.d.ts +7 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/annotations/table-cell-annotation.d.ts +9 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-body-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-caption-block.d.ts +5 -2
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-cell-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-head-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-head-cell-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/dto/table-row-block.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/table/filter-styles-strategies/table-block/table-block-filter-styles-strategy.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/extensions/table/filter-styles-strategies/table-caption/table-caption-filter-styles-strategy.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/extensions/table/filter-styles-strategies/table-cell/table-cell-filter-styles-strategy.d.ts +46 -0
- package/dist/types/components/vega-rich-text-editor/helpers/utils.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +27 -5
- package/dist/types/components/vega-rich-text-editor/public-api.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/custom-style-annotation-handler.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/html-element-to-annotation-generator.d.ts +11 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/inline-html-annotation-handler.d.ts +11 -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 +43 -7
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.d.ts +8 -3
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/html-block-strategy.d.ts +34 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/predicate.d.ts +21 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/strategy-tags.d.ts +83 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-source-view-renderer.d.ts +6 -0
- package/dist/types/components/vega-section-title/slimmers/renderers/vega-section-title-renderer.d.ts +2 -0
- package/dist/types/components/vega-section-title/types.d.ts +1 -0
- package/dist/types/components/vega-section-title/vega-section-title.d.ts +14 -0
- package/dist/types/components.d.ts +93 -8
- package/dist/types/helpers/calendar/calendar-date.d.ts +7 -0
- package/dist/types/helpers/calendar/calendar-view-generator/calendar-view-generator.abstract.d.ts +0 -1
- package/dist/types/helpers/event-manager/event-id/vega-internal-event-id.d.ts +1 -0
- package/dist/types/helpers/formatter/string-formatter/custom-formatter-strategy.d.ts +2 -1
- package/dist/types/helpers/formatter/string-formatter/number-mask-strategy.d.ts +2 -1
- package/dist/types/helpers/formatter/string-formatter/number-thousand-comma-strategy.d.ts +2 -1
- package/dist/types/helpers/formatter/string-formatter/string-format-strategy.abstract.d.ts +1 -0
- package/dist/types/helpers/formatter/string-formatter/string-mask-strategy.d.ts +32 -4
- package/dist/types/helpers/formatter/string-formatter/thousand-comma-strategy.d.ts +1 -0
- package/dist/types/helpers/keyboard/keyboard-manager.d.ts +1 -0
- package/dist/types/helpers/slimmers/aria-dialog-focusable-trap-slimmer.d.ts +20 -9
- package/dist/types/types/components.type.d.ts +3 -0
- package/dist/types/types/type-guard.d.ts +15 -1
- package/dist/types/types/ui.type.d.ts +11 -1
- package/dist/types/utils/ui.d.ts +17 -1
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-001d36af.js +1 -0
- package/dist/vega/p-01541820.entry.js +1 -0
- package/dist/vega/p-0304c3a7.js +1 -0
- package/dist/vega/p-08f03a52.entry.js +1 -0
- package/dist/vega/p-0a145766.entry.js +1 -0
- package/dist/vega/p-0d205fbf.js +1 -0
- package/dist/vega/p-0fc2ccc4.entry.js +1 -0
- package/dist/vega/p-118aeed1.entry.js +1 -0
- package/dist/vega/p-1a4e8d8a.js +1 -0
- package/dist/vega/p-23dc4064.entry.js +1 -0
- package/dist/vega/p-24b45c85.js +1 -0
- package/dist/vega/p-262a27d0.js +1 -0
- package/dist/vega/p-27dc6562.entry.js +1 -0
- package/dist/vega/p-295326ca.entry.js +1 -0
- package/dist/vega/p-2beace1c.entry.js +1 -0
- package/dist/vega/p-2ce2972f.js +1 -0
- package/dist/vega/p-2e7d5e28.entry.js +1 -0
- package/dist/vega/p-2f99c511.js +1 -0
- package/dist/vega/p-32592497.entry.js +1 -0
- package/dist/vega/p-33860e54.js +1 -0
- package/dist/vega/p-37a9f4b4.entry.js +1 -0
- package/dist/vega/p-4013d954.entry.js +1 -0
- package/dist/vega/p-42da45e3.entry.js +1 -0
- package/dist/vega/p-42e246e4.entry.js +1 -0
- package/dist/vega/p-479a169c.entry.js +1 -0
- package/dist/vega/p-47a2eec1.entry.js +1 -0
- package/dist/vega/p-49ae8c79.js +1 -0
- package/dist/vega/p-4ed416e7.js +1 -0
- package/dist/vega/p-53ba1adb.entry.js +1 -0
- package/dist/vega/p-55019e55.entry.js +1 -0
- package/dist/vega/p-565aac6e.entry.js +1 -0
- package/dist/vega/p-574586c9.entry.js +1 -0
- package/dist/vega/p-5781b9f4.entry.js +1 -0
- package/dist/vega/p-57827342.entry.js +1 -0
- package/dist/vega/p-59c6f795.js +1 -0
- package/dist/vega/p-5a8be21c.entry.js +1 -0
- package/dist/vega/p-5baff397.js +1 -0
- package/dist/vega/p-5e9f6fb6.entry.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-5f95a2fa.js +1 -0
- package/dist/vega/p-6216c30e.js +1 -0
- package/dist/vega/p-62e80151.entry.js +1 -0
- package/dist/vega/p-63d73fa0.entry.js +1 -0
- package/dist/vega/p-64e22fe5.js +1 -0
- package/dist/vega/p-679b1f00.entry.js +1 -0
- package/dist/vega/p-6e70d3cc.js +1 -0
- package/dist/vega/p-757bfca2.entry.js +1 -0
- package/dist/vega/p-76063dcb.js +1 -0
- package/dist/vega/p-76daa632.entry.js +1 -0
- package/dist/vega/p-77c6f14a.entry.js +1 -0
- package/dist/vega/p-7ac9e8ff.entry.js +1 -0
- package/dist/vega/p-83863463.js +1 -0
- package/dist/vega/p-88e6618d.js +1 -0
- package/dist/vega/p-90a0b9f3.entry.js +1 -0
- package/dist/vega/p-9324dd2c.entry.js +1 -0
- package/dist/vega/p-98c44c03.js +1 -0
- package/dist/vega/p-9aa1c66a.entry.js +1 -0
- package/dist/vega/p-9b01a28a.entry.js +1 -0
- package/dist/vega/p-9b14ac66.entry.js +1 -0
- package/dist/vega/p-9dcecdd3.js +1 -0
- package/dist/vega/p-a1d51bc2.js +1 -0
- package/dist/vega/p-ab4b06c9.entry.js +1 -0
- package/dist/vega/p-ac43be09.entry.js +1 -0
- package/dist/vega/p-add63fe0.entry.js +1 -0
- package/dist/vega/p-ae0f03c1.js +1 -0
- package/dist/vega/p-b525c800.entry.js +1 -0
- package/dist/vega/p-be651266.entry.js +1 -0
- package/dist/vega/p-c0d45f77.entry.js +1 -0
- package/dist/vega/p-c2e7992b.js +1 -0
- package/dist/vega/p-c56aa01c.entry.js +1 -0
- package/dist/vega/p-cc3c661c.entry.js +1 -0
- package/dist/vega/p-cda09e99.entry.js +1 -0
- package/dist/vega/p-d0ac7af8.js +1 -0
- package/dist/vega/p-d289a6af.js +3 -0
- package/dist/vega/p-d29e8972.entry.js +1 -0
- package/dist/vega/p-d47aa28f.js +1 -0
- package/dist/vega/p-d90eee9a.entry.js +1 -0
- package/dist/vega/p-da742a7f.entry.js +1 -0
- package/dist/vega/p-dc6e7a77.js +1 -0
- package/dist/vega/p-dcf8f58f.entry.js +1 -0
- package/dist/vega/p-dff66a67.entry.js +1 -0
- package/dist/vega/p-e1117034.entry.js +1 -0
- package/dist/vega/p-e223e0dc.entry.js +1 -0
- package/dist/vega/p-e22e5aa1.js +1 -0
- package/dist/vega/p-e753fac2.entry.js +1 -0
- package/dist/vega/p-e7a4b760.entry.js +1 -0
- package/dist/vega/p-e8fc8495.entry.js +1 -0
- package/dist/vega/p-ea2b5dbb.js +1 -0
- package/dist/vega/p-eccabba7.entry.js +1 -0
- package/dist/vega/p-f0d605e9.entry.js +1 -0
- package/dist/vega/p-f28a6074.js +1 -0
- package/dist/vega/p-f2c65579.entry.js +1 -0
- package/dist/vega/p-f2cef51a.js +1 -0
- package/dist/vega/p-f40d479d.entry.js +1 -0
- package/dist/vega/p-f5013494.entry.js +1 -0
- package/dist/vega/p-f509b439.js +1 -0
- package/dist/vega/p-f5d3ce94.js +1 -0
- package/dist/vega/p-f69e2801.entry.js +1 -0
- package/dist/vega/p-fa654762.entry.js +1 -0
- package/dist/vega/p-fbc5a7f6.entry.js +1 -0
- package/dist/vega/p-fd5ddc55.js +1 -0
- package/dist/vega/p-ff47aeee.entry.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +3 -2
- package/dist/cjs/app-globals-e9fdfbf9.js +0 -430
- package/dist/cjs/aria-dialog-focusable-trap-slimmer-6faafc3e.js +0 -218
- package/dist/cjs/child-nodes-notify-observer-slimmer-06c78f97.js +0 -90
- package/dist/cjs/code-block-847534e3.js +0 -4453
- package/dist/cjs/component-value-history-controller-slimmer.abstract-d7f9812a.js +0 -714
- package/dist/cjs/content-state-99be18a3.js +0 -4076
- package/dist/cjs/date-required-rule-3823d506.js +0 -92
- package/dist/cjs/design-token-b497bb6e.js +0 -402
- package/dist/cjs/dom-node-subject-observer-factory-f7ed3bdc.js +0 -141
- package/dist/cjs/element-appender-slimmer-eba4f3a2.js +0 -1974
- package/dist/cjs/event-emit-slimmer-83f8e2bd.js +0 -267
- package/dist/cjs/form-field-controller-slimmer-93ca7239.js +0 -1266
- package/dist/cjs/image-annotation-action-9d6af380.js +0 -285
- package/dist/cjs/inject-keyboard-manager-23d07d87.js +0 -37
- package/dist/cjs/keyboard-manager-3923e29b.js +0 -140
- package/dist/cjs/keyboard-manager-slimmer-f602725d.js +0 -39
- package/dist/cjs/month-view-generator-aa8e8e74.js +0 -102
- package/dist/cjs/public-rules-1dbda124.js +0 -46
- package/dist/cjs/range-60fb9dd2.js +0 -178
- package/dist/cjs/responsive-format-facade-a32cdb67.js +0 -944
- package/dist/cjs/rich-text-editor-required-rule-b4aab68d.js +0 -64
- package/dist/cjs/split-cell-operation-190d4a87.js +0 -2411
- package/dist/cjs/string-format-strategy.abstract-730088ee.js +0 -60
- package/dist/cjs/string-input-formatter-slimmer-9d6df58b.js +0 -230
- package/dist/cjs/string-mask-strategy-b69e3b9e.js +0 -172
- package/dist/cjs/style-formatter-9d8a4ad2.js +0 -34
- package/dist/cjs/sub-state-notify-slimmer-c80b9d21.js +0 -81
- package/dist/cjs/sub-state-observer-slimmer-15740c97.js +0 -134
- package/dist/cjs/time-required-rule-6524b650.js +0 -141
- package/dist/cjs/token-extension-b7c4ea17.js +0 -7438
- package/dist/cjs/type-guard-2a46bca5.js +0 -2022
- package/dist/cjs/ui-b3db0122.js +0 -277
- package/dist/cjs/valid-credit-card-number-rule-8eb02ea7.js +0 -173
- package/dist/cjs/vega-internal-event-id-67bb91c1.js +0 -124
- package/dist/cjs/wait-for-component-did-render-9e41b39e.js +0 -32
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/test/calendar-event-repeat-pattern-factory.test.js +0 -195
- package/dist/collection/components/vega-calendar/slimmers/common/layout/test/long-event-layout-generator.test.js +0 -94
- package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/timed-event/layout/test/day-view-event-layout-generator.test.js +0 -72
- package/dist/collection/components/vega-code-block/test/code-block-range.test.js +0 -81
- package/dist/collection/components/vega-dropdown/test/share.js +0 -13
- package/dist/collection/components/vega-input-credit-card/test/share.js +0 -21
- package/dist/collection/components/vega-nav/vega-left-nav/test/vega-left-nav-mock-data.js +0 -147
- package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.test.js +0 -21
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/action-handle-strategy-registry.test.js +0 -71
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-delete-node-content-strategy.test.js +0 -69
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-insert-line-break-with-blocks-strategy.test.js +0 -24
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/code-block-strategy-registry.test.js +0 -20
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.js +0 -15
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.js +0 -32
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-set-annotation-map-strategy.test.js +0 -11
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-update-url-strategy.test.js +0 -16
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-block-strategy-register.test.js +0 -20
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-item-strategy-register.test.js +0 -87
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-split-text-strategy.test.js +0 -32
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-update-annotation-map-strategy.test.js +0 -17
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.js +0 -77
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/update-selected-text-strategy.test.js +0 -23
- package/dist/collection/components/vega-rich-text-editor/test/dto/annotation-actions.test.js +0 -39
- package/dist/collection/components/vega-rich-text-editor/test/dto/annotation-style.test.js +0 -71
- package/dist/collection/components/vega-rich-text-editor/test/dto/annotations.test.js +0 -381
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/code-block.test.js +0 -54
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/html-block.test.js +0 -167
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/image-block.test.js +0 -90
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/list-block.test.js +0 -176
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/list-item.test.js +0 -188
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/text-block.test.js +0 -193
- package/dist/collection/components/vega-rich-text-editor/test/dto/content-state.test.js +0 -3375
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/image-node.test.js +0 -108
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/text-node.test.js +0 -510
- package/dist/collection/components/vega-rich-text-editor/test/dto/range.test.js +0 -53
- package/dist/collection/components/vega-rich-text-editor/test/e2e-utils.js +0 -182
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/custom-attribute-annotation-handler.test.js +0 -49
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/element-to-text-node-strategy.test.js +0 -38
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/html-element-to-annotation-generator.test.js +0 -26
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.test.js +0 -32
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.test.js +0 -61
- package/dist/collection/components/vega-rich-text-editor/test/extensions/extension-test-utils.js +0 -43
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/annotation-handler/annotation-handler-registration.test.js +0 -164
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/annotation-handler/table-annotation-handler.test.js +0 -298
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/annotation-handler/table-cell-annotation-handler.test.js +0 -316
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/annotation-handler/table-head-cell-annotation-handler.test.js +0 -411
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/caption-operation.test.js +0 -99
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-annotation.test.js +0 -181
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-caption-annotations.test.js +0 -84
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-cell-annotation.test.js +0 -331
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-color-annotation.test.js +0 -32
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-dto.test.js +0 -1094
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-element-to-dto-strategies.test.js +0 -1590
- package/dist/collection/components/vega-rich-text-editor/test/extensions/table/table-test-utils.js +0 -172
- package/dist/collection/components/vega-rich-text-editor/test/filter-styles-strategies/filter-styles-strategy.test.js +0 -129
- package/dist/collection/components/vega-rich-text-editor/test/fixture.js +0 -257
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/html-content-cleaner.test.js +0 -186
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-after-opening-tag-processor.test.js +0 -22
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-before-closing-tag-processor.test.js +0 -22
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-between-tags-processor.test.js +0 -26
- package/dist/collection/components/vega-rich-text-editor/test/spec-utils.js +0 -35
- package/dist/collection/components/vega-sidenav/test/test.helper.js +0 -68
- package/dist/collection/components/vega-table/slimmers/controllers/dto/test/column-render-input-model.test.js +0 -83
- package/dist/collection/components/vega-table/slimmers/controllers/dto/test/column-structure-model.test.js +0 -147
- package/dist/collection/components/vega-table/test/utils.js +0 -22
- package/dist/collection/components/vega-table/test/vega-table-sorter.test.js +0 -508
- package/dist/collection/constants/tests/validator.test.js +0 -24
- package/dist/collection/decorators/method-decorators/tests/component-load-required.test.js +0 -114
- package/dist/collection/decorators/property-decorators/tests/inject-element-appender-proxy.test.js +0 -237
- package/dist/collection/decorators/property-decorators/tests/inject-keyboard-manager.test.js +0 -91
- package/dist/collection/global/tests/before-vega-load.test.js +0 -62
- package/dist/collection/helpers/calendar/test/calendar-date-time.test.js +0 -27
- package/dist/collection/helpers/calendar/test/calendar-date.test.js +0 -172
- package/dist/collection/helpers/calendar/test/calendar-event.test.js +0 -263
- package/dist/collection/helpers/calendar/test/calendar-period/day-period.test.js +0 -118
- package/dist/collection/helpers/calendar/test/calendar-period/month-period.test.js +0 -144
- package/dist/collection/helpers/calendar/test/calendar-period/week-period.test.js +0 -114
- package/dist/collection/helpers/calendar/test/calendar-time.test.js +0 -45
- package/dist/collection/helpers/calendar/test/calendar-view-generator/day-view-generator.test.js +0 -19
- package/dist/collection/helpers/calendar/test/calendar-view-generator/month-view-generator.test.js +0 -123
- package/dist/collection/helpers/calendar/test/calendar-view-generator/week-view-generator.test.js +0 -43
- package/dist/collection/helpers/calendar/test/calendar-view.test.js +0 -9
- package/dist/collection/helpers/calendar/test/index.test.js +0 -13
- package/dist/collection/helpers/calendar/test/utils.test.js +0 -62
- package/dist/collection/helpers/change-manager/test/change-manager.test.js +0 -30
- package/dist/collection/helpers/change-manager/test/dom-node-subject-factory.test.js +0 -38
- package/dist/collection/helpers/chart/test/controllers/chart-dimension-controller.test.js +0 -63
- package/dist/collection/helpers/chart/test/drawers/arc-path-drawer.test.js +0 -55
- package/dist/collection/helpers/chart/test/drawers/legend-drawer.test.js +0 -94
- package/dist/collection/helpers/chart/test/drawers/line-drawer.test.js +0 -25
- package/dist/collection/helpers/chart/test/drawers/path-drawer.test.js +0 -21
- package/dist/collection/helpers/chart/test/drawers/rect-drawer.test.js +0 -78
- package/dist/collection/helpers/chart/test/drawers/text-drawer.test.js +0 -25
- package/dist/collection/helpers/chart/test/drawers/x-axis-drawer.test.js +0 -38
- package/dist/collection/helpers/chart/test/drawers/y-axis-drawer.test.js +0 -44
- package/dist/collection/helpers/chart/test/graph-context-factory.test.js +0 -17
- package/dist/collection/helpers/chart/test/input-processors/format-time-positions-input-processor.test.js +0 -62
- package/dist/collection/helpers/chart/test/input-processors/horizontal-x-axis-input-processor.test.js +0 -45
- package/dist/collection/helpers/chart/test/input-processors/horizontal-y-axis-input-processor.test.js +0 -80
- package/dist/collection/helpers/chart/test/input-processors/layout-input-processor.test.js +0 -40
- package/dist/collection/helpers/chart/test/input-processors/line-path-input-processor.test.js +0 -16
- package/dist/collection/helpers/chart/test/input-processors/pie-chart-filter-input-processor.test.js +0 -20
- package/dist/collection/helpers/chart/test/input-processors/pie-chart-radius-input-processor.test.js +0 -48
- package/dist/collection/helpers/chart/test/input-processors/sort-positions-input-processor.test.js +0 -53
- package/dist/collection/helpers/chart/test/input-processors/x-axis-input-processor.test.js +0 -78
- package/dist/collection/helpers/chart/test/input-processors/x-axis-label-formatter-input-processor.test.js +0 -109
- package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.js +0 -39
- package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.test.js +0 -55
- package/dist/collection/helpers/chart/test/interacting-entry-generator/arc-path-hover-generator.test.js +0 -11
- package/dist/collection/helpers/chart/test/interacting-entry-generator/pie-legend-hover-generator.test.js +0 -25
- package/dist/collection/helpers/chart/test/interactors/interactor-factory.test.js +0 -19
- package/dist/collection/helpers/chart/test/interactors/svg-interactor.test.js +0 -48
- package/dist/collection/helpers/chart/test/line-chart.test.js +0 -96
- package/dist/collection/helpers/chart/test/pie-chart.test.js +0 -38
- package/dist/collection/helpers/chart/test/renderers/canvas-renderer.test.js +0 -31
- package/dist/collection/helpers/chart/test/renderers/renderer-factory.test.js +0 -19
- package/dist/collection/helpers/chart/test/renderers/svg-renderer.test.js +0 -99
- package/dist/collection/helpers/code-format/test/code-formatter.test.js +0 -410
- package/dist/collection/helpers/common/test/common.test.js +0 -7
- package/dist/collection/helpers/common/test/wait-for-component-did-render.test.js +0 -67
- package/dist/collection/helpers/common/test/wait-for-vega-handler.test.js +0 -17
- package/dist/collection/helpers/csp/test/styles-preservator.test.js +0 -207
- package/dist/collection/helpers/csp/test/vega-nonce-manager.test.js +0 -177
- package/dist/collection/helpers/dialog/test/vega-dialog-controller.test.js +0 -114
- package/dist/collection/helpers/event-manager/test/child-nodes-event-prevent-slimmer.test.js +0 -209
- package/dist/collection/helpers/event-manager/test/child-nodes-notify-observer-slimmer.test.js +0 -81
- package/dist/collection/helpers/event-manager/test/component-event-id-map.test.js +0 -16
- package/dist/collection/helpers/event-manager/test/event-emit-slimmer.test.js +0 -144
- package/dist/collection/helpers/event-manager/test/internal-vega-event-manager.test.js +0 -70
- package/dist/collection/helpers/event-manager/test/jquery-delegated-strategy-controller.test.js +0 -131
- package/dist/collection/helpers/event-manager/test/vega-event-id.test.js +0 -16
- package/dist/collection/helpers/event-manager/test/vega-event-manager.test.js +0 -97
- package/dist/collection/helpers/feature-control/tests/feature-flag-controller.test.js +0 -69
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-border-radius-formatter.test.js +0 -64
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-border-radius-style-formatter.test.js +0 -32
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-box-display-formatter.test.js +0 -31
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-custom-formatter.test.js +0 -17
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-display-formatter.test.js +0 -23
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-flex-direction-formatter.test.js +0 -19
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-flex-wrap-formatter.test.js +0 -19
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-format-mediator.test.js +0 -43
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-gap-formatter.ts.test.js +0 -29
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-grid-column-formatter.test.js +0 -23
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-grid-justify-items-formatter.test.js +0 -19
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-grid-row-formatter.test.js +0 -27
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-margin-formatter.test.js +0 -43
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-margin-style-formatter.test.js +0 -28
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-padding-formatter.test.js +0 -43
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-padding-style-formatter.test.js +0 -28
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-size-formatter.test.js +0 -27
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-text-align-formatter.test.js +0 -19
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-translocation-formatter.test.js +0 -51
- package/dist/collection/helpers/formatter/test/responsive-map-formatter/responsive-width-and-height-formatter.test.js +0 -20
- package/dist/collection/helpers/formatter/test/state-formatter/state-background-color-formatter.test.js +0 -18
- package/dist/collection/helpers/formatter/test/state-formatter/state-border-color-formatter.test.js +0 -13
- package/dist/collection/helpers/formatter/test/state-formatter/state-border-formatter.test.js +0 -13
- package/dist/collection/helpers/formatter/test/state-formatter/state-format-facade.test.js +0 -27
- package/dist/collection/helpers/formatter/test/state-formatter/state-shadow-formatter.test.js +0 -13
- package/dist/collection/helpers/formatter/test/string-formatter/custom-formatter-strategy.test.js +0 -13
- package/dist/collection/helpers/formatter/test/string-formatter/number-mask-strategy.test.js +0 -101
- package/dist/collection/helpers/formatter/test/string-formatter/number-thousand-comma-mask-strategy.test.js +0 -40
- package/dist/collection/helpers/formatter/test/string-formatter/string-mask-strategy.test.js +0 -147
- package/dist/collection/helpers/formatter/test/string-formatter/thousand-comma-strategy.test.js +0 -21
- package/dist/collection/helpers/formatter/test/string-formatter/vega-phone-number-input-strategy.test.js +0 -43
- package/dist/collection/helpers/formatter/test/style-formatter.test.js +0 -16
- package/dist/collection/helpers/icon/test/icon-manager-controller.test.js +0 -101
- package/dist/collection/helpers/icon/test/internal-icon-manager.test.js +0 -18
- package/dist/collection/helpers/immutable/test/immutable-array.test.js +0 -78
- package/dist/collection/helpers/immutable/test/immutable-map.test.js +0 -83
- package/dist/collection/helpers/immutable/test/immutable-set.test.js +0 -87
- package/dist/collection/helpers/keyboard/test/keyboard-manager.test.js +0 -241
- package/dist/collection/helpers/level-tracker/test/nested-level-tracker.test.js +0 -33
- package/dist/collection/helpers/loading-indicator/tests/vega-loader-controller.test.js +0 -192
- package/dist/collection/helpers/notify/tests/vega-notify-controller.test.js +0 -165
- package/dist/collection/helpers/paginator/test/value-paginator.test.js +0 -15
- package/dist/collection/helpers/queue/test/synchronize-task-queue.test.js +0 -76
- package/dist/collection/helpers/remote-invocation/remote-invocation-registry.test.js +0 -17
- package/dist/collection/helpers/rte-manager/rte.manager.test.js +0 -94
- package/dist/collection/helpers/skeleton-loader/tests/vega-skeleton-loader-controller.test.js +0 -194
- package/dist/collection/helpers/slimmers/element-appender/body-positioned-wrapper/test/vega-popover-wrapper.test.js +0 -66
- package/dist/collection/helpers/slimmers/element-appender/test/element-appender-slimmer.test.js +0 -621
- package/dist/collection/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.js +0 -248
- package/dist/collection/helpers/slimmers/mutation-observer/test/data-tab-index-value-mapper.test.js +0 -120
- package/dist/collection/helpers/slimmers/mutation-observer/test/mutation-observer-slimmer.test.js +0 -182
- package/dist/collection/helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.js +0 -399
- package/dist/collection/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.js +0 -383
- package/dist/collection/helpers/slimmers/runtime-metrics/test/public-api-runtime-metrics-slimmer-base.test.js +0 -96
- package/dist/collection/helpers/slimmers/sub-state/test/sub-state-observer-slimmer.test.js +0 -228
- package/dist/collection/helpers/slimmers/test/aria-dialog-focusable-trap-slimmer.test.js +0 -375
- package/dist/collection/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.js +0 -46
- package/dist/collection/helpers/slimmers/test/brand-switch-state-controller-slimmer.test.js +0 -75
- package/dist/collection/helpers/slimmers/test/component-global-style-slimmer.test.js +0 -104
- package/dist/collection/helpers/slimmers/test/component-usage-runtime-metrics.test.js +0 -72
- package/dist/collection/helpers/slimmers/test/dark-mode-state-controller.test.js +0 -65
- package/dist/collection/helpers/slimmers/test/deprecated-property-slimmer.test.js +0 -36
- package/dist/collection/helpers/slimmers/test/field-error-controller-slimmer.test.js +0 -55
- package/dist/collection/helpers/slimmers/test/form-field-controller-slimmer.test.js +0 -278
- package/dist/collection/helpers/slimmers/test/form-field-valid-invoke-slimmer.test.js +0 -106
- package/dist/collection/helpers/slimmers/test/global/vega-nonce-injector-slimmer.test.js +0 -64
- package/dist/collection/helpers/slimmers/test/global/vega-translate-observer-slimmer.test.js +0 -89
- package/dist/collection/helpers/slimmers/test/global/vega-watch-method-cancel-slimmer.test.js +0 -101
- package/dist/collection/helpers/slimmers/test/keyboard-manager-slimmer.test.js +0 -90
- package/dist/collection/helpers/slimmers/test/page-resize-observer-slimmer.test.js +0 -278
- package/dist/collection/helpers/slimmers/test/string-input-formatter-slimmer.test.js +0 -220
- package/dist/collection/helpers/slimmers/test/translation-slimmer.test.js +0 -89
- package/dist/collection/helpers/theme/tests/theme-manager-controller.test.js +0 -614
- package/dist/collection/helpers/touch-helper/test/touch-listener.test.js +0 -122
- package/dist/collection/helpers/translation/tests/internal-translation-controller.test.js +0 -288
- package/dist/collection/helpers/translation/tests/translation.test.js +0 -46
- package/dist/collection/helpers/ui/test/element-appender.test.js +0 -530
- package/dist/collection/helpers/validator/test/rules/check-box-required-rule.test.js +0 -88
- package/dist/collection/helpers/validator/test/rules/custom-validation-rule.test.js +0 -56
- package/dist/collection/helpers/validator/test/rules/date-range-rule.test.js +0 -67
- package/dist/collection/helpers/validator/test/rules/date-required-rule.test.js +0 -120
- package/dist/collection/helpers/validator/test/rules/email-field-rule.test.js +0 -69
- package/dist/collection/helpers/validator/test/rules/file-uploader-required-rule.test.js +0 -7
- package/dist/collection/helpers/validator/test/rules/input-phone-number-required-rule.test.js +0 -105
- package/dist/collection/helpers/validator/test/rules/input-range-min-and-max-rule.test.js +0 -146
- package/dist/collection/helpers/validator/test/rules/input-range-required-rule.test.js +0 -82
- package/dist/collection/helpers/validator/test/rules/input-select-value-in-source-rule.test.js +0 -99
- package/dist/collection/helpers/validator/test/rules/max-number-rule.test.js +0 -97
- package/dist/collection/helpers/validator/test/rules/max-string-length-rule.test.js +0 -85
- package/dist/collection/helpers/validator/test/rules/min-and-max-date-rule.test.js +0 -174
- package/dist/collection/helpers/validator/test/rules/min-number-rule.test.js +0 -97
- package/dist/collection/helpers/validator/test/rules/min-string-length-rule.test.js +0 -85
- package/dist/collection/helpers/validator/test/rules/public-rules.test.js +0 -80
- package/dist/collection/helpers/validator/test/rules/required-field-rule.test.js +0 -126
- package/dist/collection/helpers/validator/test/rules/rich-text-editor-required-rule.test.js +0 -360
- package/dist/collection/helpers/validator/test/rules/time-range-required-rule.test.js +0 -82
- package/dist/collection/helpers/validator/test/rules/time-range-rule.test.js +0 -67
- package/dist/collection/helpers/validator/test/rules/time-required-rule.test.js +0 -116
- package/dist/collection/helpers/validator/test/rules/toggle-switch-required-rule.test.js +0 -72
- package/dist/collection/helpers/validator/test/rules/valid-credit-card-number-rule.test.js +0 -135
- package/dist/collection/helpers/validator/test/rules/valid-phone-number-rule.test.js +0 -95
- package/dist/collection/helpers/validator/test/validation-rule-handler/form-field-validation-rule-handler-chain.test.js +0 -65
- package/dist/collection/helpers/validator/test/validation-rule-handler/form-field-validation-rule-handler.test.js +0 -82
- package/dist/collection/helpers/validator/test/validator/form-field-controller.test.js +0 -205
- package/dist/collection/helpers/vega-telemetry-helper/test/vega-env-manager.test.js +0 -14
- package/dist/collection/helpers/zindex/test/internal-vega-z-index-manager.test.js +0 -176
- package/dist/collection/helpers/zindex/test/vega-z-index-manager.test.js +0 -46
- package/dist/collection/polyfill/d3/test/d3-array-polyfill.test.js +0 -72
- package/dist/collection/polyfill/d3/test/d3-axis-polyfill.test.js +0 -171
- package/dist/collection/polyfill/d3/test/d3-integration.test.js +0 -137
- package/dist/collection/polyfill/d3/test/d3-scale-polyfill.test.js +0 -382
- package/dist/collection/polyfill/d3/test/d3-selection-polyfill.test.js +0 -239
- package/dist/collection/polyfill/d3/test/d3-shape-polyfill.test.js +0 -225
- package/dist/collection/polyfill/d3/test/d3-time-format-polyfill.test.js +0 -162
- package/dist/collection/polyfill/d3/test/d3-time-polyfill.test.js +0 -76
- package/dist/collection/polyfill/d3/test/index.test.js +0 -78
- package/dist/collection/polyfill/libphonenumber/test/as-you-type.test.js +0 -309
- package/dist/collection/polyfill/libphonenumber/test/format-helpers.test.js +0 -192
- package/dist/collection/polyfill/libphonenumber/test/index.test.js +0 -16
- package/dist/collection/polyfill/libphonenumber/test/metadata.test.js +0 -196
- package/dist/collection/polyfill/libphonenumber/test/parse-phone-number.test.js +0 -218
- package/dist/collection/polyfill/libphonenumber/test/phone-number.test.js +0 -56
- package/dist/collection/polyfill/prism/test/css.test.js +0 -61
- package/dist/collection/polyfill/prism/test/javascript.test.js +0 -113
- package/dist/collection/polyfill/prism/test/jsx.test.js +0 -48
- package/dist/collection/polyfill/prism/test/language-registry.test.js +0 -77
- package/dist/collection/polyfill/prism/test/markup.test.js +0 -57
- package/dist/collection/polyfill/prism/test/test-utils.js +0 -22
- package/dist/collection/polyfill/prism/test/tokenizer.test.js +0 -180
- package/dist/collection/polyfill/prism/test/tsx.test.js +0 -87
- package/dist/collection/polyfill/prism/test/typescript.test.js +0 -86
- package/dist/collection/polyfill/shadow-selection/test/shadow-selection-polyfill.test.js +0 -234
- package/dist/collection/polyfill/test-polyfill/e2e/retry.js +0 -42
- package/dist/collection/polyfill/test-polyfill/unit/create-touch-event.js +0 -31
- package/dist/collection/polyfill/test-polyfill/unit/events.js +0 -100
- package/dist/collection/polyfill/test-polyfill/unit/index.js +0 -3
- package/dist/collection/polyfill/test-polyfill/unit/methods.js +0 -47
- package/dist/collection/polyfill/test-polyfill/unit/range.js +0 -15
- package/dist/collection/polyfill/test-polyfill/unit/shadow-selection.js +0 -17
- package/dist/collection/polyfill/tinycolor/tinycolor-polyfill.test.js +0 -361
- package/dist/collection/test-assets/test-icons.js +0 -5
- package/dist/collection/types/test/type-guard.test.js +0 -46
- package/dist/collection/utils/e2e-utils.js +0 -389
- package/dist/collection/utils/sanitize/test/empty-strategy.test.js +0 -12
- package/dist/collection/utils/sanitize/test/html-sanitizer.test.js +0 -57
- package/dist/collection/utils/sanitize/test/label-strategy.test.js +0 -56
- package/dist/collection/utils/sanitize/test/sanitize-strategy.test.js +0 -85
- package/dist/collection/utils/sanitize/test/sanitize.test.js +0 -22
- package/dist/collection/utils/sanitize/test/serialize-fragment.test.js +0 -25
- package/dist/collection/utils/sanitize/test/style-strategy.test.js +0 -45
- package/dist/collection/utils/spec-utils.js +0 -226
- package/dist/collection/utils/test/accessibility.test.js +0 -40
- package/dist/collection/utils/test/api.test.js +0 -34
- package/dist/collection/utils/test/array.test.js +0 -260
- package/dist/collection/utils/test/breakpoint.test.js +0 -37
- package/dist/collection/utils/test/component.test.js +0 -59
- package/dist/collection/utils/test/date.test.js +0 -104
- package/dist/collection/utils/test/design-token.test.js +0 -91
- package/dist/collection/utils/test/effect.test.js +0 -64
- package/dist/collection/utils/test/local-storage.test.js +0 -38
- package/dist/collection/utils/test/log.test.js +0 -49
- package/dist/collection/utils/test/misc.test.js +0 -40
- package/dist/collection/utils/test/number.test.js +0 -18
- package/dist/collection/utils/test/object.test.js +0 -77
- package/dist/collection/utils/test/pagination.test.js +0 -40
- package/dist/collection/utils/test/pixel.test.js +0 -29
- package/dist/collection/utils/test/safe-document.test.js +0 -13
- package/dist/collection/utils/test/spec-utils.test.js +0 -73
- package/dist/collection/utils/test/string.test.js +0 -8
- package/dist/collection/utils/test/test-utils.test.js +0 -70
- package/dist/collection/utils/test/timer.test.js +0 -16
- package/dist/collection/utils/test/ui.test.js +0 -301
- package/dist/collection/utils/test-utils.js +0 -156
- package/dist/esm/app-globals-776ccaa3.js +0 -428
- package/dist/esm/aria-dialog-focusable-trap-slimmer-cc98a7a4.js +0 -216
- package/dist/esm/child-nodes-notify-observer-slimmer-c7297b9f.js +0 -88
- package/dist/esm/code-block-58d1dbe5.js +0 -4395
- package/dist/esm/component-value-history-controller-slimmer.abstract-5beb8acb.js +0 -709
- package/dist/esm/content-state-dad1fd71.js +0 -4056
- package/dist/esm/date-required-rule-4c40a4eb.js +0 -90
- package/dist/esm/design-token-9c4eb6b1.js +0 -388
- package/dist/esm/dom-node-subject-observer-factory-94b2e2c3.js +0 -138
- package/dist/esm/element-appender-slimmer-fde815dc.js +0 -1972
- package/dist/esm/event-emit-slimmer-b236945b.js +0 -265
- package/dist/esm/form-field-controller-slimmer-00fa3678.js +0 -1264
- package/dist/esm/image-annotation-action-1ec7b461.js +0 -280
- package/dist/esm/inject-keyboard-manager-784b1364.js +0 -35
- package/dist/esm/keyboard-manager-e020039f.js +0 -138
- package/dist/esm/keyboard-manager-slimmer-4722d20c.js +0 -37
- package/dist/esm/month-view-generator-6fe1f491.js +0 -98
- package/dist/esm/public-rules-1626fb0d.js +0 -31
- package/dist/esm/range-4f9bf69d.js +0 -176
- package/dist/esm/responsive-format-facade-e8534e59.js +0 -940
- package/dist/esm/rich-text-editor-required-rule-c391aeb6.js +0 -62
- package/dist/esm/split-cell-operation-55cd9fae.js +0 -2360
- package/dist/esm/string-format-strategy.abstract-8c48e515.js +0 -58
- package/dist/esm/string-input-formatter-slimmer-519480ce.js +0 -228
- package/dist/esm/string-mask-strategy-8070817e.js +0 -170
- package/dist/esm/style-formatter-7afd0680.js +0 -32
- package/dist/esm/sub-state-notify-slimmer-54531808.js +0 -79
- package/dist/esm/sub-state-observer-slimmer-b3a773c5.js +0 -132
- package/dist/esm/time-required-rule-2569e5ad.js +0 -138
- package/dist/esm/token-extension-612575cb.js +0 -7417
- package/dist/esm/type-guard-c20cbbff.js +0 -1948
- package/dist/esm/ui-ac244bf0.js +0 -261
- package/dist/esm/valid-credit-card-number-rule-b9c3c2f8.js +0 -171
- package/dist/esm/vega-internal-event-id-8002b179.js +0 -72
- package/dist/esm/wait-for-component-did-render-1e62d6f7.js +0 -30
- package/dist/types/components/vega-calendar/slimmers/common/helpers/test/calendar-event-repeat-pattern-factory.test.d.ts +0 -1
- package/dist/types/components/vega-calendar/slimmers/common/layout/test/long-event-layout-generator.test.d.ts +0 -1
- package/dist/types/components/vega-calendar/slimmers/day-view/renderers/timed-event/layout/test/day-view-event-layout-generator.test.d.ts +0 -1
- package/dist/types/components/vega-code-block/test/code-block-range.test.d.ts +0 -1
- package/dist/types/components/vega-dropdown/test/share.d.ts +0 -12
- package/dist/types/components/vega-input-credit-card/test/share.d.ts +0 -18
- package/dist/types/components/vega-nav/vega-left-nav/test/vega-left-nav-mock-data.d.ts +0 -4
- package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/action-handle-strategy-registry.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-delete-node-content-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-insert-line-break-with-blocks-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/code-block-strategy-registry.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-set-annotation-map-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-update-url-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-block-strategy-register.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-item-strategy-register.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-split-text-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-update-annotation-map-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/update-selected-text-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/annotation-actions.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/annotation-style.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/annotations.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/code-block.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/html-block.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/image-block.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/list-block.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/list-item.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/text-block.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/content-state.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/nodes/image-node.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/nodes/text-node.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/dto/range.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/e2e-utils.d.ts +0 -67
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/custom-attribute-annotation-handler.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/element-to-text-node-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/html-element-to-annotation-generator.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/extension-test-utils.d.ts +0 -21
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/annotation-handler/annotation-handler-registration.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/annotation-handler/table-annotation-handler.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/annotation-handler/table-cell-annotation-handler.test.d.ts +0 -8
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/annotation-handler/table-head-cell-annotation-handler.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/caption-operation.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-annotation.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-caption-annotations.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-cell-annotation.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-color-annotation.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-dto.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-element-to-dto-strategies.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/extensions/table/table-test-utils.d.ts +0 -11
- package/dist/types/components/vega-rich-text-editor/test/filter-styles-strategies/filter-styles-strategy.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/fixture.d.ts +0 -19
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/html-content-cleaner.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-after-opening-tag-processor.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-before-closing-tag-processor.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-between-tags-processor.test.d.ts +0 -1
- package/dist/types/components/vega-rich-text-editor/test/spec-utils.d.ts +0 -19
- package/dist/types/components/vega-sidenav/test/test.helper.d.ts +0 -6
- package/dist/types/components/vega-table/slimmers/controllers/dto/test/column-render-input-model.test.d.ts +0 -1
- package/dist/types/components/vega-table/slimmers/controllers/dto/test/column-structure-model.test.d.ts +0 -1
- package/dist/types/components/vega-table/test/utils.d.ts +0 -9
- package/dist/types/components/vega-table/test/vega-table-sorter.test.d.ts +0 -1
- package/dist/types/constants/tests/validator.test.d.ts +0 -1
- package/dist/types/decorators/method-decorators/tests/component-load-required.test.d.ts +0 -1
- package/dist/types/decorators/property-decorators/tests/inject-element-appender-proxy.test.d.ts +0 -1
- package/dist/types/decorators/property-decorators/tests/inject-keyboard-manager.test.d.ts +0 -1
- package/dist/types/global/tests/before-vega-load.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-date-time.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-date.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-event.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-period/day-period.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-period/month-period.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-period/week-period.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-time.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-view-generator/day-view-generator.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-view-generator/month-view-generator.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-view-generator/week-view-generator.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/calendar-view.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/index.test.d.ts +0 -1
- package/dist/types/helpers/calendar/test/utils.test.d.ts +0 -1
- package/dist/types/helpers/change-manager/test/change-manager.test.d.ts +0 -1
- package/dist/types/helpers/change-manager/test/dom-node-subject-factory.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/controllers/chart-dimension-controller.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/arc-path-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/legend-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/line-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/path-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/rect-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/text-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/x-axis-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/drawers/y-axis-drawer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/graph-context-factory.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/format-time-positions-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/horizontal-x-axis-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/horizontal-y-axis-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/layout-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/line-path-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/pie-chart-filter-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/pie-chart-radius-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/sort-positions-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/x-axis-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/x-axis-label-formatter-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/input-processors/y-axis-input-processor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/interacting-entry-generator/arc-path-hover-generator.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/interacting-entry-generator/pie-legend-hover-generator.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/interactors/interactor-factory.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/interactors/svg-interactor.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/line-chart.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/pie-chart.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/renderers/canvas-renderer.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/renderers/renderer-factory.test.d.ts +0 -1
- package/dist/types/helpers/chart/test/renderers/svg-renderer.test.d.ts +0 -1
- package/dist/types/helpers/code-format/test/code-formatter.test.d.ts +0 -1
- package/dist/types/helpers/common/test/common.test.d.ts +0 -1
- package/dist/types/helpers/common/test/wait-for-component-did-render.test.d.ts +0 -1
- package/dist/types/helpers/common/test/wait-for-vega-handler.test.d.ts +0 -1
- package/dist/types/helpers/csp/test/styles-preservator.test.d.ts +0 -1
- package/dist/types/helpers/csp/test/vega-nonce-manager.test.d.ts +0 -1
- package/dist/types/helpers/dialog/test/vega-dialog-controller.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/child-nodes-event-prevent-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/child-nodes-notify-observer-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/component-event-id-map.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/event-emit-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/internal-vega-event-manager.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/jquery-delegated-strategy-controller.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/vega-event-id.test.d.ts +0 -1
- package/dist/types/helpers/event-manager/test/vega-event-manager.test.d.ts +0 -1
- package/dist/types/helpers/feature-control/tests/feature-flag-controller.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-border-radius-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-border-radius-style-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-box-display-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-custom-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-display-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-flex-direction-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-flex-wrap-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-format-mediator.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-gap-formatter.ts.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-grid-column-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-grid-justify-items-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-grid-row-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-margin-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-margin-style-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-padding-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-padding-style-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-size-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-text-align-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-translocation-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/responsive-map-formatter/responsive-width-and-height-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/state-formatter/state-background-color-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/state-formatter/state-border-color-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/state-formatter/state-border-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/state-formatter/state-format-facade.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/state-formatter/state-shadow-formatter.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/string-formatter/custom-formatter-strategy.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/string-formatter/number-mask-strategy.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/string-formatter/number-thousand-comma-mask-strategy.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/string-formatter/string-mask-strategy.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/string-formatter/thousand-comma-strategy.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/string-formatter/vega-phone-number-input-strategy.test.d.ts +0 -1
- package/dist/types/helpers/formatter/test/style-formatter.test.d.ts +0 -1
- package/dist/types/helpers/icon/test/icon-manager-controller.test.d.ts +0 -1
- package/dist/types/helpers/icon/test/internal-icon-manager.test.d.ts +0 -1
- package/dist/types/helpers/immutable/test/immutable-array.test.d.ts +0 -1
- package/dist/types/helpers/immutable/test/immutable-map.test.d.ts +0 -1
- package/dist/types/helpers/immutable/test/immutable-set.test.d.ts +0 -1
- package/dist/types/helpers/keyboard/test/keyboard-manager.test.d.ts +0 -1
- package/dist/types/helpers/level-tracker/test/nested-level-tracker.test.d.ts +0 -1
- package/dist/types/helpers/loading-indicator/tests/vega-loader-controller.test.d.ts +0 -1
- package/dist/types/helpers/notify/tests/vega-notify-controller.test.d.ts +0 -1
- package/dist/types/helpers/paginator/test/value-paginator.test.d.ts +0 -1
- package/dist/types/helpers/queue/test/synchronize-task-queue.test.d.ts +0 -1
- package/dist/types/helpers/remote-invocation/remote-invocation-registry.test.d.ts +0 -1
- package/dist/types/helpers/rte-manager/rte.manager.test.d.ts +0 -1
- package/dist/types/helpers/skeleton-loader/tests/vega-skeleton-loader-controller.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/element-appender/body-positioned-wrapper/test/vega-popover-wrapper.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/element-appender/test/element-appender-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/mutation-observer/test/data-tab-index-value-mapper.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/mutation-observer/test/mutation-observer-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.d.ts +0 -15
- package/dist/types/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/runtime-metrics/test/public-api-runtime-metrics-slimmer-base.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/sub-state/test/sub-state-observer-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/aria-dialog-focusable-trap-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/brand-switch-state-controller-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/component-global-style-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/component-usage-runtime-metrics.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/dark-mode-state-controller.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/deprecated-property-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/field-error-controller-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/form-field-controller-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/form-field-valid-invoke-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/global/vega-nonce-injector-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/global/vega-translate-observer-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/global/vega-watch-method-cancel-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/keyboard-manager-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/page-resize-observer-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/string-input-formatter-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/slimmers/test/translation-slimmer.test.d.ts +0 -1
- package/dist/types/helpers/theme/tests/theme-manager-controller.test.d.ts +0 -1
- package/dist/types/helpers/touch-helper/test/touch-listener.test.d.ts +0 -1
- package/dist/types/helpers/translation/tests/internal-translation-controller.test.d.ts +0 -1
- package/dist/types/helpers/translation/tests/translation.test.d.ts +0 -1
- package/dist/types/helpers/ui/test/element-appender.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/check-box-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/custom-validation-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/date-range-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/date-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/email-field-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/file-uploader-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/input-phone-number-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/input-range-min-and-max-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/input-range-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/input-select-value-in-source-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/max-number-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/max-string-length-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/min-and-max-date-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/min-number-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/min-string-length-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/public-rules.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/required-field-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/rich-text-editor-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/time-range-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/time-range-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/time-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/toggle-switch-required-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/valid-credit-card-number-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/rules/valid-phone-number-rule.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/validation-rule-handler/form-field-validation-rule-handler-chain.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/validation-rule-handler/form-field-validation-rule-handler.test.d.ts +0 -1
- package/dist/types/helpers/validator/test/validator/form-field-controller.test.d.ts +0 -1
- package/dist/types/helpers/vega-telemetry-helper/test/vega-env-manager.test.d.ts +0 -1
- package/dist/types/helpers/zindex/test/internal-vega-z-index-manager.test.d.ts +0 -1
- package/dist/types/helpers/zindex/test/vega-z-index-manager.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-array-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-axis-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-integration.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-scale-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-selection-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-shape-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-time-format-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/d3-time-polyfill.test.d.ts +0 -1
- package/dist/types/polyfill/d3/test/index.test.d.ts +0 -1
- package/dist/types/polyfill/libphonenumber/test/as-you-type.test.d.ts +0 -1
- package/dist/types/polyfill/libphonenumber/test/format-helpers.test.d.ts +0 -1
- package/dist/types/polyfill/libphonenumber/test/index.test.d.ts +0 -1
- package/dist/types/polyfill/libphonenumber/test/metadata.test.d.ts +0 -1
- package/dist/types/polyfill/libphonenumber/test/parse-phone-number.test.d.ts +0 -1
- package/dist/types/polyfill/libphonenumber/test/phone-number.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/css.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/javascript.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/jsx.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/language-registry.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/markup.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/test-utils.d.ts +0 -10
- package/dist/types/polyfill/prism/test/tokenizer.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/tsx.test.d.ts +0 -1
- package/dist/types/polyfill/prism/test/typescript.test.d.ts +0 -1
- package/dist/types/polyfill/shadow-selection/test/shadow-selection-polyfill.test.d.ts +0 -0
- package/dist/types/polyfill/test-polyfill/e2e/retry.d.ts +0 -8
- package/dist/types/polyfill/test-polyfill/unit/create-touch-event.d.ts +0 -11
- package/dist/types/polyfill/test-polyfill/unit/events.d.ts +0 -1
- package/dist/types/polyfill/test-polyfill/unit/index.d.ts +0 -3
- package/dist/types/polyfill/test-polyfill/unit/methods.d.ts +0 -1
- package/dist/types/polyfill/test-polyfill/unit/range.d.ts +0 -7
- package/dist/types/polyfill/test-polyfill/unit/shadow-selection.d.ts +0 -0
- package/dist/types/polyfill/tinycolor/tinycolor-polyfill.test.d.ts +0 -1
- package/dist/types/test-assets/test-icons.d.ts +0 -4
- package/dist/types/types/test/type-guard.test.d.ts +0 -1
- package/dist/types/utils/e2e-utils.d.ts +0 -160
- package/dist/types/utils/sanitize/test/empty-strategy.test.d.ts +0 -1
- package/dist/types/utils/sanitize/test/html-sanitizer.test.d.ts +0 -1
- package/dist/types/utils/sanitize/test/label-strategy.test.d.ts +0 -1
- package/dist/types/utils/sanitize/test/sanitize-strategy.test.d.ts +0 -1
- package/dist/types/utils/sanitize/test/sanitize.test.d.ts +0 -1
- package/dist/types/utils/sanitize/test/serialize-fragment.test.d.ts +0 -1
- package/dist/types/utils/sanitize/test/style-strategy.test.d.ts +0 -1
- package/dist/types/utils/spec-utils.d.ts +0 -109
- package/dist/types/utils/test/accessibility.test.d.ts +0 -1
- package/dist/types/utils/test/api.test.d.ts +0 -1
- package/dist/types/utils/test/array.test.d.ts +0 -1
- package/dist/types/utils/test/breakpoint.test.d.ts +0 -1
- package/dist/types/utils/test/component.test.d.ts +0 -1
- package/dist/types/utils/test/date.test.d.ts +0 -1
- package/dist/types/utils/test/design-token.test.d.ts +0 -1
- package/dist/types/utils/test/effect.test.d.ts +0 -1
- package/dist/types/utils/test/local-storage.test.d.ts +0 -1
- package/dist/types/utils/test/log.test.d.ts +0 -1
- package/dist/types/utils/test/misc.test.d.ts +0 -1
- package/dist/types/utils/test/number.test.d.ts +0 -1
- package/dist/types/utils/test/object.test.d.ts +0 -1
- package/dist/types/utils/test/pagination.test.d.ts +0 -1
- package/dist/types/utils/test/pixel.test.d.ts +0 -1
- package/dist/types/utils/test/safe-document.test.d.ts +0 -1
- package/dist/types/utils/test/spec-utils.test.d.ts +0 -1
- package/dist/types/utils/test/string.test.d.ts +0 -1
- package/dist/types/utils/test/test-utils.test.d.ts +0 -1
- package/dist/types/utils/test/timer.test.d.ts +0 -1
- package/dist/types/utils/test/ui.test.d.ts +0 -1
- package/dist/types/utils/test-utils.d.ts +0 -61
- package/dist/vega/p-02bab5ea.entry.js +0 -1
- package/dist/vega/p-02fec68b.entry.js +0 -1
- package/dist/vega/p-04f9b0d4.entry.js +0 -1
- package/dist/vega/p-076c6445.entry.js +0 -1
- package/dist/vega/p-085d45c9.js +0 -1
- package/dist/vega/p-0ac91609.entry.js +0 -1
- package/dist/vega/p-10e9438e.js +0 -1
- package/dist/vega/p-14dfdba3.entry.js +0 -1
- package/dist/vega/p-1665d4b8.entry.js +0 -1
- package/dist/vega/p-1784724a.entry.js +0 -1
- package/dist/vega/p-18378017.entry.js +0 -1
- package/dist/vega/p-19adff1f.entry.js +0 -1
- package/dist/vega/p-20981b17.entry.js +0 -1
- package/dist/vega/p-2697b52b.js +0 -1
- package/dist/vega/p-28c8ffb4.js +0 -1
- package/dist/vega/p-28ed34b3.entry.js +0 -1
- package/dist/vega/p-2bbbdf87.entry.js +0 -1
- package/dist/vega/p-2fd266fa.js +0 -1
- package/dist/vega/p-31945d6c.js +0 -1
- package/dist/vega/p-32a0eed4.entry.js +0 -1
- package/dist/vega/p-33475bcf.entry.js +0 -1
- package/dist/vega/p-33cacbd6.entry.js +0 -1
- package/dist/vega/p-3a0b3fed.entry.js +0 -1
- package/dist/vega/p-405ab757.js +0 -1
- package/dist/vega/p-4068e7de.js +0 -1
- package/dist/vega/p-408a1baa.entry.js +0 -1
- package/dist/vega/p-439c7c13.entry.js +0 -1
- package/dist/vega/p-441fd2b3.entry.js +0 -1
- package/dist/vega/p-46c7763f.entry.js +0 -1
- package/dist/vega/p-4a9be903.js +0 -1
- package/dist/vega/p-4e15958f.js +0 -1
- package/dist/vega/p-4e76a84d.entry.js +0 -1
- package/dist/vega/p-4ea3cf5f.entry.js +0 -1
- package/dist/vega/p-5395faac.entry.js +0 -1
- package/dist/vega/p-541ae774.entry.js +0 -1
- package/dist/vega/p-558a707e.entry.js +0 -1
- package/dist/vega/p-561e9097.entry.js +0 -1
- package/dist/vega/p-5b90bbfe.js +0 -1
- package/dist/vega/p-5d397ee0.entry.js +0 -1
- package/dist/vega/p-5dfd36d3.entry.js +0 -1
- package/dist/vega/p-603b851c.js +0 -1
- package/dist/vega/p-615bc3de.entry.js +0 -1
- package/dist/vega/p-6554a801.js +0 -1
- package/dist/vega/p-667d5b80.entry.js +0 -1
- package/dist/vega/p-679a4046.entry.js +0 -1
- package/dist/vega/p-6b19d33a.entry.js +0 -1
- package/dist/vega/p-6d6ea8b4.js +0 -1
- package/dist/vega/p-6db0556d.js +0 -1
- package/dist/vega/p-6e05fc55.js +0 -1
- package/dist/vega/p-6e13e2fc.js +0 -1
- package/dist/vega/p-71720290.entry.js +0 -1
- package/dist/vega/p-76f2e0f5.js +0 -1
- package/dist/vega/p-79df30e3.entry.js +0 -1
- package/dist/vega/p-7f68abf7.js +0 -1
- package/dist/vega/p-814c37be.entry.js +0 -1
- package/dist/vega/p-820906b8.entry.js +0 -1
- package/dist/vega/p-833b79ad.entry.js +0 -1
- package/dist/vega/p-8b891f36.entry.js +0 -1
- package/dist/vega/p-8cd70b3b.js +0 -1
- package/dist/vega/p-8f88fb57.js +0 -1
- package/dist/vega/p-905cf163.entry.js +0 -1
- package/dist/vega/p-916ef5dd.entry.js +0 -1
- package/dist/vega/p-937d5317.entry.js +0 -1
- package/dist/vega/p-972c594b.entry.js +0 -1
- package/dist/vega/p-9e6e76b2.entry.js +0 -1
- package/dist/vega/p-a01ef160.entry.js +0 -1
- package/dist/vega/p-a02f77c7.js +0 -1
- package/dist/vega/p-a0a39ec3.js +0 -1
- package/dist/vega/p-a2161e9d.js +0 -1
- package/dist/vega/p-a5543b6a.entry.js +0 -1
- package/dist/vega/p-a6ad6515.entry.js +0 -1
- package/dist/vega/p-a6fb81c5.js +0 -1
- package/dist/vega/p-ace7aa6c.entry.js +0 -1
- package/dist/vega/p-b15a2d4b.js +0 -1
- package/dist/vega/p-b4d72eff.entry.js +0 -1
- package/dist/vega/p-b589cafd.entry.js +0 -1
- package/dist/vega/p-b67672ae.entry.js +0 -1
- package/dist/vega/p-b7dd3ef2.entry.js +0 -1
- package/dist/vega/p-b91aff06.entry.js +0 -1
- package/dist/vega/p-bc142c5c.entry.js +0 -1
- package/dist/vega/p-c58c3e7e.entry.js +0 -1
- package/dist/vega/p-c962cf5b.js +0 -1
- package/dist/vega/p-cb0324e7.entry.js +0 -1
- package/dist/vega/p-d5a8bb62.entry.js +0 -1
- package/dist/vega/p-d6875e49.js +0 -1
- package/dist/vega/p-d862195c.entry.js +0 -1
- package/dist/vega/p-d94d785a.entry.js +0 -1
- package/dist/vega/p-db29681a.entry.js +0 -1
- package/dist/vega/p-dba91c23.entry.js +0 -1
- package/dist/vega/p-dccda3d1.js +0 -1
- package/dist/vega/p-dce9349e.js +0 -1
- package/dist/vega/p-dd4c3d9b.entry.js +0 -1
- package/dist/vega/p-e2268eef.js +0 -1
- package/dist/vega/p-e5da9f66.js +0 -1
- package/dist/vega/p-f7505267.js +0 -1
- package/dist/vega/p-fadeb5a2.entry.js +0 -1
- package/dist/vega/p-fb92092b.entry.js +0 -1
- package/dist/vega/p-fc3d6d9d.js +0 -1
- package/dist/vega/p-fc93b467.entry.js +0 -1
- package/dist/vega/p-fef22245.js +0 -1
|
@@ -0,0 +1,4962 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const codeBlock = require('./code-block-24b3d0e7.js');
|
|
4
|
+
const misc = require('./misc-3d30df91.js');
|
|
5
|
+
const typeGuard = require('./type-guard-362d7da3.js');
|
|
6
|
+
const changeManager = require('./change-manager-a297e4d2.js');
|
|
7
|
+
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-9110cb94.js');
|
|
8
|
+
const vegaInternalEventId = require('./vega-internal-event-id-a1837fa2.js');
|
|
9
|
+
const ui = require('./ui-ae4ee13d.js');
|
|
10
|
+
const object = require('./object-b53e9416.js');
|
|
11
|
+
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Remove list item nest list block strategy.
|
|
15
|
+
*/
|
|
16
|
+
class ListItemRemoveNestListStrategy extends codeBlock.ActionHandleStrategy {
|
|
17
|
+
/**
|
|
18
|
+
* Remove the nest list block from the list item, clear the property children when the children is empty.
|
|
19
|
+
*
|
|
20
|
+
* @param {RemoveNestListAction} action - The action instance.
|
|
21
|
+
* @param {RTEListItemBlock} target - The list item block.
|
|
22
|
+
*/
|
|
23
|
+
handleAction(action, target) {
|
|
24
|
+
if (target.nestList) {
|
|
25
|
+
if (target.nestList.length > 1) {
|
|
26
|
+
target.nestList = target.nestList.filter((child) => child !== action.nestListBlockToBeRemoved);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
target.nestList = undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Replace list item nest list strategy.
|
|
37
|
+
*/
|
|
38
|
+
class ListItemReplaceNestListStrategy extends codeBlock.ActionHandleStrategy {
|
|
39
|
+
/**
|
|
40
|
+
* @inheritDoc
|
|
41
|
+
*/
|
|
42
|
+
handleAction(action, target) {
|
|
43
|
+
action.newList.forEach((listBlock) => {
|
|
44
|
+
listBlock.parent = target;
|
|
45
|
+
});
|
|
46
|
+
target.nestList = action.newList;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Insert image node to list item block strategy.
|
|
52
|
+
*/
|
|
53
|
+
class ListItemInsertImageStrategy extends codeBlock.ActionHandleStrategy {
|
|
54
|
+
/**
|
|
55
|
+
* The image node can not insert into list item block, so insert image after parent list block.
|
|
56
|
+
*
|
|
57
|
+
* @param {InsertImageToBlockAction} action - The action instance.
|
|
58
|
+
* @param {RTEListItemBlock} target - The list item block.
|
|
59
|
+
*/
|
|
60
|
+
handleAction(action, target) {
|
|
61
|
+
target.parent.apply(action);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* List item block
|
|
67
|
+
*/
|
|
68
|
+
class RTEListItemBlock extends codeBlock.RTETextBlock {
|
|
69
|
+
constructor(id, nestList, options) {
|
|
70
|
+
super(id, 'list-item', options);
|
|
71
|
+
/**
|
|
72
|
+
* TODO: Refactor the list item properties children and nestList, merge two properties together.
|
|
73
|
+
*
|
|
74
|
+
* 1. Update the type of `children` to include `RTEListBlock` as a possible type.
|
|
75
|
+
* 2. The list block children should text block array and nest list block array, The text block should wrap a `li` tag when rendering.
|
|
76
|
+
*/
|
|
77
|
+
this.nestList = [];
|
|
78
|
+
this.nestList = nestList;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Converts a VegaRTEListItemBlock object to an RTEListItemBlock
|
|
82
|
+
*
|
|
83
|
+
* @param {VegaRTEListBlock} block - Converts a `VegaRTEListItemBlock` object into an `RTEListItemBlock`.
|
|
84
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
85
|
+
* @returns {RTEListItemBlock} Return an instance of `RTEListItemBlock`
|
|
86
|
+
*/
|
|
87
|
+
static from(block, options = { autoMatchFormat: true }) {
|
|
88
|
+
const listItemBlock = new RTEListItemBlock(block.id, undefined, options);
|
|
89
|
+
listItemBlock.children = block.nodes.map((richText) => codeBlock.RTETextNode.from(richText, listItemBlock, options));
|
|
90
|
+
if (block.children) {
|
|
91
|
+
listItemBlock.nestList = block.children.map((child) => {
|
|
92
|
+
const listBlock = RTEListBlock.from(child);
|
|
93
|
+
listBlock.parent = listItemBlock;
|
|
94
|
+
return listBlock;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const { annotations } = block;
|
|
98
|
+
if (annotations) {
|
|
99
|
+
Object.entries(annotations).forEach(([type, value]) => {
|
|
100
|
+
const item = this.createAnnotationEntity(type, value);
|
|
101
|
+
if (typeGuard.isNonNullable(item)) {
|
|
102
|
+
listItemBlock.annotationMap.set(...item);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return listItemBlock;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @inheritDoc
|
|
110
|
+
*/
|
|
111
|
+
toJSON() {
|
|
112
|
+
var _a;
|
|
113
|
+
return Object.assign(Object.assign({}, super.toJSON()), { type: 'list-item', children: (_a = this.nestList) === null || _a === void 0 ? void 0 : _a.map((block) => block.toJSON()) });
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @inheritDoc
|
|
117
|
+
*/
|
|
118
|
+
toHtml(options) {
|
|
119
|
+
const attrStr = super.generateAttributeString(options);
|
|
120
|
+
return [`<li${attrStr}>`, this.getChildrenHtml(options), `</li>`].join('');
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @inheritDoc
|
|
124
|
+
*/
|
|
125
|
+
cloneWithNodes(nodes) {
|
|
126
|
+
const block = new RTEListItemBlock(misc.generateUUID());
|
|
127
|
+
block.children = [];
|
|
128
|
+
block.apply(new codeBlock.AppendChildrenAction(nodes));
|
|
129
|
+
return block;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @inheritDoc
|
|
133
|
+
*/
|
|
134
|
+
getLastNode() {
|
|
135
|
+
if (this.nestList && this.nestList.length > 0) {
|
|
136
|
+
const childListBlock = this.nestList[this.nestList.length - 1];
|
|
137
|
+
return childListBlock.getLastNode();
|
|
138
|
+
}
|
|
139
|
+
return super.getLastNode();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new list item block.
|
|
143
|
+
*
|
|
144
|
+
* @returns {RTEListItemBlock} - A list item block.
|
|
145
|
+
*/
|
|
146
|
+
createNewListItem() {
|
|
147
|
+
return new RTEListItemBlock(misc.generateUUID());
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @inheritDoc
|
|
151
|
+
*/
|
|
152
|
+
clone(parent) {
|
|
153
|
+
var _a;
|
|
154
|
+
const block = new RTEListItemBlock(this.id);
|
|
155
|
+
block.children = this.children.map((node) => node.clone(block));
|
|
156
|
+
block.annotationMap = super.cloneAnnotations();
|
|
157
|
+
block.nestList = (_a = this.nestList) === null || _a === void 0 ? void 0 : _a.map((child) => child.clone(block));
|
|
158
|
+
block.parent = parent;
|
|
159
|
+
return block;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
(() => {
|
|
163
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.TextStyleAnnotationAction.name, RTEListItemBlock.name, new codeBlock.BlockUpdateTextStyleStrategy());
|
|
164
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.HorizontalAlignmentAnnotationAction.name, RTEListItemBlock.name, new codeBlock.BlockUpdateHorizontalAlignmentStrategy());
|
|
165
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new codeBlock.BlockInsertLineBreakStrategy());
|
|
166
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEListItemBlock.name, new codeBlock.BlockInsertLineBreakWithBlocksStrategy());
|
|
167
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.DELETE_NEST_LIST, RTEListItemBlock.name, new ListItemRemoveNestListStrategy());
|
|
168
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEListItemBlock.name, new codeBlock.BlockSplitWithTextNodeStrategy());
|
|
169
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.REPLACE_CHILD_NODES, RTEListItemBlock.name, new codeBlock.BlockReplaceNodesStrategy());
|
|
170
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.REPLACE_NEST_LIST, RTEListItemBlock.name, new ListItemReplaceNestListStrategy());
|
|
171
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTEListItemBlock.name, new codeBlock.BlockMergeNodesStrategy());
|
|
172
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListItemBlock.name, new ListItemInsertImageStrategy());
|
|
173
|
+
})();
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Convert the selected blocks to list strategy.
|
|
177
|
+
*/
|
|
178
|
+
class ListTransformToListStrategy extends codeBlock.ActionHandleStrategy {
|
|
179
|
+
/**
|
|
180
|
+
* @inheritDoc
|
|
181
|
+
*/
|
|
182
|
+
handleAction(action, target) {
|
|
183
|
+
const selectedBlocks = action.selectedBlocks;
|
|
184
|
+
const bulletList = target.parent.createList(action.listType);
|
|
185
|
+
const isSameList = selectedBlocks.every((block) => block.parent === target);
|
|
186
|
+
if (isSameList) {
|
|
187
|
+
// Select one or more list items belonging to the same list, and all items in this list should be updated
|
|
188
|
+
bulletList.apply(new codeBlock.AppendChildrenAction(target.children));
|
|
189
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, bulletList));
|
|
190
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
191
|
+
selectedBlocks.forEach((block) => block.children.map((node) => node.apply(new codeBlock.SyncUpSelectionAction())));
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const listItems = action.selectedBlocks.map((block) => target.parent.toListItem(block));
|
|
195
|
+
bulletList.apply(new codeBlock.AppendChildrenAction(listItems));
|
|
196
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, bulletList));
|
|
197
|
+
action.selectedBlocks.forEach((block) => {
|
|
198
|
+
block.parent.apply(new codeBlock.RemoveChildrenAction(block));
|
|
199
|
+
});
|
|
200
|
+
if (target.children.length === 0) {
|
|
201
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Convert the selected list block to paragraph strategy.
|
|
209
|
+
*/
|
|
210
|
+
class ListTransformToParagraphStrategy extends codeBlock.ActionHandleStrategy {
|
|
211
|
+
/**
|
|
212
|
+
* @inheritDoc
|
|
213
|
+
*/
|
|
214
|
+
handleAction(action, target) {
|
|
215
|
+
let isSelectedFirstBlock = false;
|
|
216
|
+
let isSelectedLastBlock = false;
|
|
217
|
+
const selectedBlocks = action.selectedBlocks;
|
|
218
|
+
const currentParagraph = selectedBlocks.map((block) => {
|
|
219
|
+
block.children.map((node) => node.apply(new codeBlock.SyncUpSelectionAction()));
|
|
220
|
+
if (block === target.children[0])
|
|
221
|
+
isSelectedFirstBlock = true;
|
|
222
|
+
if (block === target.children[target.children.length - 1])
|
|
223
|
+
isSelectedLastBlock = true;
|
|
224
|
+
return this.toParagraph(block);
|
|
225
|
+
});
|
|
226
|
+
if (isSelectedFirstBlock) {
|
|
227
|
+
target.parent.apply(new codeBlock.InsertChildrenBeforeAction(target, ...currentParagraph));
|
|
228
|
+
}
|
|
229
|
+
else if (isSelectedLastBlock) {
|
|
230
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, ...currentParagraph));
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
const startIndex = target.children.indexOf(selectedBlocks[0]);
|
|
234
|
+
const lastIndex = target.children.indexOf(selectedBlocks[selectedBlocks.length - 1]);
|
|
235
|
+
const firstBulletList = target.parent.createList(target.type);
|
|
236
|
+
firstBulletList.apply(new codeBlock.AppendChildrenAction(target.children.slice(0, startIndex)));
|
|
237
|
+
const lastBulletList = target.parent.createList(target.type);
|
|
238
|
+
lastBulletList.apply(new codeBlock.AppendChildrenAction(target.children.slice(lastIndex + 1)));
|
|
239
|
+
target.parent.apply(new codeBlock.InsertChildrenBeforeAction(target, firstBulletList, ...currentParagraph, lastBulletList));
|
|
240
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
241
|
+
}
|
|
242
|
+
selectedBlocks.map((block) => {
|
|
243
|
+
target.apply(new codeBlock.RemoveChildrenAction(block));
|
|
244
|
+
});
|
|
245
|
+
if (target.children.length === 0) {
|
|
246
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Converts a RTEListItemBlock to a RTETextBlock representing a paragraph.
|
|
251
|
+
*
|
|
252
|
+
* @param {RTEListItemBlock} block - The block that will be covered
|
|
253
|
+
* @returns {RTETextBlock} Returns a `RTETextBlock`.
|
|
254
|
+
*/
|
|
255
|
+
toParagraph(block) {
|
|
256
|
+
const textBlock = new codeBlock.RTETextBlock(misc.generateUUID(), 'paragraph');
|
|
257
|
+
textBlock.apply(new codeBlock.AppendChildrenAction(block['children']));
|
|
258
|
+
textBlock['annotationMap'] = block['annotationMap'];
|
|
259
|
+
return textBlock;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Insert image to list block strategy.
|
|
265
|
+
*/
|
|
266
|
+
class ListInsertImageStrategy extends codeBlock.ActionHandleStrategy {
|
|
267
|
+
/**
|
|
268
|
+
* Insert image block at behind of the list item block.
|
|
269
|
+
*
|
|
270
|
+
* @param {InsertImageToBlockAction} action - The insert image action instance.
|
|
271
|
+
* @param {RTEListBlock} target - The list block.
|
|
272
|
+
*/
|
|
273
|
+
handleAction(action, target) {
|
|
274
|
+
const imageBlock = action.imageBlockToBeInserted;
|
|
275
|
+
if (target.parent['type'] !== 'list-item') {
|
|
276
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, imageBlock));
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
target.parent.apply(action);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* List annotation
|
|
286
|
+
*/
|
|
287
|
+
class ListAnnotation extends codeBlock.BlockAnnotation {
|
|
288
|
+
constructor() {
|
|
289
|
+
super(...arguments);
|
|
290
|
+
this.type = codeBlock.BlockAnnotationTypeEnum.LIST;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Get the default standalone styles for a list block.
|
|
294
|
+
*
|
|
295
|
+
* @returns {AnnotationStyle} The default styles.
|
|
296
|
+
*/
|
|
297
|
+
static getDefaultStyles() {
|
|
298
|
+
return {
|
|
299
|
+
paddingLeft: '8px',
|
|
300
|
+
marginLeft: '16px',
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @inheritDoc
|
|
305
|
+
*/
|
|
306
|
+
renderStyle(options) {
|
|
307
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
308
|
+
return null;
|
|
309
|
+
return ListAnnotation.getDefaultStyles();
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @inheritDoc
|
|
313
|
+
*/
|
|
314
|
+
renderClass(options) {
|
|
315
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
316
|
+
return null;
|
|
317
|
+
return 'v-rte--list';
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* @inheritDoc
|
|
321
|
+
*/
|
|
322
|
+
clone() {
|
|
323
|
+
return new ListAnnotation();
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* @inheritDoc
|
|
327
|
+
*/
|
|
328
|
+
toJSON() {
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* List block
|
|
335
|
+
*/
|
|
336
|
+
class RTEListBlock extends codeBlock.RTEBlock {
|
|
337
|
+
constructor(id, type, options) {
|
|
338
|
+
super(id);
|
|
339
|
+
this.type = 'bullet-list';
|
|
340
|
+
this.children = [];
|
|
341
|
+
this.type = type;
|
|
342
|
+
const { autoMatchFormat } = options || { autoMatchFormat: true };
|
|
343
|
+
if (autoMatchFormat) {
|
|
344
|
+
this.annotationMap.set(codeBlock.BlockAnnotationTypeEnum.LIST, new ListAnnotation());
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Converts a VegaRTEListBlock object to an RTEListBlock
|
|
349
|
+
*
|
|
350
|
+
* @param {VegaRTEListBlock} block - Converts a `VegaRTEListBlock` object into an `RTEListBlock`.
|
|
351
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
352
|
+
* @returns {RTEListBlock} Return an instance of `RTEListBlock`
|
|
353
|
+
*/
|
|
354
|
+
static from(block, options = { autoMatchFormat: true }) {
|
|
355
|
+
const listBlock = new RTEListBlock(block.id, block.type, options);
|
|
356
|
+
const { annotations } = block;
|
|
357
|
+
if (annotations) {
|
|
358
|
+
Object.entries(annotations).forEach(([type, value]) => {
|
|
359
|
+
const item = this.createAnnotationEntity(type, value);
|
|
360
|
+
if (typeGuard.isNonNullable(item)) {
|
|
361
|
+
listBlock.annotationMap.set(...item);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
listBlock.children = block.blocks.map((item) => {
|
|
366
|
+
const listItemBlock = RTEListItemBlock.from(item, options);
|
|
367
|
+
listItemBlock.parent = listBlock;
|
|
368
|
+
return listItemBlock;
|
|
369
|
+
});
|
|
370
|
+
return listBlock;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The function `createAnnotationEntity` creates a block annotation entity based on the provided type
|
|
374
|
+
* and value.
|
|
375
|
+
*
|
|
376
|
+
* @param {keyof VegaRTEBlockAnnotations} type - The `type` parameter is a key of the `VegaRTEBlockAnnotations` enum, which specifies
|
|
377
|
+
* the type of annotation entity to create.
|
|
378
|
+
* @param {unknown} value - The `value` parameter in the `createAnnotationEntity` function is the value
|
|
379
|
+
* that will be used to create the annotation entity. It can be of any type depending on the specific
|
|
380
|
+
* annotation being created.
|
|
381
|
+
* @returns {Nullable<BlockAnnotationsEntity>} The `createAnnotationEntity` function returns a nullable tuple containing a
|
|
382
|
+
* `BlockAnnotationTypeEnum` and a `BlockAnnotation` object.
|
|
383
|
+
*/
|
|
384
|
+
static createAnnotationEntity(type, value) {
|
|
385
|
+
switch (type) {
|
|
386
|
+
case 'customAttribute':
|
|
387
|
+
return codeBlock.CustomAttributeAnnotation.from(value);
|
|
388
|
+
case 'customClass':
|
|
389
|
+
return codeBlock.CustomClassAnnotation.from(value);
|
|
390
|
+
case 'customStyle':
|
|
391
|
+
return codeBlock.CustomStyleAnnotation.from(value);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* @inheritDoc
|
|
396
|
+
*/
|
|
397
|
+
toJSON() {
|
|
398
|
+
return Object.assign(Object.assign({}, super.toJSON()), { id: this.id, type: this.type, blocks: this.children.map((block) => block.toJSON()) });
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* @inheritDoc
|
|
402
|
+
*/
|
|
403
|
+
toHtml(options) {
|
|
404
|
+
const BlockTag = this.getBlockTag();
|
|
405
|
+
const attrStr = super.generateAttributeString(options);
|
|
406
|
+
return [
|
|
407
|
+
`<${BlockTag}${attrStr}>`,
|
|
408
|
+
this.children.map((block) => block.toHtml(options)).join(''),
|
|
409
|
+
`</${BlockTag}>`,
|
|
410
|
+
].join('');
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @inheritDoc
|
|
414
|
+
*/
|
|
415
|
+
isNotEmpty() {
|
|
416
|
+
return this.children.length > 0;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* @inheritDoc
|
|
420
|
+
*/
|
|
421
|
+
getLastNode() {
|
|
422
|
+
return this.children[this.children.length - 1].getLastNode();
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* @inheritDoc
|
|
426
|
+
*/
|
|
427
|
+
clone(parent) {
|
|
428
|
+
const clonedListBlock = new RTEListBlock(this.id, this.type);
|
|
429
|
+
clonedListBlock.children = this.children.map((item) => item.clone(clonedListBlock));
|
|
430
|
+
clonedListBlock.annotationMap = super.cloneAnnotations();
|
|
431
|
+
clonedListBlock.parent = parent;
|
|
432
|
+
return clonedListBlock;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Returns the block tag based on the type of the list block.
|
|
436
|
+
*
|
|
437
|
+
* @returns {RTEListBlockTagType} - The block tag for the list block, either 'ol' or 'ul'.
|
|
438
|
+
*/
|
|
439
|
+
getBlockTag() {
|
|
440
|
+
return this.type === 'number-list' ? 'ol' : 'ul';
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
(() => {
|
|
444
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.TRANSFORM_LIST_BLOCK, RTEListBlock.name, new ListTransformToListStrategy());
|
|
445
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK, RTEListBlock.name, new ListTransformToParagraphStrategy());
|
|
446
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListBlock.name, new ListInsertImageStrategy());
|
|
447
|
+
})();
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Transform the selected text blocks to a code block strategy.
|
|
451
|
+
*/
|
|
452
|
+
class BlockTransformToCodeBlockStrategy extends codeBlock.ActionHandleStrategy {
|
|
453
|
+
/**
|
|
454
|
+
* Get the all select text and create a new code block.
|
|
455
|
+
*
|
|
456
|
+
* @param {TransformToCodeBlockAction} action - The action instance.
|
|
457
|
+
* @param {VegaRTEContent} target - The block top parent instance.
|
|
458
|
+
*/
|
|
459
|
+
handleAction(action, target) {
|
|
460
|
+
const selectedBlocks = action.selectedBlocks;
|
|
461
|
+
const codeBlock$1 = new codeBlock.RTECodeBlock(misc.generateUUID(), this.getCodeContent(selectedBlocks), 'plainText');
|
|
462
|
+
target.apply(new codeBlock.InsertChildrenBeforeAction(selectedBlocks[0], codeBlock$1));
|
|
463
|
+
action.newCodeBlock = codeBlock$1;
|
|
464
|
+
this.removeSelectBlocks(selectedBlocks, target);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Get the selected text block text content.
|
|
468
|
+
*
|
|
469
|
+
* @param {RTEBlock[]} selectedBlocks - The selected blocks.
|
|
470
|
+
* @returns {string} - The selected text content.
|
|
471
|
+
*/
|
|
472
|
+
getCodeContent(selectedBlocks) {
|
|
473
|
+
const selectedTextBlocks = selectedBlocks.filter((item) => item.type !== 'image' && item.type !== 'list-item');
|
|
474
|
+
return selectedTextBlocks
|
|
475
|
+
.map((block) => {
|
|
476
|
+
return block.children.map((node) => node.text).join('');
|
|
477
|
+
})
|
|
478
|
+
.join('\n');
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Remove the selected blocks after append new code block.
|
|
482
|
+
*
|
|
483
|
+
* @param {RTEBlock[]} selectedBlocks - The selected blocks.
|
|
484
|
+
* @param {VegaRTEContent} target - The selected block top parent object.
|
|
485
|
+
*/
|
|
486
|
+
removeSelectBlocks(selectedBlocks, target) {
|
|
487
|
+
for (let i = 0; i < selectedBlocks.length; i++) {
|
|
488
|
+
target.apply(new codeBlock.RemoveChildrenAction(selectedBlocks[i]));
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Abstract class to define strategies for processing HTML elements
|
|
495
|
+
*/
|
|
496
|
+
class ElementToDTOStrategy {
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Class to represent the output of a strategy applied to HTML elements
|
|
500
|
+
*/
|
|
501
|
+
class ElementToDTOStrategyOutput {
|
|
502
|
+
constructor(currentStrategy, currentElements) {
|
|
503
|
+
this.childrenOutput = [];
|
|
504
|
+
this.currentStrategy = currentStrategy;
|
|
505
|
+
this.currentElements = currentElements;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Set children output.
|
|
509
|
+
*
|
|
510
|
+
* @param {ElementToDTOStrategyOutput[]} childrenOutput - children outputs.
|
|
511
|
+
*/
|
|
512
|
+
setChildrenOutput(childrenOutput) {
|
|
513
|
+
this.childrenOutput = childrenOutput;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Transform current output and children output to DTO
|
|
517
|
+
*
|
|
518
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
519
|
+
* @returns {Nullable<RTEContentBlock>} - DTO.
|
|
520
|
+
*/
|
|
521
|
+
toDto(options = { autoMatchFormat: true, skipCustomAnnotations: true }) {
|
|
522
|
+
const currentBlock = this.currentStrategy.handle(this.currentElements, options);
|
|
523
|
+
if (this.childrenOutput.length > 0 && currentBlock) {
|
|
524
|
+
this.currentStrategy.appendChildBlocks(currentBlock, this.childrenOutput
|
|
525
|
+
.map((childOutput) => childOutput.toDto(options))
|
|
526
|
+
.filter(typeGuard.isNonNullable));
|
|
527
|
+
}
|
|
528
|
+
return currentBlock;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Manager for registering and retrieving strategies that convert HTML elements to DTOs.
|
|
534
|
+
*/
|
|
535
|
+
class elementToDTOClassStrategyManager {
|
|
536
|
+
constructor() {
|
|
537
|
+
this.elementToBlockStrategies = [];
|
|
538
|
+
this.elementToNodeStrategies = [];
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Registers a element to block strategy for converting HTML elements to DTOs. The new strategy is added to the beginning of the list to give it higher priority.
|
|
542
|
+
*
|
|
543
|
+
* @param {ElementToDTOStrategy} strategy - The strategy to register.
|
|
544
|
+
*/
|
|
545
|
+
registerElementToBlockStrategy(strategy) {
|
|
546
|
+
if (!this.hasDuplicateStrategy(strategy, this.elementToBlockStrategies)) {
|
|
547
|
+
this.elementToBlockStrategies.unshift(strategy);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Registers an element to node strategy for converting HTML elements to DTOs. The new strategy is added to the beginning of the list to give it higher priority.
|
|
552
|
+
*
|
|
553
|
+
* @param {ElementToDTOStrategy} strategy - The strategy to register.
|
|
554
|
+
*/
|
|
555
|
+
registerElementToNodeStrategy(strategy) {
|
|
556
|
+
if (!this.hasDuplicateStrategy(strategy, this.elementToNodeStrategies)) {
|
|
557
|
+
this.elementToNodeStrategies.unshift(strategy);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Retrieves all registered element to block strategies for converting HTML elements to DTOs.
|
|
562
|
+
*
|
|
563
|
+
* @returns {ElementToDTOStrategy[]} - A set of all registered element to block strategies.
|
|
564
|
+
*/
|
|
565
|
+
getElementToBlockStrategies() {
|
|
566
|
+
return this.elementToBlockStrategies;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Retrieves all registered element to node strategies for converting HTML elements to DTOs.
|
|
570
|
+
*
|
|
571
|
+
* @returns {ElementToDTOStrategy[]} - A set of all registered element to node strategies.
|
|
572
|
+
*/
|
|
573
|
+
getElementToNodeStrategies() {
|
|
574
|
+
return this.elementToNodeStrategies;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Checks if a strategy is already registered in the provided strategy list.
|
|
578
|
+
*
|
|
579
|
+
* @param {ElementToDTOStrategy} strategy - The strategy to check for duplicates.
|
|
580
|
+
* @param {ElementToDTOStrategy[]} strategyList - The list of strategies to check against.
|
|
581
|
+
* @returns {boolean} - True if the strategy is a duplicate, false otherwise.
|
|
582
|
+
*/
|
|
583
|
+
hasDuplicateStrategy(strategy, strategyList) {
|
|
584
|
+
return strategyList.includes(strategy);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
const ElementToDTOClassStrategyManager = new elementToDTOClassStrategyManager();
|
|
588
|
+
|
|
589
|
+
/** Element to DTO processor */
|
|
590
|
+
class ElementToDtoStrategyProcessor {
|
|
591
|
+
/**
|
|
592
|
+
* Transform process.
|
|
593
|
+
*
|
|
594
|
+
* @param {HTMLElement[]} elements - Current elements.
|
|
595
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
596
|
+
* @returns {ElementToDTOStrategyOutput[]} - outputs.
|
|
597
|
+
*/
|
|
598
|
+
process(elements, options = { autoMatchFormat: true, skipCustomAnnotations: true }) {
|
|
599
|
+
const strategies = this.getElementToBlockStrategies();
|
|
600
|
+
const outputs = [];
|
|
601
|
+
for (let i = 0; i < elements.length; i++) {
|
|
602
|
+
if (this.isInvalidElement(elements[i], options))
|
|
603
|
+
continue;
|
|
604
|
+
let canHandledCount = 0;
|
|
605
|
+
for (const strategy of strategies) {
|
|
606
|
+
canHandledCount = strategy.canHandle(elements, i, options);
|
|
607
|
+
if (canHandledCount > 0) {
|
|
608
|
+
const handledElements = elements.slice(i, i + canHandledCount);
|
|
609
|
+
const output = new ElementToDTOStrategyOutput(strategy, handledElements);
|
|
610
|
+
if (canHandledCount === 1 && strategy.shouldProceedToElementChildren()) {
|
|
611
|
+
output.setChildrenOutput(this.process(Array.from(handledElements[0].childNodes), options));
|
|
612
|
+
}
|
|
613
|
+
outputs.push(output);
|
|
614
|
+
i += canHandledCount - 1;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (canHandledCount === 0 && i < elements.length) {
|
|
619
|
+
const elementChildren = Array.from(elements[i].childNodes);
|
|
620
|
+
const childrenOutputs = this.process(Array.from(elementChildren), options);
|
|
621
|
+
if (childrenOutputs.length > 0) {
|
|
622
|
+
outputs.push(...childrenOutputs);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return outputs;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Checks if the given element should be skipped during processing.
|
|
630
|
+
*
|
|
631
|
+
* Comment nodes are always skipped. META and STYLE elements are skipped only
|
|
632
|
+
* in auto-match mode; in raw-HTML mode (autoMatchFormat: false) they are passed
|
|
633
|
+
* through so downstream strategies can decide how to handle them.
|
|
634
|
+
*
|
|
635
|
+
* @param {HTMLElement} element - The element to check.
|
|
636
|
+
* @param {VegaRTETransformOptions} options - Transform options.
|
|
637
|
+
* @returns {boolean} True when the element should be skipped.
|
|
638
|
+
*/
|
|
639
|
+
isInvalidElement(element, options) {
|
|
640
|
+
if (element.nodeType === Node.COMMENT_NODE)
|
|
641
|
+
return true;
|
|
642
|
+
if (options.autoMatchFormat === false)
|
|
643
|
+
return false;
|
|
644
|
+
return ['META', 'STYLE'].includes(element.nodeName);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Get the register element to block strategies.
|
|
648
|
+
*
|
|
649
|
+
* @returns {ElementToDTOStrategy[]} - The register element to block strategies.
|
|
650
|
+
*/
|
|
651
|
+
getElementToBlockStrategies() {
|
|
652
|
+
return ElementToDTOClassStrategyManager.getElementToBlockStrategies();
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
const ElementToDtoStrategyProcessor$1 = new ElementToDtoStrategyProcessor();
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Update the cursor position in the editor.
|
|
659
|
+
*/
|
|
660
|
+
class UpdateCursorPositionStrategy extends codeBlock.ActionHandleStrategy {
|
|
661
|
+
/**
|
|
662
|
+
* @inheritDoc
|
|
663
|
+
*/
|
|
664
|
+
handleAction(action, target) {
|
|
665
|
+
const { offset, nextFocusNode, immediatelyRun } = action;
|
|
666
|
+
const host = codeBlock.stateEntityRenderingRegistry.getDOMByEntity(target);
|
|
667
|
+
if (host) {
|
|
668
|
+
changeManager.ChangeManager.notify(domNodeSubjectObserverFactory.domNodeSubjectFactory.getSubject(host, vegaInternalEventId.VegaInternalUpdateRTECursorPosition), {
|
|
669
|
+
node: nextFocusNode,
|
|
670
|
+
offset,
|
|
671
|
+
updateDirectly: immediatelyRun,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Append new block array or node array to block or VegaRTEContent instance strategy.
|
|
679
|
+
*/
|
|
680
|
+
class AppendChildrenStrategy extends codeBlock.ActionHandleStrategy {
|
|
681
|
+
/**
|
|
682
|
+
* @inheritDoc
|
|
683
|
+
*/
|
|
684
|
+
handleAction(action, target) {
|
|
685
|
+
const newBlocks = action.entityToBeAppended;
|
|
686
|
+
if (target.children) {
|
|
687
|
+
newBlocks.forEach((block) => {
|
|
688
|
+
block.parent = target;
|
|
689
|
+
});
|
|
690
|
+
// This line is used to fix the typescript error `This expression is not callable`. https://github.com/microsoft/TypeScript/issues/44373
|
|
691
|
+
const arrayFixed = target.children;
|
|
692
|
+
target.children = arrayFixed.concat(newBlocks);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Insert children at the front of the block strategy.
|
|
699
|
+
*/
|
|
700
|
+
class InsertChildrenBeforeStrategy extends codeBlock.ActionHandleStrategy {
|
|
701
|
+
/**
|
|
702
|
+
* @inheritDoc
|
|
703
|
+
*/
|
|
704
|
+
handleAction(action, target) {
|
|
705
|
+
this.replaceElementWithElements(target, action.referChildren, [
|
|
706
|
+
...action.childrenToBeInserted,
|
|
707
|
+
action.referChildren,
|
|
708
|
+
]);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Replaces a specific block or node with an array of blocks or nodes within RTEContentBlock array.
|
|
712
|
+
*
|
|
713
|
+
* @param {RTEBlock | VegaRTEContent} target - The block or the VegaRTEContent instance.
|
|
714
|
+
* @param {RTEBlock | RTENode} referElement - Used as a reference element to identify the element that needs to be replaced in the array.
|
|
715
|
+
* @param {RTEBlock[] | RTENode[]} elements - An array of block or node objects that you want to replace the `referElement` with in the array.
|
|
716
|
+
*/
|
|
717
|
+
replaceElementWithElements(target, referElement, elements) {
|
|
718
|
+
if (target.children) {
|
|
719
|
+
elements.forEach((block) => {
|
|
720
|
+
block.parent = target;
|
|
721
|
+
});
|
|
722
|
+
const arrayFixed = target.children;
|
|
723
|
+
target.children = arrayFixed.flatMap((block) => {
|
|
724
|
+
if (block === referElement) {
|
|
725
|
+
return elements;
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
return block;
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Insert children at the front of the block strategy.
|
|
737
|
+
*/
|
|
738
|
+
class InsertChildrenAfterStrategy extends InsertChildrenBeforeStrategy {
|
|
739
|
+
/**
|
|
740
|
+
* @inheritDoc
|
|
741
|
+
*/
|
|
742
|
+
handleAction(action, target) {
|
|
743
|
+
this.replaceElementWithElements(target, action.referChildren, [
|
|
744
|
+
action.referChildren,
|
|
745
|
+
...action.childrenToBeInserted,
|
|
746
|
+
]);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Annotation for image
|
|
752
|
+
*/
|
|
753
|
+
class ImageAnnotation extends codeBlock.NodeAnnotation {
|
|
754
|
+
constructor(size, alt) {
|
|
755
|
+
super();
|
|
756
|
+
this.type = codeBlock.NodeAnnotationTypeEnum.IMAGE;
|
|
757
|
+
this.size = size;
|
|
758
|
+
this.alt = alt;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Generate the map item for the annotation
|
|
762
|
+
*
|
|
763
|
+
* @param {string} size - Image size
|
|
764
|
+
* @param {string} alt - Image alt
|
|
765
|
+
* @returns {[NodeAnnotationTypeEnum.IMAGE, ImageAnnotation]} Map item for the annotation
|
|
766
|
+
*/
|
|
767
|
+
static from(size, alt) {
|
|
768
|
+
return [codeBlock.NodeAnnotationTypeEnum.IMAGE, new ImageAnnotation(size, alt)];
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Get the default standalone base styles for an image node.
|
|
772
|
+
*
|
|
773
|
+
* @returns {AnnotationStyle} The default styles.
|
|
774
|
+
*/
|
|
775
|
+
static getDefaultStyles() {
|
|
776
|
+
return {
|
|
777
|
+
verticalAlign: 'bottom',
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Generate the JSON representation of the annotation
|
|
782
|
+
*
|
|
783
|
+
* @returns {Nullable<Record<string, unknown>>} JSON representation of the annotation
|
|
784
|
+
*/
|
|
785
|
+
toJSON() {
|
|
786
|
+
return typeGuard.isNonNullable(this.alt)
|
|
787
|
+
? {
|
|
788
|
+
size: this.size,
|
|
789
|
+
alt: this.alt,
|
|
790
|
+
}
|
|
791
|
+
: {
|
|
792
|
+
size: this.size,
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* @inheritDoc
|
|
797
|
+
*/
|
|
798
|
+
clone() {
|
|
799
|
+
return new ImageAnnotation(this.size, this.alt);
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* @inheritDoc
|
|
803
|
+
*/
|
|
804
|
+
renderClass(options) {
|
|
805
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
806
|
+
return null;
|
|
807
|
+
return this.size ? `v-rte--image-size-${this.size}` : null;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* @inheritDoc
|
|
811
|
+
*/
|
|
812
|
+
renderStyle(options) {
|
|
813
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
814
|
+
return null;
|
|
815
|
+
const baseStyle = ImageAnnotation.getDefaultStyles();
|
|
816
|
+
switch (this.size) {
|
|
817
|
+
case 'sm': {
|
|
818
|
+
return Object.assign(Object.assign({}, baseStyle), { width: '25%' });
|
|
819
|
+
}
|
|
820
|
+
case 'md': {
|
|
821
|
+
return Object.assign(Object.assign({}, baseStyle), { width: '50%' });
|
|
822
|
+
}
|
|
823
|
+
case 'lg': {
|
|
824
|
+
return Object.assign(Object.assign({}, baseStyle), { width: '100%' });
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
ImageAnnotation.BASE_STYLES = { verticalAlign: 'bottom' };
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Update the image node annotation map strategy.
|
|
833
|
+
*/
|
|
834
|
+
class ImageSetAnnotationMapStrategy extends codeBlock.ActionHandleStrategy {
|
|
835
|
+
/**
|
|
836
|
+
* @inheritDoc
|
|
837
|
+
*/
|
|
838
|
+
handleAction(action, target) {
|
|
839
|
+
const annotation = action.toAnnotation();
|
|
840
|
+
target.annotationMap.set(annotation.type, annotation);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* The image node update property url strategy.
|
|
846
|
+
*/
|
|
847
|
+
class ImageUpdateUrlStrategy extends codeBlock.ActionHandleStrategy {
|
|
848
|
+
/**
|
|
849
|
+
* @inheritDoc
|
|
850
|
+
*/
|
|
851
|
+
handleAction(action, target) {
|
|
852
|
+
target.url = action.url;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
857
|
+
var t = {};
|
|
858
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
859
|
+
t[p] = s[p];
|
|
860
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
861
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
862
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
863
|
+
t[p[i]] = s[p[i]];
|
|
864
|
+
}
|
|
865
|
+
return t;
|
|
866
|
+
};
|
|
867
|
+
/**
|
|
868
|
+
* Image node
|
|
869
|
+
*/
|
|
870
|
+
class RTEImageNode extends codeBlock.RTEDecoratorNode {
|
|
871
|
+
constructor(id, url, parentBlock, annotationMap) {
|
|
872
|
+
super(id, annotationMap);
|
|
873
|
+
this.type = codeBlock.NodeTypeEnum.IMAGE;
|
|
874
|
+
this.url = url;
|
|
875
|
+
this.parent = parentBlock;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Converts a VegaRTEImageNode into an RTEImageNode by mapping nodes and creating annotations.
|
|
879
|
+
*
|
|
880
|
+
* @param {VegaRTEImageNode} node - The node to be converted.
|
|
881
|
+
* @param {RTEImageBlock} parentBlock - The parent block
|
|
882
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
883
|
+
* @returns {RTEImageNode} An instance of `RTEImageBlock`
|
|
884
|
+
*/
|
|
885
|
+
static from(node, parentBlock, options = { autoMatchFormat: true }) {
|
|
886
|
+
const imageNode = new RTEImageNode(node.id, node.url, parentBlock);
|
|
887
|
+
const autoMatchFormat = !!options.autoMatchFormat;
|
|
888
|
+
const _a = Object.assign({}, node.annotations), { size } = _a, otherAnnotations = __rest(_a, ["size"]);
|
|
889
|
+
const annotations = Object.assign(Object.assign({}, otherAnnotations), { size: size !== null && size !== void 0 ? size : (autoMatchFormat ? 'md' : undefined) });
|
|
890
|
+
imageNode.annotationMap = new Map(Object.keys(annotations)
|
|
891
|
+
.map((type) => {
|
|
892
|
+
if (type === 'size' || type === 'alt') {
|
|
893
|
+
return ImageAnnotation.from(annotations.size, annotations.alt);
|
|
894
|
+
}
|
|
895
|
+
return this.createAnnotationEntity(type, annotations[type]);
|
|
896
|
+
})
|
|
897
|
+
.filter(typeGuard.isNonNullable));
|
|
898
|
+
return imageNode;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* @inheritDoc
|
|
902
|
+
*/
|
|
903
|
+
toJSON() {
|
|
904
|
+
const annotations = Array.from(this.annotationMap.values())
|
|
905
|
+
.filter((annotation) => annotation instanceof ImageAnnotation || annotation instanceof codeBlock.CommonAnnotation)
|
|
906
|
+
.reduce((record, annotation) => {
|
|
907
|
+
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
908
|
+
}, {});
|
|
909
|
+
if (annotations.alt == '')
|
|
910
|
+
delete annotations.alt;
|
|
911
|
+
return Object.assign(Object.assign({ id: this.id }, (Object.keys(annotations).length > 0 ? { annotations } : {})), { type: 'image', url: this.url });
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* @inheritDoc
|
|
915
|
+
*/
|
|
916
|
+
clone(parent) {
|
|
917
|
+
return new RTEImageNode(this.id, this.url, parent, super.cloneAnnotations());
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* @inheritDoc
|
|
921
|
+
*/
|
|
922
|
+
toHtml(options) {
|
|
923
|
+
const imageAnnotation = this.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE);
|
|
924
|
+
const attrStr = super.generateAttributeString(options, ...[
|
|
925
|
+
imageAnnotation && imageAnnotation.alt ? `alt="${imageAnnotation.alt}"` : null,
|
|
926
|
+
`src="${this.url}"`,
|
|
927
|
+
imageAnnotation && imageAnnotation.size ? `data-size="${imageAnnotation.size}"` : null,
|
|
928
|
+
].filter(typeGuard.isNonNullable));
|
|
929
|
+
return `<img${attrStr}>`;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* @inheritDoc
|
|
933
|
+
*/
|
|
934
|
+
doAnnotationActionApply(action) {
|
|
935
|
+
const strategy = codeBlock.ActionHandleStrategyRegistry.get(codeBlock.AnnotationAction.name, RTEImageNode.name);
|
|
936
|
+
if (strategy) {
|
|
937
|
+
strategy.execute(action, this);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* @inheritDoc
|
|
942
|
+
*/
|
|
943
|
+
doModifyActionApply(action) {
|
|
944
|
+
codeBlock.ActionHandleStrategyRegistry.executeTheStrategy(action, this);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
(() => {
|
|
948
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.UPDATE_IMAGE_NODE_URL, RTEImageNode.name, new ImageUpdateUrlStrategy());
|
|
949
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.AnnotationAction.name, RTEImageNode.name, new ImageSetAnnotationMapStrategy());
|
|
950
|
+
})();
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Split the current image block with a special position strategy.
|
|
954
|
+
*/
|
|
955
|
+
class BlockSplitWithImageNodeStrategy extends codeBlock.ActionHandleStrategy {
|
|
956
|
+
/**
|
|
957
|
+
* @inheritDoc
|
|
958
|
+
*/
|
|
959
|
+
handleAction(action, target) {
|
|
960
|
+
action.newBlock = this.splitImageNodes(action.splitPointNode, action.startOffsetOfNode, target);
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* The image offset should be 0 or 1
|
|
964
|
+
* <vega-rich-text-image-editor><img /></vega-rich-text-image-editor>
|
|
965
|
+
*
|
|
966
|
+
* @param {RTEImageNode} imageNode The split point image node.
|
|
967
|
+
* @param {number} imageOffset The cursor point 0 | 1.
|
|
968
|
+
* @param {RTEImageBlock} target The image block.
|
|
969
|
+
* @returns {Nullable<RTEBlock>} The new block after split
|
|
970
|
+
*/
|
|
971
|
+
splitImageNodes(imageNode, imageOffset, target) {
|
|
972
|
+
const nodesSplitIndex = target.children.indexOf(imageNode);
|
|
973
|
+
if (nodesSplitIndex > -1) {
|
|
974
|
+
const beforeNodes = target.children.slice(0, nodesSplitIndex + imageOffset);
|
|
975
|
+
const afterNodes = target.children.slice(nodesSplitIndex + imageOffset);
|
|
976
|
+
target.apply(new codeBlock.ReplaceChildNodesAction(beforeNodes));
|
|
977
|
+
const newBlock = this.cloneWithNodes(afterNodes, target);
|
|
978
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, newBlock));
|
|
979
|
+
return newBlock;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Creates a new RTEImageBlock instance with the provided RTEImageNode instances appended to it.
|
|
984
|
+
*
|
|
985
|
+
* @param {RTEImageNode[]} nodes - An array of RTEImageNode objects that will be used to create a new RTEImageBlock instance.
|
|
986
|
+
* @param {RTEImageBlock} target The image block.
|
|
987
|
+
* @returns {RTEImageBlock} A new `RTEImageBlock` object with the provided `nodes` appended to it.
|
|
988
|
+
*/
|
|
989
|
+
cloneWithNodes(nodes, target) {
|
|
990
|
+
const block = target.createNewImageBlock();
|
|
991
|
+
block.children = [];
|
|
992
|
+
block.apply(new codeBlock.AppendChildrenAction(nodes));
|
|
993
|
+
return block;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Break the current block after press enter, this action is similar with the SplitBlockWithNodeAction,
|
|
999
|
+
* The SplitBlockWithNodeAction split the current block to two same type blocks, but this action will create new paragraph or list item when break at start or end.
|
|
1000
|
+
* The property `newBlock` use to store the new create block if need.
|
|
1001
|
+
*
|
|
1002
|
+
* @example currentBlock.apply(new InsertNewParagraphAction(startContainerNode, startOffset))
|
|
1003
|
+
*/
|
|
1004
|
+
class InsertNewParagraphAction extends codeBlock.ModifyContentAction {
|
|
1005
|
+
constructor(startContainerNode, startOffset) {
|
|
1006
|
+
super();
|
|
1007
|
+
this.type = codeBlock.ModifyContentActionType.INSERT_NEW_PARAGRAPH;
|
|
1008
|
+
this.startContainerNode = startContainerNode;
|
|
1009
|
+
this.startOffset = startOffset;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* The image block insert line break strategy.
|
|
1015
|
+
*/
|
|
1016
|
+
class ImageInsertLineBreakStrategy extends codeBlock.ActionHandleStrategy {
|
|
1017
|
+
/**
|
|
1018
|
+
* The image block not support insert the line break node, so invoke the insert new paragraph logic directly.
|
|
1019
|
+
*
|
|
1020
|
+
* @param {LineBreakSingleBlockAction} action - The action instance.
|
|
1021
|
+
* @param {RTEImageBlock} target - The image block.
|
|
1022
|
+
*/
|
|
1023
|
+
handleAction(action, target) {
|
|
1024
|
+
const insertNewParagraphAction = new InsertNewParagraphAction(action.startContainerNode, action.startOffset);
|
|
1025
|
+
target.apply(insertNewParagraphAction);
|
|
1026
|
+
const newBlock = insertNewParagraphAction.newBlock;
|
|
1027
|
+
if (newBlock) {
|
|
1028
|
+
action.lineBreakNode = newBlock.children[0];
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Insert a line break node into multiple blocks selection at special position strategy.
|
|
1035
|
+
*/
|
|
1036
|
+
class ImageInsertLineBreakWithBlocksStrategy extends codeBlock.ActionHandleStrategy {
|
|
1037
|
+
/**
|
|
1038
|
+
* @inheritDoc
|
|
1039
|
+
*/
|
|
1040
|
+
handleAction(action, target) {
|
|
1041
|
+
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks, target);
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Inserts a new paragraph block with a line break after a selected block of text in a rich text editor.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {RTEBlock[]} selectedBlocks - An array of RTEBlock objects that represent the blocks that have been selected for a specific action in the Rich Text Editor.
|
|
1047
|
+
* @param {RTEImageBlock} target - The image block.
|
|
1048
|
+
* @returns {Nullable<RTETextNode>} Returns a Nullable RTETextNode.
|
|
1049
|
+
*/
|
|
1050
|
+
lineBreakMultipleBlocks(selectedBlocks, target) {
|
|
1051
|
+
const newParagraph = codeBlock.RTETextBlock.from({
|
|
1052
|
+
id: misc.generateUUID(),
|
|
1053
|
+
type: 'paragraph',
|
|
1054
|
+
nodes: [{ id: misc.generateUUID(), type: 'text', text: '\n' }],
|
|
1055
|
+
});
|
|
1056
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, newParagraph));
|
|
1057
|
+
const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
|
|
1058
|
+
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
1059
|
+
afterNodes.push(new codeBlock.RTETextNode(misc.generateUUID(), '\n', newParagraph));
|
|
1060
|
+
}
|
|
1061
|
+
newParagraph.apply(new codeBlock.AppendChildrenAction(afterNodes));
|
|
1062
|
+
return newParagraph['children'][0];
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Concat the child nodes of multiple RTEBlocks if both are not images.
|
|
1066
|
+
*
|
|
1067
|
+
* @param {RTEBlock[]} blocks - multiple block of content in a rich text editor, such as a paragraph, heading, image, etc.
|
|
1068
|
+
* @returns {RTENode[]} Array of connected block nodes
|
|
1069
|
+
*/
|
|
1070
|
+
concatBlocksNodes(blocks) {
|
|
1071
|
+
const nodes = [];
|
|
1072
|
+
blocks.map((block) => {
|
|
1073
|
+
if (block.type !== 'image') {
|
|
1074
|
+
nodes.push(...block.children);
|
|
1075
|
+
block.parent.apply(new codeBlock.RemoveChildrenAction(block));
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
return nodes;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Insert a image node at the special position of image block.
|
|
1084
|
+
*/
|
|
1085
|
+
class ImageBlockInsertImageStrategy extends codeBlock.ActionHandleStrategy {
|
|
1086
|
+
/**
|
|
1087
|
+
* @inheritDoc
|
|
1088
|
+
*/
|
|
1089
|
+
handleAction(action, target) {
|
|
1090
|
+
const splitNode = action.splitPointNode;
|
|
1091
|
+
const startOffsetOfNode = action.startOffsetOfNode;
|
|
1092
|
+
const newImageBlock = action.imageBlockToBeInserted;
|
|
1093
|
+
const newImageNodes = newImageBlock.children;
|
|
1094
|
+
if (target.children.length < 1) {
|
|
1095
|
+
target.apply(new codeBlock.AppendChildrenAction(newImageNodes));
|
|
1096
|
+
}
|
|
1097
|
+
else if (this.isCaretPositionAtBlockEnd(target, splitNode, startOffsetOfNode)) {
|
|
1098
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, newImageBlock));
|
|
1099
|
+
}
|
|
1100
|
+
else if (this.isCaretPositionAtBlockStart(target, splitNode, startOffsetOfNode)) {
|
|
1101
|
+
target.parent.apply(new codeBlock.InsertChildrenBeforeAction(target, newImageBlock));
|
|
1102
|
+
}
|
|
1103
|
+
else {
|
|
1104
|
+
target.apply(new codeBlock.SplitBlockWithNodeAction(splitNode, startOffsetOfNode));
|
|
1105
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, newImageBlock));
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Image block
|
|
1112
|
+
*/
|
|
1113
|
+
class RTEImageBlock extends codeBlock.RTEBlock {
|
|
1114
|
+
constructor(id) {
|
|
1115
|
+
super(id);
|
|
1116
|
+
this.type = 'image';
|
|
1117
|
+
this.children = [];
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Converts a VegaRTEImageBlock object into an RTEImageBlock object by mapping nodes and creating annotations.
|
|
1121
|
+
*
|
|
1122
|
+
* @param {VegaRTEImageBlock} block - The block object to be converted.
|
|
1123
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
1124
|
+
* @returns {RTEImageBlock} An instance of `RTEImageBlock`
|
|
1125
|
+
*/
|
|
1126
|
+
static from(block, options = { autoMatchFormat: true }) {
|
|
1127
|
+
const imageBlock = new RTEImageBlock(block.id);
|
|
1128
|
+
const { annotations } = block;
|
|
1129
|
+
imageBlock.children = block.nodes.map((image) => RTEImageNode.from(image, imageBlock, options));
|
|
1130
|
+
if (annotations) {
|
|
1131
|
+
super.convertAnnotationsToMap(imageBlock.annotationMap, annotations);
|
|
1132
|
+
}
|
|
1133
|
+
return imageBlock;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* @inheritDoc
|
|
1137
|
+
*/
|
|
1138
|
+
toJSON() {
|
|
1139
|
+
return Object.assign(Object.assign({}, super.toJSON()), { type: 'image', nodes: this.children.map((node) => node.toJSON()) });
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* @inheritDoc
|
|
1143
|
+
*/
|
|
1144
|
+
toHtml(options) {
|
|
1145
|
+
const attrStr = super.generateAttributeString(options);
|
|
1146
|
+
const children = this.children.map((node) => node.toHtml(options)).join('');
|
|
1147
|
+
return super.shouldRenderAsInternalWrapper()
|
|
1148
|
+
? children
|
|
1149
|
+
: [`<div${attrStr}>`, children, `</div>`].join('');
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* @inheritDoc
|
|
1153
|
+
*/
|
|
1154
|
+
isNotEmpty() {
|
|
1155
|
+
return this.children.length > 0 && this.children.some((node) => node.url.length > 0);
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* @inheritDoc
|
|
1159
|
+
*/
|
|
1160
|
+
getLastNode() {
|
|
1161
|
+
return this.children[this.children.length - 1];
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Create a new image block.
|
|
1165
|
+
*
|
|
1166
|
+
* @returns {RTEImageBlock} - The empty image block.
|
|
1167
|
+
*/
|
|
1168
|
+
createNewImageBlock() {
|
|
1169
|
+
return new RTEImageBlock(misc.generateUUID());
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* @inheritDoc
|
|
1173
|
+
*/
|
|
1174
|
+
clone(parent) {
|
|
1175
|
+
const clonedBlock = new RTEImageBlock(this.id);
|
|
1176
|
+
clonedBlock.children = this.children.map((node) => node.clone(clonedBlock));
|
|
1177
|
+
clonedBlock.annotationMap = super.cloneAnnotations();
|
|
1178
|
+
clonedBlock.parent = parent;
|
|
1179
|
+
return clonedBlock;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
(() => {
|
|
1183
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTEImageBlock.name, new codeBlock.BlockMergeNodesStrategy());
|
|
1184
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.REPLACE_CHILD_NODES, RTEImageBlock.name, new codeBlock.BlockReplaceNodesStrategy());
|
|
1185
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEImageBlock.name, new BlockSplitWithImageNodeStrategy());
|
|
1186
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEImageBlock.name, new ImageInsertLineBreakStrategy());
|
|
1187
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEImageBlock.name, new ImageInsertLineBreakWithBlocksStrategy());
|
|
1188
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEImageBlock.name, new ImageBlockInsertImageStrategy());
|
|
1189
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.HorizontalAlignmentAnnotationAction.name, RTEImageBlock.name, new codeBlock.BlockUpdateHorizontalAlignmentStrategy());
|
|
1190
|
+
})();
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* HTML Block
|
|
1194
|
+
*/
|
|
1195
|
+
class RTEHtmlBlock extends codeBlock.RTEBlock {
|
|
1196
|
+
constructor(id, htmlTag) {
|
|
1197
|
+
super(id);
|
|
1198
|
+
this.type = 'html-block';
|
|
1199
|
+
this.children = [];
|
|
1200
|
+
this.htmlTag = htmlTag;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Converts a VegaRTEHtmlBlock to an RTEHtmlBlock.
|
|
1204
|
+
*
|
|
1205
|
+
* @param {VegaRTEHtmlBlock} block - The VegaRTEHtmlBlock to convert.
|
|
1206
|
+
* @param {VegaRTETransformOptions} [options] - Optional transformation options.
|
|
1207
|
+
* @returns {RTEHtmlBlock} The converted RTEHtmlBlock.
|
|
1208
|
+
*/
|
|
1209
|
+
static from(block, options) {
|
|
1210
|
+
const htmlBlock = new RTEHtmlBlock(block.id, block.htmlTag);
|
|
1211
|
+
const { annotations } = block;
|
|
1212
|
+
if (annotations) {
|
|
1213
|
+
super.convertAnnotationsToMap(htmlBlock.annotationMap, annotations);
|
|
1214
|
+
}
|
|
1215
|
+
htmlBlock.children = this.generateBlockChildren(block.children, options, htmlBlock);
|
|
1216
|
+
return htmlBlock;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* @inheritDoc
|
|
1220
|
+
*/
|
|
1221
|
+
clone(parent) {
|
|
1222
|
+
const clonedBlock = new RTEHtmlBlock(this.id, this.htmlTag);
|
|
1223
|
+
clonedBlock.children = this.children.map((child) => child.clone(clonedBlock));
|
|
1224
|
+
clonedBlock.annotationMap = super.cloneAnnotations();
|
|
1225
|
+
clonedBlock.parent = parent;
|
|
1226
|
+
return clonedBlock;
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* @inheritDoc
|
|
1230
|
+
*/
|
|
1231
|
+
getLastNode() {
|
|
1232
|
+
return this.children[this.children.length - 1].getLastNode();
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* @inheritDoc
|
|
1236
|
+
*/
|
|
1237
|
+
isNotEmpty() {
|
|
1238
|
+
// Any RTEHtmlBlock — whether void (hr, br), childless (canvas, iframe),
|
|
1239
|
+
// or with children — represents real user content. Only the default empty
|
|
1240
|
+
// text paragraph should make the editor report as empty.
|
|
1241
|
+
return true;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* @inheritDoc
|
|
1245
|
+
*/
|
|
1246
|
+
toHtml(options) {
|
|
1247
|
+
const BlockTag = this.htmlTag;
|
|
1248
|
+
const attrStr = super.generateAttributeString(options);
|
|
1249
|
+
// Handle void/self-closing tags (hr, input, col, etc.)
|
|
1250
|
+
// Uses HTML5 syntax without self-closing slash for consistency with img and br tags
|
|
1251
|
+
if (codeBlock.HTML_VOID_TAGS.has(this.htmlTag)) {
|
|
1252
|
+
return `<${BlockTag}${attrStr}>`;
|
|
1253
|
+
}
|
|
1254
|
+
// Handle normal tags with children
|
|
1255
|
+
return [
|
|
1256
|
+
`<${BlockTag}${attrStr}>`,
|
|
1257
|
+
this.children.map((block) => block.toHtml(options)).join(''),
|
|
1258
|
+
`</${BlockTag}>`,
|
|
1259
|
+
].join('');
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* @inheritDoc
|
|
1263
|
+
*/
|
|
1264
|
+
toJSON() {
|
|
1265
|
+
return Object.assign(Object.assign({}, super.toJSON()), { id: this.id, type: this.type, htmlTag: this.htmlTag, children: this.children.map((child) => child.toJSON()) });
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* Merge the two blocks node into first block if the two blocks nodes type is same(text node or image node)
|
|
1271
|
+
*
|
|
1272
|
+
* @example firstBlock.apply(new MergeTwoBlocksNodesAction(secondBlock))
|
|
1273
|
+
*/
|
|
1274
|
+
class MergeTwoBlocksNodesAction extends codeBlock.ModifyContentAction {
|
|
1275
|
+
constructor(blockNeedToBeMerged) {
|
|
1276
|
+
super();
|
|
1277
|
+
this.type = codeBlock.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES;
|
|
1278
|
+
this.blockNeedToBeMerged = blockNeedToBeMerged;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Block delete text or decorator node strategy.
|
|
1284
|
+
*/
|
|
1285
|
+
class BlockDeleteTextOrDecoratorNodeStrategy extends codeBlock.BlockDeleteNodeContentStrategy {
|
|
1286
|
+
/**
|
|
1287
|
+
* @inheritDoc
|
|
1288
|
+
*/
|
|
1289
|
+
handleAction(action, target) {
|
|
1290
|
+
const { startContainerNode } = action;
|
|
1291
|
+
if (!startContainerNode.isContentEditable()) {
|
|
1292
|
+
this.deleteDecoratorNodeContent(action, target);
|
|
1293
|
+
}
|
|
1294
|
+
else if (startContainerNode.isTextNode()) {
|
|
1295
|
+
this.deleteTextNodeContent(action, target);
|
|
1296
|
+
}
|
|
1297
|
+
const parent = target.parent;
|
|
1298
|
+
if (parent && target.isListItemBlock() && parent.children.length === 0) {
|
|
1299
|
+
parent.parent.apply(new codeBlock.RemoveChildrenAction(parent));
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Handle the delete text logic when press delete key.
|
|
1304
|
+
*
|
|
1305
|
+
* @param {DeleteBlockContentAction} action - ModifyContentAction
|
|
1306
|
+
* @param {RTETextBlock} target - Current text block
|
|
1307
|
+
*/
|
|
1308
|
+
deleteTextNodeContent(action, target) {
|
|
1309
|
+
const startContainerNode = action.startContainerNode;
|
|
1310
|
+
const startOffset = action.startOffset;
|
|
1311
|
+
if (startOffset !== 0 && !startContainerNode.isEmpty()) {
|
|
1312
|
+
const newText = startContainerNode.text.slice(0, startOffset - 1) +
|
|
1313
|
+
startContainerNode.text.slice(startOffset);
|
|
1314
|
+
startContainerNode.apply(new codeBlock.UpdateTextAction(newText));
|
|
1315
|
+
if (newText) {
|
|
1316
|
+
action.previousNode = startContainerNode;
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
const previousNode = this.getPreviousNode(startContainerNode);
|
|
1321
|
+
// Remove the last character will not delete paragraph, the paragraph will removed after press delete again
|
|
1322
|
+
if ((previousNode && previousNode.parent === target && previousNode['text'] === '\n') ||
|
|
1323
|
+
target.children.length === 1) {
|
|
1324
|
+
action.previousNode = startContainerNode;
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
target.apply(new codeBlock.RemoveChildrenAction(startContainerNode));
|
|
1329
|
+
action.previousNode = previousNode;
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
else {
|
|
1335
|
+
let previousNode = this.getPreviousNode(startContainerNode);
|
|
1336
|
+
let nextNode = null;
|
|
1337
|
+
const isCurrentNodeEmpty = startContainerNode.isEmpty();
|
|
1338
|
+
if (target.children.length && previousNode && previousNode.parent !== target) {
|
|
1339
|
+
if (isCurrentNodeEmpty) {
|
|
1340
|
+
target.apply(new codeBlock.RemoveChildrenAction(startContainerNode));
|
|
1341
|
+
}
|
|
1342
|
+
if (target.type === previousNode.parent.type) {
|
|
1343
|
+
previousNode.parent.apply(new MergeTwoBlocksNodesAction(target));
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
if (this.isContentFirstNode(startContainerNode) && isCurrentNodeEmpty) {
|
|
1348
|
+
nextNode = this.getNextNode(startContainerNode);
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Remove line break
|
|
1352
|
+
*
|
|
1353
|
+
* @example caret at the first line
|
|
1354
|
+
* \n
|
|
1355
|
+
* test
|
|
1356
|
+
*/
|
|
1357
|
+
if (isCurrentNodeEmpty) {
|
|
1358
|
+
target.apply(new codeBlock.RemoveChildrenAction(startContainerNode));
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Remove line break or non-editable node
|
|
1362
|
+
*
|
|
1363
|
+
* @example caret at the begin of second line
|
|
1364
|
+
* \n
|
|
1365
|
+
* test
|
|
1366
|
+
* @example caret at the end of non-editable node and start of the text node
|
|
1367
|
+
* <img/><span>test</span>
|
|
1368
|
+
*/
|
|
1369
|
+
if (previousNode &&
|
|
1370
|
+
previousNode.isTextNode() &&
|
|
1371
|
+
(previousNode.isEmpty() ||
|
|
1372
|
+
(!previousNode.isContentEditable() && previousNode.parent === target))) {
|
|
1373
|
+
const shouldRemoveNode = previousNode;
|
|
1374
|
+
previousNode = this.getPreviousNode(previousNode);
|
|
1375
|
+
shouldRemoveNode.parent.apply(new codeBlock.RemoveChildrenAction(shouldRemoveNode));
|
|
1376
|
+
if (!previousNode && !isCurrentNodeEmpty) {
|
|
1377
|
+
nextNode = startContainerNode;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
// Remove the paragraph block if the content is empty
|
|
1382
|
+
// TODO: Check whether need to remove below logic because already handled the same logic in remove node strategy
|
|
1383
|
+
if (target.children.length === 0) {
|
|
1384
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
1385
|
+
}
|
|
1386
|
+
if (previousNode) {
|
|
1387
|
+
action.previousNode = previousNode;
|
|
1388
|
+
}
|
|
1389
|
+
else if (nextNode) {
|
|
1390
|
+
action.nextNode = nextNode;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Delete decorator node content
|
|
1396
|
+
*
|
|
1397
|
+
* @param {DeleteBlockContentAction} action - The delete block content action
|
|
1398
|
+
* @param {RTEBlock} target - The target block
|
|
1399
|
+
*/
|
|
1400
|
+
deleteDecoratorNodeContent(action, target) {
|
|
1401
|
+
const startContainerNode = action.startContainerNode, startOffset = action.startOffset;
|
|
1402
|
+
let previousNode = this.getPreviousNode(startContainerNode);
|
|
1403
|
+
let nextNode = null;
|
|
1404
|
+
if (startOffset !== 0) {
|
|
1405
|
+
const parentBlock = target;
|
|
1406
|
+
if (this.isContentFirstNode(startContainerNode)) {
|
|
1407
|
+
nextNode = this.getNextNode(startContainerNode);
|
|
1408
|
+
}
|
|
1409
|
+
if (parentBlock.children.length === 1) {
|
|
1410
|
+
parentBlock.parent.apply(new codeBlock.RemoveChildrenAction(parentBlock));
|
|
1411
|
+
}
|
|
1412
|
+
else {
|
|
1413
|
+
parentBlock.apply(new codeBlock.RemoveChildrenAction(startContainerNode));
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
const shouldRemoveNode = previousNode;
|
|
1418
|
+
if (shouldRemoveNode && !shouldRemoveNode.isContentEditable()) {
|
|
1419
|
+
previousNode = this.getPreviousNode(shouldRemoveNode);
|
|
1420
|
+
shouldRemoveNode.parent.apply(new codeBlock.RemoveChildrenAction(shouldRemoveNode));
|
|
1421
|
+
if (!previousNode) {
|
|
1422
|
+
action.nextNode = startContainerNode;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
if (previousNode) {
|
|
1427
|
+
action.previousNode = previousNode;
|
|
1428
|
+
}
|
|
1429
|
+
else if (nextNode) {
|
|
1430
|
+
action.nextNode = nextNode;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Insert new paragraph into current block at special position.
|
|
1437
|
+
*/
|
|
1438
|
+
class BlockInsertNewParagraphStrategy extends codeBlock.ActionHandleStrategy {
|
|
1439
|
+
/**
|
|
1440
|
+
* @inheritDoc
|
|
1441
|
+
*/
|
|
1442
|
+
handleAction(action, target) {
|
|
1443
|
+
const { startContainerNode } = action;
|
|
1444
|
+
action.newBlock = this.breakSingleBlock(startContainerNode, action.startOffset, target);
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* breakSingleTextBlock
|
|
1448
|
+
*
|
|
1449
|
+
* @param {RTETextNode} splitNode -
|
|
1450
|
+
* @param {number} startOffsetOfNode -
|
|
1451
|
+
* @param {RTEBlock} target -
|
|
1452
|
+
* @returns {Nullable<RTEBlock>} Nullable<RTEBlock>
|
|
1453
|
+
*/
|
|
1454
|
+
breakSingleBlock(splitNode, startOffsetOfNode, target) {
|
|
1455
|
+
const newParagraph = this.getNewParagraph(splitNode);
|
|
1456
|
+
if (newParagraph) {
|
|
1457
|
+
if (this.isCaretPositionAtBlockEnd(target, splitNode, startOffsetOfNode)) {
|
|
1458
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, newParagraph));
|
|
1459
|
+
}
|
|
1460
|
+
else if (this.isCaretPositionAtBlockStart(target, splitNode, startOffsetOfNode)) {
|
|
1461
|
+
target.parent.apply(new codeBlock.InsertChildrenBeforeAction(target, newParagraph));
|
|
1462
|
+
}
|
|
1463
|
+
else {
|
|
1464
|
+
const splitBlockAction = new codeBlock.SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
|
|
1465
|
+
target.apply(splitBlockAction);
|
|
1466
|
+
return splitBlockAction.newBlock;
|
|
1467
|
+
}
|
|
1468
|
+
return newParagraph;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Create new Paragraph
|
|
1473
|
+
*
|
|
1474
|
+
* @param {RTENode} splitNode - The split node of the block.
|
|
1475
|
+
* @returns {Nullable<RTETextBlock>} - The new text block.
|
|
1476
|
+
*/
|
|
1477
|
+
getNewParagraph(splitNode) {
|
|
1478
|
+
const newParagraph = this.createNewParagraph('');
|
|
1479
|
+
if (newParagraph) {
|
|
1480
|
+
let textNode = newParagraph.children[0];
|
|
1481
|
+
if (splitNode.isTextNode() && splitNode.isContentEditable()) {
|
|
1482
|
+
newParagraph.children = [];
|
|
1483
|
+
textNode = splitNode.cloneWithText('');
|
|
1484
|
+
// The link annotation don't need inherited
|
|
1485
|
+
textNode.annotationMap.delete(codeBlock.NodeAnnotationTypeEnum.LINK);
|
|
1486
|
+
newParagraph.apply(new codeBlock.AppendChildrenAction([textNode]));
|
|
1487
|
+
}
|
|
1488
|
+
return newParagraph;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Update the cursor position in the editor.
|
|
1495
|
+
*
|
|
1496
|
+
* @example richEditorRef.value.apply(new UpdateCursorPositionAction(nextFocusNode, [offset], [immediatelyRun]))
|
|
1497
|
+
*/
|
|
1498
|
+
class UpdateCursorPositionAction extends codeBlock.ModifyContentAction {
|
|
1499
|
+
/**
|
|
1500
|
+
* Set the cursor position at end of the current node.
|
|
1501
|
+
*
|
|
1502
|
+
* @param {RTENode} nextFocusNode - The rich text editor needs focus node.
|
|
1503
|
+
* @param {number} offset - The cursor offset position.
|
|
1504
|
+
* @param {boolean} immediatelyRun - Whether to immediately set the cursor position after applying it. Usually the set action will trigger after the UI renders.
|
|
1505
|
+
*/
|
|
1506
|
+
constructor(nextFocusNode, offset, immediatelyRun = false) {
|
|
1507
|
+
super();
|
|
1508
|
+
this.isFlushable = true;
|
|
1509
|
+
this.type = codeBlock.ModifyContentActionType.UPDATE_CURSOR_POSITION;
|
|
1510
|
+
this.immediatelyRun = false;
|
|
1511
|
+
this.nextFocusNode = nextFocusNode;
|
|
1512
|
+
this.offset = offset;
|
|
1513
|
+
this.immediatelyRun = immediatelyRun;
|
|
1514
|
+
// Don't flush changes if we want to immediately run the cursor update. Usually the current value is the latest value.
|
|
1515
|
+
if (this.immediatelyRun) {
|
|
1516
|
+
this.isFlushable = false;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Insert a new node in nearest position of parent block strategy.
|
|
1523
|
+
*/
|
|
1524
|
+
class InsertNodeToNearestRootStrategy extends codeBlock.ActionHandleStrategy {
|
|
1525
|
+
/**
|
|
1526
|
+
* @inheritDoc
|
|
1527
|
+
*/
|
|
1528
|
+
handleAction(action, target) {
|
|
1529
|
+
const { rteRange, nodeToBeInserted } = action;
|
|
1530
|
+
const { startNode, startOffset } = rteRange;
|
|
1531
|
+
if (startNode) {
|
|
1532
|
+
const parent = target;
|
|
1533
|
+
if (startNode.isContentEditable() && startNode.isTextNode()) {
|
|
1534
|
+
if (startNode.text === '\n' || !startNode.text || startOffset === 0) {
|
|
1535
|
+
parent.apply(new codeBlock.InsertChildrenBeforeAction(startNode, nodeToBeInserted));
|
|
1536
|
+
}
|
|
1537
|
+
else {
|
|
1538
|
+
const startText = startNode.text.substring(0, startOffset);
|
|
1539
|
+
const endText = startNode.text.substring(startOffset);
|
|
1540
|
+
const startTextNode = startNode.cloneWithText(startText);
|
|
1541
|
+
const endTextNode = startNode.cloneWithText(endText);
|
|
1542
|
+
const insertNodes = [startTextNode, nodeToBeInserted];
|
|
1543
|
+
if (endText) {
|
|
1544
|
+
insertNodes.push(endTextNode);
|
|
1545
|
+
}
|
|
1546
|
+
parent.apply(new codeBlock.InsertChildrenBeforeAction(startNode, ...insertNodes));
|
|
1547
|
+
parent.apply(new codeBlock.RemoveChildrenAction(startNode));
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
else {
|
|
1551
|
+
if (startOffset !== 0) {
|
|
1552
|
+
parent.apply(new codeBlock.InsertChildrenAfterAction(startNode, nodeToBeInserted));
|
|
1553
|
+
}
|
|
1554
|
+
else {
|
|
1555
|
+
parent.apply(new codeBlock.InsertChildrenBeforeAction(startNode, nodeToBeInserted));
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
this.updateCursorPosition(nodeToBeInserted);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Update the cursor position to end of the inserted node.
|
|
1563
|
+
*
|
|
1564
|
+
* @param {RTENode} node - node to find root content
|
|
1565
|
+
*/
|
|
1566
|
+
updateCursorPosition(node) {
|
|
1567
|
+
const root = this.getRootContent(node.parent);
|
|
1568
|
+
if (root) {
|
|
1569
|
+
root.apply(new UpdateCursorPositionAction(node));
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
/**
|
|
1575
|
+
* Strategy for inserting text into a decorator node. The decorator can not edit, so we insert the text as a new child.
|
|
1576
|
+
*/
|
|
1577
|
+
class InsertTextToDecoratorNodeStrategy extends codeBlock.ActionHandleStrategy {
|
|
1578
|
+
/**
|
|
1579
|
+
* @inheritDoc
|
|
1580
|
+
*/
|
|
1581
|
+
handleAction(action, target) {
|
|
1582
|
+
const { text, offset, decoratorNode } = action;
|
|
1583
|
+
const paragraph = this.createNewParagraph(text);
|
|
1584
|
+
if (paragraph) {
|
|
1585
|
+
const newTextNode = paragraph.children[0];
|
|
1586
|
+
if (offset !== 0) {
|
|
1587
|
+
target.apply(new codeBlock.InsertChildrenAfterAction(decoratorNode, newTextNode));
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
target.apply(new codeBlock.InsertChildrenBeforeAction(decoratorNode, newTextNode));
|
|
1591
|
+
}
|
|
1592
|
+
this.setTheCursorPosition(newTextNode);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Set the cursor position to the new text node.
|
|
1597
|
+
*
|
|
1598
|
+
* @param {RTENode} focusNode - The new text node to focus on.
|
|
1599
|
+
*/
|
|
1600
|
+
setTheCursorPosition(focusNode) {
|
|
1601
|
+
const rootContent = this.getRootContent(focusNode.parent);
|
|
1602
|
+
if (rootContent) {
|
|
1603
|
+
rootContent.apply(new UpdateCursorPositionAction(focusNode));
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* Insert new paragraph into current list item block at special position.
|
|
1610
|
+
*/
|
|
1611
|
+
class ListItemInsertNewParagraphStrategy extends codeBlock.ActionHandleStrategy {
|
|
1612
|
+
/**
|
|
1613
|
+
* @inheritDoc
|
|
1614
|
+
*/
|
|
1615
|
+
handleAction(action, target) {
|
|
1616
|
+
action.newBlock = this.breakSingleListItemBlock(action.startContainerNode, action.startOffset, target);
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Breaks a single list item block at a specific position.
|
|
1620
|
+
*
|
|
1621
|
+
* @param {RTETextNode} splitNode - The node that needs to be split within a list item block.
|
|
1622
|
+
* @param {number} startOffsetOfNode - The index within the `splitNode` where the break operation should occur.
|
|
1623
|
+
* @param {RTEListItemBlock} target - The list item block.
|
|
1624
|
+
* @returns {Nullable<RTEBlock>} Returns either a new `RTEListItemBlock` if the caret
|
|
1625
|
+
* position is at the end of the `splitNode`, or it returns the result of splitting the block at the
|
|
1626
|
+
* caret position if it is neither at the start nor at the end.
|
|
1627
|
+
*/
|
|
1628
|
+
breakSingleListItemBlock(splitNode, startOffsetOfNode, target) {
|
|
1629
|
+
const newListItem = target.createNewListItem();
|
|
1630
|
+
const newBreakNode = this.copyInlineStyleToNewNode(splitNode);
|
|
1631
|
+
newListItem.apply(new codeBlock.AppendChildrenAction([newBreakNode]));
|
|
1632
|
+
if (this.isCaretPositionAtBlockEnd(target, splitNode, startOffsetOfNode)) {
|
|
1633
|
+
return this.breakListItemAtEnd(newListItem, target);
|
|
1634
|
+
}
|
|
1635
|
+
else if (this.isCaretPositionAtBlockStart(target, splitNode, startOffsetOfNode)) {
|
|
1636
|
+
target.parent.apply(new codeBlock.InsertChildrenBeforeAction(target, newListItem));
|
|
1637
|
+
}
|
|
1638
|
+
else {
|
|
1639
|
+
const splitBlockAction = new codeBlock.SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
|
|
1640
|
+
target.apply(splitBlockAction);
|
|
1641
|
+
return splitBlockAction.newBlock;
|
|
1642
|
+
}
|
|
1643
|
+
return newListItem;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Breaks a list item at the end and handles the insertion of a new list item or paragraph accordingly.
|
|
1647
|
+
*
|
|
1648
|
+
* @param {RTEListItemBlock} newListItem - Item that represents a new list item to be added to the existing list.
|
|
1649
|
+
* @param {RTEListItemBlock} target - The list item block.
|
|
1650
|
+
* @returns {RTEBlock} Returns a `RTEBlock`.
|
|
1651
|
+
*/
|
|
1652
|
+
breakListItemAtEnd(newListItem, target) {
|
|
1653
|
+
const lastItem = target.parent.children[target.parent.children.length - 1];
|
|
1654
|
+
const currentItemIsEmpty = target.children.length === 1 && target.children[0].isEmpty();
|
|
1655
|
+
if (target === lastItem && currentItemIsEmpty) {
|
|
1656
|
+
const parentParent = target.parent.parent;
|
|
1657
|
+
if (parentParent['type'] !== 'list-item') {
|
|
1658
|
+
const newParagraph = codeBlock.RTETextBlock.from({
|
|
1659
|
+
id: misc.generateUUID(),
|
|
1660
|
+
type: 'paragraph',
|
|
1661
|
+
nodes: [],
|
|
1662
|
+
});
|
|
1663
|
+
newParagraph.apply(new codeBlock.AppendChildrenAction(newListItem.children));
|
|
1664
|
+
parentParent.apply(new codeBlock.InsertChildrenAfterAction(target.parent, newParagraph));
|
|
1665
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
1666
|
+
return newParagraph;
|
|
1667
|
+
}
|
|
1668
|
+
else {
|
|
1669
|
+
parentParent.parent.apply(new codeBlock.InsertChildrenAfterAction(parentParent, newListItem));
|
|
1670
|
+
target.parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
else {
|
|
1674
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, newListItem));
|
|
1675
|
+
}
|
|
1676
|
+
return newListItem;
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* Copy the inline style to new node
|
|
1680
|
+
*
|
|
1681
|
+
* @param {RTETextNode} needCopedNode - The node that needed to be copied to
|
|
1682
|
+
* @returns {RTETextNode} Returns a `RTETextNode`.
|
|
1683
|
+
*/
|
|
1684
|
+
copyInlineStyleToNewNode(needCopedNode) {
|
|
1685
|
+
const textNode = needCopedNode.cloneWithText('');
|
|
1686
|
+
// The link annotation doesn't need to inherit
|
|
1687
|
+
textNode.annotationMap.delete(codeBlock.NodeAnnotationTypeEnum.LINK);
|
|
1688
|
+
return textNode;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Delete the nest list block action
|
|
1694
|
+
*
|
|
1695
|
+
* @example needRemovedNestList.parent.apply(new RemoveNestListAction(needRemovedNestList))
|
|
1696
|
+
*/
|
|
1697
|
+
class RemoveNestListAction extends codeBlock.ModifyContentAction {
|
|
1698
|
+
constructor(childList) {
|
|
1699
|
+
super();
|
|
1700
|
+
this.type = codeBlock.ModifyContentActionType.DELETE_NEST_LIST;
|
|
1701
|
+
this.nestListBlockToBeRemoved = childList;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* List remove list item strategy.
|
|
1707
|
+
*/
|
|
1708
|
+
class ListRemoveListItemStrategy extends codeBlock.RemoveChildrenStrategy {
|
|
1709
|
+
/**
|
|
1710
|
+
* Remove the list item, check the list item and remove self if the list item is empty.
|
|
1711
|
+
*
|
|
1712
|
+
* @param {RemoveChildrenAction} action - The remove action instance.
|
|
1713
|
+
* @param {RTEListBlock} target - The list block.
|
|
1714
|
+
*/
|
|
1715
|
+
handleAction(action, target) {
|
|
1716
|
+
super.handleAction(action, target);
|
|
1717
|
+
const parent = target.parent;
|
|
1718
|
+
if (target.children.length === 0 && parent) {
|
|
1719
|
+
// The parent is a list item mean the current block is a nest list, so we need to use RemoveNestListAction to remove the item
|
|
1720
|
+
if (parent['type'] === 'list-item') {
|
|
1721
|
+
parent.apply(new RemoveNestListAction(target));
|
|
1722
|
+
}
|
|
1723
|
+
else {
|
|
1724
|
+
parent.apply(new codeBlock.RemoveChildrenAction(target));
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* Strategy to handle the paste content into function block.
|
|
1732
|
+
*/
|
|
1733
|
+
class PasteContentStrategy extends codeBlock.ActionHandleStrategy {
|
|
1734
|
+
/**
|
|
1735
|
+
* @inheritDoc
|
|
1736
|
+
*/
|
|
1737
|
+
handleAction(action, target) {
|
|
1738
|
+
if (target.parent) {
|
|
1739
|
+
const { blocksToBeInserted, startNode, startOffset } = action;
|
|
1740
|
+
let futureFocusBlock = target;
|
|
1741
|
+
if (startNode === target.children[0] && startOffset === 0) {
|
|
1742
|
+
target.parent.apply(new codeBlock.InsertChildrenBeforeAction(target, ...blocksToBeInserted));
|
|
1743
|
+
}
|
|
1744
|
+
else {
|
|
1745
|
+
const breakAction = new codeBlock.SplitBlockWithNodeAction(startNode, startOffset);
|
|
1746
|
+
target.apply(breakAction);
|
|
1747
|
+
target.parent.apply(new codeBlock.InsertChildrenAfterAction(target, ...blocksToBeInserted));
|
|
1748
|
+
futureFocusBlock = breakAction.newBlock;
|
|
1749
|
+
}
|
|
1750
|
+
action.futureFocusBlock = futureFocusBlock;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
/**
|
|
1756
|
+
* Manager class for registering DTO action strategies.
|
|
1757
|
+
*/
|
|
1758
|
+
class RTEDTOActionStrategyManager {
|
|
1759
|
+
/**
|
|
1760
|
+
* Registers basic strategies for a given DTO class.
|
|
1761
|
+
*
|
|
1762
|
+
* @param {string} dtoClassName - The name of the RTE block class name.
|
|
1763
|
+
*/
|
|
1764
|
+
registerBlockBasicStrategies(dtoClassName) {
|
|
1765
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.DELETE_CHILDREN, dtoClassName, dtoClassName === RTEListBlock.name
|
|
1766
|
+
? new ListRemoveListItemStrategy()
|
|
1767
|
+
: new codeBlock.RemoveChildrenStrategy());
|
|
1768
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.APPEND_CHILDREN, dtoClassName, new AppendChildrenStrategy());
|
|
1769
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_CHILDREN_BEFORE, dtoClassName, new InsertChildrenBeforeStrategy());
|
|
1770
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_CHILDREN_AFTER, dtoClassName, new InsertChildrenAfterStrategy());
|
|
1771
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.DELETE_BLOCK_CONTENT, dtoClassName, new BlockDeleteTextOrDecoratorNodeStrategy());
|
|
1772
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_NEW_PARAGRAPH, dtoClassName, dtoClassName === RTEListItemBlock.name
|
|
1773
|
+
? new ListItemInsertNewParagraphStrategy()
|
|
1774
|
+
: new BlockInsertNewParagraphStrategy());
|
|
1775
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_TEXT_TO_DECORATOR_NODE, dtoClassName, new InsertTextToDecoratorNodeStrategy());
|
|
1776
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_NODE_TO_NEAREST_ROOT, dtoClassName, new InsertNodeToNearestRootStrategy());
|
|
1777
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.PASTE_CONTENT, dtoClassName, new PasteContentStrategy());
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
const RTEDTOActionStrategyManager$1 = new RTEDTOActionStrategyManager();
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* Abstract class to define handler for generate the annotations
|
|
1784
|
+
*/
|
|
1785
|
+
class AnnotationGeneratorStrategyAbstract {
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/** Handle bold annotation */
|
|
1789
|
+
class BoldAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
1790
|
+
/**
|
|
1791
|
+
* @inheritDoc
|
|
1792
|
+
*/
|
|
1793
|
+
canHandle(targetDto) {
|
|
1794
|
+
return targetDto.name === 'RTETextNode';
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Handle annotation.
|
|
1798
|
+
*
|
|
1799
|
+
* @param {HTMLElement} element - Current elements.
|
|
1800
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
1801
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
1802
|
+
*/
|
|
1803
|
+
handle(element, parentAnnotations = {}) {
|
|
1804
|
+
return this.isBold(element) || parentAnnotations.bold ? { bold: true } : {};
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Is bold element.
|
|
1808
|
+
*
|
|
1809
|
+
* @param {HTMLElement} element - current element.
|
|
1810
|
+
* @returns {boolean} - boolean.
|
|
1811
|
+
*/
|
|
1812
|
+
isBold(element) {
|
|
1813
|
+
return (element.nodeName === 'STRONG' ||
|
|
1814
|
+
element.nodeName === 'B' ||
|
|
1815
|
+
element.style.fontWeight === codeBlock.BOLD_FONT_WEIGHT_KEYWORD ||
|
|
1816
|
+
element.style.fontWeight === codeBlock.BOLD_FONT_WEIGHT ||
|
|
1817
|
+
element.classList.contains('v-rte--bold'));
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/** Handle custom attribute annotation */
|
|
1822
|
+
class CustomAttributeAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
1823
|
+
/**
|
|
1824
|
+
* Can be handle.
|
|
1825
|
+
*
|
|
1826
|
+
* @param {RTEDtoClassPrototype} targetDto - Target DTO.
|
|
1827
|
+
* @param {HtmlElementToAnnotationGenerateOptions} [options] - Options for annotation generator.
|
|
1828
|
+
* @returns {boolean} - .
|
|
1829
|
+
*/
|
|
1830
|
+
canHandle(targetDto, options) {
|
|
1831
|
+
return !options.skipCustomAnnotations && !!targetDto;
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Handle annotation.
|
|
1835
|
+
*
|
|
1836
|
+
* @param {HTMLElement} element - Current elements.
|
|
1837
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
1838
|
+
*/
|
|
1839
|
+
handle(element) {
|
|
1840
|
+
const attributes = this.getAttributes(element);
|
|
1841
|
+
return Object.keys(attributes).length > 0 ? { customAttribute: attributes } : {};
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Obtain the custom attributes of element, excluding 'style' and 'class'.
|
|
1845
|
+
*
|
|
1846
|
+
* @param {HTMLElement} element - current element.
|
|
1847
|
+
* @returns {Record<string, string>} - Record<string, string>.
|
|
1848
|
+
*/
|
|
1849
|
+
getAttributes(element) {
|
|
1850
|
+
const attributeNames = element
|
|
1851
|
+
.getAttributeNames()
|
|
1852
|
+
.filter((attr) => attr !== 'style' && attr !== 'class' && this.isValidAttr(attr));
|
|
1853
|
+
return attributeNames.reduce((acc, item) => {
|
|
1854
|
+
acc[item] = element.getAttribute(item);
|
|
1855
|
+
return acc;
|
|
1856
|
+
}, {});
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Check if the attribute name is valid.
|
|
1860
|
+
*
|
|
1861
|
+
* @param {string} attr - Attribute name.
|
|
1862
|
+
* @returns {boolean} - True if valid, false otherwise.
|
|
1863
|
+
*/
|
|
1864
|
+
isValidAttr(attr) {
|
|
1865
|
+
return /^[a-zA-Z_][\w-]*$/.test(attr);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
/** Handle custom class annotation */
|
|
1870
|
+
class CustomClassAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
1871
|
+
/**
|
|
1872
|
+
* Can be handle.
|
|
1873
|
+
*
|
|
1874
|
+
* @param {RTEDtoClassPrototype} targetDto - Target DTO.
|
|
1875
|
+
* @param {HtmlElementToAnnotationGenerateOptions} [options] - Options for annotation generator.
|
|
1876
|
+
* @returns {boolean} - .
|
|
1877
|
+
*/
|
|
1878
|
+
canHandle(targetDto, options) {
|
|
1879
|
+
return !options.skipCustomAnnotations && !!targetDto;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Handle annotation.
|
|
1883
|
+
*
|
|
1884
|
+
* @param {HTMLElement} element - Current elements.
|
|
1885
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
1886
|
+
*/
|
|
1887
|
+
handle(element) {
|
|
1888
|
+
const classes = this.getCustomClass(element);
|
|
1889
|
+
return classes.length > 0 ? { customClass: classes } : {};
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Get the custom class
|
|
1893
|
+
*
|
|
1894
|
+
* @param {HTMLElement} element - current element.
|
|
1895
|
+
* @returns {string[]} - the class after .
|
|
1896
|
+
*/
|
|
1897
|
+
getCustomClass(element) {
|
|
1898
|
+
return element.classList
|
|
1899
|
+
.toString()
|
|
1900
|
+
.split(' ')
|
|
1901
|
+
.filter((item) => !item.includes('v-rte') && item !== '');
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
/** Handle custom style annotation */
|
|
1906
|
+
class CustomStyleAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
1907
|
+
/**
|
|
1908
|
+
* Can be handle.
|
|
1909
|
+
*
|
|
1910
|
+
* @param {RTEDtoClassPrototype} targetDto - Target DTO.
|
|
1911
|
+
* @param {HtmlElementToAnnotationGenerateOptions} [options] - Options for annotation generator.
|
|
1912
|
+
* @returns {boolean} - .
|
|
1913
|
+
*/
|
|
1914
|
+
canHandle(targetDto, options) {
|
|
1915
|
+
return !options.skipCustomAnnotations && !!targetDto;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* Handle annotation.
|
|
1919
|
+
*
|
|
1920
|
+
* @param {HTMLElement} element - Current elements.
|
|
1921
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
1922
|
+
*/
|
|
1923
|
+
handle(element) {
|
|
1924
|
+
const styles = codeBlock.createStyleMapFromElement(element);
|
|
1925
|
+
return Object.keys(styles).length > 0 ? { customStyle: styles } : {};
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
/** Handle indent annotation */
|
|
1930
|
+
class IndentAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
1931
|
+
/**
|
|
1932
|
+
* @inheritDoc
|
|
1933
|
+
*/
|
|
1934
|
+
canHandle(targetDto) {
|
|
1935
|
+
return ['RTETextBlock', 'RTEListItemBlock', 'RTEListBlock'].includes(targetDto.name);
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Handle annotation.
|
|
1939
|
+
*
|
|
1940
|
+
* @param {HTMLElement} element - Current elements.
|
|
1941
|
+
* @returns {VegaRTEBlockAnnotations} - Annotation.
|
|
1942
|
+
*/
|
|
1943
|
+
handle(element) {
|
|
1944
|
+
const indent = this.getIndent(element);
|
|
1945
|
+
return indent ? { indent: indent } : {};
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Get indent of current element.
|
|
1949
|
+
*
|
|
1950
|
+
* @param {HTMLElement} element - current element.
|
|
1951
|
+
* @returns {Nullable<number>} - Indent.
|
|
1952
|
+
*/
|
|
1953
|
+
getIndent(element) {
|
|
1954
|
+
const style = element.style;
|
|
1955
|
+
let marginLeft;
|
|
1956
|
+
if (style.marginLeft) {
|
|
1957
|
+
marginLeft = style.marginLeft;
|
|
1958
|
+
}
|
|
1959
|
+
else if (style.margin) {
|
|
1960
|
+
const margins = style.margin.split(' ');
|
|
1961
|
+
switch (margins.length) {
|
|
1962
|
+
case 4:
|
|
1963
|
+
marginLeft = margins[3];
|
|
1964
|
+
break;
|
|
1965
|
+
case 2:
|
|
1966
|
+
case 3:
|
|
1967
|
+
marginLeft = margins[1];
|
|
1968
|
+
break;
|
|
1969
|
+
default:
|
|
1970
|
+
marginLeft = margins[0];
|
|
1971
|
+
break;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
else {
|
|
1975
|
+
return null;
|
|
1976
|
+
}
|
|
1977
|
+
const marginLeftNumber = Number(marginLeft.replace('px', ''));
|
|
1978
|
+
return marginLeftNumber && marginLeftNumber >= 0 ? Math.floor(marginLeftNumber / 16) : null;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
/** Handle text align annotation */
|
|
1983
|
+
class TextAlignAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
1984
|
+
/**
|
|
1985
|
+
* Can be handle.
|
|
1986
|
+
*
|
|
1987
|
+
* @param {RTEDtoClassPrototype} targetDto - Target DTO.
|
|
1988
|
+
* @returns {boolean} - .
|
|
1989
|
+
*/
|
|
1990
|
+
canHandle(targetDto) {
|
|
1991
|
+
return ['RTETextBlock', 'RTEListItemBlock', 'RTEListBlock'].includes(targetDto.name);
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Handle annotation.
|
|
1995
|
+
*
|
|
1996
|
+
* @param {HTMLElement} element - Current elements.
|
|
1997
|
+
* @returns {VegaRTEBlockAnnotations} - Annotation.
|
|
1998
|
+
*/
|
|
1999
|
+
handle(element) {
|
|
2000
|
+
const textAlign = this.getTextAlign(element);
|
|
2001
|
+
return textAlign ? { textAlign: textAlign } : {};
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Get text align of current element.
|
|
2005
|
+
*
|
|
2006
|
+
* @param {HTMLElement} element - current element.
|
|
2007
|
+
* @returns {Nullable<VegaRTEBlockAlignment>} - Text align.
|
|
2008
|
+
*/
|
|
2009
|
+
getTextAlign(element) {
|
|
2010
|
+
const classList = element.classList;
|
|
2011
|
+
if (classList.contains(`v-rte--horizontal-alignment-left`)) {
|
|
2012
|
+
return 'left';
|
|
2013
|
+
}
|
|
2014
|
+
else if (classList.contains(`v-rte--horizontal-alignment-center`)) {
|
|
2015
|
+
return 'center';
|
|
2016
|
+
}
|
|
2017
|
+
else if (classList.contains(`v-rte--horizontal-alignment-right`)) {
|
|
2018
|
+
return 'right';
|
|
2019
|
+
}
|
|
2020
|
+
else if (classList.contains(`v-rte--horizontal-alignment-justify`)) {
|
|
2021
|
+
return 'justify';
|
|
2022
|
+
}
|
|
2023
|
+
const style = element.style;
|
|
2024
|
+
switch (style.textAlign) {
|
|
2025
|
+
case 'center':
|
|
2026
|
+
return 'center';
|
|
2027
|
+
case 'right':
|
|
2028
|
+
return 'right';
|
|
2029
|
+
case 'justify':
|
|
2030
|
+
return 'justify';
|
|
2031
|
+
case 'left':
|
|
2032
|
+
return 'left';
|
|
2033
|
+
default:
|
|
2034
|
+
return null;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
/** Handle code annotation */
|
|
2040
|
+
class CodeAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2041
|
+
/**
|
|
2042
|
+
* @inheritDoc
|
|
2043
|
+
*/
|
|
2044
|
+
canHandle(targetDto) {
|
|
2045
|
+
return targetDto.name === 'RTETextNode';
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* Handle annotation.
|
|
2049
|
+
*
|
|
2050
|
+
* @param {HTMLElement} element - Current elements.
|
|
2051
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
2052
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
2053
|
+
*/
|
|
2054
|
+
handle(element, parentAnnotations = {}) {
|
|
2055
|
+
return this.isCode(element) || parentAnnotations.code ? { code: true } : {};
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Is code element.
|
|
2059
|
+
*
|
|
2060
|
+
* @param {HTMLElement} element - current element.
|
|
2061
|
+
* @returns {boolean} - boolean.
|
|
2062
|
+
*/
|
|
2063
|
+
isCode(element) {
|
|
2064
|
+
return (element.classList.contains('v-rte--code') ||
|
|
2065
|
+
element.nodeName === 'CODE' ||
|
|
2066
|
+
element.nodeName === 'PRE' ||
|
|
2067
|
+
element.style.fontFamily === 'monospace' ||
|
|
2068
|
+
element.style.fontFamily.replace(/["']/g, '') === 'Roboto Mono');
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
/** Handle color annotation */
|
|
2073
|
+
class ColorAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2074
|
+
/**
|
|
2075
|
+
* @inheritDoc
|
|
2076
|
+
*/
|
|
2077
|
+
canHandle(targetDto) {
|
|
2078
|
+
return targetDto.name === 'RTETextNode';
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Handle annotation.
|
|
2082
|
+
*
|
|
2083
|
+
* @param {HTMLElement} element - Current elements.
|
|
2084
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
2085
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
2086
|
+
*/
|
|
2087
|
+
handle(element, parentAnnotations = {}) {
|
|
2088
|
+
const color = this.getColor(element) || parentAnnotations.textColor;
|
|
2089
|
+
return color ? { textColor: color } : {};
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Get current color of element.
|
|
2093
|
+
*
|
|
2094
|
+
* @param {HTMLElement} element - current element.
|
|
2095
|
+
* @returns {Nullable<string>} - color.
|
|
2096
|
+
*/
|
|
2097
|
+
getColor(element) {
|
|
2098
|
+
var _a;
|
|
2099
|
+
const color = element.style.color;
|
|
2100
|
+
const hexColor = (_a = ui.rgbToHex(color)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
2101
|
+
if (hexColor) {
|
|
2102
|
+
// We don't display default text color as inline style, because we defined it in the vega-rich-text-content.scss.
|
|
2103
|
+
const colorSchema = codeBlock.RTE_TEXT_COLORS.filter((item) => item.key !== codeBlock.RTE_DEFAULT_TEXT_COLOR.key).find((schema) => schema.light === hexColor || schema.dark === hexColor);
|
|
2104
|
+
if (colorSchema)
|
|
2105
|
+
return colorSchema.key;
|
|
2106
|
+
return null;
|
|
2107
|
+
}
|
|
2108
|
+
else {
|
|
2109
|
+
for (const color of codeBlock.RTE_TEXT_COLORS) {
|
|
2110
|
+
if (element.style.color.includes(color.key)) {
|
|
2111
|
+
return color.key;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
return null;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
/** Handle italic annotation */
|
|
2120
|
+
class ItalicAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2121
|
+
/**
|
|
2122
|
+
* @inheritDoc
|
|
2123
|
+
*/
|
|
2124
|
+
canHandle(targetDto) {
|
|
2125
|
+
return targetDto.name === 'RTETextNode';
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Handle annotation.
|
|
2129
|
+
*
|
|
2130
|
+
* @param {HTMLElement} element - Current elements.
|
|
2131
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
2132
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
2133
|
+
*/
|
|
2134
|
+
handle(element, parentAnnotations = {}) {
|
|
2135
|
+
return this.isItalic(element) || parentAnnotations.italic ? { italic: true } : {};
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Is italic element.
|
|
2139
|
+
*
|
|
2140
|
+
* @param {HTMLElement} element - current element.
|
|
2141
|
+
* @returns {boolean} - boolean.
|
|
2142
|
+
*/
|
|
2143
|
+
isItalic(element) {
|
|
2144
|
+
return (element.nodeName === 'I' ||
|
|
2145
|
+
element.style.fontStyle === codeBlock.ITALIC_FONT_STYLE ||
|
|
2146
|
+
element.nodeName === 'EM' ||
|
|
2147
|
+
element.classList.contains('v-rte--italic'));
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/** Handle text style annotation */
|
|
2152
|
+
class TextStyleAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2153
|
+
/**
|
|
2154
|
+
* Can be handle.
|
|
2155
|
+
*
|
|
2156
|
+
* @param {RTEDtoClassPrototype} targetDto - Target DTO.
|
|
2157
|
+
* @param {HtmlElementToAnnotationGenerateOptions} options - Options for annotation generator.
|
|
2158
|
+
* @returns {boolean} - .
|
|
2159
|
+
*/
|
|
2160
|
+
canHandle(targetDto, options) {
|
|
2161
|
+
return !!options.autoMatchFormat && targetDto.name === 'RTETextBlock';
|
|
2162
|
+
}
|
|
2163
|
+
/**
|
|
2164
|
+
* Handle annotation.
|
|
2165
|
+
*
|
|
2166
|
+
* @param {HTMLElement} element - Current elements.
|
|
2167
|
+
* @returns {VegaRTETextBlockAnnotations} - Annotation.
|
|
2168
|
+
*/
|
|
2169
|
+
handle(element) {
|
|
2170
|
+
const textStyle = this.getTextStyle(element);
|
|
2171
|
+
return textStyle ? { textStyle: textStyle } : {};
|
|
2172
|
+
}
|
|
2173
|
+
/**
|
|
2174
|
+
* Get the node type of element. The element type is determined in the following
|
|
2175
|
+
* order: "data-type" attribute, node name, font size and class name.
|
|
2176
|
+
*
|
|
2177
|
+
* @param {HTMLElement} element - element.
|
|
2178
|
+
* @returns {Nullable<VegaRTETextStyleType>} - node type.
|
|
2179
|
+
*/
|
|
2180
|
+
getTextStyle(element) {
|
|
2181
|
+
const byDataType = this.getElementTypeByDataType(element);
|
|
2182
|
+
if (byDataType)
|
|
2183
|
+
return byDataType;
|
|
2184
|
+
const byNodeName = this.getElementTypeByNodeName(element);
|
|
2185
|
+
if (byNodeName)
|
|
2186
|
+
return byNodeName;
|
|
2187
|
+
const byFontSize = this.getElementTypeByFontSize(element);
|
|
2188
|
+
if (byFontSize)
|
|
2189
|
+
return byFontSize;
|
|
2190
|
+
const byClassName = this.getElementTypeByClassName(element);
|
|
2191
|
+
if (byClassName)
|
|
2192
|
+
return byClassName;
|
|
2193
|
+
return null;
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Get the element type by data-type attribute.
|
|
2197
|
+
*
|
|
2198
|
+
* @param {HTMLElement} element - element.
|
|
2199
|
+
* @returns {Nullable<VegaRTETextStyleType>} - element type or null if not found.
|
|
2200
|
+
*/
|
|
2201
|
+
getElementTypeByDataType(element) {
|
|
2202
|
+
if (element.nodeType !== Node.TEXT_NODE && element.hasAttribute('data-type')) {
|
|
2203
|
+
return element.getAttribute('data-type');
|
|
2204
|
+
}
|
|
2205
|
+
return null;
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Get the element type by font size.
|
|
2209
|
+
*
|
|
2210
|
+
* @param {HTMLElement} element - element.
|
|
2211
|
+
* @returns {Nullable<VegaRTETextStyleType>} - element type or null if not found.
|
|
2212
|
+
*/
|
|
2213
|
+
getElementTypeByFontSize(element) {
|
|
2214
|
+
var _a;
|
|
2215
|
+
switch ((_a = element.style) === null || _a === void 0 ? void 0 : _a.fontSize) {
|
|
2216
|
+
case '36px':
|
|
2217
|
+
return 'title';
|
|
2218
|
+
case '28px':
|
|
2219
|
+
return 'subtitle';
|
|
2220
|
+
case '22px':
|
|
2221
|
+
return 'heading-1';
|
|
2222
|
+
case '20px':
|
|
2223
|
+
return 'heading-2';
|
|
2224
|
+
case '18px':
|
|
2225
|
+
return 'heading-3';
|
|
2226
|
+
default:
|
|
2227
|
+
return null;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Get the element type by node name.
|
|
2232
|
+
*
|
|
2233
|
+
* @param {HTMLElement} element - element.
|
|
2234
|
+
* @returns {Nullable<VegaRTETextStyleType>} - element type or null if not found.
|
|
2235
|
+
*/
|
|
2236
|
+
getElementTypeByNodeName(element) {
|
|
2237
|
+
switch (element.nodeName) {
|
|
2238
|
+
case 'P':
|
|
2239
|
+
return 'paragraph';
|
|
2240
|
+
case 'H1':
|
|
2241
|
+
return 'heading-1';
|
|
2242
|
+
case 'H2':
|
|
2243
|
+
return 'heading-2';
|
|
2244
|
+
case 'H3':
|
|
2245
|
+
return 'heading-3';
|
|
2246
|
+
case 'H4':
|
|
2247
|
+
return 'heading-4';
|
|
2248
|
+
case 'H5':
|
|
2249
|
+
return 'heading-5';
|
|
2250
|
+
case 'H6':
|
|
2251
|
+
return 'heading-6';
|
|
2252
|
+
default:
|
|
2253
|
+
return null;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Get the element type by class name.
|
|
2258
|
+
*
|
|
2259
|
+
* @param {HTMLElement} element - element.
|
|
2260
|
+
* @returns {Nullable<VegaRTETextStyleType>} - element type or null if not found.
|
|
2261
|
+
*/
|
|
2262
|
+
getElementTypeByClassName(element) {
|
|
2263
|
+
if (element.className) {
|
|
2264
|
+
// Match class name with pattern "v-rte--text-style-{textStyle}" or "v-rte-{textStyle}".
|
|
2265
|
+
const match = /\bv-rte-(?:-text-style-)?(title|subtitle|heading-1|heading-2|heading-3|heading-4|heading-5|heading-6|paragraph)\b/.exec(element.className);
|
|
2266
|
+
if (match) {
|
|
2267
|
+
return match[1];
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
return null;
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
/**
|
|
2275
|
+
* Predicate class provides static methods to check specific conditions on HTML elements.
|
|
2276
|
+
*/
|
|
2277
|
+
class Predicate {
|
|
2278
|
+
/**
|
|
2279
|
+
* Checks if the given element is a title or subtitle.
|
|
2280
|
+
*
|
|
2281
|
+
* @param {HTMLElement} element The element to check.
|
|
2282
|
+
* @returns {boolean} True if the element is a title or subtitle, false otherwise.
|
|
2283
|
+
*/
|
|
2284
|
+
static isTitleOrSubtitle(element) {
|
|
2285
|
+
if (element.nodeName === 'DIV') {
|
|
2286
|
+
const textBlockType = Predicate.textStyleHandler['getTextStyle'](element);
|
|
2287
|
+
return textBlockType === 'title' || textBlockType === 'subtitle';
|
|
2288
|
+
}
|
|
2289
|
+
return false;
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Check if the given element is a link element (anchor tag).
|
|
2293
|
+
*
|
|
2294
|
+
* @param {HTMLElement} element The element to check.
|
|
2295
|
+
* @returns {boolean} True if the element is a link element, false otherwise.
|
|
2296
|
+
*/
|
|
2297
|
+
static isLinkElement(element) {
|
|
2298
|
+
return element.nodeName === 'A';
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
Predicate.textStyleHandler = new TextStyleAnnotationHandler();
|
|
2302
|
+
|
|
2303
|
+
/** Handle link annotation */
|
|
2304
|
+
class LinkAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2305
|
+
constructor() {
|
|
2306
|
+
super(...arguments);
|
|
2307
|
+
this.handlers = [
|
|
2308
|
+
new CustomAttributeAnnotationHandler(),
|
|
2309
|
+
new CustomClassAnnotationHandler(),
|
|
2310
|
+
new CustomStyleAnnotationHandler(),
|
|
2311
|
+
];
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Can be handle.
|
|
2315
|
+
*
|
|
2316
|
+
* @param {RTEDtoClassPrototype} targetDto - Target DTO.
|
|
2317
|
+
* @returns {boolean} - .
|
|
2318
|
+
*/
|
|
2319
|
+
canHandle(targetDto) {
|
|
2320
|
+
return targetDto.name === 'RTETextNode';
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Handle annotation.
|
|
2324
|
+
*
|
|
2325
|
+
* @param {HTMLElement} element - Current elements.
|
|
2326
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
2327
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
2328
|
+
*/
|
|
2329
|
+
handle(element, parentAnnotations = {}) {
|
|
2330
|
+
if (parentAnnotations.link)
|
|
2331
|
+
return { link: parentAnnotations.link };
|
|
2332
|
+
return Predicate.isLinkElement(element) ? { link: this.generateLinkAnnotations(element) } : {};
|
|
2333
|
+
}
|
|
2334
|
+
/**
|
|
2335
|
+
* Generate link annotations.
|
|
2336
|
+
*
|
|
2337
|
+
* @param {HTMLElement} element - Current elements.
|
|
2338
|
+
* @returns {VegaRTELink} - link annotations.
|
|
2339
|
+
*/
|
|
2340
|
+
generateLinkAnnotations(element) {
|
|
2341
|
+
const annotations = {
|
|
2342
|
+
href: element.getAttribute('href') || '',
|
|
2343
|
+
groupKey: misc.generateUUID(),
|
|
2344
|
+
};
|
|
2345
|
+
this.handlers.forEach((handler) => {
|
|
2346
|
+
Object.assign(annotations, handler.handle(element));
|
|
2347
|
+
});
|
|
2348
|
+
return annotations;
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
/** Handle strike through annotation */
|
|
2353
|
+
class StrikeThroughAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2354
|
+
/**
|
|
2355
|
+
* @inheritDoc
|
|
2356
|
+
*/
|
|
2357
|
+
canHandle(targetDto) {
|
|
2358
|
+
return targetDto.name === 'RTETextNode';
|
|
2359
|
+
}
|
|
2360
|
+
/**
|
|
2361
|
+
* Handle annotation.
|
|
2362
|
+
*
|
|
2363
|
+
* @param {HTMLElement} element - Current elements.
|
|
2364
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
2365
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
2366
|
+
*/
|
|
2367
|
+
handle(element, parentAnnotations = {}) {
|
|
2368
|
+
return this.isStrikethrough(element) || parentAnnotations.strikethrough
|
|
2369
|
+
? { strikethrough: true }
|
|
2370
|
+
: {};
|
|
2371
|
+
}
|
|
2372
|
+
/**
|
|
2373
|
+
* Is strikethrough element.
|
|
2374
|
+
*
|
|
2375
|
+
* @param {HTMLElement} element - current element.
|
|
2376
|
+
* @returns {boolean} - boolean.
|
|
2377
|
+
*/
|
|
2378
|
+
isStrikethrough(element) {
|
|
2379
|
+
return (element.style.textDecoration.includes(codeBlock.STRIKETHROUGH_TEXT_DECORATION) ||
|
|
2380
|
+
element.nodeName === 'S' ||
|
|
2381
|
+
element.nodeName === 'DEL' ||
|
|
2382
|
+
element.classList.contains('v-rte--strikethrough'));
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
/** Handle underline annotation */
|
|
2387
|
+
class UnderlineAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2388
|
+
/**
|
|
2389
|
+
* @inheritDoc
|
|
2390
|
+
*/
|
|
2391
|
+
canHandle(targetDto) {
|
|
2392
|
+
return targetDto.name === 'RTETextNode';
|
|
2393
|
+
}
|
|
2394
|
+
/**
|
|
2395
|
+
* Handle annotation.
|
|
2396
|
+
*
|
|
2397
|
+
* @param {HTMLElement} element - Current elements.
|
|
2398
|
+
* @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
|
|
2399
|
+
* @returns {VegaRTETextAnnotations} - Annotation.
|
|
2400
|
+
*/
|
|
2401
|
+
handle(element, parentAnnotations = {}) {
|
|
2402
|
+
return this.isUnderline(element) || parentAnnotations.underline ? { underline: true } : {};
|
|
2403
|
+
}
|
|
2404
|
+
/**
|
|
2405
|
+
* Is underline element.
|
|
2406
|
+
*
|
|
2407
|
+
* @param {HTMLElement} element - current element.
|
|
2408
|
+
* @returns {boolean} - boolean.
|
|
2409
|
+
*/
|
|
2410
|
+
isUnderline(element) {
|
|
2411
|
+
return (element.style.textDecoration.includes(codeBlock.UNDERLINE_TEXT_DECORATION) ||
|
|
2412
|
+
element.nodeName === 'U' ||
|
|
2413
|
+
element.nodeName === 'INS' ||
|
|
2414
|
+
element.classList.contains('v-rte--underline'));
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
/** Handle image size annotation */
|
|
2419
|
+
class ImageSizeAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2420
|
+
/**
|
|
2421
|
+
* @inheritDoc
|
|
2422
|
+
*/
|
|
2423
|
+
canHandle(targetDto) {
|
|
2424
|
+
return targetDto.name === 'RTEImageNode';
|
|
2425
|
+
}
|
|
2426
|
+
/**
|
|
2427
|
+
* Handle annotation.
|
|
2428
|
+
*
|
|
2429
|
+
* @param {HTMLElement} element - Current elements.
|
|
2430
|
+
* @returns {VegaRTEImageAnnotations} - Annotation.
|
|
2431
|
+
*/
|
|
2432
|
+
handle(element) {
|
|
2433
|
+
const size = this.getImageSize(element);
|
|
2434
|
+
return size ? { size: size } : {};
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* Determine the image display size based on the width of the current element.
|
|
2438
|
+
*
|
|
2439
|
+
* @param {HTMLElement} element - current element.
|
|
2440
|
+
* @returns {Nullable<VegaRichTextImageEditorSizeType>} -Image size, default 'md'.
|
|
2441
|
+
*/
|
|
2442
|
+
getImageSize(element) {
|
|
2443
|
+
if (element.getAttribute('data-size')) {
|
|
2444
|
+
return element.getAttribute('data-size');
|
|
2445
|
+
}
|
|
2446
|
+
return null;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/** Handle image alt annotation */
|
|
2451
|
+
class ImageAltAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2452
|
+
/**
|
|
2453
|
+
* @inheritDoc
|
|
2454
|
+
*/
|
|
2455
|
+
canHandle(targetDto) {
|
|
2456
|
+
return targetDto.name === 'RTEImageNode';
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Handle annotation.
|
|
2460
|
+
*
|
|
2461
|
+
* @param {HTMLElement} element - Current elements.
|
|
2462
|
+
* @returns {VegaRTEImageAnnotations} - Annotation.
|
|
2463
|
+
*/
|
|
2464
|
+
handle(element) {
|
|
2465
|
+
return element.hasAttribute('alt') ? { alt: element.getAttribute('alt') } : {};
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* Tags whose direct children are always phrasing (inline) content (P, H1-H6, LI).
|
|
2471
|
+
*
|
|
2472
|
+
* This is spec knowledge from the HTML Living Standard — these grouping-content
|
|
2473
|
+
* elements have a phrasing-content content model and cannot contain block-level
|
|
2474
|
+
* descendants. It cannot be derived from the strategy registry and must be
|
|
2475
|
+
* maintained alongside the HTML spec.
|
|
2476
|
+
*
|
|
2477
|
+
* @see https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
|
|
2478
|
+
*/
|
|
2479
|
+
const BLOCK_TEXT_CONTAINER_TAGS = new Set([
|
|
2480
|
+
'P',
|
|
2481
|
+
'H1',
|
|
2482
|
+
'H2',
|
|
2483
|
+
'H3',
|
|
2484
|
+
'H4',
|
|
2485
|
+
'H5',
|
|
2486
|
+
'H6',
|
|
2487
|
+
'LI',
|
|
2488
|
+
]);
|
|
2489
|
+
/**
|
|
2490
|
+
* Tags with dedicated element-to-DTO block strategies
|
|
2491
|
+
* (P, H1-H6, LI, UL, OL, IMG, CODE).
|
|
2492
|
+
*
|
|
2493
|
+
* HtmlBlockStrategy skips these to avoid double-processing or overriding their
|
|
2494
|
+
* specialized block semantics.
|
|
2495
|
+
*
|
|
2496
|
+
* Why hard-coded: strategies use heterogeneous matching (`tagName ===`,
|
|
2497
|
+
* `matchTextBlockType` via font-size/class, etc.) so there is no single
|
|
2498
|
+
* declarative contract to derive this set from. It must be kept in sync with
|
|
2499
|
+
* the strategies registered in `dto/setup.ts`.
|
|
2500
|
+
*
|
|
2501
|
+
* Intentionally independent of {@link BLOCK_TEXT_CONTAINER_TAGS} — the two
|
|
2502
|
+
* sets encode different concepts (app architecture vs. HTML spec) and must
|
|
2503
|
+
* be maintained separately.
|
|
2504
|
+
*/
|
|
2505
|
+
const DEDICATED_STRATEGY_TAGS = new Set([
|
|
2506
|
+
'P',
|
|
2507
|
+
'H1',
|
|
2508
|
+
'H2',
|
|
2509
|
+
'H3',
|
|
2510
|
+
'H4',
|
|
2511
|
+
'H5',
|
|
2512
|
+
'H6',
|
|
2513
|
+
'LI',
|
|
2514
|
+
'UL',
|
|
2515
|
+
'OL',
|
|
2516
|
+
'IMG',
|
|
2517
|
+
'CODE',
|
|
2518
|
+
]);
|
|
2519
|
+
/**
|
|
2520
|
+
* Tags that are always treated as phrasing (inline) content, even when they
|
|
2521
|
+
* also appear in {@link DEDICATED_STRATEGY_TAGS} (CODE).
|
|
2522
|
+
* A tag in this set overrides the dedicated-strategy skip in HtmlBlockStrategy.
|
|
2523
|
+
*
|
|
2524
|
+
* Mix of HTML5 spec phrasing-content elements (BR, CODE, A) and
|
|
2525
|
+
* RTE-internal custom elements (VEGA-RICH-TEXT-LINK-EDITOR).
|
|
2526
|
+
*/
|
|
2527
|
+
const ALWAYS_INLINE_TAGS = new Set(['BR', 'VEGA-RICH-TEXT-LINK-EDITOR', 'CODE', 'A']);
|
|
2528
|
+
/**
|
|
2529
|
+
* Tags whose content model requires each child to be a distinct block-level
|
|
2530
|
+
* element (table model and definition list).
|
|
2531
|
+
*
|
|
2532
|
+
* TABLE expects CAPTION/THEAD/TBODY/TFOOT/TR; TR expects TH/TD;
|
|
2533
|
+
* THEAD/TBODY/TFOOT expect TR; DL expects DT/DD.
|
|
2534
|
+
*
|
|
2535
|
+
* Used by HtmlBlockStrategy to prevent text-only children (e.g. CAPTION,
|
|
2536
|
+
* TH, TD) from being treated as inline — they must become html-blocks so
|
|
2537
|
+
* the table structure round-trips correctly.
|
|
2538
|
+
*
|
|
2539
|
+
* Note: COLGROUP is intentionally excluded. Its only permitted child is the
|
|
2540
|
+
* void element COL, which can never produce text-node children, so the
|
|
2541
|
+
* text-only heuristic in HtmlBlockStrategy can never fire for a COLGROUP
|
|
2542
|
+
* parent.
|
|
2543
|
+
*
|
|
2544
|
+
* @see https://html.spec.whatwg.org/multipage/tables.html#the-table-element
|
|
2545
|
+
* @see https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-element
|
|
2546
|
+
*/
|
|
2547
|
+
const STRUCTURED_CONTAINER_TAGS = new Set([
|
|
2548
|
+
'TABLE',
|
|
2549
|
+
'THEAD',
|
|
2550
|
+
'TBODY',
|
|
2551
|
+
'TFOOT',
|
|
2552
|
+
'TR',
|
|
2553
|
+
'DL',
|
|
2554
|
+
]);
|
|
2555
|
+
/**
|
|
2556
|
+
* Formatting phrasing-content elements that CAN remain inline even when empty.
|
|
2557
|
+
*
|
|
2558
|
+
* Any element NOT in this set (DIV, SECTION, ARTICLE, custom elements, etc.)
|
|
2559
|
+
* is treated as a block separator. Phrasing content is a closed, finite set
|
|
2560
|
+
* per the HTML Living Standard, making an allowlist safer than blocklisting
|
|
2561
|
+
* block containers (which is open-ended — custom elements default to block).
|
|
2562
|
+
*
|
|
2563
|
+
* Intentionally excludes:
|
|
2564
|
+
* - BR, CODE, A, VEGA-RICH-TEXT-LINK-EDITOR → handled by {@link ALWAYS_INLINE_TAGS}
|
|
2565
|
+
* - P, H1-H6, LI, UL, OL, IMG → handled by {@link DEDICATED_STRATEGY_TAGS}
|
|
2566
|
+
* - VIDEO, AUDIO, EMBED → embedded content that carries media even when empty;
|
|
2567
|
+
* must be treated as block-level, not as inline formatting artifacts
|
|
2568
|
+
*
|
|
2569
|
+
* @see https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
|
|
2570
|
+
*/
|
|
2571
|
+
const PHRASING_CONTENT_TAGS = new Set([
|
|
2572
|
+
'ABBR',
|
|
2573
|
+
'B',
|
|
2574
|
+
'BDI',
|
|
2575
|
+
'BDO',
|
|
2576
|
+
'CITE',
|
|
2577
|
+
'DEL',
|
|
2578
|
+
'DFN',
|
|
2579
|
+
'EM',
|
|
2580
|
+
'I',
|
|
2581
|
+
'INS',
|
|
2582
|
+
'KBD',
|
|
2583
|
+
'MARK',
|
|
2584
|
+
'METER',
|
|
2585
|
+
'OUTPUT',
|
|
2586
|
+
'PROGRESS',
|
|
2587
|
+
'Q',
|
|
2588
|
+
'S',
|
|
2589
|
+
'SAMP',
|
|
2590
|
+
'SMALL',
|
|
2591
|
+
'SPAN',
|
|
2592
|
+
'STRONG',
|
|
2593
|
+
'SUB',
|
|
2594
|
+
'SUP',
|
|
2595
|
+
'TIME',
|
|
2596
|
+
'U',
|
|
2597
|
+
'VAR',
|
|
2598
|
+
]);
|
|
2599
|
+
/**
|
|
2600
|
+
* Returns true when the element is a direct child of a block text container
|
|
2601
|
+
* (P, H1-H6, LI), meaning it must be treated as phrasing content regardless
|
|
2602
|
+
* of its own DOM structure.
|
|
2603
|
+
*
|
|
2604
|
+
* @param {HTMLElement} element - Element to test.
|
|
2605
|
+
* @returns {boolean} True if the element is inside a block text container.
|
|
2606
|
+
*/
|
|
2607
|
+
function isInBlockTextContext(element) {
|
|
2608
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2609
|
+
return BLOCK_TEXT_CONTAINER_TAGS.has(element.parentElement.nodeName);
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
/**
|
|
2613
|
+
* Handle inline html annotation
|
|
2614
|
+
*/
|
|
2615
|
+
class InlineHtmlAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
|
|
2616
|
+
constructor() {
|
|
2617
|
+
super(...arguments);
|
|
2618
|
+
this.customAttributeHandler = new CustomAttributeAnnotationHandler();
|
|
2619
|
+
this.customStyleAnnotationHandler = new CustomStyleAnnotationHandler();
|
|
2620
|
+
this.customClassAnnotationHandler = new CustomClassAnnotationHandler();
|
|
2621
|
+
}
|
|
2622
|
+
/**
|
|
2623
|
+
* @inheritDoc
|
|
2624
|
+
*/
|
|
2625
|
+
canHandle(targetDto, options) {
|
|
2626
|
+
return targetDto.name === 'RTETextNode' && options.autoMatchFormat === false;
|
|
2627
|
+
}
|
|
2628
|
+
/**
|
|
2629
|
+
* @inheritDoc
|
|
2630
|
+
*/
|
|
2631
|
+
handle(element, parentAnnotations) {
|
|
2632
|
+
// Skip block-level dedicated tags (P, H1-H6, LI, UL, OL, IMG).
|
|
2633
|
+
// Tags in ALWAYS_INLINE_TAGS (CODE, A) are exempt and still produce inlineHtml annotations.
|
|
2634
|
+
if (DEDICATED_STRATEGY_TAGS.has(element.nodeName) && !ALWAYS_INLINE_TAGS.has(element.nodeName)) {
|
|
2635
|
+
return {};
|
|
2636
|
+
}
|
|
2637
|
+
const inlineHtml = this.generateInlineHtmlAnnotation(element, Object.assign({}, parentAnnotations));
|
|
2638
|
+
if (inlineHtml) {
|
|
2639
|
+
return { inlineHtml: inlineHtml };
|
|
2640
|
+
}
|
|
2641
|
+
return {};
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Generate inline html annotation.
|
|
2645
|
+
*
|
|
2646
|
+
* @param {HTMLElement} child - Current element.
|
|
2647
|
+
* @param {VegaRTETextAnnotations} annotations - Current annotations.
|
|
2648
|
+
* @returns {Nullable<VegaInlineHtmlSchema>} - Inline html annotation.
|
|
2649
|
+
*/
|
|
2650
|
+
generateInlineHtmlAnnotation(child, annotations) {
|
|
2651
|
+
let { inlineHtml } = annotations;
|
|
2652
|
+
const hasElementChildren = Array.from(child.childNodes).some((c) => c.nodeType === Node.ELEMENT_NODE);
|
|
2653
|
+
if (!codeBlock.RTETextNode.supportsHtmlTag(child.nodeName.toLowerCase()) || hasElementChildren) {
|
|
2654
|
+
const childInlineHtmlNode = Object.assign(Object.assign({ htmlTag: child.nodeName.toLowerCase() }, (hasElementChildren ? { groupId: misc.generateUUID() } : {})), { customAttribute: this.customAttributeHandler.handle(child).customAttribute, customStyle: this.customStyleAnnotationHandler.handle(child).customStyle, customClass: this.customClassAnnotationHandler.handle(child).customClass });
|
|
2655
|
+
if (!inlineHtml) {
|
|
2656
|
+
inlineHtml = childInlineHtmlNode;
|
|
2657
|
+
}
|
|
2658
|
+
else {
|
|
2659
|
+
inlineHtml = this.appendToInlineHtmlChain(inlineHtml, childInlineHtmlNode, child.parentNode);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
return inlineHtml ? Object.assign({}, inlineHtml) : null;
|
|
2663
|
+
}
|
|
2664
|
+
/**
|
|
2665
|
+
* Immutably appends `toAppend` at the correct position in the chain — the
|
|
2666
|
+
* deepest node whose `child.htmlTag` still matches `parentNode.nodeName`.
|
|
2667
|
+
* Each level is reconstructed via spread so the original chain is never mutated.
|
|
2668
|
+
*
|
|
2669
|
+
* @param {VegaInlineHtmlSchema} node - Current chain node.
|
|
2670
|
+
* @param {VegaInlineHtmlSchema} toAppend - Node to append at the tail.
|
|
2671
|
+
* @param {ParentNode | null} parentNode - DOM parent of the element being processed.
|
|
2672
|
+
* @returns {VegaInlineHtmlSchema} A new chain with `toAppend` inserted.
|
|
2673
|
+
*/
|
|
2674
|
+
appendToInlineHtmlChain(node, toAppend, parentNode) {
|
|
2675
|
+
if (node.child && parentNode && node.child.htmlTag === parentNode.nodeName.toLowerCase()) {
|
|
2676
|
+
return Object.assign(Object.assign({}, node), { child: this.appendToInlineHtmlChain(node.child, toAppend, parentNode) });
|
|
2677
|
+
}
|
|
2678
|
+
return Object.assign(Object.assign({}, node), { child: toAppend });
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
/** Html element to annotations generator */
|
|
2683
|
+
class HtmlElementToAnnotationGenerator {
|
|
2684
|
+
constructor() {
|
|
2685
|
+
this.handlers = [
|
|
2686
|
+
new TextAlignAnnotationHandler(),
|
|
2687
|
+
new IndentAnnotationHandler(),
|
|
2688
|
+
new BoldAnnotationHandler(),
|
|
2689
|
+
new ItalicAnnotationHandler(),
|
|
2690
|
+
new UnderlineAnnotationHandler(),
|
|
2691
|
+
new StrikeThroughAnnotationHandler(),
|
|
2692
|
+
new ColorAnnotationHandler(),
|
|
2693
|
+
new LinkAnnotationHandler(),
|
|
2694
|
+
new CodeAnnotationHandler(),
|
|
2695
|
+
new ImageSizeAnnotationHandler(),
|
|
2696
|
+
new ImageAltAnnotationHandler(),
|
|
2697
|
+
new CustomAttributeAnnotationHandler(),
|
|
2698
|
+
new CustomClassAnnotationHandler(),
|
|
2699
|
+
new CustomStyleAnnotationHandler(),
|
|
2700
|
+
new TextStyleAnnotationHandler(),
|
|
2701
|
+
new InlineHtmlAnnotationHandler(),
|
|
2702
|
+
];
|
|
2703
|
+
}
|
|
2704
|
+
/**
|
|
2705
|
+
* Register a custom annotation handler.
|
|
2706
|
+
* Custom handlers are added to the beginning of the handlers array,
|
|
2707
|
+
* giving them higher priority than default handlers.
|
|
2708
|
+
*
|
|
2709
|
+
* @param {AnnotationGeneratorStrategyAbstract} handler - The annotation handler to register.
|
|
2710
|
+
*/
|
|
2711
|
+
registerHandler(handler) {
|
|
2712
|
+
this.handlers.unshift(handler);
|
|
2713
|
+
}
|
|
2714
|
+
/**
|
|
2715
|
+
* The function generates annotations for a given target DTO and HTML element based on a set of
|
|
2716
|
+
* strategies.
|
|
2717
|
+
*
|
|
2718
|
+
* @typedef T class name of target DTO
|
|
2719
|
+
* @typedef V generated annotations type
|
|
2720
|
+
* @param {T} targetDto - Which DTO is the generated annotations to set.
|
|
2721
|
+
* @param {HTMLElement} element - Current html element.
|
|
2722
|
+
* @param {HtmlElementToAnnotationGenerateOptions} [options] - Options
|
|
2723
|
+
* @returns {V} Generated annotations.
|
|
2724
|
+
*/
|
|
2725
|
+
generate(targetDto, element, options = { autoMatchFormat: true }) {
|
|
2726
|
+
if (options && options.filterInlineStyles) {
|
|
2727
|
+
codeBlock.RTEFilterStylesStrategyRegistry.executeTheStrategyRefillAction(targetDto.name, element);
|
|
2728
|
+
}
|
|
2729
|
+
// Guard against <a> wrapping block content (e.g. <a><video></a>), which is processed as an
|
|
2730
|
+
// html-block (targetDto !== RTETextNode) — link-only mode should not apply in that case.
|
|
2731
|
+
const isLinkElement = Predicate.isLinkElement(element) && targetDto.name === 'RTETextNode';
|
|
2732
|
+
const annotations = this.handlers
|
|
2733
|
+
.filter((handler) => !options.autoMatchFormat && isLinkElement ? handler instanceof LinkAnnotationHandler : true)
|
|
2734
|
+
.filter((handler) => element.nodeType !== Node.TEXT_NODE &&
|
|
2735
|
+
handler.canHandle(targetDto, {
|
|
2736
|
+
skipCustomAnnotations: options.skipCustomAnnotations || isLinkElement,
|
|
2737
|
+
autoMatchFormat: options.autoMatchFormat,
|
|
2738
|
+
}))
|
|
2739
|
+
.reduce((annotations, handler) => {
|
|
2740
|
+
const result = handler.handle(element, options.parentAnnotations);
|
|
2741
|
+
return Object.assign(Object.assign({}, annotations), result);
|
|
2742
|
+
}, {});
|
|
2743
|
+
this.removeTextStyleDefaultsFromCustomStyle(annotations);
|
|
2744
|
+
const strategies = codeBlock.RTEFilterStylesStrategyRegistry.getStrategies(targetDto.name);
|
|
2745
|
+
for (const strategy of strategies) {
|
|
2746
|
+
if (options.autoMatchFormat || strategy.alwaysFilter) {
|
|
2747
|
+
strategy.filterAnnotations(annotations);
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
return annotations;
|
|
2751
|
+
}
|
|
2752
|
+
/**
|
|
2753
|
+
* Remove default text-style properties from customStyle.
|
|
2754
|
+
* This prevents repeated styling when switching between source edit and normal mode.
|
|
2755
|
+
*
|
|
2756
|
+
* Note: This method mutates the customStyle object inside `annotations` in place and returns the same reference.
|
|
2757
|
+
*
|
|
2758
|
+
* @param {V} annotations - The generated annotations.
|
|
2759
|
+
* @returns {V} The same annotations reference with customStyle cleaned up.
|
|
2760
|
+
*/
|
|
2761
|
+
removeTextStyleDefaultsFromCustomStyle(annotations) {
|
|
2762
|
+
const textStyle = 'textStyle' in annotations ? annotations.textStyle : undefined;
|
|
2763
|
+
const customStyle = annotations.customStyle;
|
|
2764
|
+
if (!textStyle || !customStyle) {
|
|
2765
|
+
return annotations;
|
|
2766
|
+
}
|
|
2767
|
+
const defaultStyles = codeBlock.TextStyleAnnotation.getDefaultStyles(textStyle);
|
|
2768
|
+
if (!defaultStyles) {
|
|
2769
|
+
return annotations;
|
|
2770
|
+
}
|
|
2771
|
+
for (const key of Object.keys(defaultStyles)) {
|
|
2772
|
+
if (customStyle[key] === defaultStyles[key]) {
|
|
2773
|
+
delete customStyle[key];
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
if (Object.keys(customStyle).length === 0) {
|
|
2777
|
+
delete annotations.customStyle;
|
|
2778
|
+
}
|
|
2779
|
+
return annotations;
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
const htmlElementToAnnotationGenerator = new HtmlElementToAnnotationGenerator();
|
|
2783
|
+
|
|
2784
|
+
/** Abstract class for block html element to RTE block dto */
|
|
2785
|
+
class BlockToRTEBlockStrategyAbstract extends ElementToDTOStrategy {
|
|
2786
|
+
constructor() {
|
|
2787
|
+
super(...arguments);
|
|
2788
|
+
this.annotationHandler = new TextStyleAnnotationHandler();
|
|
2789
|
+
}
|
|
2790
|
+
/**
|
|
2791
|
+
* Generate child nodes of block element, this will inherit all annotations from parent to text node and
|
|
2792
|
+
* flat the child nodes.
|
|
2793
|
+
*
|
|
2794
|
+
* Example:
|
|
2795
|
+
* <li>
|
|
2796
|
+
* <u><i>text1</i></u>
|
|
2797
|
+
* <span></span>
|
|
2798
|
+
* <span style='font-weight: bold;'><span>text2</span></span>
|
|
2799
|
+
* text3
|
|
2800
|
+
* </li>
|
|
2801
|
+
* will tranform to:
|
|
2802
|
+
* <li>
|
|
2803
|
+
* <span>text1</span> // with underline and italic annotations
|
|
2804
|
+
* <span></span> // empty span
|
|
2805
|
+
* <span>text2</span> // with bold annotations
|
|
2806
|
+
* <span>text3</span> // no annotations
|
|
2807
|
+
* </li>
|
|
2808
|
+
*
|
|
2809
|
+
* @param {HTMLElement[]} elements - Child elements.
|
|
2810
|
+
* @param {VegaRTETextAnnotations} annotations - Parent annotations.
|
|
2811
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
2812
|
+
* @returns {VegaRTETextNode[]} - Text node DTO.
|
|
2813
|
+
*/
|
|
2814
|
+
generateChildNodes(elements, annotations, options) {
|
|
2815
|
+
const childNodes = [];
|
|
2816
|
+
const disableAutoMatchFormat = !!(options && options.autoMatchFormat === false);
|
|
2817
|
+
const parentAnnotations = Object.assign({}, annotations);
|
|
2818
|
+
elements.forEach((child) => {
|
|
2819
|
+
const strategy = ElementToDTOClassStrategyManager.getElementToNodeStrategies().find((item) => item.canHandle([child], 0, options) > 0);
|
|
2820
|
+
let textNodeJson = null;
|
|
2821
|
+
if (strategy) {
|
|
2822
|
+
textNodeJson = strategy.handle([child], options, parentAnnotations);
|
|
2823
|
+
}
|
|
2824
|
+
if (textNodeJson) {
|
|
2825
|
+
childNodes.push(textNodeJson);
|
|
2826
|
+
}
|
|
2827
|
+
else if (ui.isHTMLElement(child) && child.childNodes.length > 0) {
|
|
2828
|
+
const curAnnotations = htmlElementToAnnotationGenerator.generate(codeBlock.RTETextNode, child, Object.assign({ parentAnnotations: disableAutoMatchFormat
|
|
2829
|
+
? {
|
|
2830
|
+
inlineHtml: parentAnnotations.inlineHtml,
|
|
2831
|
+
link: parentAnnotations.link,
|
|
2832
|
+
code: parentAnnotations.code,
|
|
2833
|
+
}
|
|
2834
|
+
: annotations }, options));
|
|
2835
|
+
childNodes.push(...this.generateChildNodes(Array.from(child.childNodes), curAnnotations, options));
|
|
2836
|
+
}
|
|
2837
|
+
});
|
|
2838
|
+
return childNodes;
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Get the node type of element. The element type is determined in the following
|
|
2842
|
+
* order: "data-type" attribute, node name, font size and class name.
|
|
2843
|
+
*
|
|
2844
|
+
* @param {HTMLElement} element - element.
|
|
2845
|
+
* @returns {VegaRTETextBlockType} - Block type.
|
|
2846
|
+
*/
|
|
2847
|
+
matchTextBlockType(element) {
|
|
2848
|
+
var _a;
|
|
2849
|
+
return (_a = this.annotationHandler.handle(element).textStyle) !== null && _a !== void 0 ? _a : 'paragraph';
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
/**
|
|
2854
|
+
* Converting HTML block elements into RTE blocks.
|
|
2855
|
+
*/
|
|
2856
|
+
class HtmlBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
2857
|
+
/**
|
|
2858
|
+
* @inheritDoc
|
|
2859
|
+
*/
|
|
2860
|
+
canHandle(elementsArray, currentIndex, options) {
|
|
2861
|
+
const element = elementsArray[currentIndex];
|
|
2862
|
+
if (element.nodeType === Node.TEXT_NODE || this.isInlineTagWithoutBlockChildren(element, options)) {
|
|
2863
|
+
return 0;
|
|
2864
|
+
}
|
|
2865
|
+
// Skip dedicated-strategy tags unless all children are block-level embedded
|
|
2866
|
+
// elements (e.g. <p><video></p>), in which case fall back to html-block.
|
|
2867
|
+
if (DEDICATED_STRATEGY_TAGS.has(element.nodeName) && !this.shouldFallBackToHtmlBlock(element)) {
|
|
2868
|
+
return 0;
|
|
2869
|
+
}
|
|
2870
|
+
return !options.autoMatchFormat &&
|
|
2871
|
+
this.isCustomHtmlContainer(element) &&
|
|
2872
|
+
!Predicate.isTitleOrSubtitle(element)
|
|
2873
|
+
? 1
|
|
2874
|
+
: 0;
|
|
2875
|
+
}
|
|
2876
|
+
/**
|
|
2877
|
+
* @inheritDoc
|
|
2878
|
+
*/
|
|
2879
|
+
handle(elementsArray, options) {
|
|
2880
|
+
const element = elementsArray[0];
|
|
2881
|
+
return RTEHtmlBlock.from(this.generateHtmlBlock(element, options), options);
|
|
2882
|
+
}
|
|
2883
|
+
/**
|
|
2884
|
+
* @inheritDoc
|
|
2885
|
+
*/
|
|
2886
|
+
appendChildBlocks(currentBlock, childBlocks) {
|
|
2887
|
+
currentBlock.children = childBlocks.map((block) => {
|
|
2888
|
+
block.parent = currentBlock;
|
|
2889
|
+
return block;
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* @inheritDoc
|
|
2894
|
+
*/
|
|
2895
|
+
shouldProceedToElementChildren() {
|
|
2896
|
+
return true;
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Returns true for elements that should be treated as inline content even if they have no element children (e.g. <span>text</span>).
|
|
2900
|
+
* This includes any element in a block text context (P, H1-H6, LI) and any element with text-node children but no element-node children.
|
|
2901
|
+
*
|
|
2902
|
+
* In raw-HTML mode (autoMatchFormat: false), the text-only heuristic only
|
|
2903
|
+
* applies to elements whose parent is itself a text-only wrapper (e.g.
|
|
2904
|
+
* {@code <div><span>Title</span></div>}). Structural children of non-text
|
|
2905
|
+
* containers (TABLE → CAPTION, TR → TH/TD, etc.) skip this heuristic so
|
|
2906
|
+
* they reach {@link isCustomHtmlContainer} and become html-blocks.
|
|
2907
|
+
*
|
|
2908
|
+
* @param {HTMLElement} element - Element to check.
|
|
2909
|
+
* @param {VegaRTETransformOptions} options - Transform options.
|
|
2910
|
+
* @returns {boolean} True if the element should be treated as inline content.
|
|
2911
|
+
*/
|
|
2912
|
+
isInlineTagWithoutBlockChildren(element, options) {
|
|
2913
|
+
if (isInBlockTextContext(element)) {
|
|
2914
|
+
// Empty elements that are not recognized inline elements should not
|
|
2915
|
+
// be forced inline — they may represent block-level embedded content
|
|
2916
|
+
// (e.g. <video src="...">, <audio>, <iframe src="...">).
|
|
2917
|
+
if (element.childNodes.length === 0 &&
|
|
2918
|
+
element.textContent === '' &&
|
|
2919
|
+
!ALWAYS_INLINE_TAGS.has(element.nodeName) &&
|
|
2920
|
+
!PHRASING_CONTENT_TAGS.has(element.nodeName)) {
|
|
2921
|
+
return false;
|
|
2922
|
+
}
|
|
2923
|
+
return true;
|
|
2924
|
+
}
|
|
2925
|
+
const childNodes = Array.from(element.childNodes);
|
|
2926
|
+
const isTextOnly = !childNodes.some((child) => child.nodeType === Node.ELEMENT_NODE) &&
|
|
2927
|
+
childNodes.some((child) => child.nodeType === Node.TEXT_NODE);
|
|
2928
|
+
if (!isTextOnly) {
|
|
2929
|
+
return false;
|
|
2930
|
+
}
|
|
2931
|
+
// In raw-HTML mode, a text-only element is inline only if:
|
|
2932
|
+
// 1. Its parent is not a structured container (TABLE, TR, …)
|
|
2933
|
+
// 2. The element itself is phrasing content (SPAN, EM, …)
|
|
2934
|
+
// Non-phrasing text-only elements (SUMMARY, FIGCAPTION, OPTION, SVG TEXT,
|
|
2935
|
+
// etc.) must fall through to become html-blocks.
|
|
2936
|
+
if (options.autoMatchFormat === false) {
|
|
2937
|
+
if (STRUCTURED_CONTAINER_TAGS.has(element.parentElement.nodeName))
|
|
2938
|
+
return false; // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
2939
|
+
return PHRASING_CONTENT_TAGS.has(element.nodeName) || ALWAYS_INLINE_TAGS.has(element.nodeName);
|
|
2940
|
+
}
|
|
2941
|
+
return true;
|
|
2942
|
+
}
|
|
2943
|
+
/**
|
|
2944
|
+
* Returns true when a dedicated-strategy element should fall back to html-block
|
|
2945
|
+
* because all its children are non-text, non-inline, non-dedicated elements
|
|
2946
|
+
* — indicating purely block-level embedded content that the dedicated text-block
|
|
2947
|
+
* strategy cannot represent.
|
|
2948
|
+
*
|
|
2949
|
+
* @param {HTMLElement} element - The dedicated-strategy element to check.
|
|
2950
|
+
* @returns {boolean} True when the element should be treated as html-block.
|
|
2951
|
+
*/
|
|
2952
|
+
shouldFallBackToHtmlBlock(element) {
|
|
2953
|
+
const childNodes = Array.from(element.childNodes);
|
|
2954
|
+
if (childNodes.length === 0)
|
|
2955
|
+
return false;
|
|
2956
|
+
// List items are structural children whose dedicated strategies manage
|
|
2957
|
+
// both block and inline children independently — never override them.
|
|
2958
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2959
|
+
const parentTag = element.parentElement.nodeName;
|
|
2960
|
+
if (parentTag === 'UL' || parentTag === 'OL')
|
|
2961
|
+
return false;
|
|
2962
|
+
return childNodes.every((child) => child.nodeType === Node.ELEMENT_NODE &&
|
|
2963
|
+
child.textContent === '' &&
|
|
2964
|
+
!ALWAYS_INLINE_TAGS.has(child.nodeName) &&
|
|
2965
|
+
!PHRASING_CONTENT_TAGS.has(child.nodeName));
|
|
2966
|
+
}
|
|
2967
|
+
/**
|
|
2968
|
+
* Returns true for elements that should be treated as html containers.
|
|
2969
|
+
* A DIV is only a valid container when its first child is not an IMG
|
|
2970
|
+
* (IMG children are handled by the image strategy instead).
|
|
2971
|
+
*
|
|
2972
|
+
* @param {HTMLElement} element - Element to check.
|
|
2973
|
+
* @returns {boolean} True if the element qualifies as a html container.
|
|
2974
|
+
*/
|
|
2975
|
+
isCustomHtmlContainer(element) {
|
|
2976
|
+
if (element.nodeName !== 'DIV') {
|
|
2977
|
+
return true;
|
|
2978
|
+
}
|
|
2979
|
+
return element.childNodes.length > 0 && element.childNodes[0].nodeName !== 'IMG';
|
|
2980
|
+
}
|
|
2981
|
+
/**
|
|
2982
|
+
* Generate HTML block DTO from an HTML element.
|
|
2983
|
+
*
|
|
2984
|
+
* @param {HTMLElement} element - HTML element to convert.
|
|
2985
|
+
* @param {VegaRTETransformOptions} options - Options for transformation.
|
|
2986
|
+
* @returns {VegaRTEHtmlBlock} - HTML block DTO.
|
|
2987
|
+
*/
|
|
2988
|
+
generateHtmlBlock(element, options) {
|
|
2989
|
+
return {
|
|
2990
|
+
id: misc.generateUUID(),
|
|
2991
|
+
type: 'html-block',
|
|
2992
|
+
htmlTag: element.nodeName.toLowerCase(),
|
|
2993
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEHtmlBlock, element, options),
|
|
2994
|
+
children: [],
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
/** Transform ul element to list block DTO */
|
|
3000
|
+
class UlToRTEListBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3001
|
+
/**
|
|
3002
|
+
* Can be handle.
|
|
3003
|
+
*
|
|
3004
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3005
|
+
* @param {number} currentIndex - Current element index.
|
|
3006
|
+
* @returns {number} - can be handled element count.
|
|
3007
|
+
*/
|
|
3008
|
+
canHandle(elementsArray, currentIndex) {
|
|
3009
|
+
return elementsArray[currentIndex].tagName === 'UL' ? 1 : 0;
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Parse to a block.
|
|
3013
|
+
*
|
|
3014
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3015
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3016
|
+
* @returns {Nullable<RTEContentBlock>} - Bullet list block.
|
|
3017
|
+
*/
|
|
3018
|
+
handle(elementsArray, options) {
|
|
3019
|
+
if (elementsArray[0].childNodes.length === 0)
|
|
3020
|
+
return null;
|
|
3021
|
+
return RTEListBlock.from({
|
|
3022
|
+
id: misc.generateUUID(),
|
|
3023
|
+
type: 'bullet-list',
|
|
3024
|
+
blocks: [],
|
|
3025
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEListBlock, elementsArray[0], options),
|
|
3026
|
+
}, options);
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Append child list item blocks to current list block.
|
|
3030
|
+
*
|
|
3031
|
+
* @param {RTEListBlock} currentBlock - Current list block.
|
|
3032
|
+
* @param {RTEContentBlock[]} childBlocks - Current list item blocks.
|
|
3033
|
+
*/
|
|
3034
|
+
appendChildBlocks(currentBlock, childBlocks) {
|
|
3035
|
+
currentBlock.children = childBlocks.filter((block) => block instanceof RTEListItemBlock);
|
|
3036
|
+
childBlocks.forEach((block) => (block.parent = currentBlock));
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* Should continue process to child elements.
|
|
3040
|
+
*
|
|
3041
|
+
* @returns {boolean} - boolean.
|
|
3042
|
+
*/
|
|
3043
|
+
shouldProceedToElementChildren() {
|
|
3044
|
+
return true;
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
/** Transform ol element to list block DTO */
|
|
3049
|
+
class OlToRTEListBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3050
|
+
/**
|
|
3051
|
+
* Can be handle.
|
|
3052
|
+
*
|
|
3053
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3054
|
+
* @param {number} currentIndex - Current element index.
|
|
3055
|
+
* @returns {number} - can be handled element count.
|
|
3056
|
+
*/
|
|
3057
|
+
canHandle(elementsArray, currentIndex) {
|
|
3058
|
+
return elementsArray[currentIndex].tagName === 'OL' ? 1 : 0;
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Parse to a number list block.
|
|
3062
|
+
*
|
|
3063
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3064
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3065
|
+
* @returns {Nullable<RTEContentBlock>} - Number list block.
|
|
3066
|
+
*/
|
|
3067
|
+
handle(elementsArray, options) {
|
|
3068
|
+
if (elementsArray[0].childNodes.length === 0)
|
|
3069
|
+
return null;
|
|
3070
|
+
return RTEListBlock.from({
|
|
3071
|
+
id: misc.generateUUID(),
|
|
3072
|
+
type: 'number-list',
|
|
3073
|
+
blocks: [],
|
|
3074
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEListBlock, elementsArray[0], options),
|
|
3075
|
+
}, options);
|
|
3076
|
+
}
|
|
3077
|
+
/**
|
|
3078
|
+
* Append child list item blocks to current list block.
|
|
3079
|
+
*
|
|
3080
|
+
* @param {RTEListBlock} currentBlock - Current list block.
|
|
3081
|
+
* @param {RTEContentBlock[]} childBlocks - Current list item blocks.
|
|
3082
|
+
*/
|
|
3083
|
+
appendChildBlocks(currentBlock, childBlocks) {
|
|
3084
|
+
currentBlock.children = childBlocks.filter((block) => block instanceof RTEListItemBlock);
|
|
3085
|
+
childBlocks.forEach((block) => (block.parent = currentBlock));
|
|
3086
|
+
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Should continue process to child elements.
|
|
3089
|
+
*
|
|
3090
|
+
* @returns {boolean} - boolean.
|
|
3091
|
+
*/
|
|
3092
|
+
shouldProceedToElementChildren() {
|
|
3093
|
+
return true;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
/** Transform child element of UL element which are not LI element to list item block DTO */
|
|
3098
|
+
class ULNotLiChildToRTEListItemBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3099
|
+
/**
|
|
3100
|
+
* Can be handle.
|
|
3101
|
+
*
|
|
3102
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3103
|
+
* @param {number} currentIndex - Current element index.
|
|
3104
|
+
* @returns {number} - can be handled element count.
|
|
3105
|
+
*/
|
|
3106
|
+
canHandle(elementsArray, currentIndex) {
|
|
3107
|
+
const element = elementsArray[currentIndex];
|
|
3108
|
+
const parent = element.parentElement;
|
|
3109
|
+
const isLiNode = element.nodeName !== 'LI';
|
|
3110
|
+
// while child is empty text node like newline or empty string, we should not covert it.
|
|
3111
|
+
const isEmptyNode = element.nodeType === Node.TEXT_NODE && element.textContent.trim() === '';
|
|
3112
|
+
// The node must be in list item.
|
|
3113
|
+
const isInList = typeGuard.isNonNullable(parent) && ['UL', 'OL'].includes(parent.nodeName);
|
|
3114
|
+
return isLiNode && !isEmptyNode && isInList ? 1 : 0;
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Parse to a list item block.
|
|
3118
|
+
*
|
|
3119
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3120
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3121
|
+
* @returns {Nullable<RTEContentBlock>} - List item block.
|
|
3122
|
+
*/
|
|
3123
|
+
handle(elementsArray, options) {
|
|
3124
|
+
const nodes = this.generateChildNodes(elementsArray, {}, options);
|
|
3125
|
+
return RTEListItemBlock.from({
|
|
3126
|
+
id: misc.generateUUID(),
|
|
3127
|
+
type: 'list-item',
|
|
3128
|
+
nodes: nodes,
|
|
3129
|
+
annotations: {},
|
|
3130
|
+
}, options);
|
|
3131
|
+
}
|
|
3132
|
+
/* istanbul ignore next */
|
|
3133
|
+
/**
|
|
3134
|
+
* Append child blocks.
|
|
3135
|
+
*/
|
|
3136
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3137
|
+
appendChildBlocks() { }
|
|
3138
|
+
/**
|
|
3139
|
+
* Should continue process to child elements.
|
|
3140
|
+
*
|
|
3141
|
+
* @returns {boolean} - boolean.
|
|
3142
|
+
*/
|
|
3143
|
+
shouldProceedToElementChildren() {
|
|
3144
|
+
return false;
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
/** Transform li element to list item block DTO */
|
|
3149
|
+
class LiToRTEListItemBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3150
|
+
/**
|
|
3151
|
+
* Can be handled.
|
|
3152
|
+
*
|
|
3153
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3154
|
+
* @param {number} currentIndex - Current element index.
|
|
3155
|
+
* @returns {number} - can be handled element count.
|
|
3156
|
+
*/
|
|
3157
|
+
canHandle(elementsArray, currentIndex) {
|
|
3158
|
+
const parent = elementsArray[currentIndex].parentElement;
|
|
3159
|
+
if (!['UL', 'OL'].includes(parent.nodeName) &&
|
|
3160
|
+
elementsArray.some((element) => element.nodeName === 'LI')) {
|
|
3161
|
+
let count = 0;
|
|
3162
|
+
for (let i = currentIndex; i < elementsArray.length; i++) {
|
|
3163
|
+
if (elementsArray[i].nodeName === 'LI') {
|
|
3164
|
+
count++;
|
|
3165
|
+
}
|
|
3166
|
+
else {
|
|
3167
|
+
break;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
return count;
|
|
3171
|
+
}
|
|
3172
|
+
return elementsArray[currentIndex].tagName === 'LI' ? 1 : 0;
|
|
3173
|
+
}
|
|
3174
|
+
/**
|
|
3175
|
+
* Parse to a list item block.
|
|
3176
|
+
*
|
|
3177
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3178
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3179
|
+
* @returns {Nullable<RTEContentBlock>} - List item block.
|
|
3180
|
+
*/
|
|
3181
|
+
handle(elementsArray, options) {
|
|
3182
|
+
const firstElement = elementsArray[0];
|
|
3183
|
+
const parent = firstElement.parentElement;
|
|
3184
|
+
if (!['UL', 'OL'].includes(parent.nodeName)) {
|
|
3185
|
+
return this.generateWithListBlock(elementsArray, options);
|
|
3186
|
+
}
|
|
3187
|
+
return RTEListItemBlock.from(this.generateListItemBlockDTO(firstElement, options), options);
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Append child list blocks to current list item block.
|
|
3191
|
+
*
|
|
3192
|
+
* @param {RTEListBlock} currentBlock - Current list item block.
|
|
3193
|
+
* @param {RTEListItemBlock[]} childBlocks - Current list blocks.
|
|
3194
|
+
*/
|
|
3195
|
+
appendChildBlocks(currentBlock, childBlocks) {
|
|
3196
|
+
currentBlock.nestList = childBlocks.filter((block) => ['bullet-list', 'number-list'].includes(block.type));
|
|
3197
|
+
}
|
|
3198
|
+
/**
|
|
3199
|
+
* Should continue process to child elements.
|
|
3200
|
+
*
|
|
3201
|
+
* @returns {boolean} - boolean.
|
|
3202
|
+
*/
|
|
3203
|
+
shouldProceedToElementChildren() {
|
|
3204
|
+
return true;
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Generate list block from a list of HTML elements.
|
|
3208
|
+
*
|
|
3209
|
+
* @param {HTMLElement[]} elements - List of HTML elements to convert.
|
|
3210
|
+
* @param {VegaRTETransformOptions} options - Options for transformation.
|
|
3211
|
+
* @returns {RTEListBlock} - List block DTO.
|
|
3212
|
+
*/
|
|
3213
|
+
generateWithListBlock(elements, options) {
|
|
3214
|
+
return RTEListBlock.from({
|
|
3215
|
+
id: misc.generateUUID(),
|
|
3216
|
+
type: 'bullet-list',
|
|
3217
|
+
blocks: elements.map((item) => {
|
|
3218
|
+
return this.generateListItemBlockDTO(item, options);
|
|
3219
|
+
}),
|
|
3220
|
+
}, options);
|
|
3221
|
+
}
|
|
3222
|
+
/**
|
|
3223
|
+
* Generate list item block DTO from an HTML element.
|
|
3224
|
+
*
|
|
3225
|
+
* @param {HTMLElement} element - HTML element to convert.
|
|
3226
|
+
* @param {VegaRTETransformOptions} options - Options for transformation.
|
|
3227
|
+
* @returns {VegaRTEListItemBlock} - List item block DTO.
|
|
3228
|
+
*/
|
|
3229
|
+
generateListItemBlockDTO(element, options) {
|
|
3230
|
+
return {
|
|
3231
|
+
id: misc.generateUUID(),
|
|
3232
|
+
type: 'list-item',
|
|
3233
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEListItemBlock, element, options),
|
|
3234
|
+
nodes: this.generateChildNodes(Array.from(element.childNodes.length ? element.childNodes : [element]).filter((item) => {
|
|
3235
|
+
return !['UL', 'OL'].includes(item.nodeName);
|
|
3236
|
+
}), htmlElementToAnnotationGenerator.generate(codeBlock.RTETextNode, element, Object.assign(Object.assign({}, options), { skipCustomAnnotations: true })), options),
|
|
3237
|
+
};
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
/** Transform other editor code element which has attribute data-language to RTE code block DTO */
|
|
3242
|
+
class JiraCodeToRTECodeBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3243
|
+
/**
|
|
3244
|
+
* Can be handle.
|
|
3245
|
+
*
|
|
3246
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3247
|
+
* @param {number} currentIndex - Current element index.
|
|
3248
|
+
* @returns {number} - can be handled element count.
|
|
3249
|
+
*/
|
|
3250
|
+
canHandle(elementsArray, currentIndex) {
|
|
3251
|
+
return (elementsArray[currentIndex].tagName === 'PRE' ||
|
|
3252
|
+
elementsArray[currentIndex].tagName === 'CODE') &&
|
|
3253
|
+
elementsArray[currentIndex].hasAttribute('data-language')
|
|
3254
|
+
? 1
|
|
3255
|
+
: 0;
|
|
3256
|
+
}
|
|
3257
|
+
/**
|
|
3258
|
+
* Parse to a code block.
|
|
3259
|
+
*
|
|
3260
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3261
|
+
* @returns {Nullable<RTECodeBlock>} - Code block.
|
|
3262
|
+
*/
|
|
3263
|
+
handle(elementsArray) {
|
|
3264
|
+
const codeRef = elementsArray[0];
|
|
3265
|
+
if (codeRef) {
|
|
3266
|
+
const content = codeRef.textContent;
|
|
3267
|
+
const language = codeRef.dataset
|
|
3268
|
+
.language;
|
|
3269
|
+
return codeBlock.RTECodeBlock.from({
|
|
3270
|
+
id: misc.generateUUID(),
|
|
3271
|
+
type: 'code-block',
|
|
3272
|
+
content,
|
|
3273
|
+
language,
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
/* istanbul ignore next */
|
|
3278
|
+
/**
|
|
3279
|
+
* Append child blocks.
|
|
3280
|
+
*/
|
|
3281
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3282
|
+
appendChildBlocks() { }
|
|
3283
|
+
/**
|
|
3284
|
+
* Should continue process to child elements.
|
|
3285
|
+
*
|
|
3286
|
+
* @returns {boolean} - boolean.
|
|
3287
|
+
*/
|
|
3288
|
+
shouldProceedToElementChildren() {
|
|
3289
|
+
return false;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
/** Transform vega-code-block element to code block DTO */
|
|
3294
|
+
class VegaCodeBlockToRTECodeBlockStrategy extends JiraCodeToRTECodeBlockStrategy {
|
|
3295
|
+
/**
|
|
3296
|
+
* Can be handle.
|
|
3297
|
+
*
|
|
3298
|
+
* TODO: Update the browser clipboard data to fix the issue with nested vega-code-block elements.
|
|
3299
|
+
* In safari the html snippet will be like: <vega-code-block><p><span>paragraph</span></p><vega-code-block></vega-code-block></vega-code-block>
|
|
3300
|
+
* The vega-code-block nested inside the vega-code-block, so we need to check the child element.
|
|
3301
|
+
*
|
|
3302
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3303
|
+
* @param {number} currentIndex - Current element index.
|
|
3304
|
+
* @returns {number} - can be handled element count.
|
|
3305
|
+
*/
|
|
3306
|
+
canHandle(elementsArray, currentIndex) {
|
|
3307
|
+
return (elementsArray[currentIndex].tagName === 'VEGA-CODE-BLOCK' &&
|
|
3308
|
+
!!elementsArray[currentIndex].querySelector('vega-code-block') === false) ||
|
|
3309
|
+
this.isCodeBlockContainer(elementsArray[currentIndex])
|
|
3310
|
+
? 1
|
|
3311
|
+
: 0;
|
|
3312
|
+
}
|
|
3313
|
+
/**
|
|
3314
|
+
* Parse to a code block.
|
|
3315
|
+
*
|
|
3316
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3317
|
+
* @returns {Nullable<RTECodeBlock>} - Code block.
|
|
3318
|
+
*/
|
|
3319
|
+
handle(elementsArray) {
|
|
3320
|
+
const codeBlockElement = this.isCodeBlockContainer(elementsArray[0])
|
|
3321
|
+
? elementsArray[0].querySelector('vega-code-block')
|
|
3322
|
+
: elementsArray[0];
|
|
3323
|
+
const code = codeBlockElement.querySelector('code');
|
|
3324
|
+
if (code) {
|
|
3325
|
+
return super.handle([code]); // Call the parent method to handle the code element
|
|
3326
|
+
}
|
|
3327
|
+
else if (codeBlockElement.hasAttribute('data-content')) {
|
|
3328
|
+
// The code element in shadow dom could be empty in firefox.
|
|
3329
|
+
// eslint-disable-next-line no-restricted-globals
|
|
3330
|
+
const code = document.createElement('code');
|
|
3331
|
+
code.textContent = codeBlockElement.dataset.content;
|
|
3332
|
+
code.dataset.language = codeBlockElement.dataset.language;
|
|
3333
|
+
return super.handle([code]); // Call the parent method to handle the code element
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
/* istanbul ignore next */
|
|
3337
|
+
/**
|
|
3338
|
+
* Append child blocks.
|
|
3339
|
+
*/
|
|
3340
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3341
|
+
appendChildBlocks() { }
|
|
3342
|
+
/**
|
|
3343
|
+
* Should continue process to child elements.
|
|
3344
|
+
*
|
|
3345
|
+
* @returns {boolean} - boolean.
|
|
3346
|
+
*/
|
|
3347
|
+
shouldProceedToElementChildren() {
|
|
3348
|
+
return false;
|
|
3349
|
+
}
|
|
3350
|
+
/**
|
|
3351
|
+
* Checks if the given element is a code block container.
|
|
3352
|
+
*
|
|
3353
|
+
* @param {HTMLElement} element - The element to check.
|
|
3354
|
+
* @returns {boolean} - Boolean result.
|
|
3355
|
+
*/
|
|
3356
|
+
isCodeBlockContainer(element) {
|
|
3357
|
+
return (element.tagName === 'PRE' &&
|
|
3358
|
+
element.classList.contains('code-block-container') &&
|
|
3359
|
+
element.querySelectorAll('vega-code-block').length === 1);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
/** Transform inline block element to text block DTO */
|
|
3364
|
+
class InlineBlockToRTETextBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3365
|
+
/**
|
|
3366
|
+
* Can be handle.
|
|
3367
|
+
*
|
|
3368
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3369
|
+
* @param {number} currentIndex - Current element index.
|
|
3370
|
+
* @returns {number} - can be handled element count.
|
|
3371
|
+
*/
|
|
3372
|
+
canHandle(elementsArray, currentIndex) {
|
|
3373
|
+
return [
|
|
3374
|
+
'heading-1',
|
|
3375
|
+
'heading-2',
|
|
3376
|
+
'heading-3',
|
|
3377
|
+
'heading-4',
|
|
3378
|
+
'heading-5',
|
|
3379
|
+
'heading-6',
|
|
3380
|
+
'title',
|
|
3381
|
+
'subtitle',
|
|
3382
|
+
].includes(super.matchTextBlockType(elementsArray[currentIndex]))
|
|
3383
|
+
? 1
|
|
3384
|
+
: 0;
|
|
3385
|
+
}
|
|
3386
|
+
/**
|
|
3387
|
+
* Parse to a text block.
|
|
3388
|
+
*
|
|
3389
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3390
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3391
|
+
* @returns {Nullable<RTEContentBlock>} - Text block.
|
|
3392
|
+
*/
|
|
3393
|
+
handle(elementsArray, options) {
|
|
3394
|
+
const nodes = this.generateChildNodes(Array.from(elementsArray[0].childNodes), {}, options);
|
|
3395
|
+
if (nodes.length === 0)
|
|
3396
|
+
return null;
|
|
3397
|
+
return codeBlock.RTETextBlock.from({
|
|
3398
|
+
id: misc.generateUUID(),
|
|
3399
|
+
type: super.matchTextBlockType(elementsArray[0]),
|
|
3400
|
+
nodes: nodes,
|
|
3401
|
+
annotations: htmlElementToAnnotationGenerator.generate(codeBlock.RTETextBlock, elementsArray[0], options),
|
|
3402
|
+
}, options);
|
|
3403
|
+
}
|
|
3404
|
+
/* istanbul ignore next */
|
|
3405
|
+
/**
|
|
3406
|
+
* Append child blocks.
|
|
3407
|
+
*/
|
|
3408
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3409
|
+
appendChildBlocks() { }
|
|
3410
|
+
/**
|
|
3411
|
+
* Should continue process to child elements.
|
|
3412
|
+
*
|
|
3413
|
+
* @returns {boolean} - boolean.
|
|
3414
|
+
*/
|
|
3415
|
+
shouldProceedToElementChildren() {
|
|
3416
|
+
return false;
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
/** Abstract class for block html element to RTE block dto */
|
|
3421
|
+
class ElementToRTEImageBlockStrategyAbstract extends BlockToRTEBlockStrategyAbstract {
|
|
3422
|
+
/**
|
|
3423
|
+
* Create a RTE Image block according to the img element.
|
|
3424
|
+
*
|
|
3425
|
+
* @param {HTMLElement} element - current element.
|
|
3426
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3427
|
+
* @returns {RTEImageBlock} -RTE Image block.
|
|
3428
|
+
*/
|
|
3429
|
+
createRTEImageBlock(element, options) {
|
|
3430
|
+
// RTEImageBlock is also wrapped by a div, should not as internal wrapper if the parent is a div.
|
|
3431
|
+
const isInternalWrapper = !(options && options.autoMatchFormat) &&
|
|
3432
|
+
!!(element.parentNode && element.parentNode.nodeName !== 'DIV');
|
|
3433
|
+
return RTEImageBlock.from({
|
|
3434
|
+
id: misc.generateUUID(),
|
|
3435
|
+
type: 'image',
|
|
3436
|
+
nodes: [
|
|
3437
|
+
{
|
|
3438
|
+
id: misc.generateUUID(),
|
|
3439
|
+
type: 'image',
|
|
3440
|
+
url: element.src,
|
|
3441
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEImageNode, element, options),
|
|
3442
|
+
},
|
|
3443
|
+
],
|
|
3444
|
+
annotations: Object.assign(Object.assign({}, htmlElementToAnnotationGenerator.generate(RTEImageBlock, element.parentElement, options)), { internalWrapper: isInternalWrapper }),
|
|
3445
|
+
}, options);
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
/** Transform img element to image block DTO */
|
|
3450
|
+
class ImgToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
|
|
3451
|
+
/**
|
|
3452
|
+
* Can be handle.
|
|
3453
|
+
*
|
|
3454
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3455
|
+
* @param {number} currentIndex - Current element index.
|
|
3456
|
+
* @returns {number} - can be handled element count.
|
|
3457
|
+
*/
|
|
3458
|
+
canHandle(elementsArray, currentIndex) {
|
|
3459
|
+
return elementsArray[currentIndex].tagName === 'IMG' ? 1 : 0;
|
|
3460
|
+
}
|
|
3461
|
+
/**
|
|
3462
|
+
* Parse to a image block.
|
|
3463
|
+
*
|
|
3464
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3465
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3466
|
+
* @returns {Nullable<RTEContentBlock>} - Image block.
|
|
3467
|
+
*/
|
|
3468
|
+
handle(elementsArray, options) {
|
|
3469
|
+
const element = elementsArray[0];
|
|
3470
|
+
return this.createRTEImageBlock(element, options);
|
|
3471
|
+
}
|
|
3472
|
+
/* istanbul ignore next */
|
|
3473
|
+
/**
|
|
3474
|
+
* Append child blocks.
|
|
3475
|
+
*/
|
|
3476
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3477
|
+
appendChildBlocks() { }
|
|
3478
|
+
/**
|
|
3479
|
+
* Should continue process to child elements.
|
|
3480
|
+
*
|
|
3481
|
+
* @returns {boolean} - boolean.
|
|
3482
|
+
*/
|
|
3483
|
+
shouldProceedToElementChildren() {
|
|
3484
|
+
return false;
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3488
|
+
/** Transform vega-rich-text-image-editor element to image block DTO */
|
|
3489
|
+
class VegaImageToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
|
|
3490
|
+
/**
|
|
3491
|
+
* Can be handle.
|
|
3492
|
+
*
|
|
3493
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3494
|
+
* @param {number} currentIndex - Current element index.
|
|
3495
|
+
* @returns {number} - can be handled element count.
|
|
3496
|
+
*/
|
|
3497
|
+
canHandle(elementsArray, currentIndex) {
|
|
3498
|
+
return elementsArray[currentIndex].tagName === 'VEGA-RICH-TEXT-IMAGE-EDITOR' ? 1 : 0;
|
|
3499
|
+
}
|
|
3500
|
+
/**
|
|
3501
|
+
* Parse to a image block.
|
|
3502
|
+
*
|
|
3503
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3504
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3505
|
+
* @returns {Nullable<RTEContentBlock>} - Image block.
|
|
3506
|
+
*/
|
|
3507
|
+
handle(elementsArray, options) {
|
|
3508
|
+
const element = elementsArray[0];
|
|
3509
|
+
const image = element.querySelector('img');
|
|
3510
|
+
if (typeGuard.isNonNullable(image)) {
|
|
3511
|
+
return RTEImageBlock.from({
|
|
3512
|
+
id: misc.generateUUID(),
|
|
3513
|
+
type: 'image',
|
|
3514
|
+
nodes: [
|
|
3515
|
+
{
|
|
3516
|
+
id: misc.generateUUID(),
|
|
3517
|
+
type: 'image',
|
|
3518
|
+
url: image.src,
|
|
3519
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEImageNode, element, options),
|
|
3520
|
+
},
|
|
3521
|
+
],
|
|
3522
|
+
annotations: htmlElementToAnnotationGenerator.generate(RTEImageBlock, element.parentElement, options),
|
|
3523
|
+
}, options);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
/* istanbul ignore next */
|
|
3527
|
+
/**
|
|
3528
|
+
* Append child blocks.
|
|
3529
|
+
*/
|
|
3530
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3531
|
+
appendChildBlocks() { }
|
|
3532
|
+
/**
|
|
3533
|
+
* Should continue process to child elements.
|
|
3534
|
+
*
|
|
3535
|
+
* @returns {boolean} - boolean.
|
|
3536
|
+
*/
|
|
3537
|
+
shouldProceedToElementChildren() {
|
|
3538
|
+
return false;
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
/** Transform img in span or other inline element to image block DTO */
|
|
3543
|
+
class SpanImageToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
|
|
3544
|
+
/**
|
|
3545
|
+
* Can be handle.
|
|
3546
|
+
*
|
|
3547
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3548
|
+
* @param {number} currentIndex - Current element index.
|
|
3549
|
+
* @returns {number} - can be handled element count.
|
|
3550
|
+
*/
|
|
3551
|
+
canHandle(elementsArray, currentIndex) {
|
|
3552
|
+
const element = elementsArray[currentIndex];
|
|
3553
|
+
return element.nodeType === Node.ELEMENT_NODE &&
|
|
3554
|
+
element.textContent === '' &&
|
|
3555
|
+
element.querySelector('img')
|
|
3556
|
+
? 1
|
|
3557
|
+
: 0;
|
|
3558
|
+
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Parse to a image block.
|
|
3561
|
+
*
|
|
3562
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3563
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3564
|
+
* @returns {Nullable<RTEContentBlock>} - Image block.
|
|
3565
|
+
*/
|
|
3566
|
+
handle(elementsArray, options) {
|
|
3567
|
+
const element = elementsArray[0].querySelector('img');
|
|
3568
|
+
return this.createRTEImageBlock(element, options);
|
|
3569
|
+
}
|
|
3570
|
+
/* istanbul ignore next */
|
|
3571
|
+
/**
|
|
3572
|
+
* Append child blocks.
|
|
3573
|
+
*/
|
|
3574
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3575
|
+
appendChildBlocks() { }
|
|
3576
|
+
/**
|
|
3577
|
+
* Should continue process to child elements.
|
|
3578
|
+
*
|
|
3579
|
+
* @returns {boolean} - boolean.
|
|
3580
|
+
*/
|
|
3581
|
+
shouldProceedToElementChildren() {
|
|
3582
|
+
return false;
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
/** Transform continue inline block elements to text block DTO */
|
|
3587
|
+
class ContinueInlineToRTETextBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3588
|
+
/**
|
|
3589
|
+
* @inheritDoc
|
|
3590
|
+
*/
|
|
3591
|
+
canHandle(elementsArray, currentIndex, options) {
|
|
3592
|
+
let count = 0;
|
|
3593
|
+
for (let i = currentIndex; i < elementsArray.length; i++) {
|
|
3594
|
+
const element = elementsArray[i];
|
|
3595
|
+
if (this.isInlineCandidate(element, options)) {
|
|
3596
|
+
count++;
|
|
3597
|
+
}
|
|
3598
|
+
else {
|
|
3599
|
+
break;
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
return count;
|
|
3603
|
+
}
|
|
3604
|
+
/**
|
|
3605
|
+
* Parse to a text block.
|
|
3606
|
+
*
|
|
3607
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3608
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3609
|
+
* @returns {Nullable<RTEContentBlock>} - Text block.
|
|
3610
|
+
*/
|
|
3611
|
+
handle(elementsArray, options) {
|
|
3612
|
+
const parent = elementsArray[0].parentElement;
|
|
3613
|
+
const autoMatchFormat = options && options.autoMatchFormat;
|
|
3614
|
+
const nodes = this.generateChildNodes(elementsArray, autoMatchFormat
|
|
3615
|
+
? htmlElementToAnnotationGenerator.generate(codeBlock.RTETextNode, parent, Object.assign(Object.assign({}, options), { skipCustomAnnotations: true }))
|
|
3616
|
+
: {}, options);
|
|
3617
|
+
const blockType = autoMatchFormat
|
|
3618
|
+
? super.matchTextBlockType(parent)
|
|
3619
|
+
: this.matchTextBlockTypeByTagName(parent);
|
|
3620
|
+
const internalWrapper = !autoMatchFormat && !blockType;
|
|
3621
|
+
return codeBlock.RTETextBlock.from(Object.assign({ id: misc.generateUUID(), type: blockType || 'paragraph', nodes: nodes }, (internalWrapper
|
|
3622
|
+
? { annotations: { internalWrapper: internalWrapper } }
|
|
3623
|
+
: {
|
|
3624
|
+
annotations: htmlElementToAnnotationGenerator.generate(codeBlock.RTETextBlock, parent, options),
|
|
3625
|
+
})), options);
|
|
3626
|
+
}
|
|
3627
|
+
/* istanbul ignore next */
|
|
3628
|
+
/**
|
|
3629
|
+
* Append child blocks.
|
|
3630
|
+
*/
|
|
3631
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3632
|
+
appendChildBlocks() { }
|
|
3633
|
+
/**
|
|
3634
|
+
* Should continue process to child elements.
|
|
3635
|
+
*
|
|
3636
|
+
* @returns {boolean} - boolean.
|
|
3637
|
+
*/
|
|
3638
|
+
shouldProceedToElementChildren() {
|
|
3639
|
+
return false;
|
|
3640
|
+
}
|
|
3641
|
+
/**
|
|
3642
|
+
* Match the block type by tag name.
|
|
3643
|
+
*
|
|
3644
|
+
* @param {HTMLElement} element - Target element.
|
|
3645
|
+
* @returns {Nullable<VegaRTETextBlockType>} - Block type.
|
|
3646
|
+
*/
|
|
3647
|
+
matchTextBlockTypeByTagName(element) {
|
|
3648
|
+
switch (element.nodeName) {
|
|
3649
|
+
case 'P':
|
|
3650
|
+
return 'paragraph';
|
|
3651
|
+
default:
|
|
3652
|
+
return null;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
/**
|
|
3656
|
+
* Check if the element is an inline candidate to be included in the text block.
|
|
3657
|
+
*
|
|
3658
|
+
* @param {HTMLElement} element - The element to check.
|
|
3659
|
+
* @param {VegaRTETransformOptions} [options] - Options for transformation.
|
|
3660
|
+
* @returns {boolean} - Whether the element is an inline candidate.
|
|
3661
|
+
*/
|
|
3662
|
+
isInlineCandidate(element, options) {
|
|
3663
|
+
if (element.nodeType === Node.TEXT_NODE)
|
|
3664
|
+
return true;
|
|
3665
|
+
if (ALWAYS_INLINE_TAGS.has(element.nodeName))
|
|
3666
|
+
return true;
|
|
3667
|
+
if (this.isDedicatedBlockTag(element.nodeName))
|
|
3668
|
+
return false;
|
|
3669
|
+
if (options.autoMatchFormat === false && isInBlockTextContext(element))
|
|
3670
|
+
return true;
|
|
3671
|
+
return this.isInlineLeafOrWrapper(element);
|
|
3672
|
+
}
|
|
3673
|
+
/**
|
|
3674
|
+
* Returns true when the tag has a dedicated block strategy (excludes inline annotation tags CODE and A).
|
|
3675
|
+
*
|
|
3676
|
+
* @param {string} nodeName - The node name to check.
|
|
3677
|
+
* @returns {boolean} - Whether the tag is a dedicated block tag.
|
|
3678
|
+
*/
|
|
3679
|
+
isDedicatedBlockTag(nodeName) {
|
|
3680
|
+
return DEDICATED_STRATEGY_TAGS.has(nodeName) && !ALWAYS_INLINE_TAGS.has(nodeName);
|
|
3681
|
+
}
|
|
3682
|
+
/**
|
|
3683
|
+
* Returns true for empty elements, text-only elements, or elements whose entire
|
|
3684
|
+
* descendant tree contains no block-level elements (e.g. {@code <u><i><b>text</b></i></u>}).
|
|
3685
|
+
*
|
|
3686
|
+
* @param {HTMLElement} element - The element to check.
|
|
3687
|
+
* @returns {boolean} - Whether the element is an inline leaf or wrapper.
|
|
3688
|
+
*/
|
|
3689
|
+
isInlineLeafOrWrapper(element) {
|
|
3690
|
+
if (element.childNodes.length === 0) {
|
|
3691
|
+
// An empty element is inline only if it is a known HTML phrasing-content
|
|
3692
|
+
// element (SPAN, EM, STRONG, …). Block containers (DIV, SECTION, …)
|
|
3693
|
+
// and unknown/custom elements default to block separators.
|
|
3694
|
+
return PHRASING_CONTENT_TAGS.has(element.nodeName);
|
|
3695
|
+
}
|
|
3696
|
+
if (this.isTextOnlyElement(element)) {
|
|
3697
|
+
return PHRASING_CONTENT_TAGS.has(element.nodeName) || ALWAYS_INLINE_TAGS.has(element.nodeName);
|
|
3698
|
+
}
|
|
3699
|
+
return this.hasOnlyInlineDescendants(element);
|
|
3700
|
+
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Returns true when the element has text-node children but no element children.
|
|
3703
|
+
*
|
|
3704
|
+
* @param {HTMLElement} element - The element to check.
|
|
3705
|
+
* @returns {boolean} - Whether the element contains only text nodes.
|
|
3706
|
+
*/
|
|
3707
|
+
isTextOnlyElement(element) {
|
|
3708
|
+
const childNodes = Array.from(element.childNodes);
|
|
3709
|
+
return (!childNodes.some((child) => child.nodeType === Node.ELEMENT_NODE) &&
|
|
3710
|
+
childNodes.some((child) => child.nodeType === Node.TEXT_NODE));
|
|
3711
|
+
}
|
|
3712
|
+
/**
|
|
3713
|
+
* Returns true if the element's subtree contains only inline formatting wrappers.
|
|
3714
|
+
* Instead of maintaining a hard coded tag allowlist, the check derives from:
|
|
3715
|
+
* 1. {@link DEDICATED_STRATEGY_TAGS} — rejects known block/media tags
|
|
3716
|
+
* 2. Void-element check — elements with no child nodes (INPUT, COL, HR, …)
|
|
3717
|
+
* are replaced/embedded content, not formatting wrappers
|
|
3718
|
+
*
|
|
3719
|
+
* @param {HTMLElement} element - Element to inspect.
|
|
3720
|
+
* @returns {boolean} True if the element has no block-level descendants.
|
|
3721
|
+
*/
|
|
3722
|
+
hasOnlyInlineDescendants(element) {
|
|
3723
|
+
for (let i = 0; i < element.children.length; i++) {
|
|
3724
|
+
const child = element.children[i];
|
|
3725
|
+
if (this.isDedicatedBlockTag(child.nodeName))
|
|
3726
|
+
return false;
|
|
3727
|
+
// An empty element is not a formatting wrapper — it is likely a void/embedded
|
|
3728
|
+
// element (INPUT, HR, COL, empty SPAN) that acts as a block separator.
|
|
3729
|
+
if (!child.hasChildNodes())
|
|
3730
|
+
return false;
|
|
3731
|
+
if (!this.hasOnlyInlineDescendants(child))
|
|
3732
|
+
return false;
|
|
3733
|
+
}
|
|
3734
|
+
return true;
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
/**
|
|
3739
|
+
* Class to handle text node elements and convert them to text node DTOs
|
|
3740
|
+
*/
|
|
3741
|
+
class ElementToTextNodeStrategy extends ElementToDTOStrategy {
|
|
3742
|
+
/**
|
|
3743
|
+
* @inheritDoc
|
|
3744
|
+
*/
|
|
3745
|
+
shouldProceedToElementChildren() {
|
|
3746
|
+
return false;
|
|
3747
|
+
}
|
|
3748
|
+
/**
|
|
3749
|
+
* @inheritDoc
|
|
3750
|
+
*/
|
|
3751
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3752
|
+
appendChildBlocks() { }
|
|
3753
|
+
/**
|
|
3754
|
+
* Generate text node DTO object
|
|
3755
|
+
*
|
|
3756
|
+
* @param {string} text - text content.
|
|
3757
|
+
* @param {VegaRTETextAnnotations} annotations - Current annotations.
|
|
3758
|
+
* @returns {VegaRTETextNode} - Text node DTO.
|
|
3759
|
+
*/
|
|
3760
|
+
generateTextNode(text, annotations) {
|
|
3761
|
+
return {
|
|
3762
|
+
id: misc.generateUUID(),
|
|
3763
|
+
type: 'text',
|
|
3764
|
+
text: text,
|
|
3765
|
+
annotations: annotations,
|
|
3766
|
+
};
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
/**
|
|
3771
|
+
* Class to handle plain text nodes and convert them to RTE text node DTOs
|
|
3772
|
+
*/
|
|
3773
|
+
class PlainTextToTextNodeStrategy extends ElementToTextNodeStrategy {
|
|
3774
|
+
/**
|
|
3775
|
+
* @inheritDoc
|
|
3776
|
+
*/
|
|
3777
|
+
canHandle(elementsArray, currentIndex) {
|
|
3778
|
+
const element = elementsArray[currentIndex];
|
|
3779
|
+
return element.nodeType === Node.TEXT_NODE ? 1 : 0;
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* @inheritDoc
|
|
3783
|
+
*/
|
|
3784
|
+
handle(elementsArray, options, parentTextAnnotations) {
|
|
3785
|
+
const parentAnnotations = Object.assign({}, parentTextAnnotations);
|
|
3786
|
+
const disableAutoMatchFormat = !!(options && options.autoMatchFormat === false);
|
|
3787
|
+
const child = elementsArray[0];
|
|
3788
|
+
const parentNodeName = child.parentNode.nodeName.toLowerCase();
|
|
3789
|
+
const plainText = disableAutoMatchFormat && !codeBlock.RTETextNode.supportsHtmlTag(parentNodeName);
|
|
3790
|
+
const textNode = this.generateTextNode(String(child.textContent), disableAutoMatchFormat
|
|
3791
|
+
? object.cleanObject(Object.assign(Object.assign({}, (parentNodeName === 'span'
|
|
3792
|
+
? parentAnnotations
|
|
3793
|
+
: {
|
|
3794
|
+
// text node could be wrapped in <a> tag, so we need to keep the parent link annotation
|
|
3795
|
+
link: parentAnnotations.link,
|
|
3796
|
+
code: parentNodeName === 'code' ? parentAnnotations.code : undefined,
|
|
3797
|
+
})), { inlineHtml: parentAnnotations.inlineHtml, plainText: plainText || undefined }))
|
|
3798
|
+
: parentAnnotations);
|
|
3799
|
+
return Object.assign({}, textNode);
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
/**
|
|
3804
|
+
* Class to handle inline html element to text node dto
|
|
3805
|
+
*/
|
|
3806
|
+
class InlineElementToTextNodeStrategy extends ElementToTextNodeStrategy {
|
|
3807
|
+
/**
|
|
3808
|
+
* @inheritDoc
|
|
3809
|
+
*/
|
|
3810
|
+
canHandle(elementsArray, currentIndex) {
|
|
3811
|
+
const element = elementsArray[currentIndex];
|
|
3812
|
+
return ui.isHTMLElement(element) && (element.nodeName === 'BR' || element.childNodes.length === 0)
|
|
3813
|
+
? 1
|
|
3814
|
+
: 0;
|
|
3815
|
+
}
|
|
3816
|
+
/**
|
|
3817
|
+
* @inheritDoc
|
|
3818
|
+
*/
|
|
3819
|
+
handle(elementsArray, options, annotations) {
|
|
3820
|
+
const disableAutoMatchFormat = !!(options && options.autoMatchFormat === false);
|
|
3821
|
+
const parentAnnotations = Object.assign({}, annotations);
|
|
3822
|
+
const child = elementsArray[0];
|
|
3823
|
+
const curAnnotations = htmlElementToAnnotationGenerator.generate(codeBlock.RTETextNode, child, Object.assign({ parentAnnotations: disableAutoMatchFormat
|
|
3824
|
+
? {
|
|
3825
|
+
inlineHtml: parentAnnotations.inlineHtml,
|
|
3826
|
+
link: parentAnnotations.link,
|
|
3827
|
+
code: parentAnnotations.code,
|
|
3828
|
+
}
|
|
3829
|
+
: annotations }, options));
|
|
3830
|
+
if (child.nodeName === 'BR') {
|
|
3831
|
+
return this.generateTextNode('\n', curAnnotations);
|
|
3832
|
+
}
|
|
3833
|
+
else if (child.childNodes.length === 0) {
|
|
3834
|
+
// For empty dom, there will be no internal iteration, we need to handle it directly here.
|
|
3835
|
+
// Example: <span></span>, <video src='...'></video>
|
|
3836
|
+
const emptyNodeAnnotations = disableAutoMatchFormat
|
|
3837
|
+
? object.cleanObject(Object.assign(Object.assign({}, (codeBlock.RTETextNode.supportsHtmlTag(child.nodeName.toLowerCase()) ? curAnnotations : {})), { inlineHtml: curAnnotations.inlineHtml }))
|
|
3838
|
+
: curAnnotations;
|
|
3839
|
+
return Object.assign({}, this.generateTextNode('', emptyNodeAnnotations));
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
|
|
3844
|
+
/**
|
|
3845
|
+
* Filter styles strategy for image node, which defines the styles to be filtered and the conditions for filtering and refilling styles for image nodes.
|
|
3846
|
+
*/
|
|
3847
|
+
class ImageFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
3848
|
+
constructor() {
|
|
3849
|
+
super(...arguments);
|
|
3850
|
+
this.stylesToBeFiltered = ImageAnnotation.getDefaultStyles();
|
|
3851
|
+
this.elementTagName = 'img';
|
|
3852
|
+
}
|
|
3853
|
+
/**
|
|
3854
|
+
* Used for the filterAnnotations method.
|
|
3855
|
+
*
|
|
3856
|
+
* @returns {boolean} Always `true` — image defaults are emitted as inline styles.
|
|
3857
|
+
*/
|
|
3858
|
+
get alwaysFilter() {
|
|
3859
|
+
return true;
|
|
3860
|
+
}
|
|
3861
|
+
/**
|
|
3862
|
+
* @inheritDoc
|
|
3863
|
+
*/
|
|
3864
|
+
canFilter(blockOrNodeInstance) {
|
|
3865
|
+
return codeBlock.Predicate.isImageNode(blockOrNodeInstance);
|
|
3866
|
+
}
|
|
3867
|
+
/**
|
|
3868
|
+
* @inheritDoc
|
|
3869
|
+
*/
|
|
3870
|
+
canRefill(_blockOrNodeClassName, element) {
|
|
3871
|
+
return element.tagName.toLowerCase() === this.elementTagName;
|
|
3872
|
+
}
|
|
3873
|
+
/**
|
|
3874
|
+
* @inheritDoc
|
|
3875
|
+
*/
|
|
3876
|
+
toCssText() {
|
|
3877
|
+
return this.buildCssTextForStyles(this.elementTagName, this.classNameToBeAdded);
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
/**
|
|
3882
|
+
* Filters the default ListAnnotation styles (paddingLeft, marginLeft) from
|
|
3883
|
+
* customStyle when parsing an RTEListBlock.
|
|
3884
|
+
*/
|
|
3885
|
+
class ListBlockFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
3886
|
+
constructor() {
|
|
3887
|
+
super(...arguments);
|
|
3888
|
+
this.stylesToBeFiltered = ListAnnotation.getDefaultStyles();
|
|
3889
|
+
this.elementTagName = 'ol,ul';
|
|
3890
|
+
}
|
|
3891
|
+
/**
|
|
3892
|
+
* @inheritDoc
|
|
3893
|
+
*/
|
|
3894
|
+
canFilter(blockOrNodeInstance) {
|
|
3895
|
+
return codeBlock.Predicate.isListBlock(blockOrNodeInstance.constructor.name);
|
|
3896
|
+
}
|
|
3897
|
+
/**
|
|
3898
|
+
* @inheritDoc
|
|
3899
|
+
*/
|
|
3900
|
+
canRefill(blockOrNodeClassName, element) {
|
|
3901
|
+
return codeBlock.Predicate.isListBlock(blockOrNodeClassName) && element.matches(this.elementTagName);
|
|
3902
|
+
}
|
|
3903
|
+
/**
|
|
3904
|
+
* @inheritDoc
|
|
3905
|
+
*/
|
|
3906
|
+
toCssText() {
|
|
3907
|
+
const selector = this.elementTagName
|
|
3908
|
+
.split(',')
|
|
3909
|
+
.map((tag) => `.${codeBlock.RTEFilterStylesStrategy.RTE_CONTENT_CONTAINER_CLASS_NAME} ${tag.trim()}`)
|
|
3910
|
+
.join(', ');
|
|
3911
|
+
return `${selector} { ${this.convertStylesMapToCssText(this.stylesToBeFiltered)} }`;
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
/**
|
|
3916
|
+
* Filters the default paragraph styles from customStyle when parsing an
|
|
3917
|
+
* RTEListItemBlock. List-item blocks implicitly use paragraph styling,
|
|
3918
|
+
* so these inline defaults are redundant and should not be persisted.
|
|
3919
|
+
*/
|
|
3920
|
+
class ListItemBlockFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
3921
|
+
constructor() {
|
|
3922
|
+
super(...arguments);
|
|
3923
|
+
this.stylesToBeFiltered = codeBlock.TextStyleAnnotation.getDefaultStyles('paragraph');
|
|
3924
|
+
this.elementTagName = 'li';
|
|
3925
|
+
this.headingOrTitleClassNamePattern = /^v-rte-(h[1-6]|title|subtitle)$/;
|
|
3926
|
+
}
|
|
3927
|
+
/**
|
|
3928
|
+
* Check the important font-size for list item block are default styles, and the block is a list item block.
|
|
3929
|
+
*
|
|
3930
|
+
* @inheritDoc
|
|
3931
|
+
*/
|
|
3932
|
+
canFilter(blockOrNodeInstance) {
|
|
3933
|
+
const styles = blockOrNodeInstance.getStyles();
|
|
3934
|
+
const isDefaultStyles = !styles.fontSize ||
|
|
3935
|
+
this.isBlockOrNodeStylesMatchFilterStyles(blockOrNodeInstance, ['fontSize', 'lineHeight']);
|
|
3936
|
+
return codeBlock.Predicate.isListItemBlock(blockOrNodeInstance.constructor.name) && isDefaultStyles;
|
|
3937
|
+
}
|
|
3938
|
+
/**
|
|
3939
|
+
* @inheritDoc
|
|
3940
|
+
*/
|
|
3941
|
+
canRefill(blockOrNodeClassName, element) {
|
|
3942
|
+
return (codeBlock.Predicate.isListItemBlock(blockOrNodeClassName) &&
|
|
3943
|
+
element.matches(this.elementTagName) &&
|
|
3944
|
+
this.isElementNotHeadingOrTitle(element));
|
|
3945
|
+
}
|
|
3946
|
+
/**
|
|
3947
|
+
* @inheritDoc
|
|
3948
|
+
*/
|
|
3949
|
+
toCssText() {
|
|
3950
|
+
return this.buildCssTextForStyles(this.elementTagName);
|
|
3951
|
+
}
|
|
3952
|
+
/**
|
|
3953
|
+
* Check the list item element does not have heading or title class names.
|
|
3954
|
+
*
|
|
3955
|
+
* @param {HTMLElement} element - The list item element to check.
|
|
3956
|
+
* @returns {boolean} - True if the element does not have heading or title class names, false otherwise.
|
|
3957
|
+
*/
|
|
3958
|
+
isElementNotHeadingOrTitle(element) {
|
|
3959
|
+
const classNames = element.className.split(' ');
|
|
3960
|
+
return !classNames.some((className) => this.headingOrTitleClassNamePattern.test(className.trim()));
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
/**
|
|
3965
|
+
* Filters redundant `textAlign` from `customStyle` when parsing blocks that carry
|
|
3966
|
+
* a semantic `textAlign` annotation (RTETextBlock, RTEListBlock, RTEListItemBlock).
|
|
3967
|
+
*
|
|
3968
|
+
* During source-to-normal round-trips the `HorizontalAlignmentAnnotation` emits
|
|
3969
|
+
* `text-align` as an inline style (standalone mode), and `CustomStyleAnnotationHandler`
|
|
3970
|
+
* captures it into `customStyle`. This strategy removes the duplicate so the
|
|
3971
|
+
* semantic annotation is the single source of truth.
|
|
3972
|
+
*/
|
|
3973
|
+
class AlignmentFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
3974
|
+
constructor() {
|
|
3975
|
+
super(...arguments);
|
|
3976
|
+
this.stylesToBeFiltered = {};
|
|
3977
|
+
}
|
|
3978
|
+
/**
|
|
3979
|
+
* @returns {boolean} Always `true` — alignment inline styles are always emitted
|
|
3980
|
+
* in standalone/source-edit mode, so the duplicate is always safe to remove.
|
|
3981
|
+
*/
|
|
3982
|
+
get alwaysFilter() {
|
|
3983
|
+
return true;
|
|
3984
|
+
}
|
|
3985
|
+
/**
|
|
3986
|
+
* Removes `textAlign` from `customStyle` when it duplicates the value returned
|
|
3987
|
+
* by `HorizontalAlignmentAnnotation.getDefaultStyles(textAlign)`.
|
|
3988
|
+
*
|
|
3989
|
+
* @param {VegaRTEAnnotations} annotations - The annotations object (mutated in place).
|
|
3990
|
+
* @returns {VegaRTEAnnotations} The same annotations reference.
|
|
3991
|
+
*/
|
|
3992
|
+
filterAnnotations(annotations) {
|
|
3993
|
+
const { textAlign, customStyle } = annotations;
|
|
3994
|
+
if (!textAlign || !customStyle) {
|
|
3995
|
+
return annotations;
|
|
3996
|
+
}
|
|
3997
|
+
this.stylesToBeFiltered = codeBlock.HorizontalAlignmentAnnotation.getDefaultStyles(textAlign);
|
|
3998
|
+
return super.filterAnnotations(annotations);
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
|
|
4002
|
+
/**
|
|
4003
|
+
* The CodeFilterStylesStrategy is responsible for filtering code styles from text nodes that are annotated as code.
|
|
4004
|
+
*/
|
|
4005
|
+
class CodeFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
4006
|
+
constructor() {
|
|
4007
|
+
super(...arguments);
|
|
4008
|
+
this.stylesToBeFiltered = codeBlock.CodeAnnotation.getDefaultStyles();
|
|
4009
|
+
this.elementTagName = 'code';
|
|
4010
|
+
}
|
|
4011
|
+
/**
|
|
4012
|
+
* Only strips code-default styles when the `code` annotation is present,
|
|
4013
|
+
* so that a user-applied `fontFamily: 'Roboto Mono'` without code is preserved.
|
|
4014
|
+
*
|
|
4015
|
+
* @param {VegaRTEAnnotations} annotations - The annotations object (mutated in place).
|
|
4016
|
+
* @returns {VegaRTEAnnotations} The same annotations reference.
|
|
4017
|
+
*/
|
|
4018
|
+
filterAnnotations(annotations) {
|
|
4019
|
+
const { code, customStyle } = annotations;
|
|
4020
|
+
if (!code || !customStyle) {
|
|
4021
|
+
return annotations;
|
|
4022
|
+
}
|
|
4023
|
+
return super.filterAnnotations(annotations);
|
|
4024
|
+
}
|
|
4025
|
+
/**
|
|
4026
|
+
* Determines whether the dto instance is a code text node.
|
|
4027
|
+
*
|
|
4028
|
+
* @param {RTEBlock | RTENode} blockOrNodeInstance - The block or node instance to check.
|
|
4029
|
+
* @returns {boolean} - True if the instance is a code text node, false otherwise.
|
|
4030
|
+
*/
|
|
4031
|
+
canFilter(blockOrNodeInstance) {
|
|
4032
|
+
return codeBlock.Predicate.isCodeNode(blockOrNodeInstance);
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* Check if the node is a text node and it is a code node.
|
|
4036
|
+
*
|
|
4037
|
+
* @param {string} blockOrNodeClassName - The class name of the block or node instance to check.
|
|
4038
|
+
* @param {HTMLElement} element - The HTML element of the node instance.
|
|
4039
|
+
* @returns {boolean} True if the node is a text node it a code element.
|
|
4040
|
+
*/
|
|
4041
|
+
canRefill(blockOrNodeClassName, element) {
|
|
4042
|
+
return codeBlock.Predicate.isTextNode(blockOrNodeClassName) && element.matches(this.elementTagName);
|
|
4043
|
+
}
|
|
4044
|
+
/**
|
|
4045
|
+
* The code style in title and heading no need to be bold in default.
|
|
4046
|
+
*
|
|
4047
|
+
* @returns {string} The CSS text string for code styles.
|
|
4048
|
+
*/
|
|
4049
|
+
toCssText() {
|
|
4050
|
+
const selector = `.${codeBlock.RTEFilterStylesStrategy.RTE_CONTENT_CONTAINER_CLASS_NAME} ${this.elementTagName}`;
|
|
4051
|
+
return `${selector} { ${this.convertStylesMapToCssText(Object.assign(Object.assign({}, this.stylesToBeFiltered), { fontWeight: '500' }))} }`;
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
/**
|
|
4056
|
+
* Filters redundant inline text formatting styles from `customStyle` when
|
|
4057
|
+
* parsing an RTETextNode. These styles are already represented by semantic
|
|
4058
|
+
* annotations and should not be persisted as custom overrides after source
|
|
4059
|
+
* edit round-trips.
|
|
4060
|
+
*/
|
|
4061
|
+
class TextFormatFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
4062
|
+
constructor() {
|
|
4063
|
+
super(...arguments);
|
|
4064
|
+
this.stylesToBeFiltered = {};
|
|
4065
|
+
}
|
|
4066
|
+
/**
|
|
4067
|
+
* @returns {boolean} Always `true` — this strategy runs regardless of `autoMatchFormat`.
|
|
4068
|
+
*/
|
|
4069
|
+
get alwaysFilter() {
|
|
4070
|
+
return true;
|
|
4071
|
+
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Filter redundant text format styles from `customStyle`.
|
|
4074
|
+
*
|
|
4075
|
+
* @param {VegaRTEAnnotations} annotations - The annotations to filter.
|
|
4076
|
+
* @returns {VegaRTEAnnotations} The same annotations reference with customStyle cleaned up.
|
|
4077
|
+
*/
|
|
4078
|
+
filterAnnotations(annotations) {
|
|
4079
|
+
const textAnnotations = annotations;
|
|
4080
|
+
const customStyle = textAnnotations.customStyle;
|
|
4081
|
+
if (!customStyle) {
|
|
4082
|
+
return annotations;
|
|
4083
|
+
}
|
|
4084
|
+
// Only delete styles that match the default values(BOLD_FONT_WEIGHT) to avoid affecting normal-source conversion.
|
|
4085
|
+
if (textAnnotations.bold && customStyle.fontWeight === codeBlock.BOLD_FONT_WEIGHT) {
|
|
4086
|
+
delete customStyle.fontWeight;
|
|
4087
|
+
}
|
|
4088
|
+
if (textAnnotations.italic && customStyle.fontStyle === codeBlock.ITALIC_FONT_STYLE) {
|
|
4089
|
+
delete customStyle.fontStyle;
|
|
4090
|
+
}
|
|
4091
|
+
const normalizedTextDecoration = this.normalizeTextDecoration(customStyle.textDecoration);
|
|
4092
|
+
if (normalizedTextDecoration &&
|
|
4093
|
+
this.shouldRemoveTextDecoration(normalizedTextDecoration, textAnnotations)) {
|
|
4094
|
+
delete customStyle.textDecoration;
|
|
4095
|
+
}
|
|
4096
|
+
if (Object.keys(customStyle).length === 0) {
|
|
4097
|
+
delete textAnnotations.customStyle;
|
|
4098
|
+
}
|
|
4099
|
+
return annotations;
|
|
4100
|
+
}
|
|
4101
|
+
/**
|
|
4102
|
+
* Normalizes a `text-decoration` CSS value to a sorted, unique token string of
|
|
4103
|
+
* toolbar-only tokens (`underline`, `line-through`). Returns `undefined` if the
|
|
4104
|
+
* value contains any non-toolbar token (e.g. `wavy`, a color).
|
|
4105
|
+
*
|
|
4106
|
+
* @param {string | undefined} value - The raw `textDecoration` CSS value.
|
|
4107
|
+
* @returns {string | undefined} Normalized token string, or `undefined` if the value cannot be safely removed.
|
|
4108
|
+
*/
|
|
4109
|
+
normalizeTextDecoration(value) {
|
|
4110
|
+
if (!value) {
|
|
4111
|
+
return undefined;
|
|
4112
|
+
}
|
|
4113
|
+
const tokens = value.trim().toLowerCase().split(/\s+/);
|
|
4114
|
+
if (tokens.some((token) => token !== codeBlock.UNDERLINE_TEXT_DECORATION && token !== codeBlock.STRIKETHROUGH_TEXT_DECORATION)) {
|
|
4115
|
+
return undefined;
|
|
4116
|
+
}
|
|
4117
|
+
return Array.from(new Set(tokens)).sort().join(' ');
|
|
4118
|
+
}
|
|
4119
|
+
/**
|
|
4120
|
+
* Determines whether the `textDecoration` custom style should be removed based on the
|
|
4121
|
+
* semantic annotations present. Removal happens only when the normalized value exactly
|
|
4122
|
+
* matches the set of `{underline, strikethrough}` annotations.
|
|
4123
|
+
*
|
|
4124
|
+
* @param {string} normalizedTextDecoration - The normalized `textDecoration` token string.
|
|
4125
|
+
* @param {VegaRTETextAnnotations} annotations - The text annotations to check against.
|
|
4126
|
+
* @returns {boolean} `true` if the `textDecoration` style is redundant and should be removed.
|
|
4127
|
+
*/
|
|
4128
|
+
shouldRemoveTextDecoration(normalizedTextDecoration, annotations) {
|
|
4129
|
+
const expectedTokens = [];
|
|
4130
|
+
if (annotations.underline) {
|
|
4131
|
+
expectedTokens.push(codeBlock.UNDERLINE_TEXT_DECORATION);
|
|
4132
|
+
}
|
|
4133
|
+
if (annotations.strikethrough) {
|
|
4134
|
+
expectedTokens.push(codeBlock.STRIKETHROUGH_TEXT_DECORATION);
|
|
4135
|
+
}
|
|
4136
|
+
if (expectedTokens.length === 0) {
|
|
4137
|
+
return false;
|
|
4138
|
+
}
|
|
4139
|
+
return normalizedTextDecoration === expectedTokens.sort().join(' ');
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
/**
|
|
4144
|
+
*
|
|
4145
|
+
*/
|
|
4146
|
+
class ParagraphFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
4147
|
+
constructor() {
|
|
4148
|
+
super(...arguments);
|
|
4149
|
+
this.stylesToBeFiltered = codeBlock.TextStyleAnnotation.getDefaultStyles('paragraph');
|
|
4150
|
+
this.type = 'paragraph';
|
|
4151
|
+
this.elementTagName = 'p';
|
|
4152
|
+
}
|
|
4153
|
+
/**
|
|
4154
|
+
* Don't run the filterAnnotations for paragraph heading, title, subtitle, list heading item, list title item, list subtitle item.
|
|
4155
|
+
* Already handle it in html-element-to-annotation-generator.ts#removeTextStyleDefaultsFromCustomStyle
|
|
4156
|
+
*
|
|
4157
|
+
* @inheritDoc
|
|
4158
|
+
*/
|
|
4159
|
+
filterAnnotations(annotations) {
|
|
4160
|
+
return annotations;
|
|
4161
|
+
}
|
|
4162
|
+
/**
|
|
4163
|
+
* Determines whether the dto instance is text block and has the same type as the strategy's configured type.
|
|
4164
|
+
*
|
|
4165
|
+
* @param {RTEBlock | RTENode} blockOrNodeInstance - The block or node instance to check.
|
|
4166
|
+
* @returns {boolean} - True if the instance is a text block with the same type as the strategy, false otherwise.
|
|
4167
|
+
*/
|
|
4168
|
+
canFilter(blockOrNodeInstance) {
|
|
4169
|
+
return (codeBlock.Predicate.isTextBlock(blockOrNodeInstance.constructor.name) &&
|
|
4170
|
+
blockOrNodeInstance.type === this.type);
|
|
4171
|
+
}
|
|
4172
|
+
/**
|
|
4173
|
+
* @inheritDoc
|
|
4174
|
+
*/
|
|
4175
|
+
canRefill(blockOrNodeClassName, element) {
|
|
4176
|
+
const selector = this.classNameToBeAdded
|
|
4177
|
+
? `.${this.classNameToBeAdded}`
|
|
4178
|
+
: this.elementTagName;
|
|
4179
|
+
return codeBlock.Predicate.isTextBlock(blockOrNodeClassName) && element.matches(selector);
|
|
4180
|
+
}
|
|
4181
|
+
/**
|
|
4182
|
+
* @inheritDoc
|
|
4183
|
+
*/
|
|
4184
|
+
toCssText() {
|
|
4185
|
+
return this.buildCssTextForStyles(this.elementTagName, this.classNameToBeAdded);
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
/**
|
|
4190
|
+
* The HeadingFilterStylesStrategy class is responsible for filtering and refilling styles for heading text blocks (h1 to h6) in the rich text editor.
|
|
4191
|
+
*/
|
|
4192
|
+
class HeadingFilterStylesStrategy extends ParagraphFilterStylesStrategy {
|
|
4193
|
+
constructor(level) {
|
|
4194
|
+
super();
|
|
4195
|
+
this.type = 'heading-1';
|
|
4196
|
+
this.elementTagName = 'h1';
|
|
4197
|
+
this.type = `heading-${level}`;
|
|
4198
|
+
this.elementTagName = `h${level}`;
|
|
4199
|
+
this.stylesToBeFiltered = codeBlock.TextStyleAnnotation.getDefaultStyles(this.type);
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
/**
|
|
4204
|
+
* The TitleFilterStylesStrategy class is responsible for filtering and refilling styles for title and subtitle text blocks in the rich text editor.
|
|
4205
|
+
*/
|
|
4206
|
+
class TitleFilterStylesStrategy extends ParagraphFilterStylesStrategy {
|
|
4207
|
+
constructor(titleType) {
|
|
4208
|
+
super();
|
|
4209
|
+
this.type = 'title';
|
|
4210
|
+
this.elementTagName = 'div';
|
|
4211
|
+
this.classNameToBeAdded = 'v-rte-title';
|
|
4212
|
+
this.type = titleType;
|
|
4213
|
+
this.classNameToBeAdded = `v-rte-${titleType}`;
|
|
4214
|
+
this.stylesToBeFiltered = codeBlock.TextStyleAnnotation.getDefaultStyles(this.type);
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
|
|
4218
|
+
/**
|
|
4219
|
+
* The TitleHeadingNodeFilterStylesStrategy is responsible for filtering styles from text nodes that are children of title and heading blocks.
|
|
4220
|
+
* In title and heading blocks, the text nodes will have a default bold style.
|
|
4221
|
+
*/
|
|
4222
|
+
class TitleHeadingNodeFilterStylesStrategy extends codeBlock.RTEFilterStylesStrategy {
|
|
4223
|
+
constructor() {
|
|
4224
|
+
super(...arguments);
|
|
4225
|
+
this.stylesToBeFiltered = TitleHeadingNodeFilterStylesStrategy.BOLD_STYLES;
|
|
4226
|
+
this.elementTagName = 'span';
|
|
4227
|
+
this.parentBlockTypes = [
|
|
4228
|
+
'heading-1',
|
|
4229
|
+
'heading-2',
|
|
4230
|
+
'heading-3',
|
|
4231
|
+
'heading-4',
|
|
4232
|
+
'heading-5',
|
|
4233
|
+
'heading-6',
|
|
4234
|
+
'title',
|
|
4235
|
+
];
|
|
4236
|
+
this.parentElementSelectors = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', '.v-rte-title'];
|
|
4237
|
+
this.toBeCheckedSelector = this.parentElementSelectors.join(',');
|
|
4238
|
+
}
|
|
4239
|
+
/**
|
|
4240
|
+
* Don't run filterAnnotations method, because already handle it in text format filter strategy.
|
|
4241
|
+
*
|
|
4242
|
+
* @inheritDoc
|
|
4243
|
+
*/
|
|
4244
|
+
filterAnnotations(annotations) {
|
|
4245
|
+
return annotations;
|
|
4246
|
+
}
|
|
4247
|
+
/**
|
|
4248
|
+
* Determines whether the dto instance is text node and its parent block is a heading or title.
|
|
4249
|
+
*
|
|
4250
|
+
* @param {RTEBlock | RTENode} blockOrNodeInstance - The block or node instance to check.
|
|
4251
|
+
* @returns {boolean} - True if the instance is a text node and its parent block is a heading or title, false otherwise.
|
|
4252
|
+
*/
|
|
4253
|
+
canFilter(blockOrNodeInstance) {
|
|
4254
|
+
return (codeBlock.Predicate.isTextNode(blockOrNodeInstance.constructor.name) &&
|
|
4255
|
+
this.parentBlockIsHeadingOrTitle(blockOrNodeInstance));
|
|
4256
|
+
}
|
|
4257
|
+
/**
|
|
4258
|
+
* Check if the node is a text node and its parent block is a heading or title.
|
|
4259
|
+
*
|
|
4260
|
+
* @param {string} blockOrNodeClassName - The class name of the block or node instance to check.
|
|
4261
|
+
* @param {HTMLElement} element - The HTML element of the node instance.
|
|
4262
|
+
* @returns {boolean} True if the node is a text node and its parent block is a heading or title, false otherwise.
|
|
4263
|
+
*/
|
|
4264
|
+
canRefill(blockOrNodeClassName, element) {
|
|
4265
|
+
return (codeBlock.Predicate.isTextNode(blockOrNodeClassName) &&
|
|
4266
|
+
element.nodeName === 'SPAN' &&
|
|
4267
|
+
this.isHeadingOrTitleChild(element));
|
|
4268
|
+
}
|
|
4269
|
+
/**
|
|
4270
|
+
* @inheritDoc
|
|
4271
|
+
*/
|
|
4272
|
+
toCssText() {
|
|
4273
|
+
const selectors = this.parentElementSelectors.map((key) => `.${TitleHeadingNodeFilterStylesStrategy.RTE_CONTENT_CONTAINER_CLASS_NAME} ${key}`);
|
|
4274
|
+
return `${selectors.join(',')} { ${this.convertStylesMapToCssText()} }`;
|
|
4275
|
+
}
|
|
4276
|
+
/**
|
|
4277
|
+
* Checks if the parent block of the given node instance is a heading or title.
|
|
4278
|
+
*
|
|
4279
|
+
* @param {RTENode | RTEBlock} blockOrNodeInstance - The node instance to check.
|
|
4280
|
+
* @returns {boolean} True if the parent block is a heading or title, false otherwise.
|
|
4281
|
+
*/
|
|
4282
|
+
parentBlockIsHeadingOrTitle(blockOrNodeInstance) {
|
|
4283
|
+
const parentBlock = blockOrNodeInstance.parent;
|
|
4284
|
+
return parentBlock ? this.parentBlockTypes.includes(parentBlock.type) : false;
|
|
4285
|
+
}
|
|
4286
|
+
/**
|
|
4287
|
+
* Check if the element is a descendant of a heading or title element.
|
|
4288
|
+
* Traverses upward through the DOM, stopping at the block element or body element
|
|
4289
|
+
* to avoid unbounded traversal to the document root.
|
|
4290
|
+
*
|
|
4291
|
+
* <h1><span>bold text</span></h1>
|
|
4292
|
+
* <h1><a><span>link text</span></a></h1>
|
|
4293
|
+
* <h1><a><b><span>nested text</span></b></a></h1>
|
|
4294
|
+
*
|
|
4295
|
+
* @param {HTMLElement} element - The element to check.
|
|
4296
|
+
* @returns {boolean} True if the element is a descendant of a heading or title, false otherwise.
|
|
4297
|
+
*/
|
|
4298
|
+
isHeadingOrTitleChild(element) {
|
|
4299
|
+
let current = element.parentElement;
|
|
4300
|
+
while (current) {
|
|
4301
|
+
if (current.matches(this.toBeCheckedSelector))
|
|
4302
|
+
return true;
|
|
4303
|
+
// Stop traversing upward if we reach a block element to prevent unbounded traversal to the document root. The title children will always be wrapped in a div, so we can safely stop at div as well.
|
|
4304
|
+
if (TitleHeadingNodeFilterStylesStrategy.NON_HEADING_TITLE_ELEMENT_TAGS.includes(current.tagName))
|
|
4305
|
+
return false;
|
|
4306
|
+
current = current.parentElement;
|
|
4307
|
+
}
|
|
4308
|
+
return false;
|
|
4309
|
+
}
|
|
4310
|
+
}
|
|
4311
|
+
TitleHeadingNodeFilterStylesStrategy.BOLD_STYLES = {
|
|
4312
|
+
fontWeight: '700',
|
|
4313
|
+
};
|
|
4314
|
+
TitleHeadingNodeFilterStylesStrategy.NON_HEADING_TITLE_ELEMENT_TAGS = [
|
|
4315
|
+
'TD',
|
|
4316
|
+
'TH',
|
|
4317
|
+
'TR',
|
|
4318
|
+
'TABLE',
|
|
4319
|
+
'THEAD',
|
|
4320
|
+
'TBODY',
|
|
4321
|
+
'DIV',
|
|
4322
|
+
'BODY',
|
|
4323
|
+
];
|
|
4324
|
+
|
|
4325
|
+
/**
|
|
4326
|
+
* Filters the default heading styles from customStyle when parsing an RTEListItemBlock that is supposed to be a heading.
|
|
4327
|
+
*/
|
|
4328
|
+
class ListHeadingItemBlockFilterStylesStrategy extends HeadingFilterStylesStrategy {
|
|
4329
|
+
constructor(level) {
|
|
4330
|
+
super(level);
|
|
4331
|
+
this.classNameToBeAdded = `v-rte-h${level}`;
|
|
4332
|
+
this.elementTagName = 'li';
|
|
4333
|
+
}
|
|
4334
|
+
/**
|
|
4335
|
+
* Check the important font-size and line-height for list item block are default styles, and the block is a list item block.
|
|
4336
|
+
*
|
|
4337
|
+
* @inheritDoc
|
|
4338
|
+
*/
|
|
4339
|
+
canFilter(blockOrNodeInstance) {
|
|
4340
|
+
return (codeBlock.Predicate.isListItemBlock(blockOrNodeInstance.constructor.name) &&
|
|
4341
|
+
this.isBlockOrNodeStylesMatchFilterStyles(blockOrNodeInstance, ['fontSize', 'lineHeight']));
|
|
4342
|
+
}
|
|
4343
|
+
/**
|
|
4344
|
+
* @inheritDoc
|
|
4345
|
+
*/
|
|
4346
|
+
canRefill(blockOrNodeClassName, element) {
|
|
4347
|
+
return (codeBlock.Predicate.isListItemBlock(blockOrNodeClassName) &&
|
|
4348
|
+
element.matches(this.elementTagName) &&
|
|
4349
|
+
element.classList.contains(this.classNameToBeAdded));
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
|
|
4353
|
+
/**
|
|
4354
|
+
* Filters the default title/subtitle styles from customStyle when parsing an RTEListItemBlock that is supposed to be a title/subtitle.
|
|
4355
|
+
*/
|
|
4356
|
+
class ListTitleItemBlockFilterStylesStrategy extends TitleFilterStylesStrategy {
|
|
4357
|
+
constructor(type) {
|
|
4358
|
+
super(type);
|
|
4359
|
+
this.classNameToBeAdded = `v-rte-${type}`;
|
|
4360
|
+
this.elementTagName = 'li';
|
|
4361
|
+
}
|
|
4362
|
+
/**
|
|
4363
|
+
* Check the important font-size and line-height for list item block are default styles, and the block is a list item block.
|
|
4364
|
+
*
|
|
4365
|
+
* @inheritDoc
|
|
4366
|
+
*/
|
|
4367
|
+
canFilter(blockOrNodeInstance) {
|
|
4368
|
+
return (codeBlock.Predicate.isListItemBlock(blockOrNodeInstance.constructor.name) &&
|
|
4369
|
+
this.isBlockOrNodeStylesMatchFilterStyles(blockOrNodeInstance, ['fontSize', 'lineHeight']));
|
|
4370
|
+
}
|
|
4371
|
+
/**
|
|
4372
|
+
* @inheritDoc
|
|
4373
|
+
*/
|
|
4374
|
+
canRefill(blockOrNodeClassName, element) {
|
|
4375
|
+
return (codeBlock.Predicate.isListItemBlock(blockOrNodeClassName) &&
|
|
4376
|
+
element.matches(this.elementTagName) &&
|
|
4377
|
+
element.classList.contains(this.classNameToBeAdded));
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
/**
|
|
4382
|
+
* Register and setup the default DTO classes and their basic action strategies.
|
|
4383
|
+
*/
|
|
4384
|
+
// Register the default block DTOs
|
|
4385
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('paragraph', codeBlock.RTETextBlock);
|
|
4386
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('title', codeBlock.RTETextBlock);
|
|
4387
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('subtitle', codeBlock.RTETextBlock);
|
|
4388
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-1', codeBlock.RTETextBlock);
|
|
4389
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-2', codeBlock.RTETextBlock);
|
|
4390
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-3', codeBlock.RTETextBlock);
|
|
4391
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-4', codeBlock.RTETextBlock);
|
|
4392
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-5', codeBlock.RTETextBlock);
|
|
4393
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-6', codeBlock.RTETextBlock);
|
|
4394
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('heading-6', codeBlock.RTETextBlock);
|
|
4395
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('list-item', RTEListItemBlock);
|
|
4396
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('bullet-list', RTEListBlock);
|
|
4397
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('number-list', RTEListBlock);
|
|
4398
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('image', RTEImageBlock);
|
|
4399
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('code-block', codeBlock.RTECodeBlock);
|
|
4400
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('html-block', RTEHtmlBlock);
|
|
4401
|
+
// Register the default node DTOs
|
|
4402
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('text', codeBlock.RTETextNode);
|
|
4403
|
+
codeBlock.RTEDTOClassManager.registerRTEDTOClass('image', RTEImageNode);
|
|
4404
|
+
// Register basic strategies for default block DTOs
|
|
4405
|
+
RTEDTOActionStrategyManager$1.registerBlockBasicStrategies(codeBlock.RTETextBlock.name);
|
|
4406
|
+
RTEDTOActionStrategyManager$1.registerBlockBasicStrategies(RTEListBlock.name);
|
|
4407
|
+
RTEDTOActionStrategyManager$1.registerBlockBasicStrategies(RTEListItemBlock.name);
|
|
4408
|
+
RTEDTOActionStrategyManager$1.registerBlockBasicStrategies(RTEImageBlock.name);
|
|
4409
|
+
RTEDTOActionStrategyManager$1.registerBlockBasicStrategies(RTEHtmlBlock.name);
|
|
4410
|
+
// Register element to DTO strategies for default node DTOs, The order of registration matters, the later registered strategy has higher priority.
|
|
4411
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new ContinueInlineToRTETextBlockStrategy());
|
|
4412
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new SpanImageToRTEImageBlockStrategy());
|
|
4413
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new VegaImageToRTEImageBlockStrategy());
|
|
4414
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new ImgToRTEImageBlockStrategy());
|
|
4415
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new InlineBlockToRTETextBlockStrategy());
|
|
4416
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new LiToRTEListItemBlockStrategy());
|
|
4417
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new ULNotLiChildToRTEListItemBlockStrategy());
|
|
4418
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new OlToRTEListBlockStrategy());
|
|
4419
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new UlToRTEListBlockStrategy());
|
|
4420
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new HtmlBlockStrategy());
|
|
4421
|
+
//!important: Code block strategies must be registered after HtmlBlockStrategy because registerElementToBlockStrategy uses unshift, giving later registrations higher priority.
|
|
4422
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new JiraCodeToRTECodeBlockStrategy());
|
|
4423
|
+
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new VegaCodeBlockToRTECodeBlockStrategy());
|
|
4424
|
+
ElementToDTOClassStrategyManager.registerElementToNodeStrategy(new InlineElementToTextNodeStrategy());
|
|
4425
|
+
ElementToDTOClassStrategyManager.registerElementToNodeStrategy(new PlainTextToTextNodeStrategy());
|
|
4426
|
+
// Register filter styles strategies (remove redundant default styles during HTML → DTO conversion)
|
|
4427
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new AlignmentFilterStylesStrategy());
|
|
4428
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListBlock.name, new AlignmentFilterStylesStrategy());
|
|
4429
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new AlignmentFilterStylesStrategy());
|
|
4430
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextNode.name, new TextFormatFilterStylesStrategy());
|
|
4431
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new ParagraphFilterStylesStrategy());
|
|
4432
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new HeadingFilterStylesStrategy(1));
|
|
4433
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new HeadingFilterStylesStrategy(2));
|
|
4434
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new HeadingFilterStylesStrategy(3));
|
|
4435
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new HeadingFilterStylesStrategy(4));
|
|
4436
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new HeadingFilterStylesStrategy(5));
|
|
4437
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new HeadingFilterStylesStrategy(6));
|
|
4438
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new TitleFilterStylesStrategy('title'));
|
|
4439
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextBlock.name, new TitleFilterStylesStrategy('subtitle'));
|
|
4440
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextNode.name, new TitleHeadingNodeFilterStylesStrategy());
|
|
4441
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextNode.name, new CodeFilterStylesStrategy());
|
|
4442
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTETextNode.name, new codeBlock.LinkFilterStylesStrategy());
|
|
4443
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEImageNode.name, new ImageFilterStylesStrategy());
|
|
4444
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTECodeBlock.name, new codeBlock.CodeBlockFilterStylesStrategy());
|
|
4445
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(codeBlock.RTECodeBlockNode.name, new codeBlock.CodeBlockNodeFilterStylesStrategy());
|
|
4446
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListBlock.name, new ListBlockFilterStylesStrategy());
|
|
4447
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListItemBlockFilterStylesStrategy());
|
|
4448
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(1));
|
|
4449
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(2));
|
|
4450
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(3));
|
|
4451
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(4));
|
|
4452
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(5));
|
|
4453
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(6));
|
|
4454
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListTitleItemBlockFilterStylesStrategy('title'));
|
|
4455
|
+
codeBlock.RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListTitleItemBlockFilterStylesStrategy('subtitle'));
|
|
4456
|
+
|
|
4457
|
+
/**
|
|
4458
|
+
* StylePreservator handles CSP-compliant style management by temporarily converting
|
|
4459
|
+
* inline styles to data attributes during HTML parsing operations.
|
|
4460
|
+
*
|
|
4461
|
+
* @example
|
|
4462
|
+
* ```typescript
|
|
4463
|
+
* const context = StylePreservator.preserve('<div style="color: red;">Content</div>');
|
|
4464
|
+
* const safeHtml = context.getProcessedHtml();
|
|
4465
|
+
* context.restore(parsedElements);
|
|
4466
|
+
* ```
|
|
4467
|
+
*/
|
|
4468
|
+
class StylePreservator {
|
|
4469
|
+
/**
|
|
4470
|
+
* Preserves inline styles by converting them to data attributes.
|
|
4471
|
+
*
|
|
4472
|
+
* @param {string} htmlString - The HTML string containing inline styles
|
|
4473
|
+
* @returns {StylePreservationContext} A context object for later style restoration
|
|
4474
|
+
*/
|
|
4475
|
+
static preserve(htmlString) {
|
|
4476
|
+
const processedHtml = htmlString.replace(/\s+style=/g, ' data-style=');
|
|
4477
|
+
return new StylePreservationContext(processedHtml);
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
/**
|
|
4481
|
+
* Context class that manages the lifecycle of preserved styles.
|
|
4482
|
+
*/
|
|
4483
|
+
class StylePreservationContext {
|
|
4484
|
+
constructor(processedHtml) {
|
|
4485
|
+
this.processedHtml = processedHtml;
|
|
4486
|
+
}
|
|
4487
|
+
/**
|
|
4488
|
+
* Returns the HTML string with style attributes converted to data-style.
|
|
4489
|
+
*
|
|
4490
|
+
* @returns {string} The processed HTML string
|
|
4491
|
+
*/
|
|
4492
|
+
getProcessedHtml() {
|
|
4493
|
+
return this.processedHtml;
|
|
4494
|
+
}
|
|
4495
|
+
/**
|
|
4496
|
+
* Restores data-style attributes back to style attributes.
|
|
4497
|
+
*
|
|
4498
|
+
* @param {HTMLElement[]} elements - Array of HTML elements to process
|
|
4499
|
+
* @returns {void}
|
|
4500
|
+
*/
|
|
4501
|
+
restore(elements) {
|
|
4502
|
+
this.walkNodes(elements);
|
|
4503
|
+
}
|
|
4504
|
+
/**
|
|
4505
|
+
* Recursively walk through nodes and restore styles
|
|
4506
|
+
*
|
|
4507
|
+
* @param {HTMLElement[]} elements - list of nodes
|
|
4508
|
+
* @returns {void}
|
|
4509
|
+
*/
|
|
4510
|
+
walkNodes(elements) {
|
|
4511
|
+
elements.forEach((element) => {
|
|
4512
|
+
if (ui.isHTMLElement(element)) {
|
|
4513
|
+
// Restore data-style back to style
|
|
4514
|
+
const dataStyle = element.getAttribute('data-style');
|
|
4515
|
+
if (dataStyle) {
|
|
4516
|
+
element.style.cssText = dataStyle;
|
|
4517
|
+
element.removeAttribute('data-style');
|
|
4518
|
+
}
|
|
4519
|
+
// Recursively process child nodes
|
|
4520
|
+
if (element.children.length > 0) {
|
|
4521
|
+
this.walkNodes(Array.from(element.children));
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
});
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4528
|
+
/**
|
|
4529
|
+
* Removes whitespace between tags, except preserves ALL whitespace between matching opening/closing tag pairs.
|
|
4530
|
+
*
|
|
4531
|
+
* This processor scans for patterns of `<tag>(whitespace)<tag>` and:
|
|
4532
|
+
* - If the first tag is an opening tag and the second tag is its matching closing tag (e.g., `<span> </span>`),
|
|
4533
|
+
* preserves ALL the whitespace between them (including spaces, tabs, newlines)
|
|
4534
|
+
* - Otherwise, removes all the whitespace between the tags
|
|
4535
|
+
*
|
|
4536
|
+
* Examples:
|
|
4537
|
+
* - `</p>\n\t<div>` → `</p><div>` (different tags: closing p, opening div - whitespace removed)
|
|
4538
|
+
* - `<div>\n\t<span>` → `<div><span>` (different tags: opening div, opening span - whitespace removed)
|
|
4539
|
+
* - `<span> </span>` → `<span> </span>` (matching tags: opening span, closing span - space preserved)
|
|
4540
|
+
* - `<span> </span>` → `<span> </span>` (matching tags - multiple spaces preserved)
|
|
4541
|
+
* - `<span>\n\t</span>` → `<span>\n\t</span>` (matching tags - \n\t preserved)
|
|
4542
|
+
* - `<code> </code>` → `<code> </code>` (matching tags - space preserved)
|
|
4543
|
+
* - `</div> <p>` → `</div><p>` (different tags: closing div, opening p - whitespace removed)
|
|
4544
|
+
*/
|
|
4545
|
+
class RemoveWhitespaceBetweenTagsProcessor {
|
|
4546
|
+
/**
|
|
4547
|
+
* Process the HTML string to remove whitespace between non-matching tags.
|
|
4548
|
+
*
|
|
4549
|
+
* @param {string} html - The HTML string to process.
|
|
4550
|
+
* @returns {string} The processed HTML string.
|
|
4551
|
+
*/
|
|
4552
|
+
process(html) {
|
|
4553
|
+
return html.replace(/(<[^>]+>)(\s+)(<[^>]+>)/g, (_match, tag1, whitespace, tag2) => {
|
|
4554
|
+
const openingTagName = this.extractOpeningTagName(tag1);
|
|
4555
|
+
const closingTagName = this.extractClosingTagName(tag2);
|
|
4556
|
+
// Preserve all whitespace if tags match (e.g., <span> </span>)
|
|
4557
|
+
if (openingTagName && closingTagName && openingTagName === closingTagName) {
|
|
4558
|
+
return `${tag1}${whitespace}${tag2}`;
|
|
4559
|
+
}
|
|
4560
|
+
// Remove whitespace for non-matching tags
|
|
4561
|
+
return `${tag1}${tag2}`;
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4564
|
+
/**
|
|
4565
|
+
* Extracts the tag name from an opening HTML tag.
|
|
4566
|
+
*
|
|
4567
|
+
* Supports standard HTML tags (div, span, h1, etc.) and custom elements with hyphens (my-component).
|
|
4568
|
+
*
|
|
4569
|
+
* Examples:
|
|
4570
|
+
* - `<span>` → `span`
|
|
4571
|
+
* - `<div class="test">` → `div`
|
|
4572
|
+
* - `<my-component id="123">` → `my-component`
|
|
4573
|
+
* - `</span>` → `null` (not an opening tag)
|
|
4574
|
+
*
|
|
4575
|
+
* @param {string} tag - The tag string to extract from (e.g., '<span>', '<div class="test">').
|
|
4576
|
+
* @returns {string | null} The tag name or null if not an opening tag.
|
|
4577
|
+
* @private
|
|
4578
|
+
*/
|
|
4579
|
+
extractOpeningTagName(tag) {
|
|
4580
|
+
// Pattern: <(tag name) where tag name starts with letter, followed by letters/numbers/hyphens
|
|
4581
|
+
const match = tag.match(/<(\w[\w-]*)/);
|
|
4582
|
+
return match ? match[1] : null;
|
|
4583
|
+
}
|
|
4584
|
+
/**
|
|
4585
|
+
* Extracts the tag name from a closing HTML tag.
|
|
4586
|
+
*
|
|
4587
|
+
* Supports standard HTML tags (div, span, h1, etc.) and custom elements with hyphens (my-component).
|
|
4588
|
+
*
|
|
4589
|
+
* Examples:
|
|
4590
|
+
* - `</span>` → `span`
|
|
4591
|
+
* - `</div>` → `div`
|
|
4592
|
+
* - `</my-component>` → `my-component`
|
|
4593
|
+
* - `<span>` → `null` (not a closing tag)
|
|
4594
|
+
*
|
|
4595
|
+
* @param {string} tag - The tag string to extract from (e.g., '</span>', '</div>').
|
|
4596
|
+
* @returns {string | null} The tag name or null if not a closing tag.
|
|
4597
|
+
* @private
|
|
4598
|
+
*/
|
|
4599
|
+
extractClosingTagName(tag) {
|
|
4600
|
+
// Pattern: </(tag name) where tag name starts with letter, followed by letters/numbers/hyphens
|
|
4601
|
+
const match = tag.match(/<\/(\w[\w-]*)/);
|
|
4602
|
+
return match ? match[1] : null;
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
|
|
4606
|
+
/**
|
|
4607
|
+
* Removes `\n` and `\t` characters after opening tags (before text content).
|
|
4608
|
+
*
|
|
4609
|
+
* Transforms patterns like `>[\n\t]+(text)` to `>(text)`.
|
|
4610
|
+
*
|
|
4611
|
+
* Examples:
|
|
4612
|
+
* - `<p>\n\tHello` → `<p>Hello`
|
|
4613
|
+
* - `<div>\n\n\tWorld` → `<div>World`
|
|
4614
|
+
*/
|
|
4615
|
+
class RemoveWhitespaceAfterOpeningTagProcessor {
|
|
4616
|
+
/**
|
|
4617
|
+
* Process the HTML string to remove `\n` and `\t` after opening tags.
|
|
4618
|
+
*
|
|
4619
|
+
* @param {string} html - The HTML string to process.
|
|
4620
|
+
* @returns {string} The processed HTML string.
|
|
4621
|
+
*/
|
|
4622
|
+
process(html) {
|
|
4623
|
+
// Pattern: `>[\n\t]+(text)` → `>(text)`
|
|
4624
|
+
return html.replace(/(>)[\n\t]+(?=.)/g, '$1');
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
/**
|
|
4629
|
+
* Removes `\n` and `\t` characters before closing tags (after text content).
|
|
4630
|
+
*
|
|
4631
|
+
* Transforms patterns like `(text)[\n\t]+<` to `(text)<`.
|
|
4632
|
+
*
|
|
4633
|
+
* Examples:
|
|
4634
|
+
* - `World\n\t</p>` → `World</p>`
|
|
4635
|
+
* - `Hello\n</div>` → `Hello</div>`
|
|
4636
|
+
*/
|
|
4637
|
+
class RemoveWhitespaceBeforeClosingTagProcessor {
|
|
4638
|
+
/**
|
|
4639
|
+
* Process the HTML string to remove `\n` and `\t` before closing tags.
|
|
4640
|
+
*
|
|
4641
|
+
* @param {string} html - The HTML string to process.
|
|
4642
|
+
* @returns {string} The processed HTML string.
|
|
4643
|
+
*/
|
|
4644
|
+
process(html) {
|
|
4645
|
+
// Pattern: `(text)[\n\t]+<` → `(text)<`
|
|
4646
|
+
return html.replace(/(.?)[\n\t]+(?=<)/g, '$1');
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4650
|
+
/**
|
|
4651
|
+
* Main HTML content cleaner that orchestrates multiple cleaning processors.
|
|
4652
|
+
*
|
|
4653
|
+
* This class implements a chain of responsibility pattern where each processor
|
|
4654
|
+
* handles a specific aspect of HTML cleaning. The processors are applied in sequence
|
|
4655
|
+
* and the entire chain is repeated until no more changes occur.
|
|
4656
|
+
*
|
|
4657
|
+
* Processors (in order):
|
|
4658
|
+
* 1. RemoveWhitespaceBetweenTagsProcessor - Removes whitespace between non-matching tags
|
|
4659
|
+
* 2. RemoveWhitespaceAfterOpeningTagProcessor - Removes \n and \t after opening tags
|
|
4660
|
+
* 3. RemoveWhitespaceBeforeClosingTagProcessor - Removes \n and \t before closing tags
|
|
4661
|
+
*/
|
|
4662
|
+
class HTMLContentCleaner {
|
|
4663
|
+
constructor() {
|
|
4664
|
+
this.processors = [
|
|
4665
|
+
new RemoveWhitespaceBetweenTagsProcessor(),
|
|
4666
|
+
new RemoveWhitespaceAfterOpeningTagProcessor(),
|
|
4667
|
+
new RemoveWhitespaceBeforeClosingTagProcessor(),
|
|
4668
|
+
];
|
|
4669
|
+
}
|
|
4670
|
+
/**
|
|
4671
|
+
* Cleans HTML by applying all processors in the chain repeatedly until no changes occur.
|
|
4672
|
+
*
|
|
4673
|
+
* The cleaning process:
|
|
4674
|
+
* 1. Applies each processor in sequence
|
|
4675
|
+
* 2. Compares the result with the input
|
|
4676
|
+
* 3. If changes were made, repeats the process
|
|
4677
|
+
* 4. Returns the final cleaned HTML
|
|
4678
|
+
*
|
|
4679
|
+
* Examples of transformations:
|
|
4680
|
+
* - `<p>\n\t <span>test</span>\n\t </p>` → `<p><span>test</span></p>`
|
|
4681
|
+
* - `<p>\n\tHello</p>` → `<p>Hello</p>`
|
|
4682
|
+
* - `<p>Hello\n\t</p>` → `<p>Hello</p>`
|
|
4683
|
+
* - `<span> </span>` → `<span> </span>` (preserved - matching tags)
|
|
4684
|
+
* - `<p>Hello World</p>` → `<p>Hello World</p>` (preserved - regular spaces)
|
|
4685
|
+
*
|
|
4686
|
+
* @param {string} html - The HTML string to clean.
|
|
4687
|
+
* @returns {string} The cleaned HTML string.
|
|
4688
|
+
*/
|
|
4689
|
+
clean(html) {
|
|
4690
|
+
if (!html || html.trim().length === 0) {
|
|
4691
|
+
return html;
|
|
4692
|
+
}
|
|
4693
|
+
let result = html;
|
|
4694
|
+
let previousResult;
|
|
4695
|
+
// Keep processing until no more changes occur
|
|
4696
|
+
do {
|
|
4697
|
+
previousResult = result;
|
|
4698
|
+
// Apply each processor in the chain
|
|
4699
|
+
for (const processor of this.processors) {
|
|
4700
|
+
result = processor.process(result);
|
|
4701
|
+
}
|
|
4702
|
+
} while (result !== previousResult);
|
|
4703
|
+
return result;
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
|
|
4707
|
+
/**
|
|
4708
|
+
* Class representing the content state of the rich text editor.
|
|
4709
|
+
*/
|
|
4710
|
+
class VegaRTEContent {
|
|
4711
|
+
constructor(blocks) {
|
|
4712
|
+
blocks.forEach((block) => {
|
|
4713
|
+
block.parent = this;
|
|
4714
|
+
});
|
|
4715
|
+
this.children = blocks;
|
|
4716
|
+
}
|
|
4717
|
+
/**
|
|
4718
|
+
* Converts a JSON array of blocks to a class array of RTEContentBlock.
|
|
4719
|
+
*
|
|
4720
|
+
* @param {VegaRTEContentBlock[]} value The JSON array of blocks to convert.
|
|
4721
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
4722
|
+
* @returns {VegaRTEContent} The converted array of RTEContentBlock.
|
|
4723
|
+
*/
|
|
4724
|
+
static fromJSON(value, options = { autoMatchFormat: true }) {
|
|
4725
|
+
const blocks = value.map((block) => {
|
|
4726
|
+
const BlockClass = codeBlock.RTEDTOClassManager.getRTEBlockClass(block.type);
|
|
4727
|
+
if (BlockClass) {
|
|
4728
|
+
return BlockClass.from(block, options);
|
|
4729
|
+
}
|
|
4730
|
+
else {
|
|
4731
|
+
throw new Error(`[Vega] Unknown block type: ${block.type}`);
|
|
4732
|
+
}
|
|
4733
|
+
});
|
|
4734
|
+
return new VegaRTEContent(blocks);
|
|
4735
|
+
}
|
|
4736
|
+
/**
|
|
4737
|
+
* Create an empty content state
|
|
4738
|
+
*
|
|
4739
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
4740
|
+
* @returns {VegaRTEContent} An empty content state
|
|
4741
|
+
*/
|
|
4742
|
+
static createEmptyContent(options = { autoMatchFormat: true }) {
|
|
4743
|
+
return VegaRTEContent.fromJSON([
|
|
4744
|
+
{
|
|
4745
|
+
id: misc.generateUUID(),
|
|
4746
|
+
type: 'paragraph',
|
|
4747
|
+
annotations: {
|
|
4748
|
+
internalWrapper: !options.autoMatchFormat,
|
|
4749
|
+
},
|
|
4750
|
+
nodes: [
|
|
4751
|
+
{
|
|
4752
|
+
id: misc.generateUUID(),
|
|
4753
|
+
annotations: { plainText: !options.autoMatchFormat },
|
|
4754
|
+
type: 'text',
|
|
4755
|
+
text: '',
|
|
4756
|
+
},
|
|
4757
|
+
],
|
|
4758
|
+
},
|
|
4759
|
+
], options);
|
|
4760
|
+
}
|
|
4761
|
+
/**
|
|
4762
|
+
* Converts HTML content to a VegaRTEContent instance.
|
|
4763
|
+
*
|
|
4764
|
+
* @param {string} html - The HTML string to convert.
|
|
4765
|
+
* @param {VegaRTETransformOptions} options - Optional transformation options.
|
|
4766
|
+
* @returns {VegaRTEContent} The converted content state.
|
|
4767
|
+
*/
|
|
4768
|
+
static fromHtml(html, options = { autoMatchFormat: true, skipCustomAnnotations: false }) {
|
|
4769
|
+
const cleaner = new HTMLContentCleaner();
|
|
4770
|
+
const formattedHtml = cleaner.clean(html);
|
|
4771
|
+
const context = StylePreservator.preserve(formattedHtml);
|
|
4772
|
+
const safeHtml = context.getProcessedHtml();
|
|
4773
|
+
const body = new DOMParser().parseFromString(safeHtml, 'text/html').body;
|
|
4774
|
+
const htmlElements = Array.from(body.childNodes);
|
|
4775
|
+
context.restore(htmlElements);
|
|
4776
|
+
const blocks = ElementToDtoStrategyProcessor$1.process(htmlElements, options)
|
|
4777
|
+
.filter(typeGuard.isNonNullable)
|
|
4778
|
+
.map((output) => output.toDto(options))
|
|
4779
|
+
.filter(typeGuard.isNonNullable);
|
|
4780
|
+
return new VegaRTEContent(blocks);
|
|
4781
|
+
}
|
|
4782
|
+
/**
|
|
4783
|
+
* Generates the content style file for the rich text editor based on the registered filter styles strategies.
|
|
4784
|
+
*
|
|
4785
|
+
* @param {VegaRTEGenerateStyleOptions} options - Options for generating the content style file.
|
|
4786
|
+
* @returns {string} The html template style text.
|
|
4787
|
+
*/
|
|
4788
|
+
static generateContentStyles(options) {
|
|
4789
|
+
return codeBlock.RTEFilterStylesStrategyRegistry.generateAllStylesContent(options === null || options === void 0 ? void 0 : options.enableFontImports);
|
|
4790
|
+
}
|
|
4791
|
+
/**
|
|
4792
|
+
* Clones the content state.
|
|
4793
|
+
*
|
|
4794
|
+
* @param {boolean} deep - If true, performs a deep clone of the content state.
|
|
4795
|
+
* @returns {VegaRTEContent} The cloned content state.
|
|
4796
|
+
*/
|
|
4797
|
+
clone(deep = false) {
|
|
4798
|
+
return deep
|
|
4799
|
+
? new VegaRTEContent(this.children.map((block) => block.clone(this)))
|
|
4800
|
+
: new VegaRTEContent([...this.children]);
|
|
4801
|
+
}
|
|
4802
|
+
/**
|
|
4803
|
+
* Converts the content state to a JSON array of blocks.
|
|
4804
|
+
*
|
|
4805
|
+
* @returns {VegaRTEContentBlock[]} The JSON array of blocks.
|
|
4806
|
+
*/
|
|
4807
|
+
toJSON() {
|
|
4808
|
+
return this.children.map((block) => block.toJSON());
|
|
4809
|
+
}
|
|
4810
|
+
/**
|
|
4811
|
+
* Converts the content state to HTML.
|
|
4812
|
+
*
|
|
4813
|
+
* @param {VegaRTETransformOptions} [options] - The conversion options.
|
|
4814
|
+
* @returns {string} The HTML representation of the content state.
|
|
4815
|
+
*/
|
|
4816
|
+
toHtml(options) {
|
|
4817
|
+
if (options &&
|
|
4818
|
+
(typeGuard.isNonNullable(options.autoMatchFormat) || typeGuard.isNonNullable(options.skipCustomAnnotations))) {
|
|
4819
|
+
globalSlimmerRegistry.LogUtility.warn(`The 'options' parameter's properties 'autoMatchFormat' and 'skipCustomAnnotations' in toHtml method are deprecated and will be removed in the future.`);
|
|
4820
|
+
}
|
|
4821
|
+
if (this.isEmpty()) {
|
|
4822
|
+
return '';
|
|
4823
|
+
}
|
|
4824
|
+
return this.children
|
|
4825
|
+
.map((block) => block.toHtml({ filterInlineStyles: options === null || options === void 0 ? void 0 : options.filterInlineStyles }))
|
|
4826
|
+
.join('');
|
|
4827
|
+
}
|
|
4828
|
+
/**
|
|
4829
|
+
* Checks if the content state is empty.
|
|
4830
|
+
*
|
|
4831
|
+
* @returns {boolean} True if the content state is empty, false otherwise.
|
|
4832
|
+
*/
|
|
4833
|
+
isEmpty() {
|
|
4834
|
+
if (this.children.length === 0) {
|
|
4835
|
+
return true;
|
|
4836
|
+
}
|
|
4837
|
+
if (this.children.length === 1) {
|
|
4838
|
+
const block = this.children[0];
|
|
4839
|
+
return !block.isNotEmpty();
|
|
4840
|
+
}
|
|
4841
|
+
return false;
|
|
4842
|
+
}
|
|
4843
|
+
/**
|
|
4844
|
+
* Internal method to add the block item, remove the block item
|
|
4845
|
+
*
|
|
4846
|
+
* @param {ModifyContentAction} action - Modify content action
|
|
4847
|
+
*/
|
|
4848
|
+
apply(action) {
|
|
4849
|
+
codeBlock.ActionHandleStrategyRegistry.executeTheStrategy(action, this);
|
|
4850
|
+
// Check if the action has been executed and is flushable
|
|
4851
|
+
if (action['executedFlag'] && action.isFlushable) {
|
|
4852
|
+
const host = codeBlock.stateEntityRenderingRegistry.getDOMByEntity(this);
|
|
4853
|
+
if (host) {
|
|
4854
|
+
changeManager.ChangeManager.notify(domNodeSubjectObserverFactory.domNodeSubjectFactory.getSubject(host, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges), {});
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
/**
|
|
4859
|
+
* Get the last node in the content.
|
|
4860
|
+
*
|
|
4861
|
+
* @returns {Nullable<RTENode>} The last node in the content or null if there are no nodes.
|
|
4862
|
+
*/
|
|
4863
|
+
getLastNode() {
|
|
4864
|
+
if (this.children.length === 0) {
|
|
4865
|
+
return null;
|
|
4866
|
+
}
|
|
4867
|
+
const lastBlock = this.children[this.children.length - 1];
|
|
4868
|
+
return lastBlock.getLastNode();
|
|
4869
|
+
}
|
|
4870
|
+
/**
|
|
4871
|
+
* Convert text to list.
|
|
4872
|
+
*
|
|
4873
|
+
* @param {RTETextBlock} block - block
|
|
4874
|
+
* @returns {RTEListItemBlock} list item block dto.
|
|
4875
|
+
*/
|
|
4876
|
+
toListItem(block) {
|
|
4877
|
+
block.children.map((node) => node.apply(new codeBlock.SyncUpSelectionAction()));
|
|
4878
|
+
const listItemBlock = new RTEListItemBlock(misc.generateUUID());
|
|
4879
|
+
listItemBlock.apply(new codeBlock.AppendChildrenAction(block['children']));
|
|
4880
|
+
listItemBlock['annotationMap'] = block['annotationMap'];
|
|
4881
|
+
return listItemBlock;
|
|
4882
|
+
}
|
|
4883
|
+
/**
|
|
4884
|
+
* create list.
|
|
4885
|
+
*
|
|
4886
|
+
* @param {ListType} type - type
|
|
4887
|
+
* @returns {RTEListBlock} list block dto.
|
|
4888
|
+
*/
|
|
4889
|
+
createList(type) {
|
|
4890
|
+
return new RTEListBlock(misc.generateUUID(), type);
|
|
4891
|
+
}
|
|
4892
|
+
/**
|
|
4893
|
+
* Finds a node by its ID in the content.
|
|
4894
|
+
*
|
|
4895
|
+
* @param {string} id - The ID of the node to find.
|
|
4896
|
+
* @returns {Nullable<RTENode>} The found node or null if not found.
|
|
4897
|
+
*/
|
|
4898
|
+
findNodeById(id) {
|
|
4899
|
+
return this.findNodeInBlocksById(id, this.children);
|
|
4900
|
+
}
|
|
4901
|
+
/**
|
|
4902
|
+
* Recursively searches for a node by its ID in the given blocks.
|
|
4903
|
+
*
|
|
4904
|
+
* @param {string} id - The ID of the node to find.
|
|
4905
|
+
* @param {RTEContentBlock[]} blocks - The blocks to search within.
|
|
4906
|
+
* @returns {Nullable<RTENode>} The found node or null if not found.
|
|
4907
|
+
*/
|
|
4908
|
+
findNodeInBlocksById(id, blocks) {
|
|
4909
|
+
for (const block of blocks) {
|
|
4910
|
+
if ('children' in block) {
|
|
4911
|
+
for (const node of block.children) {
|
|
4912
|
+
if (node.id === id) {
|
|
4913
|
+
return node;
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
if (block instanceof RTEListItemBlock && block.nestList) {
|
|
4918
|
+
for (const cBlock of block.nestList) {
|
|
4919
|
+
const foundNode = this.findNodeInBlocksById(id, cBlock.children);
|
|
4920
|
+
if (foundNode) {
|
|
4921
|
+
return foundNode;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
if (block instanceof RTEListBlock && block.children) {
|
|
4926
|
+
const foundNode = this.findNodeInBlocksById(id, block.children);
|
|
4927
|
+
if (foundNode) {
|
|
4928
|
+
return foundNode;
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
}
|
|
4932
|
+
return null;
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4935
|
+
(() => {
|
|
4936
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.DELETE_CHILDREN, VegaRTEContent.name, new codeBlock.RemoveChildrenStrategy());
|
|
4937
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.APPEND_CHILDREN, VegaRTEContent.name, new AppendChildrenStrategy());
|
|
4938
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_CHILDREN_BEFORE, VegaRTEContent.name, new InsertChildrenBeforeStrategy());
|
|
4939
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.INSERT_CHILDREN_AFTER, VegaRTEContent.name, new InsertChildrenAfterStrategy());
|
|
4940
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.TRANSFORM_TO_CODE_BLOCK, VegaRTEContent.name, new BlockTransformToCodeBlockStrategy());
|
|
4941
|
+
codeBlock.ActionHandleStrategyRegistry.register(codeBlock.ModifyContentActionType.UPDATE_CURSOR_POSITION, VegaRTEContent.name, new UpdateCursorPositionStrategy());
|
|
4942
|
+
})();
|
|
4943
|
+
|
|
4944
|
+
exports.AnnotationGeneratorStrategyAbstract = AnnotationGeneratorStrategyAbstract;
|
|
4945
|
+
exports.BlockToRTEBlockStrategyAbstract = BlockToRTEBlockStrategyAbstract;
|
|
4946
|
+
exports.ElementToDTOClassStrategyManager = ElementToDTOClassStrategyManager;
|
|
4947
|
+
exports.ElementToDTOStrategy = ElementToDTOStrategy;
|
|
4948
|
+
exports.ElementToDtoStrategyProcessor = ElementToDtoStrategyProcessor$1;
|
|
4949
|
+
exports.ImageAnnotation = ImageAnnotation;
|
|
4950
|
+
exports.InsertChildrenBeforeStrategy = InsertChildrenBeforeStrategy;
|
|
4951
|
+
exports.InsertNewParagraphAction = InsertNewParagraphAction;
|
|
4952
|
+
exports.MergeTwoBlocksNodesAction = MergeTwoBlocksNodesAction;
|
|
4953
|
+
exports.PasteContentStrategy = PasteContentStrategy;
|
|
4954
|
+
exports.RTEDTOActionStrategyManager = RTEDTOActionStrategyManager$1;
|
|
4955
|
+
exports.RTEImageBlock = RTEImageBlock;
|
|
4956
|
+
exports.RTEImageNode = RTEImageNode;
|
|
4957
|
+
exports.RTEListBlock = RTEListBlock;
|
|
4958
|
+
exports.RTEListItemBlock = RTEListItemBlock;
|
|
4959
|
+
exports.StylePreservator = StylePreservator;
|
|
4960
|
+
exports.UpdateCursorPositionAction = UpdateCursorPositionAction;
|
|
4961
|
+
exports.VegaRTEContent = VegaRTEContent;
|
|
4962
|
+
exports.htmlElementToAnnotationGenerator = htmlElementToAnnotationGenerator;
|