@heartlandone/vega 2.49.1 → 2.50.0-RTE-preview

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 (646) hide show
  1. package/dist/cjs/{app-globals-65622aeb.js → app-globals-8e811cac.js} +6 -6
  2. package/dist/cjs/{child-nodes-event-prevent-slimmer-cc193ee1.js → child-nodes-event-prevent-slimmer-26ecfb15.js} +1 -1
  3. package/dist/cjs/{content-state-6a48bcb5.js → code-block-4cd8bccd.js} +1166 -1131
  4. package/dist/cjs/content-state-6cb98931.js +2496 -0
  5. package/dist/cjs/{design-token-cba4222e.js → design-token-8b48cb59.js} +1 -1
  6. package/dist/cjs/{element-appender-slimmer-4a26ecb2.js → element-appender-slimmer-d6b975e6.js} +3 -3
  7. package/dist/cjs/{event-emit-slimmer-8247249c.js → event-emit-slimmer-ee7a8c06.js} +1 -1
  8. package/dist/cjs/{form-field-controller-slimmer-4b0af5bc.js → form-field-controller-slimmer-88cbb139.js} +4 -4
  9. package/dist/cjs/{image-annotation-action-9c2b9c8e.js → image-annotation-action-f36b1a72.js} +65 -35
  10. package/dist/cjs/{index-c4dec3aa.js → index-4dd54e6b.js} +1 -1
  11. package/dist/cjs/{index-09acd3c9.js → index-7700600c.js} +9 -0
  12. package/dist/cjs/index.cjs.js +17 -16
  13. package/dist/cjs/{internal-vega-event-manager-c9948b59.js → internal-vega-event-manager-58afcde7.js} +1 -0
  14. package/dist/cjs/loader.cjs.js +11 -9
  15. package/dist/cjs/{public-rules-10ec636d.js → public-rules-555271e0.js} +8 -6
  16. package/dist/cjs/{responsive-format-facade-263d49f6.js → responsive-format-facade-8ce41c8a.js} +3 -3
  17. package/dist/cjs/{rich-text-editor-required-rule-5faded94.js → rich-text-editor-required-rule-d1b38bf7.js} +1 -1
  18. package/dist/cjs/selection-controller-828990cc.js +765 -0
  19. package/dist/cjs/string-39438062.js +24 -0
  20. package/dist/cjs/{string-input-formatter-slimmer-50322824.js → string-input-formatter-slimmer-9e7d7ce2.js} +2 -2
  21. package/dist/cjs/{style-formatter-ae0ef7fc.js → style-formatter-2294d77f.js} +1 -1
  22. package/dist/cjs/{sub-state-notify-slimmer-7f437b19.js → sub-state-notify-slimmer-f3ee01b7.js} +1 -1
  23. package/dist/cjs/{sub-state-observer-slimmer-e90362cd.js → sub-state-observer-slimmer-e1a00b74.js} +1 -1
  24. package/dist/cjs/{translation-212b1875.js → translation-e5003a00.js} +5 -0
  25. package/dist/cjs/{translation-slimmer-d1512c6d.js → translation-slimmer-127a0f83.js} +1 -1
  26. package/dist/cjs/vega-accordion.cjs.entry.js +11 -9
  27. package/dist/cjs/vega-app-footer.cjs.entry.js +1 -1
  28. package/dist/cjs/vega-app-header-button.cjs.entry.js +12 -10
  29. package/dist/cjs/vega-backdrop.cjs.entry.js +1 -1
  30. package/dist/cjs/vega-banner.cjs.entry.js +3 -3
  31. package/dist/cjs/vega-bar-chart.cjs.entry.js +1 -1
  32. package/dist/cjs/vega-box.cjs.entry.js +11 -9
  33. package/dist/cjs/vega-brand-logo.cjs.entry.js +1 -1
  34. package/dist/cjs/vega-breadcrumb.cjs.entry.js +4 -4
  35. package/dist/cjs/vega-button-circle.cjs.entry.js +12 -10
  36. package/dist/cjs/vega-button-group_2.cjs.entry.js +7 -7
  37. package/dist/cjs/vega-button-link.cjs.entry.js +4 -4
  38. package/dist/cjs/vega-button.cjs.entry.js +11 -9
  39. package/dist/cjs/vega-calendar_3.cjs.entry.js +9 -9
  40. package/dist/cjs/vega-card.cjs.entry.js +10 -8
  41. package/dist/cjs/vega-carousel.cjs.entry.js +10 -8
  42. package/dist/cjs/vega-checkbox_2.cjs.entry.js +9 -9
  43. package/dist/cjs/vega-chip.cjs.entry.js +12 -10
  44. package/dist/cjs/vega-code-block.cjs.entry.js +4073 -0
  45. package/dist/cjs/vega-color-picker.cjs.entry.js +8 -8
  46. package/dist/cjs/vega-combo-box.cjs.entry.js +9 -9
  47. package/dist/cjs/vega-counter-badge.cjs.entry.js +1 -1
  48. package/dist/cjs/vega-date-picker_2.cjs.entry.js +17 -16
  49. package/dist/cjs/vega-dialog_2.cjs.entry.js +12 -10
  50. package/dist/cjs/vega-divider.cjs.entry.js +10 -8
  51. package/dist/cjs/vega-dropdown_5.cjs.entry.js +15 -13
  52. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  53. package/dist/cjs/vega-field-error.cjs.entry.js +1 -1
  54. package/dist/cjs/vega-field-label.cjs.entry.js +3 -3
  55. package/dist/cjs/vega-file-uploader.cjs.entry.js +9 -9
  56. package/dist/cjs/vega-flag-icon.cjs.entry.js +10 -8
  57. package/dist/cjs/vega-flex.cjs.entry.js +11 -9
  58. package/dist/cjs/vega-font.cjs.entry.js +10 -8
  59. package/dist/cjs/vega-form.cjs.entry.js +10 -10
  60. package/dist/cjs/vega-grid.cjs.entry.js +10 -8
  61. package/dist/cjs/vega-hint.cjs.entry.js +1 -1
  62. package/dist/cjs/vega-icon.cjs.entry.js +10 -8
  63. package/dist/cjs/vega-image-uploader.cjs.entry.js +14 -13
  64. package/dist/cjs/vega-input-credit-card.cjs.entry.js +9 -9
  65. package/dist/cjs/vega-input-numeric.cjs.entry.js +10 -10
  66. package/dist/cjs/vega-input-phone-number.cjs.entry.js +12 -11
  67. package/dist/cjs/vega-input-range.cjs.entry.js +10 -10
  68. package/dist/cjs/vega-input-select.cjs.entry.js +19 -18
  69. package/dist/cjs/vega-input.cjs.entry.js +10 -10
  70. package/dist/cjs/{vega-internal-event-id-bfea9b93.js → vega-internal-event-id-62371952.js} +2 -0
  71. package/dist/cjs/vega-item-toggle.cjs.entry.js +3 -3
  72. package/dist/cjs/vega-left-nav_5.cjs.entry.js +13 -11
  73. package/dist/cjs/vega-line-chart.cjs.entry.js +1 -1
  74. package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +9 -7
  75. package/dist/cjs/vega-page-notification_2.cjs.entry.js +1 -1
  76. package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +4 -4
  77. package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +4 -4
  78. package/dist/cjs/vega-pagination.cjs.entry.js +12 -10
  79. package/dist/cjs/vega-pie-chart.cjs.entry.js +1 -1
  80. package/dist/cjs/vega-popover_2.cjs.entry.js +11 -9
  81. package/dist/cjs/vega-progress-tracker.cjs.entry.js +3 -3
  82. package/dist/cjs/vega-radio_2.cjs.entry.js +9 -9
  83. package/dist/cjs/vega-rich-text-content.cjs.entry.js +311 -137
  84. package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +1225 -2502
  85. package/dist/cjs/vega-section-title.cjs.entry.js +1 -1
  86. package/dist/cjs/vega-segment-control.cjs.entry.js +3 -3
  87. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +14 -13
  88. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +10 -10
  89. package/dist/cjs/vega-sidenav_3.cjs.entry.js +12 -10
  90. package/dist/cjs/vega-signature-capture.cjs.entry.js +14 -13
  91. package/dist/cjs/{vega-skeleton-loader-controller-db868c98.js → vega-skeleton-loader-controller-83e05b6c.js} +1 -1
  92. package/dist/cjs/vega-skeleton.cjs.entry.js +1 -1
  93. package/dist/cjs/vega-slot-container.cjs.entry.js +1 -1
  94. package/dist/cjs/vega-stepper.cjs.entry.js +9 -9
  95. package/dist/cjs/vega-tab-group_2.cjs.entry.js +4 -4
  96. package/dist/cjs/vega-table_8.cjs.entry.js +14 -12
  97. package/dist/cjs/vega-text.cjs.entry.js +1 -1
  98. package/dist/cjs/vega-textarea.cjs.entry.js +9 -9
  99. package/dist/cjs/vega-time-picker_2.cjs.entry.js +15 -14
  100. package/dist/cjs/vega-toggle-switch.cjs.entry.js +8 -8
  101. package/dist/cjs/vega-tooltip_2.cjs.entry.js +10 -8
  102. package/dist/cjs/vega.cjs.js +11 -9
  103. package/dist/collection/collection-manifest.json +7 -1
  104. package/dist/collection/components/vega-code-block/assets/copy.js +3 -0
  105. package/dist/collection/components/vega-code-block/slimmers/controllers/code-highlight-parser.abstract.js +62 -0
  106. package/dist/collection/components/vega-code-block/slimmers/controllers/default-code-highlight-parse-controller.js +48 -0
  107. package/dist/collection/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.js +99 -0
  108. package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-content-parse-controller.js +50 -0
  109. package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-focus-controller.js +57 -0
  110. package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-input-controller.js +255 -0
  111. package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-selection-controller.js +266 -0
  112. package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-value-controller.js +44 -0
  113. package/dist/collection/components/vega-code-block/slimmers/renderers/vega-code-block-content-renderer.js +123 -0
  114. package/dist/collection/components/vega-code-block/slimmers/renderers/vega-code-block-copy-button-renderer.js +67 -0
  115. package/dist/collection/components/vega-code-block/slimmers/renderers/vega-code-block-renderer.js +122 -0
  116. package/dist/collection/components/vega-code-block/types.js +10 -0
  117. package/dist/collection/components/vega-code-block/vega-code-block.css +158 -0
  118. package/dist/collection/components/vega-code-block/vega-code-block.js +399 -0
  119. package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +5 -5
  120. package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +2 -0
  121. package/dist/collection/components/vega-rich-text-content/vega-rich-text-content.css +60 -5
  122. package/dist/collection/components/vega-rich-text-editor/assets/file-code.js +3 -0
  123. package/dist/collection/components/vega-rich-text-editor/assets/rectangle-code.js +3 -0
  124. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy.abstract.js +24 -0
  125. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-horizontal-alignment-strategy.js +15 -0
  126. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-indent-strategy.js +15 -0
  127. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy.js +1 -0
  128. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/code-node-set-selection-range-strategy.js +13 -0
  129. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/node-update-annotation-map-strategy.js +14 -0
  130. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy.js +3 -1
  131. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.js +1 -1
  132. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-code-block-strategy.js +48 -0
  133. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-insert-image-strategy.js +17 -0
  134. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-remove-self-strategy.js +77 -0
  135. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/switch-out-from-code-block-strategy.js +38 -0
  136. package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/update-code-block-strategy.js +14 -0
  137. package/dist/collection/components/vega-rich-text-editor/dto/actions/custom-style-annotation-action.js +20 -0
  138. package/dist/collection/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.js +4 -0
  139. package/dist/collection/components/vega-rich-text-editor/dto/actions/remove-code-block-action.js +13 -0
  140. package/dist/collection/components/vega-rich-text-editor/dto/actions/switch-out-from-code-block-action.js +15 -0
  141. package/dist/collection/components/vega-rich-text-editor/dto/actions/transform-to-code-block-action.js +13 -0
  142. package/dist/collection/components/vega-rich-text-editor/dto/actions/update-code-block-action.js +15 -0
  143. package/dist/collection/components/vega-rich-text-editor/dto/annotations/block-annotation.abstract.js +1 -0
  144. package/dist/collection/components/vega-rich-text-editor/dto/annotations/bold-annotation.js +13 -5
  145. package/dist/collection/components/vega-rich-text-editor/dto/annotations/clear-formatting-annotation.js +2 -0
  146. package/dist/collection/components/vega-rich-text-editor/dto/annotations/code-annotation.js +14 -9
  147. package/dist/collection/components/vega-rich-text-editor/dto/annotations/common-annotation.abstract.js +12 -0
  148. package/dist/collection/components/vega-rich-text-editor/dto/annotations/custom-attribute-annotation.js +65 -0
  149. package/dist/collection/components/vega-rich-text-editor/dto/annotations/custom-class-annotation.js +54 -0
  150. package/dist/collection/components/vega-rich-text-editor/dto/annotations/custom-style-annotation.js +57 -0
  151. package/dist/collection/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.js +26 -10
  152. package/dist/collection/components/vega-rich-text-editor/dto/annotations/image-annotation.js +16 -7
  153. package/dist/collection/components/vega-rich-text-editor/dto/annotations/indent-annotation.js +8 -2
  154. package/dist/collection/components/vega-rich-text-editor/dto/annotations/italic-annotation.js +13 -5
  155. package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-annotation.js +12 -9
  156. package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-group-annotation.js +89 -0
  157. package/dist/collection/components/vega-rich-text-editor/dto/annotations/list-annotation.js +41 -0
  158. package/dist/collection/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.js +9 -9
  159. package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-color-annotation.js +3 -7
  160. package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-style-annotation.js +74 -12
  161. package/dist/collection/components/vega-rich-text-editor/dto/annotations/underline-annotation.js +9 -9
  162. package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +69 -2
  163. package/dist/collection/components/vega-rich-text-editor/dto/blocks/code-block.js +106 -0
  164. package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +15 -1
  165. package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +50 -0
  166. package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +12 -1
  167. package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +66 -2
  168. package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +29 -0
  169. package/dist/collection/components/vega-rich-text-editor/dto/nodes/code-block-node.js +56 -0
  170. package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +26 -9
  171. package/dist/collection/components/vega-rich-text-editor/dto/nodes/node.abstract.js +81 -0
  172. package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +15 -2
  173. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-renderer.abstract.js +5 -22
  174. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.js +9 -93
  175. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/code-block-renderer.js +62 -0
  176. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/image-block-renderer.js +1 -1
  177. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/link-wrapper-renderer.js +121 -0
  178. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/list-block-renderer.js +1 -1
  179. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/list-item-block-renderer.js +1 -1
  180. package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.js +2 -23
  181. package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/code-block-node-renderer.js +81 -0
  182. package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/image-node-renderer.js +47 -7
  183. package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/node-renderer.abstract.js +0 -27
  184. package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.js +3 -2
  185. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/delete-selected-nodes-controller.js +19 -4
  186. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/block-to-rte-block-strategy.abstract.js +155 -15
  187. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.js +2 -1
  188. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.js +6 -1
  189. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-rte-image-block-strategy.abstract.js +38 -0
  190. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy.js +3 -20
  191. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy.js +59 -5
  192. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.js +54 -0
  193. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/li-to-rte-list-item-block-strategy.js +1 -1
  194. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ol-to-rte-list-block-strategy.js +3 -2
  195. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy.js +3 -20
  196. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-not-li-child-to-rte-list-item-block.js +7 -3
  197. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy.js +3 -2
  198. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.js +69 -0
  199. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-image-to-rte-image-block-strategy.js +4 -7
  200. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-line-break-handler.js +7 -5
  201. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paragraph-handler.js +7 -5
  202. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.js +25 -10
  203. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/internal-code-block-selection-controller.js +64 -0
  204. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/selection-controller.js +59 -53
  205. package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.js +21 -8
  206. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/toolbar-renderer.js +10 -0
  207. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.js +5 -3
  208. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.js +5 -3
  209. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.js +5 -3
  210. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.js +5 -3
  211. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.js +5 -3
  212. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/code-block-toolbar-button-slimmer.js +65 -0
  213. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/code-toolbar-button-slimmer.js +5 -3
  214. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/center-align-toolbar-button-slimmer.js +2 -2
  215. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.js +8 -2
  216. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/justify-align-toolbar-button-slimmer.js +2 -2
  217. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/left-align-toolbar-button-slimmer.js +2 -2
  218. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/right-align-toolbar-button-slimmer.js +2 -2
  219. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.js +2 -2
  220. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.js +5 -3
  221. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.js +3 -3
  222. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.js +2 -2
  223. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.js +3 -3
  224. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.js +60 -0
  225. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.js +5 -3
  226. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.js +5 -3
  227. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.js +6 -4
  228. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/toolbar-button-slimmer.abstract.js +3 -2
  229. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.js +5 -3
  230. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/visual-mode-toolbar-button-slimmer.abstract.js +28 -0
  231. package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-renderer.js +31 -3
  232. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/code-block-strategy-registry.test.js +21 -0
  233. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.js +2 -0
  234. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/image-block-strategy-register.test.js +3 -0
  235. package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.js +23 -1
  236. package/dist/collection/components/vega-rich-text-editor/test/dto/annotations.test.js +247 -27
  237. package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/code-block.test.js +54 -0
  238. package/dist/collection/components/vega-rich-text-editor/test/dto/content-state.test.js +1793 -0
  239. package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/image-node.test.js +12 -0
  240. package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/text-node.test.js +41 -4
  241. package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.test.js +32 -0
  242. package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.test.js +61 -0
  243. package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.css +7 -0
  244. package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +18 -1
  245. package/dist/collection/helpers/code-format/code-formatter.js +108 -0
  246. package/dist/collection/helpers/code-format/test/code-formatter.test.js +362 -0
  247. package/dist/collection/helpers/event-manager/event-id/component-event-id-map.js +2 -1
  248. package/dist/collection/helpers/event-manager/event-id/vega-internal-event-id.js +1 -0
  249. package/dist/collection/helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract.js +47 -0
  250. package/dist/collection/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.js +46 -0
  251. package/dist/collection/helpers/translation/locales/en.js +5 -0
  252. package/dist/collection/helpers/translation/tests/internal-translation-controller.test.js +5 -0
  253. package/dist/collection/polyfill/shadow-selection/shadow-selection-polyfill.js +17 -15
  254. package/dist/collection/polyfill/shadow-selection/test/shadow-selection-polyfill.test.js +1 -0
  255. package/dist/collection/polyfill/test-polyfill/unit/methods.js +9 -0
  256. package/dist/collection/utils/string.js +10 -0
  257. package/dist/esm/{app-globals-1f8c30e9.js → app-globals-9058ac3b.js} +6 -6
  258. package/dist/esm/{child-nodes-event-prevent-slimmer-5d45361e.js → child-nodes-event-prevent-slimmer-1142fb79.js} +1 -1
  259. package/dist/esm/{content-state-dbc9f635.js → code-block-8b5bd928.js} +1141 -1122
  260. package/dist/esm/content-state-8c3f862b.js +2489 -0
  261. package/dist/esm/{design-token-0699f0ca.js → design-token-bd436e0d.js} +1 -1
  262. package/dist/esm/{dom-node-subject-factory-f77cf9cc.js → dom-node-subject-factory-eb6bba5d.js} +1 -1
  263. package/dist/esm/{dom-node-subject-observer-factory-715dccf9.js → dom-node-subject-observer-factory-6083d518.js} +1 -1
  264. package/dist/esm/{element-appender-slimmer-96cb54e2.js → element-appender-slimmer-baf5e249.js} +5 -5
  265. package/dist/esm/{event-emit-slimmer-b7d511f6.js → event-emit-slimmer-480d3b54.js} +3 -3
  266. package/dist/esm/{form-field-controller-slimmer-89a72ee7.js → form-field-controller-slimmer-bfb4034d.js} +6 -6
  267. package/dist/esm/{image-annotation-action-1aa938ab.js → image-annotation-action-a8b860ad.js} +57 -28
  268. package/dist/esm/{index-187f71d1.js → index-d0a47531.js} +9 -0
  269. package/dist/esm/{index-4aa167d6.js → index-db0ec3ee.js} +2 -2
  270. package/dist/esm/index.js +12 -11
  271. package/dist/esm/{internal-vega-event-manager-87dc436c.js → internal-vega-event-manager-56c6469a.js} +2 -1
  272. package/dist/esm/loader.js +12 -10
  273. package/dist/esm/polyfills/core-js.js +0 -0
  274. package/dist/esm/polyfills/dom.js +0 -0
  275. package/dist/esm/polyfills/es5-html-element.js +0 -0
  276. package/dist/esm/polyfills/index.js +0 -0
  277. package/dist/esm/polyfills/system.js +0 -0
  278. package/dist/esm/{public-rules-5cf6aa95.js → public-rules-90fbd41a.js} +8 -6
  279. package/dist/esm/{responsive-format-facade-42f3fcfa.js → responsive-format-facade-827de03a.js} +3 -3
  280. package/dist/esm/{rich-text-editor-required-rule-6a7cd3ee.js → rich-text-editor-required-rule-0d470d82.js} +1 -1
  281. package/dist/esm/selection-controller-dd4f4407.js +759 -0
  282. package/dist/esm/string-a953eafc.js +21 -0
  283. package/dist/esm/{string-input-formatter-slimmer-c61f82d6.js → string-input-formatter-slimmer-0d30b976.js} +3 -3
  284. package/dist/esm/{style-formatter-cb00c709.js → style-formatter-232842f5.js} +1 -1
  285. package/dist/esm/{sub-state-notify-slimmer-4e3cf09d.js → sub-state-notify-slimmer-04e06501.js} +2 -2
  286. package/dist/esm/{sub-state-observer-slimmer-be7a6ce3.js → sub-state-observer-slimmer-b4c2ddc3.js} +2 -2
  287. package/dist/esm/{translation-cf7f020a.js → translation-71e0711d.js} +5 -0
  288. package/dist/esm/{translation-slimmer-88966d5c.js → translation-slimmer-e6b130bf.js} +1 -1
  289. package/dist/esm/vega-accordion.entry.js +13 -11
  290. package/dist/esm/vega-app-footer.entry.js +1 -1
  291. package/dist/esm/vega-app-header-button.entry.js +14 -12
  292. package/dist/esm/vega-backdrop.entry.js +1 -1
  293. package/dist/esm/vega-banner.entry.js +5 -5
  294. package/dist/esm/vega-bar-chart.entry.js +1 -1
  295. package/dist/esm/vega-box.entry.js +12 -10
  296. package/dist/esm/vega-brand-logo.entry.js +1 -1
  297. package/dist/esm/vega-breadcrumb.entry.js +6 -6
  298. package/dist/esm/vega-button-circle.entry.js +14 -12
  299. package/dist/esm/vega-button-group_2.entry.js +9 -9
  300. package/dist/esm/vega-button-link.entry.js +6 -6
  301. package/dist/esm/vega-button.entry.js +13 -11
  302. package/dist/esm/vega-calendar_3.entry.js +11 -11
  303. package/dist/esm/vega-card.entry.js +11 -9
  304. package/dist/esm/vega-carousel.entry.js +12 -10
  305. package/dist/esm/vega-checkbox_2.entry.js +11 -11
  306. package/dist/esm/vega-chip.entry.js +14 -12
  307. package/dist/esm/vega-code-block.entry.js +4069 -0
  308. package/dist/esm/vega-color-picker.entry.js +10 -10
  309. package/dist/esm/vega-combo-box.entry.js +11 -11
  310. package/dist/esm/vega-counter-badge.entry.js +1 -1
  311. package/dist/esm/vega-date-picker_2.entry.js +19 -18
  312. package/dist/esm/vega-dialog_2.entry.js +14 -12
  313. package/dist/esm/vega-divider.entry.js +11 -9
  314. package/dist/esm/vega-dropdown_5.entry.js +17 -15
  315. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  316. package/dist/esm/vega-field-error.entry.js +1 -1
  317. package/dist/esm/vega-field-label.entry.js +5 -5
  318. package/dist/esm/vega-file-uploader.entry.js +11 -11
  319. package/dist/esm/vega-flag-icon.entry.js +11 -9
  320. package/dist/esm/vega-flex.entry.js +12 -10
  321. package/dist/esm/vega-font.entry.js +11 -9
  322. package/dist/esm/vega-form.entry.js +12 -12
  323. package/dist/esm/vega-grid.entry.js +11 -9
  324. package/dist/esm/vega-hint.entry.js +1 -1
  325. package/dist/esm/vega-icon.entry.js +11 -9
  326. package/dist/esm/vega-image-uploader.entry.js +16 -15
  327. package/dist/esm/vega-input-credit-card.entry.js +11 -11
  328. package/dist/esm/vega-input-numeric.entry.js +12 -12
  329. package/dist/esm/vega-input-phone-number.entry.js +14 -13
  330. package/dist/esm/vega-input-range.entry.js +12 -12
  331. package/dist/esm/vega-input-select.entry.js +21 -20
  332. package/dist/esm/vega-input.entry.js +12 -12
  333. package/dist/esm/{vega-internal-event-id-85ad403f.js → vega-internal-event-id-820393ad.js} +2 -1
  334. package/dist/esm/vega-item-toggle.entry.js +5 -5
  335. package/dist/esm/vega-left-nav_5.entry.js +15 -13
  336. package/dist/esm/vega-line-chart.entry.js +1 -1
  337. package/dist/esm/vega-loader-wrapper_2.entry.js +10 -8
  338. package/dist/esm/vega-page-notification_2.entry.js +3 -3
  339. package/dist/esm/vega-pagination-page-selector-mobile.entry.js +6 -6
  340. package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +6 -6
  341. package/dist/esm/vega-pagination.entry.js +14 -12
  342. package/dist/esm/vega-pie-chart.entry.js +1 -1
  343. package/dist/esm/vega-popover_2.entry.js +13 -11
  344. package/dist/esm/vega-progress-tracker.entry.js +5 -5
  345. package/dist/esm/vega-radio_2.entry.js +11 -11
  346. package/dist/esm/vega-rich-text-content.entry.js +305 -131
  347. package/dist/esm/vega-rich-text-editor_4.entry.js +1132 -2409
  348. package/dist/esm/vega-section-title.entry.js +1 -1
  349. package/dist/esm/vega-segment-control.entry.js +5 -5
  350. package/dist/esm/vega-selection-chip_2.entry.js +16 -15
  351. package/dist/esm/vega-selection-tile_2.entry.js +12 -12
  352. package/dist/esm/vega-sidenav_3.entry.js +14 -12
  353. package/dist/esm/vega-signature-capture.entry.js +16 -15
  354. package/dist/esm/{vega-skeleton-loader-controller-c2a8bd27.js → vega-skeleton-loader-controller-878e1b28.js} +1 -1
  355. package/dist/esm/vega-skeleton.entry.js +1 -1
  356. package/dist/esm/vega-slot-container.entry.js +1 -1
  357. package/dist/esm/vega-stepper.entry.js +11 -11
  358. package/dist/esm/vega-tab-group_2.entry.js +6 -6
  359. package/dist/esm/vega-table_8.entry.js +16 -14
  360. package/dist/esm/vega-text.entry.js +1 -1
  361. package/dist/esm/vega-textarea.entry.js +11 -11
  362. package/dist/esm/vega-time-picker_2.entry.js +17 -16
  363. package/dist/esm/vega-toggle-switch.entry.js +10 -10
  364. package/dist/esm/vega-tooltip_2.entry.js +12 -10
  365. package/dist/esm/vega.js +12 -10
  366. package/dist/types/components/vega-code-block/assets/copy.d.ts +3 -0
  367. package/dist/types/components/vega-code-block/slimmers/controllers/code-highlight-parser.abstract.d.ts +40 -0
  368. package/dist/types/components/vega-code-block/slimmers/controllers/default-code-highlight-parse-controller.d.ts +19 -0
  369. package/dist/types/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.d.ts +43 -0
  370. package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-content-parse-controller.d.ts +23 -0
  371. package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-focus-controller.d.ts +21 -0
  372. package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-input-controller.d.ts +100 -0
  373. package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-selection-controller.d.ts +93 -0
  374. package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-value-controller.d.ts +21 -0
  375. package/dist/types/components/vega-code-block/slimmers/renderers/vega-code-block-content-renderer.d.ts +57 -0
  376. package/dist/types/components/vega-code-block/slimmers/renderers/vega-code-block-copy-button-renderer.d.ts +23 -0
  377. package/dist/types/components/vega-code-block/slimmers/renderers/vega-code-block-renderer.d.ts +50 -0
  378. package/dist/types/components/vega-code-block/types.d.ts +19 -0
  379. package/dist/types/components/vega-code-block/vega-code-block.d.ts +116 -0
  380. package/dist/types/components/vega-rich-text-editor/assets/file-code.d.ts +3 -0
  381. package/dist/types/components/vega-rich-text-editor/assets/rectangle-code.d.ts +3 -0
  382. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/action-handle-strategy.abstract.d.ts +15 -0
  383. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-horizontal-alignment-strategy.d.ts +15 -0
  384. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-indent-strategy.d.ts +15 -0
  385. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/code-node-set-selection-range-strategy.d.ts +12 -0
  386. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-node-content-strategy.d.ts +3 -3
  387. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.d.ts +4 -5
  388. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-code-block-strategy.d.ts +29 -0
  389. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-insert-image-strategy.d.ts +15 -0
  390. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-remove-self-strategy.d.ts +28 -0
  391. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/switch-out-from-code-block-strategy.d.ts +12 -0
  392. package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/update-code-block-strategy.d.ts +12 -0
  393. package/dist/types/components/vega-rich-text-editor/dto/actions/custom-style-annotation-action.d.ts +17 -0
  394. package/dist/types/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.d.ts +5 -1
  395. package/dist/types/components/vega-rich-text-editor/dto/actions/remove-code-block-action.d.ts +10 -0
  396. package/dist/types/components/vega-rich-text-editor/dto/actions/switch-out-from-code-block-action.d.ts +14 -0
  397. package/dist/types/components/vega-rich-text-editor/dto/actions/transform-to-code-block-action.d.ts +14 -0
  398. package/dist/types/components/vega-rich-text-editor/dto/actions/update-code-block-action.d.ts +14 -0
  399. package/dist/types/components/vega-rich-text-editor/dto/annotations/annotation.abstract.d.ts +2 -1
  400. package/dist/types/components/vega-rich-text-editor/dto/annotations/block-annotation.abstract.d.ts +17 -4
  401. package/dist/types/components/vega-rich-text-editor/dto/annotations/bold-annotation.d.ts +7 -5
  402. package/dist/types/components/vega-rich-text-editor/dto/annotations/clear-formatting-annotation.d.ts +2 -1
  403. package/dist/types/components/vega-rich-text-editor/dto/annotations/code-annotation.d.ts +5 -9
  404. package/dist/types/components/vega-rich-text-editor/dto/annotations/common-annotation.abstract.d.ts +20 -0
  405. package/dist/types/components/vega-rich-text-editor/dto/annotations/custom-attribute-annotation.d.ts +43 -0
  406. package/dist/types/components/vega-rich-text-editor/dto/annotations/custom-class-annotation.d.ts +40 -0
  407. package/dist/types/components/vega-rich-text-editor/dto/annotations/custom-style-annotation.d.ts +42 -0
  408. package/dist/types/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.d.ts +5 -9
  409. package/dist/types/components/vega-rich-text-editor/dto/annotations/image-annotation.d.ts +7 -5
  410. package/dist/types/components/vega-rich-text-editor/dto/annotations/indent-annotation.d.ts +5 -1
  411. package/dist/types/components/vega-rich-text-editor/dto/annotations/italic-annotation.d.ts +7 -5
  412. package/dist/types/components/vega-rich-text-editor/dto/annotations/link-annotation.d.ts +6 -4
  413. package/dist/types/components/vega-rich-text-editor/dto/annotations/link-group-annotation.d.ts +48 -0
  414. package/dist/types/components/vega-rich-text-editor/dto/annotations/list-annotation.d.ts +25 -0
  415. package/dist/types/components/vega-rich-text-editor/dto/annotations/node-annotation.abstract.d.ts +15 -3
  416. package/dist/types/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.d.ts +5 -9
  417. package/dist/types/components/vega-rich-text-editor/dto/annotations/text-color-annotation.d.ts +3 -7
  418. package/dist/types/components/vega-rich-text-editor/dto/annotations/text-style-annotation.d.ts +7 -5
  419. package/dist/types/components/vega-rich-text-editor/dto/annotations/underline-annotation.d.ts +5 -9
  420. package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +39 -4
  421. package/dist/types/components/vega-rich-text-editor/dto/blocks/code-block.d.ts +56 -0
  422. package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +4 -0
  423. package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +20 -2
  424. package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +4 -0
  425. package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +14 -4
  426. package/dist/types/components/vega-rich-text-editor/dto/content-state.d.ts +13 -0
  427. package/dist/types/components/vega-rich-text-editor/dto/nodes/code-block-node.d.ts +45 -0
  428. package/dist/types/components/vega-rich-text-editor/dto/nodes/image-node.d.ts +4 -0
  429. package/dist/types/components/vega-rich-text-editor/dto/nodes/node.abstract.d.ts +46 -2
  430. package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +7 -2
  431. package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-renderer.abstract.d.ts +4 -11
  432. package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.d.ts +7 -5
  433. package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/code-block-renderer.d.ts +39 -0
  434. package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/link-wrapper-renderer.d.ts +24 -0
  435. package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.d.ts +0 -1
  436. package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/code-block-node-renderer.d.ts +37 -0
  437. package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/image-node-renderer.d.ts +22 -0
  438. package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/node-renderer.abstract.d.ts +1 -15
  439. package/dist/types/components/vega-rich-text-editor/interface.d.ts +65 -26
  440. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/block-to-rte-block-strategy.abstract.d.ts +64 -6
  441. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.d.ts +3 -1
  442. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-rte-image-block-strategy.abstract.d.ts +20 -0
  443. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy.d.ts +2 -2
  444. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy.d.ts +30 -1
  445. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.d.ts +31 -0
  446. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ol-to-rte-list-block-strategy.d.ts +2 -3
  447. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy.d.ts +2 -2
  448. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy.d.ts +2 -3
  449. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.d.ts +42 -0
  450. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-image-to-rte-image-block-strategy.d.ts +2 -2
  451. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.d.ts +7 -1
  452. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/internal-code-block-selection-controller.d.ts +45 -0
  453. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/selection-controller.d.ts +17 -23
  454. package/dist/types/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.d.ts +6 -4
  455. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/toolbar-renderer.d.ts +2 -0
  456. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.d.ts +2 -2
  457. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.d.ts +3 -2
  458. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.d.ts +2 -2
  459. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.d.ts +2 -2
  460. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.d.ts +2 -2
  461. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/code-block-toolbar-button-slimmer.d.ts +22 -0
  462. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/code-toolbar-button-slimmer.d.ts +2 -2
  463. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/center-align-toolbar-button-slimmer.d.ts +2 -2
  464. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.d.ts +4 -2
  465. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/justify-align-toolbar-button-slimmer.d.ts +2 -2
  466. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/left-align-toolbar-button-slimmer.d.ts +2 -2
  467. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/right-align-toolbar-button-slimmer.d.ts +2 -2
  468. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.d.ts +3 -2
  469. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.d.ts +2 -2
  470. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.d.ts +2 -2
  471. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.d.ts +3 -2
  472. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.d.ts +2 -2
  473. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.d.ts +13 -0
  474. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.d.ts +2 -2
  475. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.d.ts +3 -2
  476. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.d.ts +3 -2
  477. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/toolbar-button-slimmer.abstract.d.ts +3 -2
  478. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.d.ts +2 -2
  479. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/visual-mode-toolbar-button-slimmer.abstract.d.ts +17 -0
  480. package/dist/types/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-renderer.d.ts +8 -2
  481. package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/code-block-strategy-registry.test.d.ts +1 -0
  482. package/dist/types/components/vega-rich-text-editor/test/dto/blocks/code-block.test.d.ts +1 -0
  483. package/dist/types/components/vega-rich-text-editor/test/dto/content-state.test.d.ts +1 -1
  484. package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.test.d.ts +1 -0
  485. package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.test.d.ts +1 -0
  486. package/dist/types/components/vega-rich-text-editor/vega-rich-text-editor.d.ts +7 -0
  487. package/dist/types/components.d.ts +95 -0
  488. package/dist/types/helpers/code-format/code-formatter.d.ts +34 -0
  489. package/dist/types/helpers/code-format/test/code-formatter.test.d.ts +1 -0
  490. package/dist/types/helpers/event-manager/event-id/vega-internal-event-id.d.ts +1 -0
  491. package/dist/types/helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract.d.ts +20 -0
  492. package/dist/types/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.d.ts +1 -0
  493. package/dist/types/helpers/translation/interface.d.ts +6 -1
  494. package/dist/types/polyfill/shadow-selection/shadow-selection-polyfill.d.ts +26 -0
  495. package/dist/types/types/components.type.d.ts +1 -0
  496. package/dist/types/utils/string.d.ts +7 -0
  497. package/dist/vega/index.esm.js +1 -1
  498. package/dist/vega/p-0104207d.entry.js +1 -0
  499. package/dist/vega/p-010f1715.entry.js +1 -0
  500. package/dist/vega/p-01593f9d.js +1 -0
  501. package/dist/vega/p-020b04ed.js +1 -0
  502. package/dist/vega/p-02841589.js +1 -0
  503. package/dist/vega/p-03cfb331.entry.js +9 -0
  504. package/dist/vega/{p-b649e86e.entry.js → p-0bff8716.entry.js} +1 -1
  505. package/dist/vega/p-1056a049.entry.js +1 -0
  506. package/dist/vega/p-10e41bbe.js +1 -0
  507. package/dist/vega/{p-83ef9e7d.entry.js → p-12e6173c.entry.js} +1 -1
  508. package/dist/vega/{p-54add0d2.js → p-1397ba3f.js} +1 -1
  509. package/dist/vega/p-13d9a1fd.entry.js +1 -0
  510. package/dist/vega/p-13eae47f.entry.js +1 -0
  511. package/dist/vega/p-1630864e.entry.js +1 -0
  512. package/dist/vega/p-1b335e30.entry.js +1 -0
  513. package/dist/vega/{p-8ade44bf.js → p-1e194737.js} +1 -1
  514. package/dist/vega/{p-252e42c7.entry.js → p-1f346008.entry.js} +1 -1
  515. package/dist/vega/p-1f86ab76.entry.js +1 -0
  516. package/dist/vega/p-1fe746ab.entry.js +1 -0
  517. package/dist/vega/{p-8c388b58.entry.js → p-211c028f.entry.js} +1 -1
  518. package/dist/vega/p-21d26bb4.js +2 -0
  519. package/dist/vega/{p-b351ace3.entry.js → p-23e6f2b2.entry.js} +1 -1
  520. package/dist/vega/p-268aea63.js +1 -0
  521. package/dist/vega/{p-a01f149d.entry.js → p-27ccf34d.entry.js} +1 -1
  522. package/dist/vega/{p-913eb7f9.entry.js → p-29f9be26.entry.js} +1 -1
  523. package/dist/vega/{p-27003a81.entry.js → p-30dcf606.entry.js} +1 -1
  524. package/dist/vega/{p-89ab72e3.js → p-3c20ae84.js} +1 -1
  525. package/dist/vega/p-4172fb81.js +1 -0
  526. package/dist/vega/{p-45f696b4.js → p-419697c6.js} +1 -1
  527. package/dist/vega/p-427e4cee.entry.js +1 -0
  528. package/dist/vega/p-4604ed0e.entry.js +1 -0
  529. package/dist/vega/{p-8d283666.js → p-4ab3df00.js} +1 -1
  530. package/dist/vega/{p-72ecfd40.js → p-4e8fb53a.js} +1 -1
  531. package/dist/vega/p-50a3ae3d.js +1 -0
  532. package/dist/vega/{p-b847a143.entry.js → p-50b80d76.entry.js} +1 -1
  533. package/dist/vega/p-531ffb18.entry.js +1 -0
  534. package/dist/vega/p-53daeb45.entry.js +1 -0
  535. package/dist/vega/p-54fdd401.entry.js +1 -0
  536. package/dist/vega/{p-47ff95ba.entry.js → p-5741ecf0.entry.js} +1 -1
  537. package/dist/vega/{p-6cabdb36.js → p-58f8928a.js} +1 -1
  538. package/dist/vega/{p-4a32a6c0.entry.js → p-5c4cb804.entry.js} +1 -1
  539. package/dist/vega/{p-a46bc9f1.entry.js → p-5ce386c8.entry.js} +1 -1
  540. package/dist/vega/p-5f377954.js +1 -1
  541. package/dist/vega/{p-0079088b.entry.js → p-5fd5a538.entry.js} +1 -1
  542. package/dist/vega/{p-0969877b.entry.js → p-64f452fe.entry.js} +1 -1
  543. package/dist/vega/p-66759f4e.js +1 -0
  544. package/dist/vega/{p-bc2dd43d.js → p-6ea42854.js} +1 -1
  545. package/dist/vega/p-70f25341.entry.js +1 -0
  546. package/dist/vega/{p-ec1f2d21.entry.js → p-737bccb9.entry.js} +1 -1
  547. package/dist/vega/{p-bcb10ae3.entry.js → p-7503fe08.entry.js} +1 -1
  548. package/dist/vega/{p-46714da3.entry.js → p-7b0a4688.entry.js} +1 -1
  549. package/dist/vega/p-7def7b74.entry.js +1 -0
  550. package/dist/vega/{p-48517a5d.entry.js → p-7f5a85c6.entry.js} +1 -1
  551. package/dist/vega/p-825ae7c4.js +1 -0
  552. package/dist/vega/p-831c4144.entry.js +1 -0
  553. package/dist/vega/p-85dc08b4.entry.js +1 -0
  554. package/dist/vega/{p-a821bcf3.js → p-86782109.js} +1 -1
  555. package/dist/vega/p-87459914.js +1 -0
  556. package/dist/vega/{p-1971d980.entry.js → p-87a1fc77.entry.js} +1 -1
  557. package/dist/vega/p-89565247.entry.js +1 -0
  558. package/dist/vega/{p-7088ead9.entry.js → p-89e915e9.entry.js} +1 -1
  559. package/dist/vega/{p-81fbfb6d.entry.js → p-8aa7e56e.entry.js} +1 -1
  560. package/dist/vega/p-94263ece.entry.js +1 -0
  561. package/dist/vega/{p-d0007822.entry.js → p-9524e48a.entry.js} +1 -1
  562. package/dist/vega/{p-147e3cbd.entry.js → p-991b4717.entry.js} +1 -1
  563. package/dist/vega/{p-647025dd.entry.js → p-99b9b320.entry.js} +1 -1
  564. package/dist/vega/{p-aea89be5.entry.js → p-9ba14b7c.entry.js} +1 -1
  565. package/dist/vega/p-9cb79f8d.entry.js +1 -0
  566. package/dist/vega/p-9e3f52f0.entry.js +1 -0
  567. package/dist/vega/{p-6586e2a2.entry.js → p-a0e122a6.entry.js} +1 -1
  568. package/dist/vega/{p-9803042f.entry.js → p-b0fe6c0f.entry.js} +1 -1
  569. package/dist/vega/{p-b2bca332.entry.js → p-b518e1a0.entry.js} +1 -1
  570. package/dist/vega/p-b538e81a.entry.js +1 -0
  571. package/dist/vega/p-b824baf7.entry.js +1 -0
  572. package/dist/vega/{p-2fadef27.entry.js → p-b959b4d4.entry.js} +1 -1
  573. package/dist/vega/{p-54f17c2e.entry.js → p-bb4f0fa1.entry.js} +1 -1
  574. package/dist/vega/{p-2da83c2a.js → p-bbb39d6f.js} +1 -1
  575. package/dist/vega/{p-cfda64fd.entry.js → p-bc8fd0ee.entry.js} +1 -1
  576. package/dist/vega/p-bcaf8375.entry.js +1 -0
  577. package/dist/vega/{p-02d7d948.entry.js → p-bec90ff3.entry.js} +1 -1
  578. package/dist/vega/p-c6b94dde.entry.js +1 -0
  579. package/dist/vega/{p-c754b32c.js → p-ce6b62c4.js} +1 -1
  580. package/dist/vega/{p-5e34ea25.entry.js → p-d00fbc11.entry.js} +1 -1
  581. package/dist/vega/{p-10a40dfb.entry.js → p-d2a2af2c.entry.js} +1 -1
  582. package/dist/vega/p-d64b20c2.js +1 -0
  583. package/dist/vega/p-da779940.entry.js +1 -0
  584. package/dist/vega/{p-a7dcb2a3.js → p-db910162.js} +1 -1
  585. package/dist/vega/{p-6f81fe1e.js → p-e1a2a701.js} +1 -1
  586. package/dist/vega/p-e3694aa5.entry.js +1 -0
  587. package/dist/vega/p-e7318c4c.entry.js +1 -0
  588. package/dist/vega/{p-a5c39ba2.entry.js → p-e8fc027e.entry.js} +1 -1
  589. package/dist/vega/{p-6a830bc5.entry.js → p-e92ecb78.entry.js} +1 -1
  590. package/dist/vega/p-e969c3f4.entry.js +1 -0
  591. package/dist/vega/{p-61eb7f32.entry.js → p-ec8b7f01.entry.js} +1 -1
  592. package/dist/vega/p-eed9bda2.entry.js +1 -0
  593. package/dist/vega/p-f4c54c98.entry.js +1 -0
  594. package/dist/vega/{p-5160a6b9.entry.js → p-f5fc80bc.entry.js} +1 -1
  595. package/dist/vega/p-f67be7ef.js +1 -0
  596. package/dist/vega/{p-5e3a15a1.js → p-f9fafc55.js} +1 -1
  597. package/dist/vega/{p-27e56c67.entry.js → p-fc21fb2d.entry.js} +1 -1
  598. package/dist/vega/p-fed9220b.entry.js +1 -0
  599. package/dist/vega/vega.esm.js +1 -1
  600. package/package.json +2 -1
  601. package/dist/cjs/string-21427167.js +0 -13
  602. package/dist/esm/string-be824360.js +0 -11
  603. package/dist/vega/p-06adb37e.entry.js +0 -1
  604. package/dist/vega/p-06c5fe97.entry.js +0 -1
  605. package/dist/vega/p-0bb29d98.js +0 -1
  606. package/dist/vega/p-0ed7a098.entry.js +0 -1
  607. package/dist/vega/p-0f6b3a89.entry.js +0 -1
  608. package/dist/vega/p-136f665b.entry.js +0 -1
  609. package/dist/vega/p-1503f791.js +0 -1
  610. package/dist/vega/p-16fd7c32.js +0 -1
  611. package/dist/vega/p-1a263af1.entry.js +0 -1
  612. package/dist/vega/p-1af4771a.entry.js +0 -1
  613. package/dist/vega/p-1c298d5a.js +0 -2
  614. package/dist/vega/p-1c63afd2.entry.js +0 -1
  615. package/dist/vega/p-1e05b7b4.entry.js +0 -1
  616. package/dist/vega/p-1ea863a6.entry.js +0 -1
  617. package/dist/vega/p-271b30b9.entry.js +0 -1
  618. package/dist/vega/p-2d1d4f33.entry.js +0 -1
  619. package/dist/vega/p-353b3ded.entry.js +0 -1
  620. package/dist/vega/p-44b0a005.js +0 -1
  621. package/dist/vega/p-4e76904e.entry.js +0 -1
  622. package/dist/vega/p-4ec0d36f.entry.js +0 -1
  623. package/dist/vega/p-5c954088.entry.js +0 -1
  624. package/dist/vega/p-646a9198.entry.js +0 -1
  625. package/dist/vega/p-6d7d923b.js +0 -1
  626. package/dist/vega/p-6e898779.js +0 -1
  627. package/dist/vega/p-77492977.entry.js +0 -1
  628. package/dist/vega/p-804f71b3.js +0 -1
  629. package/dist/vega/p-8789d34d.entry.js +0 -1
  630. package/dist/vega/p-8813c0ac.entry.js +0 -1
  631. package/dist/vega/p-8a85c7af.entry.js +0 -1
  632. package/dist/vega/p-8ba43640.entry.js +0 -1
  633. package/dist/vega/p-98c64d77.entry.js +0 -1
  634. package/dist/vega/p-9f3539a4.entry.js +0 -1
  635. package/dist/vega/p-b42aea55.entry.js +0 -1
  636. package/dist/vega/p-b5d70ee0.entry.js +0 -1
  637. package/dist/vega/p-bf1894ec.js +0 -1
  638. package/dist/vega/p-bfb344e1.entry.js +0 -1
  639. package/dist/vega/p-c9a4e79a.entry.js +0 -1
  640. package/dist/vega/p-dbc82247.js +0 -1
  641. package/dist/vega/p-e2e36d2b.entry.js +0 -1
  642. package/dist/vega/p-ef8272b5.entry.js +0 -1
  643. package/dist/vega/p-f4c1d961.js +0 -1
  644. package/dist/vega/p-f5279deb.entry.js +0 -1
  645. package/dist/vega/p-f8033cd3.entry.js +0 -1
  646. package/dist/vega/p-fe63bd50.entry.js +0 -1
