@globalpayments/vega 2.38.0 → 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.
Files changed (262) hide show
  1. package/dist/cjs/{app-globals-7087f121.js → app-globals-dd3e7925.js} +2 -3
  2. package/dist/cjs/content-state-c5b47ca1.js +6644 -0
  3. package/dist/cjs/{image-annotation-action-7d82f7e1.js → image-annotation-action-75b9c0d3.js} +5 -6
  4. package/dist/cjs/index.cjs.js +13 -14
  5. package/dist/cjs/loader.cjs.js +8 -9
  6. package/dist/cjs/vega-date-picker_2.cjs.entry.js +1 -1
  7. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  8. package/dist/cjs/vega-input-phone-number.cjs.entry.js +31 -7
  9. package/dist/cjs/vega-popover_2.cjs.entry.js +14 -0
  10. package/dist/cjs/vega-rich-text-content.cjs.entry.js +18 -19
  11. package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +75 -79
  12. package/dist/cjs/vega.cjs.js +8 -9
  13. package/dist/collection/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.js +18 -2
  14. package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.js +7 -4
  15. package/dist/collection/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.js +4 -0
  16. package/dist/collection/components/vega-popover/vega-popover.js +37 -0
  17. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy-registry.js +52 -0
  18. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy.abstract.js +63 -0
  19. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-link-group-strategy.js +21 -0
  20. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy.js +32 -0
  21. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/image-set-annotation-map-strategy.js +13 -0
  22. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-split-text-strategy.js +134 -0
  23. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-update-annotation-map-strategy.js +47 -0
  24. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-blocks-strategy.js +19 -0
  25. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-nodes-strategy.js +21 -0
  26. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-image-strategy.js +54 -0
  27. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-node-content-strategy.js +152 -0
  28. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy.js +99 -0
  29. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-after-strategy.js +15 -0
  30. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-before-strategy.js +38 -0
  31. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-image-into-text-strategy.js +31 -0
  32. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-line-break-strategy.js +57 -0
  33. 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
  34. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-new-paragraph-strategy.js +55 -0
  35. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-nodes-after-node-strategy.js +14 -0
  36. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-nodes-before-node-strategy.js +14 -0
  37. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-merge-nodes-strategy.js +25 -0
  38. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-child-block-strategy.js +15 -0
  39. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.js +21 -0
  40. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-node-with-nodes-strategy.js +28 -0
  41. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-nodes-strategy.js +17 -0
  42. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-split-with-image-node-strategy.js +48 -0
  43. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-split-with-text-node-strategy.js +43 -0
  44. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-list-strategy.js +26 -0
  45. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-block-insert-image-strategy.js +32 -0
  46. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-line-break-strategy.js +21 -0
  47. 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
  48. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-new-paragraph-strategy.js +44 -0
  49. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-update-url-strategy.js +12 -0
  50. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-insert-image-strategy.js +22 -0
  51. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-delete-text-content-strategy.js +20 -0
  52. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-image-strategy.js +15 -0
  53. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-new-paragraph-strategy.js +92 -0
  54. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-nest-list-strategy.js +22 -0
  55. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-node-strategy.js +19 -0
  56. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-replace-nest-list-strategy.js +15 -0
  57. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-remove-list-item-strategy.js +27 -0
  58. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-list-strategy.js +36 -0
  59. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-paragraph-strategy.js +63 -0
  60. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-replace-selected-text-strategy.js +46 -0
  61. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-update-text-strategy.js +20 -0
  62. package/dist/collection/components/vega-rich-text-editor/dto/actions/image-update-url-action.js +13 -0
  63. package/dist/collection/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.js +1 -1
  64. package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +3 -215
  65. package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +31 -244
  66. package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +17 -155
  67. package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +33 -184
  68. package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +40 -352
  69. package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +13 -23
  70. package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +14 -6
  71. package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +23 -182
  72. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.js +2 -1
  73. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/action-handle-strategy-registry.test.js +41 -0
  74. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/block-insert-line-break-with-blocks-strategy.test.js +24 -0
  75. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.js +14 -0
  76. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.js +30 -0
  77. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-set-annotation-map-strategy.test.js +11 -0
  78. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-update-url-strategy.test.js +16 -0
  79. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-block-strategy-register.test.js +20 -0
  80. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-item-strategy-register.test.js +31 -0
  81. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-split-text-strategy.test.js +31 -0
  82. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-update-annotation-map-strategy.test.js +17 -0
  83. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.js +55 -0
  84. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/update-selected-text-strategy.test.js +23 -0
  85. package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +2 -2
  86. package/dist/collection/helpers/validator/rules/valid-phone-number-rule.js +7 -2
  87. package/dist/collection/helpers/validator/test/rules/valid-phone-number-rule.test.js +8 -0
  88. package/dist/esm/{app-globals-4cca4a96.js → app-globals-c954167a.js} +2 -3
  89. package/dist/esm/content-state-2edba4ec.js +6600 -0
  90. package/dist/esm/{form-field-controller-slimmer-3535e76a.js → form-field-controller-slimmer-7a9f2b2e.js} +1 -1
  91. package/dist/esm/{image-annotation-action-3da42221.js → image-annotation-action-b6668f48.js} +1 -2
  92. package/dist/esm/{index-6e05b241.js → index-d172bafa.js} +1 -1
  93. package/dist/esm/index.js +5 -6
  94. package/dist/esm/loader.js +9 -10
  95. package/dist/esm/{string-input-formatter-slimmer-d4132497.js → string-input-formatter-slimmer-418b54f0.js} +2 -2
  96. package/dist/esm/{sub-state-notify-slimmer-51151fc3.js → sub-state-notify-slimmer-b36fd081.js} +1 -1
  97. package/dist/esm/{sub-state-observer-slimmer-d77a1c46.js → sub-state-observer-slimmer-09452523.js} +1 -1
  98. package/dist/esm/vega-button-group_2.entry.js +3 -3
  99. package/dist/esm/vega-calendar_3.entry.js +3 -3
  100. package/dist/esm/vega-checkbox_2.entry.js +2 -2
  101. package/dist/esm/vega-color-picker.entry.js +2 -2
  102. package/dist/esm/vega-combo-box.entry.js +2 -2
  103. package/dist/esm/vega-date-picker_2.entry.js +5 -5
  104. package/dist/esm/vega-dropdown_5.entry.js +3 -3
  105. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  106. package/dist/esm/vega-file-uploader.entry.js +2 -2
  107. package/dist/esm/vega-form.entry.js +2 -2
  108. package/dist/esm/vega-image-uploader.entry.js +2 -2
  109. package/dist/esm/vega-input-credit-card.entry.js +2 -2
  110. package/dist/esm/vega-input-numeric.entry.js +3 -3
  111. package/dist/esm/vega-input-phone-number.entry.js +33 -9
  112. package/dist/esm/vega-input-range.entry.js +2 -2
  113. package/dist/esm/vega-input-select.entry.js +2 -2
  114. package/dist/esm/vega-input.entry.js +5 -5
  115. package/dist/esm/{vega-internal-event-id-d0690d0d.js → vega-internal-event-id-f269c42f.js} +1 -1
  116. package/dist/esm/vega-left-nav_5.entry.js +3 -3
  117. package/dist/esm/vega-popover_2.entry.js +15 -1
  118. package/dist/esm/vega-radio_2.entry.js +2 -2
  119. package/dist/esm/vega-rich-text-content.entry.js +6 -7
  120. package/dist/esm/vega-rich-text-editor_4.entry.js +21 -25
  121. package/dist/esm/vega-selection-chip_2.entry.js +4 -4
  122. package/dist/esm/vega-selection-tile_2.entry.js +4 -4
  123. package/dist/esm/vega-sidenav_3.entry.js +3 -3
  124. package/dist/esm/vega-signature-capture.entry.js +2 -2
  125. package/dist/esm/vega-stepper.entry.js +2 -2
  126. package/dist/esm/vega-table_8.entry.js +3 -3
  127. package/dist/esm/vega-textarea.entry.js +2 -2
  128. package/dist/esm/vega-time-picker_2.entry.js +2 -2
  129. package/dist/esm/vega-toggle-switch.entry.js +2 -2
  130. package/dist/esm/vega.js +9 -10
  131. package/dist/types/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.d.ts +7 -0
  132. package/dist/types/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.d.ts +1 -0
  133. package/dist/types/components/vega-popover/vega-popover.d.ts +10 -0
  134. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy-registry.d.ts +37 -0
  135. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy.abstract.d.ts +66 -0
  136. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-link-group-strategy.d.ts +15 -0
  137. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy.d.ts +15 -0
  138. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/image-set-annotation-map-strategy.d.ts +13 -0
  139. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-split-text-strategy.d.ts +47 -0
  140. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-update-annotation-map-strategy.d.ts +15 -0
  141. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-blocks-strategy.d.ts +13 -0
  142. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-append-nodes-strategy.d.ts +16 -0
  143. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-image-strategy.d.ts +19 -0
  144. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-node-content-strategy.d.ts +61 -0
  145. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy.d.ts +19 -0
  146. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-after-strategy.d.ts +13 -0
  147. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-blocks-before-strategy.d.ts +23 -0
  148. 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
  149. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-line-break-strategy.d.ts +30 -0
  150. 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
  151. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-insert-new-paragraph-strategy.d.ts +29 -0
  152. 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
  153. 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
  154. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-merge-nodes-strategy.d.ts +16 -0
  155. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-child-block-strategy.d.ts +13 -0
  156. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.d.ts +17 -0
  157. 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
  158. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-replace-nodes-strategy.d.ts +16 -0
  159. 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
  160. 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
  161. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-list-strategy.d.ts +15 -0
  162. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-block-insert-image-strategy.d.ts +12 -0
  163. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-line-break-strategy.d.ts +15 -0
  164. 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
  165. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-insert-new-paragraph-strategy.d.ts +21 -0
  166. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/image-update-url-strategy.d.ts +12 -0
  167. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-insert-image-strategy.d.ts +15 -0
  168. 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
  169. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-insert-image-strategy.d.ts +15 -0
  170. 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
  171. 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
  172. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-item-remove-node-strategy.d.ts +15 -0
  173. 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
  174. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-remove-list-item-strategy.d.ts +15 -0
  175. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-list-strategy.d.ts +12 -0
  176. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/list-transform-to-paragraph-strategy.d.ts +19 -0
  177. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-replace-selected-text-strategy.d.ts +20 -0
  178. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/node-update-text-strategy.d.ts +15 -0
  179. package/dist/types/components/vega-rich-text-editor/dto/actions/image-update-url-action.d.ts +11 -0
  180. package/dist/types/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.d.ts +2 -2
  181. package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +1 -79
  182. package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +3 -77
  183. package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +0 -38
  184. package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +3 -58
  185. package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +5 -93
  186. package/dist/types/components/vega-rich-text-editor/dto/content-state.d.ts +1 -2
  187. package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +0 -43
  188. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/action-handle-strategy-registry.test.d.ts +1 -0
  189. 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
  190. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.d.ts +1 -0
  191. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.d.ts +1 -0
  192. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-set-annotation-map-strategy.test.d.ts +1 -0
  193. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-update-url-strategy.test.d.ts +1 -0
  194. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-block-strategy-register.test.d.ts +1 -0
  195. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/list-item-strategy-register.test.d.ts +1 -0
  196. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-split-text-strategy.test.d.ts +1 -0
  197. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/node-update-annotation-map-strategy.test.d.ts +1 -0
  198. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.d.ts +1 -0
  199. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/update-selected-text-strategy.test.d.ts +1 -0
  200. package/dist/types/components.d.ts +14 -0
  201. package/dist/types/helpers/validator/rules/valid-phone-number-rule.d.ts +3 -1
  202. package/dist/vega/index.esm.js +1 -1
  203. package/dist/vega/{p-ba077ca8.entry.js → p-073beb31.entry.js} +1 -1
  204. package/dist/vega/{p-6419e13e.entry.js → p-0b697841.entry.js} +1 -1
  205. package/dist/vega/p-0cc1ad76.js +1 -0
  206. package/dist/vega/{p-29d6ec6c.js → p-239bae84.js} +1 -1
  207. package/dist/vega/{p-7198d675.entry.js → p-24ac5151.entry.js} +1 -1
  208. package/dist/vega/{p-cb4fd6e1.entry.js → p-257b1bc2.entry.js} +1 -1
  209. package/dist/vega/{p-ba2833c0.entry.js → p-3c85a11b.entry.js} +1 -1
  210. package/dist/vega/{p-b517ed15.js → p-49bf2b3a.js} +1 -1
  211. package/dist/vega/p-4a8db510.entry.js +1 -0
  212. package/dist/vega/p-4b19706c.entry.js +1 -0
  213. package/dist/vega/{p-bf4996d5.entry.js → p-4e436842.entry.js} +1 -1
  214. package/dist/vega/{p-12fe63c1.entry.js → p-59834ea4.entry.js} +1 -1
  215. package/dist/vega/{p-50eabdca.entry.js → p-59cfed37.entry.js} +1 -1
  216. package/dist/vega/p-5f377954.js +1 -1
  217. package/dist/vega/p-60e1ebe1.entry.js +1 -0
  218. package/dist/vega/{p-23fd9401.entry.js → p-629bd266.entry.js} +1 -1
  219. package/dist/vega/p-6408d3dc.entry.js +1 -0
  220. package/dist/vega/{p-3e8f9fcf.entry.js → p-64e0c944.entry.js} +1 -1
  221. package/dist/vega/{p-b9a0f136.entry.js → p-64e49394.entry.js} +1 -1
  222. package/dist/vega/p-6e5db02b.js +1 -0
  223. package/dist/vega/{p-9689ad99.entry.js → p-74ff73d6.entry.js} +1 -1
  224. package/dist/vega/{p-b809f3d7.entry.js → p-8120e7a1.entry.js} +1 -1
  225. package/dist/vega/p-894c067a.entry.js +1 -0
  226. package/dist/vega/{p-e9785742.entry.js → p-989b36a2.entry.js} +1 -1
  227. package/dist/vega/{p-a2a34239.entry.js → p-9ee23f34.entry.js} +1 -1
  228. package/dist/vega/{p-34bd9204.js → p-a9e1123a.js} +1 -1
  229. package/dist/vega/{p-267cde46.entry.js → p-b071be5c.entry.js} +1 -1
  230. package/dist/vega/{p-1b67c443.entry.js → p-b6bffdf3.entry.js} +1 -1
  231. package/dist/vega/{p-20326c64.js → p-bd0116f9.js} +1 -1
  232. package/dist/vega/{p-a7e078ac.entry.js → p-bf6d3c00.entry.js} +1 -1
  233. package/dist/vega/{p-ecaf4cfa.entry.js → p-c00fde35.entry.js} +1 -1
  234. package/dist/vega/{p-7baa4fae.entry.js → p-c2e96537.entry.js} +1 -1
  235. package/dist/vega/{p-3cb90bdf.entry.js → p-ce94a9c5.entry.js} +1 -1
  236. package/dist/vega/{p-904b489a.entry.js → p-d03945cb.entry.js} +1 -1
  237. package/dist/vega/p-d2e6090a.js +1 -0
  238. package/dist/vega/{p-348e95ba.js → p-d2ff56d8.js} +1 -1
  239. package/dist/vega/p-e0d3ca2d.js +1 -0
  240. package/dist/vega/{p-ee2e4bff.entry.js → p-ea78ddfa.entry.js} +1 -1
  241. package/dist/vega/{p-e9a5bd12.entry.js → p-f1ebe86b.entry.js} +1 -1
  242. package/dist/vega/{p-497f2f86.entry.js → p-fc49a98e.entry.js} +1 -1
  243. package/dist/vega/vega.esm.js +1 -1
  244. package/package.json +1 -1
  245. package/dist/cjs/content-state-f97d3278.js +0 -2990
  246. package/dist/cjs/node-annotation.abstract-4f6df9cf.js +0 -3223
  247. package/dist/collection/components/vega-rich-text-editor/dto/actions/clear-child-nodes-action.js +0 -12
  248. package/dist/collection/components/vega-rich-text-editor/dto/helper/block-base-operator.js +0 -47
  249. package/dist/esm/content-state-ccf5f960.js +0 -2954
  250. package/dist/esm/node-annotation.abstract-b2e36bc4.js +0 -3214
  251. package/dist/types/components/vega-rich-text-editor/dto/actions/clear-child-nodes-action.d.ts +0 -9
  252. package/dist/types/components/vega-rich-text-editor/dto/helper/block-base-operator.d.ts +0 -24
  253. package/dist/vega/p-0461e318.js +0 -1
  254. package/dist/vega/p-1d93b3a9.js +0 -1
  255. package/dist/vega/p-2fecbcf9.entry.js +0 -1
  256. package/dist/vega/p-52a8a4f8.js +0 -1
  257. package/dist/vega/p-7edcb8d0.entry.js +0 -1
  258. package/dist/vega/p-9728d571.entry.js +0 -1
  259. package/dist/vega/p-a7f40a65.entry.js +0 -1
  260. package/dist/vega/p-a8b16ff2.js +0 -1
  261. package/dist/vega/p-aed80794.entry.js +0 -1
  262. package/dist/vega/p-f86ec91b.js +0 -1
