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