@@ -0,0 +1,2489 @@
1
+ import { B as BlockDeleteNodeContentStrategy, R as RemoveChildAction, a as RTEImageNode, A as ActionHandleStrategy, b as ReplaceChildNodesAction, I as InsertBlocksAfterAction, c as AppendChildNodesAction, d as RTETextBlock, e as InsertBlocksBeforeAction, S as SplitBlockWithNodeAction, M as ModifyContentAction, f as ModifyContentActionType, g as RTETextNode, h as BlockReplaceNodeWithNodesStrategy, i as RTEBlock, j as ActionHandleStrategyRegistry, k as BlockMergeNodesStrategy, l as BlockRemoveNodeStrategy, m as BlockAppendNodesStrategy, n as BlockReplaceNodesStrategy, o as BlockInsertNodesBeforeNodeStrategy, H as HorizontalAlignmentAnnotationAction, p as BlockUpdateHorizontalAlignmentStrategy, q as BlockDeleteTextContentStrategy, N as NodeAnnotationTypeEnum, r as BlockInsertLineBreakStrategy, s as BlockInsertLineBreakWithBlocksStrategy, t as BlockSplitWithTextNodeStrategy, u as SyncUpSelectionAction, v as BlockAnnotation, w as BlockAnnotationTypeEnum, C as CustomStyleAnnotation, x as CustomClassAnnotation, y as CustomAttributeAnnotation, z as RTECodeBlock, D as RTE_TEXT_COLORS } from './code-block-8b5bd928.js';
2
+ import { g as generateUUID } from './create-public-api-runtime-metrics-slimmer-8ada793f.js';
3
+ import { i as isNonNullable } from './type-guard-158f6d7a.js';
4
+ import { d as dashCaseToCamel } from './string-a953eafc.js';
5
+ import { r as rgbToHex } from './ui-ed1283bb.js';
6
+
7
+ /**
8
+ * The image block delete the image node strategy.
9
+ */
10
+ class BlockDeleteImageStrategy extends BlockDeleteNodeContentStrategy {
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ handleAction(action, target) {
15
+ this.deleteNodeContent(action, target);
16
+ }
17
+ /**
18
+ * Deletes content from a block node based on specific conditions.
19
+ *
20
+ * @param {DeleteBlockContentAction} action - Delete block content action
21
+ * @param {RTEImageBlock} target - The image block.
22
+ */
23
+ deleteNodeContent(action, target) {
24
+ const startContainerNode = action
25
+ .startContainerNode, startOffset = action.startOffset;
26
+ let previousNode = this.getPreviousNode(startContainerNode);
27
+ let nextNode = null;
28
+ if (startOffset === 1) {
29
+ const parentBlock = target;
30
+ if (this.isContentFirstNode(startContainerNode)) {
31
+ nextNode = this.getNextNode(startContainerNode);
32
+ }
33
+ if (parentBlock.nodes.length === 1) {
34
+ parentBlock.parent.apply(new RemoveChildAction(parentBlock));
35
+ }
36
+ else {
37
+ parentBlock.apply(new RemoveChildAction(startContainerNode));
38
+ }
39
+ }
40
+ else {
41
+ const shouldRemoveNode = previousNode;
42
+ if (shouldRemoveNode && shouldRemoveNode instanceof RTEImageNode) {
43
+ previousNode = this.getPreviousNode(shouldRemoveNode);
44
+ shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
45
+ if (!previousNode) {
46
+ action.nextNode = startContainerNode;
47
+ }
48
+ }
49
+ }
50
+ if (previousNode) {
51
+ action.previousNode = previousNode;
52
+ }
53
+ else if (nextNode) {
54
+ action.nextNode = nextNode;
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Split the current image block with a special position strategy.
61
+ */
62
+ class BlockSplitWithImageNodeStrategy extends ActionHandleStrategy {
63
+ /**
64
+ * @inheritDoc
65
+ */
66
+ handleAction(action, target) {
67
+ action.newBlock = this.splitImageNodes(action.splitPointNode, action.startOffsetOfNode, target);
68
+ }
69
+ /**
70
+ * The image offset should be 0 or 1
71
+ * <vega-rich-text-image-editor><img /></vega-rich-text-image-editor>
72
+ *
73
+ * @param {RTEImageNode} imageNode The split point image node.
74
+ * @param {number} imageOffset The cursor point 0 | 1.
75
+ * @param {RTEImageBlock} target The image block.
76
+ * @returns {Nullable<RTEBlock>} The new block after split
77
+ */
78
+ splitImageNodes(imageNode, imageOffset, target) {
79
+ const nodesSplitIndex = target.nodes.indexOf(imageNode);
80
+ if (nodesSplitIndex > -1) {
81
+ const beforeNodes = target.nodes.slice(0, nodesSplitIndex + imageOffset);
82
+ const afterNodes = target.nodes.slice(nodesSplitIndex + imageOffset);
83
+ target.apply(new ReplaceChildNodesAction(beforeNodes));
84
+ const newBlock = this.cloneWithNodes(afterNodes, target);
85
+ target.parent.apply(new InsertBlocksAfterAction(target, newBlock));
86
+ return newBlock;
87
+ }
88
+ }
89
+ /**
90
+ * Creates a new RTEImageBlock instance with the provided RTEImageNode instances appended to it.
91
+ *
92
+ * @param {RTEImageNode[]} nodes - An array of RTEImageNode objects that will be used to create a new RTEImageBlock instance.
93
+ * @param {RTEImageBlock} target The image block.
94
+ * @returns {RTEImageBlock} A new `RTEImageBlock` object with the provided `nodes` appended to it.
95
+ */
96
+ cloneWithNodes(nodes, target) {
97
+ const block = target.createNewImageBlock();
98
+ block.nodes = [];
99
+ block.apply(new AppendChildNodesAction(nodes));
100
+ return block;
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Insert a new paragraph at the image block special position strategy.
106
+ */
107
+ class ImageInsertNewParagraphStrategy extends ActionHandleStrategy {
108
+ /**
109
+ * @inheritDoc
110
+ */
111
+ handleAction(action, target) {
112
+ action.newBlock = this.breakSingleBlock(action.startContainerNode, action.startOffset, target);
113
+ }
114
+ /**
115
+ * Used to split a block of text at a specific position and insert a new paragraph block.
116
+ *
117
+ * @param {RTEImageNode} splitNode - The node that needs to be split into separate blocks.
118
+ * @param {number} startOffsetOfNode - The index or position within the `splitNode` where the block should be broken or split.
119
+ * @param {RTEImageBlock} target - The image block.
120
+ * @returns {Nullable<RTEBlock>} Returns either a new paragraph block or the new block created after splitting the original block.
121
+ */
122
+ breakSingleBlock(splitNode, startOffsetOfNode, target) {
123
+ const newParagraph = RTETextBlock.from({
124
+ id: generateUUID(),
125
+ type: 'paragraph',
126
+ nodes: [{ id: generateUUID(), type: 'text', text: '' }],
127
+ });
128
+ if (this.isCaretPositionAtImageBlockEnd(target, splitNode, startOffsetOfNode)) {
129
+ target.parent.apply(new InsertBlocksAfterAction(target, newParagraph));
130
+ }
131
+ else if (this.isCaretPositionAtImageBlockStart(target, splitNode, startOffsetOfNode)) {
132
+ target.parent.apply(new InsertBlocksBeforeAction(target, newParagraph));
133
+ }
134
+ else {
135
+ const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
136
+ target.apply(splitBlockAction);
137
+ return splitBlockAction.newBlock;
138
+ }
139
+ return newParagraph;
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Break the current block after press enter, this action is similar with the SplitBlockWithNodeAction,
145
+ * The SplitBlockWithNodeAction split the current block to two same type blocks, but this action will create new paragraph or list item when break at start or end.
146
+ * The property `newBlock` use to store the new create block if need.
147
+ *
148
+ * @example currentBlock.apply(new BreakSingleBlockAction(startContainerNode, startOffset))
149
+ */
150
+ class BreakSingleBlockAction extends ModifyContentAction {
151
+ constructor(startContainerNode, startOffset) {
152
+ super();
153
+ this.type = ModifyContentActionType.BREAK_SINGLE_BLOCK;
154
+ this.startContainerNode = startContainerNode;
155
+ this.startOffset = startOffset;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * The image block insert line break strategy.
161
+ */
162
+ class ImageInsertLineBreakStrategy extends ActionHandleStrategy {
163
+ /**
164
+ * The image block not support insert the line break node, so invoke the insert new paragraph logic directly.
165
+ *
166
+ * @param {LineBreakSingleBlockAction} action - The action instance.
167
+ * @param {RTEImageBlock} target - The image block.
168
+ */
169
+ handleAction(action, target) {
170
+ const insertNewParagraphAction = new BreakSingleBlockAction(action.startContainerNode, action.startOffset);
171
+ target.apply(insertNewParagraphAction);
172
+ const newBlock = insertNewParagraphAction.newBlock;
173
+ if (newBlock) {
174
+ action.lineBreakNode = newBlock.nodes[0];
175
+ }
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Insert a line break node into multiple blocks selection at special position strategy.
181
+ */
182
+ class ImageInsertLineBreakWithBlocksStrategy extends ActionHandleStrategy {
183
+ /**
184
+ * @inheritDoc
185
+ */
186
+ handleAction(action, target) {
187
+ action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks, target);
188
+ }
189
+ /**
190
+ * Inserts a new paragraph block with a line break after a selected block of text in a rich text editor.
191
+ *
192
+ * @param {RTEBlock[]} selectedBlocks - An array of RTEBlock objects that represent the blocks that have been selected for a specific action in the Rich Text Editor.
193
+ * @param {RTEImageBlock} target - The image block.
194
+ * @returns {Nullable<RTETextNode>} Returns a Nullable RTETextNode.
195
+ */
196
+ lineBreakMultipleBlocks(selectedBlocks, target) {
197
+ const newParagraph = RTETextBlock.from({
198
+ id: generateUUID(),
199
+ type: 'paragraph',
200
+ nodes: [{ id: generateUUID(), type: 'text', text: '\n' }],
201
+ });
202
+ target.parent.apply(new InsertBlocksAfterAction(target, newParagraph));
203
+ const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
204
+ if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
205
+ afterNodes.push(new RTETextNode(generateUUID(), '\n', newParagraph));
206
+ }
207
+ newParagraph.apply(new AppendChildNodesAction(afterNodes));
208
+ return newParagraph['nodes'][0];
209
+ }
210
+ /**
211
+ * Concat the child nodes of multiple RTEBlocks if both are not images.
212
+ *
213
+ * @param {RTEBlock[]} blocks - multiple block of content in a rich text editor, such as a paragraph, heading, image, etc.
214
+ * @returns {RTENode[]} Array of connected block nodes
215
+ */
216
+ concatBlocksNodes(blocks) {
217
+ const nodes = [];
218
+ blocks.map((block) => {
219
+ if (block.type !== 'image') {
220
+ nodes.push(...block['nodes']);
221
+ block.parent.apply(new RemoveChildAction(block));
222
+ }
223
+ });
224
+ return nodes;
225
+ }
226
+ }
227
+
228
+ /**
229
+ * Insert a image node at the special position of image block.
230
+ */
231
+ class ImageBlockInsertImageStrategy extends ActionHandleStrategy {
232
+ /**
233
+ * @inheritDoc
234
+ */
235
+ handleAction(action, target) {
236
+ const splitNode = action.splitPointNode;
237
+ const startOffsetOfNode = action.startOffsetOfNode;
238
+ const newImageBlock = action.imageBlockToBeInserted;
239
+ const newImageNodes = newImageBlock.nodes;
240
+ if (target.nodes.length < 1) {
241
+ target.apply(new AppendChildNodesAction(newImageNodes));
242
+ }
243
+ else if (this.isCaretPositionAtImageBlockEnd(target, splitNode, startOffsetOfNode)) {
244
+ target.parent.apply(new InsertBlocksAfterAction(target, newImageBlock));
245
+ }
246
+ else if (this.isCaretPositionAtImageBlockStart(target, splitNode, startOffsetOfNode)) {
247
+ target.parent.apply(new InsertBlocksBeforeAction(target, newImageBlock));
248
+ }
249
+ else {
250
+ target.apply(new SplitBlockWithNodeAction(splitNode, startOffsetOfNode));
251
+ target.parent.apply(new InsertBlocksAfterAction(target, newImageBlock));
252
+ }
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Insert some text nodes at the behind of the node strategy.
258
+ */
259
+ class BlockInsertNodesAfterNodeStrategy extends BlockReplaceNodeWithNodesStrategy {
260
+ /**
261
+ * @inheritDoc
262
+ */
263
+ handleAction(action, target) {
264
+ const referNode = action.referNode;
265
+ const nodes = [referNode, ...action.nodesToBeInserted];
266
+ this.replaceNodeWithNodes(target, referNode, nodes);
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Image block
272
+ */
273
+ class RTEImageBlock extends RTEBlock {
274
+ constructor(id) {
275
+ super(id);
276
+ this.type = 'image';
277
+ this.nodes = [];
278
+ }
279
+ /**
280
+ * Converts a VegaRTEImageBlock object into an RTEImageBlock object by mapping nodes and creating annotations.
281
+ *
282
+ * @param {VegaRTEImageBlock} block - The block object to be converted.
283
+ * @returns {RTEImageBlock} An instance of `RTEImageBlock`
284
+ */
285
+ static from(block) {
286
+ const imageBlock = new RTEImageBlock(block.id);
287
+ const { annotations } = block;
288
+ imageBlock.nodes = block.nodes.map((image) => RTEImageNode.from(image, imageBlock));
289
+ if (annotations) {
290
+ Object.entries(annotations).forEach(([type, value]) => {
291
+ const item = this.createAnnotationEntity(type, value);
292
+ if (isNonNullable(item)) {
293
+ imageBlock.annotationMap.set(...item);
294
+ }
295
+ });
296
+ }
297
+ return imageBlock;
298
+ }
299
+ /**
300
+ * @inheritDoc
301
+ */
302
+ toJSON() {
303
+ return Object.assign(Object.assign({}, super.toJSON()), { type: 'image', nodes: this.nodes.map((node) => node.toJSON()) });
304
+ }
305
+ /**
306
+ * @inheritDoc
307
+ */
308
+ toHtml() {
309
+ const attrStr = super.generateAttributeString();
310
+ return [
311
+ `<div${attrStr}>`,
312
+ this.nodes.map((node) => node.toHtml()).join(''),
313
+ `</div>`,
314
+ ].join('');
315
+ }
316
+ /**
317
+ * @inheritDoc
318
+ */
319
+ isNotEmpty() {
320
+ return this.nodes.length > 0 && this.nodes.some((node) => node.url.length > 0);
321
+ }
322
+ /**
323
+ * @inheritDoc
324
+ */
325
+ getLastNode() {
326
+ return this.nodes[this.nodes.length - 1];
327
+ }
328
+ /**
329
+ * Create a new image block.
330
+ *
331
+ * @returns {RTEImageBlock} - The empty image block.
332
+ */
333
+ createNewImageBlock() {
334
+ return new RTEImageBlock(generateUUID());
335
+ }
336
+ /**
337
+ * @inheritDoc
338
+ */
339
+ clone() {
340
+ const clonedBlock = new RTEImageBlock(this.id);
341
+ clonedBlock.nodes = this.nodes.map((node) => {
342
+ const clonedNode = node.clone();
343
+ clonedNode.parentBlock = clonedBlock;
344
+ return clonedNode;
345
+ });
346
+ clonedBlock.annotationMap = super.cloneAnnotations();
347
+ clonedBlock.parent = this.parent;
348
+ return clonedBlock;
349
+ }
350
+ }
351
+ (() => {
352
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_BLOCK_CONTENT, RTEImageBlock.name, new BlockDeleteImageStrategy());
353
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTEImageBlock.name, new BlockMergeNodesStrategy());
354
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEImageBlock.name, new BlockRemoveNodeStrategy());
355
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEImageBlock.name, new BlockAppendNodesStrategy());
356
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_CHILD_NODES, RTEImageBlock.name, new BlockReplaceNodesStrategy());
357
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEImageBlock.name, new BlockSplitWithImageNodeStrategy());
358
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.BREAK_SINGLE_BLOCK, RTEImageBlock.name, new ImageInsertNewParagraphStrategy());
359
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEImageBlock.name, new ImageInsertLineBreakStrategy());
360
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEImageBlock.name, new ImageInsertLineBreakWithBlocksStrategy());
361
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEImageBlock.name, new ImageBlockInsertImageStrategy());
362
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_BEFORE, RTEImageBlock.name, new BlockInsertNodesBeforeNodeStrategy());
363
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_AFTER, RTEImageBlock.name, new BlockInsertNodesAfterNodeStrategy());
364
+ ActionHandleStrategyRegistry.register(HorizontalAlignmentAnnotationAction.name, RTEImageBlock.name, new BlockUpdateHorizontalAlignmentStrategy());
365
+ })();
366
+
367
+ /**
368
+ * The list item block block delete text content strategy.
369
+ */
370
+ class ListItemDeleteTextContentStrategy extends BlockDeleteTextContentStrategy {
371
+ /**
372
+ * Delete the list item content and delete the parent list after delete the last item.
373
+ *
374
+ * @param {DeleteBlockContentAction} action - The delete block content action instance.
375
+ * @param {RTEListItemBlock} target - The list item block.
376
+ */
377
+ handleAction(action, target) {
378
+ const listBlock = target.parent;
379
+ this.deleteNodeContent(action, target);
380
+ if (listBlock.blocks.length === 0) {
381
+ listBlock.parent.apply(new RemoveChildAction(listBlock));
382
+ }
383
+ }
384
+ }
385
+
386
+ /**
387
+ * Remove list item child node strategy.
388
+ */
389
+ class ListItemRemoveNodeStrategy extends ActionHandleStrategy {
390
+ /**
391
+ * Remove child node from the list item, remove the list item if the list item is empty.
392
+ *
393
+ * @param {RemoveChildAction} action - The remove child action instance.
394
+ * @param {RTEListItemBlock} target - The list item block.
395
+ */
396
+ handleAction(action, target) {
397
+ target.nodes = target.nodes.filter((node) => node !== action.entityToBeRemoved);
398
+ if (target.nodes.length === 0 && (!target.children || !target.children.length)) {
399
+ target.parent.apply(new RemoveChildAction(target));
400
+ }
401
+ }
402
+ }
403
+
404
+ /**
405
+ * Remove list item nest list block strategy.
406
+ */
407
+ class ListItemRemoveNestListStrategy extends ActionHandleStrategy {
408
+ /**
409
+ * Remove the nest list block from the list item, clear the property children when the children is empty.
410
+ *
411
+ * @param {RemoveNestListAction} action - The action instance.
412
+ * @param {RTEListItemBlock} target - The list item block.
413
+ */
414
+ handleAction(action, target) {
415
+ if (target.children) {
416
+ if (target.children.length > 1) {
417
+ target.children = target.children.filter((child) => child !== action.nestListBlockToBeRemoved);
418
+ }
419
+ else {
420
+ target.children = undefined;
421
+ }
422
+ }
423
+ }
424
+ }
425
+
426
+ /**
427
+ * Replace list item nest list strategy.
428
+ */
429
+ class ListItemReplaceNestListStrategy extends ActionHandleStrategy {
430
+ /**
431
+ * @inheritDoc
432
+ */
433
+ handleAction(action, target) {
434
+ action.newList.forEach((listBlock) => {
435
+ listBlock.parent = target;
436
+ });
437
+ target.children = action.newList;
438
+ }
439
+ }
440
+
441
+ /**
442
+ * Insert new paragraph into current list item block at special position.
443
+ */
444
+ class ListItemInsertNewParagraphStrategy extends ActionHandleStrategy {
445
+ /**
446
+ * @inheritDoc
447
+ */
448
+ handleAction(action, target) {
449
+ action.newBlock = this.breakSingleListItemBlock(action.startContainerNode, action.startOffset, target);
450
+ }
451
+ /**
452
+ * Breaks a single list item block at a specific position.
453
+ *
454
+ * @param {RTETextNode} splitNode - The node that needs to be split within a list item block.
455
+ * @param {number} startOffsetOfNode - The index within the `splitNode` where the break operation should occur.
456
+ * @param {RTEListItemBlock} target - The list item block.
457
+ * @returns {Nullable<RTEBlock>} Returns either a new `RTEListItemBlock` if the caret
458
+ * position is at the end of the `splitNode`, or it returns the result of splitting the block at the
459
+ * caret position if it is neither at the start nor at the end.
460
+ */
461
+ breakSingleListItemBlock(splitNode, startOffsetOfNode, target) {
462
+ const newListItem = target.createNewListItem();
463
+ const newBreakNode = this.copyInlineStyleToNewNode(splitNode);
464
+ newListItem.apply(new AppendChildNodesAction([newBreakNode]));
465
+ if (this.isCaretPositionAtTextBlockEnd(target, splitNode, startOffsetOfNode)) {
466
+ return this.breakListItemAtEnd(newListItem, target);
467
+ }
468
+ else if (this.isCaretPositionAtTextBlockStart(target, splitNode, startOffsetOfNode)) {
469
+ target.parent.apply(new InsertBlocksBeforeAction(target, newListItem));
470
+ }
471
+ else {
472
+ const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
473
+ target.apply(splitBlockAction);
474
+ return splitBlockAction.newBlock;
475
+ }
476
+ return newListItem;
477
+ }
478
+ /**
479
+ * Breaks a list item at the end and handles the insertion of a new list item or paragraph accordingly.
480
+ *
481
+ * @param {RTEListItemBlock} newListItem - Item that represents a new list item to be added to the existing list.
482
+ * @param {RTEListItemBlock} target - The list item block.
483
+ * @returns {RTEBlock} Returns a `RTEBlock`.
484
+ */
485
+ breakListItemAtEnd(newListItem, target) {
486
+ const lastItem = target.parent.blocks[target.parent.blocks.length - 1];
487
+ const currentItemIsEmpty = target.nodes.length === 1 && target.nodes[0].isEmpty();
488
+ if (target === lastItem && currentItemIsEmpty) {
489
+ const parentParent = target.parent.parent;
490
+ if (parentParent['type'] !== 'list-item') {
491
+ const newParagraph = RTETextBlock.from({
492
+ id: generateUUID(),
493
+ type: 'paragraph',
494
+ nodes: [],
495
+ });
496
+ newParagraph.apply(new AppendChildNodesAction(newListItem.nodes));
497
+ parentParent.apply(new InsertBlocksAfterAction(target.parent, newParagraph));
498
+ target.parent.apply(new RemoveChildAction(target));
499
+ return newParagraph;
500
+ }
501
+ else {
502
+ parentParent.parent.apply(new InsertBlocksAfterAction(parentParent, newListItem));
503
+ target.parent.apply(new RemoveChildAction(target));
504
+ }
505
+ }
506
+ else {
507
+ target.parent.apply(new InsertBlocksAfterAction(target, newListItem));
508
+ }
509
+ return newListItem;
510
+ }
511
+ /**
512
+ * Copy the inline style to new node
513
+ *
514
+ * @param {RTETextNode} needCopedNode - The node that needed to be copied to
515
+ * @returns {RTETextNode} Returns a `RTETextNode`.
516
+ */
517
+ copyInlineStyleToNewNode(needCopedNode) {
518
+ const textNode = needCopedNode.cloneWithText('');
519
+ // The link annotation doesn't need to inherit
520
+ textNode.annotationMap.delete(NodeAnnotationTypeEnum.LINK);
521
+ return textNode;
522
+ }
523
+ }
524
+
525
+ /**
526
+ * Insert image node to list item block strategy.
527
+ */
528
+ class ListItemInsertImageStrategy extends ActionHandleStrategy {
529
+ /**
530
+ * The image node can not insert into list item block, so insert image after parent list block.
531
+ *
532
+ * @param {InsertImageToBlockAction} action - The action instance.
533
+ * @param {RTEListItemBlock} target - The list item block.
534
+ */
535
+ handleAction(action, target) {
536
+ target.parent.apply(action);
537
+ }
538
+ }
539
+
540
+ /**
541
+ * List item block
542
+ */
543
+ class RTEListItemBlock extends RTETextBlock {
544
+ constructor(id, children) {
545
+ super(id, 'list-item');
546
+ this.children = [];
547
+ this.children = children;
548
+ }
549
+ /**
550
+ * Converts a VegaRTEListItemBlock object to an RTEListItemBlock
551
+ *
552
+ * @param {VegaRTEListBlock} block - Converts a `VegaRTEListItemBlock` object into an `RTEListItemBlock`.
553
+ * @returns {RTEListItemBlock} Return an instance of `RTEListItemBlock`
554
+ */
555
+ static from(block) {
556
+ const listItemBlock = new RTEListItemBlock(block.id);
557
+ listItemBlock.nodes = block.nodes.map((richText) => RTETextNode.from(richText, listItemBlock));
558
+ if (block.children) {
559
+ listItemBlock.children = block.children.map((child) => {
560
+ const listBlock = RTEListBlock.from(child);
561
+ listBlock.parent = listItemBlock;
562
+ return listBlock;
563
+ });
564
+ }
565
+ const { annotations } = block;
566
+ if (annotations) {
567
+ Object.entries(annotations).forEach(([type, value]) => {
568
+ const item = this.createAnnotationEntity(type, value);
569
+ if (isNonNullable(item)) {
570
+ listItemBlock.annotationMap.set(...item);
571
+ }
572
+ });
573
+ }
574
+ return listItemBlock;
575
+ }
576
+ /**
577
+ * @inheritDoc
578
+ */
579
+ toJSON() {
580
+ var _a;
581
+ return Object.assign(Object.assign({}, super.toJSON()), { type: 'list-item', children: (_a = this.children) === null || _a === void 0 ? void 0 : _a.map((block) => block.toJSON()) });
582
+ }
583
+ /**
584
+ * @inheritDoc
585
+ */
586
+ toHtml() {
587
+ const attrStr = super.generateAttributeString();
588
+ return [
589
+ `<li${attrStr}>`,
590
+ this.nodes.map((node) => node.toHtml()).join(''),
591
+ `</li>`,
592
+ ].join('');
593
+ }
594
+ /**
595
+ * @inheritDoc
596
+ */
597
+ cloneWithNodes(nodes) {
598
+ const block = new RTEListItemBlock(generateUUID());
599
+ block.nodes = [];
600
+ block.apply(new AppendChildNodesAction(nodes));
601
+ return block;
602
+ }
603
+ /**
604
+ * @inheritDoc
605
+ */
606
+ getLastNode() {
607
+ if (this.children && this.children.length > 0) {
608
+ const childListBlock = this.children[this.children.length - 1];
609
+ return childListBlock.getLastNode();
610
+ }
611
+ return super.getLastNode();
612
+ }
613
+ /**
614
+ * Create a new list item block.
615
+ *
616
+ * @returns {RTEListItemBlock} - A list item block.
617
+ */
618
+ createNewListItem() {
619
+ return new RTEListItemBlock(generateUUID());
620
+ }
621
+ /**
622
+ * @inheritDoc
623
+ */
624
+ clone() {
625
+ var _a;
626
+ const block = new RTEListItemBlock(this.id);
627
+ block.nodes = this.nodes.map((node) => {
628
+ const clonedNode = node.clone();
629
+ clonedNode.parentBlock = block;
630
+ return clonedNode;
631
+ });
632
+ block.annotationMap = super.cloneAnnotations();
633
+ block.children = (_a = this.children) === null || _a === void 0 ? void 0 : _a.map((child) => {
634
+ const clonedChild = child.clone();
635
+ clonedChild.parent = block;
636
+ return clonedChild;
637
+ });
638
+ block.parent = this.parent;
639
+ return block;
640
+ }
641
+ }
642
+ (() => {
643
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_BLOCK_CONTENT, RTEListItemBlock.name, new ListItemDeleteTextContentStrategy());
644
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new BlockInsertLineBreakStrategy());
645
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEListItemBlock.name, new BlockInsertLineBreakWithBlocksStrategy());
646
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEListItemBlock.name, new ListItemRemoveNodeStrategy());
647
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_NEST_LIST, RTEListItemBlock.name, new ListItemRemoveNestListStrategy());
648
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEListItemBlock.name, new BlockAppendNodesStrategy());
649
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEListItemBlock.name, new BlockSplitWithTextNodeStrategy());
650
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_CHILD_NODES, RTEListItemBlock.name, new BlockReplaceNodesStrategy());
651
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_NEST_LIST, RTEListItemBlock.name, new ListItemReplaceNestListStrategy());
652
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTEListItemBlock.name, new BlockMergeNodesStrategy());
653
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new ListItemInsertNewParagraphStrategy());
654
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListItemBlock.name, new ListItemInsertImageStrategy());
655
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_BEFORE, RTEListItemBlock.name, new BlockInsertNodesBeforeNodeStrategy());
656
+ })();
657
+
658
+ /**
659
+ * Insert block array at the front of the block strategy.
660
+ */
661
+ class BlockInsertBlocksBeforeStrategy extends ActionHandleStrategy {
662
+ /**
663
+ * @inheritDoc
664
+ */
665
+ handleAction(action, target) {
666
+ this.replaceBlockWithBlocks(target, action.referBlock, [
667
+ ...action.blocksToBeInserted,
668
+ action.referBlock,
669
+ ]);
670
+ }
671
+ /**
672
+ * Replaces a specific block with an array of blocks within a RTEContentBlock array.
673
+ *
674
+ * @param {RTEListBlock|VegaRTEContent} target - The list block or the VegaRTEContent instance.
675
+ * @param {RTEBlock} referBlock - Used as a reference block to identify the block that needs to be replaced in the `blocks` array.
676
+ * @param {RTEBlock[]} blocks - An array of RTEBlock objects that you want to replace the `referBlock` with in the `blocks` array.
677
+ */
678
+ replaceBlockWithBlocks(target, referBlock, blocks) {
679
+ if (target.blocks) {
680
+ blocks.forEach((block) => {
681
+ block.parent = target;
682
+ });
683
+ const arrayFixed = target.blocks;
684
+ target.blocks = arrayFixed.flatMap((block) => {
685
+ if (block === referBlock) {
686
+ return blocks;
687
+ }
688
+ else {
689
+ return block;
690
+ }
691
+ });
692
+ }
693
+ }
694
+ }
695
+
696
+ /**
697
+ * Insert block array at the behind of the block strategy.
698
+ */
699
+ class BlockInsertBlocksAfterStrategy extends BlockInsertBlocksBeforeStrategy {
700
+ /**
701
+ * @inheritDoc
702
+ */
703
+ handleAction(action, target) {
704
+ this.replaceBlockWithBlocks(target, action.referBlock, [
705
+ action.referBlock,
706
+ ...action.blocksToBeInserted,
707
+ ]);
708
+ }
709
+ }
710
+
711
+ /**
712
+ * Append new block array to list block or VegaRTEContent instance strategy.
713
+ */
714
+ class BlockAppendBlocksStrategy extends ActionHandleStrategy {
715
+ /**
716
+ * @inheritDoc
717
+ */
718
+ handleAction(action, target) {
719
+ const newBlocks = action.entityToBeAppended;
720
+ if (target.blocks) {
721
+ newBlocks.forEach((block) => {
722
+ block.parent = target;
723
+ });
724
+ const arrayFixed = target.blocks;
725
+ target.blocks = arrayFixed.concat(newBlocks);
726
+ }
727
+ }
728
+ }
729
+
730
+ /**
731
+ * Delete the nest list block action
732
+ *
733
+ * @example needRemovedNestList.parent.apply(new RemoveNestListAction(needRemovedNestList))
734
+ */
735
+ class RemoveNestListAction extends ModifyContentAction {
736
+ constructor(childList) {
737
+ super();
738
+ this.type = ModifyContentActionType.DELETE_NEST_LIST;
739
+ this.nestListBlockToBeRemoved = childList;
740
+ }
741
+ }
742
+
743
+ /**
744
+ * List block or VegaRTEContent remove child block strategy.
745
+ */
746
+ class BlockRemoveChildBlockStrategy extends ActionHandleStrategy {
747
+ /**
748
+ * @inheritDoc
749
+ */
750
+ handleAction(action, target) {
751
+ const blockToBeRemoved = action.entityToBeRemoved;
752
+ if (target.blocks) {
753
+ target.blocks = target.blocks.filter((block) => block !== blockToBeRemoved);
754
+ }
755
+ }
756
+ }
757
+
758
+ /**
759
+ * List remove list item strategy.
760
+ */
761
+ class ListRemoveListItemStrategy extends BlockRemoveChildBlockStrategy {
762
+ /**
763
+ * Remove the list item, check the list item and remove self if the list item is empty.
764
+ *
765
+ * @param {RemoveChildAction} action - The remove action instance.
766
+ * @param {RTEListBlock} target - The list block.
767
+ */
768
+ handleAction(action, target) {
769
+ super.handleAction(action, target);
770
+ const parent = target.parent;
771
+ if (target.blocks.length === 0 && parent) {
772
+ // The parent is a list item mean the current block is a nest list, so we need to use RemoveNestListAction to remove the item
773
+ if (parent['type'] === 'list-item') {
774
+ parent.apply(new RemoveNestListAction(target));
775
+ }
776
+ else {
777
+ parent.apply(new RemoveChildAction(target));
778
+ }
779
+ }
780
+ }
781
+ }
782
+
783
+ /**
784
+ * Convert the selected blocks to list strategy.
785
+ */
786
+ class ListTransformToListStrategy extends ActionHandleStrategy {
787
+ /**
788
+ * @inheritDoc
789
+ */
790
+ handleAction(action, target) {
791
+ const selectedBlocks = action.selectedBlocks;
792
+ const bulletList = target.parent.createList(action.listType);
793
+ const isSameList = selectedBlocks.every((block) => block.parent === target);
794
+ if (isSameList) {
795
+ // Select one or more list items belonging to the same list, and all items in this list should be updated
796
+ bulletList.apply(new AppendChildNodesAction(target.blocks));
797
+ target.parent.apply(new InsertBlocksAfterAction(target, bulletList));
798
+ target.parent.apply(new RemoveChildAction(target));
799
+ selectedBlocks.forEach((block) => block.nodes.map((node) => node.apply(new SyncUpSelectionAction())));
800
+ }
801
+ else {
802
+ const listItems = action.selectedBlocks.map((block) => target.parent.toListItem(block));
803
+ bulletList.apply(new AppendChildNodesAction(listItems));
804
+ target.parent.apply(new InsertBlocksAfterAction(target, bulletList));
805
+ action.selectedBlocks.forEach((block) => {
806
+ block.parent.apply(new RemoveChildAction(block));
807
+ });
808
+ if (target.blocks.length === 0) {
809
+ target.parent.apply(new RemoveChildAction(target));
810
+ }
811
+ }
812
+ }
813
+ }
814
+
815
+ /**
816
+ * Convert the selected list block to paragraph strategy.
817
+ */
818
+ class ListTransformToParagraphStrategy extends ActionHandleStrategy {
819
+ /**
820
+ * @inheritDoc
821
+ */
822
+ handleAction(action, target) {
823
+ let isSelectedFirstBlock = false;
824
+ let isSelectedLastBlock = false;
825
+ const selectedBlocks = action.selectedBlocks;
826
+ const currentParagraph = selectedBlocks.map((block) => {
827
+ block.nodes.map((node) => node.apply(new SyncUpSelectionAction()));
828
+ if (block === target.blocks[0])
829
+ isSelectedFirstBlock = true;
830
+ if (block === target.blocks[target.blocks.length - 1])
831
+ isSelectedLastBlock = true;
832
+ return this.toParagraph(block);
833
+ });
834
+ if (isSelectedFirstBlock) {
835
+ target.parent.apply(new InsertBlocksBeforeAction(target, ...currentParagraph));
836
+ }
837
+ else if (isSelectedLastBlock) {
838
+ target.parent.apply(new InsertBlocksAfterAction(target, ...currentParagraph));
839
+ }
840
+ else {
841
+ const startIndex = target.blocks.indexOf(selectedBlocks[0]);
842
+ const lastIndex = target.blocks.indexOf(selectedBlocks[selectedBlocks.length - 1]);
843
+ const firstBulletList = target.parent.createList(target.type);
844
+ firstBulletList.apply(new AppendChildNodesAction(target.blocks.slice(0, startIndex)));
845
+ const lastBulletList = target.parent.createList(target.type);
846
+ lastBulletList.apply(new AppendChildNodesAction(target.blocks.slice(lastIndex + 1)));
847
+ target.parent.apply(new InsertBlocksBeforeAction(target, firstBulletList, ...currentParagraph, lastBulletList));
848
+ target.parent.apply(new RemoveChildAction(target));
849
+ }
850
+ selectedBlocks.map((block) => {
851
+ target.apply(new RemoveChildAction(block));
852
+ });
853
+ if (target.blocks.length === 0) {
854
+ target.parent.apply(new RemoveChildAction(target));
855
+ }
856
+ }
857
+ /**
858
+ * Converts a RTEListItemBlock to a RTETextBlock representing a paragraph.
859
+ *
860
+ * @param {RTEListItemBlock} block - The block that will be covered
861
+ * @returns {RTETextBlock} Returns a `RTETextBlock`.
862
+ */
863
+ toParagraph(block) {
864
+ const textBlock = new RTETextBlock(generateUUID(), 'paragraph');
865
+ textBlock.apply(new AppendChildNodesAction(block['nodes']));
866
+ textBlock['annotationMap'] = block['annotationMap'];
867
+ return textBlock;
868
+ }
869
+ }
870
+
871
+ /**
872
+ * Insert image to list block strategy.
873
+ */
874
+ class ListInsertImageStrategy extends ActionHandleStrategy {
875
+ /**
876
+ * Insert image block at behind of the list item block.
877
+ *
878
+ * @param {InsertImageToBlockAction} action - The insert image action instance.
879
+ * @param {RTEListBlock} target - The list block.
880
+ */
881
+ handleAction(action, target) {
882
+ const imageBlock = action.imageBlockToBeInserted;
883
+ if (target.parent['type'] !== 'list-item') {
884
+ target.parent.apply(new InsertBlocksAfterAction(target, imageBlock));
885
+ }
886
+ else {
887
+ target.parent.apply(action);
888
+ }
889
+ }
890
+ }
891
+
892
+ /**
893
+ * List annotation
894
+ */
895
+ class ListAnnotation extends BlockAnnotation {
896
+ constructor() {
897
+ super(...arguments);
898
+ this.type = BlockAnnotationTypeEnum.LIST;
899
+ }
900
+ /**
901
+ * @inheritDoc
902
+ */
903
+ renderStyle(options) {
904
+ if (!(options === null || options === void 0 ? void 0 : options.standalone))
905
+ return null;
906
+ return {
907
+ paddingLeft: '8px',
908
+ marginLeft: '16px',
909
+ };
910
+ }
911
+ /**
912
+ * @inheritDoc
913
+ */
914
+ renderClass(options) {
915
+ if (options === null || options === void 0 ? void 0 : options.standalone)
916
+ return null;
917
+ return 'v-rte--list';
918
+ }
919
+ /**
920
+ * @inheritDoc
921
+ */
922
+ clone() {
923
+ return new ListAnnotation();
924
+ }
925
+ /**
926
+ * @inheritDoc
927
+ */
928
+ toJSON() {
929
+ return undefined;
930
+ }
931
+ }
932
+
933
+ /**
934
+ * List block
935
+ */
936
+ class RTEListBlock extends RTEBlock {
937
+ constructor(id, type) {
938
+ super(id);
939
+ this.type = 'bullet-list';
940
+ this.blocks = [];
941
+ this.type = type;
942
+ this.annotationMap.set(BlockAnnotationTypeEnum.LIST, new ListAnnotation());
943
+ }
944
+ /**
945
+ * Converts a VegaRTEListBlock object to an RTEListBlock
946
+ *
947
+ * @param {VegaRTEListBlock} block - Converts a `VegaRTEListBlock` object into an `RTEListBlock`.
948
+ * @returns {RTEListBlock} Return an instance of `RTEListBlock`
949
+ */
950
+ static from(block) {
951
+ const listBlock = new RTEListBlock(block.id, block.type);
952
+ const { annotations } = block;
953
+ if (annotations) {
954
+ Object.entries(annotations).forEach(([type, value]) => {
955
+ const item = this.createAnnotationEntity(type, value);
956
+ if (isNonNullable(item)) {
957
+ listBlock.annotationMap.set(...item);
958
+ }
959
+ });
960
+ }
961
+ listBlock.blocks = block.blocks.map((item) => {
962
+ const listItemBlock = RTEListItemBlock.from(item);
963
+ listItemBlock.parent = listBlock;
964
+ return listItemBlock;
965
+ });
966
+ return listBlock;
967
+ }
968
+ /**
969
+ * The function `createAnnotationEntity` creates a block annotation entity based on the provided type
970
+ * and value.
971
+ *
972
+ * @param {keyof VegaRTEBlockAnnotations} type - The `type` parameter is a key of the `VegaRTEBlockAnnotations` enum, which specifies
973
+ * the type of annotation entity to create.
974
+ * @param {unknown} value - The `value` parameter in the `createAnnotationEntity` function is the value
975
+ * that will be used to create the annotation entity. It can be of any type depending on the specific
976
+ * annotation being created.
977
+ * @returns {Nullable<BlockAnnotationsEntity>} The `createAnnotationEntity` function returns a nullable tuple containing a
978
+ * `BlockAnnotationTypeEnum` and a `BlockAnnotation` object.
979
+ */
980
+ static createAnnotationEntity(type, value) {
981
+ switch (type) {
982
+ case 'customAttribute':
983
+ return CustomAttributeAnnotation.from(value);
984
+ case 'customClass':
985
+ return CustomClassAnnotation.from(value);
986
+ case 'customStyle':
987
+ return CustomStyleAnnotation.from(value);
988
+ }
989
+ }
990
+ /**
991
+ * @inheritDoc
992
+ */
993
+ toJSON() {
994
+ return Object.assign(Object.assign({}, super.toJSON()), { id: this.id, type: this.type, blocks: this.blocks.map((block) => block.toJSON()) });
995
+ }
996
+ /**
997
+ * @inheritDoc
998
+ */
999
+ toHtml() {
1000
+ const BlockTag = this.type === 'number-list' ? 'ol' : 'ul';
1001
+ const attrStr = super.generateAttributeString();
1002
+ return [
1003
+ `<${BlockTag}${attrStr}>`,
1004
+ this.blocks.map((block) => block.toHtml()).join(''),
1005
+ `</${BlockTag}>`,
1006
+ ].join('');
1007
+ }
1008
+ /**
1009
+ * @inheritDoc
1010
+ */
1011
+ isNotEmpty() {
1012
+ return this.blocks.length > 0;
1013
+ }
1014
+ /**
1015
+ * @inheritDoc
1016
+ */
1017
+ getLastNode() {
1018
+ return this.blocks[this.blocks.length - 1].getLastNode();
1019
+ }
1020
+ /**
1021
+ * @inheritDoc
1022
+ */
1023
+ clone() {
1024
+ const clonedListBlock = new RTEListBlock(this.id, this.type);
1025
+ clonedListBlock.blocks = this.blocks.map((item) => {
1026
+ const clonedListItemBlock = item.clone();
1027
+ clonedListItemBlock.parent = clonedListBlock;
1028
+ return clonedListItemBlock;
1029
+ });
1030
+ clonedListBlock.annotationMap = super.cloneAnnotations();
1031
+ clonedListBlock.parent = this.parent;
1032
+ return clonedListBlock;
1033
+ }
1034
+ }
1035
+ (() => {
1036
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEListBlock.name, new ListRemoveListItemStrategy());
1037
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_BLOCKS_BEFORE, RTEListBlock.name, new BlockInsertBlocksBeforeStrategy());
1038
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_BLOCKS_AFTER, RTEListBlock.name, new BlockInsertBlocksAfterStrategy());
1039
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEListBlock.name, new BlockAppendBlocksStrategy());
1040
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.TRANSFORM_LIST_BLOCK, RTEListBlock.name, new ListTransformToListStrategy());
1041
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK, RTEListBlock.name, new ListTransformToParagraphStrategy());
1042
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListBlock.name, new ListInsertImageStrategy());
1043
+ })();
1044
+
1045
+ /**
1046
+ * Transform the selected text blocks to a code block strategy.
1047
+ */
1048
+ class BlockTransformToCodeBlockStrategy extends ActionHandleStrategy {
1049
+ /**
1050
+ * Get the all select text and create a new code block.
1051
+ *
1052
+ * @param {TransformToCodeBlockAction} action - The action instance.
1053
+ * @param {VegaRTEContent} target - The block top parent instance.
1054
+ */
1055
+ handleAction(action, target) {
1056
+ const selectedBlocks = action.selectedBlocks;
1057
+ const codeBlock = new RTECodeBlock(generateUUID(), this.getCodeContent(selectedBlocks), 'plainText');
1058
+ target.apply(new InsertBlocksBeforeAction(selectedBlocks[0], codeBlock));
1059
+ action.newCodeBlock = codeBlock;
1060
+ this.removeSelectBlocks(selectedBlocks, target);
1061
+ }
1062
+ /**
1063
+ * Get the selected text block text content.
1064
+ *
1065
+ * @param {RTEBlock[]} selectedBlocks - The selected blocks.
1066
+ * @returns {string} - The selected text content.
1067
+ */
1068
+ getCodeContent(selectedBlocks) {
1069
+ const selectedTextBlocks = selectedBlocks.filter((item) => item.type !== 'image' && item.type !== 'list-item');
1070
+ return selectedTextBlocks
1071
+ .map((block) => {
1072
+ return block.nodes.map((node) => node.text).join('');
1073
+ })
1074
+ .join('\n');
1075
+ }
1076
+ /**
1077
+ * Remove the selected blocks after append new code block.
1078
+ *
1079
+ * @param {RTEBlock[]} selectedBlocks - The selected blocks.
1080
+ * @param {VegaRTEContent} target - The selected block top parent object.
1081
+ */
1082
+ removeSelectBlocks(selectedBlocks, target) {
1083
+ for (let i = 0; i < selectedBlocks.length; i++) {
1084
+ target.apply(new RemoveChildAction(selectedBlocks[i]));
1085
+ }
1086
+ }
1087
+ }
1088
+
1089
+ /**
1090
+ * Abstract class to define strategies for processing HTML elements
1091
+ */
1092
+ class ElementToDTOStrategy {
1093
+ }
1094
+ /**
1095
+ * Class to represent the output of a strategy applied to HTML elements
1096
+ */
1097
+ class ElementToDTOStrategyOutput {
1098
+ constructor(currentStrategy, currentElements) {
1099
+ this.childrenOutput = [];
1100
+ this.currentStrategy = currentStrategy;
1101
+ this.currentElements = currentElements;
1102
+ }
1103
+ /**
1104
+ * Set children output.
1105
+ *
1106
+ * @param {ElementToDTOStrategyOutput[]} childrenOutput - children outputs.
1107
+ */
1108
+ setChildrenOutput(childrenOutput) {
1109
+ this.childrenOutput = childrenOutput;
1110
+ }
1111
+ /**
1112
+ * Transform current output and children output to DTO
1113
+ *
1114
+ * @returns {Nullable<RTEContentBlock>} - DTO.
1115
+ */
1116
+ toDto() {
1117
+ const currentBlock = this.currentStrategy.handle(this.currentElements);
1118
+ if (this.childrenOutput.length > 0 && currentBlock) {
1119
+ this.currentStrategy.appendChildBlocks(currentBlock, this.childrenOutput
1120
+ .map((childOutput) => childOutput.toDto())
1121
+ .filter(isNonNullable));
1122
+ }
1123
+ return currentBlock;
1124
+ }
1125
+ }
1126
+
1127
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
1128
+ var t = {};
1129
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1130
+ t[p] = s[p];
1131
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1132
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1133
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1134
+ t[p[i]] = s[p[i]];
1135
+ }
1136
+ return t;
1137
+ };
1138
+ /** Abstract class for block html element to RTE block dto */
1139
+ class BlockToRTEBlockStrategyAbstract extends ElementToDTOStrategy {
1140
+ /**
1141
+ * Generate child nodes of block element, this will inherit all annotations from parent to text node and
1142
+ * flat the child nodes.
1143
+ *
1144
+ * Example:
1145
+ * <li>
1146
+ * <u><i>text1</i></u>
1147
+ * <span style='font-weight: bold;'><span>text2</span></span>
1148
+ * text3
1149
+ * </li>
1150
+ * will tranform to:
1151
+ * <li>
1152
+ * <span>text1</span> // with underline and italic annotations
1153
+ * <span>text2</span> // with bold annotations
1154
+ * <span>text3</span> // no annotations
1155
+ * </li>
1156
+ *
1157
+ * @param {HTMLElement[]} elements - Child elements.
1158
+ * @param {VegaRTETextAnnotations} annotations - Parent annotations.
1159
+ * @returns {VegaRTETextNode[]} - Text node DTO.
1160
+ */
1161
+ generateChildNodes(elements, annotations = {}) {
1162
+ const childNodes = [];
1163
+ elements.forEach((child) => {
1164
+ if (child.nodeType === Node.TEXT_NODE) {
1165
+ if (this.isInvalidTextNode(child))
1166
+ return;
1167
+ childNodes.push({
1168
+ id: generateUUID(),
1169
+ type: 'text',
1170
+ text: String(child.textContent),
1171
+ annotations: annotations,
1172
+ });
1173
+ }
1174
+ else {
1175
+ childNodes.push(...this.generateChildNodes(Array.from(child.childNodes), this.inheritAndGenerateTextNodeAnnotations(child, annotations)));
1176
+ }
1177
+ });
1178
+ return childNodes;
1179
+ }
1180
+ /**
1181
+ * Generate annotations map for block element.
1182
+ *
1183
+ * @param {HTMLElement} element - current element.
1184
+ * @returns {VegaRTEBlockAnnotations} - Text block annotations.
1185
+ */
1186
+ generateBlockAnnotations(element) {
1187
+ const annotations = {};
1188
+ const textAlign = this.getTextAlign(element);
1189
+ const indent = this.getIndent(element);
1190
+ if (textAlign)
1191
+ annotations.textAlign = textAlign;
1192
+ if (indent)
1193
+ annotations.indent = indent;
1194
+ this.generateCommonAnnotations(element, annotations);
1195
+ return annotations;
1196
+ }
1197
+ /**
1198
+ * Obtain the custom attributes of element, excluding 'style' and 'class'.
1199
+ *
1200
+ * @param {HTMLElement} element - current element.
1201
+ * @param {string[]} attributes - the custom attributes of current element.
1202
+ * @returns {Record<string, string>} - Record<string, string>.
1203
+ */
1204
+ generateCustomAttrAnnotations(element, attributes) {
1205
+ return attributes.reduce((acc, item) => {
1206
+ acc[item] = element.getAttribute(item);
1207
+ return acc;
1208
+ }, {});
1209
+ }
1210
+ /**
1211
+ * Obtain and format the style of element.
1212
+ *
1213
+ * @param {HTMLElement} element - current element.
1214
+ * @returns {AnnotationStyle} - Record<string, string>.
1215
+ */
1216
+ generateCustomStyleAnnotations(element) {
1217
+ const customStyle = element.getAttribute('style');
1218
+ const styleValue = customStyle.split(';').filter(Boolean);
1219
+ return styleValue
1220
+ .filter((key) => key !== ' ')
1221
+ .map((key) => {
1222
+ // to remove redundant quote pairs if needed, for example: ['fontFamily: "Roboto Mono"'] will be updated to ['fontFamily: Roboto Mono']
1223
+ const styleObject = key.replace(/(['"])((?:\\\1|[^\1])*?)\1/g, '$2').split(':');
1224
+ const styleKey = dashCaseToCamel(styleObject[0].trim());
1225
+ return {
1226
+ [styleKey]: styleObject[1].trim().replace(';', ''),
1227
+ };
1228
+ })
1229
+ .reduce((current, obj) => (Object.assign(Object.assign({}, current), obj)), {});
1230
+ }
1231
+ /**
1232
+ * Inherit annotation from block should not include custom annotation.
1233
+ *
1234
+ * @param {HTMLElement} element - current element.
1235
+ * @returns {VegaRTETextAnnotations} - Inherit node annotations.
1236
+ */
1237
+ generateBlockInheritAnnotations(element) {
1238
+ const annotations = this.generateTextNodeAnnotations(element);
1239
+ return this.filterOutCustomAnnotation(annotations);
1240
+ }
1241
+ /**
1242
+ * Generate custom attribute, custom class and custom style annotation.
1243
+ *
1244
+ * @param {HTMLElement} element - current element.
1245
+ * @param {VegaRTEBlockAnnotations} annotations - current element.
1246
+ * @returns {VegaRTETextAnnotations} - Inherit node annotations.
1247
+ */
1248
+ generateCommonAnnotations(element, annotations = {}) {
1249
+ const customAttributes = this.getCustomAttributeName(element);
1250
+ const customClass = this.getCustomClass(element);
1251
+ if (customAttributes.length > 0)
1252
+ annotations.customAttribute = this.generateCustomAttrAnnotations(element, customAttributes);
1253
+ if (customClass.length > 0)
1254
+ annotations.customClass = customClass;
1255
+ if (element.getAttribute('style'))
1256
+ annotations.customStyle = this.generateCustomStyleAnnotations(element);
1257
+ return annotations;
1258
+ }
1259
+ /**
1260
+ * Inherit and generate text node annotations.
1261
+ *
1262
+ * @param {HTMLElement} element - current element.
1263
+ * @param {VegaRTETextAnnotations} parentAnnotations - parent annotations
1264
+ * @returns {VegaRTETextAnnotations} - Inherit node annotations.
1265
+ */
1266
+ inheritAndGenerateTextNodeAnnotations(element, parentAnnotations) {
1267
+ const inheritedAnnotation = this.filterOutCustomAnnotation(parentAnnotations);
1268
+ const currentNodeAnnotation = this.generateTextNodeAnnotations(element);
1269
+ parentAnnotations.bold && (currentNodeAnnotation.bold = true);
1270
+ parentAnnotations.underline && (currentNodeAnnotation.underline = true);
1271
+ parentAnnotations.italic && (currentNodeAnnotation.italic = true);
1272
+ parentAnnotations.strikethrough && (currentNodeAnnotation.strikethrough = true);
1273
+ return Object.assign({}, inheritedAnnotation, currentNodeAnnotation);
1274
+ }
1275
+ /**
1276
+ * Generate annotations map for text node element.
1277
+ *
1278
+ * @param {HTMLElement} element - current element.
1279
+ * @returns {VegaRTETextAnnotations} - Text node annotations.
1280
+ */
1281
+ generateTextNodeAnnotations(element) {
1282
+ const annotations = {
1283
+ bold: this.isBold(element),
1284
+ italic: this.isItalic(element),
1285
+ underline: this.isUnderline(element),
1286
+ strikethrough: this.isStrikethrough(element),
1287
+ code: this.isCode(element),
1288
+ };
1289
+ const color = this.getColor(element);
1290
+ const link = this.getLink(element);
1291
+ if (color)
1292
+ annotations.textColor = color;
1293
+ // while have link, the custom attribute, class and style have already generated in link annotation,
1294
+ // so we not need generate it again.
1295
+ if (link) {
1296
+ annotations.link = link;
1297
+ }
1298
+ else {
1299
+ this.generateCommonAnnotations(element, annotations);
1300
+ }
1301
+ return annotations;
1302
+ }
1303
+ /**
1304
+ * Filter out custom annotations.
1305
+ *
1306
+ * @param {VegaRTETextAnnotations} annotations - Annotations.
1307
+ * @returns {VegaRTETextAnnotations} - Filtered annotations.
1308
+ */
1309
+ filterOutCustomAnnotation(annotations) {
1310
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1311
+ const filteredAnnotation = __rest(annotations, ["customAttribute", "customClass", "customStyle"]);
1312
+ return filteredAnnotation;
1313
+ }
1314
+ /**
1315
+ * Get the custom class
1316
+ *
1317
+ * @param {HTMLElement} element - current element.
1318
+ * @returns {string[]} - the class after .
1319
+ */
1320
+ getCustomClass(element) {
1321
+ return element.classList
1322
+ .toString()
1323
+ .split(' ')
1324
+ .filter((item) => !item.includes('v-rte') && item !== '');
1325
+ }
1326
+ /**
1327
+ * Check is a invalid text node.
1328
+ *
1329
+ * @param {HTMLElement} element - Current node element.
1330
+ * @returns {boolean} - boolean.
1331
+ */
1332
+ isInvalidTextNode(element) {
1333
+ if (element.nodeValue && element.nodeValue.includes('\t')) {
1334
+ const value = element.nodeValue.replace(/\n|\t/gm, '');
1335
+ if (value.length === 0)
1336
+ return true;
1337
+ }
1338
+ return false;
1339
+ }
1340
+ /**
1341
+ * Is code element.
1342
+ *
1343
+ * @param {HTMLElement} element - current element.
1344
+ * @returns {boolean} - boolean.
1345
+ */
1346
+ isCode(element) {
1347
+ return (element.classList.contains('v-rte--code') ||
1348
+ element.nodeName === 'CODE' ||
1349
+ element.nodeName === 'PRE' ||
1350
+ element.style.fontFamily === 'monospace');
1351
+ }
1352
+ /**
1353
+ * Is bold element.
1354
+ *
1355
+ * @param {HTMLElement} element - current element.
1356
+ * @returns {boolean} - boolean.
1357
+ */
1358
+ isBold(element) {
1359
+ return (element.nodeName === 'STRONG' ||
1360
+ element.nodeName === 'B' ||
1361
+ element.style.fontWeight === 'bold' ||
1362
+ element.style.fontWeight === '700' ||
1363
+ element.classList.contains('v-rte--bold'));
1364
+ }
1365
+ /**
1366
+ * Is italic element.
1367
+ *
1368
+ * @param {HTMLElement} element - current element.
1369
+ * @returns {boolean} - boolean.
1370
+ */
1371
+ isItalic(element) {
1372
+ return (element.nodeName === 'I' ||
1373
+ element.style.fontStyle === 'italic' ||
1374
+ element.nodeName === 'EM' ||
1375
+ element.classList.contains('v-rte--italic'));
1376
+ }
1377
+ /**
1378
+ * Is underline element.
1379
+ *
1380
+ * @param {HTMLElement} element - current element.
1381
+ * @returns {boolean} - boolean.
1382
+ */
1383
+ isUnderline(element) {
1384
+ return (element.style.textDecoration.includes('underline') ||
1385
+ element.nodeName === 'U' ||
1386
+ element.nodeName === 'INS' ||
1387
+ element.classList.contains('v-rte--underline'));
1388
+ }
1389
+ /**
1390
+ * Is strikethrough element.
1391
+ *
1392
+ * @param {HTMLElement} element - current element.
1393
+ * @returns {boolean} - boolean.
1394
+ */
1395
+ isStrikethrough(element) {
1396
+ return (element.style.textDecoration.includes('line-through') ||
1397
+ element.nodeName === 'S' ||
1398
+ element.nodeName === 'DEL' ||
1399
+ element.classList.contains('v-rte--strikethrough'));
1400
+ }
1401
+ /**
1402
+ * Get current color of element.
1403
+ *
1404
+ * @param {HTMLElement} element - current element.
1405
+ * @returns {Nullable<string>} - color.
1406
+ */
1407
+ getColor(element) {
1408
+ var _a;
1409
+ const color = element.style.color;
1410
+ const hexColor = (_a = rgbToHex(color)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
1411
+ if (hexColor) {
1412
+ const colorSchema = RTE_TEXT_COLORS.find((schema) => schema.light === hexColor || schema.dark === hexColor);
1413
+ if (colorSchema)
1414
+ return colorSchema.key;
1415
+ return null;
1416
+ }
1417
+ else {
1418
+ for (const color of RTE_TEXT_COLORS) {
1419
+ if (element.style.color.includes(color.key)) {
1420
+ return color.key;
1421
+ }
1422
+ }
1423
+ return null;
1424
+ }
1425
+ }
1426
+ /**
1427
+ * Get current link of element.
1428
+ *
1429
+ * @param {HTMLElement} element - current element.
1430
+ * @returns {Nullable<VegaRTELink>} - link.
1431
+ */
1432
+ getLink(element) {
1433
+ if (element.nodeName === 'A') {
1434
+ const link = {
1435
+ href: element.href,
1436
+ groupKey: generateUUID(),
1437
+ };
1438
+ const customAttributes = this.getCustomAttributeName(element);
1439
+ const customClass = this.getCustomClass(element);
1440
+ if (customAttributes.length > 0) {
1441
+ link.customAttribute = this.generateCustomAttrAnnotations(element, customAttributes);
1442
+ }
1443
+ if (customClass.length > 0) {
1444
+ link.customClass = customClass;
1445
+ }
1446
+ if (element.getAttribute('style')) {
1447
+ link.customStyle = this.generateCustomStyleAnnotations(element);
1448
+ }
1449
+ return link;
1450
+ }
1451
+ return null;
1452
+ }
1453
+ /**
1454
+ * Get text align of current element.
1455
+ *
1456
+ * @param {HTMLElement} element - current element.
1457
+ * @returns {Nullable<VegaRTEBlockAlignment>} - Text align.
1458
+ */
1459
+ getTextAlign(element) {
1460
+ const classList = element.classList;
1461
+ if (classList.contains(`v-rte--horizontal-alignment-left`)) {
1462
+ return 'left';
1463
+ }
1464
+ else if (classList.contains(`v-rte--horizontal-alignment-center`)) {
1465
+ return 'center';
1466
+ }
1467
+ else if (classList.contains(`v-rte--horizontal-alignment-right`)) {
1468
+ return 'right';
1469
+ }
1470
+ else if (classList.contains(`v-rte--horizontal-alignment-justify`)) {
1471
+ return 'justify';
1472
+ }
1473
+ const style = element.style;
1474
+ switch (style.textAlign) {
1475
+ case 'center':
1476
+ return 'center';
1477
+ case 'right':
1478
+ return 'right';
1479
+ case 'justify':
1480
+ return 'justify';
1481
+ case 'left':
1482
+ return 'left';
1483
+ default:
1484
+ return null;
1485
+ }
1486
+ }
1487
+ /**
1488
+ * Get indent of current element.
1489
+ *
1490
+ * @param {HTMLElement} element - current element.
1491
+ * @returns {Nullable<number>} - Indent.
1492
+ */
1493
+ getIndent(element) {
1494
+ const style = element.style;
1495
+ let marginLeft;
1496
+ if (style.marginLeft) {
1497
+ marginLeft = style.marginLeft;
1498
+ }
1499
+ else if (style.margin) {
1500
+ const margins = style.margin.split(' ');
1501
+ switch (margins.length) {
1502
+ case 4:
1503
+ marginLeft = margins[3];
1504
+ break;
1505
+ case 2:
1506
+ case 3:
1507
+ marginLeft = margins[1];
1508
+ break;
1509
+ default:
1510
+ marginLeft = margins[0];
1511
+ break;
1512
+ }
1513
+ }
1514
+ else {
1515
+ return null;
1516
+ }
1517
+ const marginLeftNumber = Number(marginLeft.replace('px', ''));
1518
+ return marginLeftNumber && marginLeftNumber >= 0 ? Math.floor(marginLeftNumber / 16) : null;
1519
+ }
1520
+ /**
1521
+ * Get custom attribute of current element, excluding 'style' and 'class'.
1522
+ *
1523
+ * @param {HTMLElement} element - current element.
1524
+ * @returns {string[]} - Text align.
1525
+ */
1526
+ getCustomAttributeName(element) {
1527
+ return element.getAttributeNames().filter((attr) => attr !== 'style' && attr !== 'class');
1528
+ }
1529
+ }
1530
+
1531
+ /** Transform continue inline block elements to text block DTO */
1532
+ class ContinueInlineToRTETextBlockStrategy extends BlockToRTEBlockStrategyAbstract {
1533
+ /**
1534
+ * Can be handle.
1535
+ *
1536
+ * @param {HTMLElement[]} elementsArray - Current elements.
1537
+ * @param {number} currentIndex - Current element index.
1538
+ * @returns {number} - can be handled element count.
1539
+ */
1540
+ canHandle(elementsArray, currentIndex) {
1541
+ let count = 0;
1542
+ for (let i = currentIndex; i < elementsArray.length; i++) {
1543
+ const element = elementsArray[i];
1544
+ if (element.nodeType === Node.TEXT_NODE ||
1545
+ (ContinueInlineToRTETextBlockStrategy.canHandleTags.includes(element.nodeName) &&
1546
+ !(element.textContent === '' && element.querySelector('IMG')))) {
1547
+ count++;
1548
+ }
1549
+ else {
1550
+ break;
1551
+ }
1552
+ }
1553
+ return count;
1554
+ }
1555
+ /**
1556
+ * Parse to a text block.
1557
+ *
1558
+ * @param {HTMLElement[]} elementsArray - Current elements.
1559
+ * @returns {Nullable<RTEContentBlock>} - Text block.
1560
+ */
1561
+ handle(elementsArray) {
1562
+ const parent = elementsArray[0].parentElement;
1563
+ const nodes = this.generateChildNodes(elementsArray, this.generateBlockInheritAnnotations(parent));
1564
+ if (nodes.length === 0)
1565
+ return null;
1566
+ return RTETextBlock.from({
1567
+ id: generateUUID(),
1568
+ type: 'paragraph',
1569
+ nodes: nodes,
1570
+ annotations: this.generateBlockAnnotations(parent),
1571
+ });
1572
+ }
1573
+ /* istanbul ignore next */
1574
+ /**
1575
+ * Append child blocks.
1576
+ */
1577
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
1578
+ appendChildBlocks() { }
1579
+ /**
1580
+ * Should continue process to child elements.
1581
+ *
1582
+ * @returns {boolean} - boolean.
1583
+ */
1584
+ shouldProceedToElementChildren() {
1585
+ return false;
1586
+ }
1587
+ }
1588
+ ContinueInlineToRTETextBlockStrategy.canHandleTags = [
1589
+ 'SPAN',
1590
+ 'STRONG',
1591
+ 'CODE',
1592
+ 'I',
1593
+ 'EM',
1594
+ 'S',
1595
+ 'U',
1596
+ 'A',
1597
+ 'VEGA-RICH-TEXT-LINK-EDITOR',
1598
+ 'B',
1599
+ 'INS',
1600
+ 'DEL',
1601
+ 'PRE',
1602
+ ];
1603
+
1604
+ /** Transform ul element to list block DTO */
1605
+ class UlToRTEListBlockStrategy extends BlockToRTEBlockStrategyAbstract {
1606
+ /**
1607
+ * Can be handle.
1608
+ *
1609
+ * @param {HTMLElement[]} elementsArray - Current elements.
1610
+ * @param {number} currentIndex - Current element index.
1611
+ * @returns {number} - can be handled element count.
1612
+ */
1613
+ canHandle(elementsArray, currentIndex) {
1614
+ return elementsArray[currentIndex].tagName === 'UL' ? 1 : 0;
1615
+ }
1616
+ /**
1617
+ * Parse to a block.
1618
+ *
1619
+ * @param {HTMLElement[]} elementsArray - Current elements.
1620
+ * @returns {Nullable<RTEContentBlock>} - Bullet list block.
1621
+ */
1622
+ handle(elementsArray) {
1623
+ if (elementsArray[0].childNodes.length === 0)
1624
+ return null;
1625
+ return RTEListBlock.from({
1626
+ id: generateUUID(),
1627
+ type: 'bullet-list',
1628
+ blocks: [],
1629
+ annotations: this.generateBlockAnnotations(elementsArray[0]),
1630
+ });
1631
+ }
1632
+ /**
1633
+ * Append child list item blocks to current list block.
1634
+ *
1635
+ * @param {RTEListBlock} currentBlock - Current list block.
1636
+ * @param {RTEContentBlock[]} childBlocks - Current list item blocks.
1637
+ */
1638
+ appendChildBlocks(currentBlock, childBlocks) {
1639
+ currentBlock.blocks = childBlocks.filter((block) => block instanceof RTEListItemBlock);
1640
+ childBlocks.forEach((block) => (block.parent = currentBlock));
1641
+ }
1642
+ /**
1643
+ * Should continue process to child elements.
1644
+ *
1645
+ * @returns {boolean} - boolean.
1646
+ */
1647
+ shouldProceedToElementChildren() {
1648
+ return true;
1649
+ }
1650
+ }
1651
+
1652
+ /** Transform li element to list item block DTO */
1653
+ class LiToRTEListItemBlockStrategy extends BlockToRTEBlockStrategyAbstract {
1654
+ /**
1655
+ * Can be handle.
1656
+ *
1657
+ * @param {HTMLElement[]} elementsArray - Current elements.
1658
+ * @param {number} currentIndex - Current element index.
1659
+ * @returns {number} - can be handled element count.
1660
+ */
1661
+ canHandle(elementsArray, currentIndex) {
1662
+ return elementsArray[currentIndex].tagName === 'LI' ? 1 : 0;
1663
+ }
1664
+ /**
1665
+ * Parse to a list item block.
1666
+ *
1667
+ * @param {HTMLElement[]} elementsArray - Current elements.
1668
+ * @returns {Nullable<RTEContentBlock>} - List item block.
1669
+ */
1670
+ handle(elementsArray) {
1671
+ if (elementsArray[0].childNodes.length === 0)
1672
+ return null;
1673
+ return RTEListItemBlock.from({
1674
+ id: generateUUID(),
1675
+ type: 'list-item',
1676
+ nodes: this.generateChildNodes(Array.from(elementsArray[0].childNodes).filter((item) => !['UL', 'OL'].includes(item.nodeName)), this.generateBlockInheritAnnotations(elementsArray[0])),
1677
+ annotations: this.generateBlockAnnotations(elementsArray[0]),
1678
+ });
1679
+ }
1680
+ /**
1681
+ * Append child list blocks to current list item block.
1682
+ *
1683
+ * @param {RTEListBlock} currentBlock - Current list item block.
1684
+ * @param {RTEListItemBlock[]} childBlocks - Current list blocks.
1685
+ */
1686
+ appendChildBlocks(currentBlock, childBlocks) {
1687
+ currentBlock.children = childBlocks.filter((block) => ['bullet-list', 'number-list'].includes(block.type));
1688
+ }
1689
+ /**
1690
+ * Should continue process to child elements.
1691
+ *
1692
+ * @returns {boolean} - boolean.
1693
+ */
1694
+ shouldProceedToElementChildren() {
1695
+ return true;
1696
+ }
1697
+ }
1698
+
1699
+ /** Transform inline block element to text block DTO */
1700
+ class InlineBlockToRTETextBlockStrategy extends BlockToRTEBlockStrategyAbstract {
1701
+ /**
1702
+ * Can be handle.
1703
+ *
1704
+ * @param {HTMLElement[]} elementsArray - Current elements.
1705
+ * @param {number} currentIndex - Current element index.
1706
+ * @returns {number} - can be handled element count.
1707
+ */
1708
+ canHandle(elementsArray, currentIndex) {
1709
+ return [
1710
+ 'heading-1',
1711
+ 'heading-2',
1712
+ 'heading-3',
1713
+ 'heading-4',
1714
+ 'heading-5',
1715
+ 'heading-6',
1716
+ 'title',
1717
+ 'subtitle',
1718
+ ].includes(this.getElementType(elementsArray[currentIndex]))
1719
+ ? 1
1720
+ : 0;
1721
+ }
1722
+ /**
1723
+ * Parse to a text block.
1724
+ *
1725
+ * @param {HTMLElement[]} elementsArray - Current elements.
1726
+ * @returns {Nullable<RTEContentBlock>} - Text block.
1727
+ */
1728
+ handle(elementsArray) {
1729
+ const nodes = this.generateChildNodes(Array.from(elementsArray[0].childNodes));
1730
+ if (nodes.length === 0)
1731
+ return null;
1732
+ return RTETextBlock.from({
1733
+ id: generateUUID(),
1734
+ type: this.getElementType(elementsArray[0]),
1735
+ nodes: nodes,
1736
+ annotations: Object.assign(Object.assign({}, this.generateBlockAnnotations(elementsArray[0])), { textStyle: this.getElementType(elementsArray[0]) }),
1737
+ });
1738
+ }
1739
+ /* istanbul ignore next */
1740
+ /**
1741
+ * Append child blocks.
1742
+ */
1743
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
1744
+ appendChildBlocks() { }
1745
+ /**
1746
+ * Should continue process to child elements.
1747
+ *
1748
+ * @returns {boolean} - boolean.
1749
+ */
1750
+ shouldProceedToElementChildren() {
1751
+ return false;
1752
+ }
1753
+ /**
1754
+ * Get the node type of element. The element type is determined in the following
1755
+ * order: "data-type" attribute, node name, font size and class name.
1756
+ *
1757
+ * @param {HTMLElement} element - element.
1758
+ * @returns {string} - node type.
1759
+ */
1760
+ getElementType(element) {
1761
+ const byDataType = this.getElementTypeByDataType(element);
1762
+ if (byDataType)
1763
+ return byDataType;
1764
+ const byNodeName = this.getElementTypeByNodeName(element);
1765
+ if (byNodeName)
1766
+ return byNodeName;
1767
+ const byFontSize = this.getElementTypeByFontSize(element);
1768
+ if (byFontSize)
1769
+ return byFontSize;
1770
+ const byClassName = this.getElementTypeByClassName(element);
1771
+ if (byClassName)
1772
+ return byClassName;
1773
+ return 'paragraph';
1774
+ }
1775
+ /**
1776
+ * Get the element type by data-type attribute.
1777
+ *
1778
+ * @param {HTMLElement} element - element.
1779
+ * @returns {Nullable<string>} - element type or null if not found.
1780
+ */
1781
+ getElementTypeByDataType(element) {
1782
+ if (element.nodeType !== Node.TEXT_NODE && element.hasAttribute('data-type')) {
1783
+ return element.getAttribute('data-type');
1784
+ }
1785
+ return null;
1786
+ }
1787
+ /**
1788
+ * Get the element type by font size.
1789
+ *
1790
+ * @param {HTMLElement} element - element.
1791
+ * @returns {Nullable<string>} - element type or null if not found.
1792
+ */
1793
+ getElementTypeByFontSize(element) {
1794
+ var _a;
1795
+ switch ((_a = element.style) === null || _a === void 0 ? void 0 : _a.fontSize) {
1796
+ case '36px':
1797
+ return 'title';
1798
+ case '28px':
1799
+ return 'subtitle';
1800
+ case '22px':
1801
+ return 'heading-1';
1802
+ case '20px':
1803
+ return 'heading-2';
1804
+ case '18px':
1805
+ return 'heading-3';
1806
+ default:
1807
+ return null;
1808
+ }
1809
+ }
1810
+ /**
1811
+ * Get the element type by node name.
1812
+ *
1813
+ * @param {HTMLElement} element - element.
1814
+ * @returns {Nullable<string>} - element type or null if not found.
1815
+ */
1816
+ getElementTypeByNodeName(element) {
1817
+ switch (element.nodeName) {
1818
+ case 'H1':
1819
+ return 'heading-1';
1820
+ case 'H2':
1821
+ return 'heading-2';
1822
+ case 'H3':
1823
+ return 'heading-3';
1824
+ case 'H4':
1825
+ return 'heading-4';
1826
+ case 'H5':
1827
+ return 'heading-5';
1828
+ case 'H6':
1829
+ return 'heading-6';
1830
+ default:
1831
+ return null;
1832
+ }
1833
+ }
1834
+ /**
1835
+ * Get the element type by class name.
1836
+ *
1837
+ * @param {HTMLElement} element - element.
1838
+ * @returns {Nullable<string>} - element type or null if not found.
1839
+ */
1840
+ getElementTypeByClassName(element) {
1841
+ if (element.className) {
1842
+ const match = /\bv-rte--text-style-(title|subtitle|heading-1|heading-2|heading-3|paragraph)\b/.exec(element.className);
1843
+ if (match) {
1844
+ return match[1];
1845
+ }
1846
+ }
1847
+ return null;
1848
+ }
1849
+ }
1850
+
1851
+ /** Abstract class for block html element to RTE block dto */
1852
+ class ElementToRTEImageBlockStrategyAbstract extends BlockToRTEBlockStrategyAbstract {
1853
+ /**
1854
+ * Determine the image display size based on the width of the current element.
1855
+ *
1856
+ * @param {HTMLElement} element - current element.
1857
+ * @returns {VegaRichTextImageEditorSizeType} -Image size, default 'md'.
1858
+ */
1859
+ getImageSize(element) {
1860
+ if (element.getAttribute('data-size'))
1861
+ return element.getAttribute('data-size');
1862
+ return 'md';
1863
+ }
1864
+ /**
1865
+ * Create a RTE Image block according to the img element.
1866
+ *
1867
+ * @param {HTMLElement} element - current element.
1868
+ * @returns {RTEImageBlock} -RTE Image block.
1869
+ */
1870
+ createRTEImageBlock(element) {
1871
+ return RTEImageBlock.from({
1872
+ id: generateUUID(),
1873
+ type: 'image',
1874
+ nodes: [
1875
+ {
1876
+ id: generateUUID(),
1877
+ type: 'image',
1878
+ url: element.src,
1879
+ annotations: Object.assign({ size: this.getImageSize(element), alt: element.alt }, this.generateCommonAnnotations(element)),
1880
+ },
1881
+ ],
1882
+ annotations: this.generateBlockAnnotations(element.parentElement),
1883
+ });
1884
+ }
1885
+ }
1886
+
1887
+ /** Transform img element to image block DTO */
1888
+ class ImgToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
1889
+ /**
1890
+ * Can be handle.
1891
+ *
1892
+ * @param {HTMLElement[]} elementsArray - Current elements.
1893
+ * @param {number} currentIndex - Current element index.
1894
+ * @returns {number} - can be handled element count.
1895
+ */
1896
+ canHandle(elementsArray, currentIndex) {
1897
+ return elementsArray[currentIndex].tagName === 'IMG' ? 1 : 0;
1898
+ }
1899
+ /**
1900
+ * Parse to a image block.
1901
+ *
1902
+ * @param {HTMLElement[]} elementsArray - Current elements.
1903
+ * @returns {Nullable<RTEContentBlock>} - Image block.
1904
+ */
1905
+ handle(elementsArray) {
1906
+ const element = elementsArray[0];
1907
+ return this.createRTEImageBlock(element);
1908
+ }
1909
+ /* istanbul ignore next */
1910
+ /**
1911
+ * Append child blocks.
1912
+ */
1913
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
1914
+ appendChildBlocks() { }
1915
+ /**
1916
+ * Should continue process to child elements.
1917
+ *
1918
+ * @returns {boolean} - boolean.
1919
+ */
1920
+ shouldProceedToElementChildren() {
1921
+ return false;
1922
+ }
1923
+ }
1924
+
1925
+ /** Transform vega-rich-text-image-editor element to image block DTO */
1926
+ class VegaImageToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
1927
+ /**
1928
+ * Can be handle.
1929
+ *
1930
+ * @param {HTMLElement[]} elementsArray - Current elements.
1931
+ * @param {number} currentIndex - Current element index.
1932
+ * @returns {number} - can be handled element count.
1933
+ */
1934
+ canHandle(elementsArray, currentIndex) {
1935
+ return elementsArray[currentIndex].tagName === 'VEGA-RICH-TEXT-IMAGE-EDITOR' ? 1 : 0;
1936
+ }
1937
+ /**
1938
+ * Parse to a image block.
1939
+ *
1940
+ * @param {HTMLElement[]} elementsArray - Current elements.
1941
+ * @returns {Nullable<RTEContentBlock>} - Image block.
1942
+ */
1943
+ handle(elementsArray) {
1944
+ const element = elementsArray[0];
1945
+ const image = element.querySelector('img');
1946
+ if (isNonNullable(image)) {
1947
+ return RTEImageBlock.from({
1948
+ id: generateUUID(),
1949
+ type: 'image',
1950
+ nodes: [
1951
+ {
1952
+ id: generateUUID(),
1953
+ type: 'image',
1954
+ url: image.src,
1955
+ annotations: Object.assign({ size: this.getImageSize(element), alt: element.alt }, this.generateCommonAnnotations(element)),
1956
+ },
1957
+ ],
1958
+ annotations: this.generateBlockAnnotations(element.parentElement),
1959
+ });
1960
+ }
1961
+ }
1962
+ /* istanbul ignore next */
1963
+ /**
1964
+ * Append child blocks.
1965
+ */
1966
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
1967
+ appendChildBlocks() { }
1968
+ /**
1969
+ * Should continue process to child elements.
1970
+ *
1971
+ * @returns {boolean} - boolean.
1972
+ */
1973
+ shouldProceedToElementChildren() {
1974
+ return false;
1975
+ }
1976
+ }
1977
+
1978
+ /** Transform ol element to list block DTO */
1979
+ class OlToRTEListBlockStrategy extends BlockToRTEBlockStrategyAbstract {
1980
+ /**
1981
+ * Can be handle.
1982
+ *
1983
+ * @param {HTMLElement[]} elementsArray - Current elements.
1984
+ * @param {number} currentIndex - Current element index.
1985
+ * @returns {number} - can be handled element count.
1986
+ */
1987
+ canHandle(elementsArray, currentIndex) {
1988
+ return elementsArray[currentIndex].tagName === 'OL' ? 1 : 0;
1989
+ }
1990
+ /**
1991
+ * Parse to a number list block.
1992
+ *
1993
+ * @param {HTMLElement[]} elementsArray - Current elements.
1994
+ * @returns {Nullable<RTEContentBlock>} - Number list block.
1995
+ */
1996
+ handle(elementsArray) {
1997
+ if (elementsArray[0].childNodes.length === 0)
1998
+ return null;
1999
+ return RTEListBlock.from({
2000
+ id: generateUUID(),
2001
+ type: 'number-list',
2002
+ blocks: [],
2003
+ annotations: this.generateBlockAnnotations(elementsArray[0]),
2004
+ });
2005
+ }
2006
+ /**
2007
+ * Append child list item blocks to current list block.
2008
+ *
2009
+ * @param {RTEListBlock} currentBlock - Current list block.
2010
+ * @param {RTEContentBlock[]} childBlocks - Current list item blocks.
2011
+ */
2012
+ appendChildBlocks(currentBlock, childBlocks) {
2013
+ currentBlock.blocks = childBlocks.filter((block) => block instanceof RTEListItemBlock);
2014
+ childBlocks.forEach((block) => (block.parent = currentBlock));
2015
+ }
2016
+ /**
2017
+ * Should continue process to child elements.
2018
+ *
2019
+ * @returns {boolean} - boolean.
2020
+ */
2021
+ shouldProceedToElementChildren() {
2022
+ return true;
2023
+ }
2024
+ }
2025
+
2026
+ /** Transform img in span or other inline element to image block DTO */
2027
+ class SpanImageToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
2028
+ /**
2029
+ * Can be handle.
2030
+ *
2031
+ * @param {HTMLElement[]} elementsArray - Current elements.
2032
+ * @param {number} currentIndex - Current element index.
2033
+ * @returns {number} - can be handled element count.
2034
+ */
2035
+ canHandle(elementsArray, currentIndex) {
2036
+ const element = elementsArray[currentIndex];
2037
+ return element.nodeType === Node.ELEMENT_NODE &&
2038
+ element.textContent === '' &&
2039
+ element.querySelector('img')
2040
+ ? 1
2041
+ : 0;
2042
+ }
2043
+ /**
2044
+ * Parse to a image block.
2045
+ *
2046
+ * @param {HTMLElement[]} elementsArray - Current elements.
2047
+ * @returns {Nullable<RTEContentBlock>} - Image block.
2048
+ */
2049
+ handle(elementsArray) {
2050
+ const element = elementsArray[0].querySelector('img');
2051
+ return this.createRTEImageBlock(element);
2052
+ }
2053
+ /* istanbul ignore next */
2054
+ /**
2055
+ * Append child blocks.
2056
+ */
2057
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2058
+ appendChildBlocks() { }
2059
+ /**
2060
+ * Should continue process to child elements.
2061
+ *
2062
+ * @returns {boolean} - boolean.
2063
+ */
2064
+ shouldProceedToElementChildren() {
2065
+ return false;
2066
+ }
2067
+ }
2068
+
2069
+ /** Transform child element of UL element which are not LI element to list item block DTO */
2070
+ class ULNotLiChildToRTEListItemBlockStrategy extends BlockToRTEBlockStrategyAbstract {
2071
+ /**
2072
+ * Can be handle.
2073
+ *
2074
+ * @param {HTMLElement[]} elementsArray - Current elements.
2075
+ * @param {number} currentIndex - Current element index.
2076
+ * @returns {number} - can be handled element count.
2077
+ */
2078
+ canHandle(elementsArray, currentIndex) {
2079
+ const element = elementsArray[currentIndex];
2080
+ const parent = element.parentElement;
2081
+ const isLiNode = element.nodeName !== 'LI';
2082
+ // while child is empty text node like newline or empty string, we should not covert it.
2083
+ const isEmptyNode = element.nodeType === Node.TEXT_NODE && element.textContent.trim() === '';
2084
+ // The node must be in list item.
2085
+ const isInList = isNonNullable(parent) && ['UL', 'OL'].includes(parent.nodeName);
2086
+ return isLiNode && !isEmptyNode && isInList ? 1 : 0;
2087
+ }
2088
+ /**
2089
+ * Parse to a list item block.
2090
+ *
2091
+ * @param {HTMLElement[]} elementsArray - Current elements.
2092
+ * @returns {Nullable<RTEContentBlock>} - List item block.
2093
+ */
2094
+ handle(elementsArray) {
2095
+ const nodes = this.generateChildNodes(elementsArray);
2096
+ return RTEListItemBlock.from({
2097
+ id: generateUUID(),
2098
+ type: 'list-item',
2099
+ nodes: nodes,
2100
+ annotations: {},
2101
+ });
2102
+ }
2103
+ /* istanbul ignore next */
2104
+ /**
2105
+ * Append child blocks.
2106
+ */
2107
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2108
+ appendChildBlocks() { }
2109
+ /**
2110
+ * Should continue process to child elements.
2111
+ *
2112
+ * @returns {boolean} - boolean.
2113
+ */
2114
+ shouldProceedToElementChildren() {
2115
+ return false;
2116
+ }
2117
+ }
2118
+
2119
+ /** Transform other editor code element which has attribute data-language to RTE code block DTO */
2120
+ class JiraCodeToRTECodeBlockStrategy extends BlockToRTEBlockStrategyAbstract {
2121
+ /**
2122
+ * Can be handle.
2123
+ *
2124
+ * @param {HTMLElement[]} elementsArray - Current elements.
2125
+ * @param {number} currentIndex - Current element index.
2126
+ * @returns {number} - can be handled element count.
2127
+ */
2128
+ canHandle(elementsArray, currentIndex) {
2129
+ return (elementsArray[currentIndex].tagName === 'PRE' ||
2130
+ elementsArray[currentIndex].tagName === 'CODE') &&
2131
+ elementsArray[currentIndex].hasAttribute('data-language')
2132
+ ? 1
2133
+ : 0;
2134
+ }
2135
+ /**
2136
+ * Parse to a code block.
2137
+ *
2138
+ * @param {HTMLElement[]} elementsArray - Current elements.
2139
+ * @returns {Nullable<RTECodeBlock>} - Code block.
2140
+ */
2141
+ handle(elementsArray) {
2142
+ const codeRef = elementsArray[0];
2143
+ if (codeRef) {
2144
+ const content = codeRef.textContent;
2145
+ const language = codeRef.dataset
2146
+ .language;
2147
+ return RTECodeBlock.from({
2148
+ id: generateUUID(),
2149
+ type: 'code-block',
2150
+ content,
2151
+ language,
2152
+ });
2153
+ }
2154
+ }
2155
+ /* istanbul ignore next */
2156
+ /**
2157
+ * Append child blocks.
2158
+ */
2159
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2160
+ appendChildBlocks() { }
2161
+ /**
2162
+ * Should continue process to child elements.
2163
+ *
2164
+ * @returns {boolean} - boolean.
2165
+ */
2166
+ shouldProceedToElementChildren() {
2167
+ return false;
2168
+ }
2169
+ }
2170
+
2171
+ /** Transform vega-code-block element to code block DTO */
2172
+ class VegaCodeBlockToRTECodeBlockStrategy extends JiraCodeToRTECodeBlockStrategy {
2173
+ /**
2174
+ * Can be handle.
2175
+ *
2176
+ * TODO: Update the browser clipboard data to fix the issue with nested vega-code-block elements.
2177
+ * In safari the html snippet will be like: <vega-code-block><p><span>paragraph</span></p><vega-code-block></vega-code-block></vega-code-block>
2178
+ * The vega-code-block nested inside the vega-code-block, so we need to check the child element.
2179
+ *
2180
+ * @param {HTMLElement[]} elementsArray - Current elements.
2181
+ * @param {number} currentIndex - Current element index.
2182
+ * @returns {number} - can be handled element count.
2183
+ */
2184
+ canHandle(elementsArray, currentIndex) {
2185
+ return (elementsArray[currentIndex].tagName === 'VEGA-CODE-BLOCK' &&
2186
+ !!elementsArray[currentIndex].querySelector('vega-code-block') === false) ||
2187
+ this.isCodeBlockContainer(elementsArray[currentIndex])
2188
+ ? 1
2189
+ : 0;
2190
+ }
2191
+ /**
2192
+ * Parse to a code block.
2193
+ *
2194
+ * @param {HTMLElement[]} elementsArray - Current elements.
2195
+ * @returns {Nullable<RTECodeBlock>} - Code block.
2196
+ */
2197
+ handle(elementsArray) {
2198
+ const codeBlockElement = this.isCodeBlockContainer(elementsArray[0])
2199
+ ? elementsArray[0].querySelector('vega-code-block')
2200
+ : elementsArray[0];
2201
+ const code = codeBlockElement.querySelector('code');
2202
+ if (code) {
2203
+ return super.handle([code]); // Call the parent method to handle the code element
2204
+ }
2205
+ else if (codeBlockElement.hasAttribute('data-content')) {
2206
+ // The code element in shadow dom could be empty in firefox.
2207
+ const code = document.createElement('code');
2208
+ code.textContent = codeBlockElement.dataset.content;
2209
+ code.dataset.language = codeBlockElement.dataset.language;
2210
+ return super.handle([code]); // Call the parent method to handle the code element
2211
+ }
2212
+ }
2213
+ /* istanbul ignore next */
2214
+ /**
2215
+ * Append child blocks.
2216
+ */
2217
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
2218
+ appendChildBlocks() { }
2219
+ /**
2220
+ * Should continue process to child elements.
2221
+ *
2222
+ * @returns {boolean} - boolean.
2223
+ */
2224
+ shouldProceedToElementChildren() {
2225
+ return false;
2226
+ }
2227
+ /**
2228
+ * Checks if the given element is a code block container.
2229
+ *
2230
+ * @param {HTMLElement} element - The element to check.
2231
+ * @returns {boolean} - Boolean result.
2232
+ */
2233
+ isCodeBlockContainer(element) {
2234
+ return (element.tagName === 'PRE' &&
2235
+ element.classList.contains('code-block-container') &&
2236
+ element.querySelectorAll('vega-code-block').length === 1);
2237
+ }
2238
+ }
2239
+
2240
+ /** Element to DTO processor */
2241
+ class ElementToDtoStrategyProcessor {
2242
+ constructor() {
2243
+ this.elementStrategies = [
2244
+ new UlToRTEListBlockStrategy(),
2245
+ new OlToRTEListBlockStrategy(),
2246
+ new ULNotLiChildToRTEListItemBlockStrategy(),
2247
+ new LiToRTEListItemBlockStrategy(),
2248
+ new VegaCodeBlockToRTECodeBlockStrategy(),
2249
+ new JiraCodeToRTECodeBlockStrategy(),
2250
+ new InlineBlockToRTETextBlockStrategy(),
2251
+ new ImgToRTEImageBlockStrategy(),
2252
+ new VegaImageToRTEImageBlockStrategy(),
2253
+ new SpanImageToRTEImageBlockStrategy(),
2254
+ new ContinueInlineToRTETextBlockStrategy(),
2255
+ ];
2256
+ }
2257
+ /**
2258
+ * Transform process.
2259
+ *
2260
+ * @param {HTMLElement[]} elements - Current elements.
2261
+ * @returns {ElementToDTOStrategyOutput[]} - outputs.
2262
+ */
2263
+ process(elements) {
2264
+ const outputs = [];
2265
+ for (let i = 0; i < elements.length; i++) {
2266
+ if (this.isInvalidElement(elements[i]))
2267
+ continue;
2268
+ let canHandledCount = 0;
2269
+ for (const strategy of this.elementStrategies) {
2270
+ canHandledCount = strategy.canHandle(elements, i);
2271
+ if (canHandledCount > 0) {
2272
+ const handledElements = elements.slice(i, i + canHandledCount);
2273
+ const output = new ElementToDTOStrategyOutput(strategy, handledElements);
2274
+ if (canHandledCount === 1 && strategy.shouldProceedToElementChildren()) {
2275
+ output.setChildrenOutput(this.process(Array.from(handledElements[0].childNodes)));
2276
+ }
2277
+ outputs.push(output);
2278
+ i += canHandledCount - 1;
2279
+ break;
2280
+ }
2281
+ }
2282
+ if (canHandledCount === 0 && i < elements.length) {
2283
+ const elementChildren = Array.from(elements[i].childNodes);
2284
+ const childrenOutputs = this.process(Array.from(elementChildren));
2285
+ if (childrenOutputs.length > 0) {
2286
+ outputs.push(...childrenOutputs);
2287
+ }
2288
+ }
2289
+ }
2290
+ return outputs;
2291
+ }
2292
+ /**
2293
+ * Checks if the given element is valid to parse.
2294
+ *
2295
+ * @param {HTMLElement} element - The pasted element.
2296
+ * @returns {boolean} Is valid
2297
+ */
2298
+ isInvalidElement(element) {
2299
+ if (element.nodeType === Node.COMMENT_NODE)
2300
+ return true;
2301
+ return ['META', 'BUTTON', 'STYLE'].includes(element.nodeName);
2302
+ }
2303
+ }
2304
+ const ElementToDtoStrategyProcessor$1 = new ElementToDtoStrategyProcessor();
2305
+
2306
+ /**
2307
+ * Class representing the content state of the rich text editor.
2308
+ */
2309
+ class VegaRTEContent {
2310
+ constructor(blocks) {
2311
+ blocks.forEach((block) => {
2312
+ block.parent = this;
2313
+ });
2314
+ this.blocks = blocks;
2315
+ }
2316
+ /**
2317
+ * Converts a JSON array of blocks to a class array of RTEContentBlock.
2318
+ *
2319
+ * @param {VegaRTEContentBlock[]} value The JSON array of blocks to convert.
2320
+ * @returns {VegaRTEContent} The converted array of RTEContentBlock.
2321
+ */
2322
+ static fromJSON(value) {
2323
+ const blocks = value.map((block) => {
2324
+ switch (block.type) {
2325
+ case 'paragraph':
2326
+ case 'title':
2327
+ case 'subtitle':
2328
+ case 'heading-1':
2329
+ case 'heading-2':
2330
+ case 'heading-3': {
2331
+ return RTETextBlock.from(block);
2332
+ }
2333
+ case 'image':
2334
+ return RTEImageBlock.from(block);
2335
+ case 'bullet-list':
2336
+ case 'number-list':
2337
+ return RTEListBlock.from(block);
2338
+ case 'code-block':
2339
+ return RTECodeBlock.from(block);
2340
+ default: {
2341
+ throw new Error(`[Vega] Unknown block type: ${block.type}`);
2342
+ }
2343
+ }
2344
+ });
2345
+ return new VegaRTEContent(blocks);
2346
+ }
2347
+ /**
2348
+ * Create an empty content state
2349
+ *
2350
+ * @returns {VegaRTEContent} An empty content state
2351
+ */
2352
+ static createEmptyContent() {
2353
+ return VegaRTEContent.fromJSON([
2354
+ {
2355
+ id: generateUUID(),
2356
+ type: 'paragraph',
2357
+ nodes: [
2358
+ {
2359
+ id: generateUUID(),
2360
+ type: 'text',
2361
+ text: '',
2362
+ },
2363
+ ],
2364
+ },
2365
+ ]);
2366
+ }
2367
+ /**
2368
+ * Converts HTML content to a VegaRTEContent instance.
2369
+ *
2370
+ * @param {string} html - The HTML string to convert.
2371
+ * @returns {VegaRTEContent} The converted content state.
2372
+ */
2373
+ static fromHtml(html) {
2374
+ const body = new DOMParser().parseFromString(html, 'text/html').body;
2375
+ const blocks = ElementToDtoStrategyProcessor$1.process(Array.from(body.childNodes))
2376
+ .filter(isNonNullable)
2377
+ .map((output) => output.toDto())
2378
+ .filter(isNonNullable);
2379
+ return new VegaRTEContent(blocks);
2380
+ }
2381
+ /**
2382
+ * Clones the content state.
2383
+ *
2384
+ * @param {boolean} deep - If true, performs a deep clone of the content state.
2385
+ * @returns {VegaRTEContent} The cloned content state.
2386
+ */
2387
+ clone(deep = false) {
2388
+ return deep
2389
+ ? new VegaRTEContent(this.blocks.map((block) => block.clone()))
2390
+ : new VegaRTEContent([...this.blocks]);
2391
+ }
2392
+ /**
2393
+ * Converts the content state to a JSON array of blocks.
2394
+ *
2395
+ * @returns {VegaRTEContentBlock[]} The JSON array of blocks.
2396
+ */
2397
+ toJSON() {
2398
+ return this.blocks.map((block) => block.toJSON());
2399
+ }
2400
+ /**
2401
+ * Converts the content state to HTML.
2402
+ *
2403
+ * @returns {string} The HTML representation of the content state.
2404
+ */
2405
+ toHtml() {
2406
+ return this.blocks.map((block) => block.toHtml()).join('');
2407
+ }
2408
+ /**
2409
+ * Internal method to add the block item, remove the block item
2410
+ *
2411
+ * @param {ModifyContentAction} action - Modify content action
2412
+ */
2413
+ apply(action) {
2414
+ ActionHandleStrategyRegistry.executeTheStrategy(action, this);
2415
+ }
2416
+ /**
2417
+ * Convert text to list.
2418
+ *
2419
+ * @param {RTETextBlock} block - block
2420
+ * @returns {RTEListItemBlock} list item block dto.
2421
+ */
2422
+ toListItem(block) {
2423
+ block.nodes.map((node) => node.apply(new SyncUpSelectionAction()));
2424
+ const listItemBlock = new RTEListItemBlock(generateUUID());
2425
+ listItemBlock.apply(new AppendChildNodesAction(block['nodes']));
2426
+ listItemBlock['annotationMap'] = block['annotationMap'];
2427
+ return listItemBlock;
2428
+ }
2429
+ /**
2430
+ * create list.
2431
+ *
2432
+ * @param {ListType} type - type
2433
+ * @returns {RTEListBlock} list block dto.
2434
+ */
2435
+ createList(type) {
2436
+ return new RTEListBlock(generateUUID(), type);
2437
+ }
2438
+ /**
2439
+ * Finds a node by its ID in the content.
2440
+ *
2441
+ * @param {string} id - The ID of the node to find.
2442
+ * @returns {Nullable<RTENode>} The found node or null if not found.
2443
+ */
2444
+ findNodeById(id) {
2445
+ return this.findNodeInBlocksById(id, this.blocks);
2446
+ }
2447
+ /**
2448
+ * Recursively searches for a node by its ID in the given blocks.
2449
+ *
2450
+ * @param {string} id - The ID of the node to find.
2451
+ * @param {RTEContentBlock[]} blocks - The blocks to search within.
2452
+ * @returns {Nullable<RTENode>} The found node or null if not found.
2453
+ */
2454
+ findNodeInBlocksById(id, blocks) {
2455
+ for (const block of blocks) {
2456
+ if ('nodes' in block) {
2457
+ for (const node of block.nodes) {
2458
+ if (node.id === id) {
2459
+ return node;
2460
+ }
2461
+ }
2462
+ }
2463
+ if (block instanceof RTEListItemBlock && block.children) {
2464
+ for (const cBlock of block.children) {
2465
+ const foundNode = this.findNodeInBlocksById(id, cBlock.blocks);
2466
+ if (foundNode) {
2467
+ return foundNode;
2468
+ }
2469
+ }
2470
+ }
2471
+ if (block instanceof RTEListBlock && block.blocks) {
2472
+ const foundNode = this.findNodeInBlocksById(id, block.blocks);
2473
+ if (foundNode) {
2474
+ return foundNode;
2475
+ }
2476
+ }
2477
+ }
2478
+ return null;
2479
+ }
2480
+ }
2481
+ (() => {
2482
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, VegaRTEContent.name, new BlockRemoveChildBlockStrategy());
2483
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, VegaRTEContent.name, new BlockAppendBlocksStrategy());
2484
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_BLOCKS_BEFORE, VegaRTEContent.name, new BlockInsertBlocksBeforeStrategy());
2485
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_BLOCKS_AFTER, VegaRTEContent.name, new BlockInsertBlocksAfterStrategy());
2486
+ ActionHandleStrategyRegistry.register(ModifyContentActionType.TRANSFORM_TO_CODE_BLOCK, VegaRTEContent.name, new BlockTransformToCodeBlockStrategy());
2487
+ })();
2488
+
2489
+ export { BreakSingleBlockAction as B, ElementToDtoStrategyProcessor$1 as E, RTEImageBlock as R, VegaRTEContent as V, RTEListItemBlock as a, RTEListBlock as b };