@@ -1,15 +1,24 @@
1
1
  import { RTETextNode } from '../nodes/text-node';
2
2
  import { RTEListBlock } from './list-block';
3
3
  import { ModifyContentActionType } from '../actions/modify-content-action.abstract';
4
- import { RemoveChildAction } from '../actions/remove-child-action';
5
4
  import { AppendChildNodesAction } from '../actions/append-child-nodes-action';
6
5
  import { generateUUID } from '../../../../utils/misc';
7
- import { SplitBlockWithNodeAction } from '../actions/split-block-with-node-action';
8
6
  import { RTETextBlock } from './text-block';
9
- import { InsertBlocksAfterAction } from '../actions/insert-blocks-after-block';
10
- import { InsertBlocksBeforeAction } from '../actions/insert-blocks-before-block';
11
7
  import { isNonNullable } from '../../../../types/type-guard';
12
- import { NodeAnnotationTypeEnum } from '../annotations/node-annotation.abstract';
8
+ import { ActionHandleStrategyRegistry } from '../action-handle-strategies/action-handle-strategy-registry';
9
+ import { ListItemDeleteTextContentStrategy } from '../action-handle-strategies/modify-content-strategies/list-item-delete-text-content-strategy';
10
+ import { BlockInsertLineBreakStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-line-break-strategy';
11
+ import { BlockInsertLineBreakWithBlocksStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-line-break-with-blocks-strategy';
12
+ import { ListItemRemoveNodeStrategy } from '../action-handle-strategies/modify-content-strategies/list-item-remove-node-strategy';
13
+ import { ListItemRemoveNestListStrategy } from '../action-handle-strategies/modify-content-strategies/list-item-remove-nest-list-strategy';
14
+ import { BlockAppendNodesStrategy } from '../action-handle-strategies/modify-content-strategies/block-append-nodes-strategy';
15
+ import { BlockSplitWithTextNodeStrategy } from '../action-handle-strategies/modify-content-strategies/block-split-with-text-node-strategy';
16
+ import { BlockReplaceNodesStrategy } from '../action-handle-strategies/modify-content-strategies/block-replace-nodes-strategy';
17
+ import { ListItemReplaceNestListStrategy } from '../action-handle-strategies/modify-content-strategies/list-item-replace-nest-list-strategy';
18
+ import { BlockMergeNodesStrategy } from '../action-handle-strategies/modify-content-strategies/block-merge-nodes-strategy';
19
+ import { ListItemInsertNewParagraphStrategy } from '../action-handle-strategies/modify-content-strategies/list-item-insert-new-paragraph-strategy';
20
+ import { ListItemInsertImageStrategy } from '../action-handle-strategies/modify-content-strategies/list-item-insert-image-strategy';
21
+ import { BlockInsertNodesBeforeNodeStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-nodes-before-node-strategy';
13
22
  /**
14
23
  * List item block
15
24
  */
@@ -84,186 +93,26 @@ export class RTEListItemBlock extends RTETextBlock {
84
93
  return super.getLastNode();
85
94
  }
86
95
  /**
87
- * Apply a modify action to block
96
+ * Create a new list item block.
88
97
  *
89
- * @param {ModifyContentAction} action - Modify action
98
+ * @returns {RTEListItemBlock} - A list item block.
90
99
  */
91
- doModifyActionApply(action) {
92
- switch (action.type) {
93
- case ModifyContentActionType.DELETE_CHILD:
94
- this.removeListChildNode(action);
95
- break;
96
- case ModifyContentActionType.DELETE_NEST_LIST:
97
- this.removeNestList(action);
98
- break;
99
- case ModifyContentActionType.APPEND_CHILD_NODES:
100
- this.appendChildNodes(action.entityToBeAppended);
101
- break;
102
- case ModifyContentActionType.CLEAR_CHILD_NODES:
103
- this.nodes = [];
104
- break;
105
- case ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
106
- this.splitListItemBlock(action);
107
- break;
108
- case ModifyContentActionType.REPLACE_CHILD_NODES:
109
- this.nodes = [];
110
- this.appendChildNodes(action.newChildNodes);
111
- break;
112
- case ModifyContentActionType.REPLACE_NEST_LIST:
113
- this.replaceNestList(action.newList);
114
- break;
115
- case ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
116
- this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
117
- break;
118
- case ModifyContentActionType.BREAK_SINGLE_BLOCK:
119
- action.newBlock = this.breakSingleListItemBlock(action.startContainerNode, action.startOffset);
120
- break;
121
- case ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
122
- action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
123
- break;
124
- case ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
125
- action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
126
- break;
127
- case ModifyContentActionType.DELETE_BLOCK_CONTENT:
128
- this.deleteListNodeContent(action);
129
- break;
130
- case ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
131
- this.parent.apply(action);
132
- break;
133
- case ModifyContentActionType.INSERT_NODES_BEFORE:
134
- this.replaceNodeWithNodes(action.referNode, [
135
- ...action.nodesToBeInserted,
136
- action.referNode,
137
- ]);
138
- break;
139
- }
140
- }
141
- /**
142
- * Remove the list child node
143
- *
144
- * @param {RemoveChildAction} action - Modify action
145
- */
146
- removeListChildNode(action) {
147
- this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
148
- if (this.nodes.length === 0 && (!this.children || !this.children.length)) {
149
- this.parent.apply(new RemoveChildAction(this));
150
- }
151
- }
152
- /**
153
- * Remove the nest list
154
- *
155
- * @param {RemoveNestListAction} action - Modify action
156
- */
157
- removeNestList(action) {
158
- if (this.children) {
159
- if (this.children.length > 1) {
160
- this.children = this.children.filter((child) => child !== action.nestListBlockToBeRemoved);
161
- }
162
- else {
163
- this.children = undefined;
164
- }
165
- }
166
- }
167
- /**
168
- * Iterates through a list of RTEListBlock and sets their parent property to the current object, then replaces the children property with the new list.
169
- *
170
- * @param {RTEListBlock[]} newList - new list that you want to replace the existing children of the current object with.
171
- */
172
- replaceNestList(newList) {
173
- newList.forEach((listBlock) => {
174
- listBlock.parent = this;
175
- });
176
- this.children = newList;
177
- }
178
- /**
179
- * Split list item block
180
- *
181
- * @param {SplitBlockWithNodeAction} action - Modify action
182
- */
183
- splitListItemBlock(action) {
184
- action.newBlock = this.splitTextNodeBlock(action.splitPointNode, action.startOffsetOfNode);
185
- }
186
- /**
187
- * Breaks a single list item block at a specific position.
188
- *
189
- * @param {RTETextNode} splitNode - The node that needs to be split within a list item block.
190
- * @param {number} startOffsetOfNode - The index within the `splitNode` where the break operation should occur.
191
- * @returns {Nullable<RTEBlock>} Returns either a new `RTEListItemBlock` if the caret
192
- * position is at the end of the `splitNode`, or it returns the result of splitting the block at the
193
- * caret position if it is neither at the start nor at the end.
194
- */
195
- breakSingleListItemBlock(splitNode, startOffsetOfNode) {
196
- const newListItem = new RTEListItemBlock(generateUUID());
197
- const newBreakNode = this.copyInlineStyleToNewNode(splitNode);
198
- newListItem.apply(new AppendChildNodesAction([newBreakNode]));
199
- if (this.isCaretPositionAtEnd(splitNode, startOffsetOfNode)) {
200
- return this.breakListItemAtEnd(newListItem);
201
- }
202
- else if (this.isCaretPositionAtStart(splitNode, startOffsetOfNode)) {
203
- this.parent.apply(new InsertBlocksBeforeAction(this, newListItem));
204
- }
205
- else {
206
- const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
207
- this.apply(splitBlockAction);
208
- return splitBlockAction.newBlock;
209
- }
210
- return newListItem;
211
- }
212
- /**
213
- * Breaks a list item at the end and handles the insertion of a new list item or paragraph accordingly.
214
- *
215
- * @param {RTEListItemBlock} newListItem - Item that represents a new list item to be added to the existing list.
216
- * @returns {RTEBlock} Returns a `RTEBlock`.
217
- */
218
- breakListItemAtEnd(newListItem) {
219
- const lastItem = this.parent.blocks[this.parent.blocks.length - 1];
220
- const currentItemIsEmpty = this.nodes.length === 1 && this.nodes[0].isEmpty();
221
- if (this === lastItem && currentItemIsEmpty) {
222
- const parentParent = this.parent.parent;
223
- if (parentParent['type'] !== 'list-item') {
224
- const newParagraph = RTETextBlock.from({
225
- id: generateUUID(),
226
- type: 'paragraph',
227
- nodes: [],
228
- });
229
- newParagraph.apply(new AppendChildNodesAction(newListItem.nodes));
230
- parentParent.apply(new InsertBlocksAfterAction(this.parent, newParagraph));
231
- this.parent.apply(new RemoveChildAction(this));
232
- return newParagraph;
233
- }
234
- else {
235
- parentParent.parent.apply(new InsertBlocksAfterAction(parentParent, newListItem));
236
- this.parent.apply(new RemoveChildAction(this));
237
- }
238
- }
239
- else {
240
- this.parent.apply(new InsertBlocksAfterAction(this, newListItem));
241
- }
242
- return newListItem;
243
- }
244
- /**
245
- * Delete list node content
246
- *
247
- * @param {DeleteBlockContentAction} action - Modify action
248
- */
249
- deleteListNodeContent(action) {
250
- const startContainerNode = action.startContainerNode;
251
- const listBlock = startContainerNode.parentBlock.parent;
252
- this.deleteNodeContent(action);
253
- if (listBlock.blocks.length === 0) {
254
- listBlock.parent.apply(new RemoveChildAction(listBlock));
255
- }
256
- }
257
- /**
258
- * Copy the inline style to new node
259
- *
260
- * @param {RTETextNode} needCopedNode - The node that needed to be copied to
261
- * @returns {RTETextNode} Returns a `RTETextNode`.
262
- */
263
- copyInlineStyleToNewNode(needCopedNode) {
264
- const textNode = needCopedNode.cloneWithText('');
265
- // The link annotation doesn't need to inherit
266
- textNode.annotationMap.delete(NodeAnnotationTypeEnum.LINK);
267
- return textNode;
100
+ createNewListItem() {
101
+ return new RTEListItemBlock(generateUUID());
268
102
  }
269
103
  }
104
+ (() => {
105
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_BLOCK_CONTENT, RTEListItemBlock.name, new ListItemDeleteTextContentStrategy());
106
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new BlockInsertLineBreakStrategy());
107
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEListItemBlock.name, new BlockInsertLineBreakWithBlocksStrategy());
108
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEListItemBlock.name, new ListItemRemoveNodeStrategy());
109
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_NEST_LIST, RTEListItemBlock.name, new ListItemRemoveNestListStrategy());
110
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEListItemBlock.name, new BlockAppendNodesStrategy());
111
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEListItemBlock.name, new BlockSplitWithTextNodeStrategy());
112
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_CHILD_NODES, RTEListItemBlock.name, new BlockReplaceNodesStrategy());
113
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_NEST_LIST, RTEListItemBlock.name, new ListItemReplaceNestListStrategy());
114
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTEListItemBlock.name, new BlockMergeNodesStrategy());
115
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new ListItemInsertNewParagraphStrategy());
116
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListItemBlock.name, new ListItemInsertImageStrategy());
117
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_BEFORE, RTEListItemBlock.name, new BlockInsertNodesBeforeNodeStrategy());
118
+ })();
@@ -2,23 +2,28 @@ import { RTETextNode } from '../nodes/text-node';
2
2
  import { isNonNullable } from '../../../../types/type-guard';
