@heartlandone/vega 2.102.0 → 2.103.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-49c2a999.js → app-globals-85986306.js} +10 -10
- package/dist/cjs/{code-block-06e6591f.js → code-block-72de6c4d.js} +80 -1
- package/dist/cjs/{component-value-history-controller-slimmer.abstract-f29908f8.js → component-value-history-controller-slimmer.abstract-23d2b3d8.js} +3 -3
- package/dist/cjs/{content-state-8c862e5e.js → content-state-ff40bdc6.js} +38 -5
- package/dist/cjs/{date-required-rule-b672c432.js → date-required-rule-608e704b.js} +1 -1
- package/dist/cjs/{design-token-351ffd2c.js → design-token-a101a8d0.js} +3 -3
- package/dist/cjs/{element-appender-slimmer-f932b166.js → element-appender-slimmer-b93cc564.js} +2 -2
- package/dist/cjs/{form-field-controller-slimmer-5adb86ae.js → form-field-controller-slimmer-124d54ea.js} +1 -1
- package/dist/cjs/{image-annotation-action-25907d6b.js → image-annotation-action-1ee41bc7.js} +2 -2
- package/dist/cjs/{image-extension-1cf84f27.js → image-extension-6a92c524.js} +247 -5
- package/dist/cjs/index.cjs.js +17 -17
- package/dist/cjs/{inject-keyboard-manager-84d33920.js → inject-keyboard-manager-32d7dd0e.js} +1 -1
- package/dist/cjs/{internal-calendar-period-factory-3c5236be.js → internal-calendar-period-factory-c3198ea7.js} +1 -1
- package/dist/cjs/{internal-translation-controller-eae8a8de.js → internal-translation-controller-0d67ca4d.js} +1 -0
- package/dist/cjs/{keyboard-manager-baa83a61.js → keyboard-manager-332eec89.js} +1 -1
- package/dist/cjs/{keyboard-manager-slimmer-d1974b28.js → keyboard-manager-slimmer-a2872981.js} +1 -1
- package/dist/cjs/{link-extension-2a6133b7.js → link-extension-1b4ed437.js} +3 -3
- package/dist/cjs/loader.cjs.js +12 -12
- package/dist/cjs/{month-view-generator-a6827548.js → month-view-generator-b6a2b8be.js} +1 -1
- package/dist/cjs/{public-rules-7f26e0ae.js → public-rules-2066613c.js} +7 -7
- package/dist/cjs/{range-518b95a2.js → range-712fe703.js} +1 -1
- package/dist/cjs/{responsive-format-facade-95c54444.js → responsive-format-facade-44d33457.js} +1 -1
- package/dist/cjs/{rich-text-editor-required-rule-5d0c76ec.js → rich-text-editor-required-rule-1aa75d22.js} +1 -1
- package/dist/cjs/{split-cell-operation-28f6f8d9.js → split-cell-operation-afc82323.js} +3 -3
- package/dist/cjs/{state-border-formatter-6c284859.js → state-border-formatter-49984fd6.js} +1 -1
- package/dist/cjs/{string-format-strategy.abstract-f15b6196.js → string-format-strategy.abstract-bd563c01.js} +1 -1
- package/dist/cjs/{string-input-formatter-slimmer-5a3f1b55.js → string-input-formatter-slimmer-4faebac9.js} +1 -1
- package/dist/cjs/{string-mask-strategy-af6f3ba0.js → string-mask-strategy-624c4398.js} +2 -2
- package/dist/cjs/{style-formatter-324211fd.js → style-formatter-151d89a3.js} +2 -2
- package/dist/cjs/{time-required-rule-9e714442.js → time-required-rule-8cd8f9b9.js} +1 -1
- package/dist/cjs/{token-extension-86723cad.js → token-extension-72d0cb08.js} +1011 -767
- package/dist/cjs/{translation-slimmer-0227ee24.js → translation-slimmer-1771d01f.js} +1 -1
- package/dist/cjs/{type-guard-29e01bd4.js → type-guard-cce6fe1f.js} +1 -1
- package/dist/cjs/{valid-credit-card-number-rule-4ec364af.js → valid-credit-card-number-rule-b13c2fc4.js} +1 -1
- package/dist/cjs/vega-accordion.cjs.entry.js +6 -6
- package/dist/cjs/vega-app-header-button.cjs.entry.js +5 -5
- package/dist/cjs/vega-box.cjs.entry.js +6 -6
- package/dist/cjs/vega-button-circle.cjs.entry.js +5 -5
- package/dist/cjs/vega-button.cjs.entry.js +3 -3
- package/dist/cjs/vega-calendar_5.cjs.entry.js +7 -7
- package/dist/cjs/vega-card.cjs.entry.js +5 -5
- package/dist/cjs/vega-carousel.cjs.entry.js +3 -3
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-chip.cjs.entry.js +5 -5
- package/dist/cjs/vega-code-block.cjs.entry.js +8 -8
- package/dist/cjs/vega-color-picker.cjs.entry.js +2 -2
- package/dist/cjs/vega-color-swatch-picker.cjs.entry.js +3 -3
- package/dist/cjs/vega-color-swatch.cjs.entry.js +2 -2
- package/dist/cjs/vega-combo-box.cjs.entry.js +8 -8
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +13 -13
- package/dist/cjs/vega-dialog_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-divider.cjs.entry.js +5 -5
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +7 -7
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-field-label.cjs.entry.js +2 -2
- package/dist/cjs/vega-file-uploader.cjs.entry.js +3 -3
- package/dist/cjs/vega-flag-icon.cjs.entry.js +5 -5
- package/dist/cjs/vega-flex.cjs.entry.js +6 -6
- package/dist/cjs/vega-font.cjs.entry.js +5 -5
- package/dist/cjs/vega-form.cjs.entry.js +2 -2
- package/dist/cjs/vega-grid.cjs.entry.js +5 -5
- package/dist/cjs/vega-icon.cjs.entry.js +5 -5
- package/dist/cjs/vega-image-uploader.cjs.entry.js +5 -5
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-numeric.cjs.entry.js +12 -14
- package/dist/cjs/vega-input-passcode.cjs.entry.js +5 -5
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +4 -4
- package/dist/cjs/vega-input-range.cjs.entry.js +3 -3
- package/dist/cjs/vega-input-select.cjs.entry.js +5 -5
- package/dist/cjs/vega-input.cjs.entry.js +31 -27
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +7 -7
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +2 -2
- package/dist/cjs/vega-pagination.cjs.entry.js +4 -4
- package/dist/cjs/vega-popover_2.cjs.entry.js +8 -8
- package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-radio_2.cjs.entry.js +5 -5
- package/dist/cjs/vega-rich-text-bookmark-editor.cjs.entry.js +2 -2
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +6 -6
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +474 -207
- package/dist/cjs/vega-rich-text-find-replace-panel.cjs.entry.js +1 -1
- package/dist/cjs/vega-rich-text-special-characters-panel.cjs.entry.js +5 -5
- package/dist/cjs/vega-rich-text-table-properties_3.cjs.entry.js +8 -8
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +3 -3
- package/dist/cjs/vega-signature-capture.cjs.entry.js +7 -7
- package/dist/cjs/vega-stepper.cjs.entry.js +2 -2
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-table_11.cjs.entry.js +4 -4
- package/dist/cjs/vega-textarea.cjs.entry.js +2 -2
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +9 -9
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +2 -2
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +6 -6
- package/dist/cjs/vega.cjs.js +12 -12
- package/dist/collection/components/vega-input/slimmers/controllers/vega-input-state-controller.js +0 -14
- package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-container-renderer.js +11 -2
- package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-renderer.js +11 -1
- package/dist/collection/components/vega-input/vega-input.js +52 -8
- package/dist/collection/components/vega-input-numeric/slimmers/renderers/vega-input-numeric-renderer.js +7 -1
- package/dist/collection/components/vega-input-numeric/vega-input-numeric.js +0 -8
- package/dist/collection/components/vega-rich-text-editor/constants/constant.js +4 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/sequential-composition-strategy.js +31 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/sequential-composition-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +4 -1
- package/dist/collection/components/vega-rich-text-editor/dto/flush-changes-payload.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/dto/function-block.js +30 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/element-to-dto-strategies/div-to-function-block-strategy.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/controllers/chooser-positioner.js +107 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/controllers/paste-chooser-controller.js +91 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/controllers/paste-event-interceptor.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/controllers/selection-snapshot-service.js +54 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/image-extractor.js +17 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/paste-chooser-ui.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/paste-extension.js +41 -354
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/pipeline/data-transfer-builder.js +36 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/pipeline/paste-dispatcher.js +23 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/pipeline/paste-processing-pipeline.js +30 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/paste-processing-strategy.abstract.js +34 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/paste-strategy-selector.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/strategies/plain-paste-strategy.js +74 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/paste/type.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/helpers/utils.js +67 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/abstract-delete-content-handler.js +67 -11
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/backward-delete-content-handler.js +4 -17
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/base-handler.js +34 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/forward-delete-content-handler.js +13 -32
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-line-break-handler.js +60 -25
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paragraph-handler.js +55 -19
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.js +165 -59
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-text-handler.js +55 -21
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.js +2 -16
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/value-controller.js +11 -1
- package/dist/collection/components/vega-rich-text-editor/utils/html-to-plain-text-utils.js +240 -0
- package/dist/collection/helpers/translation/locales/en.js +1 -0
- package/dist/esm/{app-globals-da5c83c2.js → app-globals-8cdfc5c9.js} +10 -10
- package/dist/esm/{code-block-d8f83d85.js → code-block-9360c331.js} +74 -2
- package/dist/esm/{component-value-history-controller-slimmer.abstract-642e7147.js → component-value-history-controller-slimmer.abstract-9ea58806.js} +3 -3
- package/dist/esm/{content-state-486eae1d.js → content-state-67a12e74.js} +38 -5
- package/dist/esm/{date-required-rule-08695d25.js → date-required-rule-66b5bf02.js} +1 -1
- package/dist/esm/{design-token-df3331d9.js → design-token-acd1efeb.js} +3 -3
- package/dist/esm/{element-appender-slimmer-f02a227f.js → element-appender-slimmer-7e5bc1e9.js} +2 -2
- package/dist/esm/{form-field-controller-slimmer-a7c0a0f8.js → form-field-controller-slimmer-d653c494.js} +1 -1
- package/dist/esm/{image-annotation-action-df744ba5.js → image-annotation-action-9525be48.js} +2 -2
- package/dist/esm/{image-extension-20b39140.js → image-extension-aea75132.js} +246 -6
- package/dist/esm/index.js +17 -17
- package/dist/esm/{inject-keyboard-manager-399ed867.js → inject-keyboard-manager-f6522d2f.js} +1 -1
- package/dist/esm/{internal-calendar-period-factory-7b866c3b.js → internal-calendar-period-factory-261df2f2.js} +1 -1
- package/dist/esm/{internal-translation-controller-4a7ee4d5.js → internal-translation-controller-3637e47e.js} +1 -0
- package/dist/esm/{keyboard-manager-f5d13a34.js → keyboard-manager-53e8d8d0.js} +1 -1
- package/dist/esm/{keyboard-manager-slimmer-f40dcb54.js → keyboard-manager-slimmer-b3de042d.js} +1 -1
- package/dist/esm/{link-extension-3f93d70d.js → link-extension-57ba9520.js} +3 -3
- package/dist/esm/loader.js +12 -12
- package/dist/esm/{month-view-generator-0c665987.js → month-view-generator-15215a09.js} +1 -1
- package/dist/esm/{public-rules-470a1dac.js → public-rules-c77a1550.js} +7 -7
- package/dist/esm/{range-8e89fb54.js → range-3c74e1c8.js} +1 -1
- package/dist/esm/{responsive-format-facade-55131a33.js → responsive-format-facade-1b325d06.js} +1 -1
- package/dist/esm/{rich-text-editor-required-rule-06caf383.js → rich-text-editor-required-rule-cfd32ba2.js} +1 -1
- package/dist/esm/{split-cell-operation-e158366a.js → split-cell-operation-85a036f9.js} +3 -3
- package/dist/esm/{state-border-formatter-2b73fa08.js → state-border-formatter-ce3495b0.js} +1 -1
- package/dist/esm/{string-format-strategy.abstract-8c7937e3.js → string-format-strategy.abstract-8ce04558.js} +1 -1
- package/dist/esm/{string-input-formatter-slimmer-681c6b71.js → string-input-formatter-slimmer-0d60ba7d.js} +1 -1
- package/dist/esm/{string-mask-strategy-b8cceee6.js → string-mask-strategy-cabc1d50.js} +2 -2
- package/dist/esm/{style-formatter-fcd70869.js → style-formatter-00fe4f1c.js} +2 -2
- package/dist/esm/{time-required-rule-ce50859b.js → time-required-rule-57ceeae9.js} +1 -1
- package/dist/esm/{token-extension-2401e753.js → token-extension-645a9520.js} +1011 -767
- package/dist/esm/{translation-slimmer-b3f3cf65.js → translation-slimmer-b69057eb.js} +1 -1
- package/dist/esm/{type-guard-08c82e08.js → type-guard-204094c6.js} +1 -1
- package/dist/esm/{valid-credit-card-number-rule-66bad519.js → valid-credit-card-number-rule-0874e19f.js} +1 -1
- package/dist/esm/vega-accordion.entry.js +6 -6
- package/dist/esm/vega-app-header-button.entry.js +5 -5
- package/dist/esm/vega-box.entry.js +6 -6
- package/dist/esm/vega-button-circle.entry.js +5 -5
- package/dist/esm/vega-button.entry.js +3 -3
- package/dist/esm/vega-calendar_5.entry.js +7 -7
- package/dist/esm/vega-card.entry.js +5 -5
- package/dist/esm/vega-carousel.entry.js +3 -3
- package/dist/esm/vega-checkbox_2.entry.js +2 -2
- package/dist/esm/vega-chip.entry.js +5 -5
- package/dist/esm/vega-code-block.entry.js +8 -8
- package/dist/esm/vega-color-picker.entry.js +2 -2
- package/dist/esm/vega-color-swatch-picker.entry.js +3 -3
- package/dist/esm/vega-color-swatch.entry.js +2 -2
- package/dist/esm/vega-combo-box.entry.js +8 -8
- package/dist/esm/vega-date-picker_2.entry.js +13 -13
- package/dist/esm/vega-dialog_2.entry.js +3 -3
- package/dist/esm/vega-divider.entry.js +5 -5
- package/dist/esm/vega-dropdown_5.entry.js +7 -7
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-field-label.entry.js +2 -2
- package/dist/esm/vega-file-uploader.entry.js +3 -3
- package/dist/esm/vega-flag-icon.entry.js +5 -5
- package/dist/esm/vega-flex.entry.js +6 -6
- package/dist/esm/vega-font.entry.js +5 -5
- package/dist/esm/vega-form.entry.js +2 -2
- package/dist/esm/vega-grid.entry.js +5 -5
- package/dist/esm/vega-icon.entry.js +5 -5
- package/dist/esm/vega-image-uploader.entry.js +5 -5
- package/dist/esm/vega-input-credit-card.entry.js +6 -6
- package/dist/esm/vega-input-numeric.entry.js +12 -14
- package/dist/esm/vega-input-passcode.entry.js +5 -5
- package/dist/esm/vega-input-phone-number.entry.js +4 -4
- package/dist/esm/vega-input-range.entry.js +3 -3
- package/dist/esm/vega-input-select.entry.js +5 -5
- package/dist/esm/vega-input.entry.js +31 -27
- package/dist/esm/vega-left-nav_5.entry.js +7 -7
- package/dist/esm/vega-loader-wrapper_2.entry.js +3 -3
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +2 -2
- package/dist/esm/vega-pagination.entry.js +4 -4
- package/dist/esm/vega-popover_2.entry.js +8 -8
- package/dist/esm/vega-progress-tracker_2.entry.js +3 -3
- package/dist/esm/vega-radio_2.entry.js +5 -5
- package/dist/esm/vega-rich-text-bookmark-editor.entry.js +2 -2
- package/dist/esm/vega-rich-text-content.entry.js +6 -6
- package/dist/esm/vega-rich-text-editor_4.entry.js +474 -207
- package/dist/esm/vega-rich-text-find-replace-panel.entry.js +1 -1
- package/dist/esm/vega-rich-text-special-characters-panel.entry.js +5 -5
- package/dist/esm/vega-rich-text-table-properties_3.entry.js +8 -8
- package/dist/esm/vega-selection-chip_2.entry.js +4 -4
- package/dist/esm/vega-selection-tile_2.entry.js +2 -2
- package/dist/esm/vega-sidenav_3.entry.js +3 -3
- package/dist/esm/vega-signature-capture.entry.js +7 -7
- package/dist/esm/vega-stepper.entry.js +2 -2
- package/dist/esm/vega-tab-group_2.entry.js +6 -6
- package/dist/esm/vega-table_11.entry.js +4 -4
- package/dist/esm/vega-textarea.entry.js +2 -2
- package/dist/esm/vega-time-picker_2.entry.js +9 -9
- package/dist/esm/vega-toggle-switch.entry.js +2 -2
- package/dist/esm/vega-tooltip_2.entry.js +6 -6
- package/dist/esm/vega.js +12 -12
- package/dist/sri/vega-sri-manifest.json +321 -321
- package/dist/types/components/vega-input/slimmers/controllers/vega-input-state-controller.d.ts +0 -2
- package/dist/types/components/vega-input/slimmers/renderers/vega-input-input-container-renderer.d.ts +4 -0
- package/dist/types/components/vega-input/slimmers/renderers/vega-input-input-renderer.d.ts +2 -0
- package/dist/types/components/vega-input/vega-input.d.ts +15 -3
- package/dist/types/components/vega-input-numeric/slimmers/renderers/vega-input-numeric-renderer.d.ts +2 -0
- package/dist/types/components/vega-input-numeric/vega-input-numeric.d.ts +0 -2
- package/dist/types/components/vega-rich-text-editor/constants/constant.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/sequential-composition-strategy.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.d.ts +4 -1
- package/dist/types/components/vega-rich-text-editor/dto/actions/sequential-composition-action.d.ts +30 -0
- package/dist/types/components/vega-rich-text-editor/dto/flush-changes-payload.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/extensions/functions/dto/function-block.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/controllers/chooser-positioner.d.ts +33 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/controllers/paste-chooser-controller.d.ts +43 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/controllers/paste-event-interceptor.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/controllers/selection-snapshot-service.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/image-extractor.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/paste-image-parser.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/paste/parse-local-images-helper/pending-image-registry.d.ts +1 -1
- package/dist/types/components/vega-rich-text-editor/extensions/paste/paste-chooser-ui.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/paste-extension.d.ts +28 -93
- package/dist/types/components/vega-rich-text-editor/extensions/paste/pipeline/data-transfer-builder.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/pipeline/paste-dispatcher.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/pipeline/paste-processing-pipeline.d.ts +18 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/paste-processing-strategy.abstract.d.ts +28 -6
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/paste-strategy-selector.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/strategies/plain-paste-strategy.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/extensions/paste/type.d.ts +35 -0
- package/dist/types/components/vega-rich-text-editor/helpers/utils.d.ts +47 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/abstract-delete-content-handler.d.ts +17 -6
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/backward-delete-content-handler.d.ts +5 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/base-handler.d.ts +30 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/forward-delete-content-handler.d.ts +5 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-line-break-handler.d.ts +21 -4
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paragraph-handler.d.ts +12 -4
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.d.ts +38 -5
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-text-handler.d.ts +7 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.d.ts +2 -0
- package/dist/types/components/vega-rich-text-editor/utils/html-to-plain-text-utils.d.ts +31 -0
- package/dist/types/components.d.ts +24 -0
- package/dist/types/helpers/translation/interface.d.ts +1 -0
- package/dist/types/types/public-api.d.ts +2 -1
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-8a4cc7c2.entry.js → p-0169f71c.entry.js} +1 -1
- package/dist/vega/p-018bb83b.entry.js +1 -0
- package/dist/vega/{p-25e51acb.js → p-08bf08d2.js} +1 -1
- package/dist/vega/{p-85a940c0.entry.js → p-0b33753f.entry.js} +1 -1
- package/dist/vega/{p-a5fa260b.js → p-1537b1e4.js} +1 -1
- package/dist/vega/{p-7dfb1481.entry.js → p-17f6dc94.entry.js} +1 -1
- package/dist/vega/{p-dd673eb4.entry.js → p-1a4d1991.entry.js} +1 -1
- package/dist/vega/{p-557b64bd.js → p-1b2e5898.js} +1 -1
- package/dist/vega/{p-2256eb09.entry.js → p-1f1f93bf.entry.js} +1 -1
- package/dist/vega/{p-d86e0b01.js → p-1fb953f8.js} +1 -1
- package/dist/vega/{p-03efc67a.entry.js → p-2171b571.entry.js} +1 -1
- package/dist/vega/p-255fe20b.js +1 -0
- package/dist/vega/{p-cf5c5515.js → p-261cf764.js} +1 -1
- package/dist/vega/{p-f0b49ae4.entry.js → p-27e77ea1.entry.js} +1 -1
- package/dist/vega/{p-109f0e33.entry.js → p-28acbe42.entry.js} +1 -1
- package/dist/vega/{p-27c9c2a5.entry.js → p-2acc600a.entry.js} +1 -1
- package/dist/vega/p-2fc2299f.js +1 -0
- package/dist/vega/{p-b48caf90.entry.js → p-2ff659a1.entry.js} +1 -1
- package/dist/vega/{p-527c3211.entry.js → p-322da1eb.entry.js} +1 -1
- package/dist/vega/{p-dffe47db.js → p-3283fa2f.js} +1 -1
- package/dist/vega/p-3567dc55.entry.js +1 -0
- package/dist/vega/{p-c6419eb3.entry.js → p-36b795c6.entry.js} +1 -1
- package/dist/vega/p-37714a3a.js +1 -0
- package/dist/vega/{p-d7e59f31.js → p-3b4e2ba0.js} +1 -1
- package/dist/vega/{p-3d060d2f.entry.js → p-3b911043.entry.js} +1 -1
- package/dist/vega/{p-5c6d36ef.entry.js → p-3e270b65.entry.js} +1 -1
- package/dist/vega/{p-b68f55e2.js → p-4043508a.js} +1 -1
- package/dist/vega/p-4151d4a8.js +1 -0
- package/dist/vega/{p-c6b6987e.js → p-45af801f.js} +1 -1
- package/dist/vega/p-48c2150b.entry.js +1 -0
- package/dist/vega/p-4b253f74.entry.js +1 -0
- package/dist/vega/{p-75c7f8ea.entry.js → p-4cdc064d.entry.js} +1 -1
- package/dist/vega/{p-1d8a8507.entry.js → p-4e4b50f3.entry.js} +1 -1
- package/dist/vega/{p-d8fa2f19.entry.js → p-564110ba.entry.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-bec31ffc.entry.js → p-608d3559.entry.js} +1 -1
- package/dist/vega/{p-3ce7521e.entry.js → p-64eb05d3.entry.js} +1 -1
- package/dist/vega/{p-2f5c4b61.entry.js → p-66bf209b.entry.js} +1 -1
- package/dist/vega/{p-83f5ef3a.entry.js → p-69eadbd8.entry.js} +1 -1
- package/dist/vega/{p-c66c6fd2.entry.js → p-6c4edee8.entry.js} +1 -1
- package/dist/vega/p-6e16bb3a.js +1 -0
- package/dist/vega/{p-7d748545.entry.js → p-76f4fdba.entry.js} +1 -1
- package/dist/vega/{p-4c6989ae.entry.js → p-7874055b.entry.js} +1 -1
- package/dist/vega/{p-ca60a74b.entry.js → p-7d3d24f6.entry.js} +1 -1
- package/dist/vega/{p-3bfb53e3.js → p-7f9ad7bc.js} +1 -1
- package/dist/vega/{p-18ddc6a4.entry.js → p-8193f4ef.entry.js} +1 -1
- package/dist/vega/{p-816064f2.entry.js → p-8197d172.entry.js} +1 -1
- package/dist/vega/{p-634b138c.entry.js → p-8ac0b1b2.entry.js} +1 -1
- package/dist/vega/{p-553510d8.entry.js → p-8c61db9d.entry.js} +1 -1
- package/dist/vega/{p-061a76c3.entry.js → p-8de29082.entry.js} +1 -1
- package/dist/vega/{p-325b804d.entry.js → p-8e59606f.entry.js} +1 -1
- package/dist/vega/p-8ea41806.js +1 -0
- package/dist/vega/{p-ff9090af.entry.js → p-9153c2f5.entry.js} +1 -1
- package/dist/vega/{p-a0c87e88.entry.js → p-92411f56.entry.js} +1 -1
- package/dist/vega/{p-049e64b1.entry.js → p-94d65dcf.entry.js} +1 -1
- package/dist/vega/{p-a261a675.entry.js → p-9a96fb05.entry.js} +1 -1
- package/dist/vega/{p-7044bb48.js → p-9fcfd738.js} +1 -1
- package/dist/vega/{p-b1e1c7d0.js → p-a2c7a3bc.js} +1 -1
- package/dist/vega/p-a2dcde12.js +1 -0
- package/dist/vega/{p-be0eb72f.js → p-a60d75d9.js} +1 -1
- package/dist/vega/{p-5a347a15.js → p-a9fc4043.js} +1 -1
- package/dist/vega/{p-efef0dfe.entry.js → p-abe5f7f0.entry.js} +1 -1
- package/dist/vega/{p-197388a5.entry.js → p-ac98c189.entry.js} +1 -1
- package/dist/vega/{p-dd273d89.entry.js → p-ade903b3.entry.js} +1 -1
- package/dist/vega/{p-c0eb8c58.js → p-affb40e8.js} +1 -1
- package/dist/vega/{p-277aab9b.js → p-b3a1cd22.js} +1 -1
- package/dist/vega/p-b63a90b3.entry.js +1 -0
- package/dist/vega/{p-f9f96030.entry.js → p-ba050d63.entry.js} +1 -1
- package/dist/vega/{p-bf0b46c1.js → p-ba67eb96.js} +1 -1
- package/dist/vega/{p-f0c6e9c5.entry.js → p-c08ac33f.entry.js} +1 -1
- package/dist/vega/{p-46be74fc.entry.js → p-c7ec97d1.entry.js} +1 -1
- package/dist/vega/{p-effbfc50.entry.js → p-ca1fe571.entry.js} +1 -1
- package/dist/vega/{p-408c3ad4.entry.js → p-cc9fc36a.entry.js} +1 -1
- package/dist/vega/{p-741e064e.entry.js → p-d044d54f.entry.js} +1 -1
- package/dist/vega/{p-0e0e66c9.entry.js → p-d3a9355c.entry.js} +1 -1
- package/dist/vega/p-d5a75228.js +1 -0
- package/dist/vega/{p-76135e80.entry.js → p-dc83fa6b.entry.js} +1 -1
- package/dist/vega/{p-92efdbf0.entry.js → p-dcfce26e.entry.js} +1 -1
- package/dist/vega/p-df9585f6.js +3 -0
- package/dist/vega/{p-f5f26b44.entry.js → p-e2c8a470.entry.js} +1 -1
- package/dist/vega/{p-23781e76.js → p-e33a954f.js} +1 -1
- package/dist/vega/{p-e577dda8.entry.js → p-e5fc6583.entry.js} +1 -1
- package/dist/vega/p-e668cf11.js +1 -0
- package/dist/vega/{p-0338f621.entry.js → p-e6b0a292.entry.js} +1 -1
- package/dist/vega/{p-381d8781.js → p-e84c2589.js} +1 -1
- package/dist/vega/{p-1b97e751.entry.js → p-eb945d34.entry.js} +1 -1
- package/dist/vega/{p-d8a0e3e0.entry.js → p-ebe1dd2b.entry.js} +1 -1
- package/dist/vega/{p-6beaf1c8.entry.js → p-f818bb20.entry.js} +1 -1
- package/dist/vega/p-f981cf2c.js +1 -0
- package/dist/vega/p-f9d09b0c.js +1 -0
- package/dist/vega/{p-4d20a56f.js → p-fdbdf12f.js} +1 -1
- package/dist/vega/{p-48100d38.entry.js → p-fee080b9.entry.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/vega/p-040bd9ca.js +0 -1
- package/dist/vega/p-087240db.js +0 -1
- package/dist/vega/p-15052b2e.entry.js +0 -1
- package/dist/vega/p-28c16885.js +0 -1
- package/dist/vega/p-30cc31dd.entry.js +0 -1
- package/dist/vega/p-3ec4d710.js +0 -1
- package/dist/vega/p-43ea1e86.js +0 -1
- package/dist/vega/p-7228088b.entry.js +0 -1
- package/dist/vega/p-7f711049.js +0 -1
- package/dist/vega/p-7fd15dd1.js +0 -1
- package/dist/vega/p-85695819.js +0 -1
- package/dist/vega/p-8e1f30ec.entry.js +0 -1
- package/dist/vega/p-9680dfe6.js +0 -1
- package/dist/vega/p-ae12cc3f.js +0 -3
- package/dist/vega/p-c0823f32.js +0 -1
- package/dist/vega/p-c5af2ecc.entry.js +0 -1
- package/dist/vega/p-fa43272c.js +0 -1
package/dist/collection/components/vega-rich-text-editor/extensions/paste/paste-extension.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { VegaRTEExtension } from '../extension.abstract';
|
|
2
|
-
import { RTEPasteChooserUI } from './paste-chooser-ui';
|
|
3
|
-
import { RTE_PASTE_MODE_DATA_TYPE } from '../../constants/constant';
|
|
4
2
|
import { PasteStrategySelector } from './strategies/paste-strategy-selector';
|
|
5
|
-
import { RTEPasteMode, } from './strategies/paste-processing-strategy.abstract';
|
|
6
3
|
import { PasteImageParser } from './parse-local-images-helper/paste-image-parser';
|
|
7
4
|
import { RTEImageNode } from '../../dto/nodes/image-node';
|
|
8
5
|
import { REPLACE_IMAGE_SRC } from './actions/image-replace-src-action';
|
|
9
6
|
import { ImageReplaceSrcStrategy } from './action-handler-strategies/image-replace-src-strategy';
|
|
10
7
|
import { PendingImageRegistry } from './parse-local-images-helper/pending-image-registry';
|
|
8
|
+
import { ChooserPositioner } from './controllers/chooser-positioner';
|
|
9
|
+
import { ImageExtractor } from './parse-local-images-helper/image-extractor';
|
|
10
|
+
import { PasteProcessingPipeline } from './pipeline/paste-processing-pipeline';
|
|
11
|
+
import { PasteDataTransferBuilder } from './pipeline/data-transfer-builder';
|
|
12
|
+
import { PasteDispatcher } from './pipeline/paste-dispatcher';
|
|
13
|
+
import { SelectionSnapshotService } from './controllers/selection-snapshot-service';
|
|
14
|
+
import { PasteEventInterceptor } from './controllers/paste-event-interceptor';
|
|
15
|
+
import { PasteChooserController } from './controllers/paste-chooser-controller';
|
|
11
16
|
/**
|
|
12
17
|
* Vega Rich Text Editor paste extension.
|
|
13
18
|
* Intercepts keyboard paste and allows users to choose paste mode.
|
|
@@ -17,16 +22,7 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
17
22
|
super();
|
|
18
23
|
this.editableEl = null;
|
|
19
24
|
this.contentHostEl = null;
|
|
20
|
-
this.chooserUI = null;
|
|
21
25
|
this.pendingPastePayload = null;
|
|
22
|
-
this.listenerDocument = null;
|
|
23
|
-
this.listenerWindow = null;
|
|
24
|
-
this.options = {};
|
|
25
|
-
this.strategySelector = new PasteStrategySelector();
|
|
26
|
-
this.clipboardFileContent = null;
|
|
27
|
-
this.imageParser = new PasteImageParser();
|
|
28
|
-
/** Owns pending pasted-image previews awaiting upload and their URL replacement. */
|
|
29
|
-
this.pendingImageRegistry = new PendingImageRegistry();
|
|
30
26
|
/**
|
|
31
27
|
* Handles a native paste event by capturing the clipboard payload and
|
|
32
28
|
* rendering the paste-mode chooser.
|
|
@@ -34,33 +30,7 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
34
30
|
* @param {ClipboardEvent} event Native clipboard paste event.
|
|
35
31
|
*/
|
|
36
32
|
this.handlePasteEvent = (event) => {
|
|
37
|
-
|
|
38
|
-
const clipboardData = event.clipboardData;
|
|
39
|
-
if (!clipboardData) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// HTML is sanitized via DOMParser and ElementToDtoStrategyProcessor pipeline
|
|
43
|
-
const html = clipboardData.getData('text/html') || '';
|
|
44
|
-
const text = clipboardData.getData('text/plain') || '';
|
|
45
|
-
// RTF must be read synchronously here: the paste event's DataTransfer is only
|
|
46
|
-
// readable during event dispatch, so reading it later (after the chooser) returns ''.
|
|
47
|
-
const rtf = clipboardData.getData('text/rtf') || '';
|
|
48
|
-
if (!html && !text) {
|
|
49
|
-
// Empty clipboard paste should not mutate editor content.
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
event.stopPropagation();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
event.preventDefault();
|
|
55
|
-
event.stopPropagation();
|
|
56
|
-
const range = this.cloneCurrentSelectionRange();
|
|
57
|
-
const selectedNodes = ((_b = (_a = this.extensionContext) === null || _a === void 0 ? void 0 : _a.getSelectedNodes) === null || _b === void 0 ? void 0 : _b.call(_a)) || [];
|
|
58
|
-
this.pendingPastePayload = { html, text, range, selectedNodes: [...selectedNodes] };
|
|
59
|
-
this.clipboardFileContent = {
|
|
60
|
-
files: clipboardData.files ? Array.from(clipboardData.files) : [],
|
|
61
|
-
rtf,
|
|
62
|
-
};
|
|
63
|
-
this.renderPasteChooser(event);
|
|
33
|
+
this.pasteEventInterceptor.handlePasteEvent(event);
|
|
64
34
|
};
|
|
65
35
|
/**
|
|
66
36
|
* Dismisses the chooser when a pointer interaction occurs outside of it.
|
|
@@ -68,14 +38,7 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
68
38
|
* @param {Event} event Pointer event captured on the document.
|
|
69
39
|
*/
|
|
70
40
|
this.handleOutsidePointerDown = (event) => {
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const eventPath = typeof event.composedPath === 'function' ? event.composedPath() : [];
|
|
75
|
-
if (this.chooserUI.includesEventPath(eventPath)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.clearPasteChooser();
|
|
41
|
+
this.pasteChooserController.handleOutsidePointerDown(event);
|
|
79
42
|
};
|
|
80
43
|
/**
|
|
81
44
|
* Dismisses the chooser when the Escape key is pressed.
|
|
@@ -83,17 +46,30 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
83
46
|
* @param {KeyboardEvent} event Keyboard event captured on the document.
|
|
84
47
|
*/
|
|
85
48
|
this.handleOutsideKeyDown = (event) => {
|
|
86
|
-
|
|
87
|
-
this.clearPasteChooser();
|
|
88
|
-
}
|
|
49
|
+
this.pasteChooserController.handleOutsideKeyDown(event);
|
|
89
50
|
};
|
|
90
51
|
/**
|
|
91
52
|
* Dismisses the chooser when any relevant scroll container scrolls.
|
|
92
53
|
*/
|
|
93
54
|
this.handleOutsideScroll = () => {
|
|
94
|
-
this.
|
|
55
|
+
this.pasteChooserController.handleOutsideScroll();
|
|
95
56
|
};
|
|
96
57
|
this.options = options;
|
|
58
|
+
this.strategySelector = new PasteStrategySelector();
|
|
59
|
+
this.imageParser = new PasteImageParser();
|
|
60
|
+
this.pendingImageRegistry = new PendingImageRegistry();
|
|
61
|
+
this.chooserPositioner = new ChooserPositioner(() => this.hostEl, () => { var _a, _b; return (_b = (_a = this.pendingPastePayload) === null || _a === void 0 ? void 0 : _a.range) !== null && _b !== void 0 ? _b : this.cloneCurrentSelectionRange(); });
|
|
62
|
+
this.processingPipeline = new PasteProcessingPipeline(this.strategySelector, new ImageExtractor(this.imageParser), this.pendingImageRegistry);
|
|
63
|
+
this.dataTransferBuilder = new PasteDataTransferBuilder();
|
|
64
|
+
this.pasteDispatcher = new PasteDispatcher();
|
|
65
|
+
this.selectionSnapshotService = new SelectionSnapshotService(() => this.extensionContext);
|
|
66
|
+
this.pasteEventInterceptor = new PasteEventInterceptor(this.selectionSnapshotService, (payload, event) => {
|
|
67
|
+
this.pendingPastePayload = payload;
|
|
68
|
+
this.renderPasteChooser(event);
|
|
69
|
+
});
|
|
70
|
+
this.pasteChooserController = new PasteChooserController(this.chooserPositioner, (mode) => this.applyPasteMode(mode), () => {
|
|
71
|
+
this.pendingPastePayload = null;
|
|
72
|
+
});
|
|
97
73
|
}
|
|
98
74
|
/** @inheritDoc */
|
|
99
75
|
initialExtensionAfterLoad(context) {
|
|
@@ -107,6 +83,10 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
107
83
|
this.clearPasteChooser();
|
|
108
84
|
this.pendingImageRegistry.discardUnsentPreviews();
|
|
109
85
|
}
|
|
86
|
+
/** @returns {RTEPasteChooserUI | null} Currently open chooser UI, or `null` when closed. */
|
|
87
|
+
get chooserUI() {
|
|
88
|
+
return this.pasteChooserController.ui;
|
|
89
|
+
}
|
|
110
90
|
/**
|
|
111
91
|
* Attaches the paste listener to the editable element.
|
|
112
92
|
*/
|
|
@@ -114,17 +94,13 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
114
94
|
const { editableEl, contentHostEl, } = this.getEditorElements();
|
|
115
95
|
this.editableEl = editableEl;
|
|
116
96
|
this.contentHostEl = contentHostEl;
|
|
117
|
-
|
|
118
|
-
this.editableEl.addEventListener('paste', this.handlePasteEvent);
|
|
119
|
-
}
|
|
97
|
+
this.pasteEventInterceptor.attach(this.editableEl);
|
|
120
98
|
}
|
|
121
99
|
/**
|
|
122
100
|
* Detaches the paste listener from the editable element.
|
|
123
101
|
*/
|
|
124
102
|
detachPasteListener() {
|
|
125
|
-
|
|
126
|
-
this.editableEl.removeEventListener('paste', this.handlePasteEvent);
|
|
127
|
-
}
|
|
103
|
+
this.pasteEventInterceptor.detach();
|
|
128
104
|
this.editableEl = null;
|
|
129
105
|
this.contentHostEl = null;
|
|
130
106
|
}
|
|
@@ -155,12 +131,7 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
155
131
|
* @returns {Range | null} Cloned range or `null` when there is no selection.
|
|
156
132
|
*/
|
|
157
133
|
cloneCurrentSelectionRange() {
|
|
158
|
-
|
|
159
|
-
const selection = (_a = this.extensionContext) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
160
|
-
if (selection && selection.rangeCount > 0) {
|
|
161
|
-
return selection.getRangeAt(0).cloneRange();
|
|
162
|
-
}
|
|
163
|
-
return null;
|
|
134
|
+
return this.selectionSnapshotService.capture().range;
|
|
164
135
|
}
|
|
165
136
|
/**
|
|
166
137
|
* Renders the paste-mode chooser and wires up dismissal listeners.
|
|
@@ -168,145 +139,8 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
168
139
|
* @param {ClipboardEvent} pasteEvent Originating paste event used for positioning.
|
|
169
140
|
*/
|
|
170
141
|
renderPasteChooser(pasteEvent) {
|
|
171
|
-
var _a
|
|
172
|
-
|
|
173
|
-
if (!hostRoot) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
this.clearPasteChooser(false);
|
|
177
|
-
const position = this.computeChooserPosition(pasteEvent);
|
|
178
|
-
this.chooserUI = new RTEPasteChooserUI(hostRoot, {
|
|
179
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
180
|
-
onModeSelect: (mode) => {
|
|
181
|
-
this.applyPasteMode(mode);
|
|
182
|
-
},
|
|
183
|
-
}, {
|
|
184
|
-
showWordOption: ((_c = this.options) === null || _c === void 0 ? void 0 : _c.enableWordPaste) === true,
|
|
185
|
-
});
|
|
186
|
-
this.chooserUI.open(position);
|
|
187
|
-
this.listenerDocument = this.hostEl.ownerDocument;
|
|
188
|
-
this.listenerWindow = this.listenerDocument.defaultView;
|
|
189
|
-
this.listenerDocument.addEventListener('mousedown', this.handleOutsidePointerDown, true);
|
|
190
|
-
this.listenerDocument.addEventListener('keydown', this.handleOutsideKeyDown, true);
|
|
191
|
-
this.listenerDocument.addEventListener('scroll', this.handleOutsideScroll, true);
|
|
192
|
-
if (this.listenerWindow) {
|
|
193
|
-
this.listenerWindow.addEventListener('scroll', this.handleOutsideScroll, true);
|
|
194
|
-
}
|
|
195
|
-
if (this.contentHostEl) {
|
|
196
|
-
this.contentHostEl.addEventListener('scroll', this.handleOutsideScroll);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Computes the on-screen position for the chooser based on pointer or caret.
|
|
201
|
-
*
|
|
202
|
-
* @param {ClipboardEvent} event Originating paste event.
|
|
203
|
-
* @returns {ChooserPosition} Position in viewport coordinates.
|
|
204
|
-
*/
|
|
205
|
-
computeChooserPosition(event) {
|
|
206
|
-
var _a, _b, _c;
|
|
207
|
-
const hostRect = this.hostEl.getBoundingClientRect();
|
|
208
|
-
const viewportHeight = (_b = (_a = this.hostEl.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.innerHeight) !== null && _b !== void 0 ? _b : window.innerHeight;
|
|
209
|
-
const pointerEvent = event;
|
|
210
|
-
const hasPointer = typeof pointerEvent.clientX === 'number' &&
|
|
211
|
-
pointerEvent.clientX > 0 &&
|
|
212
|
-
typeof pointerEvent.clientY === 'number' &&
|
|
213
|
-
pointerEvent.clientY > 0;
|
|
214
|
-
// For keyboard-initiated paste (Command/Control+V) clientX/Y are 0, so anchor
|
|
215
|
-
// the chooser to the current caret instead of a fixed host-relative spot.
|
|
216
|
-
const caretRect = hasPointer ? null : this.getCaretRect();
|
|
217
|
-
const CHOOSER_GAP_PX = 8;
|
|
218
|
-
const CHOOSER_MIN_MARGIN_PX = 12;
|
|
219
|
-
const CHOOSER_WIDTH_PX = 220;
|
|
220
|
-
const CHOOSER_FALLBACK_OFFSET_PX = 40;
|
|
221
|
-
const CHOOSER_MIN_VISIBLE_BELOW_SPACE_PX = 88;
|
|
222
|
-
const baseLeft = hasPointer
|
|
223
|
-
? pointerEvent.clientX
|
|
224
|
-
: (_c = caretRect === null || caretRect === void 0 ? void 0 : caretRect.left) !== null && _c !== void 0 ? _c : hostRect.left + CHOOSER_MIN_MARGIN_PX;
|
|
225
|
-
const baseTop = hasPointer
|
|
226
|
-
? pointerEvent.clientY
|
|
227
|
-
: caretRect
|
|
228
|
-
? caretRect.bottom
|
|
229
|
-
: hostRect.top + CHOOSER_FALLBACK_OFFSET_PX;
|
|
230
|
-
const maxLeft = Math.max(hostRect.left + CHOOSER_MIN_MARGIN_PX, hostRect.right - CHOOSER_WIDTH_PX);
|
|
231
|
-
const left = Math.min(Math.max(baseLeft, hostRect.left + CHOOSER_MIN_MARGIN_PX), maxLeft);
|
|
232
|
-
const top = Math.max(baseTop + CHOOSER_GAP_PX, hostRect.top + CHOOSER_MIN_MARGIN_PX);
|
|
233
|
-
const availableBelow = viewportHeight - top - CHOOSER_MIN_MARGIN_PX;
|
|
234
|
-
const availableAbove = top - CHOOSER_MIN_MARGIN_PX;
|
|
235
|
-
const placement = availableBelow >= CHOOSER_MIN_VISIBLE_BELOW_SPACE_PX || availableBelow >= availableAbove
|
|
236
|
-
? ['bottom', 'top']
|
|
237
|
-
: ['top', 'bottom'];
|
|
238
|
-
return { left, top, placement };
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Resolves the bounding rect of the pending caret position.
|
|
242
|
-
*
|
|
243
|
-
* @returns {DOMRect | null} Caret rect or `null` when it cannot be determined.
|
|
244
|
-
*/
|
|
245
|
-
getCaretRect() {
|
|
246
|
-
var _a, _b;
|
|
247
|
-
const range = (_b = (_a = this.pendingPastePayload) === null || _a === void 0 ? void 0 : _a.range) !== null && _b !== void 0 ? _b : this.cloneCurrentSelectionRange();
|
|
248
|
-
if (!range) {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
const rect = range.getBoundingClientRect();
|
|
252
|
-
if (this.isUnavailableRect(rect)) {
|
|
253
|
-
// eslint-disable-next-line spellcheck/spell-checker
|
|
254
|
-
const domRectList = range.getClientRects();
|
|
255
|
-
if (domRectList.length > 0) {
|
|
256
|
-
return domRectList[0];
|
|
257
|
-
}
|
|
258
|
-
return this.getRangeContainerRect(range);
|
|
259
|
-
}
|
|
260
|
-
return rect;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Returns whether the browser could not resolve a meaningful caret rectangle.
|
|
264
|
-
*
|
|
265
|
-
* @param {DOMRect} rect Candidate caret rect.
|
|
266
|
-
* @returns {boolean} Whether the rect is unusable.
|
|
267
|
-
*/
|
|
268
|
-
isUnavailableRect(rect) {
|
|
269
|
-
return rect.width === 0 && rect.height === 0 && rect.left === 0 && rect.top === 0;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Falls back to the range container or neighbor child node bounds.
|
|
273
|
-
*
|
|
274
|
-
* @param {Range} range Caret/selection range.
|
|
275
|
-
* @returns {DOMRect | null} Best-effort caret anchor rectangle.
|
|
276
|
-
*/
|
|
277
|
-
getRangeContainerRect(range) {
|
|
278
|
-
var _a, _b, _c, _d, _e, _f;
|
|
279
|
-
const containerNode = (_a = range.startContainer) !== null && _a !== void 0 ? _a : null;
|
|
280
|
-
if (!containerNode) {
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
if (containerNode.nodeType === Node.ELEMENT_NODE) {
|
|
284
|
-
const containerElement = containerNode;
|
|
285
|
-
const previousNode = (_b = containerElement.childNodes[range.startOffset - 1]) !== null && _b !== void 0 ? _b : null;
|
|
286
|
-
const currentNode = (_c = containerElement.childNodes[range.startOffset]) !== null && _c !== void 0 ? _c : null;
|
|
287
|
-
return ((_e = (_d = this.getNodeRect(previousNode)) !== null && _d !== void 0 ? _d : this.getNodeRect(currentNode)) !== null && _e !== void 0 ? _e : this.getNodeRect(containerElement));
|
|
288
|
-
}
|
|
289
|
-
return (_f = this.getNodeRect(containerNode)) !== null && _f !== void 0 ? _f : this.getNodeRect(containerNode.parentNode);
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Returns an element-backed rectangle from a DOM node.
|
|
293
|
-
*
|
|
294
|
-
* @param {Node | null} node Candidate node.
|
|
295
|
-
* @returns {DOMRect | null} Node rectangle when resolvable.
|
|
296
|
-
*/
|
|
297
|
-
getNodeRect(node) {
|
|
298
|
-
var _a, _b;
|
|
299
|
-
if (!node) {
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
303
|
-
return (_b = (_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : null;
|
|
304
|
-
}
|
|
305
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
306
|
-
const rect = node.getBoundingClientRect();
|
|
307
|
-
return this.isUnavailableRect(rect) ? null : rect;
|
|
308
|
-
}
|
|
309
|
-
return null;
|
|
142
|
+
var _a;
|
|
143
|
+
this.pasteChooserController.open(this.hostEl, this.contentHostEl, pasteEvent, ((_a = this.options) === null || _a === void 0 ? void 0 : _a.enableWordPaste) === true);
|
|
310
144
|
}
|
|
311
145
|
/**
|
|
312
146
|
* Applies the chosen paste mode by dispatching a synthetic paste input event.
|
|
@@ -328,36 +162,13 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
328
162
|
return;
|
|
329
163
|
}
|
|
330
164
|
editableEl.focus();
|
|
331
|
-
this.
|
|
332
|
-
this.
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
: this.strategySelector.selectStrategyByType(mode);
|
|
336
|
-
let processedHtml = strategy.process(this.pendingPastePayload.html);
|
|
337
|
-
// If the strategy supports image processing and there is clipboard file content, parse local images.
|
|
338
|
-
if (strategy.supportsImageProcessing && this.clipboardFileContent) {
|
|
339
|
-
processedHtml = this.parseLocalImages(processedHtml, this.clipboardFileContent);
|
|
340
|
-
}
|
|
341
|
-
this.clipboardFileContent = null;
|
|
342
|
-
const dataTransfer = this.createDataTransfer(processedHtml, this.pendingPastePayload.text, strategy.type);
|
|
343
|
-
this.dispatchBeforeInputPaste(editableEl, dataTransfer);
|
|
165
|
+
this.selectionSnapshotService.restore(this.pendingPastePayload);
|
|
166
|
+
const output = this.processingPipeline.process(this.pendingPastePayload, mode);
|
|
167
|
+
const dataTransfer = this.dataTransferBuilder.build(output);
|
|
168
|
+
this.pasteDispatcher.dispatch(editableEl, dataTransfer);
|
|
344
169
|
this.clearPasteChooser();
|
|
345
170
|
this.emitLocalImageInsertedEvent();
|
|
346
171
|
}
|
|
347
|
-
/**
|
|
348
|
-
* Parses local images from the HTML and emits events for further processing.
|
|
349
|
-
*
|
|
350
|
-
* @param {string} html HTML content to parse.
|
|
351
|
-
* @param {ClipboardFileContent} clipboardFileContent Clipboard file content for image extraction.
|
|
352
|
-
* @returns {string} Processed HTML with local image references replaced.
|
|
353
|
-
*/
|
|
354
|
-
parseLocalImages(html, clipboardFileContent) {
|
|
355
|
-
const { html: result, previews } = this.imageParser.parseLocalImages(html, clipboardFileContent);
|
|
356
|
-
if (previews.length > 0) {
|
|
357
|
-
this.pendingImageRegistry.register(previews);
|
|
358
|
-
}
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
172
|
/**
|
|
362
173
|
* Emits the `imageInsertedCallback` for any pending previews, allowing the
|
|
363
174
|
* consumer to upload them and resolve their URLs.
|
|
@@ -367,137 +178,13 @@ export class VegaRTEPasteExtension extends VegaRTEExtension {
|
|
|
367
178
|
this.pendingImageRegistry.notifyInserted(this.options.imageInsertedCallback, () => { var _a; return (_a = this.editableEl) !== null && _a !== void 0 ? _a : this.getEditableElement(); }, (imageElement) => this.getDTOEntityByDom(imageElement));
|
|
368
179
|
}
|
|
369
180
|
}
|
|
370
|
-
/**
|
|
371
|
-
* Restores SelectionController state from the captured selection so synthetic
|
|
372
|
-
* beforeinput paste can replace the selected content instead of appending.
|
|
373
|
-
*
|
|
374
|
-
* @param {PendingPastePayload} payload Pending paste payload.
|
|
375
|
-
*/
|
|
376
|
-
restoreSelectionControllerState(payload) {
|
|
377
|
-
if (!payload.range || !this.extensionContext) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
const rangeOptions = {
|
|
381
|
-
startNode: payload.range.startContainer,
|
|
382
|
-
endNode: payload.range.endContainer,
|
|
383
|
-
startOffset: payload.range.startOffset,
|
|
384
|
-
endOffset: payload.range.endOffset,
|
|
385
|
-
};
|
|
386
|
-
this.extensionContext.setSelectedNodes(payload.selectedNodes || [], rangeOptions);
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Restores a previously cloned selection range.
|
|
390
|
-
*
|
|
391
|
-
* @param {Range | null} range Range to restore.
|
|
392
|
-
*/
|
|
393
|
-
restoreSelectionRange(range) {
|
|
394
|
-
var _a;
|
|
395
|
-
if (!range) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
const selection = (_a = this.extensionContext) === null || _a === void 0 ? void 0 : _a.getSelection();
|
|
399
|
-
if (selection) {
|
|
400
|
-
selection.removeAllRanges();
|
|
401
|
-
selection.addRange(range);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Dispatches a synthetic `beforeinput` paste event into the editor pipeline.
|
|
406
|
-
*
|
|
407
|
-
* @param {HTMLDivElement} editableEl Editable content element.
|
|
408
|
-
* @param {DataTransfer} dataTransfer Clipboard payload for the paste.
|
|
409
|
-
*/
|
|
410
|
-
dispatchBeforeInputPaste(editableEl, dataTransfer) {
|
|
411
|
-
// This synthetic beforeinput event intentionally reuses the existing
|
|
412
|
-
// UserInputController -> insertFromPaste -> InsertPasteHandler pipeline.
|
|
413
|
-
const beforeInputEvent = new CustomEvent('beforeinput', {
|
|
414
|
-
bubbles: true,
|
|
415
|
-
cancelable: true,
|
|
416
|
-
});
|
|
417
|
-
try {
|
|
418
|
-
Object.defineProperties(beforeInputEvent, {
|
|
419
|
-
inputType: {
|
|
420
|
-
value: 'insertFromPaste',
|
|
421
|
-
configurable: true,
|
|
422
|
-
},
|
|
423
|
-
dataTransfer: {
|
|
424
|
-
value: dataTransfer,
|
|
425
|
-
configurable: true,
|
|
426
|
-
},
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
catch (_a) {
|
|
430
|
-
Object.assign(beforeInputEvent, {
|
|
431
|
-
inputType: 'insertFromPaste',
|
|
432
|
-
dataTransfer,
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
editableEl.dispatchEvent(beforeInputEvent);
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Builds a `DataTransfer` payload carrying the paste content and mode marker.
|
|
439
|
-
*
|
|
440
|
-
* @param {string} html HTML clipboard content.
|
|
441
|
-
* @param {string} text Plain text clipboard content.
|
|
442
|
-
* @param {RTEPasteMode} [mode] Selected paste mode marker.
|
|
443
|
-
* @returns {DataTransfer} Populated data transfer payload.
|
|
444
|
-
*/
|
|
445
|
-
createDataTransfer(html, text, mode) {
|
|
446
|
-
if (typeof DataTransfer !== 'undefined') {
|
|
447
|
-
const dataTransfer = new DataTransfer();
|
|
448
|
-
if (html) {
|
|
449
|
-
dataTransfer.setData('text/html', html);
|
|
450
|
-
}
|
|
451
|
-
if (text) {
|
|
452
|
-
dataTransfer.setData('text/plain', text);
|
|
453
|
-
}
|
|
454
|
-
if (mode) {
|
|
455
|
-
dataTransfer.setData(RTE_PASTE_MODE_DATA_TYPE, mode);
|
|
456
|
-
}
|
|
457
|
-
return dataTransfer;
|
|
458
|
-
}
|
|
459
|
-
return {
|
|
460
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
461
|
-
getData: (type) => {
|
|
462
|
-
if (type === 'text/html') {
|
|
463
|
-
return html;
|
|
464
|
-
}
|
|
465
|
-
if (type === 'text/plain') {
|
|
466
|
-
return text;
|
|
467
|
-
}
|
|
468
|
-
if (type === RTE_PASTE_MODE_DATA_TYPE) {
|
|
469
|
-
return mode !== null && mode !== void 0 ? mode : '';
|
|
470
|
-
}
|
|
471
|
-
return '';
|
|
472
|
-
},
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
181
|
/**
|
|
476
182
|
* Tears down the chooser UI and removes dismissal listeners.
|
|
477
183
|
*
|
|
478
184
|
* @param {boolean} [clearPayload] Whether to also clear the pending payload.
|
|
479
185
|
*/
|
|
480
186
|
clearPasteChooser(clearPayload = true) {
|
|
481
|
-
|
|
482
|
-
this.contentHostEl.removeEventListener('scroll', this.handleOutsideScroll);
|
|
483
|
-
}
|
|
484
|
-
if (this.listenerWindow) {
|
|
485
|
-
this.listenerWindow.removeEventListener('scroll', this.handleOutsideScroll, true);
|
|
486
|
-
this.listenerWindow = null;
|
|
487
|
-
}
|
|
488
|
-
if (this.listenerDocument) {
|
|
489
|
-
this.listenerDocument.removeEventListener('mousedown', this.handleOutsidePointerDown, true);
|
|
490
|
-
this.listenerDocument.removeEventListener('keydown', this.handleOutsideKeyDown, true);
|
|
491
|
-
this.listenerDocument.removeEventListener('scroll', this.handleOutsideScroll, true);
|
|
492
|
-
this.listenerDocument = null;
|
|
493
|
-
}
|
|
494
|
-
if (this.chooserUI) {
|
|
495
|
-
this.chooserUI.destroy();
|
|
496
|
-
}
|
|
497
|
-
this.chooserUI = null;
|
|
498
|
-
if (clearPayload) {
|
|
499
|
-
this.pendingPastePayload = null;
|
|
500
|
-
}
|
|
187
|
+
this.pasteChooserController.clear(clearPayload);
|
|
501
188
|
}
|
|
502
189
|
}
|
|
503
190
|
(() => {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RTE_PASTE_MODE_DATA_TYPE } from '../../../constants/constant';
|
|
2
|
+
/** Builds the DataTransfer contract consumed by InsertPasteHandler. */
|
|
3
|
+
export class PasteDataTransferBuilder {
|
|
4
|
+
/**
|
|
5
|
+
* @param {PasteOutput} output Processed paste output to serialize.
|
|
6
|
+
* @returns {DataTransfer} Data transfer payload consumed by the paste handler.
|
|
7
|
+
*/
|
|
8
|
+
build(output) {
|
|
9
|
+
// Reserved keys always win over `markers` so a strategy cannot clobber the base contract.
|
|
10
|
+
const safeMarkers = Object.assign({}, output.markers);
|
|
11
|
+
PasteDataTransferBuilder.RESERVED_KEYS.forEach((key) => delete safeMarkers[key]);
|
|
12
|
+
const values = Object.assign(Object.assign({}, safeMarkers), { 'text/html': output.html, 'text/plain': output.text, [RTE_PASTE_MODE_DATA_TYPE]: output.mode });
|
|
13
|
+
if (typeof DataTransfer !== 'undefined') {
|
|
14
|
+
const dataTransfer = new DataTransfer();
|
|
15
|
+
Object.keys(values).forEach((type) => {
|
|
16
|
+
const value = values[type];
|
|
17
|
+
if (value) {
|
|
18
|
+
dataTransfer.setData(type, value);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return dataTransfer;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
/**
|
|
25
|
+
* @param {string} type Clipboard data type to read.
|
|
26
|
+
* @returns {string} Clipboard value for the requested type.
|
|
27
|
+
*/
|
|
28
|
+
getData: (type) => { var _a; return (_a = values[type]) !== null && _a !== void 0 ? _a : ''; },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
PasteDataTransferBuilder.RESERVED_KEYS = [
|
|
33
|
+
'text/html',
|
|
34
|
+
'text/plain',
|
|
35
|
+
RTE_PASTE_MODE_DATA_TYPE,
|
|
36
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Dispatches processed paste data through the editor's existing beforeinput pipeline. */
|
|
2
|
+
export class PasteDispatcher {
|
|
3
|
+
/**
|
|
4
|
+
* @param {HTMLDivElement} editableEl Editable content element receiving the event.
|
|
5
|
+
* @param {DataTransfer} dataTransfer Processed clipboard payload.
|
|
6
|
+
*/
|
|
7
|
+
dispatch(editableEl, dataTransfer) {
|
|
8
|
+
const beforeInputEvent = new CustomEvent('beforeinput', {
|
|
9
|
+
bubbles: true,
|
|
10
|
+
cancelable: true,
|
|
11
|
+
});
|
|
12
|
+
try {
|
|
13
|
+
Object.defineProperties(beforeInputEvent, {
|
|
14
|
+
inputType: { value: 'insertFromPaste', configurable: true },
|
|
15
|
+
dataTransfer: { value: dataTransfer, configurable: true },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
Object.assign(beforeInputEvent, { inputType: 'insertFromPaste', dataTransfer });
|
|
20
|
+
}
|
|
21
|
+
editableEl.dispatchEvent(beforeInputEvent);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Selects and executes one paste strategy, then performs declared post-processing. */
|
|
2
|
+
export class PasteProcessingPipeline {
|
|
3
|
+
constructor(selector, imageExtractor, pendingImageRegistry) {
|
|
4
|
+
this.selector = selector;
|
|
5
|
+
this.imageExtractor = imageExtractor;
|
|
6
|
+
this.pendingImageRegistry = pendingImageRegistry;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @param {PendingPastePayload} payload Captured clipboard and selection data.
|
|
10
|
+
* @param {RTEPasteMode} explicitMode Paste mode selected by the user.
|
|
11
|
+
* @returns {PasteOutput} Processed paste output and image extraction metadata.
|
|
12
|
+
*/
|
|
13
|
+
process(payload, explicitMode) {
|
|
14
|
+
const input = {
|
|
15
|
+
html: payload.html,
|
|
16
|
+
text: payload.text,
|
|
17
|
+
files: payload.files,
|
|
18
|
+
rtf: payload.rtf,
|
|
19
|
+
};
|
|
20
|
+
const output = this.selector.select(input, explicitMode).transform(input);
|
|
21
|
+
if (!output.extractImages) {
|
|
22
|
+
return output;
|
|
23
|
+
}
|
|
24
|
+
const extraction = this.imageExtractor.extract(output.html, output.imagesToExtract, input.rtf);
|
|
25
|
+
if (extraction.previews.length > 0) {
|
|
26
|
+
this.pendingImageRegistry.register(extraction.previews);
|
|
27
|
+
}
|
|
28
|
+
return Object.assign(Object.assign({}, output), { html: extraction.html });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var RTEPasteMode;
|
|
2
2
|
(function (RTEPasteMode) {
|
|
3
3
|
RTEPasteMode["RICH"] = "rich";
|
|
4
|
+
RTEPasteMode["PLAIN"] = "plain";
|
|
4
5
|
RTEPasteMode["WORD"] = "word";
|
|
5
6
|
})(RTEPasteMode || (RTEPasteMode = {}));
|
|
6
7
|
/**
|
|
@@ -52,4 +53,37 @@ export class AbstractPasteProcessingStrategy {
|
|
|
52
53
|
get supportsImageProcessing() {
|
|
53
54
|
return false;
|
|
54
55
|
}
|
|
56
|
+
/** @returns {boolean} Whether this strategy consumes `text/plain` instead of `text/html` (default: false). */
|
|
57
|
+
get consumesPlainText() {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Owns the complete content policy for this paste mode. Subclasses that
|
|
62
|
+
* only need a different source string should override {@link getSourceContent}
|
|
63
|
+
* instead of re-implementing this method.
|
|
64
|
+
*
|
|
65
|
+
* @param {PasteInput} input Complete clipboard payload.
|
|
66
|
+
* @returns {PasteOutput} Complete downstream paste contract.
|
|
67
|
+
*/
|
|
68
|
+
transform(input) {
|
|
69
|
+
const content = this.getSourceContent(input);
|
|
70
|
+
return {
|
|
71
|
+
html: this.process(content),
|
|
72
|
+
text: this.consumesPlainText ? content : input.text,
|
|
73
|
+
mode: this.type,
|
|
74
|
+
markers: {},
|
|
75
|
+
extractImages: this.supportsImageProcessing,
|
|
76
|
+
imagesToExtract: this.supportsImageProcessing ? input.files : [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolves the source string passed to {@link process}. Defaults to
|
|
81
|
+
* `input.text` when {@link consumesPlainText} is true, otherwise `input.html`.
|
|
82
|
+
*
|
|
83
|
+
* @param {PasteInput} input Complete clipboard payload.
|
|
84
|
+
* @returns {string} Content to feed into `process`.
|
|
85
|
+
*/
|
|
86
|
+
getSourceContent(input) {
|
|
87
|
+
return this.consumesPlainText ? input.text : input.html;
|
|
88
|
+
}
|
|
55
89
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DefaultPasteProcessingStrategy } from './default-paste-strategy';
|
|
2
|
+
import { RTEPasteMode } from './paste-processing-strategy.abstract';
|
|
2
3
|
import { WordPasteProcessingStrategy } from './word-paste-strategy';
|
|
4
|
+
import { PlainPasteProcessingStrategy } from './plain-paste-strategy';
|
|
3
5
|
/**
|
|
4
6
|
* Centralized selector for paste processing strategies.
|
|
5
7
|
*
|
|
@@ -12,10 +14,27 @@ export class PasteStrategySelector {
|
|
|
12
14
|
constructor() {
|
|
13
15
|
this.defaultStrategy = new DefaultPasteProcessingStrategy();
|
|
14
16
|
this.strategies = [
|
|
17
|
+
new PlainPasteProcessingStrategy(),
|
|
15
18
|
new WordPasteProcessingStrategy(),
|
|
16
19
|
this.defaultStrategy, // Fallback
|
|
17
20
|
];
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Selects the strategy that will process this paste.
|
|
24
|
+
*
|
|
25
|
+
* When `explicitMode` is provided and not `rich`, the strategy registered for that mode
|
|
26
|
+
* is used. Otherwise the highest-priority strategy whose `canHandle` matches the HTML
|
|
27
|
+
* wins, falling back to the default pass-through strategy.
|
|
28
|
+
*
|
|
29
|
+
* @param {PasteInput} input Captured clipboard payload used for auto-detection.
|
|
30
|
+
* @param {RTEPasteMode} [explicitMode] Paste mode the user picked from the chooser.
|
|
31
|
+
* @returns {AbstractPasteProcessingStrategy} Strategy to run for this paste.
|
|
32
|
+
*/
|
|
33
|
+
select(input, explicitMode) {
|
|
34
|
+
return explicitMode && explicitMode !== RTEPasteMode.RICH
|
|
35
|
+
? this.selectStrategyByType(explicitMode)
|
|
36
|
+
: this.selectStrategy(input.html);
|
|
37
|
+
}
|
|
19
38
|
/**
|
|
20
39
|
* Select the appropriate strategy for the given HTML content.
|
|
21
40
|
* Returns the highest-priority strategy that can handle the content.
|