@globalpayments/vega 2.37.2 → 2.39.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-7087f121.js → app-globals-dd3e7925.js} +2 -3
- package/dist/cjs/content-state-c5b47ca1.js +6644 -0
- package/dist/cjs/{image-annotation-action-7d82f7e1.js → image-annotation-action-75b9c0d3.js} +5 -6
- package/dist/cjs/index.cjs.js +13 -14
- package/dist/cjs/loader.cjs.js +8 -9
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +1 -1
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +31 -7
- package/dist/cjs/vega-popover_2.cjs.entry.js +14 -0
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +18 -19
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +75 -79
- package/dist/cjs/vega.cjs.js +8 -9
- package/dist/collection/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.js +18 -2
- package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.js +7 -4
- package/dist/collection/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.js +4 -0
- package/dist/collection/components/vega-popover/vega-popover.js +37 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy-registry.js +52 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy.abstract.js +63 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-link-group-strategy.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy.js +32 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/image-set-annotation-map-strategy.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-split-text-strategy.js +134 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-update-annotation-map-strategy.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-blocks-strategy.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-nodes-strategy.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-image-strategy.js +54 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-node-content-strategy.js +152 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy.js +99 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-after-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-before-strategy.js +38 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-image-into-text-strategy.js +31 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-line-break-strategy.js +57 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-line-break-with-blocks-strategy.js +60 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-new-paragraph-strategy.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-nodes-after-node-strategy.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-nodes-before-node-strategy.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-merge-nodes-strategy.js +25 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-child-block-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-node-with-nodes-strategy.js +28 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-nodes-strategy.js +17 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-split-with-image-node-strategy.js +48 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-split-with-text-node-strategy.js +43 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-list-strategy.js +26 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-block-insert-image-strategy.js +32 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-line-break-strategy.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-line-break-with-blocks-strategy.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-new-paragraph-strategy.js +44 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-update-url-strategy.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-insert-image-strategy.js +22 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-delete-text-content-strategy.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-image-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-new-paragraph-strategy.js +92 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-nest-list-strategy.js +22 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-node-strategy.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-replace-nest-list-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-remove-list-item-strategy.js +27 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-list-strategy.js +36 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-paragraph-strategy.js +63 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-replace-selected-text-strategy.js +46 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-update-text-strategy.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/image-update-url-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +3 -215
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +31 -244
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +17 -155
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +33 -184
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +40 -352
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +13 -23
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +14 -6
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +23 -182
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/action-handle-strategy-registry.test.js +41 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-insert-line-break-with-blocks-strategy.test.js +24 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.js +30 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-set-annotation-map-strategy.test.js +11 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-update-url-strategy.test.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-block-strategy-register.test.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-item-strategy-register.test.js +31 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-split-text-strategy.test.js +31 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-update-annotation-map-strategy.test.js +17 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/update-selected-text-strategy.test.js +23 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +2 -2
- package/dist/collection/helpers/validator/rules/valid-phone-number-rule.js +7 -2
- package/dist/collection/helpers/validator/test/rules/valid-phone-number-rule.test.js +8 -0
- package/dist/esm/{app-globals-4cca4a96.js → app-globals-c954167a.js} +2 -3
- package/dist/esm/content-state-2edba4ec.js +6600 -0
- package/dist/esm/{form-field-controller-slimmer-3535e76a.js → form-field-controller-slimmer-7a9f2b2e.js} +1 -1
- package/dist/esm/{image-annotation-action-3da42221.js → image-annotation-action-b6668f48.js} +1 -2
- package/dist/esm/{index-6e05b241.js → index-d172bafa.js} +1 -1
- package/dist/esm/index.js +5 -6
- package/dist/esm/loader.js +9 -10
- package/dist/esm/{string-input-formatter-slimmer-d4132497.js → string-input-formatter-slimmer-418b54f0.js} +2 -2
- package/dist/esm/{sub-state-notify-slimmer-51151fc3.js → sub-state-notify-slimmer-b36fd081.js} +1 -1
- package/dist/esm/{sub-state-observer-slimmer-d77a1c46.js → sub-state-observer-slimmer-09452523.js} +1 -1
- package/dist/esm/vega-button-group_2.entry.js +3 -3
- package/dist/esm/vega-calendar_3.entry.js +3 -3
- package/dist/esm/vega-checkbox_2.entry.js +2 -2
- package/dist/esm/vega-color-picker.entry.js +2 -2
- package/dist/esm/vega-combo-box.entry.js +2 -2
- package/dist/esm/vega-date-picker_2.entry.js +5 -5
- package/dist/esm/vega-dropdown_5.entry.js +3 -3
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-file-uploader.entry.js +2 -2
- package/dist/esm/vega-form.entry.js +2 -2
- package/dist/esm/vega-image-uploader.entry.js +2 -2
- package/dist/esm/vega-input-credit-card.entry.js +2 -2
- package/dist/esm/vega-input-numeric.entry.js +3 -3
- package/dist/esm/vega-input-phone-number.entry.js +33 -9
- package/dist/esm/vega-input-range.entry.js +2 -2
- package/dist/esm/vega-input-select.entry.js +2 -2
- package/dist/esm/vega-input.entry.js +5 -5
- package/dist/esm/{vega-internal-event-id-d0690d0d.js → vega-internal-event-id-f269c42f.js} +1 -1
- package/dist/esm/vega-left-nav_5.entry.js +3 -3
- package/dist/esm/vega-popover_2.entry.js +15 -1
- package/dist/esm/vega-radio_2.entry.js +2 -2
- package/dist/esm/vega-rich-text-content.entry.js +6 -7
- package/dist/esm/vega-rich-text-editor_4.entry.js +21 -25
- package/dist/esm/vega-selection-chip_2.entry.js +4 -4
- package/dist/esm/vega-selection-tile_2.entry.js +4 -4
- package/dist/esm/vega-sidenav_3.entry.js +3 -3
- package/dist/esm/vega-signature-capture.entry.js +2 -2
- package/dist/esm/vega-stepper.entry.js +2 -2
- package/dist/esm/vega-table_8.entry.js +3 -3
- package/dist/esm/vega-textarea.entry.js +2 -2
- package/dist/esm/vega-time-picker_2.entry.js +2 -2
- package/dist/esm/vega-toggle-switch.entry.js +2 -2
- package/dist/esm/vega.js +9 -10
- package/dist/types/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.d.ts +7 -0
- package/dist/types/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.d.ts +1 -0
- package/dist/types/components/vega-popover/vega-popover.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy-registry.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy.abstract.d.ts +66 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-link-group-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/image-set-annotation-map-strategy.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-split-text-strategy.d.ts +47 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-update-annotation-map-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-blocks-strategy.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-nodes-strategy.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-image-strategy.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-node-content-strategy.d.ts +61 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-after-strategy.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-before-strategy.d.ts +23 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-image-into-text-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-line-break-strategy.d.ts +30 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-line-break-with-blocks-strategy.d.ts +36 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-new-paragraph-strategy.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-nodes-after-node-strategy.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-nodes-before-node-strategy.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-merge-nodes-strategy.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-child-block-strategy.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.d.ts +17 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-node-with-nodes-strategy.d.ts +20 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-nodes-strategy.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-split-with-image-node-strategy.d.ts +30 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-split-with-text-node-strategy.d.ts +24 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-list-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-block-insert-image-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-line-break-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-line-break-with-blocks-strategy.d.ts +27 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-new-paragraph-strategy.d.ts +21 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-update-url-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-insert-image-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-delete-text-content-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-image-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-new-paragraph-strategy.d.ts +38 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-nest-list-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-node-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-replace-nest-list-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-remove-list-item-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-list-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-paragraph-strategy.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-replace-selected-text-strategy.d.ts +20 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-update-text-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/image-update-url-action.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +1 -79
- package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +3 -77
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +0 -38
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +3 -58
- package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +5 -93
- package/dist/types/components/vega-rich-text-editor/dto/content-state.d.ts +1 -2
- package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +0 -43
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/action-handle-strategy-registry.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-insert-line-break-with-blocks-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-set-annotation-map-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-update-url-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-block-strategy-register.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-item-strategy-register.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-split-text-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-update-annotation-map-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/update-selected-text-strategy.test.d.ts +1 -0
- package/dist/types/components.d.ts +14 -0
- package/dist/types/helpers/validator/rules/valid-phone-number-rule.d.ts +3 -1
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-ba077ca8.entry.js → p-073beb31.entry.js} +1 -1
- package/dist/vega/{p-6419e13e.entry.js → p-0b697841.entry.js} +1 -1
- package/dist/vega/p-0cc1ad76.js +1 -0
- package/dist/vega/{p-29d6ec6c.js → p-239bae84.js} +1 -1
- package/dist/vega/{p-7198d675.entry.js → p-24ac5151.entry.js} +1 -1
- package/dist/vega/{p-cb4fd6e1.entry.js → p-257b1bc2.entry.js} +1 -1
- package/dist/vega/{p-ba2833c0.entry.js → p-3c85a11b.entry.js} +1 -1
- package/dist/vega/{p-b517ed15.js → p-49bf2b3a.js} +1 -1
- package/dist/vega/p-4a8db510.entry.js +1 -0
- package/dist/vega/p-4b19706c.entry.js +1 -0
- package/dist/vega/{p-bf4996d5.entry.js → p-4e436842.entry.js} +1 -1
- package/dist/vega/{p-12fe63c1.entry.js → p-59834ea4.entry.js} +1 -1
- package/dist/vega/{p-50eabdca.entry.js → p-59cfed37.entry.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-60e1ebe1.entry.js +1 -0
- package/dist/vega/{p-23fd9401.entry.js → p-629bd266.entry.js} +1 -1
- package/dist/vega/p-6408d3dc.entry.js +1 -0
- package/dist/vega/{p-3e8f9fcf.entry.js → p-64e0c944.entry.js} +1 -1
- package/dist/vega/{p-b9a0f136.entry.js → p-64e49394.entry.js} +1 -1
- package/dist/vega/p-6e5db02b.js +1 -0
- package/dist/vega/{p-9689ad99.entry.js → p-74ff73d6.entry.js} +1 -1
- package/dist/vega/{p-b809f3d7.entry.js → p-8120e7a1.entry.js} +1 -1
- package/dist/vega/p-894c067a.entry.js +1 -0
- package/dist/vega/{p-e9785742.entry.js → p-989b36a2.entry.js} +1 -1
- package/dist/vega/{p-a2a34239.entry.js → p-9ee23f34.entry.js} +1 -1
- package/dist/vega/{p-34bd9204.js → p-a9e1123a.js} +1 -1
- package/dist/vega/{p-267cde46.entry.js → p-b071be5c.entry.js} +1 -1
- package/dist/vega/{p-1b67c443.entry.js → p-b6bffdf3.entry.js} +1 -1
- package/dist/vega/{p-20326c64.js → p-bd0116f9.js} +1 -1
- package/dist/vega/{p-a7e078ac.entry.js → p-bf6d3c00.entry.js} +1 -1
- package/dist/vega/{p-ecaf4cfa.entry.js → p-c00fde35.entry.js} +1 -1
- package/dist/vega/{p-7baa4fae.entry.js → p-c2e96537.entry.js} +1 -1
- package/dist/vega/{p-3cb90bdf.entry.js → p-ce94a9c5.entry.js} +1 -1
- package/dist/vega/{p-904b489a.entry.js → p-d03945cb.entry.js} +1 -1
- package/dist/vega/p-d2e6090a.js +1 -0
- package/dist/vega/{p-348e95ba.js → p-d2ff56d8.js} +1 -1
- package/dist/vega/p-e0d3ca2d.js +1 -0
- package/dist/vega/{p-ee2e4bff.entry.js → p-ea78ddfa.entry.js} +1 -1
- package/dist/vega/{p-e9a5bd12.entry.js → p-f1ebe86b.entry.js} +1 -1
- package/dist/vega/{p-497f2f86.entry.js → p-fc49a98e.entry.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/content-state-f97d3278.js +0 -2990
- package/dist/cjs/node-annotation.abstract-4f6df9cf.js +0 -3223
- package/dist/collection/components/vega-rich-text-editor/dto/actions/clear-child-nodes-action.js +0 -12
- package/dist/collection/components/vega-rich-text-editor/dto/helper/block-base-operator.js +0 -47
- package/dist/esm/content-state-ccf5f960.js +0 -2954
- package/dist/esm/node-annotation.abstract-b2e36bc4.js +0 -3214
- package/dist/types/components/vega-rich-text-editor/dto/actions/clear-child-nodes-action.d.ts +0 -9
- package/dist/types/components/vega-rich-text-editor/dto/helper/block-base-operator.d.ts +0 -24
- package/dist/vega/p-0461e318.js +0 -1
- package/dist/vega/p-1d93b3a9.js +0 -1
- package/dist/vega/p-2fecbcf9.entry.js +0 -1
- package/dist/vega/p-52a8a4f8.js +0 -1
- package/dist/vega/p-7edcb8d0.entry.js +0 -1
- package/dist/vega/p-9728d571.entry.js +0 -1
- package/dist/vega/p-a7f40a65.entry.js +0 -1
- package/dist/vega/p-a8b16ff2.js +0 -1
- package/dist/vega/p-aed80794.entry.js +0 -1
- package/dist/vega/p-f86ec91b.js +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { InternalAnnotationTypeEnum } from '../../annotations/annotation.abstract';
|
|
2
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
3
|
+
import { TextSplittableAction } from '../../actions/splittable-action.abstract';
|
|
4
|
+
import stateEntityRenderingRegistry from '../../../slimmers/controllers/state-entity-rendering-registry';
|
|
5
|
+
/**
|
|
6
|
+
* Split the text node into two or there nodes according to the rules.
|
|
7
|
+
*/
|
|
8
|
+
export class NodeSplitTextStrategy extends ActionHandleStrategy {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
// The new create node that need apply annotation or the current target. This property used to export after the execute method invoke.
|
|
12
|
+
this.applyTargetNode = null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Split the text node.
|
|
16
|
+
*
|
|
17
|
+
* @param {TextSplittableAction} action - The split action.
|
|
18
|
+
* @param {RTETextNode} target - The text node that need to be splited.
|
|
19
|
+
* @returns {Nullable<RTETextNode>} - The new insert text node or the current text node that need to apply the action.
|
|
20
|
+
*/
|
|
21
|
+
handleAction(action, target) {
|
|
22
|
+
const selectionRangeAnnotation = target.getAnnotationByType(InternalAnnotationTypeEnum.SELECTION_RANGE);
|
|
23
|
+
this.setApplyTargetNode(null);
|
|
24
|
+
if (action instanceof TextSplittableAction && action.doSplit && selectionRangeAnnotation) {
|
|
25
|
+
const { startContainer, endContainer, startOffset, endOffset } = selectionRangeAnnotation.range;
|
|
26
|
+
const noTextRangeSelected = startContainer === endContainer && startOffset === endOffset;
|
|
27
|
+
target.parentBlock.nodes = target.parentBlock.nodes.flatMap((item) => {
|
|
28
|
+
if (item.id === target.id) {
|
|
29
|
+
if (noTextRangeSelected) {
|
|
30
|
+
return this.insertNewNode(startOffset, target);
|
|
31
|
+
}
|
|
32
|
+
if (this.shouldSplitSelection(selectionRangeAnnotation.range)) {
|
|
33
|
+
return this.splitTextNode(selectionRangeAnnotation.range, target);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.setApplyTargetNode(target);
|
|
37
|
+
return target;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return item;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return this.applyTargetNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Insert the new node at the start offset
|
|
47
|
+
*
|
|
48
|
+
* @param {number} startOffset - The start position offset
|
|
49
|
+
* @param {RTETextNode} target - RTETextNode
|
|
50
|
+
* @returns {RTETextNode[]} - RTETextNode array
|
|
51
|
+
*/
|
|
52
|
+
insertNewNode(startOffset, target) {
|
|
53
|
+
const newNode = target.cloneWithText('');
|
|
54
|
+
this.setApplyTargetNode(newNode);
|
|
55
|
+
if (startOffset === 0) {
|
|
56
|
+
return [newNode, target];
|
|
57
|
+
}
|
|
58
|
+
if (startOffset === target.text.length) {
|
|
59
|
+
return [target, newNode];
|
|
60
|
+
}
|
|
61
|
+
const beforeNode = target.cloneWithText(target.text.substring(0, startOffset));
|
|
62
|
+
const afterNode = target.cloneWithText(target.text.substring(startOffset));
|
|
63
|
+
return [beforeNode, newNode, afterNode];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a given range should be split based on various conditions within the range.
|
|
67
|
+
*
|
|
68
|
+
* @param {Range} range - Selection range
|
|
69
|
+
* @returns {boolean} Returns a boolean value indicating whether the selection range should be split.
|
|
70
|
+
*/
|
|
71
|
+
shouldSplitSelection(range) {
|
|
72
|
+
const { startContainer, endContainer, startOffset, endOffset } = range;
|
|
73
|
+
const isCrossNode = startContainer !== endContainer;
|
|
74
|
+
const isPartialStart = startOffset > 0;
|
|
75
|
+
const isPartialEnd = endOffset < (endContainer.textContent ? endContainer.textContent.length : 0);
|
|
76
|
+
const isPartialSelection = isPartialStart || isPartialEnd;
|
|
77
|
+
return isCrossNode || isPartialSelection;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Split text node with range
|
|
81
|
+
*
|
|
82
|
+
* @param {Range} range - Selection range
|
|
83
|
+
* @param {RTETextNode} target - RTETextNode
|
|
84
|
+
* @returns {RTETextNode[] | this} RTETextNode array
|
|
85
|
+
*/
|
|
86
|
+
splitTextNode(range, target) {
|
|
87
|
+
const { startContainer, endContainer, startOffset } = range;
|
|
88
|
+
const startNode = startContainer.parentElement;
|
|
89
|
+
const endNode = endContainer.parentElement;
|
|
90
|
+
/**
|
|
91
|
+
* Split the text from the start offset to the end offset
|
|
92
|
+
*
|
|
93
|
+
* @param {string} text - The text string
|
|
94
|
+
* @param {number} startOffset - The start offset position
|
|
95
|
+
* @param {number} endOffset - The end offset position
|
|
96
|
+
* @returns {RTETextNode[]} - The split text node array
|
|
97
|
+
*/
|
|
98
|
+
const splitText = (text, startOffset, endOffset) => {
|
|
99
|
+
const beforeText = text.substring(0, startOffset);
|
|
100
|
+
const selectedText = text.substring(startOffset, endOffset);
|
|
101
|
+
const afterText = text.substring(endOffset);
|
|
102
|
+
return [
|
|
103
|
+
target.cloneWithText(beforeText),
|
|
104
|
+
target.cloneWithText(selectedText),
|
|
105
|
+
target.cloneWithText(afterText),
|
|
106
|
+
];
|
|
107
|
+
};
|
|
108
|
+
const startItemDto = startNode && stateEntityRenderingRegistry.getEntityByDOM(startNode);
|
|
109
|
+
const endItemDto = endNode && stateEntityRenderingRegistry.getEntityByDOM(endNode);
|
|
110
|
+
if (startItemDto && startItemDto.id === target.id) {
|
|
111
|
+
const endOffset = startContainer === endContainer ? range.endOffset : target.text.length;
|
|
112
|
+
const [beforeNode, selectedNode, afterNode] = splitText(target.text, startOffset, endOffset);
|
|
113
|
+
this.setApplyTargetNode(selectedNode);
|
|
114
|
+
return [beforeNode, selectedNode, afterNode].filter((node) => !!node.text);
|
|
115
|
+
}
|
|
116
|
+
else if (endItemDto && endItemDto.id === target.id) {
|
|
117
|
+
const [beforeNode, selectedNode, afterNode] = splitText(target.text, 0, range.endOffset);
|
|
118
|
+
this.setApplyTargetNode(selectedNode);
|
|
119
|
+
return [beforeNode, selectedNode, afterNode].filter((node) => !!node.text);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.setApplyTargetNode(target);
|
|
123
|
+
return target;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Store the text node which need to apply the annotation. Clear the value if the input is null.
|
|
128
|
+
*
|
|
129
|
+
* @param {RTETextNode | null} node - The new text node.
|
|
130
|
+
*/
|
|
131
|
+
setApplyTargetNode(node) {
|
|
132
|
+
this.applyTargetNode = node;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isNonNullable } from '../../../../../types/type-guard';
|
|
2
|
+
import { ClearFormattingAnnotationAction } from '../../actions/clear-formatting-annotation-action';
|
|
3
|
+
import { CodeAnnotationAction } from '../../actions/code-annotation-action';
|
|
4
|
+
import { DeleteNodeAnnotationAction } from '../../actions/delete-node-annotation-action';
|
|
5
|
+
import { LinkAnnotationAction } from '../../actions/link-annotation-action';
|
|
6
|
+
import { LinkGroupAnnotationAction } from '../../actions/link-group-annotation-action';
|
|
7
|
+
import { ClearFormattingAnnotation } from '../../annotations/clear-formatting-annotation';
|
|
8
|
+
import { NodeAnnotation } from '../../annotations/node-annotation.abstract';
|
|
9
|
+
import { SelectionRangeAnnotation } from '../../annotations/selection-range-annotation';
|
|
10
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
11
|
+
/**
|
|
12
|
+
* The current strategy used to modify the text node annotation map.
|
|
13
|
+
*/
|
|
14
|
+
export class NodeUpdateAnnotationMapStrategy extends ActionHandleStrategy {
|
|
15
|
+
/**
|
|
16
|
+
* Remove or set annotation to the text node annotation map.
|
|
17
|
+
*
|
|
18
|
+
* @param {AnnotationAction} action - The annotation action instance.
|
|
19
|
+
* @param {RTETextNode} target - The current text node.
|
|
20
|
+
*/
|
|
21
|
+
handleAction(action, target) {
|
|
22
|
+
const annotation = action.toAnnotation();
|
|
23
|
+
if (action instanceof DeleteNodeAnnotationAction) {
|
|
24
|
+
target.annotationMap.delete(action.annotationType);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (annotation instanceof ClearFormattingAnnotation) {
|
|
28
|
+
annotation.items.forEach((item) => {
|
|
29
|
+
target.deleteAnnotationByType(item);
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (annotation instanceof NodeAnnotation || annotation instanceof SelectionRangeAnnotation) {
|
|
34
|
+
if (action instanceof LinkAnnotationAction) {
|
|
35
|
+
if (isNonNullable(action.newText)) {
|
|
36
|
+
target.text = action.newText;
|
|
37
|
+
}
|
|
38
|
+
target.parentBlock.apply(new LinkGroupAnnotationAction(action.link.groupKey, [target]));
|
|
39
|
+
}
|
|
40
|
+
if (action instanceof CodeAnnotationAction) {
|
|
41
|
+
this.handleAction(new ClearFormattingAnnotationAction(), target);
|
|
42
|
+
}
|
|
43
|
+
target.annotationMap.set(annotation.type, annotation);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
2
|
+
/**
|
|
3
|
+
* Append new block array to list block or VegaRTEContent instance strategy.
|
|
4
|
+
*/
|
|
5
|
+
export class BlockAppendBlocksStrategy extends ActionHandleStrategy {
|
|
6
|
+
/**
|
|
7
|
+
* @inheritDoc
|
|
8
|
+
*/
|
|
9
|
+
handleAction(action, target) {
|
|
10
|
+
const newBlocks = action.entityToBeAppended;
|
|
11
|
+
if (target.blocks) {
|
|
12
|
+
newBlocks.forEach((block) => {
|
|
13
|
+
block.parent = target;
|
|
14
|
+
});
|
|
15
|
+
const arrayFixed = target.blocks;
|
|
16
|
+
target.blocks = arrayFixed.concat(newBlocks);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
2
|
+
/**
|
|
3
|
+
* Append the nodes to the text block or image block strategy.
|
|
4
|
+
*/
|
|
5
|
+
export class BlockAppendNodesStrategy extends ActionHandleStrategy {
|
|
6
|
+
/**
|
|
7
|
+
* Append the text nodes to the text block or the image block.
|
|
8
|
+
*
|
|
9
|
+
* @param {AppendChildNodesAction} action - The remove child action instance.
|
|
10
|
+
* @param {RTETextBlock | RTEImageBlock} target - The parent block of the node that will be removed.
|
|
11
|
+
*/
|
|
12
|
+
handleAction(action, target) {
|
|
13
|
+
const nodesToBeAppended = action.entityToBeAppended;
|
|
14
|
+
nodesToBeAppended.forEach((node) => {
|
|
15
|
+
node.parentBlock = target;
|
|
16
|
+
});
|
|
17
|
+
// This line is used to fix the typescript error `This expression is not callable`. https://github.com/microsoft/TypeScript/issues/44373
|
|
18
|
+
const arrayFixed = target.nodes;
|
|
19
|
+
target.nodes = arrayFixed.concat(nodesToBeAppended);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RemoveChildAction } from '../../actions/remove-child-action';
|
|
2
|
+
import { RTEImageNode } from '../../nodes/image-node';
|
|
3
|
+
import { BlockDeleteNodeContentStrategy } from './block-delete-node-content-strategy';
|
|
4
|
+
/**
|
|
5
|
+
* The image block delete the image node strategy.
|
|
6
|
+
*/
|
|
7
|
+
export class BlockDeleteImageStrategy extends BlockDeleteNodeContentStrategy {
|
|
8
|
+
/**
|
|
9
|
+
* @inheritDoc
|
|
10
|
+
*/
|
|
11
|
+
handleAction(action, target) {
|
|
12
|
+
this.deleteNodeContent(action, target);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Deletes content from a block node based on specific conditions.
|
|
16
|
+
*
|
|
17
|
+
* @param {DeleteBlockContentAction} action - Delete block content action
|
|
18
|
+
* @param {RTEImageBlock} target - The image block.
|
|
19
|
+
*/
|
|
20
|
+
deleteNodeContent(action, target) {
|
|
21
|
+
const startContainerNode = action
|
|
22
|
+
.startContainerNode, startOffset = action.startOffset;
|
|
23
|
+
let previousNode = this.getPreviousNode(startContainerNode);
|
|
24
|
+
let nextNode = null;
|
|
25
|
+
if (startOffset === 1) {
|
|
26
|
+
const parentBlock = target;
|
|
27
|
+
if (this.isContentFirstNode(startContainerNode)) {
|
|
28
|
+
nextNode = this.getNextNode(startContainerNode);
|
|
29
|
+
}
|
|
30
|
+
if (parentBlock.nodes.length === 1) {
|
|
31
|
+
parentBlock.parent.apply(new RemoveChildAction(parentBlock));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
parentBlock.apply(new RemoveChildAction(startContainerNode));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const shouldRemoveNode = previousNode;
|
|
39
|
+
if (shouldRemoveNode && shouldRemoveNode instanceof RTEImageNode) {
|
|
40
|
+
previousNode = this.getPreviousNode(shouldRemoveNode);
|
|
41
|
+
shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
|
|
42
|
+
if (!previousNode) {
|
|
43
|
+
action.nextNode = startContainerNode;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (previousNode) {
|
|
48
|
+
action.previousNode = previousNode;
|
|
49
|
+
}
|
|
50
|
+
else if (nextNode) {
|
|
51
|
+
action.nextNode = nextNode;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
2
|
+
/**
|
|
3
|
+
* The delete node content contains some common functions that used for image block delete the image node or text block delete text node.
|
|
4
|
+
*/
|
|
5
|
+
export class BlockDeleteNodeContentStrategy extends ActionHandleStrategy {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the previous node relative to the current node in a rich text editor structure.
|
|
8
|
+
*
|
|
9
|
+
* @param {RTENode} currentNode - An object of type `RTENode`.
|
|
10
|
+
* @returns {Nullable<RTENode>} the previous block last node
|
|
11
|
+
*/
|
|
12
|
+
getPreviousNode(currentNode) {
|
|
13
|
+
const currentBlock = currentNode.parentBlock;
|
|
14
|
+
const currentIndex = currentBlock['nodes'].indexOf(currentNode);
|
|
15
|
+
if (currentIndex > 0) {
|
|
16
|
+
return currentBlock['nodes'][currentIndex - 1];
|
|
17
|
+
}
|
|
18
|
+
else if (currentBlock.parent) {
|
|
19
|
+
const previousBlock = this.getPreviousBlock(currentBlock);
|
|
20
|
+
if (previousBlock) {
|
|
21
|
+
return this.getBlockLastNode(previousBlock);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the next node relative to the current node in a rich text editor structure.
|
|
27
|
+
*
|
|
28
|
+
* @param {RTENode} currentNode - An object of type `RTENode`.
|
|
29
|
+
* @returns {Nullable<RTENode>} the next block first node
|
|
30
|
+
*/
|
|
31
|
+
getNextNode(currentNode) {
|
|
32
|
+
const currentBlock = currentNode.parentBlock;
|
|
33
|
+
const currentIndex = currentBlock['nodes'].indexOf(currentNode);
|
|
34
|
+
if (currentBlock['nodes'][currentIndex + 1]) {
|
|
35
|
+
return currentBlock['nodes'][currentIndex + 1];
|
|
36
|
+
}
|
|
37
|
+
else if (currentBlock.parent) {
|
|
38
|
+
const nextBlock = this.getNextBlock(currentBlock);
|
|
39
|
+
if (nextBlock) {
|
|
40
|
+
return this.getBlockFirstNode(nextBlock);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Determines if a given node is the first node within the current state.
|
|
46
|
+
*
|
|
47
|
+
* @param {RTENode} currentNode - An object representing a node in a rich text editor (RTE).
|
|
48
|
+
* @returns {boolean} True or false;
|
|
49
|
+
*/
|
|
50
|
+
isContentFirstNode(currentNode) {
|
|
51
|
+
const currentBlock = currentNode.parentBlock;
|
|
52
|
+
const currentIndex = currentBlock['nodes'].indexOf(currentNode);
|
|
53
|
+
const parent = currentBlock.parent;
|
|
54
|
+
if (currentBlock.type === 'list-item') {
|
|
55
|
+
const listParent = parent.parent;
|
|
56
|
+
return (currentIndex === 0 &&
|
|
57
|
+
Array.isArray(parent['blocks']) &&
|
|
58
|
+
parent['blocks'][0] === currentBlock &&
|
|
59
|
+
listParent['type'] !== 'list-item' &&
|
|
60
|
+
Array.isArray(listParent['blocks']) &&
|
|
61
|
+
listParent['blocks'][0] === parent);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return (currentIndex === 0 && Array.isArray(parent['blocks']) && parent['blocks'][0] === currentBlock);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* TODO: The getPreviousBlock add nest list support
|
|
69
|
+
* This function retrieves the previous block in a rich text editor, considering different scenarios such as being in a bullet list.
|
|
70
|
+
*
|
|
71
|
+
* @param {RTEBlock} currentBlock - Used to retrieve the previous block relative to the given `currentBlock` within a rich text editor context.
|
|
72
|
+
* @returns {Nullable<RTEBlock>} The previous block if existing
|
|
73
|
+
*/
|
|
74
|
+
getPreviousBlock(currentBlock) {
|
|
75
|
+
if (currentBlock && currentBlock.parent && currentBlock.parent['blocks']) {
|
|
76
|
+
const currentBlockIndex = currentBlock.parent['blocks'].indexOf(currentBlock);
|
|
77
|
+
if (currentBlockIndex > 0) {
|
|
78
|
+
return currentBlock.parent['blocks'][currentBlockIndex - 1];
|
|
79
|
+
}
|
|
80
|
+
else if ((currentBlock.parent['type'] === 'number-list' ||
|
|
81
|
+
currentBlock.parent['type'] === 'bullet-list') &&
|
|
82
|
+
currentBlockIndex === 0) {
|
|
83
|
+
return this.getPreviousBlock(currentBlock.parent);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the last node within a given RTE block, handling different block types accordingly.
|
|
89
|
+
*
|
|
90
|
+
* @param {RTEBlock} currentBlock - Returns the last node within that block.
|
|
91
|
+
* @returns {Nullable<RTENode>} Returns the last node of the given `currentBlock` object.
|
|
92
|
+
*/
|
|
93
|
+
getBlockLastNode(currentBlock) {
|
|
94
|
+
if (currentBlock.type === 'list-item') {
|
|
95
|
+
if (currentBlock['children'] && currentBlock['children'].length > 0) {
|
|
96
|
+
return this.getBlockLastNode(currentBlock['children'][currentBlock['children'].length - 1]);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return currentBlock['nodes'][currentBlock['nodes'].length - 1];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (currentBlock.type === 'number-list' || currentBlock.type === 'bullet-list') {
|
|
103
|
+
const listItems = currentBlock.blocks;
|
|
104
|
+
if (listItems) {
|
|
105
|
+
const lastListItem = listItems[listItems.length - 1];
|
|
106
|
+
return this.getBlockLastNode(lastListItem);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (currentBlock['nodes']) {
|
|
111
|
+
return currentBlock['nodes'][currentBlock['nodes'].length - 1];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns the first node within a given RTE block, handling different block types accordingly.
|
|
117
|
+
*
|
|
118
|
+
* @param {RTEBlock} currentBlock - Returns the first node within that block.
|
|
119
|
+
* @returns {Nullable<RTENode>} Returns the first node of the given `currentBlock` object.
|
|
120
|
+
*/
|
|
121
|
+
getBlockFirstNode(currentBlock) {
|
|
122
|
+
if (currentBlock.type === 'number-list' || currentBlock.type === 'bullet-list') {
|
|
123
|
+
if (currentBlock.blocks) {
|
|
124
|
+
const firstListItem = currentBlock.blocks[0];
|
|
125
|
+
return this.getBlockFirstNode(firstListItem);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (currentBlock['nodes']) {
|
|
130
|
+
return currentBlock['nodes'][0];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* This function retrieves the next block in a rich text editor, considering different scenarios such as being in a bullet list.
|
|
136
|
+
*
|
|
137
|
+
* @param {RTEBlock} currentBlock - Used to retrieve the next block relative to the given `currentBlock` within a rich text editor context.
|
|
138
|
+
* @returns {Nullable<RTEBlock>} The next block if existing
|
|
139
|
+
*/
|
|
140
|
+
getNextBlock(currentBlock) {
|
|
141
|
+
if (currentBlock && currentBlock.parent && currentBlock.parent['blocks']) {
|
|
142
|
+
const currentBlockIndex = currentBlock.parent['blocks'].indexOf(currentBlock);
|
|
143
|
+
if (currentBlock.parent['blocks'][currentBlockIndex + 1]) {
|
|
144
|
+
return currentBlock.parent['blocks'][currentBlockIndex + 1];
|
|
145
|
+
}
|
|
146
|
+
else if (currentBlock.type === 'list-item' &&
|
|
147
|
+
currentBlock.parent.blocks.length === currentBlockIndex + 1) {
|
|
148
|
+
return this.getNextBlock(currentBlock.parent);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { MergeTwoBlocksNodesAction } from '../../actions/merge-two-blocks-nodes-action';
|
|
2
|
+
import { RemoveChildAction } from '../../actions/remove-child-action';
|
|
3
|
+
import { UpdateTextAction } from '../../actions/update-text-action';
|
|
4
|
+
import { RTETextNode } from '../../nodes/text-node';
|
|
5
|
+
import { BlockDeleteNodeContentStrategy } from './block-delete-node-content-strategy';
|
|
6
|
+
/**
|
|
7
|
+
* The text block delete text content strategy.
|
|
8
|
+
*/
|
|
9
|
+
export class BlockDeleteTextContentStrategy extends BlockDeleteNodeContentStrategy {
|
|
10
|
+
/**
|
|
11
|
+
* @inheritDoc
|
|
12
|
+
*/
|
|
13
|
+
handleAction(action, target) {
|
|
14
|
+
this.deleteNodeContent(action, target);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Handle the delete text logic when press delete key.
|
|
18
|
+
*
|
|
19
|
+
* @param {DeleteBlockContentAction} action - ModifyContentAction
|
|
20
|
+
* @param {RTETextBlock} target - Current text block
|
|
21
|
+
*/
|
|
22
|
+
deleteNodeContent(action, target) {
|
|
23
|
+
const startContainerNode = action.startContainerNode;
|
|
24
|
+
const startOffset = action.startOffset;
|
|
25
|
+
if (startOffset !== 0 && !startContainerNode.isEmpty()) {
|
|
26
|
+
const newText = startContainerNode.text.slice(0, startOffset - 1) +
|
|
27
|
+
startContainerNode.text.slice(startOffset);
|
|
28
|
+
startContainerNode.apply(new UpdateTextAction(newText));
|
|
29
|
+
if (newText) {
|
|
30
|
+
action.previousNode = startContainerNode;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const previousNode = this.getPreviousNode(startContainerNode);
|
|
35
|
+
// Remove the last character will not delete paragraph, the paragraph will removed after press delete again
|
|
36
|
+
if ((previousNode && previousNode.parentBlock === target && previousNode['text'] === '\n') ||
|
|
37
|
+
target.nodes.length === 1) {
|
|
38
|
+
action.previousNode = startContainerNode;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
target.apply(new RemoveChildAction(startContainerNode));
|
|
43
|
+
action.previousNode = previousNode;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
let previousNode = this.getPreviousNode(startContainerNode);
|
|
50
|
+
let nextNode = null;
|
|
51
|
+
if (target.nodes.length && previousNode && previousNode.parentBlock !== target) {
|
|
52
|
+
if (startContainerNode.isEmpty()) {
|
|
53
|
+
target.apply(new RemoveChildAction(startContainerNode));
|
|
54
|
+
}
|
|
55
|
+
previousNode.parentBlock.apply(new MergeTwoBlocksNodesAction(target));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (this.isContentFirstNode(startContainerNode) && startContainerNode.isEmpty()) {
|
|
59
|
+
nextNode = this.getNextNode(startContainerNode);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Remove line break
|
|
63
|
+
*
|
|
64
|
+
* @example caret at the first line
|
|
65
|
+
* \n
|
|
66
|
+
* test
|
|
67
|
+
*/
|
|
68
|
+
if (startContainerNode.isEmpty()) {
|
|
69
|
+
target.apply(new RemoveChildAction(startContainerNode));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Remove line break
|
|
73
|
+
*
|
|
74
|
+
* @example caret at the begin of second line
|
|
75
|
+
* \n
|
|
76
|
+
* test
|
|
77
|
+
*/
|
|
78
|
+
if (previousNode instanceof RTETextNode && previousNode.isEmpty()) {
|
|
79
|
+
const shouldRemoveNode = previousNode;
|
|
80
|
+
previousNode = this.getPreviousNode(previousNode);
|
|
81
|
+
shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
|
|
82
|
+
if (!previousNode) {
|
|
83
|
+
nextNode = startContainerNode;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//Remove the paragraph block if the content is empty
|
|
88
|
+
if (target.nodes.length === 0) {
|
|
89
|
+
target.parent.apply(new RemoveChildAction(target));
|
|
90
|
+
}
|
|
91
|
+
if (previousNode) {
|
|
92
|
+
action.previousNode = previousNode;
|
|
93
|
+
}
|
|
94
|
+
else if (nextNode) {
|
|
95
|
+
action.nextNode = nextNode;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BlockInsertBlocksBeforeStrategy } from './block-insert-blocks-before-strategy';
|
|
2
|
+
/**
|
|
3
|
+
* Insert block array at the behind of the block strategy.
|
|
4
|
+
*/
|
|
5
|
+
export class BlockInsertBlocksAfterStrategy extends BlockInsertBlocksBeforeStrategy {
|
|
6
|
+
/**
|
|
7
|
+
* @inheritDoc
|
|
8
|
+
*/
|
|
9
|
+
handleAction(action, target) {
|
|
10
|
+
this.replaceBlockWithBlocks(target, action.referBlock, [
|
|
11
|
+
action.referBlock,
|
|
12
|
+
...action.blocksToBeInserted,
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
2
|
+
/**
|
|
3
|
+
* Insert block array at the front of the block strategy.
|
|
4
|
+
*/
|
|
5
|
+
export class BlockInsertBlocksBeforeStrategy extends ActionHandleStrategy {
|
|
6
|
+
/**
|
|
7
|
+
* @inheritDoc
|
|
8
|
+
*/
|
|
9
|
+
handleAction(action, target) {
|
|
10
|
+
this.replaceBlockWithBlocks(target, action.referBlock, [
|
|
11
|
+
...action.blocksToBeInserted,
|
|
12
|
+
action.referBlock,
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Replaces a specific block with an array of blocks within a RTEContentBlock array.
|
|
17
|
+
*
|
|
18
|
+
* @param {RTEListBlock|VegaRTEContent} target - The list block or the VegaRTEContent instance.
|
|
19
|
+
* @param {RTEBlock} referBlock - Used as a reference block to identify the block that needs to be replaced in the `blocks` array.
|
|
20
|
+
* @param {RTEBlock[]} blocks - An array of RTEBlock objects that you want to replace the `referBlock` with in the `blocks` array.
|
|
21
|
+
*/
|
|
22
|
+
replaceBlockWithBlocks(target, referBlock, blocks) {
|
|
23
|
+
if (target.blocks) {
|
|
24
|
+
blocks.forEach((block) => {
|
|
25
|
+
block.parent = target;
|
|
26
|
+
});
|
|
27
|
+
const arrayFixed = target.blocks;
|
|
28
|
+
target.blocks = arrayFixed.flatMap((block) => {
|
|
29
|
+
if (block === referBlock) {
|
|
30
|
+
return blocks;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return block;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InsertBlocksAfterAction } from '../../actions/insert-blocks-after-block';
|
|
2
|
+
import { InsertBlocksBeforeAction } from '../../actions/insert-blocks-before-block';
|
|
3
|
+
import { SplitBlockWithNodeAction } from '../../actions/split-block-with-node-action';
|
|
4
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
5
|
+
/**
|
|
6
|
+
* Insert a image block into the text block at special position strategy.
|
|
7
|
+
*/
|
|
8
|
+
export class BlockInsertImageIntoTextStrategy extends ActionHandleStrategy {
|
|
9
|
+
/**
|
|
10
|
+
* insertImage
|
|
11
|
+
*
|
|
12
|
+
* @param {InsertImageToBlockAction} action - Insert image action instance.
|
|
13
|
+
* @param {RTETextBlock} target - The text block.
|
|
14
|
+
*/
|
|
15
|
+
handleAction(action, target) {
|
|
16
|
+
const splitNode = action.splitPointNode;
|
|
17
|
+
const startOffsetOfNode = action.startOffsetOfNode;
|
|
18
|
+
const newImageBlock = action.imageBlockToBeInserted;
|
|
19
|
+
if (this.isCaretPositionAtTextBlockEnd(target, splitNode, startOffsetOfNode)) {
|
|
20
|
+
target.parent.apply(new InsertBlocksAfterAction(target, newImageBlock));
|
|
21
|
+
}
|
|
22
|
+
else if (this.isCaretPositionAtTextBlockStart(target, splitNode, startOffsetOfNode)) {
|
|
23
|
+
target.parent.apply(new InsertBlocksBeforeAction(target, newImageBlock));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
|
|
27
|
+
target.apply(splitBlockAction);
|
|
28
|
+
target.parent.apply(new InsertBlocksAfterAction(target, newImageBlock));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { generateUUID } from '../../../../../utils/misc';
|
|
2
|
+
import { ReplaceChildNodesAction } from '../../actions/replace-child-nodes-action';
|
|
3
|
+
import { RTETextNode } from '../../nodes/text-node';
|
|
4
|
+
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
|
|
5
|
+
/**
|
|
6
|
+
* Insert a line break node into current text block at special position strategy.
|
|
7
|
+
*/
|
|
8
|
+
export class BlockInsertLineBreakStrategy extends ActionHandleStrategy {
|
|
9
|
+
/**
|
|
10
|
+
* @inheritDoc
|
|
11
|
+
*/
|
|
12
|
+
handleAction(action, target) {
|
|
13
|
+
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset, target);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* lineBreakSingleBlock
|
|
17
|
+
*
|
|
18
|
+
* @param {RTETextNode} splitNode -
|
|
19
|
+
* @param {number} startOffsetOfNode -
|
|
20
|
+
* @param {RTETextBlock} target -
|
|
21
|
+
* @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
|
|
22
|
+
*/
|
|
23
|
+
lineBreakSingleBlock(splitNode, startOffsetOfNode, target) {
|
|
24
|
+
if (splitNode) {
|
|
25
|
+
const lineBreakNode = new RTETextNode(generateUUID(), '\n', target);
|
|
26
|
+
const beforeText = splitNode.text.slice(0, startOffsetOfNode);
|
|
27
|
+
const afterText = splitNode.text.slice(startOffsetOfNode);
|
|
28
|
+
const nodesSplitIndex = target.nodes.indexOf(splitNode);
|
|
29
|
+
if (nodesSplitIndex > -1) {
|
|
30
|
+
const beforeNodes = target.nodes.slice(0, nodesSplitIndex);
|
|
31
|
+
const afterNodes = target.nodes.slice(nodesSplitIndex + 1);
|
|
32
|
+
if (beforeText) {
|
|
33
|
+
beforeNodes.push(splitNode.cloneWithText(beforeText));
|
|
34
|
+
}
|
|
35
|
+
if (afterText) {
|
|
36
|
+
afterNodes.unshift(splitNode.cloneWithText(afterText));
|
|
37
|
+
}
|
|
38
|
+
this.mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes, target);
|
|
39
|
+
}
|
|
40
|
+
return lineBreakNode;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* mergeLineBreakNodes
|
|
45
|
+
*
|
|
46
|
+
* @param {RTENode[]} beforeNodes -
|
|
47
|
+
* @param {RTETextNode} lineBreakNode -
|
|
48
|
+
* @param {RTENode[]} afterNodes -
|
|
49
|
+
* @param {RTETextBlock} target -
|
|
50
|
+
*/
|
|
51
|
+
mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes, target) {
|
|
52
|
+
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
53
|
+
afterNodes.push(new RTETextNode(generateUUID(), '\n', target, beforeNodes[beforeNodes.length - 1] && beforeNodes[beforeNodes.length - 1].annotationMap));
|
|
54
|
+
}
|
|
55
|
+
target.apply(new ReplaceChildNodesAction([...beforeNodes, lineBreakNode, ...afterNodes]));
|
|
56
|
+
}
|
|
57
|
+
}
|