3
3
  import { TextStyleAnnotation } from '../annotations/text-style-annotation';
4
4
  import { ModifyContentActionType } from '../actions/modify-content-action.abstract';
5
- import { RemoveChildAction } from '../actions/remove-child-action';
6
5
  import { AppendChildNodesAction } from '../actions/append-child-nodes-action';
7
6
  import { RTEBlock } from './block.abstract';
8
- import { InternalAnnotationTypeEnum } from '../annotations/annotation.abstract';
9
7
  import { TextStyleAnnotationAction } from '../actions/text-style-annotation-action';
10
- import { BoldAnnotationAction } from '../actions/bold-annotation-action';
11
8
  import { NodeAnnotationTypeEnum } from '../annotations/node-annotation.abstract';
12
9
  import { LinkAnnotationAction } from '../actions/link-annotation-action';
13
10
  import { LinkGroupAnnotationAction } from '../actions/link-group-annotation-action';
14
- import { SplitBlockWithNodeAction } from '../actions/split-block-with-node-action';
15
11
  import { generateUUID } from '../../../../utils/misc';
16
- import { ReplaceChildNodesAction } from '../actions/replace-child-nodes-action';
17
- import { MergeTwoBlocksNodesAction } from '../actions/merge-two-blocks-nodes-action';
18
- import { InsertBlocksAfterAction } from '../actions/insert-blocks-after-block';
19
- import { InsertBlocksBeforeAction } from '../actions/insert-blocks-before-block';
20
- import { UpdateTextAction } from '../actions/update-text-action';
21
- import { DeleteNodeAnnotationAction } from '../actions/delete-node-annotation-action';
12
+ import { ActionHandleStrategyRegistry } from '../action-handle-strategies/action-handle-strategy-registry';
13
+ import { BlockUpdateTextStyleStrategy } from '../action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy';
14
+ import { BlockUpdateLinkGroupStrategy } from '../action-handle-strategies/apply-annotation-strategies/block-update-link-group-strategy';
15
+ import { BlockRemoveNodeStrategy } from '../action-handle-strategies/modify-content-strategies/block-remove-node-strategy';
16
+ import { BlockAppendNodesStrategy } from '../action-handle-strategies/modify-content-strategies/block-append-nodes-strategy';
17
+ import { BlockSplitWithTextNodeStrategy } from '../action-handle-strategies/modify-content-strategies/block-split-with-text-node-strategy';
18
+ import { BlockReplaceNodesStrategy } from '../action-handle-strategies/modify-content-strategies/block-replace-nodes-strategy';
19
+ import { BlockMergeNodesStrategy } from '../action-handle-strategies/modify-content-strategies/block-merge-nodes-strategy';
20
+ import { BlockInsertNewParagraphStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-new-paragraph-strategy';
21
+ import { BlockInsertLineBreakStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-line-break-strategy';
22
+ import { BlockInsertLineBreakWithBlocksStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-line-break-with-blocks-strategy';
23
+ import { BlockDeleteTextContentStrategy } from '../action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy';
24
+ import { BlockInsertImageIntoTextStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-image-into-text-strategy';
25
+ import { BlockInsertNodesBeforeNodeStrategy } from '../action-handle-strategies/modify-content-strategies/block-insert-nodes-before-node-strategy';
26
+ import { BlockTransformToListStrategy } from '../action-handle-strategies/modify-content-strategies/block-transform-to-list-strategy';
22
27
  /**
23
28
  * Text block
24
29
  */
@@ -135,353 +140,36 @@ export class RTETextBlock extends RTEBlock {
135
140
  return this.nodes[this.nodes.length - 1];
136
141
  }
137
142
  /**
138
- * @inheritDoc
139
- */
140
- doAnnotationActionApply(action) {
141
- if (action instanceof TextStyleAnnotationAction) {
142
- if (this.type !== 'list-item') {
143
- this.type = action.textStyle;
144
- }
145
- if (action.bold) {
146
- this.nodes.forEach((node) => {
147
- const boldAnnotationAction = new BoldAnnotationAction(true);
148
- boldAnnotationAction.doSplit = false;
149
- node.apply(boldAnnotationAction);
150
- });
151
- }
152
- else {
153
- this.nodes.forEach((node) => {
154
- node.apply(new DeleteNodeAnnotationAction(NodeAnnotationTypeEnum.BOLD));
155
- });
156
- }
157
- return;
158
- }
159
- if (action instanceof LinkGroupAnnotationAction) {
160
- const linkGroupAnnotation = this.getAnnotationByType(InternalAnnotationTypeEnum.LINK_GROUP);
161
- if (linkGroupAnnotation) {
162
- const linkGroup = linkGroupAnnotation.linkGroups.get(action.groupKey);
163
- linkGroupAnnotation.linkGroups.set(action.groupKey, [...linkGroup, ...action.nodes]);
164
- this.annotationMap.set(InternalAnnotationTypeEnum.LINK_GROUP, linkGroupAnnotation);
165
- }
166
- return;
167
- }
168
- }
169
- /**
170
- * Apply a modify action to block
171
- *
172
- * @param {ModifyContentAction} action - Modify action
173
- */
174
- doModifyActionApply(action) {
175
- switch (action.type) {
176
- case ModifyContentActionType.DELETE_CHILD:
177
- this.removeChildNode(action);
178
- break;
179
- case ModifyContentActionType.APPEND_CHILD_NODES:
180
- this.appendChildNodes(action.entityToBeAppended);
181
- break;
182
- case ModifyContentActionType.CLEAR_CHILD_NODES:
183
- this.nodes = [];
184
- break;
185
- case ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
186
- action.newBlock = this.splitTextNodeBlock(action.splitPointNode, action.startOffsetOfNode);
187
- break;
188
- case ModifyContentActionType.REPLACE_CHILD_NODES:
189
- this.nodes = [];
190
- this.appendChildNodes(action.newChildNodes);
191
- break;
192
- case ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
193
- this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
194
- break;
195
- case ModifyContentActionType.BREAK_SINGLE_BLOCK:
196
- action.newBlock = this.breakSingleTextBlock(action.startContainerNode, action.startOffset);
197
- break;
198
- case ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
199
- action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
200
- break;
201
- case ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
202
- action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
203
- break;
204
- case ModifyContentActionType.TRANSFORM_LIST_BLOCK:
205
- this.convertParagraphToList(action);
206
- break;
207
- case ModifyContentActionType.DELETE_BLOCK_CONTENT:
208
- this.deleteNodeContent(action);
209
- break;
210
- case ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
211
- this.insertImage(action);
212
- break;
213
- case ModifyContentActionType.INSERT_NODES_BEFORE:
214
- this.replaceNodeWithNodes(action.referNode, [
215
- ...action.nodesToBeInserted,
216
- action.referNode,
217
- ]);
218
- break;
219
- }
220
- }
221
- /**
222
- * Splits a text node at a specified offset within a block of nodes and returns a new block with the split nodes.
223
- *
224
- * @param {RTETextNode} splitNode - The text node that will be split
225
- * @param {number} startOffsetOfNode - The index at which will split the text content of the `splitNode`.
226
- * @returns {Nullable<RTEBlock>} return either an RTEBlock object or null.
227
- */
228
- splitTextNodeBlock(splitNode, startOffsetOfNode) {
229
- if (splitNode) {
230
- const beforeText = splitNode.text.slice(0, startOffsetOfNode);
231
- const afterText = splitNode.text.slice(startOffsetOfNode);
232
- const nodesSplitIndex = this.nodes.indexOf(splitNode);
233
- if (nodesSplitIndex > -1) {
234
- const beforeNodes = this.nodes.slice(0, nodesSplitIndex);
235
- const afterNodes = this.nodes.slice(nodesSplitIndex + 1);
236
- if (beforeText) {
237
- beforeNodes.push(splitNode.cloneWithText(beforeText));
238
- }
239
- if (afterText) {
240
- afterNodes.unshift(splitNode.cloneWithText(afterText));
241
- }
242
- this.apply(new ReplaceChildNodesAction(beforeNodes));
243
- const newBlock = this.cloneWithNodes(afterNodes);
244
- this.parent.apply(new InsertBlocksAfterAction(this, newBlock));
245
- return newBlock;
246
- }
247
- }
248
- }
249
- /**
250
- * Checks if the caret position is at the start of a specified RTETextNode.
251
- *
252
- * @param {RTETextNode} node - `RTETextNode` - a node representing an image in a rich text editor.
253
- * @param {number} startOffset - The position within the text node where the caret is located.
254
- * @returns {boolean} a boolean value, which indicates whether the caret position is at the start of the RTETextNode.
255
- */
256
- isCaretPositionAtStart(node, startOffset) {
257
- return node === this.nodes[0] && startOffset === 0;
258
- }
259
- /**
260
- * Checks if the caret position is at the end of a specified RTETextNode.
261
- *
262
- * @param {RTETextNode} node - `RTETextNode` - a node representing an image in a rich text editor.
263
- * @param {number} startOffset - The position within the text node where the caret is located.
264
- * @returns {boolean} a boolean value, which indicates whether the caret position is at the start of the RTETextNode.
265
- */
266
- isCaretPositionAtEnd(node, startOffset) {
267
- const lastNode = this.nodes[this.nodes.length - 1];
268
- return node === lastNode && (node.isEmpty() || startOffset === lastNode.text.length);
269
- }
270
- /**
271
- * lineBreakSingleBlock
272
- *
273
- * @param {RTETextNode} splitNode -
274
- * @param {number} startOffsetOfNode -
275
- * @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
276
- */
277
- lineBreakSingleBlock(splitNode, startOffsetOfNode) {
278
- if (splitNode) {
279
- const lineBreakNode = new RTETextNode(generateUUID(), '\n', this);
280
- const beforeText = splitNode.text.slice(0, startOffsetOfNode);
281
- const afterText = splitNode.text.slice(startOffsetOfNode);
282
- const nodesSplitIndex = this.nodes.indexOf(splitNode);
283
- if (nodesSplitIndex > -1) {
284
- const beforeNodes = this.nodes.slice(0, nodesSplitIndex);
285
- const afterNodes = this.nodes.slice(nodesSplitIndex + 1);
286
- if (beforeText) {
287
- beforeNodes.push(splitNode.cloneWithText(beforeText));
288
- }
289
- if (afterText) {
290
- afterNodes.unshift(splitNode.cloneWithText(afterText));
291
- }
292
- this.mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes);
293
- }
294
- return lineBreakNode;
295
- }
296
- }
297
- /**
298
- * lineBreakMultipleBlocks
299
- *
300
- * @param {RTEBlock[]} selectedBlocks -
301
- * @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
302
- */
303
- lineBreakMultipleBlocks(selectedBlocks) {
304
- const beforeNodes = this['nodes'];
305
- const lineBreakNode = new RTETextNode(generateUUID(), '\n', this);
306
- const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
307
- this.mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes);
308
- return lineBreakNode;
309
- }
310
- /**
311
- * deleteNodeContent
312
- *
313
- * @param {DeleteBlockContentAction} action - ModifyContentAction
314
- */
315
- deleteNodeContent(action) {
316
- const startContainerNode = action.startContainerNode;
317
- const startOffset = action.startOffset;
318
- if (startOffset !== 0 && !startContainerNode.isEmpty()) {
319
- const newText = startContainerNode.text.slice(0, startOffset - 1) +
320
- startContainerNode.text.slice(startOffset);
321
- startContainerNode.apply(new UpdateTextAction(newText));
322
- if (newText) {
323
- action.previousNode = startContainerNode;
324
- return;
325
- }
326
- else {
327
- const previousNode = this.getPreviousNode(startContainerNode);
328
- // Remove the last character will not delete paragraph, the paragraph will removed after press delete again
329
- if ((previousNode && previousNode.parentBlock === this && previousNode['text'] === '\n') ||
330
- this.nodes.length === 1) {
331
- action.previousNode = startContainerNode;
332
- return;
333
- }
334
- else {
335
- this.apply(new RemoveChildAction(startContainerNode));
336
- action.previousNode = previousNode;
337
- return;
338
- }
339
- }
340
- }
341
- else {
342
- let previousNode = this.getPreviousNode(startContainerNode);
343
- let nextNode = null;
344
- if (this.nodes.length && previousNode && previousNode.parentBlock !== this) {
345
- if (startContainerNode.isEmpty()) {
346
- this.apply(new RemoveChildAction(startContainerNode));
347
- }
348
- previousNode.parentBlock.apply(new MergeTwoBlocksNodesAction(this));
349
- }
350
- else {
351
- if (this.isContentFirstNode(startContainerNode) && startContainerNode.isEmpty()) {
352
- nextNode = this.getNextNode(startContainerNode);
353
- }
354
- /**
355
- * Remove line break
356
- *
357
- * @example caret at the first line
358
- * \n
359
- * test
360
- */
361
- if (startContainerNode.isEmpty()) {
362
- this.apply(new RemoveChildAction(startContainerNode));
363
- }
364
- /**
365
- * Remove line break
366
- *
367
- * @example caret at the begin of second line
368
- * \n
369
- * test
370
- */
371
- if (previousNode instanceof RTETextNode && previousNode.isEmpty()) {
372
- const shouldRemoveNode = previousNode;
373
- previousNode = this.getPreviousNode(previousNode);
374
- shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
375
- if (!previousNode) {
376
- nextNode = startContainerNode;
377
- }
378
- }
379
- }
380
- //Remove the paragraph block if the content is empty
381
- if (this.nodes.length === 0) {
382
- this.parent.apply(new RemoveChildAction(this));
383
- }
384
- if (previousNode) {
385
- action.previousNode = previousNode;
386
- }
387
- else if (nextNode) {
388
- action.nextNode = nextNode;
389
- }
390
- }
391
- }
392
- /**
393
- * Remove the child node
394
- *
395
- * @param {RemoveChildAction} action - Modify action
396
- */
397
- removeChildNode(action) {
398
- this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
399
- if (this.nodes.length === 0) {
400
- this.parent.apply(new RemoveChildAction(this));
401
- }
402
- }
403
- /**
404
- * mergeLineBreakNodes
143
+ * Create new empty paragraph.
405
144
  *
406
- * @param {RTENode[]} beforeNodes -
407
- * @param {RTETextNode} lineBreakNode -
408
- * @param {RTENode[]} afterNodes -
145
+ * @returns {RTETextBlock} Paragraph.
409
146
  */
410
- mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes) {
411
- if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
412
- afterNodes.push(new RTETextNode(generateUUID(), '\n', this, beforeNodes[beforeNodes.length - 1] && beforeNodes[beforeNodes.length - 1].annotationMap));
413
- }
414
- this.apply(new ReplaceChildNodesAction([...beforeNodes, lineBreakNode, ...afterNodes]));
415
- }
416
- /**
417
- * breakSingleTextBlock
418
- *
419
- * @param {RTETextNode} splitNode -
420
- * @param {number} startOffsetOfNode -
421
- * @returns {Nullable<RTEBlock>} Nullable<RTEBlock>
422
- */
423
- breakSingleTextBlock(splitNode, startOffsetOfNode) {
424
- const newParagraph = this.copyInlineStyleToNewParagraph(splitNode);
425
- if (this.isCaretPositionAtEnd(splitNode, startOffsetOfNode)) {
426
- this.parent.apply(new InsertBlocksAfterAction(this, newParagraph));
427
- }
428
- else if (this.isCaretPositionAtStart(splitNode, startOffsetOfNode)) {
429
- this.parent.apply(new InsertBlocksBeforeAction(this, newParagraph));
430
- }
431
- else {
432
- const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
433
- this.apply(splitBlockAction);
434
- return splitBlockAction.newBlock;
435
- }
436
- return newParagraph;
147
+ createNewParagraph() {
148
+ return new RTETextBlock(generateUUID(), 'paragraph');
437
149
  }
438
150
  /**
439
- * convertParagraphToList
440
- *
441
- * @param {TransformListAction} action - ModifyContentAction
442
- */
443
- convertParagraphToList(action) {
444
- const bulletList = this.parent.createList(action.listType);
445
- const listItems = action.selectedBlocks.map((node) => this.parent.toListItem(node));
446
- bulletList.apply(new AppendChildNodesAction(listItems));
447
- this.parent.apply(new InsertBlocksAfterAction(action.selectedBlocks[0], bulletList));
448
- action.selectedBlocks.forEach((node) => {
449
- node.parent.apply(new RemoveChildAction(node));
450
- });
451
- }
452
- /**
453
- * insertImage
454
- *
455
- * @param {InsertImageToBlockAction} action - ModifyContentAction
151
+ * @inheritDoc
456
152
  */
457
- insertImage(action) {
458
- const splitNode = action.splitPointNode;
459
- const startOffsetOfNode = action.startOffsetOfNode;
460
- const newImageBlock = action.imageBlockToBeInserted;
461
- if (this.isCaretPositionAtEnd(splitNode, startOffsetOfNode)) {
462
- this.parent.apply(new InsertBlocksAfterAction(this, newImageBlock));
463
- }
464
- else if (this.isCaretPositionAtStart(splitNode, startOffsetOfNode)) {
465
- this.parent.apply(new InsertBlocksBeforeAction(this, newImageBlock));
466
- }
467
- else {
468
- const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
469
- this.apply(splitBlockAction);
470
- this.parent.apply(new InsertBlocksAfterAction(this, newImageBlock));
153
+ doAnnotationActionApply(action) {
154
+ const strategy = ActionHandleStrategyRegistry.get(action.constructor.name, RTETextBlock.name);
155
+ if (strategy) {
156
+ strategy.execute(action, this);
471
157
  }
472
158
  }
473
- /**
474
- * copyInlineStyleToNewParagraph
475
- *
476
- * @param {RTETextNode} needCopedNode -
477
- * @returns {RTETextBlock} RTETextBlock
478
- */
479
- copyInlineStyleToNewParagraph(needCopedNode) {
480
- const textNode = needCopedNode.cloneWithText('');
481
- // The link annotation don't need inherited
482
- textNode.annotationMap.delete(NodeAnnotationTypeEnum.LINK);
483
- const newParagraph = new RTETextBlock(generateUUID(), 'paragraph');
484
- newParagraph.apply(new AppendChildNodesAction([textNode]));
485
- return newParagraph;
486
- }
487
159
  }
160
+ (() => {
161
+ ActionHandleStrategyRegistry.register(TextStyleAnnotationAction.name, RTETextBlock.name, new BlockUpdateTextStyleStrategy());
162
+ ActionHandleStrategyRegistry.register(LinkGroupAnnotationAction.name, RTETextBlock.name, new BlockUpdateLinkGroupStrategy());
163
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTETextBlock.name, new BlockRemoveNodeStrategy());
164
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTETextBlock.name, new BlockAppendNodesStrategy());
165
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTETextBlock.name, new BlockSplitWithTextNodeStrategy());
166
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_CHILD_NODES, RTETextBlock.name, new BlockReplaceNodesStrategy());
167
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTETextBlock.name, new BlockMergeNodesStrategy());
168
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.BREAK_SINGLE_BLOCK, RTETextBlock.name, new BlockInsertNewParagraphStrategy());
169
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTETextBlock.name, new BlockInsertLineBreakStrategy());
170
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTETextBlock.name, new BlockInsertLineBreakWithBlocksStrategy());
171
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_BLOCK_CONTENT, RTETextBlock.name, new BlockDeleteTextContentStrategy());
172
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTETextBlock.name, new BlockInsertImageIntoTextStrategy());
173
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_BEFORE, RTETextBlock.name, new BlockInsertNodesBeforeNodeStrategy());
174
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.TRANSFORM_LIST_BLOCK, RTETextBlock.name, new BlockTransformToListStrategy());
175
+ })();