@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,4073 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-7700600c.js');
6
+ const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
7
+ const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-dcb32c24.js');
8
+ const component = require('./component-73a88c4e.js');
9
+ const internalIconManager = require('./internal-icon-manager-00f49470.js');
10
+ const trashCan = require('./trash-can-46a5e19a.js');
11
+ const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-a7a3b196.js');
12
+ const domNodeSubjectFactory = require('./dom-node-subject-factory-d5826bff.js');
13
+ const codeBlock = require('./code-block-4cd8bccd.js');
14
+ const ui = require('./ui-13b42af0.js');
15
+ const eventEmitSlimmer = require('./event-emit-slimmer-ee7a8c06.js');
16
+ const object = require('./object-bbd4ed7f.js');
17
+ const translationSlimmer = require('./translation-slimmer-127a0f83.js');
18
+ const selectionController = require('./selection-controller-828990cc.js');
19
+ const changeManager = require('./change-manager-a297e4d2.js');
20
+ const vegaInternalEventId = require('./vega-internal-event-id-62371952.js');
21
+ const timer = require('./timer-5f33058b.js');
22
+ const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-26ecfb15.js');
23
+ const _commonjsHelpers = require('./_commonjsHelpers-537d719a.js');
24
+ const componentGlobalStyleSlimmer = require('./component-global-style-slimmer-6749808c.js');
25
+ require('./icon-manager-9a47399c.js');
26
+ require('./create-public-api-runtime-metrics-slimmer-a3d17afb.js');
27
+ require('./dynamic-slimmer-f31fdfd7.js');
28
+ require('./observer-f49483e8.js');
29
+ require('./type-guard-4ba85fdc.js');
30
+ require('./breakpoints-ebde4837.js');
31
+ require('./ui-32e69595.js');
32
+ require('./regex-c1f70fd4.js');
33
+ require('./typography-4560e7f1.js');
34
+ require('./string-39438062.js');
35
+ require('./dark-mode-style-controller-4adb7fb2.js');
36
+ require('./static-subject-title-7e7d791a.js');
37
+ require('./internal-vega-event-manager-58afcde7.js');
38
+ require('./translation-e5003a00.js');
39
+ require('./synchronize-task-queue-1ee80e94.js');
40
+ require('./vega-env-manager-23b8b23c.js');
41
+ require('./feature-flag-controller-5e58aae4.js');
42
+ require('./index-8b247c17.js');
43
+
44
+ var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
45
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
46
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
47
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
48
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
49
+ };
50
+ /**
51
+ * The code block editor renderer class.
52
+ */
53
+ class VegaCodeBlockRenderer extends globalSlimmerRegistry.VegaSlimmer {
54
+ constructor() {
55
+ super(...arguments);
56
+ this.languageDropdownProps = {
57
+ searchable: false,
58
+ };
59
+ this.languageOptions = Object.keys(codeBlock.CodeLanguage).map((key) => {
60
+ return { id: codeBlock.CodeLanguage[key], displayName: key };
61
+ });
62
+ /**
63
+ * Handle the code language update.
64
+ *
65
+ * @param {HTMLVegaInputSelectElement} node - The language select element.
66
+ */
67
+ this.handleLanguageChange = (node) => {
68
+ domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, domNodeSubjectFactory.VegaChange, (payload) => {
69
+ var _a;
70
+ this.valueController.updateValue((_a = this.value) === null || _a === void 0 ? void 0 : _a.code, payload.detail);
71
+ });
72
+ };
73
+ /**
74
+ * Handle the code language update.
75
+ *
76
+ * @param {HTMLVegaButtonCircleElement} node - The delete button.
77
+ */
78
+ this.handleDeleteClick = (node) => {
79
+ domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, domNodeSubjectFactory.VegaClick, () => {
80
+ const event = this.removeEventEmitter.emit();
81
+ if (!event.defaultPrevented) {
82
+ this.host.remove();
83
+ }
84
+ });
85
+ };
86
+ }
87
+ /**
88
+ * Get the toolbar container element ref.
89
+ *
90
+ * @returns {HTMLDivElement} - The div element.
91
+ */
92
+ getToolbarContainerRef() {
93
+ return this.toolbarContainerRef;
94
+ }
95
+ /**
96
+ * Render the code block editor toolbar element or copy element.
97
+ *
98
+ * @returns {HTMLElement} - The code block operate action button.
99
+ */
100
+ render() {
101
+ return (index.h(index.Fragment, null,
102
+ index.h("div", { part: "editor-toolbar", contenteditable: false, class: {
103
+ 'editor-toolbar': !this.readOnly,
104
+ 'copy-button-container': this.showCopyButton && this.readOnly,
105
+ }, ref: (node) => (this.toolbarContainerRef = node) },
106
+ this.renderEditorToolbar(),
107
+ this.copyButtonRenderer.render()),
108
+ this.contentRenderer.render()));
109
+ }
110
+ /**
111
+ * Render a language select and delete button.
112
+ *
113
+ * @returns {Nullable<HTMLElement>} The editor toolbar container element.
114
+ */
115
+ renderEditorToolbar() {
116
+ var _a, _b;
117
+ if (!this.readOnly) {
118
+ return (index.h(index.Fragment, null,
119
+ index.h("vega-input-select", { source: this.languageOptions, value: (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.language) !== null && _b !== void 0 ? _b : '', disabled: this.disabled, placeholder: this.translationSlimmer.t('Select Language'), size: "small", vegaDropdownProps: this.languageDropdownProps, exportparts: "select-container, selected-box, placeholder, toggle-icon-container, toggle-icon", ref: this.handleLanguageChange }),
120
+ index.h("vega-button-circle", { key: "delete-button", disabled: this.disabled, label: this.translationSlimmer.t('Delete Code'), icon: internalIconManager.VegaInternalIconManager.getIconKey('trash-can'), iconColor: "text-secondary", variant: "icon-only", size: "extra-small", ref: this.handleDeleteClick })));
121
+ }
122
+ }
123
+ }
124
+ (() => {
125
+ internalIconManager.VegaInternalIconManager.register({
126
+ 'trash-can': trashCan.trashCan,
127
+ });
128
+ })();
129
+ __decorate$9([
130
+ globalSlimmerRegistry.MapToComponentField()
131
+ ], VegaCodeBlockRenderer.prototype, "readOnly", void 0);
132
+ __decorate$9([
133
+ globalSlimmerRegistry.MapToComponentField()
134
+ ], VegaCodeBlockRenderer.prototype, "host", void 0);
135
+ __decorate$9([
136
+ globalSlimmerRegistry.MapToComponentField()
137
+ ], VegaCodeBlockRenderer.prototype, "disabled", void 0);
138
+ __decorate$9([
139
+ globalSlimmerRegistry.MapToComponentField()
140
+ ], VegaCodeBlockRenderer.prototype, "showCopyButton", void 0);
141
+ __decorate$9([
142
+ globalSlimmerRegistry.MapToComponentField()
143
+ ], VegaCodeBlockRenderer.prototype, "value", void 0);
144
+ __decorate$9([
145
+ globalSlimmerRegistry.MapToComponentField()
146
+ ], VegaCodeBlockRenderer.prototype, "contentRenderer", void 0);
147
+ __decorate$9([
148
+ globalSlimmerRegistry.MapToComponentField()
149
+ ], VegaCodeBlockRenderer.prototype, "valueController", void 0);
150
+ __decorate$9([
151
+ globalSlimmerRegistry.MapToComponentField()
152
+ ], VegaCodeBlockRenderer.prototype, "removeEventEmitter", void 0);
153
+ __decorate$9([
154
+ globalSlimmerRegistry.MapToComponentField()
155
+ ], VegaCodeBlockRenderer.prototype, "translationSlimmer", void 0);
156
+ __decorate$9([
157
+ globalSlimmerRegistry.MapToComponentField()
158
+ ], VegaCodeBlockRenderer.prototype, "copyButtonRenderer", void 0);
159
+
160
+ var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
161
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
162
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
163
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
164
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
165
+ };
166
+ /**
167
+ * The code block content renderer class.
168
+ */
169
+ class VegaCodeBlockContentRenderer extends globalSlimmerRegistry.VegaSlimmer {
170
+ constructor() {
171
+ super(...arguments);
172
+ /**
173
+ * The code input area focus.
174
+ */
175
+ this.handleFocus = () => {
176
+ if (!this.readOnly && !this.disabled) {
177
+ this.host.classList.add('focus');
178
+ }
179
+ };
180
+ /**
181
+ * The code input area blur.
182
+ */
183
+ this.handleBlur = () => {
184
+ this.host.classList.remove('focus');
185
+ };
186
+ }
187
+ /**
188
+ * Get the editable root element.
189
+ *
190
+ * @returns {HTMLElement} - The root element.
191
+ */
192
+ getCodeContentContainerRef() {
193
+ return this.codeContentContainerRef;
194
+ }
195
+ /**
196
+ * Add focus and blur event listener.
197
+ */
198
+ registerEventListener() {
199
+ if (this.codeContentContainerRef) {
200
+ this.codeContentContainerRef.addEventListener('focusin', this.handleFocus);
201
+ this.codeContentContainerRef.addEventListener('focusout', this.handleBlur);
202
+ }
203
+ }
204
+ /**
205
+ * Remove the event listener.
206
+ */
207
+ unregisterEventListener() {
208
+ if (this.codeContentContainerRef) {
209
+ this.codeContentContainerRef.removeEventListener('focusin', this.handleFocus);
210
+ this.codeContentContainerRef.removeEventListener('focusout', this.handleBlur);
211
+ }
212
+ }
213
+ /**
214
+ * Render the code content.
215
+ *
216
+ * @returns {HTMLElement} - The code element.
217
+ */
218
+ render() {
219
+ var _a;
220
+ const codeNodes = this.contentParseController.parseCode();
221
+ const language = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.language) || '';
222
+ return (index.h(index.Fragment, null,
223
+ index.h("style", null, this.getLineNumberStyleVariable(codeNodes)),
224
+ index.h("code", { role: "textbox", tabIndex: 0, spellcheck: false, ref: (node) => (this.codeContentContainerRef = node), contenteditable: this.readOnly || this.disabled ? false : true, "data-language": language, innerHTML: codeNodes
225
+ .map((codeNode) => this.renderCodeNode(codeNode))
226
+ .join('') })));
227
+ }
228
+ /**
229
+ * Render the code node the html element.
230
+ *
231
+ * @param {CodeNodeType} codeNode - The code node object.
232
+ * @returns {string} - The html element.
233
+ */
234
+ renderCodeNode(codeNode) {
235
+ const { key, className, mark, text } = codeNode;
236
+ return `<span key='${key}' class='${className}' data-mark='${mark}' data-index='${key}'>${text || ' '}</span>`;
237
+ }
238
+ /**
239
+ * Dynamic calculate line number element width and update the margin and padding variable.
240
+ *
241
+ * @param {CodeNodeType[]} codeNodes - The code node array.
242
+ * @returns {string} - The style content.
243
+ */
244
+ getLineNumberStyleVariable(codeNodes) {
245
+ const lineCountArray = codeNodes.filter((item) => {
246
+ return item.text === '\n';
247
+ });
248
+ const singleTextLength = 10;
249
+ const gap = 16;
250
+ const space = (lineCountArray.length + 1).toString().length * singleTextLength;
251
+ return `code{--v-code-line-number-width:${space}px;--v-code-line-number-ml:-${space + gap}px;--v-code-block-pl:${space + gap}px}`;
252
+ }
253
+ }
254
+ __decorate$8([
255
+ globalSlimmerRegistry.MapToComponentField()
256
+ ], VegaCodeBlockContentRenderer.prototype, "host", void 0);
257
+ __decorate$8([
258
+ globalSlimmerRegistry.MapToComponentField()
259
+ ], VegaCodeBlockContentRenderer.prototype, "readOnly", void 0);
260
+ __decorate$8([
261
+ globalSlimmerRegistry.MapToComponentField()
262
+ ], VegaCodeBlockContentRenderer.prototype, "disabled", void 0);
263
+ __decorate$8([
264
+ globalSlimmerRegistry.MapToComponentField()
265
+ ], VegaCodeBlockContentRenderer.prototype, "value", void 0);
266
+ __decorate$8([
267
+ globalSlimmerRegistry.MapToComponentField()
268
+ ], VegaCodeBlockContentRenderer.prototype, "valueController", void 0);
269
+ __decorate$8([
270
+ globalSlimmerRegistry.MapToComponentField()
271
+ ], VegaCodeBlockContentRenderer.prototype, "contentParseController", void 0);
272
+ __decorate$8([
273
+ globalSlimmerRegistry.MapToComponentField()
274
+ ], VegaCodeBlockContentRenderer.prototype, "selectionController", void 0);
275
+ __decorate$8([
276
+ globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
277
+ ], VegaCodeBlockContentRenderer.prototype, "registerEventListener", null);
278
+ __decorate$8([
279
+ globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
280
+ ], VegaCodeBlockContentRenderer.prototype, "unregisterEventListener", null);
281
+
282
+ var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
283
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
284
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
285
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
286
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
287
+ };
288
+ /**
289
+ * The component value controller.
290
+ */
291
+ class VegaCodeBlockValueController extends globalSlimmerRegistry.VegaSlimmer {
292
+ /**
293
+ * Update the component value if code content or code language update.
294
+ *
295
+ * @param {string} code - The new code content.
296
+ * @param {string} language - The new code language.
297
+ */
298
+ updateValue(code, language) {
299
+ if (!this.value || this.value.code !== code || this.value.language !== language) {
300
+ this.value = {
301
+ language: language,
302
+ code,
303
+ };
304
+ this.changeEventEmitter.emit(this.value);
305
+ }
306
+ }
307
+ /**
308
+ * Set a default value if the value is not defined.
309
+ */
310
+ initialValue() {
311
+ if (!this.value) {
312
+ this.value = { code: '', language: 'plainText' };
313
+ }
314
+ }
315
+ }
316
+ __decorate$7([
317
+ globalSlimmerRegistry.MapToComponentField({ writable: true })
318
+ ], VegaCodeBlockValueController.prototype, "value", void 0);
319
+ __decorate$7([
320
+ globalSlimmerRegistry.MapToComponentField()
321
+ ], VegaCodeBlockValueController.prototype, "changeEventEmitter", void 0);
322
+ __decorate$7([
323
+ globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
324
+ ], VegaCodeBlockValueController.prototype, "initialValue", null);
325
+
326
+ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
327
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
328
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
329
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
330
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
331
+ };
332
+ /**
333
+ * Parse the code content to different tokens.
334
+ */
335
+ class CodeContentParseController extends globalSlimmerRegistry.VegaSlimmer {
336
+ constructor() {
337
+ super(...arguments);
338
+ this.codeNodes = [];
339
+ }
340
+ /**
341
+ * Get the current rendering code node array.
342
+ *
343
+ * @returns {CodeNodeType[]} - The code node array.
344
+ */
345
+ getCurrentCodeNodes() {
346
+ return this.codeNodes;
347
+ }
348
+ /**
349
+ * Split the code content to code node array. The default parse used if the language is not defined.
350
+ *
351
+ * @returns {CodeNodeType[]} - The code node array.
352
+ */
353
+ parseCode() {
354
+ const parsers = [
355
+ this.prismCodeHighlightParser,
356
+ this.defaultCodeHighlightParser,
357
+ ];
358
+ let result = [];
359
+ for (const parser of parsers) {
360
+ if (parser.canParse()) {
361
+ result = parser.parse();
362
+ break;
363
+ }
364
+ }
365
+ this.codeNodes = result;
366
+ return result;
367
+ }
368
+ }
369
+ __decorate$6([
370
+ globalSlimmerRegistry.MapToComponentField()
371
+ ], CodeContentParseController.prototype, "prismCodeHighlightParser", void 0);
372
+ __decorate$6([
373
+ globalSlimmerRegistry.MapToComponentField()
374
+ ], CodeContentParseController.prototype, "defaultCodeHighlightParser", void 0);
375
+
376
+ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
377
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
378
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
379
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
380
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
381
+ };
382
+ /**
383
+ * The class used to control the code block input cursor.
384
+ */
385
+ class VegaCodeBlockSelectionController extends selectionController.AutoRunWhenReRenderTaskQueueSlimmer {
386
+ constructor() {
387
+ super(1);
388
+ this.selectionState = null;
389
+ this.handleSelectionWithDebounce = timer.debounce(this.handleSelectionChange, VegaCodeBlockSelectionController.SELECTION_CHANGE_DEBOUNCE_TIME, this);
390
+ /**
391
+ * The method invoke after the component re-render.
392
+ */
393
+ this.doTask = async () => {
394
+ // add await Promise.resolve to put the code behind to a micro task
395
+ await Promise.resolve();
396
+ const selection = this.getSelection();
397
+ const range = this.createNextRange();
398
+ if (selection && range) {
399
+ selection.removeAllRanges();
400
+ selection.addRange(range);
401
+ }
402
+ };
403
+ }
404
+ /**
405
+ * Get current range instance.
406
+ *
407
+ * @returns {Nullable<Range>} - The range instance or null.
408
+ */
409
+ getCurrentRange() {
410
+ const selection = this.getSelection();
411
+ if (selection.rangeCount) {
412
+ return selection.getRangeAt(0);
413
+ }
414
+ }
415
+ /**
416
+ * We need to store the selection state if the selection is a ShadowSelection, because the range is out of date in `input` event.
417
+ *
418
+ * @param {VegaRangeLike} range - The range like object.
419
+ */
420
+ storeInputStaticRange(range) {
421
+ const selection = this.getSelection();
422
+ if (selection instanceof selectionController.ShadowSelection) {
423
+ this.selectionState = {
424
+ contentOffset: this.getContentOffsetByRange(range),
425
+ currentNodeOffset: 0,
426
+ };
427
+ }
428
+ }
429
+ /**
430
+ * Sets the next selection state with specified start and end nodes, offsets, push the update task to a queue.
431
+ *
432
+ * @param {Nullable<number>} [offset] - Set the range start offset to current position.
433
+ * @param {boolean} [immediatelyRun] - Should the task run immediately. default is false.
434
+ */
435
+ enqueueSelectionRangeFutureState(offset, immediatelyRun = false) {
436
+ if (offset || offset === 0) {
437
+ this.selectionState = {
438
+ contentOffset: offset,
439
+ currentNodeOffset: 0,
440
+ };
441
+ }
442
+ else {
443
+ const selection = this.getSelection();
444
+ if (selection && selection.rangeCount > 0) {
445
+ // If the selection is a ShadowSelection, we need to use the selectionState update in method `storeInputStaticRange`.
446
+ // Otherwise, we can get the content offset from the selection range.
447
+ if (!(selection instanceof selectionController.ShadowSelection)) {
448
+ const range = selection.getRangeAt(0);
449
+ this.selectionState = {
450
+ contentOffset: this.getContentOffsetByRange(range),
451
+ currentNodeOffset: range.startOffset,
452
+ };
453
+ }
454
+ }
455
+ }
456
+ super.enqueueTheTaskIntoQueue(immediatelyRun);
457
+ }
458
+ /**
459
+ * Component lifecycle
460
+ */
461
+ addSelectionChangeEventListener() {
462
+ document.addEventListener('selectionchange', this.handleSelectionWithDebounce);
463
+ }
464
+ /**
465
+ * Component lifecycle
466
+ */
467
+ removeSelectionChangeEventListener() {
468
+ document.removeEventListener('selectionchange', this.handleSelectionWithDebounce);
469
+ }
470
+ /**
471
+ * Create the code block shadowRoot new range instance from the next selection state.
472
+ *
473
+ * @returns {Nullable<Range>} - The new range instance.
474
+ */
475
+ createNextRange() {
476
+ if (this.selectionState) {
477
+ const codeContentContainerRef = this.contentRenderer.getCodeContentContainerRef();
478
+ const rangeStartNodeSelector = this.getCursorNodeSelectorAndUpdateOffset();
479
+ let startOffset = this.selectionState.currentNodeOffset;
480
+ const cursorSpan = codeContentContainerRef.querySelector(rangeStartNodeSelector);
481
+ if (cursorSpan) {
482
+ const range = new Range();
483
+ startOffset = Math.min(cursorSpan.firstChild.textContent.length, startOffset);
484
+ range.setStart(cursorSpan.firstChild, startOffset);
485
+ range.setEnd(cursorSpan.firstChild, startOffset);
486
+ this.selectionState = null;
487
+ return range;
488
+ }
489
+ }
490
+ }
491
+ /**
492
+ * Get the code block selected range
493
+ *
494
+ * @returns {Selection} A [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) object
495
+ */
496
+ getSelection() {
497
+ return selectionController.ShadowSelectionPolyfill.getSelection(this.host.shadowRoot);
498
+ }
499
+ /**
500
+ * Get the current input cursor offset of the code content, so we can get the next cursor node according the offset after re-render.
501
+ *
502
+ * @example
503
+ * Code content: const t = new Date();\nconsole.log(t);
504
+ * Render result: <span>const</span><span> t</span><span> = </span><span>new</span><span> Date();</span><span>\n</span><span>console.</span><span>log</span><span>(t)</span>
505
+ * Current range: {startContainer: [The last span], startOffset:2}
506
+ * Offset: 26
507
+ * @param {VegaRangeLike} range - The current selection range like object.
508
+ * @returns {number} - The index of the cursor position.
509
+ */
510
+ getContentOffsetByRange(range) {
511
+ const codeContentContainerRef = this.contentRenderer.getCodeContentContainerRef();
512
+ let { startContainer, startOffset } = range;
513
+ if (startContainer.nodeName === 'SPAN' && startContainer.childNodes.length > 1) {
514
+ startContainer = startContainer.childNodes[Math.max(0, startOffset - 1)];
515
+ startOffset = this.getTextContent(startContainer).length;
516
+ }
517
+ const spanNodes = Array.from(codeContentContainerRef.childNodes);
518
+ let offset = 0;
519
+ const startSpan = startContainer.nodeName === 'BR' || startContainer.nodeType === Node.TEXT_NODE
520
+ ? startContainer.parentElement
521
+ : startContainer;
522
+ for (let i = 0; i < spanNodes.length; i++) {
523
+ if (startContainer === codeContentContainerRef) {
524
+ if (i < startOffset) {
525
+ offset += this.getTextContent(spanNodes[i]).length;
526
+ }
527
+ }
528
+ else {
529
+ if (spanNodes[i] === startSpan) {
530
+ if (startSpan.childNodes.length === 1) {
531
+ offset += startOffset;
532
+ }
533
+ else {
534
+ for (let j = 0; j < startSpan.childNodes.length; j++) {
535
+ if (startSpan.childNodes[j] === startContainer) {
536
+ offset += startOffset;
537
+ break;
538
+ }
539
+ else {
540
+ offset += this.getTextContent(startSpan.childNodes[j]).length;
541
+ }
542
+ }
543
+ }
544
+ break;
545
+ }
546
+ else {
547
+ offset += this.getTextContent(spanNodes[i]).length;
548
+ }
549
+ }
550
+ }
551
+ return offset;
552
+ }
553
+ /**
554
+ * Get the range start container selector after the code content re-render and update the offset of current node.
555
+ *
556
+ * @returns {string} - The span which has attribute data-index=[index].
557
+ */
558
+ getCursorNodeSelectorAndUpdateOffset() {
559
+ const codeNodes = this.contentParseController.getCurrentCodeNodes();
560
+ const { contentOffset } = this.selectionState;
561
+ let nodeIndex = 0;
562
+ if (!this.value || !this.value.code || contentOffset >= this.value.code.length) {
563
+ this.selectionState.currentNodeOffset = codeNodes[codeNodes.length - 1].text.length;
564
+ nodeIndex = codeNodes.length - 1;
565
+ }
566
+ else {
567
+ let text = '';
568
+ for (let i = 0; i < codeNodes.length; i++) {
569
+ text += codeNodes[i].text;
570
+ if (text.length >= contentOffset) {
571
+ this.selectionState.currentNodeOffset = Math.max(0, codeNodes[i].text.length - (text.length - contentOffset));
572
+ nodeIndex = i;
573
+ break;
574
+ }
575
+ }
576
+ }
577
+ // The cursor position is incorrect in firefox when cursor node is line break node.
578
+ if (codeNodes[nodeIndex].text === '\n' && this.selectionState.currentNodeOffset > 0) {
579
+ nodeIndex++;
580
+ this.selectionState.currentNodeOffset = 0;
581
+ }
582
+ return `span[data-index="${nodeIndex}"]`;
583
+ }
584
+ /**
585
+ * Notify the code content selection change event.
586
+ */
587
+ handleSelectionChange() {
588
+ const selection = this.getSelection();
589
+ if (selection && selection.rangeCount > 0) {
590
+ changeManager.ChangeManager.notify(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalCodeBlockSelectionChange), { detail: true });
591
+ }
592
+ else {
593
+ changeManager.ChangeManager.notify(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalCodeBlockSelectionChange), { detail: false });
594
+ }
595
+ }
596
+ /**
597
+ * Get the node text content, the BR node will return `\n`;
598
+ *
599
+ * @param {Node} node - The node instance.
600
+ * @returns {string} - The node text content.
601
+ */
602
+ getTextContent(node) {
603
+ if (node.nodeType === Node.TEXT_NODE) {
604
+ return node.textContent;
605
+ }
606
+ else if (node.nodeName === 'BR') {
607
+ return '\n';
608
+ }
609
+ else {
610
+ return node.innerText;
611
+ }
612
+ }
613
+ }
614
+ // Must make sure the debounce time will not greater than the RTE selection range debounce time.
615
+ VegaCodeBlockSelectionController.SELECTION_CHANGE_DEBOUNCE_TIME = Math.min(selectionController.SelectionController.SELECTION_CHANGE_DEBOUNCE_TIME, 40);
616
+ __decorate$5([
617
+ globalSlimmerRegistry.MapToComponentField()
618
+ ], VegaCodeBlockSelectionController.prototype, "host", void 0);
619
+ __decorate$5([
620
+ globalSlimmerRegistry.MapToComponentField()
621
+ ], VegaCodeBlockSelectionController.prototype, "value", void 0);
622
+ __decorate$5([
623
+ globalSlimmerRegistry.MapToComponentField()
624
+ ], VegaCodeBlockSelectionController.prototype, "contentRenderer", void 0);
625
+ __decorate$5([
626
+ globalSlimmerRegistry.MapToComponentField()
627
+ ], VegaCodeBlockSelectionController.prototype, "contentParseController", void 0);
628
+ __decorate$5([
629
+ globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
630
+ ], VegaCodeBlockSelectionController.prototype, "addSelectionChangeEventListener", null);
631
+ __decorate$5([
632
+ globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
633
+ ], VegaCodeBlockSelectionController.prototype, "removeSelectionChangeEventListener", null);
634
+
635
+ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
636
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
637
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
638
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
639
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
640
+ };
641
+ /**
642
+ * The class used to control the code block modify content action.
643
+ */
644
+ class CodeBlockInputController extends globalSlimmerRegistry.VegaSlimmer {
645
+ constructor() {
646
+ super(...arguments);
647
+ this.insertCompositionTextEndFlag = true;
648
+ /**
649
+ * Stop the input event bubbles and update the code value.
650
+ *
651
+ * @param {InputEvent} e - The input event object.
652
+ */
653
+ this.handleInputEvent = (e) => {
654
+ this.stopEventPropagation(e);
655
+ this.updateCodeContent();
656
+ };
657
+ /**
658
+ * Prevent paste the file into code block. Prevent to delete the last space.
659
+ *
660
+ * @param {InputEvent} e - The input event object.
661
+ */
662
+ this.handleBeforeInput = (e) => {
663
+ e.stopPropagation();
664
+ const inputType = e.inputType;
665
+ if (inputType === 'insertFromPaste' &&
666
+ e.dataTransfer &&
667
+ e.dataTransfer.files &&
668
+ e.dataTransfer.files.length) {
669
+ e.preventDefault();
670
+ return;
671
+ }
672
+ else if (inputType === 'deleteContentBackward') {
673
+ if (!this.value || !this.value.code || this.value.code === ' ') {
674
+ e.preventDefault();
675
+ return;
676
+ }
677
+ // In low version firefox, the selected text could not delete when press delete key, so we delete it manually.
678
+ const range = this.selectionController.getCurrentRange();
679
+ if (range && !range.collapsed) {
680
+ const contentStartOffset = this.getContentStartOffset(range);
681
+ const newValue = this.deleteSelectedText(contentStartOffset, range.toString().length);
682
+ e.preventDefault();
683
+ this.valueController.updateValue(newValue, this.value.language);
684
+ this.selectionController.enqueueSelectionRangeFutureState(contentStartOffset);
685
+ return;
686
+ }
687
+ }
688
+ this.storeStaticRange(e);
689
+ };
690
+ /**
691
+ * An event handler function that is triggered when the composition of text input starts. In this case,
692
+ * it sets the `insertCompositionTextEndFlag` property of the `UserInputController` class to `false`.
693
+ *
694
+ * @param {CompositionEvent} e The composition event instance
695
+ */
696
+ this.handleCompositionStart = (e) => {
697
+ this.insertCompositionTextEndFlag = false;
698
+ this.stopEventPropagation(e);
699
+ };
700
+ /**
701
+ * An event handler function that is triggered when the composition of text input ends. In this case,
702
+ * it sets the `insertCompositionTextEndFlag` property of the `UserInputController` class to `true`.
703
+ *
704
+ * @param {CompositionEvent} e The composition event instance
705
+ */
706
+ this.handleCompositionEnd = (e) => {
707
+ this.insertCompositionTextEndFlag = true;
708
+ this.stopEventPropagation(e);
709
+ this.updateCodeContent();
710
+ };
711
+ }
712
+ /**
713
+ * Stop `beforeinput` and `input` event bubbles to parent element.
714
+ */
715
+ registerInputEvent() {
716
+ const codeContentContainerRef = this.contentRenderer.getCodeContentContainerRef();
717
+ if (codeContentContainerRef) {
718
+ codeContentContainerRef.addEventListener('compositionstart', this.handleCompositionStart);
719
+ codeContentContainerRef.addEventListener('compositionend', this.handleCompositionEnd);
720
+ codeContentContainerRef.addEventListener('beforeinput', this.handleBeforeInput);
721
+ codeContentContainerRef.addEventListener('input', this.handleInputEvent);
722
+ }
723
+ }
724
+ /**
725
+ * Remove the event listener.
726
+ */
727
+ unregisterEventListener() {
728
+ const codeContentContainerRef = this.contentRenderer.getCodeContentContainerRef();
729
+ if (codeContentContainerRef) {
730
+ codeContentContainerRef.removeEventListener('beforeinput', this.handleBeforeInput);
731
+ codeContentContainerRef.removeEventListener('input', this.handleInputEvent);
732
+ codeContentContainerRef.removeEventListener('compositionstart', this.handleCompositionStart);
733
+ codeContentContainerRef.removeEventListener('compositionend', this.handleCompositionEnd);
734
+ }
735
+ }
736
+ /**
737
+ * Stop the event bubbles.
738
+ *
739
+ * @param {Event} e - The event object.
740
+ */
741
+ stopEventPropagation(e) {
742
+ e.stopPropagation();
743
+ }
744
+ /**
745
+ * Delete the selected text manually.
746
+ *
747
+ * @param {number} contentStartOffset - The start index.
748
+ * @param {number} length - The selected text length.
749
+ * @returns {string} - The content after delete.
750
+ */
751
+ deleteSelectedText(contentStartOffset, length) {
752
+ let oldValue = this.value.code;
753
+ if (length >= oldValue.length) {
754
+ oldValue = '';
755
+ }
756
+ else {
757
+ oldValue = oldValue.slice(0, contentStartOffset) + oldValue.slice(contentStartOffset + length);
758
+ }
759
+ return oldValue;
760
+ }
761
+ /**
762
+ * Calculate caret position of the code content.
763
+ *
764
+ * @param {Range} param - The range instance.
765
+ * @returns {number} - The caret position.
766
+ */
767
+ getContentStartOffset({ startContainer, startOffset }) {
768
+ const startSpan = startContainer.nodeType === Node.TEXT_NODE
769
+ ? startContainer.parentElement
770
+ : startContainer;
771
+ const currentNodes = this.contentParseController.getCurrentCodeNodes();
772
+ let index = Number(startSpan.dataset.index);
773
+ if (startSpan.nodeName === 'CODE') {
774
+ index = startOffset;
775
+ startOffset = 0;
776
+ }
777
+ let beforeText = '';
778
+ for (let i = 0; i < index; i++) {
779
+ beforeText += currentNodes[i].text;
780
+ }
781
+ return beforeText.length + startOffset;
782
+ }
783
+ /**
784
+ * Store the static range of the input event if the `insertCompositionTextEndFlag` is true.
785
+ * The static range will be used to get the correct cursor position. In safari browser the range from the ShadowSelectionPolyfill is incorrect.
786
+ *
787
+ * @param {InputEvent} e - The input event object.
788
+ */
789
+ storeStaticRange(e) {
790
+ const range = this.selectionController.getCurrentRange();
791
+ if (this.insertCompositionTextEndFlag && range) {
792
+ const { startContainer, startOffset } = range;
793
+ const dataLength = this.getInsertDataLength(e);
794
+ this.selectionController.storeInputStaticRange({
795
+ startContainer: startContainer,
796
+ startOffset: Math.max(0, startOffset + dataLength),
797
+ });
798
+ }
799
+ }
800
+ //TODO: Refactor the update range logic to unified the flow.
801
+ /**
802
+ * Calculates the length of the inserted data based on the input event type.
803
+ *
804
+ * @param {InputEvent} e - The input event object.
805
+ * @returns {number} - The length of the inserted data.
806
+ */
807
+ getInsertDataLength(e) {
808
+ const { data, inputType } = e;
809
+ switch (inputType) {
810
+ case 'insertText':
811
+ return data.length; // For insert text, we return the length of the inserted text.
812
+ case 'insertParagraph':
813
+ case 'insertLineBreak':
814
+ return 1; // For paragraph or line break, we consider it as a single character.
815
+ case 'deleteContentBackward':
816
+ return -1; // For delete backward, we return -1.
817
+ default:
818
+ return 0; // For other input types, we return 0.
819
+ }
820
+ }
821
+ /**
822
+ * Update the code content after user modify action.
823
+ */
824
+ updateCodeContent() {
825
+ var _a;
826
+ if (this.insertCompositionTextEndFlag) {
827
+ this.selectionController.enqueueSelectionRangeFutureState();
828
+ const codeContentContainerRef = this.contentRenderer.getCodeContentContainerRef();
829
+ // Remove the unnecessary line break tag before get the code content.
830
+ this.removeUnnecessaryLineBreak(codeContentContainerRef.querySelector('br'));
831
+ let newContent = codeContentContainerRef.innerText;
832
+ if (newContent.endsWith('\n\n')) {
833
+ newContent = newContent.slice(0, newContent.length - '\n'.length) + ' ';
834
+ }
835
+ if (this.isInsertSingleLineBreakAtEnd(newContent)) {
836
+ newContent = newContent + ' ';
837
+ }
838
+ if (newContent.endsWith('\n')) {
839
+ newContent = newContent.slice(0, newContent.length - '\n'.length);
840
+ }
841
+ this.valueController.updateValue(newContent, (_a = this.value) === null || _a === void 0 ? void 0 : _a.language);
842
+ }
843
+ }
844
+ /**
845
+ * If remove all content of span element, browser will create a new <br/> element, we need remove the unnecessary element.
846
+ * In firefox, the new <br/> element will append in span element when insert line break at end of content, and the current element should not remove.
847
+ *
848
+ * @param {Nullable<HTMLElement>} br - The new create line break element.
849
+ */
850
+ removeUnnecessaryLineBreak(br) {
851
+ if (br && br.parentElement && br.parentElement.tagName !== 'SPAN') {
852
+ br.remove();
853
+ }
854
+ }
855
+ /**
856
+ * In some low versions of firefox, there are only one line break tag when insert line break at end of content. We need check this and add white space to make the line break work properly.
857
+ *
858
+ * @param {string} newValue - The new code content.
859
+ * @returns {boolean} - Boolean result.
860
+ */
861
+ isInsertSingleLineBreakAtEnd(newValue) {
862
+ if ((!this.value && newValue === ' \n') || (this.value && this.value.code + '\n' === newValue)) {
863
+ return true;
864
+ }
865
+ return false;
866
+ }
867
+ }
868
+ __decorate$4([
869
+ globalSlimmerRegistry.MapToComponentField()
870
+ ], CodeBlockInputController.prototype, "selectionController", void 0);
871
+ __decorate$4([
872
+ globalSlimmerRegistry.MapToComponentField()
873
+ ], CodeBlockInputController.prototype, "contentRenderer", void 0);
874
+ __decorate$4([
875
+ globalSlimmerRegistry.MapToComponentField()
876
+ ], CodeBlockInputController.prototype, "valueController", void 0);
877
+ __decorate$4([
878
+ globalSlimmerRegistry.MapToComponentField()
879
+ ], CodeBlockInputController.prototype, "contentParseController", void 0);
880
+ __decorate$4([
881
+ globalSlimmerRegistry.MapToComponentField()
882
+ ], CodeBlockInputController.prototype, "value", void 0);
883
+ __decorate$4([
884
+ globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
885
+ ], CodeBlockInputController.prototype, "registerInputEvent", null);
886
+ __decorate$4([
887
+ globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
888
+ ], CodeBlockInputController.prototype, "unregisterEventListener", null);
889
+
890
+ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
891
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
892
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
893
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
894
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
895
+ };
896
+ /**
897
+ * Control the component focus state.
898
+ */
899
+ class VegaCodeBlockFocusController extends globalSlimmerRegistry.VegaSlimmer {
900
+ /**
901
+ * Focus the code block and update the selection range offset to end.
902
+ */
903
+ focusAndUpdateSelection() {
904
+ if (!this.disabled && !this.readOnly) {
905
+ const codeContentContainerRef = this.contentRenderer.getCodeContentContainerRef();
906
+ if (codeContentContainerRef) {
907
+ codeContentContainerRef.focus();
908
+ const offset = this.value && this.value.code && this.value.code !== ' ' ? this.value.code.length : 0;
909
+ this.selectionController.enqueueSelectionRangeFutureState(offset, true);
910
+ }
911
+ }
912
+ }
913
+ /**
914
+ * Remove the focus class when component disabled or readonly.
915
+ */
916
+ removeFocusAfterDisabled() {
917
+ if (this.disabled || this.readOnly) {
918
+ this.host.classList.remove('focus');
919
+ }
920
+ }
921
+ }
922
+ __decorate$3([
923
+ globalSlimmerRegistry.MapToComponentField()
924
+ ], VegaCodeBlockFocusController.prototype, "host", void 0);
925
+ __decorate$3([
926
+ globalSlimmerRegistry.MapToComponentField()
927
+ ], VegaCodeBlockFocusController.prototype, "value", void 0);
928
+ __decorate$3([
929
+ globalSlimmerRegistry.MapToComponentField()
930
+ ], VegaCodeBlockFocusController.prototype, "readOnly", void 0);
931
+ __decorate$3([
932
+ globalSlimmerRegistry.MapToComponentField()
933
+ ], VegaCodeBlockFocusController.prototype, "disabled", void 0);
934
+ __decorate$3([
935
+ globalSlimmerRegistry.MapToComponentField()
936
+ ], VegaCodeBlockFocusController.prototype, "contentRenderer", void 0);
937
+ __decorate$3([
938
+ globalSlimmerRegistry.MapToComponentField()
939
+ ], VegaCodeBlockFocusController.prototype, "selectionController", void 0);
940
+ __decorate$3([
941
+ globalSlimmerRegistry.MapToComponentMethod('doFocus')
942
+ ], VegaCodeBlockFocusController.prototype, "focusAndUpdateSelection", null);
943
+ __decorate$3([
944
+ globalSlimmerRegistry.MapToComponentMethod('watchEditableChange')
945
+ ], VegaCodeBlockFocusController.prototype, "removeFocusAfterDisabled", null);
946
+
947
+ const copy = {
948
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><g clip-path="url(#clip0_70002_574)"><path fill="currentColor" d="M11.7794 1.65539L10.3439 0.219844C10.2044 0.0790078 10.0122 0 9.81303 0H5.97865C5.15014 0 4.47865 0.671719 4.47865 1.5L4.47911 7.5C4.49975 8.32969 5.1724 9 5.99975 9H10.4997C11.3247 9 11.9997 8.325 11.9997 7.5V2.18555C11.9997 1.9868 11.9201 1.79602 11.7794 1.65539ZM10.8747 7.5C10.8747 7.70709 10.7068 7.875 10.4997 7.875H5.97865C5.77151 7.875 5.60365 7.70709 5.60365 7.5V1.50305C5.60365 1.29595 5.77156 1.12805 5.97865 1.12805H8.97865L8.99975 2.25C8.99975 2.66414 9.33561 3 9.74975 3H10.8537V7.5H10.8747ZM6.37475 10.5C6.37475 10.7071 6.20684 10.875 5.99975 10.875H1.47865C1.27151 10.875 1.10365 10.7071 1.10365 10.5L1.12428 4.50234C1.12428 4.29525 1.29218 4.12734 1.49928 4.12734H3.74975V3H1.49951C0.670996 3 -0.000488281 3.67148 -0.000488281 4.5L-0.000258594 10.5C-0.000207031 11.3273 0.671465 12 1.49975 12H5.99975C6.82475 12 7.49975 11.325 7.49975 10.5V9.75H6.39584L6.37475 10.5Z"/></g><defs><clipPath id="clip0_70002_574"><rect width="12" height="12" fill="currentColor"/></clipPath></defs></svg>`,
949
+ };
950
+
951
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
952
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
953
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
954
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
955
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
956
+ };
957
+ class VegaCodeBlockCopyButtonRenderer extends globalSlimmerRegistry.VegaSlimmer {
958
+ constructor() {
959
+ super(...arguments);
960
+ /**
961
+ * Copy the code.
962
+ *
963
+ * @param {HTMLVegaButtonCircleElement} node - The copy button.
964
+ */
965
+ this.handleCopyClick = (node) => {
966
+ domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, domNodeSubjectFactory.VegaClick, async () => {
967
+ var _a;
968
+ const content = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.code) || '';
969
+ if (content && globalThis.navigator && globalThis.navigator.clipboard) {
970
+ clearTimeout(this.updateLabelTimer);
971
+ await globalThis.navigator.clipboard.writeText(content);
972
+ const oldTooltip = node.label;
973
+ node.label = this.translationSlimmer.t('Copied');
974
+ this.updateLabelTimer = setTimeout(() => {
975
+ if (node) {
976
+ node.label = oldTooltip;
977
+ }
978
+ }, VegaCodeBlockCopyButtonRenderer.RESET_TOOLTIP_TIME);
979
+ }
980
+ });
981
+ };
982
+ }
983
+ /**
984
+ * Render a copy button.
985
+ *
986
+ * @returns {Nullable<HTMLElement>} The button element.
987
+ */
988
+ render() {
989
+ if (this.showCopyButton && this.readOnly) {
990
+ return (index.h("vega-button-circle", { key: "copy-button", label: this.translationSlimmer.t('Copy Code'), class: "copy-code-button", icon: internalIconManager.VegaInternalIconManager.getIconKey('copy'), iconColor: "text-secondary", variant: "icon-only", size: "extra-small", ref: this.handleCopyClick }));
991
+ }
992
+ }
993
+ }
994
+ (() => {
995
+ internalIconManager.VegaInternalIconManager.register({
996
+ copy: copy,
997
+ });
998
+ })();
999
+ VegaCodeBlockCopyButtonRenderer.RESET_TOOLTIP_TIME = 1000;
1000
+ __decorate$2([
1001
+ globalSlimmerRegistry.MapToComponentField()
1002
+ ], VegaCodeBlockCopyButtonRenderer.prototype, "value", void 0);
1003
+ __decorate$2([
1004
+ globalSlimmerRegistry.MapToComponentField()
1005
+ ], VegaCodeBlockCopyButtonRenderer.prototype, "readOnly", void 0);
1006
+ __decorate$2([
1007
+ globalSlimmerRegistry.MapToComponentField()
1008
+ ], VegaCodeBlockCopyButtonRenderer.prototype, "showCopyButton", void 0);
1009
+ __decorate$2([
1010
+ globalSlimmerRegistry.MapToComponentField()
1011
+ ], VegaCodeBlockCopyButtonRenderer.prototype, "translationSlimmer", void 0);
1012
+
1013
+ var prism = _commonjsHelpers.createCommonjsModule(function (module) {
1014
+ /* **********************************************
1015
+ Begin prism-core.js
1016
+ ********************************************** */
1017
+
1018
+ /// <reference lib="WebWorker"/>
1019
+
1020
+ var _self = (typeof window !== 'undefined')
1021
+ ? window // if in browser
1022
+ : (
1023
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
1024
+ ? self // if in worker
1025
+ : {} // if in node js
1026
+ );
1027
+
1028
+ /**
1029
+ * Prism: Lightweight, robust, elegant syntax highlighting
1030
+ *
1031
+ * @license MIT <https://opensource.org/licenses/MIT>
1032
+ * @author Lea Verou <https://lea.verou.me>
1033
+ * @namespace
1034
+ * @public
1035
+ */
1036
+ var Prism = (function (_self) {
1037
+
1038
+ // Private helper vars
1039
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
1040
+ var uniqueId = 0;
1041
+
1042
+ // The grammar object for plaintext
1043
+ var plainTextGrammar = {};
1044
+
1045
+
1046
+ var _ = {
1047
+ /**
1048
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
1049
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
1050
+ * additional languages or plugins yourself.
1051
+ *
1052
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
1053
+ *
1054
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
1055
+ * empty Prism object into the global scope before loading the Prism script like this:
1056
+ *
1057
+ * ```js
1058
+ * window.Prism = window.Prism || {};
1059
+ * Prism.manual = true;
1060
+ * // add a new <script> to load Prism's script
1061
+ * ```
1062
+ *
1063
+ * @default false
1064
+ * @type {boolean}
1065
+ * @memberof Prism
1066
+ * @public
1067
+ */
1068
+ manual: _self.Prism && _self.Prism.manual,
1069
+ /**
1070
+ * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
1071
+ * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
1072
+ * own worker, you don't want it to do this.
1073
+ *
1074
+ * By setting this value to `true`, Prism will not add its own listeners to the worker.
1075
+ *
1076
+ * You obviously have to change this value before Prism executes. To do this, you can add an
1077
+ * empty Prism object into the global scope before loading the Prism script like this:
1078
+ *
1079
+ * ```js
1080
+ * window.Prism = window.Prism || {};
1081
+ * Prism.disableWorkerMessageHandler = true;
1082
+ * // Load Prism's script
1083
+ * ```
1084
+ *
1085
+ * @default false
1086
+ * @type {boolean}
1087
+ * @memberof Prism
1088
+ * @public
1089
+ */
1090
+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
1091
+
1092
+ /**
1093
+ * A namespace for utility methods.
1094
+ *
1095
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
1096
+ * change or disappear at any time.
1097
+ *
1098
+ * @namespace
1099
+ * @memberof Prism
1100
+ */
1101
+ util: {
1102
+ encode: function encode(tokens) {
1103
+ if (tokens instanceof Token) {
1104
+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
1105
+ } else if (Array.isArray(tokens)) {
1106
+ return tokens.map(encode);
1107
+ } else {
1108
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
1109
+ }
1110
+ },
1111
+
1112
+ /**
1113
+ * Returns the name of the type of the given value.
1114
+ *
1115
+ * @param {any} o
1116
+ * @returns {string}
1117
+ * @example
1118
+ * type(null) === 'Null'
1119
+ * type(undefined) === 'Undefined'
1120
+ * type(123) === 'Number'
1121
+ * type('foo') === 'String'
1122
+ * type(true) === 'Boolean'
1123
+ * type([1, 2]) === 'Array'
1124
+ * type({}) === 'Object'
1125
+ * type(String) === 'Function'
1126
+ * type(/abc+/) === 'RegExp'
1127
+ */
1128
+ type: function (o) {
1129
+ return Object.prototype.toString.call(o).slice(8, -1);
1130
+ },
1131
+
1132
+ /**
1133
+ * Returns a unique number for the given object. Later calls will still return the same number.
1134
+ *
1135
+ * @param {Object} obj
1136
+ * @returns {number}
1137
+ */
1138
+ objId: function (obj) {
1139
+ if (!obj['__id']) {
1140
+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
1141
+ }
1142
+ return obj['__id'];
1143
+ },
1144
+
1145
+ /**
1146
+ * Creates a deep clone of the given object.
1147
+ *
1148
+ * The main intended use of this function is to clone language definitions.
1149
+ *
1150
+ * @param {T} o
1151
+ * @param {Record<number, any>} [visited]
1152
+ * @returns {T}
1153
+ * @template T
1154
+ */
1155
+ clone: function deepClone(o, visited) {
1156
+ visited = visited || {};
1157
+
1158
+ var clone; var id;
1159
+ switch (_.util.type(o)) {
1160
+ case 'Object':
1161
+ id = _.util.objId(o);
1162
+ if (visited[id]) {
1163
+ return visited[id];
1164
+ }
1165
+ clone = /** @type {Record<string, any>} */ ({});
1166
+ visited[id] = clone;
1167
+
1168
+ for (var key in o) {
1169
+ if (o.hasOwnProperty(key)) {
1170
+ clone[key] = deepClone(o[key], visited);
1171
+ }
1172
+ }
1173
+
1174
+ return /** @type {any} */ (clone);
1175
+
1176
+ case 'Array':
1177
+ id = _.util.objId(o);
1178
+ if (visited[id]) {
1179
+ return visited[id];
1180
+ }
1181
+ clone = [];
1182
+ visited[id] = clone;
1183
+
1184
+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
1185
+ clone[i] = deepClone(v, visited);
1186
+ });
1187
+
1188
+ return /** @type {any} */ (clone);
1189
+
1190
+ default:
1191
+ return o;
1192
+ }
1193
+ },
1194
+
1195
+ /**
1196
+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
1197
+ *
1198
+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
1199
+ *
1200
+ * @param {Element} element
1201
+ * @returns {string}
1202
+ */
1203
+ getLanguage: function (element) {
1204
+ while (element) {
1205
+ var m = lang.exec(element.className);
1206
+ if (m) {
1207
+ return m[1].toLowerCase();
1208
+ }
1209
+ element = element.parentElement;
1210
+ }
1211
+ return 'none';
1212
+ },
1213
+
1214
+ /**
1215
+ * Sets the Prism `language-xxxx` class of the given element.
1216
+ *
1217
+ * @param {Element} element
1218
+ * @param {string} language
1219
+ * @returns {void}
1220
+ */
1221
+ setLanguage: function (element, language) {
1222
+ // remove all `language-xxxx` classes
1223
+ // (this might leave behind a leading space)
1224
+ element.className = element.className.replace(RegExp(lang, 'gi'), '');
1225
+
1226
+ // add the new `language-xxxx` class
1227
+ // (using `classList` will automatically clean up spaces for us)
1228
+ element.classList.add('language-' + language);
1229
+ },
1230
+
1231
+ /**
1232
+ * Returns the script element that is currently executing.
1233
+ *
1234
+ * This does __not__ work for line script element.
1235
+ *
1236
+ * @returns {HTMLScriptElement | null}
1237
+ */
1238
+ currentScript: function () {
1239
+ if (typeof document === 'undefined') {
1240
+ return null;
1241
+ }
1242
+ if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
1243
+ return /** @type {any} */ (document.currentScript);
1244
+ }
1245
+
1246
+ // IE11 workaround
1247
+ // we'll get the src of the current script by parsing IE11's error stack trace
1248
+ // this will not work for inline scripts
1249
+
1250
+ try {
1251
+ throw new Error();
1252
+ } catch (err) {
1253
+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
1254
+ // A stack will look like this:
1255
+ //
1256
+ // Error
1257
+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
1258
+ // at Global code (http://localhost/components/prism-core.js:606:1)
1259
+
1260
+ var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
1261
+ if (src) {
1262
+ var scripts = document.getElementsByTagName('script');
1263
+ for (var i in scripts) {
1264
+ if (scripts[i].src == src) {
1265
+ return scripts[i];
1266
+ }
1267
+ }
1268
+ }
1269
+ return null;
1270
+ }
1271
+ },
1272
+
1273
+ /**
1274
+ * Returns whether a given class is active for `element`.
1275
+ *
1276
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
1277
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
1278
+ * given class is just the given class with a `no-` prefix.
1279
+ *
1280
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
1281
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
1282
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
1283
+ *
1284
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
1285
+ * version of it, the class is considered active.
1286
+ *
1287
+ * @param {Element} element
1288
+ * @param {string} className
1289
+ * @param {boolean} [defaultActivation=false]
1290
+ * @returns {boolean}
1291
+ */
1292
+ isActive: function (element, className, defaultActivation) {
1293
+ var no = 'no-' + className;
1294
+
1295
+ while (element) {
1296
+ var classList = element.classList;
1297
+ if (classList.contains(className)) {
1298
+ return true;
1299
+ }
1300
+ if (classList.contains(no)) {
1301
+ return false;
1302
+ }
1303
+ element = element.parentElement;
1304
+ }
1305
+ return !!defaultActivation;
1306
+ }
1307
+ },
1308
+
1309
+ /**
1310
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
1311
+ *
1312
+ * @namespace
1313
+ * @memberof Prism
1314
+ * @public
1315
+ */
1316
+ languages: {
1317
+ /**
1318
+ * The grammar for plain, unformatted text.
1319
+ */
1320
+ plain: plainTextGrammar,
1321
+ plaintext: plainTextGrammar,
1322
+ text: plainTextGrammar,
1323
+ txt: plainTextGrammar,
1324
+
1325
+ /**
1326
+ * Creates a deep copy of the language with the given id and appends the given tokens.
1327
+ *
1328
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
1329
+ * will be overwritten at its original position.
1330
+ *
1331
+ * ## Best practices
1332
+ *
1333
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
1334
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
1335
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
1336
+ *
1337
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
1338
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
1339
+ *
1340
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
1341
+ * @param {Grammar} redef The new tokens to append.
1342
+ * @returns {Grammar} The new language created.
1343
+ * @public
1344
+ * @example
1345
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
1346
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
1347
+ * // at its original position
1348
+ * 'comment': { ... },
1349
+ * // CSS doesn't have a 'color' token, so this token will be appended
1350
+ * 'color': /\b(?:red|green|blue)\b/
1351
+ * });
1352
+ */
1353
+ extend: function (id, redef) {
1354
+ var lang = _.util.clone(_.languages[id]);
1355
+
1356
+ for (var key in redef) {
1357
+ lang[key] = redef[key];
1358
+ }
1359
+
1360
+ return lang;
1361
+ },
1362
+
1363
+ /**
1364
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
1365
+ *
1366
+ * ## Usage
1367
+ *
1368
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
1369
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
1370
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
1371
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
1372
+ * this:
1373
+ *
1374
+ * ```js
1375
+ * Prism.languages.markup.style = {
1376
+ * // token
1377
+ * };
1378
+ * ```
1379
+ *
1380
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
1381
+ * before existing tokens. For the CSS example above, you would use it like this:
1382
+ *
1383
+ * ```js
1384
+ * Prism.languages.insertBefore('markup', 'cdata', {
1385
+ * 'style': {
1386
+ * // token
1387
+ * }
1388
+ * });
1389
+ * ```
1390
+ *
1391
+ * ## Special cases
1392
+ *
1393
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
1394
+ * will be ignored.
1395
+ *
1396
+ * This behavior can be used to insert tokens after `before`:
1397
+ *
1398
+ * ```js
1399
+ * Prism.languages.insertBefore('markup', 'comment', {
1400
+ * 'comment': Prism.languages.markup.comment,
1401
+ * // tokens after 'comment'
1402
+ * });
1403
+ * ```
1404
+ *
1405
+ * ## Limitations
1406
+ *
1407
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
1408
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
1409
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
1410
+ * deleting properties which is necessary to insert at arbitrary positions.
1411
+ *
1412
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
1413
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
1414
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
1415
+ *
1416
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
1417
+ * you hold the target object in a variable, then the value of the variable will not change.
1418
+ *
1419
+ * ```js
1420
+ * var oldMarkup = Prism.languages.markup;
1421
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
1422
+ *
1423
+ * assert(oldMarkup !== Prism.languages.markup);
1424
+ * assert(newMarkup === Prism.languages.markup);
1425
+ * ```
1426
+ *
1427
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
1428
+ * object to be modified.
1429
+ * @param {string} before The key to insert before.
1430
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
1431
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
1432
+ * object to be modified.
1433
+ *
1434
+ * Defaults to `Prism.languages`.
1435
+ * @returns {Grammar} The new grammar object.
1436
+ * @public
1437
+ */
1438
+ insertBefore: function (inside, before, insert, root) {
1439
+ root = root || /** @type {any} */ (_.languages);
1440
+ var grammar = root[inside];
1441
+ /** @type {Grammar} */
1442
+ var ret = {};
1443
+
1444
+ for (var token in grammar) {
1445
+ if (grammar.hasOwnProperty(token)) {
1446
+
1447
+ if (token == before) {
1448
+ for (var newToken in insert) {
1449
+ if (insert.hasOwnProperty(newToken)) {
1450
+ ret[newToken] = insert[newToken];
1451
+ }
1452
+ }
1453
+ }
1454
+
1455
+ // Do not insert token which also occur in insert. See #1525
1456
+ if (!insert.hasOwnProperty(token)) {
1457
+ ret[token] = grammar[token];
1458
+ }
1459
+ }
1460
+ }
1461
+
1462
+ var old = root[inside];
1463
+ root[inside] = ret;
1464
+
1465
+ // Update references in other language definitions
1466
+ _.languages.DFS(_.languages, function (key, value) {
1467
+ if (value === old && key != inside) {
1468
+ this[key] = ret;
1469
+ }
1470
+ });
1471
+
1472
+ return ret;
1473
+ },
1474
+
1475
+ // Traverse a language definition with Depth First Search
1476
+ DFS: function DFS(o, callback, type, visited) {
1477
+ visited = visited || {};
1478
+
1479
+ var objId = _.util.objId;
1480
+
1481
+ for (var i in o) {
1482
+ if (o.hasOwnProperty(i)) {
1483
+ callback.call(o, i, o[i], type || i);
1484
+
1485
+ var property = o[i];
1486
+ var propertyType = _.util.type(property);
1487
+
1488
+ if (propertyType === 'Object' && !visited[objId(property)]) {
1489
+ visited[objId(property)] = true;
1490
+ DFS(property, callback, null, visited);
1491
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
1492
+ visited[objId(property)] = true;
1493
+ DFS(property, callback, i, visited);
1494
+ }
1495
+ }
1496
+ }
1497
+ }
1498
+ },
1499
+
1500
+ plugins: {},
1501
+
1502
+ /**
1503
+ * This is the most high-level function in Prism’s API.
1504
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
1505
+ * each one of them.
1506
+ *
1507
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
1508
+ *
1509
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
1510
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
1511
+ * @memberof Prism
1512
+ * @public
1513
+ */
1514
+ highlightAll: function (async, callback) {
1515
+ _.highlightAllUnder(document, async, callback);
1516
+ },
1517
+
1518
+ /**
1519
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
1520
+ * {@link Prism.highlightElement} on each one of them.
1521
+ *
1522
+ * The following hooks will be run:
1523
+ * 1. `before-highlightall`
1524
+ * 2. `before-all-elements-highlight`
1525
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
1526
+ *
1527
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
1528
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
1529
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
1530
+ * @memberof Prism
1531
+ * @public
1532
+ */
1533
+ highlightAllUnder: function (container, async, callback) {
1534
+ var env = {
1535
+ callback: callback,
1536
+ container: container,
1537
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
1538
+ };
1539
+
1540
+ _.hooks.run('before-highlightall', env);
1541
+
1542
+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
1543
+
1544
+ _.hooks.run('before-all-elements-highlight', env);
1545
+
1546
+ for (var i = 0, element; (element = env.elements[i++]);) {
1547
+ _.highlightElement(element, async === true, env.callback);
1548
+ }
1549
+ },
1550
+
1551
+ /**
1552
+ * Highlights the code inside a single element.
1553
+ *
1554
+ * The following hooks will be run:
1555
+ * 1. `before-sanity-check`
1556
+ * 2. `before-highlight`
1557
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
1558
+ * 4. `before-insert`
1559
+ * 5. `after-highlight`
1560
+ * 6. `complete`
1561
+ *
1562
+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
1563
+ * the element's language.
1564
+ *
1565
+ * @param {Element} element The element containing the code.
1566
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
1567
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
1568
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
1569
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
1570
+ *
1571
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
1572
+ * asynchronous highlighting to work. You can build your own bundle on the
1573
+ * [Download page](https://prismjs.com/download.html).
1574
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
1575
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
1576
+ * @memberof Prism
1577
+ * @public
1578
+ */
1579
+ highlightElement: function (element, async, callback) {
1580
+ // Find language
1581
+ var language = _.util.getLanguage(element);
1582
+ var grammar = _.languages[language];
1583
+
1584
+ // Set language on the element, if not present
1585
+ _.util.setLanguage(element, language);
1586
+
1587
+ // Set language on the parent, for styling
1588
+ var parent = element.parentElement;
1589
+ if (parent && parent.nodeName.toLowerCase() === 'pre') {
1590
+ _.util.setLanguage(parent, language);
1591
+ }
1592
+
1593
+ var code = element.textContent;
1594
+
1595
+ var env = {
1596
+ element: element,
1597
+ language: language,
1598
+ grammar: grammar,
1599
+ code: code
1600
+ };
1601
+
1602
+ function insertHighlightedCode(highlightedCode) {
1603
+ env.highlightedCode = highlightedCode;
1604
+
1605
+ _.hooks.run('before-insert', env);
1606
+
1607
+ env.element.innerHTML = env.highlightedCode;
1608
+
1609
+ _.hooks.run('after-highlight', env);
1610
+ _.hooks.run('complete', env);
1611
+ callback && callback.call(env.element);
1612
+ }
1613
+
1614
+ _.hooks.run('before-sanity-check', env);
1615
+
1616
+ // plugins may change/add the parent/element
1617
+ parent = env.element.parentElement;
1618
+ if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
1619
+ parent.setAttribute('tabindex', '0');
1620
+ }
1621
+
1622
+ if (!env.code) {
1623
+ _.hooks.run('complete', env);
1624
+ callback && callback.call(env.element);
1625
+ return;
1626
+ }
1627
+
1628
+ _.hooks.run('before-highlight', env);
1629
+
1630
+ if (!env.grammar) {
1631
+ insertHighlightedCode(_.util.encode(env.code));
1632
+ return;
1633
+ }
1634
+
1635
+ if (async && _self.Worker) {
1636
+ var worker = new Worker(_.filename);
1637
+
1638
+ worker.onmessage = function (evt) {
1639
+ insertHighlightedCode(evt.data);
1640
+ };
1641
+
1642
+ worker.postMessage(JSON.stringify({
1643
+ language: env.language,
1644
+ code: env.code,
1645
+ immediateClose: true
1646
+ }));
1647
+ } else {
1648
+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
1649
+ }
1650
+ },
1651
+
1652
+ /**
1653
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
1654
+ * and the language definitions to use, and returns a string with the HTML produced.
1655
+ *
1656
+ * The following hooks will be run:
1657
+ * 1. `before-tokenize`
1658
+ * 2. `after-tokenize`
1659
+ * 3. `wrap`: On each {@link Token}.
1660
+ *
1661
+ * @param {string} text A string with the code to be highlighted.
1662
+ * @param {Grammar} grammar An object containing the tokens to use.
1663
+ *
1664
+ * Usually a language definition like `Prism.languages.markup`.
1665
+ * @param {string} language The name of the language definition passed to `grammar`.
1666
+ * @returns {string} The highlighted HTML.
1667
+ * @memberof Prism
1668
+ * @public
1669
+ * @example
1670
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
1671
+ */
1672
+ highlight: function (text, grammar, language) {
1673
+ var env = {
1674
+ code: text,
1675
+ grammar: grammar,
1676
+ language: language
1677
+ };
1678
+ _.hooks.run('before-tokenize', env);
1679
+ if (!env.grammar) {
1680
+ throw new Error('The language "' + env.language + '" has no grammar.');
1681
+ }
1682
+ env.tokens = _.tokenize(env.code, env.grammar);
1683
+ _.hooks.run('after-tokenize', env);
1684
+ return Token.stringify(_.util.encode(env.tokens), env.language);
1685
+ },
1686
+
1687
+ /**
1688
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
1689
+ * and the language definitions to use, and returns an array with the tokenized code.
1690
+ *
1691
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
1692
+ *
1693
+ * This method could be useful in other contexts as well, as a very crude parser.
1694
+ *
1695
+ * @param {string} text A string with the code to be highlighted.
1696
+ * @param {Grammar} grammar An object containing the tokens to use.
1697
+ *
1698
+ * Usually a language definition like `Prism.languages.markup`.
1699
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
1700
+ * @memberof Prism
1701
+ * @public
1702
+ * @example
1703
+ * let code = `var foo = 0;`;
1704
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
1705
+ * tokens.forEach(token => {
1706
+ * if (token instanceof Prism.Token && token.type === 'number') {
1707
+ * console.log(`Found numeric literal: ${token.content}`);
1708
+ * }
1709
+ * });
1710
+ */
1711
+ tokenize: function (text, grammar) {
1712
+ var rest = grammar.rest;
1713
+ if (rest) {
1714
+ for (var token in rest) {
1715
+ grammar[token] = rest[token];
1716
+ }
1717
+
1718
+ delete grammar.rest;
1719
+ }
1720
+
1721
+ var tokenList = new LinkedList();
1722
+ addAfter(tokenList, tokenList.head, text);
1723
+
1724
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
1725
+
1726
+ return toArray(tokenList);
1727
+ },
1728
+
1729
+ /**
1730
+ * @namespace
1731
+ * @memberof Prism
1732
+ * @public
1733
+ */
1734
+ hooks: {
1735
+ all: {},
1736
+
1737
+ /**
1738
+ * Adds the given callback to the list of callbacks for the given hook.
1739
+ *
1740
+ * The callback will be invoked when the hook it is registered for is run.
1741
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
1742
+ *
1743
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
1744
+ *
1745
+ * @param {string} name The name of the hook.
1746
+ * @param {HookCallback} callback The callback function which is given environment variables.
1747
+ * @public
1748
+ */
1749
+ add: function (name, callback) {
1750
+ var hooks = _.hooks.all;
1751
+
1752
+ hooks[name] = hooks[name] || [];
1753
+
1754
+ hooks[name].push(callback);
1755
+ },
1756
+
1757
+ /**
1758
+ * Runs a hook invoking all registered callbacks with the given environment variables.
1759
+ *
1760
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
1761
+ *
1762
+ * @param {string} name The name of the hook.
1763
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
1764
+ * @public
1765
+ */
1766
+ run: function (name, env) {
1767
+ var callbacks = _.hooks.all[name];
1768
+
1769
+ if (!callbacks || !callbacks.length) {
1770
+ return;
1771
+ }
1772
+
1773
+ for (var i = 0, callback; (callback = callbacks[i++]);) {
1774
+ callback(env);
1775
+ }
1776
+ }
1777
+ },
1778
+
1779
+ Token: Token
1780
+ };
1781
+ _self.Prism = _;
1782
+
1783
+
1784
+ // Typescript note:
1785
+ // The following can be used to import the Token type in JSDoc:
1786
+ //
1787
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
1788
+
1789
+ /**
1790
+ * Creates a new token.
1791
+ *
1792
+ * @param {string} type See {@link Token#type type}
1793
+ * @param {string | TokenStream} content See {@link Token#content content}
1794
+ * @param {string|string[]} [alias] The alias(es) of the token.
1795
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
1796
+ * @class
1797
+ * @global
1798
+ * @public
1799
+ */
1800
+ function Token(type, content, alias, matchedStr) {
1801
+ /**
1802
+ * The type of the token.
1803
+ *
1804
+ * This is usually the key of a pattern in a {@link Grammar}.
1805
+ *
1806
+ * @type {string}
1807
+ * @see GrammarToken
1808
+ * @public
1809
+ */
1810
+ this.type = type;
1811
+ /**
1812
+ * The strings or tokens contained by this token.
1813
+ *
1814
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
1815
+ *
1816
+ * @type {string | TokenStream}
1817
+ * @public
1818
+ */
1819
+ this.content = content;
1820
+ /**
1821
+ * The alias(es) of the token.
1822
+ *
1823
+ * @type {string|string[]}
1824
+ * @see GrammarToken
1825
+ * @public
1826
+ */
1827
+ this.alias = alias;
1828
+ // Copy of the full string this token was created from
1829
+ this.length = (matchedStr || '').length | 0;
1830
+ }
1831
+
1832
+ /**
1833
+ * A token stream is an array of strings and {@link Token Token} objects.
1834
+ *
1835
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
1836
+ * them.
1837
+ *
1838
+ * 1. No adjacent strings.
1839
+ * 2. No empty strings.
1840
+ *
1841
+ * The only exception here is the token stream that only contains the empty string and nothing else.
1842
+ *
1843
+ * @typedef {Array<string | Token>} TokenStream
1844
+ * @global
1845
+ * @public
1846
+ */
1847
+
1848
+ /**
1849
+ * Converts the given token or token stream to an HTML representation.
1850
+ *
1851
+ * The following hooks will be run:
1852
+ * 1. `wrap`: On each {@link Token}.
1853
+ *
1854
+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
1855
+ * @param {string} language The name of current language.
1856
+ * @returns {string} The HTML representation of the token or token stream.
1857
+ * @memberof Token
1858
+ * @static
1859
+ */
1860
+ Token.stringify = function stringify(o, language) {
1861
+ if (typeof o == 'string') {
1862
+ return o;
1863
+ }
1864
+ if (Array.isArray(o)) {
1865
+ var s = '';
1866
+ o.forEach(function (e) {
1867
+ s += stringify(e, language);
1868
+ });
1869
+ return s;
1870
+ }
1871
+
1872
+ var env = {
1873
+ type: o.type,
1874
+ content: stringify(o.content, language),
1875
+ tag: 'span',
1876
+ classes: ['token', o.type],
1877
+ attributes: {},
1878
+ language: language
1879
+ };
1880
+
1881
+ var aliases = o.alias;
1882
+ if (aliases) {
1883
+ if (Array.isArray(aliases)) {
1884
+ Array.prototype.push.apply(env.classes, aliases);
1885
+ } else {
1886
+ env.classes.push(aliases);
1887
+ }
1888
+ }
1889
+
1890
+ _.hooks.run('wrap', env);
1891
+
1892
+ var attributes = '';
1893
+ for (var name in env.attributes) {
1894
+ attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
1895
+ }
1896
+
1897
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
1898
+ };
1899
+
1900
+ /**
1901
+ * @param {RegExp} pattern
1902
+ * @param {number} pos
1903
+ * @param {string} text
1904
+ * @param {boolean} lookbehind
1905
+ * @returns {RegExpExecArray | null}
1906
+ */
1907
+ function matchPattern(pattern, pos, text, lookbehind) {
1908
+ pattern.lastIndex = pos;
1909
+ var match = pattern.exec(text);
1910
+ if (match && lookbehind && match[1]) {
1911
+ // change the match to remove the text matched by the Prism lookbehind group
1912
+ var lookbehindLength = match[1].length;
1913
+ match.index += lookbehindLength;
1914
+ match[0] = match[0].slice(lookbehindLength);
1915
+ }
1916
+ return match;
1917
+ }
1918
+
1919
+ /**
1920
+ * @param {string} text
1921
+ * @param {LinkedList<string | Token>} tokenList
1922
+ * @param {any} grammar
1923
+ * @param {LinkedListNode<string | Token>} startNode
1924
+ * @param {number} startPos
1925
+ * @param {RematchOptions} [rematch]
1926
+ * @returns {void}
1927
+ * @private
1928
+ *
1929
+ * @typedef RematchOptions
1930
+ * @property {string} cause
1931
+ * @property {number} reach
1932
+ */
1933
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
1934
+ for (var token in grammar) {
1935
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
1936
+ continue;
1937
+ }
1938
+
1939
+ var patterns = grammar[token];
1940
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
1941
+
1942
+ for (var j = 0; j < patterns.length; ++j) {
1943
+ if (rematch && rematch.cause == token + ',' + j) {
1944
+ return;
1945
+ }
1946
+
1947
+ var patternObj = patterns[j];
1948
+ var inside = patternObj.inside;
1949
+ var lookbehind = !!patternObj.lookbehind;
1950
+ var greedy = !!patternObj.greedy;
1951
+ var alias = patternObj.alias;
1952
+
1953
+ if (greedy && !patternObj.pattern.global) {
1954
+ // Without the global flag, lastIndex won't work
1955
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
1956
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
1957
+ }
1958
+
1959
+ /** @type {RegExp} */
1960
+ var pattern = patternObj.pattern || patternObj;
1961
+
1962
+ for ( // iterate the token list and keep track of the current token/string position
1963
+ var currentNode = startNode.next, pos = startPos;
1964
+ currentNode !== tokenList.tail;
1965
+ pos += currentNode.value.length, currentNode = currentNode.next
1966
+ ) {
1967
+
1968
+ if (rematch && pos >= rematch.reach) {
1969
+ break;
1970
+ }
1971
+
1972
+ var str = currentNode.value;
1973
+
1974
+ if (tokenList.length > text.length) {
1975
+ // Something went terribly wrong, ABORT, ABORT!
1976
+ return;
1977
+ }
1978
+
1979
+ if (str instanceof Token) {
1980
+ continue;
1981
+ }
1982
+
1983
+ var removeCount = 1; // this is the to parameter of removeBetween
1984
+ var match;
1985
+
1986
+ if (greedy) {
1987
+ match = matchPattern(pattern, pos, text, lookbehind);
1988
+ if (!match || match.index >= text.length) {
1989
+ break;
1990
+ }
1991
+
1992
+ var from = match.index;
1993
+ var to = match.index + match[0].length;
1994
+ var p = pos;
1995
+
1996
+ // find the node that contains the match
1997
+ p += currentNode.value.length;
1998
+ while (from >= p) {
1999
+ currentNode = currentNode.next;
2000
+ p += currentNode.value.length;
2001
+ }
2002
+ // adjust pos (and p)
2003
+ p -= currentNode.value.length;
2004
+ pos = p;
2005
+
2006
+ // the current node is a Token, then the match starts inside another Token, which is invalid
2007
+ if (currentNode.value instanceof Token) {
2008
+ continue;
2009
+ }
2010
+
2011
+ // find the last node which is affected by this match
2012
+ for (
2013
+ var k = currentNode;
2014
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
2015
+ k = k.next
2016
+ ) {
2017
+ removeCount++;
2018
+ p += k.value.length;
2019
+ }
2020
+ removeCount--;
2021
+
2022
+ // replace with the new match
2023
+ str = text.slice(pos, p);
2024
+ match.index -= pos;
2025
+ } else {
2026
+ match = matchPattern(pattern, 0, str, lookbehind);
2027
+ if (!match) {
2028
+ continue;
2029
+ }
2030
+ }
2031
+
2032
+ // eslint-disable-next-line no-redeclare
2033
+ var from = match.index;
2034
+ var matchStr = match[0];
2035
+ var before = str.slice(0, from);
2036
+ var after = str.slice(from + matchStr.length);
2037
+
2038
+ var reach = pos + str.length;
2039
+ if (rematch && reach > rematch.reach) {
2040
+ rematch.reach = reach;
2041
+ }
2042
+
2043
+ var removeFrom = currentNode.prev;
2044
+
2045
+ if (before) {
2046
+ removeFrom = addAfter(tokenList, removeFrom, before);
2047
+ pos += before.length;
2048
+ }
2049
+
2050
+ removeRange(tokenList, removeFrom, removeCount);
2051
+
2052
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
2053
+ currentNode = addAfter(tokenList, removeFrom, wrapped);
2054
+
2055
+ if (after) {
2056
+ addAfter(tokenList, currentNode, after);
2057
+ }
2058
+
2059
+ if (removeCount > 1) {
2060
+ // at least one Token object was removed, so we have to do some rematching
2061
+ // this can only happen if the current pattern is greedy
2062
+
2063
+ /** @type {RematchOptions} */
2064
+ var nestedRematch = {
2065
+ cause: token + ',' + j,
2066
+ reach: reach
2067
+ };
2068
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
2069
+
2070
+ // the reach might have been extended because of the rematching
2071
+ if (rematch && nestedRematch.reach > rematch.reach) {
2072
+ rematch.reach = nestedRematch.reach;
2073
+ }
2074
+ }
2075
+ }
2076
+ }
2077
+ }
2078
+ }
2079
+
2080
+ /**
2081
+ * @typedef LinkedListNode
2082
+ * @property {T} value
2083
+ * @property {LinkedListNode<T> | null} prev The previous node.
2084
+ * @property {LinkedListNode<T> | null} next The next node.
2085
+ * @template T
2086
+ * @private
2087
+ */
2088
+
2089
+ /**
2090
+ * @template T
2091
+ * @private
2092
+ */
2093
+ function LinkedList() {
2094
+ /** @type {LinkedListNode<T>} */
2095
+ var head = { value: null, prev: null, next: null };
2096
+ /** @type {LinkedListNode<T>} */
2097
+ var tail = { value: null, prev: head, next: null };
2098
+ head.next = tail;
2099
+
2100
+ /** @type {LinkedListNode<T>} */
2101
+ this.head = head;
2102
+ /** @type {LinkedListNode<T>} */
2103
+ this.tail = tail;
2104
+ this.length = 0;
2105
+ }
2106
+
2107
+ /**
2108
+ * Adds a new node with the given value to the list.
2109
+ *
2110
+ * @param {LinkedList<T>} list
2111
+ * @param {LinkedListNode<T>} node
2112
+ * @param {T} value
2113
+ * @returns {LinkedListNode<T>} The added node.
2114
+ * @template T
2115
+ */
2116
+ function addAfter(list, node, value) {
2117
+ // assumes that node != list.tail && values.length >= 0
2118
+ var next = node.next;
2119
+
2120
+ var newNode = { value: value, prev: node, next: next };
2121
+ node.next = newNode;
2122
+ next.prev = newNode;
2123
+ list.length++;
2124
+
2125
+ return newNode;
2126
+ }
2127
+ /**
2128
+ * Removes `count` nodes after the given node. The given node will not be removed.
2129
+ *
2130
+ * @param {LinkedList<T>} list
2131
+ * @param {LinkedListNode<T>} node
2132
+ * @param {number} count
2133
+ * @template T
2134
+ */
2135
+ function removeRange(list, node, count) {
2136
+ var next = node.next;
2137
+ for (var i = 0; i < count && next !== list.tail; i++) {
2138
+ next = next.next;
2139
+ }
2140
+ node.next = next;
2141
+ next.prev = node;
2142
+ list.length -= i;
2143
+ }
2144
+ /**
2145
+ * @param {LinkedList<T>} list
2146
+ * @returns {T[]}
2147
+ * @template T
2148
+ */
2149
+ function toArray(list) {
2150
+ var array = [];
2151
+ var node = list.head.next;
2152
+ while (node !== list.tail) {
2153
+ array.push(node.value);
2154
+ node = node.next;
2155
+ }
2156
+ return array;
2157
+ }
2158
+
2159
+
2160
+ if (!_self.document) {
2161
+ if (!_self.addEventListener) {
2162
+ // in Node.js
2163
+ return _;
2164
+ }
2165
+
2166
+ if (!_.disableWorkerMessageHandler) {
2167
+ // In worker
2168
+ _self.addEventListener('message', function (evt) {
2169
+ var message = JSON.parse(evt.data);
2170
+ var lang = message.language;
2171
+ var code = message.code;
2172
+ var immediateClose = message.immediateClose;
2173
+
2174
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
2175
+ if (immediateClose) {
2176
+ _self.close();
2177
+ }
2178
+ }, false);
2179
+ }
2180
+
2181
+ return _;
2182
+ }
2183
+
2184
+ // Get current script and highlight
2185
+ var script = _.util.currentScript();
2186
+
2187
+ if (script) {
2188
+ _.filename = script.src;
2189
+
2190
+ if (script.hasAttribute('data-manual')) {
2191
+ _.manual = true;
2192
+ }
2193
+ }
2194
+
2195
+ function highlightAutomaticallyCallback() {
2196
+ if (!_.manual) {
2197
+ _.highlightAll();
2198
+ }
2199
+ }
2200
+
2201
+ if (!_.manual) {
2202
+ // If the document state is "loading", then we'll use DOMContentLoaded.
2203
+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
2204
+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
2205
+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
2206
+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
2207
+ // See https://github.com/PrismJS/prism/issues/2102
2208
+ var readyState = document.readyState;
2209
+ if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
2210
+ document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
2211
+ } else {
2212
+ if (window.requestAnimationFrame) {
2213
+ window.requestAnimationFrame(highlightAutomaticallyCallback);
2214
+ } else {
2215
+ window.setTimeout(highlightAutomaticallyCallback, 16);
2216
+ }
2217
+ }
2218
+ }
2219
+
2220
+ return _;
2221
+
2222
+ }(_self));
2223
+
2224
+ if (module.exports) {
2225
+ module.exports = Prism;
2226
+ }
2227
+
2228
+ // hack for components to work correctly in node.js
2229
+ if (typeof _commonjsHelpers.commonjsGlobal !== 'undefined') {
2230
+ _commonjsHelpers.commonjsGlobal.Prism = Prism;
2231
+ }
2232
+
2233
+ // some additional documentation/types
2234
+
2235
+ /**
2236
+ * The expansion of a simple `RegExp` literal to support additional properties.
2237
+ *
2238
+ * @typedef GrammarToken
2239
+ * @property {RegExp} pattern The regular expression of the token.
2240
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
2241
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
2242
+ * @property {boolean} [greedy=false] Whether the token is greedy.
2243
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
2244
+ * @property {Grammar} [inside] The nested grammar of this token.
2245
+ *
2246
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
2247
+ *
2248
+ * This can be used to make nested and even recursive language definitions.
2249
+ *
2250
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
2251
+ * each another.
2252
+ * @global
2253
+ * @public
2254
+ */
2255
+
2256
+ /**
2257
+ * @typedef Grammar
2258
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
2259
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
2260
+ * @global
2261
+ * @public
2262
+ */
2263
+
2264
+ /**
2265
+ * A function which will invoked after an element was successfully highlighted.
2266
+ *
2267
+ * @callback HighlightCallback
2268
+ * @param {Element} element The element successfully highlighted.
2269
+ * @returns {void}
2270
+ * @global
2271
+ * @public
2272
+ */
2273
+
2274
+ /**
2275
+ * @callback HookCallback
2276
+ * @param {Object<string, any>} env The environment variables of the hook.
2277
+ * @returns {void}
2278
+ * @global
2279
+ * @public
2280
+ */
2281
+
2282
+
2283
+ /* **********************************************
2284
+ Begin prism-markup.js
2285
+ ********************************************** */
2286
+
2287
+ Prism.languages.markup = {
2288
+ 'comment': {
2289
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
2290
+ greedy: true
2291
+ },
2292
+ 'prolog': {
2293
+ pattern: /<\?[\s\S]+?\?>/,
2294
+ greedy: true
2295
+ },
2296
+ 'doctype': {
2297
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
2298
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
2299
+ greedy: true,
2300
+ inside: {
2301
+ 'internal-subset': {
2302
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
2303
+ lookbehind: true,
2304
+ greedy: true,
2305
+ inside: null // see below
2306
+ },
2307
+ 'string': {
2308
+ pattern: /"[^"]*"|'[^']*'/,
2309
+ greedy: true
2310
+ },
2311
+ 'punctuation': /^<!|>$|[[\]]/,
2312
+ 'doctype-tag': /^DOCTYPE/i,
2313
+ 'name': /[^\s<>'"]+/
2314
+ }
2315
+ },
2316
+ 'cdata': {
2317
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2318
+ greedy: true
2319
+ },
2320
+ 'tag': {
2321
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2322
+ greedy: true,
2323
+ inside: {
2324
+ 'tag': {
2325
+ pattern: /^<\/?[^\s>\/]+/,
2326
+ inside: {
2327
+ 'punctuation': /^<\/?/,
2328
+ 'namespace': /^[^\s>\/:]+:/
2329
+ }
2330
+ },
2331
+ 'special-attr': [],
2332
+ 'attr-value': {
2333
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
2334
+ inside: {
2335
+ 'punctuation': [
2336
+ {
2337
+ pattern: /^=/,
2338
+ alias: 'attr-equals'
2339
+ },
2340
+ {
2341
+ pattern: /^(\s*)["']|["']$/,
2342
+ lookbehind: true
2343
+ }
2344
+ ]
2345
+ }
2346
+ },
2347
+ 'punctuation': /\/?>/,
2348
+ 'attr-name': {
2349
+ pattern: /[^\s>\/]+/,
2350
+ inside: {
2351
+ 'namespace': /^[^\s>\/:]+:/
2352
+ }
2353
+ }
2354
+
2355
+ }
2356
+ },
2357
+ 'entity': [
2358
+ {
2359
+ pattern: /&[\da-z]{1,8};/i,
2360
+ alias: 'named-entity'
2361
+ },
2362
+ /&#x?[\da-f]{1,8};/i
2363
+ ]
2364
+ };
2365
+
2366
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2367
+ Prism.languages.markup['entity'];
2368
+ Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
2369
+
2370
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
2371
+ Prism.hooks.add('wrap', function (env) {
2372
+
2373
+ if (env.type === 'entity') {
2374
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
2375
+ }
2376
+ });
2377
+
2378
+ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2379
+ /**
2380
+ * Adds an inlined language to markup.
2381
+ *
2382
+ * An example of an inlined language is CSS with `<style>` tags.
2383
+ *
2384
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
2385
+ * case insensitive.
2386
+ * @param {string} lang The language key.
2387
+ * @example
2388
+ * addInlined('style', 'css');
2389
+ */
2390
+ value: function addInlined(tagName, lang) {
2391
+ var includedCdataInside = {};
2392
+ includedCdataInside['language-' + lang] = {
2393
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
2394
+ lookbehind: true,
2395
+ inside: Prism.languages[lang]
2396
+ };
2397
+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2398
+
2399
+ var inside = {
2400
+ 'included-cdata': {
2401
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2402
+ inside: includedCdataInside
2403
+ }
2404
+ };
2405
+ inside['language-' + lang] = {
2406
+ pattern: /[\s\S]+/,
2407
+ inside: Prism.languages[lang]
2408
+ };
2409
+
2410
+ var def = {};
2411
+ def[tagName] = {
2412
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
2413
+ lookbehind: true,
2414
+ greedy: true,
2415
+ inside: inside
2416
+ };
2417
+
2418
+ Prism.languages.insertBefore('markup', 'cdata', def);
2419
+ }
2420
+ });
2421
+ Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
2422
+ /**
2423
+ * Adds an pattern to highlight languages embedded in HTML attributes.
2424
+ *
2425
+ * An example of an inlined language is CSS with `style` attributes.
2426
+ *
2427
+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
2428
+ * case insensitive.
2429
+ * @param {string} lang The language key.
2430
+ * @example
2431
+ * addAttribute('style', 'css');
2432
+ */
2433
+ value: function (attrName, lang) {
2434
+ Prism.languages.markup.tag.inside['special-attr'].push({
2435
+ pattern: RegExp(
2436
+ /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
2437
+ 'i'
2438
+ ),
2439
+ lookbehind: true,
2440
+ inside: {
2441
+ 'attr-name': /^[^\s=]+/,
2442
+ 'attr-value': {
2443
+ pattern: /=[\s\S]+/,
2444
+ inside: {
2445
+ 'value': {
2446
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
2447
+ lookbehind: true,
2448
+ alias: [lang, 'language-' + lang],
2449
+ inside: Prism.languages[lang]
2450
+ },
2451
+ 'punctuation': [
2452
+ {
2453
+ pattern: /^=/,
2454
+ alias: 'attr-equals'
2455
+ },
2456
+ /"|'/
2457
+ ]
2458
+ }
2459
+ }
2460
+ }
2461
+ });
2462
+ }
2463
+ });
2464
+
2465
+ Prism.languages.html = Prism.languages.markup;
2466
+ Prism.languages.mathml = Prism.languages.markup;
2467
+ Prism.languages.svg = Prism.languages.markup;
2468
+
2469
+ Prism.languages.xml = Prism.languages.extend('markup', {});
2470
+ Prism.languages.ssml = Prism.languages.xml;
2471
+ Prism.languages.atom = Prism.languages.xml;
2472
+ Prism.languages.rss = Prism.languages.xml;
2473
+
2474
+
2475
+ /* **********************************************
2476
+ Begin prism-css.js
2477
+ ********************************************** */
2478
+
2479
+ (function (Prism) {
2480
+
2481
+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
2482
+
2483
+ Prism.languages.css = {
2484
+ 'comment': /\/\*[\s\S]*?\*\//,
2485
+ 'atrule': {
2486
+ pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
2487
+ inside: {
2488
+ 'rule': /^@[\w-]+/,
2489
+ 'selector-function-argument': {
2490
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
2491
+ lookbehind: true,
2492
+ alias: 'selector'
2493
+ },
2494
+ 'keyword': {
2495
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
2496
+ lookbehind: true
2497
+ }
2498
+ // See rest below
2499
+ }
2500
+ },
2501
+ 'url': {
2502
+ // https://drafts.csswg.org/css-values-3/#urls
2503
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
2504
+ greedy: true,
2505
+ inside: {
2506
+ 'function': /^url/i,
2507
+ 'punctuation': /^\(|\)$/,
2508
+ 'string': {
2509
+ pattern: RegExp('^' + string.source + '$'),
2510
+ alias: 'url'
2511
+ }
2512
+ }
2513
+ },
2514
+ 'selector': {
2515
+ pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
2516
+ lookbehind: true
2517
+ },
2518
+ 'string': {
2519
+ pattern: string,
2520
+ greedy: true
2521
+ },
2522
+ 'property': {
2523
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
2524
+ lookbehind: true
2525
+ },
2526
+ 'important': /!important\b/i,
2527
+ 'function': {
2528
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
2529
+ lookbehind: true
2530
+ },
2531
+ 'punctuation': /[(){};:,]/
2532
+ };
2533
+
2534
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2535
+
2536
+ var markup = Prism.languages.markup;
2537
+ if (markup) {
2538
+ markup.tag.addInlined('style', 'css');
2539
+ markup.tag.addAttribute('style', 'css');
2540
+ }
2541
+
2542
+ }(Prism));
2543
+
2544
+
2545
+ /* **********************************************
2546
+ Begin prism-clike.js
2547
+ ********************************************** */
2548
+
2549
+ Prism.languages.clike = {
2550
+ 'comment': [
2551
+ {
2552
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
2553
+ lookbehind: true,
2554
+ greedy: true
2555
+ },
2556
+ {
2557
+ pattern: /(^|[^\\:])\/\/.*/,
2558
+ lookbehind: true,
2559
+ greedy: true
2560
+ }
2561
+ ],
2562
+ 'string': {
2563
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
2564
+ greedy: true
2565
+ },
2566
+ 'class-name': {
2567
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
2568
+ lookbehind: true,
2569
+ inside: {
2570
+ 'punctuation': /[.\\]/
2571
+ }
2572
+ },
2573
+ 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
2574
+ 'boolean': /\b(?:false|true)\b/,
2575
+ 'function': /\b\w+(?=\()/,
2576
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
2577
+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
2578
+ 'punctuation': /[{}[\];(),.:]/
2579
+ };
2580
+
2581
+
2582
+ /* **********************************************
2583
+ Begin prism-javascript.js
2584
+ ********************************************** */
2585
+
2586
+ Prism.languages.javascript = Prism.languages.extend('clike', {
2587
+ 'class-name': [
2588
+ Prism.languages.clike['class-name'],
2589
+ {
2590
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2591
+ lookbehind: true
2592
+ }
2593
+ ],
2594
+ 'keyword': [
2595
+ {
2596
+ pattern: /((?:^|\})\s*)catch\b/,
2597
+ lookbehind: true
2598
+ },
2599
+ {
2600
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
2601
+ lookbehind: true
2602
+ },
2603
+ ],
2604
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
2605
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
2606
+ 'number': {
2607
+ pattern: RegExp(
2608
+ /(^|[^\w$])/.source +
2609
+ '(?:' +
2610
+ (
2611
+ // constant
2612
+ /NaN|Infinity/.source +
2613
+ '|' +
2614
+ // binary integer
2615
+ /0[bB][01]+(?:_[01]+)*n?/.source +
2616
+ '|' +
2617
+ // octal integer
2618
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
2619
+ '|' +
2620
+ // hexadecimal integer
2621
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
2622
+ '|' +
2623
+ // decimal bigint
2624
+ /\d+(?:_\d+)*n/.source +
2625
+ '|' +
2626
+ // decimal number (integer or float) but no bigint
2627
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
2628
+ ) +
2629
+ ')' +
2630
+ /(?![\w$])/.source
2631
+ ),
2632
+ lookbehind: true
2633
+ },
2634
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
2635
+ });
2636
+
2637
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
2638
+
2639
+ Prism.languages.insertBefore('javascript', 'keyword', {
2640
+ 'regex': {
2641
+ pattern: RegExp(
2642
+ // lookbehind
2643
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
2644
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
2645
+ // Regex pattern:
2646
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
2647
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
2648
+ // with the only syntax, so we have to define 2 different regex patterns.
2649
+ /\//.source +
2650
+ '(?:' +
2651
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
2652
+ '|' +
2653
+ // `v` flag syntax. This supports 3 levels of nested character classes.
2654
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
2655
+ ')' +
2656
+ // lookahead
2657
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
2658
+ ),
2659
+ lookbehind: true,
2660
+ greedy: true,
2661
+ inside: {
2662
+ 'regex-source': {
2663
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
2664
+ lookbehind: true,
2665
+ alias: 'language-regex',
2666
+ inside: Prism.languages.regex
2667
+ },
2668
+ 'regex-delimiter': /^\/|\/$/,
2669
+ 'regex-flags': /^[a-z]+$/,
2670
+ }
2671
+ },
2672
+ // This must be declared before keyword because we use "function" inside the look-forward
2673
+ 'function-variable': {
2674
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
2675
+ alias: 'function'
2676
+ },
2677
+ 'parameter': [
2678
+ {
2679
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
2680
+ lookbehind: true,
2681
+ inside: Prism.languages.javascript
2682
+ },
2683
+ {
2684
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
2685
+ lookbehind: true,
2686
+ inside: Prism.languages.javascript
2687
+ },
2688
+ {
2689
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
2690
+ lookbehind: true,
2691
+ inside: Prism.languages.javascript
2692
+ },
2693
+ {
2694
+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
2695
+ lookbehind: true,
2696
+ inside: Prism.languages.javascript
2697
+ }
2698
+ ],
2699
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
2700
+ });
2701
+
2702
+ Prism.languages.insertBefore('javascript', 'string', {
2703
+ 'hashbang': {
2704
+ pattern: /^#!.*/,
2705
+ greedy: true,
2706
+ alias: 'comment'
2707
+ },
2708
+ 'template-string': {
2709
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
2710
+ greedy: true,
2711
+ inside: {
2712
+ 'template-punctuation': {
2713
+ pattern: /^`|`$/,
2714
+ alias: 'string'
2715
+ },
2716
+ 'interpolation': {
2717
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
2718
+ lookbehind: true,
2719
+ inside: {
2720
+ 'interpolation-punctuation': {
2721
+ pattern: /^\$\{|\}$/,
2722
+ alias: 'punctuation'
2723
+ },
2724
+ rest: Prism.languages.javascript
2725
+ }
2726
+ },
2727
+ 'string': /[\s\S]+/
2728
+ }
2729
+ },
2730
+ 'string-property': {
2731
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
2732
+ lookbehind: true,
2733
+ greedy: true,
2734
+ alias: 'property'
2735
+ }
2736
+ });
2737
+
2738
+ Prism.languages.insertBefore('javascript', 'operator', {
2739
+ 'literal-property': {
2740
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
2741
+ lookbehind: true,
2742
+ alias: 'property'
2743
+ },
2744
+ });
2745
+
2746
+ if (Prism.languages.markup) {
2747
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
2748
+
2749
+ // add attribute support for all DOM events.
2750
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
2751
+ Prism.languages.markup.tag.addAttribute(
2752
+ /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
2753
+ 'javascript'
2754
+ );
2755
+ }
2756
+
2757
+ Prism.languages.js = Prism.languages.javascript;
2758
+
2759
+
2760
+ /* **********************************************
2761
+ Begin prism-file-highlight.js
2762
+ ********************************************** */
2763
+
2764
+ (function () {
2765
+
2766
+ if (typeof Prism === 'undefined' || typeof document === 'undefined') {
2767
+ return;
2768
+ }
2769
+
2770
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
2771
+ if (!Element.prototype.matches) {
2772
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
2773
+ }
2774
+
2775
+ var LOADING_MESSAGE = 'Loading…';
2776
+ var FAILURE_MESSAGE = function (status, message) {
2777
+ return '✖ Error ' + status + ' while fetching file: ' + message;
2778
+ };
2779
+ var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
2780
+
2781
+ var EXTENSIONS = {
2782
+ 'js': 'javascript',
2783
+ 'py': 'python',
2784
+ 'rb': 'ruby',
2785
+ 'ps1': 'powershell',
2786
+ 'psm1': 'powershell',
2787
+ 'sh': 'bash',
2788
+ 'bat': 'batch',
2789
+ 'h': 'c',
2790
+ 'tex': 'latex'
2791
+ };
2792
+
2793
+ var STATUS_ATTR = 'data-src-status';
2794
+ var STATUS_LOADING = 'loading';
2795
+ var STATUS_LOADED = 'loaded';
2796
+ var STATUS_FAILED = 'failed';
2797
+
2798
+ var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
2799
+ + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
2800
+
2801
+ /**
2802
+ * Loads the given file.
2803
+ *
2804
+ * @param {string} src The URL or path of the source file to load.
2805
+ * @param {(result: string) => void} success
2806
+ * @param {(reason: string) => void} error
2807
+ */
2808
+ function loadFile(src, success, error) {
2809
+ var xhr = new XMLHttpRequest();
2810
+ xhr.open('GET', src, true);
2811
+ xhr.onreadystatechange = function () {
2812
+ if (xhr.readyState == 4) {
2813
+ if (xhr.status < 400 && xhr.responseText) {
2814
+ success(xhr.responseText);
2815
+ } else {
2816
+ if (xhr.status >= 400) {
2817
+ error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
2818
+ } else {
2819
+ error(FAILURE_EMPTY_MESSAGE);
2820
+ }
2821
+ }
2822
+ }
2823
+ };
2824
+ xhr.send(null);
2825
+ }
2826
+
2827
+ /**
2828
+ * Parses the given range.
2829
+ *
2830
+ * This returns a range with inclusive ends.
2831
+ *
2832
+ * @param {string | null | undefined} range
2833
+ * @returns {[number, number | undefined] | undefined}
2834
+ */
2835
+ function parseRange(range) {
2836
+ var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
2837
+ if (m) {
2838
+ var start = Number(m[1]);
2839
+ var comma = m[2];
2840
+ var end = m[3];
2841
+
2842
+ if (!comma) {
2843
+ return [start, start];
2844
+ }
2845
+ if (!end) {
2846
+ return [start, undefined];
2847
+ }
2848
+ return [start, Number(end)];
2849
+ }
2850
+ return undefined;
2851
+ }
2852
+
2853
+ Prism.hooks.add('before-highlightall', function (env) {
2854
+ env.selector += ', ' + SELECTOR;
2855
+ });
2856
+
2857
+ Prism.hooks.add('before-sanity-check', function (env) {
2858
+ var pre = /** @type {HTMLPreElement} */ (env.element);
2859
+ if (pre.matches(SELECTOR)) {
2860
+ env.code = ''; // fast-path the whole thing and go to complete
2861
+
2862
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
2863
+
2864
+ // add code element with loading message
2865
+ var code = pre.appendChild(document.createElement('CODE'));
2866
+ code.textContent = LOADING_MESSAGE;
2867
+
2868
+ var src = pre.getAttribute('data-src');
2869
+
2870
+ var language = env.language;
2871
+ if (language === 'none') {
2872
+ // the language might be 'none' because there is no language set;
2873
+ // in this case, we want to use the extension as the language
2874
+ var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
2875
+ language = EXTENSIONS[extension] || extension;
2876
+ }
2877
+
2878
+ // set language classes
2879
+ Prism.util.setLanguage(code, language);
2880
+ Prism.util.setLanguage(pre, language);
2881
+
2882
+ // preload the language
2883
+ var autoloader = Prism.plugins.autoloader;
2884
+ if (autoloader) {
2885
+ autoloader.loadLanguages(language);
2886
+ }
2887
+
2888
+ // load file
2889
+ loadFile(
2890
+ src,
2891
+ function (text) {
2892
+ // mark as loaded
2893
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
2894
+
2895
+ // handle data-range
2896
+ var range = parseRange(pre.getAttribute('data-range'));
2897
+ if (range) {
2898
+ var lines = text.split(/\r\n?|\n/g);
2899
+
2900
+ // the range is one-based and inclusive on both ends
2901
+ var start = range[0];
2902
+ var end = range[1] == null ? lines.length : range[1];
2903
+
2904
+ if (start < 0) { start += lines.length; }
2905
+ start = Math.max(0, Math.min(start - 1, lines.length));
2906
+ if (end < 0) { end += lines.length; }
2907
+ end = Math.max(0, Math.min(end, lines.length));
2908
+
2909
+ text = lines.slice(start, end).join('\n');
2910
+
2911
+ // add data-start for line numbers
2912
+ if (!pre.hasAttribute('data-start')) {
2913
+ pre.setAttribute('data-start', String(start + 1));
2914
+ }
2915
+ }
2916
+
2917
+ // highlight code
2918
+ code.textContent = text;
2919
+ Prism.highlightElement(code);
2920
+ },
2921
+ function (error) {
2922
+ // mark as failed
2923
+ pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
2924
+
2925
+ code.textContent = error;
2926
+ }
2927
+ );
2928
+ }
2929
+ });
2930
+
2931
+ Prism.plugins.fileHighlight = {
2932
+ /**
2933
+ * Executes the File Highlight plugin for all matching `pre` elements under the given container.
2934
+ *
2935
+ * Note: Elements which are already loaded or currently loading will not be touched by this method.
2936
+ *
2937
+ * @param {ParentNode} [container=document]
2938
+ */
2939
+ highlight: function highlight(container) {
2940
+ var elements = (container || document).querySelectorAll(SELECTOR);
2941
+
2942
+ for (var i = 0, element; (element = elements[i++]);) {
2943
+ Prism.highlightElement(element);
2944
+ }
2945
+ }
2946
+ };
2947
+
2948
+ var logged = false;
2949
+ /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
2950
+ Prism.fileHighlight = function () {
2951
+ if (!logged) {
2952
+ console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
2953
+ logged = true;
2954
+ }
2955
+ Prism.plugins.fileHighlight.highlight.apply(this, arguments);
2956
+ };
2957
+
2958
+ }());
2959
+ });
2960
+
2961
+ Prism.languages.clike = {
2962
+ 'comment': [
2963
+ {
2964
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
2965
+ lookbehind: true,
2966
+ greedy: true
2967
+ },
2968
+ {
2969
+ pattern: /(^|[^\\:])\/\/.*/,
2970
+ lookbehind: true,
2971
+ greedy: true
2972
+ }
2973
+ ],
2974
+ 'string': {
2975
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
2976
+ greedy: true
2977
+ },
2978
+ 'class-name': {
2979
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
2980
+ lookbehind: true,
2981
+ inside: {
2982
+ 'punctuation': /[.\\]/
2983
+ }
2984
+ },
2985
+ 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
2986
+ 'boolean': /\b(?:false|true)\b/,
2987
+ 'function': /\b\w+(?=\()/,
2988
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
2989
+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
2990
+ 'punctuation': /[{}[\];(),.:]/
2991
+ };
2992
+
2993
+ Prism.languages.javascript = Prism.languages.extend('clike', {
2994
+ 'class-name': [
2995
+ Prism.languages.clike['class-name'],
2996
+ {
2997
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2998
+ lookbehind: true
2999
+ }
3000
+ ],
3001
+ 'keyword': [
3002
+ {
3003
+ pattern: /((?:^|\})\s*)catch\b/,
3004
+ lookbehind: true
3005
+ },
3006
+ {
3007
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
3008
+ lookbehind: true
3009
+ },
3010
+ ],
3011
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
3012
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
3013
+ 'number': {
3014
+ pattern: RegExp(
3015
+ /(^|[^\w$])/.source +
3016
+ '(?:' +
3017
+ (
3018
+ // constant
3019
+ /NaN|Infinity/.source +
3020
+ '|' +
3021
+ // binary integer
3022
+ /0[bB][01]+(?:_[01]+)*n?/.source +
3023
+ '|' +
3024
+ // octal integer
3025
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
3026
+ '|' +
3027
+ // hexadecimal integer
3028
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
3029
+ '|' +
3030
+ // decimal bigint
3031
+ /\d+(?:_\d+)*n/.source +
3032
+ '|' +
3033
+ // decimal number (integer or float) but no bigint
3034
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
3035
+ ) +
3036
+ ')' +
3037
+ /(?![\w$])/.source
3038
+ ),
3039
+ lookbehind: true
3040
+ },
3041
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
3042
+ });
3043
+
3044
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
3045
+
3046
+ Prism.languages.insertBefore('javascript', 'keyword', {
3047
+ 'regex': {
3048
+ pattern: RegExp(
3049
+ // lookbehind
3050
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
3051
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
3052
+ // Regex pattern:
3053
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
3054
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
3055
+ // with the only syntax, so we have to define 2 different regex patterns.
3056
+ /\//.source +
3057
+ '(?:' +
3058
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
3059
+ '|' +
3060
+ // `v` flag syntax. This supports 3 levels of nested character classes.
3061
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
3062
+ ')' +
3063
+ // lookahead
3064
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
3065
+ ),
3066
+ lookbehind: true,
3067
+ greedy: true,
3068
+ inside: {
3069
+ 'regex-source': {
3070
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
3071
+ lookbehind: true,
3072
+ alias: 'language-regex',
3073
+ inside: Prism.languages.regex
3074
+ },
3075
+ 'regex-delimiter': /^\/|\/$/,
3076
+ 'regex-flags': /^[a-z]+$/,
3077
+ }
3078
+ },
3079
+ // This must be declared before keyword because we use "function" inside the look-forward
3080
+ 'function-variable': {
3081
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
3082
+ alias: 'function'
3083
+ },
3084
+ 'parameter': [
3085
+ {
3086
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
3087
+ lookbehind: true,
3088
+ inside: Prism.languages.javascript
3089
+ },
3090
+ {
3091
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
3092
+ lookbehind: true,
3093
+ inside: Prism.languages.javascript
3094
+ },
3095
+ {
3096
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
3097
+ lookbehind: true,
3098
+ inside: Prism.languages.javascript
3099
+ },
3100
+ {
3101
+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
3102
+ lookbehind: true,
3103
+ inside: Prism.languages.javascript
3104
+ }
3105
+ ],
3106
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
3107
+ });
3108
+
3109
+ Prism.languages.insertBefore('javascript', 'string', {
3110
+ 'hashbang': {
3111
+ pattern: /^#!.*/,
3112
+ greedy: true,
3113
+ alias: 'comment'
3114
+ },
3115
+ 'template-string': {
3116
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
3117
+ greedy: true,
3118
+ inside: {
3119
+ 'template-punctuation': {
3120
+ pattern: /^`|`$/,
3121
+ alias: 'string'
3122
+ },
3123
+ 'interpolation': {
3124
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
3125
+ lookbehind: true,
3126
+ inside: {
3127
+ 'interpolation-punctuation': {
3128
+ pattern: /^\$\{|\}$/,
3129
+ alias: 'punctuation'
3130
+ },
3131
+ rest: Prism.languages.javascript
3132
+ }
3133
+ },
3134
+ 'string': /[\s\S]+/
3135
+ }
3136
+ },
3137
+ 'string-property': {
3138
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
3139
+ lookbehind: true,
3140
+ greedy: true,
3141
+ alias: 'property'
3142
+ }
3143
+ });
3144
+
3145
+ Prism.languages.insertBefore('javascript', 'operator', {
3146
+ 'literal-property': {
3147
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
3148
+ lookbehind: true,
3149
+ alias: 'property'
3150
+ },
3151
+ });
3152
+
3153
+ if (Prism.languages.markup) {
3154
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
3155
+
3156
+ // add attribute support for all DOM events.
3157
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
3158
+ Prism.languages.markup.tag.addAttribute(
3159
+ /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
3160
+ 'javascript'
3161
+ );
3162
+ }
3163
+
3164
+ Prism.languages.js = Prism.languages.javascript;
3165
+
3166
+ Prism.languages.markup = {
3167
+ 'comment': {
3168
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
3169
+ greedy: true
3170
+ },
3171
+ 'prolog': {
3172
+ pattern: /<\?[\s\S]+?\?>/,
3173
+ greedy: true
3174
+ },
3175
+ 'doctype': {
3176
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
3177
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
3178
+ greedy: true,
3179
+ inside: {
3180
+ 'internal-subset': {
3181
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
3182
+ lookbehind: true,
3183
+ greedy: true,
3184
+ inside: null // see below
3185
+ },
3186
+ 'string': {
3187
+ pattern: /"[^"]*"|'[^']*'/,
3188
+ greedy: true
3189
+ },
3190
+ 'punctuation': /^<!|>$|[[\]]/,
3191
+ 'doctype-tag': /^DOCTYPE/i,
3192
+ 'name': /[^\s<>'"]+/
3193
+ }
3194
+ },
3195
+ 'cdata': {
3196
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
3197
+ greedy: true
3198
+ },
3199
+ 'tag': {
3200
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
3201
+ greedy: true,
3202
+ inside: {
3203
+ 'tag': {
3204
+ pattern: /^<\/?[^\s>\/]+/,
3205
+ inside: {
3206
+ 'punctuation': /^<\/?/,
3207
+ 'namespace': /^[^\s>\/:]+:/
3208
+ }
3209
+ },
3210
+ 'special-attr': [],
3211
+ 'attr-value': {
3212
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
3213
+ inside: {
3214
+ 'punctuation': [
3215
+ {
3216
+ pattern: /^=/,
3217
+ alias: 'attr-equals'
3218
+ },
3219
+ {
3220
+ pattern: /^(\s*)["']|["']$/,
3221
+ lookbehind: true
3222
+ }
3223
+ ]
3224
+ }
3225
+ },
3226
+ 'punctuation': /\/?>/,
3227
+ 'attr-name': {
3228
+ pattern: /[^\s>\/]+/,
3229
+ inside: {
3230
+ 'namespace': /^[^\s>\/:]+:/
3231
+ }
3232
+ }
3233
+
3234
+ }
3235
+ },
3236
+ 'entity': [
3237
+ {
3238
+ pattern: /&[\da-z]{1,8};/i,
3239
+ alias: 'named-entity'
3240
+ },
3241
+ /&#x?[\da-f]{1,8};/i
3242
+ ]
3243
+ };
3244
+
3245
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
3246
+ Prism.languages.markup['entity'];
3247
+ Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
3248
+
3249
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
3250
+ Prism.hooks.add('wrap', function (env) {
3251
+
3252
+ if (env.type === 'entity') {
3253
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
3254
+ }
3255
+ });
3256
+
3257
+ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
3258
+ /**
3259
+ * Adds an inlined language to markup.
3260
+ *
3261
+ * An example of an inlined language is CSS with `<style>` tags.
3262
+ *
3263
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
3264
+ * case insensitive.
3265
+ * @param {string} lang The language key.
3266
+ * @example
3267
+ * addInlined('style', 'css');
3268
+ */
3269
+ value: function addInlined(tagName, lang) {
3270
+ var includedCdataInside = {};
3271
+ includedCdataInside['language-' + lang] = {
3272
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
3273
+ lookbehind: true,
3274
+ inside: Prism.languages[lang]
3275
+ };
3276
+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
3277
+
3278
+ var inside = {
3279
+ 'included-cdata': {
3280
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
3281
+ inside: includedCdataInside
3282
+ }
3283
+ };
3284
+ inside['language-' + lang] = {
3285
+ pattern: /[\s\S]+/,
3286
+ inside: Prism.languages[lang]
3287
+ };
3288
+
3289
+ var def = {};
3290
+ def[tagName] = {
3291
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
3292
+ lookbehind: true,
3293
+ greedy: true,
3294
+ inside: inside
3295
+ };
3296
+
3297
+ Prism.languages.insertBefore('markup', 'cdata', def);
3298
+ }
3299
+ });
3300
+ Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
3301
+ /**
3302
+ * Adds an pattern to highlight languages embedded in HTML attributes.
3303
+ *
3304
+ * An example of an inlined language is CSS with `style` attributes.
3305
+ *
3306
+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
3307
+ * case insensitive.
3308
+ * @param {string} lang The language key.
3309
+ * @example
3310
+ * addAttribute('style', 'css');
3311
+ */
3312
+ value: function (attrName, lang) {
3313
+ Prism.languages.markup.tag.inside['special-attr'].push({
3314
+ pattern: RegExp(
3315
+ /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
3316
+ 'i'
3317
+ ),
3318
+ lookbehind: true,
3319
+ inside: {
3320
+ 'attr-name': /^[^\s=]+/,
3321
+ 'attr-value': {
3322
+ pattern: /=[\s\S]+/,
3323
+ inside: {
3324
+ 'value': {
3325
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
3326
+ lookbehind: true,
3327
+ alias: [lang, 'language-' + lang],
3328
+ inside: Prism.languages[lang]
3329
+ },
3330
+ 'punctuation': [
3331
+ {
3332
+ pattern: /^=/,
3333
+ alias: 'attr-equals'
3334
+ },
3335
+ /"|'/
3336
+ ]
3337
+ }
3338
+ }
3339
+ }
3340
+ });
3341
+ }
3342
+ });
3343
+
3344
+ Prism.languages.html = Prism.languages.markup;
3345
+ Prism.languages.mathml = Prism.languages.markup;
3346
+ Prism.languages.svg = Prism.languages.markup;
3347
+
3348
+ Prism.languages.xml = Prism.languages.extend('markup', {});
3349
+ Prism.languages.ssml = Prism.languages.xml;
3350
+ Prism.languages.atom = Prism.languages.xml;
3351
+ Prism.languages.rss = Prism.languages.xml;
3352
+
3353
+ Prism.languages.c = Prism.languages.extend('clike', {
3354
+ 'comment': {
3355
+ pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
3356
+ greedy: true
3357
+ },
3358
+ 'string': {
3359
+ // https://en.cppreference.com/w/c/language/string_literal
3360
+ pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
3361
+ greedy: true
3362
+ },
3363
+ 'class-name': {
3364
+ pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
3365
+ lookbehind: true
3366
+ },
3367
+ 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
3368
+ 'function': /\b[a-z_]\w*(?=\s*\()/i,
3369
+ 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
3370
+ 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
3371
+ });
3372
+
3373
+ Prism.languages.insertBefore('c', 'string', {
3374
+ 'char': {
3375
+ // https://en.cppreference.com/w/c/language/character_constant
3376
+ pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
3377
+ greedy: true
3378
+ }
3379
+ });
3380
+
3381
+ Prism.languages.insertBefore('c', 'string', {
3382
+ 'macro': {
3383
+ // allow for multiline macro definitions
3384
+ // spaces after the # character compile fine with gcc
3385
+ pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
3386
+ lookbehind: true,
3387
+ greedy: true,
3388
+ alias: 'property',
3389
+ inside: {
3390
+ 'string': [
3391
+ {
3392
+ // highlight the path of the include statement as a string
3393
+ pattern: /^(#\s*include\s*)<[^>]+>/,
3394
+ lookbehind: true
3395
+ },
3396
+ Prism.languages.c['string']
3397
+ ],
3398
+ 'char': Prism.languages.c['char'],
3399
+ 'comment': Prism.languages.c['comment'],
3400
+ 'macro-name': [
3401
+ {
3402
+ pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
3403
+ lookbehind: true
3404
+ },
3405
+ {
3406
+ pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
3407
+ lookbehind: true,
3408
+ alias: 'function'
3409
+ }
3410
+ ],
3411
+ // highlight macro directives as keywords
3412
+ 'directive': {
3413
+ pattern: /^(#\s*)[a-z]+/,
3414
+ lookbehind: true,
3415
+ alias: 'keyword'
3416
+ },
3417
+ 'directive-hash': /^#/,
3418
+ 'punctuation': /##|\\(?=[\r\n])/,
3419
+ 'expression': {
3420
+ pattern: /\S[\s\S]*/,
3421
+ inside: Prism.languages.c
3422
+ }
3423
+ }
3424
+ }
3425
+ });
3426
+
3427
+ Prism.languages.insertBefore('c', 'function', {
3428
+ // highlight predefined macros as constants
3429
+ 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
3430
+ });
3431
+
3432
+ delete Prism.languages.c['boolean'];
3433
+
3434
+ (function (Prism) {
3435
+
3436
+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
3437
+
3438
+ Prism.languages.css = {
3439
+ 'comment': /\/\*[\s\S]*?\*\//,
3440
+ 'atrule': {
3441
+ pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
3442
+ inside: {
3443
+ 'rule': /^@[\w-]+/,
3444
+ 'selector-function-argument': {
3445
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
3446
+ lookbehind: true,
3447
+ alias: 'selector'
3448
+ },
3449
+ 'keyword': {
3450
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
3451
+ lookbehind: true
3452
+ }
3453
+ // See rest below
3454
+ }
3455
+ },
3456
+ 'url': {
3457
+ // https://drafts.csswg.org/css-values-3/#urls
3458
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
3459
+ greedy: true,
3460
+ inside: {
3461
+ 'function': /^url/i,
3462
+ 'punctuation': /^\(|\)$/,
3463
+ 'string': {
3464
+ pattern: RegExp('^' + string.source + '$'),
3465
+ alias: 'url'
3466
+ }
3467
+ }
3468
+ },
3469
+ 'selector': {
3470
+ pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
3471
+ lookbehind: true
3472
+ },
3473
+ 'string': {
3474
+ pattern: string,
3475
+ greedy: true
3476
+ },
3477
+ 'property': {
3478
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
3479
+ lookbehind: true
3480
+ },
3481
+ 'important': /!important\b/i,
3482
+ 'function': {
3483
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
3484
+ lookbehind: true
3485
+ },
3486
+ 'punctuation': /[(){};:,]/
3487
+ };
3488
+
3489
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
3490
+
3491
+ var markup = Prism.languages.markup;
3492
+ if (markup) {
3493
+ markup.tag.addInlined('style', 'css');
3494
+ markup.tag.addAttribute('style', 'css');
3495
+ }
3496
+
3497
+ }(Prism));
3498
+
3499
+ (function (Prism) {
3500
+
3501
+ Prism.languages.typescript = Prism.languages.extend('javascript', {
3502
+ 'class-name': {
3503
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
3504
+ lookbehind: true,
3505
+ greedy: true,
3506
+ inside: null // see below
3507
+ },
3508
+ 'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/,
3509
+ });
3510
+
3511
+ // The keywords TypeScript adds to JavaScript
3512
+ Prism.languages.typescript.keyword.push(
3513
+ /\b(?:abstract|declare|is|keyof|readonly|require)\b/,
3514
+ // keywords that have to be followed by an identifier
3515
+ /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
3516
+ // This is for `import type *, {}`
3517
+ /\btype\b(?=\s*(?:[\{*]|$))/
3518
+ );
3519
+
3520
+ // doesn't work with TS because TS is too complex
3521
+ delete Prism.languages.typescript['parameter'];
3522
+ delete Prism.languages.typescript['literal-property'];
3523
+
3524
+ // a version of typescript specifically for highlighting types
3525
+ var typeInside = Prism.languages.extend('typescript', {});
3526
+ delete typeInside['class-name'];
3527
+
3528
+ Prism.languages.typescript['class-name'].inside = typeInside;
3529
+
3530
+ Prism.languages.insertBefore('typescript', 'function', {
3531
+ 'decorator': {
3532
+ pattern: /@[$\w\xA0-\uFFFF]+/,
3533
+ inside: {
3534
+ 'at': {
3535
+ pattern: /^@/,
3536
+ alias: 'operator'
3537
+ },
3538
+ 'function': /^[\s\S]+/
3539
+ }
3540
+ },
3541
+ 'generic-function': {
3542
+ // e.g. foo<T extends "bar" | "baz">( ...
3543
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
3544
+ greedy: true,
3545
+ inside: {
3546
+ 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
3547
+ 'generic': {
3548
+ pattern: /<[\s\S]+/, // everything after the first <
3549
+ alias: 'class-name',
3550
+ inside: typeInside
3551
+ }
3552
+ }
3553
+ }
3554
+ });
3555
+
3556
+ Prism.languages.ts = Prism.languages.typescript;
3557
+
3558
+ }(Prism));
3559
+
3560
+ (function (Prism) {
3561
+
3562
+ var javascript = Prism.util.clone(Prism.languages.javascript);
3563
+
3564
+ var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
3565
+ var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
3566
+ var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
3567
+
3568
+ /**
3569
+ * @param {string} source
3570
+ * @param {string} [flags]
3571
+ */
3572
+ function re(source, flags) {
3573
+ source = source
3574
+ .replace(/<S>/g, function () { return space; })
3575
+ .replace(/<BRACES>/g, function () { return braces; })
3576
+ .replace(/<SPREAD>/g, function () { return spread; });
3577
+ return RegExp(source, flags);
3578
+ }
3579
+
3580
+ spread = re(spread).source;
3581
+
3582
+
3583
+ Prism.languages.jsx = Prism.languages.extend('markup', javascript);
3584
+ Prism.languages.jsx.tag.pattern = re(
3585
+ /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
3586
+ );
3587
+
3588
+ Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/;
3589
+ Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
3590
+ Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
3591
+ Prism.languages.jsx.tag.inside['comment'] = javascript['comment'];
3592
+
3593
+ Prism.languages.insertBefore('inside', 'attr-name', {
3594
+ 'spread': {
3595
+ pattern: re(/<SPREAD>/.source),
3596
+ inside: Prism.languages.jsx
3597
+ }
3598
+ }, Prism.languages.jsx.tag);
3599
+
3600
+ Prism.languages.insertBefore('inside', 'special-attr', {
3601
+ 'script': {
3602
+ // Allow for two levels of nesting
3603
+ pattern: re(/=<BRACES>/.source),
3604
+ alias: 'language-javascript',
3605
+ inside: {
3606
+ 'script-punctuation': {
3607
+ pattern: /^=(?=\{)/,
3608
+ alias: 'punctuation'
3609
+ },
3610
+ rest: Prism.languages.jsx
3611
+ },
3612
+ }
3613
+ }, Prism.languages.jsx.tag);
3614
+
3615
+ // The following will handle plain text inside tags
3616
+ var stringifyToken = function (token) {
3617
+ if (!token) {
3618
+ return '';
3619
+ }
3620
+ if (typeof token === 'string') {
3621
+ return token;
3622
+ }
3623
+ if (typeof token.content === 'string') {
3624
+ return token.content;
3625
+ }
3626
+ return token.content.map(stringifyToken).join('');
3627
+ };
3628
+
3629
+ var walkTokens = function (tokens) {
3630
+ var openedTags = [];
3631
+ for (var i = 0; i < tokens.length; i++) {
3632
+ var token = tokens[i];
3633
+ var notTagNorBrace = false;
3634
+
3635
+ if (typeof token !== 'string') {
3636
+ if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
3637
+ // We found a tag, now find its kind
3638
+
3639
+ if (token.content[0].content[0].content === '</') {
3640
+ // Closing tag
3641
+ if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
3642
+ // Pop matching opening tag
3643
+ openedTags.pop();
3644
+ }
3645
+ } else {
3646
+ if (token.content[token.content.length - 1].content === '/>') ; else {
3647
+ // Opening tag
3648
+ openedTags.push({
3649
+ tagName: stringifyToken(token.content[0].content[1]),
3650
+ openedBraces: 0
3651
+ });
3652
+ }
3653
+ }
3654
+ } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
3655
+
3656
+ // Here we might have entered a JSX context inside a tag
3657
+ openedTags[openedTags.length - 1].openedBraces++;
3658
+
3659
+ } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
3660
+
3661
+ // Here we might have left a JSX context inside a tag
3662
+ openedTags[openedTags.length - 1].openedBraces--;
3663
+
3664
+ } else {
3665
+ notTagNorBrace = true;
3666
+ }
3667
+ }
3668
+ if (notTagNorBrace || typeof token === 'string') {
3669
+ if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
3670
+ // Here we are inside a tag, and not inside a JSX context.
3671
+ // That's plain text: drop any tokens matched.
3672
+ var plainText = stringifyToken(token);
3673
+
3674
+ // And merge text with adjacent text
3675
+ if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
3676
+ plainText += stringifyToken(tokens[i + 1]);
3677
+ tokens.splice(i + 1, 1);
3678
+ }
3679
+ if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
3680
+ plainText = stringifyToken(tokens[i - 1]) + plainText;
3681
+ tokens.splice(i - 1, 1);
3682
+ i--;
3683
+ }
3684
+
3685
+ tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
3686
+ }
3687
+ }
3688
+
3689
+ if (token.content && typeof token.content !== 'string') {
3690
+ walkTokens(token.content);
3691
+ }
3692
+ }
3693
+ };
3694
+
3695
+ Prism.hooks.add('after-tokenize', function (env) {
3696
+ if (env.language !== 'jsx' && env.language !== 'tsx') {
3697
+ return;
3698
+ }
3699
+ walkTokens(env.tokens);
3700
+ });
3701
+
3702
+ }(Prism));
3703
+
3704
+ (function (Prism) {
3705
+ var typescript = Prism.util.clone(Prism.languages.typescript);
3706
+ Prism.languages.tsx = Prism.languages.extend('jsx', typescript);
3707
+
3708
+ // doesn't work with TS because TS is too complex
3709
+ delete Prism.languages.tsx['parameter'];
3710
+ delete Prism.languages.tsx['literal-property'];
3711
+
3712
+ // This will prevent collisions between TSX tags and TS generic types.
3713
+ // Idea by https://github.com/karlhorky
3714
+ // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
3715
+ var tag = Prism.languages.tsx.tag;
3716
+ tag.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + '(?:' + tag.pattern.source + ')', tag.pattern.flags);
3717
+ tag.lookbehind = true;
3718
+ }(Prism));
3719
+
3720
+ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3721
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3722
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3723
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3724
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3725
+ };
3726
+ const presetLanguages = Object.values(codeBlock.CodeLanguage);
3727
+ /**
3728
+ * Processing the code content into different types of nodes.
3729
+ */
3730
+ class CodeHighlightParser extends globalSlimmerRegistry.VegaSlimmer {
3731
+ /**
3732
+ * Split the HTML tag to avoid the content render to a html element.
3733
+ *
3734
+ * @example <div> -> ['<', 'div', '>']
3735
+ * @param {string} text - The code content.
3736
+ * @returns {string[]} - The code content array.
3737
+ */
3738
+ splitTag(text) {
3739
+ if (!this.hasSpecialCharacter(text) || text.length < 2) {
3740
+ return [text];
3741
+ }
3742
+ else {
3743
+ const result = [];
3744
+ const textArray = text.split('');
3745
+ let nextIndex = 0;
3746
+ textArray.forEach((item) => {
3747
+ if (item === '<' || item === '>' || item === '/') {
3748
+ result.push(item);
3749
+ nextIndex = result.length;
3750
+ }
3751
+ else {
3752
+ result[nextIndex] = result[nextIndex] ? result[nextIndex] + item : item;
3753
+ }
3754
+ });
3755
+ return result;
3756
+ }
3757
+ }
3758
+ /**
3759
+ * Check the current language is a preset language and the language is not plain text.
3760
+ *
3761
+ * @param {Nullable<string>} language - The input language.
3762
+ * @returns {boolean} - The boolean result.
3763
+ */
3764
+ isHighlightLanguage(language) {
3765
+ return language !== 'plainText' && presetLanguages.includes(language);
3766
+ }
3767
+ /**
3768
+ * Check the text has special character.
3769
+ *
3770
+ * @param {string} text - The test text.
3771
+ * @returns {boolean} - Return true is the text has <, > , /.
3772
+ */
3773
+ hasSpecialCharacter(text) {
3774
+ return /[<|>|\\/]/.test(text);
3775
+ }
3776
+ }
3777
+ __decorate$1([
3778
+ globalSlimmerRegistry.MapToComponentField()
3779
+ ], CodeHighlightParser.prototype, "value", void 0);
3780
+
3781
+ /**
3782
+ * Use the plugin Prism to highlight the code content.
3783
+ */
3784
+ class PrismCodeHighlightParseController extends CodeHighlightParser {
3785
+ /**
3786
+ * Return true when the content and language are defined.
3787
+ *
3788
+ * @returns {boolean} - Boolean value.
3789
+ */
3790
+ canParse() {
3791
+ const { code, language } = this.value || { code: '' };
3792
+ return code && language && this.isHighlightLanguage(language);
3793
+ }
3794
+ /**
3795
+ * Use plugin to parse the string code into an array of nodes with different keywords.
3796
+ *
3797
+ * @returns {CodeNodeType[]} - The object contains content and highlight type.
3798
+ */
3799
+ parse() {
3800
+ const { code, language } = this.value;
3801
+ let result = [];
3802
+ const parseLanguage = prism.languages[language];
3803
+ const tokens = prism.tokenize(code, parseLanguage);
3804
+ result = this.getHighlightNodes(tokens);
3805
+ let lineNumber = 0;
3806
+ return result.map((node, index) => {
3807
+ let className = node.className;
3808
+ if (index === 0 || result[index - 1].text === '\n') {
3809
+ lineNumber++;
3810
+ className = `v-code-line-number ${node.className}`;
3811
+ }
3812
+ return {
3813
+ text: node.text,
3814
+ key: `${index}`,
3815
+ className,
3816
+ mark: `${lineNumber}`,
3817
+ };
3818
+ });
3819
+ }
3820
+ /**
3821
+ * Parse the plugin parse result to a usable array.
3822
+ *
3823
+ * @param {(string | CodeHighlightToken)[]} tokens - The plugin parse result.
3824
+ * @param {string} [type] - The keywords. Such as variable, function-name, attr-name...
3825
+ * @returns {CodeNodeType[]} - The code node array.
3826
+ */
3827
+ getHighlightNodes(tokens, type) {
3828
+ const nodes = [];
3829
+ for (const token of tokens) {
3830
+ if (typeof token === 'string') {
3831
+ const partials = token.split(/(\n|\t)/);
3832
+ const partialsLength = partials.length;
3833
+ for (let i = 0; i < partialsLength; i++) {
3834
+ const part = partials[i];
3835
+ if (part) {
3836
+ const textArray = this.splitTag(part);
3837
+ nodes.push(...textArray.map((text) => this.createCodeNode(text, type)));
3838
+ }
3839
+ }
3840
+ }
3841
+ else {
3842
+ const { content } = token;
3843
+ if (typeof content === 'string') {
3844
+ nodes.push(...this.getHighlightNodes([content], token.type));
3845
+ }
3846
+ else if (Array.isArray(content)) {
3847
+ nodes.push(...this.getHighlightNodes(content, token.type));
3848
+ }
3849
+ }
3850
+ }
3851
+ return nodes;
3852
+ }
3853
+ /**
3854
+ * Create a CodeNodeType type object by the code content and highlight type.
3855
+ *
3856
+ * @param {string} text - The code content.
3857
+ * @param {string} highlightType - The highlight type.
3858
+ * @returns {CodeNodeType} - The code node object.
3859
+ */
3860
+ createCodeNode(text, highlightType) {
3861
+ return {
3862
+ text,
3863
+ key: '',
3864
+ className: `token ${highlightType || ''}`,
3865
+ mark: '',
3866
+ };
3867
+ }
3868
+ }
3869
+
3870
+ /**
3871
+ * Plain text parse logic.
3872
+ */
3873
+ class DefaultCodeHighlightParseController extends CodeHighlightParser {
3874
+ /**
3875
+ * Default parser will handle if others not catch.
3876
+ *
3877
+ * @returns {boolean} True value.
3878
+ */
3879
+ canParse() {
3880
+ const { code, language } = this.value || { code: '' };
3881
+ return !code || !language || language === 'plainText' || !this.isHighlightLanguage(language);
3882
+ }
3883
+ /**
3884
+ * The default parse will split the html tag and create the line number.
3885
+ *
3886
+ * @returns {CodeNodeType[]} - The code node array.
3887
+ */
3888
+ parse() {
3889
+ var _a, _b;
3890
+ const code = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '';
3891
+ const nodes = code.split('\n');
3892
+ let result = [];
3893
+ nodes.forEach((item, index) => {
3894
+ result = result.concat(this.splitTag(item).map((text, textIndex) => {
3895
+ return {
3896
+ text: text,
3897
+ key: '',
3898
+ mark: `${index + 1}`,
3899
+ className: textIndex === 0 ? 'v-code-line-number' : '',
3900
+ };
3901
+ }));
3902
+ if (index < nodes.length - 1) {
3903
+ result.push({
3904
+ text: '\n',
3905
+ key: `line-break${index}`,
3906
+ className: 'v-code-line-break',
3907
+ mark: `${index + 1}`,
3908
+ });
3909
+ }
3910
+ });
3911
+ result = result.map((item, index) => {
3912
+ return Object.assign(Object.assign({}, item), { key: `${index}` });
3913
+ });
3914
+ return result;
3915
+ }
3916
+ }
3917
+
3918
+ const codeColorVariableCss = ":root{--code-orange:#cd3e00;--code-green:#007e7e;--code-purple:#6851f5;--code-gray:#67727e;--code-neutral:rgb(15, 36, 51);--code-neutral-8:rgba(15, 36, 51, 0.8);--code-neutral-7:rgba(15, 36, 51, 0.7)}.dark{--code-orange:#ff9571;--code-green:#73e6dc;--code-purple:#c7bdff;--code-gray:#8b959f;--code-neutral:rgb(252, 252, 252);--code-neutral-8:rgba(252, 252, 252, 0.8);--code-neutral-7:rgba(252, 252, 252, 0.7)}";
3919
+
3920
+ const vegaCodeBlockCss = ":host{display:block;border-radius:2px;background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));padding-left:12px;padding-right:12px;padding-top:12px;padding-bottom:12px}:host code{display:block;box-sizing:border-box;color:rgba(var(--v-text-primary, 32, 54, 69, 1));text-align:left;font-family:\"Roboto Mono\";font-weight:400;line-height:22px;font-size:16px;white-space:pre-wrap;min-height:22px;tab-size:2px}:host code:focus-visible{outline:none}:host .editor-toolbar{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-bottom:12px;border:1px solid rgba(var(--v-border-divider-secondary, 199, 217, 229, 1));border-top-width:0px;border-left-width:0px;border-right-width:0px;margin-bottom:12px;user-select:none}:host .editor-toolbar vega-input-select{width:auto;min-width:161px}:host(.show-line-number) code .v-code-line-number::before{content:attr(data-mark);width:var(--v-code-line-number-width);margin-left:var(--v-code-line-number-ml);padding-right:16px;text-align:right;user-select:none;font-style:normal;color:rgba(var(--v-text-secondary, 107, 116, 125, 1));display:inline-block}:host(.show-line-number) code{padding-left:var(--v-code-block-pl)}:host::part(select-container){padding-top:0px;padding-bottom:0px;padding-left:8px;padding-right:8px;border-radius:4px}:host::part(selected-box),:host::part(placeholder){font-size:14px;user-select:none}:host::part(toggle-icon-container){width:12px;height:12px;line-height:12px}:host::part(toggle-icon){width:12px;height:12px}:host(.readonly) .copy-button-container{position:relative}:host(.readonly) .copy-button-container .copy-code-button{position:absolute;top:0px;right:0px}:host(.disabled:not(.highlight)) code{color:rgba(var(--v-text-input-disabled, 107, 116, 125, 1))}:host(.disabled.highlight){opacity:0.5}:host(.focus:not(.disabled,.readonly)){outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:0px}:host(.highlight) code{color:var(--code-neutral)}code .comment,code .prolog,code .doctype,code .cdata{color:var(--code-gray);font-style:italic}code .namespace{color:var(--code-neutral-7)}code .string,code .attr-value,code .builtin{color:var(--code-green)}code .punctuation,code .operator,code .attr-equals{color:var(--code-gray)}code .entity,code .url,code .symbol,code .number,code .boolean,code .variable,code .constant,code .property,code .regex,code .inserted{color:var(--code-neutral-8)}code .atrule,code .function,code .attr-name{color:var(--code-orange)}code .deleted{color:var(--code-neutral)}code .function-variable{color:#ff0000}code .tag,code .selector,code .keyword{color:var(--code-purple)}";
3921
+
3922
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3923
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3924
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3925
+ r = Reflect.decorate(decorators, target, key, desc);
3926
+ else
3927
+ for (var i = decorators.length - 1; i >= 0; i--)
3928
+ if (d = decorators[i])
3929
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3930
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3931
+ };
3932
+ const VegaCodeBlock = class {
3933
+ constructor(hostRef) {
3934
+ index.registerInstance(this, hostRef);
3935
+ this.vegaChange = index.createEvent(this, "vegaChange", 7);
3936
+ this.change = index.createEvent(this, "change", 7);
3937
+ this.vegaRemove = index.createEvent(this, "vegaRemove", 7);
3938
+ this.remove = index.createEvent(this, "remove", 7);
3939
+ this.globalSlimmers = {};
3940
+ //TODO: The global style should be removed after the code color change to the color token.
3941
+ this.componentGlobalStyleSlimmer = new componentGlobalStyleSlimmer.ComponentGlobalStyleSlimmer(codeColorVariableCss);
3942
+ this.translationSlimmer = new translationSlimmer.TranslationSlimmer();
3943
+ this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
3944
+ this.codeBlockRenderer = new VegaCodeBlockRenderer();
3945
+ this.contentRenderer = new VegaCodeBlockContentRenderer();
3946
+ this.copyButtonRenderer = new VegaCodeBlockCopyButtonRenderer();
3947
+ this.valueController = new VegaCodeBlockValueController();
3948
+ this.contentParseController = new CodeContentParseController();
3949
+ this.prismCodeHighlightParser = new PrismCodeHighlightParseController();
3950
+ this.defaultCodeHighlightParser = new DefaultCodeHighlightParseController();
3951
+ this.selectionController = new VegaCodeBlockSelectionController();
3952
+ this.inputController = new CodeBlockInputController();
3953
+ this.focusController = new VegaCodeBlockFocusController();
3954
+ this.changeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaCodeBlock, domNodeSubjectFactory.VegaChange);
3955
+ this.removeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaCodeBlock, domNodeSubjectFactory.VegaRemove);
3956
+ this.eventPreventSlimmer = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([domNodeSubjectFactory.VegaChange], () => this.codeBlockRenderer.getToolbarContainerRef());
3957
+ /**
3958
+ * Specifies whether the code block editor is in read-only mode.
3959
+ *
3960
+ * @vegaVersion 2.50.0-RTE-preview
3961
+ */
3962
+ this.readOnly = false;
3963
+ /**
3964
+ * Specifies whether the code block editor is disabled.
3965
+ *
3966
+ * @vegaVersion 2.50.0-RTE-preview
3967
+ */
3968
+ this.disabled = false;
3969
+ /**
3970
+ * Specifies whether to display the copy button in the code block.
3971
+ *
3972
+ * @vegaVersion 2.50.0-RTE-preview
3973
+ */
3974
+ this.showCopyButton = true;
3975
+ /**
3976
+ * Specifies whether to display the code line number in the code block.
3977
+ *
3978
+ * @vegaVersion 2.50.0-RTE-preview
3979
+ */
3980
+ this.showLineNumber = true;
3981
+ }
3982
+ watchEditableChange() {
3983
+ }
3984
+ /**
3985
+ * Check the props value to avoid unnecessary updates.
3986
+ *
3987
+ * @param {unknown} newValue - The new props value.
3988
+ * @param {unknown} oldValue - The old props value.
3989
+ * @param {string} name - The property name.
3990
+ * @returns {boolean} Return false to skip the current update flow.
3991
+ */
3992
+ componentShouldUpdate(newValue, oldValue, name) {
3993
+ if (name === 'value' && object.deepEqual(newValue, oldValue)) {
3994
+ return false;
3995
+ }
3996
+ return true;
3997
+ }
3998
+ /**
3999
+ * Invoke this method to focus the current code block.
4000
+ *
4001
+ * @vegaVersion 2.50.0-RTE-preview
4002
+ */
4003
+ async doFocus() {
4004
+ }
4005
+ render() {
4006
+ const classNames = ui.arrayToClassString([
4007
+ this.readOnly ? 'readonly' : '',
4008
+ this.disabled ? 'disabled' : '',
4009
+ this.showLineNumber ? 'show-line-number' : '',
4010
+ this.prismCodeHighlightParser.canParse() ? 'highlight' : '',
4011
+ ]);
4012
+ return component.sanitizeVegaComponent(index.h(index.Host, { contenteditable: false, class: classNames }, this.codeBlockRenderer.render()), this.host);
4013
+ }
4014
+ get host() { return index.getElement(this); }
4015
+ static get watchers() { return {
4016
+ "readOnly": ["watchEditableChange"],
4017
+ "disabled": ["watchEditableChange"]
4018
+ }; }
4019
+ };
4020
+ __decorate([
4021
+ componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
4022
+ ], VegaCodeBlock.prototype, "globalSlimmers", void 0);
4023
+ __decorate([
4024
+ globalSlimmerRegistry.InjectVegaSlimmer()
4025
+ ], VegaCodeBlock.prototype, "componentGlobalStyleSlimmer", void 0);
4026
+ __decorate([
4027
+ globalSlimmerRegistry.InjectVegaSlimmer()
4028
+ ], VegaCodeBlock.prototype, "translationSlimmer", void 0);
4029
+ __decorate([
4030
+ globalSlimmerRegistry.InjectVegaSlimmer()
4031
+ ], VegaCodeBlock.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
4032
+ __decorate([
4033
+ globalSlimmerRegistry.InjectVegaSlimmer()
4034
+ ], VegaCodeBlock.prototype, "codeBlockRenderer", void 0);
4035
+ __decorate([
4036
+ globalSlimmerRegistry.InjectVegaSlimmer()
4037
+ ], VegaCodeBlock.prototype, "contentRenderer", void 0);
4038
+ __decorate([
4039
+ globalSlimmerRegistry.InjectVegaSlimmer()
4040
+ ], VegaCodeBlock.prototype, "copyButtonRenderer", void 0);
4041
+ __decorate([
4042
+ globalSlimmerRegistry.InjectVegaSlimmer()
4043
+ ], VegaCodeBlock.prototype, "valueController", void 0);
4044
+ __decorate([
4045
+ globalSlimmerRegistry.InjectVegaSlimmer()
4046
+ ], VegaCodeBlock.prototype, "contentParseController", void 0);
4047
+ __decorate([
4048
+ globalSlimmerRegistry.InjectVegaSlimmer()
4049
+ ], VegaCodeBlock.prototype, "prismCodeHighlightParser", void 0);
4050
+ __decorate([
4051
+ globalSlimmerRegistry.InjectVegaSlimmer()
4052
+ ], VegaCodeBlock.prototype, "defaultCodeHighlightParser", void 0);
4053
+ __decorate([
4054
+ globalSlimmerRegistry.InjectVegaSlimmer()
4055
+ ], VegaCodeBlock.prototype, "selectionController", void 0);
4056
+ __decorate([
4057
+ globalSlimmerRegistry.InjectVegaSlimmer()
4058
+ ], VegaCodeBlock.prototype, "inputController", void 0);
4059
+ __decorate([
4060
+ globalSlimmerRegistry.InjectVegaSlimmer()
4061
+ ], VegaCodeBlock.prototype, "focusController", void 0);
4062
+ __decorate([
4063
+ globalSlimmerRegistry.InjectVegaSlimmer()
4064
+ ], VegaCodeBlock.prototype, "changeEventEmitter", void 0);
4065
+ __decorate([
4066
+ globalSlimmerRegistry.InjectVegaSlimmer()
4067
+ ], VegaCodeBlock.prototype, "removeEventEmitter", void 0);
4068
+ __decorate([
4069
+ globalSlimmerRegistry.InjectVegaSlimmer()
4070
+ ], VegaCodeBlock.prototype, "eventPreventSlimmer", void 0);
4071
+ VegaCodeBlock.style = vegaCodeBlockCss;
4072
+
4073
+ exports.vega_code_block = VegaCodeBlock;