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