@globalpayments/vega 2.33.0 → 2.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
- package/dist/cjs/{app-globals-d28dd560.js → app-globals-4e819773.js} +31 -22
- package/dist/cjs/block-annotation.abstract-4d88b939.js +875 -0
- package/dist/cjs/{breakpoints-7e2dff90.js → breakpoints-17d6c4c7.js} +2 -13
- package/dist/cjs/breakpoints-ebde4837.js +14 -0
- package/dist/cjs/{change-manager-a297e4d2.js → change-manager-bda1d107.js} +1 -1
- package/dist/cjs/{chevron-down-ca2fa88e.js → chevron-down-9847bf78.js} +0 -5
- package/dist/cjs/chevron-up-21465cf7.js +7 -0
- package/dist/cjs/{child-nodes-event-prevent-slimmer-f07a8fe9.js → child-nodes-event-prevent-slimmer-e1a6e5ad.js} +3 -3
- package/dist/cjs/{child-nodes-notify-observer-slimmer-79f2f5a7.js → child-nodes-notify-observer-slimmer-03a3f79e.js} +5 -5
- package/dist/cjs/{component-73a88c4e.js → component-63af66ea.js} +1 -1
- package/dist/cjs/{component-global-style-slimmer-6749808c.js → component-global-style-slimmer-6b64a26c.js} +1 -1
- package/dist/cjs/{component-usage-runtime-metrics-1ee24991.js → component-usage-runtime-metrics-019d3c00.js} +2 -2
- package/dist/cjs/content-state-3a2724f6.js +2184 -0
- package/dist/cjs/{create-public-api-runtime-metrics-slimmer-5cc88124.js → create-public-api-runtime-metrics-slimmer-8c6a8fb7.js} +3 -3
- package/dist/cjs/{date-0a6bb035.js → date-ffe382a4.js} +1 -1
- package/dist/cjs/{deprecated-property-slimmer-fc729fd9.js → deprecated-property-slimmer-f36e3779.js} +2 -2
- package/dist/cjs/{design-token-92906579.js → design-token-908e3f69.js} +5 -5
- package/dist/cjs/{vega-event-id-81270f6a.js → dom-node-subject-observer-factory-093462f1.js} +170 -0
- package/dist/cjs/{dynamic-slimmer-f31fdfd7.js → dynamic-slimmer-dc30600a.js} +1 -1
- package/dist/cjs/{element-appender-slimmer-415d261a.js → element-appender-slimmer-0dd70e61.js} +17 -10
- package/dist/cjs/{event-emit-slimmer-83278943.js → event-emit-slimmer-a46bb411.js} +5 -5
- package/dist/cjs/{feature-flag-controller-0d1015fa.js → feature-flag-controller-e97b5f29.js} +3 -3
- package/dist/cjs/{form-field-controller-slimmer-2a982ead.js → form-field-controller-slimmer-9aeabcdc.js} +16 -17
- package/dist/cjs/{index-09acd3c9.js → global-slimmer-registry-dd2691b8.js} +296 -274
- package/dist/cjs/{icon-manager-3787af39.js → icon-manager-36dcfb65.js} +2 -2
- package/dist/cjs/index-8b247c17.js +325 -0
- package/dist/cjs/index.cjs.js +37 -30
- package/dist/cjs/{inject-keyboard-manager-e79a1ade.js → inject-keyboard-manager-af37c861.js} +1 -1
- package/dist/cjs/{internal-icon-manager-2ff58050.js → internal-icon-manager-2282a62f.js} +1 -1
- package/dist/cjs/{internal-vega-event-manager-5fe83465.js → internal-vega-event-manager-d7643ec6.js} +72 -68
- package/dist/cjs/{internal-vega-z-index-manager-f03ddb37.js → internal-vega-z-index-manager-e24e4309.js} +1 -1
- package/dist/cjs/{keyboard-manager-34b78600.js → keyboard-manager-5afbc8f1.js} +1 -1
- package/dist/cjs/{keyboard-manager-slimmer-8e2d4b5d.js → keyboard-manager-slimmer-9be2a880.js} +2 -2
- package/dist/cjs/loader.cjs.js +28 -23
- package/dist/cjs/{mutation-observer-slimmer-895b3d3e.js → mutation-observer-slimmer-98bbbdf0.js} +1 -1
- package/dist/cjs/{vega-skeleton-loader-controller-4a1eedcd.js → node.abstract-f8075f84.js} +234 -840
- package/dist/cjs/{page-resize-observer-slimmer-a8cf1874.js → page-resize-observer-slimmer-e54fa9d4.js} +2 -2
- package/dist/cjs/{remote-invocation-registry-32aaf6c2.js → remote-invocation-registry-71a45468.js} +4 -4
- package/dist/cjs/{required-field-rule-9a57b1a0.js → required-field-rule-7f9945fa.js} +2 -1
- package/dist/cjs/{responsive-format-facade-ad2f67bf.js → responsive-format-facade-74079f1b.js} +3 -3
- package/dist/cjs/{state-background-color-formatter-418b84e6.js → state-background-color-formatter-d32a1098.js} +2 -2
- package/dist/cjs/{static-subject-title-471e1793.js → static-subject-title-d66b88fb.js} +2 -0
- package/dist/cjs/{string-input-formatter-slimmer-79272527.js → string-input-formatter-slimmer-297765c0.js} +2 -2
- package/dist/cjs/{style-formatter-68f3a5f8.js → style-formatter-5deb065f.js} +2 -2
- package/dist/cjs/{sub-state-notify-slimmer-13f1892b.js → sub-state-notify-slimmer-73201c53.js} +6 -7
- package/dist/cjs/{sub-state-observer-slimmer-6c0b635d.js → sub-state-observer-slimmer-10c0d402.js} +6 -7
- package/dist/cjs/{synchronize-task-queue-8977cf10.js → synchronize-task-queue-1ee80e94.js} +10 -1
- package/dist/cjs/text-color-toolbar-button-slimmer-b1c9f40e.js +210 -0
- package/dist/cjs/text-node-0d12da5a.js +1077 -0
- package/dist/cjs/{translation-42c1b2c8.js → translation-f6b7ee84.js} +4 -4
- package/dist/cjs/{translation-slimmer-32aa13e7.js → translation-slimmer-90f9f71f.js} +2 -2
- package/dist/cjs/trash-can-46a5e19a.js +7 -0
- package/dist/cjs/{type-guard-a07b353b.js → type-guard-4ba85fdc.js} +18 -18
- package/dist/cjs/{ui-08f33116.js → ui-b5906704.js} +20 -1
- package/dist/cjs/vega-accordion.cjs.entry.js +46 -47
- package/dist/cjs/vega-app-footer.cjs.entry.js +12 -13
- package/dist/cjs/vega-app-header-button.cjs.entry.js +48 -48
- package/dist/cjs/vega-backdrop.cjs.entry.js +8 -9
- package/dist/cjs/vega-banner.cjs.entry.js +36 -38
- package/dist/cjs/vega-bar-chart.cjs.entry.js +5 -6
- package/dist/cjs/vega-box.cjs.entry.js +15 -15
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +34 -36
- package/dist/cjs/vega-button-circle.cjs.entry.js +29 -30
- package/dist/cjs/vega-button-group_2.cjs.entry.js +32 -34
- package/dist/cjs/vega-button-link.cjs.entry.js +26 -28
- package/dist/cjs/vega-button.cjs.entry.js +30 -31
- package/dist/cjs/vega-calendar_3.cjs.entry.js +139 -140
- package/dist/cjs/vega-card.cjs.entry.js +13 -13
- package/dist/cjs/vega-carousel.cjs.entry.js +27 -29
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +49 -50
- package/dist/cjs/vega-chip.cjs.entry.js +39 -40
- package/dist/cjs/vega-color-picker.cjs.entry.js +29 -31
- package/dist/cjs/vega-combo-box.cjs.entry.js +52 -53
- package/dist/cjs/vega-counter-badge.cjs.entry.js +9 -10
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +62 -62
- package/dist/cjs/{vega-dialog-controller-dce8cdaf.js → vega-dialog-controller-aaf1f43e.js} +2 -2
- package/dist/cjs/vega-dialog_2.cjs.entry.js +50 -51
- package/dist/cjs/vega-divider.cjs.entry.js +13 -13
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +133 -134
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-field-error.cjs.entry.js +8 -9
- package/dist/cjs/vega-field-label.cjs.entry.js +20 -23
- package/dist/cjs/vega-file-uploader.cjs.entry.js +76 -81
- package/dist/cjs/vega-flex.cjs.entry.js +18 -17
- package/dist/cjs/vega-font.cjs.entry.js +16 -16
- package/dist/cjs/vega-form.cjs.entry.js +41 -42
- package/dist/cjs/vega-grid.cjs.entry.js +13 -13
- package/dist/cjs/vega-hint.cjs.entry.js +6 -7
- package/dist/cjs/vega-icon.cjs.entry.js +18 -18
- package/dist/cjs/vega-image-uploader.cjs.entry.js +57 -58
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +42 -43
- package/dist/cjs/vega-input-numeric.cjs.entry.js +35 -36
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +51 -52
- package/dist/cjs/vega-input-range.cjs.entry.js +44 -45
- package/dist/cjs/vega-input-select.cjs.entry.js +71 -71
- package/dist/cjs/vega-input.cjs.entry.js +50 -52
- package/dist/cjs/{vega-internal-event-id-79be9bc5.js → vega-internal-event-id-85b68849.js} +12 -0
- package/dist/cjs/vega-item-toggle.cjs.entry.js +19 -22
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +107 -107
- package/dist/cjs/vega-line-chart.cjs.entry.js +6 -7
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +18 -18
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +18 -21
- package/dist/cjs/vega-pagination.cjs.entry.js +53 -55
- package/dist/cjs/vega-pie-chart.cjs.entry.js +6 -7
- package/dist/cjs/vega-popover_2.cjs.entry.js +72 -37
- package/dist/cjs/vega-progress-tracker.cjs.entry.js +27 -30
- package/dist/cjs/vega-radio_2.cjs.entry.js +53 -54
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +179 -0
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +4894 -0
- package/dist/cjs/vega-section-title.cjs.entry.js +14 -15
- package/dist/cjs/vega-segment-control.cjs.entry.js +24 -26
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +53 -54
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +64 -65
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +48 -50
- package/dist/cjs/vega-signature-capture.cjs.entry.js +44 -46
- package/dist/cjs/vega-skeleton.cjs.entry.js +25 -26
- package/dist/cjs/vega-slot-container.cjs.entry.js +5 -6
- package/dist/cjs/vega-stepper.cjs.entry.js +38 -39
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +58 -59
- package/dist/cjs/vega-table_8.cjs.entry.js +183 -183
- package/dist/cjs/vega-text.cjs.entry.js +10 -10
- package/dist/cjs/vega-textarea.cjs.entry.js +39 -40
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +88 -89
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +25 -27
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +22 -22
- package/dist/cjs/vega.cjs.js +28 -23
- package/dist/collection/collection-manifest.json +18 -0
- package/dist/collection/components/vega-file-uploader/vega-file-uploader.js +2 -2
- package/dist/collection/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.js +42 -4
- package/dist/collection/components/vega-rich-text-content/slimmers/controllers/vega-rich-text-content-state-controller.js +38 -0
- package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +59 -0
- package/dist/collection/components/vega-rich-text-content/vega-rich-text-content.css +132 -0
- package/dist/collection/components/vega-rich-text-content/vega-rich-text-content.js +124 -0
- package/dist/collection/components/vega-rich-text-editor/assets/align-center.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/align-justify.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/align-left.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/align-right.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/bold.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/code-simple.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/image.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/indent.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/italic.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/link.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/list-ol.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/list-ul.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/outdent.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/strikethrough.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/text-size.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/text-slash.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/text.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/assets/underline.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/constants/constant.js +33 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/annotation-action.abstract.js +5 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/append-child-nodes-action.js +9 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/bold-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/break-single-block-action.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/clear-child-nodes-action.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/clear-formatting-annotation-action.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/code-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/delete-block-content-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/delete-node-annotation-action.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/horizontal-alignment-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/image-annotation-action.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/indent-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/insert-blocks-after-block.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/insert-blocks-before-block.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/insert-image-to-block-action.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/insert-nodes-after-node-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/insert-nodes-before-node-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/italic-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/line-break-multiple-block-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/line-break-single-block-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/link-annotation-action.js +26 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/link-group-annotation-action.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/merge-two-blocks-nodes-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.js +32 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/remove-child-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/remove-nest-list-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/replace-child-nodes-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/replace-nest-list-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/replace-selected-text-action.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/selection-change-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/split-block-with-node-action.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/splittable-action.abstract.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/strikethrough-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/sync-up-selection-action.js +18 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/text-color-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/text-style-annotation-action.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/transform-list-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/transform-paragraph-action.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/underline-annotation-action.js +20 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/update-text-action.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/annotation.abstract.js +11 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/block-annotation.abstract.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/bold-annotation.js +48 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/clear-formatting-annotation.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/code-annotation.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.js +90 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/image-annotation.js +66 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/indent-annotation.js +78 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/italic-annotation.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-annotation.js +62 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-group-annotation.js +102 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/node-annotation.abstract.js +18 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/selection-range-annotation.js +11 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.js +57 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-color-annotation.js +85 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-style-annotation.js +105 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/underline-annotation.js +57 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +354 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +260 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +189 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +236 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +424 -0
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +135 -0
- package/dist/collection/components/vega-rich-text-editor/dto/helper/block-base-operator.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +103 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/node.abstract.js +103 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +297 -0
- package/dist/collection/components/vega-rich-text-editor/dto/range.js +178 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/focus-controller.js +73 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-handler.abstract.js +135 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-processor.js +74 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/image-to-dto-handler.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/inline-block-to-dto-handler.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/link-to-dto-handler.js +50 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-item-to-dto-handler.js +41 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-to-dto-handler.js +57 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/paragraph-to-dto-handler.js +56 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-block-to-dto-handler.js +77 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-to-dto-handler.js +44 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/base-handler.js +191 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/delete-content-handler.js +108 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-line-break-handler.js +100 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paragraph-handler.js +90 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.js +91 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-text-handler.js +93 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/insert-image-controller.js +117 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/rich-text-content-controller.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/selection-controller.js +294 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/state-entity-rendering-registry.js +38 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/text-node-color-controller.js +51 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/text-node-rendering-registry.js +26 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.js +201 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/value-controller.js +91 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/toolbar-renderer.js +97 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.js +51 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.js +70 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.js +70 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.js +68 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.js +46 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/code-toolbar-button-slimmer.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/center-align-toolbar-button-slimmer.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.js +77 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/justify-align-toolbar-button-slimmer.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/left-align-toolbar-button-slimmer.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/right-align-toolbar-button-slimmer.js +47 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.js +72 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.js +49 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.js +46 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.js +97 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.js +45 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.js +52 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.js +129 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.js +128 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/toolbar-button-slimmer.abstract.js +62 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.js +52 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-renderer.js +126 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/annotation-actions.test.js +38 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/annotations.test.js +134 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/image-block.test.js +90 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/list-block.test.js +224 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/list-item.test.js +228 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/text-block.test.js +173 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/content-state.test.js +172 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/image-node.test.js +93 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/text-node.test.js +433 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/range.test.js +53 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor-toolbar-button/slimmers/renderers/vega-rich-text-editor-toolbar-button-renderer.js +57 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor-toolbar-button/vega-rich-text-editor-toolbar-button.css +50 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor-toolbar-button/vega-rich-text-editor-toolbar-button.js +246 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.css +264 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +676 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-image-editor/slimmers/renderers/vega-rich-text-image-editor-renderer.js +133 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-image-editor/vega-rich-text-image-editor.css +13 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-image-editor/vega-rich-text-image-editor.js +165 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-link-editor/slimmers/renderers/vega-rich-text-link-editor-renderer.js +144 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-link-editor/vega-rich-text-link-editor.css +11 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-link-editor/vega-rich-text-link-editor.js +247 -0
- package/dist/collection/constants/ui.js +1 -0
- package/dist/collection/global/scripts/before-vega-load.js +9 -1
- package/dist/collection/helpers/change-manager/subject/static-subject/static-subject-title.js +1 -0
- package/dist/collection/helpers/common/index.js +27 -0
- package/dist/collection/helpers/common/test/wait-for-vega-handler.test.js +1 -1
- package/dist/collection/helpers/dialog/test/vega-dialog-controller.test.js +1 -1
- package/dist/collection/helpers/event-manager/event-id/component-event-id-map.js +5 -1
- package/dist/collection/helpers/event-manager/event-id/vega-event-id.js +1 -0
- package/dist/collection/helpers/event-manager/event-id/vega-internal-event-id.js +6 -0
- package/dist/collection/helpers/event-manager/test/vega-event-manager.test.js +1 -1
- package/dist/collection/helpers/feature-control/feature-flag-controller.js +1 -1
- package/dist/collection/helpers/feature-control/tests/feature-flag-controller.test.js +1 -1
- package/dist/collection/helpers/icon/test/icon-manager-controller.test.js +1 -1
- package/dist/collection/helpers/loading-indicator/tests/vega-loader-controller.test.js +1 -1
- package/dist/collection/helpers/notify/tests/vega-notify-controller.test.js +1 -1
- package/dist/collection/helpers/public-api.js +1 -0
- package/dist/collection/helpers/queue/synchronize-task-queue.js +10 -1
- package/dist/collection/helpers/queue/test/synchronize-task-queue.test.js +28 -0
- package/dist/collection/helpers/skeleton-loader/tests/vega-skeleton-loader-controller.test.js +1 -1
- package/dist/collection/helpers/slimmers/component-usage-runtime-metrics.js +1 -1
- package/dist/collection/helpers/slimmers/dark-mode-state-controller-slimmer.js +46 -0
- package/dist/collection/helpers/slimmers/element-appender-slimmer.js +10 -3
- package/dist/collection/helpers/slimmers/runtime-metrics/public-api-runtime-metrics-slimmer-base.js +1 -1
- package/dist/collection/helpers/slimmers/runtime-metrics/test/public-api-runtime-metrics-slimmer-base.test.js +1 -1
- package/dist/collection/helpers/slimmers/test/component-usage-runtime-metrics.test.js +1 -1
- package/dist/collection/helpers/slimmers/test/dark-mode-state-controller.test.js +65 -0
- package/dist/collection/helpers/theme/controllers/dark-mode-style-controller.js +45 -3
- package/dist/collection/helpers/theme/tests/theme-manager-controller.test.js +2 -2
- package/dist/collection/helpers/theme/theme-manager.js +3 -0
- package/dist/collection/helpers/validator/rules/{file-uploader-required-rule.js → object-array-required-rule.js} +3 -3
- package/dist/collection/helpers/validator/rules/required-field-rule.js +2 -1
- package/dist/collection/helpers/validator/rules/rich-text-editor-required-rule.js +57 -0
- package/dist/collection/helpers/validator/test/rules/object-array-required-rule.test.js +7 -0
- package/dist/collection/helpers/validator/test/rules/required-field-rule.test.js +11 -0
- package/dist/collection/helpers/validator/test/rules/rich-text-editor-required-rule.test.js +317 -0
- package/dist/collection/helpers/zindex/test/vega-z-index-manager.test.js +1 -1
- package/dist/collection/polyfill/shadow-selection/shadow-selection-polyfill.js +164 -0
- package/dist/collection/polyfill/shadow-selection/test/shadow-selection-polyfill.test.js +233 -0
- package/dist/collection/polyfill/test-polyfill/unit/index.js +1 -0
- package/dist/collection/polyfill/test-polyfill/unit/methods.js +9 -0
- package/dist/collection/polyfill/test-polyfill/unit/range.js +15 -0
- package/dist/collection/polyfill/test-polyfill/unit/shadow-selection.js +17 -0
- package/dist/collection/utils/spec-utils.js +2 -1
- package/dist/collection/utils/test/ui.test.js +6 -1
- package/dist/collection/utils/ui.js +18 -0
- package/dist/collection/value-model-adapters/angular-ng-model-accessor-adapter.js +1 -0
- package/dist/collection/value-model-adapters/vue-component-v-model-adaptor.js +1 -0
- package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
- package/dist/esm/{app-globals-c018477a.js → app-globals-9971ccfd.js} +22 -13
- package/dist/esm/block-annotation.abstract-b0554e2b.js +868 -0
- package/dist/esm/{breakpoints-36a3ed69.js → breakpoints-91116111.js} +2 -12
- package/dist/esm/breakpoints-d9faf11c.js +12 -0
- package/dist/esm/{change-manager-6a7eb88c.js → change-manager-8f5b72c2.js} +1 -1
- package/dist/esm/chevron-down-4a75d28e.js +5 -0
- package/dist/esm/chevron-up-b1989751.js +5 -0
- package/dist/esm/{child-nodes-event-prevent-slimmer-8de7e3bb.js → child-nodes-event-prevent-slimmer-8ceabe63.js} +3 -3
- package/dist/esm/{child-nodes-notify-observer-slimmer-3d52b843.js → child-nodes-notify-observer-slimmer-afc15e00.js} +4 -4
- package/dist/esm/{component-cae24190.js → component-051a594c.js} +1 -1
- package/dist/esm/{component-global-style-slimmer-000e0c11.js → component-global-style-slimmer-631f956f.js} +1 -1
- package/dist/esm/{component-usage-runtime-metrics-b3f6ac79.js → component-usage-runtime-metrics-21813c36.js} +2 -2
- package/dist/esm/content-state-acf55eb0.js +2164 -0
- package/dist/esm/{create-public-api-runtime-metrics-slimmer-cc1164bb.js → create-public-api-runtime-metrics-slimmer-14cb4599.js} +3 -3
- package/dist/esm/{date-732bc749.js → date-655c0af8.js} +1 -1
- package/dist/esm/{deprecated-property-slimmer-43d184b3.js → deprecated-property-slimmer-9ea5019c.js} +2 -2
- package/dist/esm/{design-token-2a527af3.js → design-token-20fdba82.js} +6 -6
- package/dist/esm/dom-node-subject-observer-factory-80358591.js +269 -0
- package/dist/esm/{dynamic-slimmer-90b8af32.js → dynamic-slimmer-85746483.js} +1 -1
- package/dist/esm/{element-appender-slimmer-48d826b2.js → element-appender-slimmer-4dfa326d.js} +17 -10
- package/dist/esm/{event-emit-slimmer-493e6b9d.js → event-emit-slimmer-c03cf145.js} +5 -5
- package/dist/esm/{feature-flag-controller-6bbf53c1.js → feature-flag-controller-dfde0cfa.js} +3 -3
- package/dist/esm/{form-field-controller-slimmer-88492678.js → form-field-controller-slimmer-de5fe574.js} +11 -12
- package/dist/esm/{index-187f71d1.js → global-slimmer-registry-6887a59f.js} +284 -275
- package/dist/esm/{icon-manager-1ee2c968.js → icon-manager-3cef32e7.js} +2 -2
- package/dist/esm/index-44c794b4.js +323 -0
- package/dist/esm/index.js +29 -23
- package/dist/esm/{inject-keyboard-manager-8a82e8c9.js → inject-keyboard-manager-45309420.js} +1 -1
- package/dist/esm/{internal-icon-manager-7004584d.js → internal-icon-manager-7fc7535a.js} +1 -1
- package/dist/esm/{internal-vega-event-manager-48ac30f1.js → internal-vega-event-manager-3a3815d3.js} +6 -2
- package/dist/esm/{internal-vega-z-index-manager-7d2b54c3.js → internal-vega-z-index-manager-89e8b6f5.js} +1 -1
- package/dist/esm/{keyboard-manager-d1f9ddc1.js → keyboard-manager-2c06eafe.js} +1 -1
- package/dist/esm/{keyboard-manager-slimmer-8723f20f.js → keyboard-manager-slimmer-fd177285.js} +2 -2
- package/dist/esm/{legend-input-processor-0cef3ebe.js → legend-input-processor-15939912.js} +1 -1
- package/dist/esm/loader.js +28 -23
- package/dist/esm/{mutation-observer-slimmer-6cef9549.js → mutation-observer-slimmer-ca2cb2e8.js} +1 -1
- package/dist/esm/{vega-skeleton-loader-controller-1911558d.js → node.abstract-93746055.js} +226 -833
- package/dist/esm/{page-resize-observer-slimmer-994c1e1b.js → page-resize-observer-slimmer-8589ebc8.js} +2 -2
- package/dist/esm/{remote-invocation-registry-1682b34e.js → remote-invocation-registry-2ec6936d.js} +2 -2
- package/dist/esm/{required-field-rule-5da360cc.js → required-field-rule-368b31fa.js} +2 -1
- package/dist/esm/{responsive-format-facade-3dc84e41.js → responsive-format-facade-559ec469.js} +3 -3
- package/dist/esm/{state-background-color-formatter-0540d006.js → state-background-color-formatter-16031a43.js} +2 -2
- package/dist/esm/{static-subject-title-500cf2a3.js → static-subject-title-e06a3840.js} +2 -1
- package/dist/esm/{string-input-formatter-slimmer-fc23bc9f.js → string-input-formatter-slimmer-c9fb1fa1.js} +2 -2
- package/dist/esm/{style-formatter-ccb2da0d.js → style-formatter-51845b6d.js} +2 -2
- package/dist/esm/{sub-state-notify-slimmer-21b1c646.js → sub-state-notify-slimmer-6e97a58a.js} +5 -6
- package/dist/esm/{sub-state-observer-slimmer-8c80d874.js → sub-state-observer-slimmer-0968ce04.js} +5 -6
- package/dist/esm/{synchronize-task-queue-8f5fbbd9.js → synchronize-task-queue-ac8acc3b.js} +10 -1
- package/dist/esm/text-color-toolbar-button-slimmer-d0255b98.js +207 -0
- package/dist/esm/text-node-6f7d736c.js +1055 -0
- package/dist/esm/{translation-4eb3cf85.js → translation-b3fe8e74.js} +4 -4
- package/dist/esm/{translation-slimmer-9d07a0ff.js → translation-slimmer-860cd766.js} +2 -2
- package/dist/esm/trash-can-8819a939.js +5 -0
- package/dist/esm/{type-guard-63caf78b.js → type-guard-158f6d7a.js} +20 -20
- package/dist/esm/{typography-a8fc4764.js → typography-396de03f.js} +1 -1
- package/dist/esm/{ui-0132dbb5.js → ui-5600b48f.js} +20 -2
- package/dist/esm/vega-accordion.entry.js +22 -23
- package/dist/esm/vega-app-footer.entry.js +3 -4
- package/dist/esm/vega-app-header-button.entry.js +26 -26
- package/dist/esm/vega-backdrop.entry.js +4 -5
- package/dist/esm/vega-banner.entry.js +15 -17
- package/dist/esm/vega-bar-chart.entry.js +5 -6
- package/dist/esm/vega-box.entry.js +13 -13
- package/dist/esm/vega-breadcrumb.entry.js +13 -15
- package/dist/esm/vega-button-circle.entry.js +21 -22
- package/dist/esm/vega-button-group_2.entry.js +16 -18
- package/dist/esm/vega-button-link.entry.js +13 -15
- package/dist/esm/vega-button.entry.js +20 -21
- package/dist/esm/vega-calendar_3.entry.js +29 -30
- package/dist/esm/vega-card.entry.js +11 -11
- package/dist/esm/vega-carousel.entry.js +17 -19
- package/dist/esm/vega-checkbox_2.entry.js +24 -25
- package/dist/esm/vega-chip.entry.js +21 -22
- package/dist/esm/vega-color-picker.entry.js +19 -21
- package/dist/esm/vega-combo-box.entry.js +27 -28
- package/dist/esm/vega-counter-badge.entry.js +3 -4
- package/dist/esm/vega-date-picker_2.entry.js +37 -37
- package/dist/esm/{vega-dialog-controller-8b343a17.js → vega-dialog-controller-5b23f68c.js} +2 -2
- package/dist/esm/vega-dialog_2.entry.js +24 -25
- package/dist/esm/vega-divider.entry.js +11 -11
- package/dist/esm/vega-dropdown_5.entry.js +33 -34
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-field-error.entry.js +5 -6
- package/dist/esm/vega-field-label.entry.js +9 -12
- package/dist/esm/vega-file-uploader.entry.js +27 -32
- package/dist/esm/vega-flex.entry.js +16 -15
- package/dist/esm/vega-font.entry.js +12 -12
- package/dist/esm/vega-form.entry.js +23 -24
- package/dist/esm/vega-grid.entry.js +11 -11
- package/dist/esm/vega-hint.entry.js +3 -4
- package/dist/esm/vega-icon.entry.js +14 -14
- package/dist/esm/vega-image-uploader.entry.js +28 -29
- package/dist/esm/vega-input-credit-card.entry.js +25 -26
- package/dist/esm/vega-input-numeric.entry.js +26 -27
- package/dist/esm/vega-input-phone-number.entry.js +25 -26
- package/dist/esm/vega-input-range.entry.js +23 -24
- package/dist/esm/vega-input-select.entry.js +31 -31
- package/dist/esm/vega-input.entry.js +23 -25
- package/dist/esm/{vega-internal-event-id-770faa12.js → vega-internal-event-id-4af5c6e9.js} +7 -1
- package/dist/esm/vega-item-toggle.entry.js +10 -13
- package/dist/esm/vega-left-nav_5.entry.js +32 -32
- package/dist/esm/vega-line-chart.entry.js +6 -7
- package/dist/esm/vega-loader-wrapper_2.entry.js +10 -10
- package/dist/esm/vega-page-notification_2.entry.js +6 -9
- package/dist/esm/vega-pagination.entry.js +17 -19
- package/dist/esm/vega-pie-chart.entry.js +5 -6
- package/dist/esm/vega-popover_2.entry.js +59 -24
- package/dist/esm/vega-progress-tracker.entry.js +10 -13
- package/dist/esm/vega-radio_2.entry.js +26 -27
- package/dist/esm/vega-rich-text-content.entry.js +175 -0
- package/dist/esm/vega-rich-text-editor_4.entry.js +4887 -0
- package/dist/esm/vega-section-title.entry.js +3 -4
- package/dist/esm/vega-segment-control.entry.js +12 -14
- package/dist/esm/vega-selection-chip_2.entry.js +28 -29
- package/dist/esm/vega-selection-tile_2.entry.js +26 -27
- package/dist/esm/vega-sidenav_3.entry.js +23 -25
- package/dist/esm/vega-signature-capture.entry.js +27 -29
- package/dist/esm/vega-skeleton.entry.js +3 -4
- package/dist/esm/vega-slot-container.entry.js +2 -3
- package/dist/esm/vega-stepper.entry.js +22 -23
- package/dist/esm/vega-tab-group_2.entry.js +18 -19
- package/dist/esm/vega-table_8.entry.js +33 -33
- package/dist/esm/vega-text.entry.js +6 -6
- package/dist/esm/vega-textarea.entry.js +23 -24
- package/dist/esm/vega-time-picker_2.entry.js +31 -32
- package/dist/esm/vega-toggle-switch.entry.js +18 -20
- package/dist/esm/vega-tooltip_2.entry.js +16 -16
- package/dist/esm/vega.js +28 -23
- package/dist/esm/{y-axis-input-processor-a4d6aa50.js → y-axis-input-processor-a26a57e5.js} +1 -1
- package/dist/types/components/vega-popover/slimmers/controllers/vega-popover-appender-controller.d.ts +19 -0
- package/dist/types/components/vega-rich-text-content/slimmers/controllers/vega-rich-text-content-state-controller.d.ts +11 -0
- package/dist/types/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.d.ts +20 -0
- package/dist/types/components/vega-rich-text-content/vega-rich-text-content.d.ts +44 -0
- package/dist/types/components/vega-rich-text-editor/assets/align-center.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/align-justify.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/align-left.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/align-right.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/bold.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/code-simple.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/image.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/indent.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/italic.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/link.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/list-ol.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/list-ul.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/outdent.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/strikethrough.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/text-size.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/text-slash.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/text.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/assets/underline.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/constants/constant.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/annotation-action.abstract.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/append-child-nodes-action.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/bold-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/break-single-block-action.d.ts +18 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/clear-child-nodes-action.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/clear-formatting-annotation-action.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/code-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/delete-block-content-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/delete-node-annotation-action.d.ts +18 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/horizontal-alignment-annotation-action.d.ts +17 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/image-annotation-action.d.ts +18 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/indent-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/insert-blocks-after-block.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/insert-blocks-before-block.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/insert-image-to-block-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/insert-nodes-after-node-action.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/insert-nodes-before-node-action.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/italic-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/line-break-multiple-block-action.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/line-break-single-block-action.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/link-annotation-action.d.ts +24 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/link-group-annotation-action.d.ts +18 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/merge-two-blocks-nodes-action.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.d.ts +30 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/remove-child-action.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/remove-nest-list-action.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/replace-child-nodes-action.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/replace-nest-list-action.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/replace-selected-text-action.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/selection-change-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/split-block-with-node-action.d.ts +17 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/splittable-action.abstract.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/strikethrough-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/sync-up-selection-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/text-color-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/text-style-annotation-action.d.ts +18 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/transform-list-action.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/transform-paragraph-action.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/underline-annotation-action.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/update-text-action.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/annotation.abstract.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/block-annotation.abstract.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/bold-annotation.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/clear-formatting-annotation.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/code-annotation.d.ts +43 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.d.ts +50 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/image-annotation.d.ts +41 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/indent-annotation.d.ts +44 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/italic-annotation.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-annotation.d.ts +44 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-group-annotation.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/node-annotation.abstract.d.ts +28 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/selection-range-annotation.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.d.ts +43 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-color-annotation.d.ts +50 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-style-annotation.d.ts +44 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/underline-annotation.d.ts +43 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +175 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +49 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +30 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +33 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +63 -0
- package/dist/types/components/vega-rich-text-editor/dto/content-state.d.ts +58 -0
- package/dist/types/components/vega-rich-text-editor/dto/helper/block-base-operator.d.ts +24 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/image-node.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/node.abstract.d.ts +65 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +33 -0
- package/dist/types/components/vega-rich-text-editor/dto/range.d.ts +102 -0
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +175 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/focus-controller.d.ts +33 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-handler.abstract.d.ts +67 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-processor.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/image-to-dto-handler.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/inline-block-to-dto-handler.d.ts +35 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/link-to-dto-handler.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-item-to-dto-handler.d.ts +36 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-to-dto-handler.d.ts +39 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/paragraph-to-dto-handler.d.ts +39 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-block-to-dto-handler.d.ts +46 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-to-dto-handler.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/base-handler.d.ts +78 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/delete-content-handler.d.ts +33 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-line-break-handler.d.ts +53 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paragraph-handler.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.d.ts +44 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-text-handler.d.ts +25 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/insert-image-controller.d.ts +39 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/rich-text-content-controller.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/selection-controller.d.ts +123 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/state-entity-rendering-registry.d.ts +33 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/text-node-color-controller.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/text-node-rendering-registry.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.d.ts +70 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/value-controller.d.ts +38 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/toolbar-renderer.d.ts +21 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/code-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/center-align-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/justify-align-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/left-align-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/right-align-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.d.ts +16 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.d.ts +28 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.d.ts +21 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/toolbar-button-slimmer.abstract.d.ts +49 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-renderer.d.ts +53 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/annotations.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/image-block.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/list-block.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/list-item.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/text-block.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/content-state.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/nodes/image-node.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/nodes/text-node.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/range.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-editor-toolbar-button/slimmers/renderers/vega-rich-text-editor-toolbar-button-renderer.d.ts +11 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-editor-toolbar-button/vega-rich-text-editor-toolbar-button.d.ts +62 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-editor.d.ts +186 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-image-editor/slimmers/renderers/vega-rich-text-image-editor-renderer.d.ts +20 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-image-editor/types.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-image-editor/vega-rich-text-image-editor.d.ts +46 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-link-editor/slimmers/renderers/vega-rich-text-link-editor-renderer.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-link-editor/types.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-link-editor/vega-rich-text-link-editor.d.ts +64 -0
- package/dist/types/components.d.ts +378 -0
- package/dist/types/constants/ui.d.ts +1 -1
- package/dist/types/helpers/change-manager/subject/static-subject/static-subject-title.d.ts +2 -1
- package/dist/types/helpers/common/index.d.ts +8 -0
- package/dist/types/helpers/event-manager/event-id/vega-event-id.d.ts +1 -0
- package/dist/types/helpers/event-manager/event-id/vega-internal-event-id.d.ts +6 -0
- package/dist/types/helpers/public-api.d.ts +1 -0
- package/dist/types/helpers/queue/synchronize-task-queue.d.ts +7 -0
- package/dist/types/helpers/slimmers/dark-mode-state-controller-slimmer.d.ts +21 -0
- package/dist/types/helpers/slimmers/element-appender-slimmer.d.ts +2 -0
- package/dist/types/helpers/slimmers/test/dark-mode-state-controller.test.d.ts +1 -0
- package/dist/types/helpers/theme/controllers/dark-mode-style-controller.d.ts +20 -0
- package/dist/types/helpers/validator/rules/form-field-validation-rule.d.ts +7 -1
- package/dist/types/helpers/validator/rules/{file-uploader-required-rule.d.ts → object-array-required-rule.d.ts} +3 -3
- package/dist/types/helpers/validator/rules/rich-text-editor-required-rule.d.ts +39 -0
- package/dist/types/helpers/validator/test/rules/object-array-required-rule.test.d.ts +1 -0
- package/dist/types/helpers/validator/test/rules/rich-text-editor-required-rule.test.d.ts +1 -0
- package/dist/types/polyfill/shadow-selection/shadow-selection-polyfill.d.ts +64 -0
- package/dist/types/polyfill/shadow-selection/test/shadow-selection-polyfill.test.d.ts +0 -0
- package/dist/types/polyfill/test-polyfill/unit/index.d.ts +1 -0
- package/dist/types/polyfill/test-polyfill/unit/range.d.ts +7 -0
- package/dist/types/polyfill/test-polyfill/unit/shadow-selection.d.ts +0 -0
- package/dist/types/types/components.type.d.ts +15 -0
- package/dist/types/utils/ui.d.ts +7 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-034e6348.entry.js +1 -0
- package/dist/vega/p-0cd2b50f.entry.js +1 -0
- package/dist/vega/{p-5453f591.js → p-0e0c47ad.js} +1 -1
- package/dist/vega/p-109a00cf.entry.js +1 -0
- package/dist/vega/p-112455b1.js +1 -0
- package/dist/vega/{p-bdb94242.js → p-11a19ca0.js} +1 -1
- package/dist/vega/{p-a04632d0.js → p-11cb477b.js} +1 -1
- package/dist/vega/p-1564cc4d.entry.js +1 -0
- package/dist/vega/p-18886765.entry.js +1 -0
- package/dist/vega/p-1995e98e.js +1 -0
- package/dist/vega/p-19b26168.entry.js +1 -0
- package/dist/vega/{p-b62f0454.js → p-1ec4b319.js} +1 -1
- package/dist/vega/p-1ec763ab.js +1 -0
- package/dist/vega/p-1fb56e14.js +1 -0
- package/dist/vega/p-21992602.entry.js +1 -0
- package/dist/vega/p-22563151.entry.js +1 -0
- package/dist/vega/p-23795da1.entry.js +1 -0
- package/dist/vega/p-29277e41.entry.js +1 -0
- package/dist/vega/{p-9b797118.js → p-296cc56b.js} +1 -1
- package/dist/vega/p-2a7e9422.entry.js +1 -0
- package/dist/vega/p-2ca6d977.entry.js +1 -0
- package/dist/vega/p-2e419309.entry.js +1 -0
- package/dist/vega/p-2fc3af2f.js +1 -0
- package/dist/vega/p-3039bef8.js +1 -0
- package/dist/vega/{p-e2acbc60.js → p-3152031c.js} +1 -1
- package/dist/vega/p-315667f1.js +1 -0
- package/dist/vega/p-34939c97.entry.js +1 -0
- package/dist/vega/{p-a46329bb.js → p-368d0060.js} +1 -1
- package/dist/vega/p-3897bb2d.entry.js +1 -0
- package/dist/vega/{p-69e63d21.entry.js → p-390c5236.entry.js} +1 -1
- package/dist/vega/{p-af7a3154.js → p-3953c705.js} +1 -1
- package/dist/vega/{p-c4a52c83.js → p-39836361.js} +1 -1
- package/dist/vega/{p-a190c86a.js → p-3b4bde3e.js} +1 -1
- package/dist/vega/p-3ce31dc3.js +1 -0
- package/dist/vega/{p-04215e74.js → p-3f1b542a.js} +1 -1
- package/dist/vega/{p-2d0d575f.js → p-443ad3b3.js} +1 -1
- package/dist/vega/p-452e284a.js +1 -0
- package/dist/vega/p-49f4a666.js +1 -0
- package/dist/vega/p-4bcd6612.js +1 -0
- package/dist/vega/p-4c41dd64.js +1 -0
- package/dist/vega/p-55beac7f.entry.js +1 -0
- package/dist/vega/p-57405834.entry.js +1 -0
- package/dist/vega/p-589e6041.entry.js +1 -0
- package/dist/vega/{p-6a334573.js → p-59bdf9b8.js} +1 -1
- package/dist/vega/p-5e95402a.entry.js +1 -0
- package/dist/vega/p-5eee21b4.entry.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-613ddaab.js +1 -0
- package/dist/vega/{p-2d5a9f66.js → p-62774231.js} +1 -1
- package/dist/vega/p-62cea2e7.entry.js +1 -0
- package/dist/vega/p-65b79fd7.js +1 -0
- package/dist/vega/p-6741e2b9.entry.js +1 -0
- package/dist/vega/p-6a084fe1.entry.js +1 -0
- package/dist/vega/{p-760283d1.entry.js → p-6b286226.entry.js} +1 -1
- package/dist/vega/p-6b722905.entry.js +1 -0
- package/dist/vega/p-6e4b2752.entry.js +1 -0
- package/dist/vega/{p-47c87634.js → p-70151c27.js} +1 -1
- package/dist/vega/p-7209d03b.js +1 -0
- package/dist/vega/p-728b029a.entry.js +1 -0
- package/dist/vega/p-76fc408e.entry.js +1 -0
- package/dist/vega/p-7a40e033.js +1 -0
- package/dist/vega/p-7a9f453e.entry.js +1 -0
- package/dist/vega/p-80ccd894.entry.js +1 -0
- package/dist/vega/{p-ed237efc.js → p-81ead59a.js} +1 -1
- package/dist/vega/{p-987fbbd0.js → p-843a0c1c.js} +1 -1
- package/dist/vega/p-84c597c8.entry.js +1 -0
- package/dist/vega/p-8b78c6a3.entry.js +1 -0
- package/dist/vega/p-8be45a45.entry.js +1 -0
- package/dist/vega/p-8c26227e.js +1 -0
- package/dist/vega/p-8d7b45f7.entry.js +1 -0
- package/dist/vega/p-8e17b9dd.entry.js +1 -0
- package/dist/vega/p-8f93242a.js +1 -0
- package/dist/vega/p-925a2137.js +1 -0
- package/dist/vega/p-92f88033.entry.js +1 -0
- package/dist/vega/p-94de7a02.entry.js +1 -0
- package/dist/vega/p-9968e71d.entry.js +1 -0
- package/dist/vega/p-9c1eeff2.js +2 -0
- package/dist/vega/p-9d1b9e70.entry.js +1 -0
- package/dist/vega/p-a5ffe912.js +1 -0
- package/dist/vega/p-a6104aa7.js +1 -0
- package/dist/vega/p-a6169ad6.entry.js +1 -0
- package/dist/vega/{p-6a8f1251.js → p-a6a7d0c9.js} +1 -1
- package/dist/vega/p-a8bf559a.js +1 -0
- package/dist/vega/p-aacf6920.js +1 -0
- package/dist/vega/p-acf7f903.js +1 -0
- package/dist/vega/p-afec17ad.entry.js +1 -0
- package/dist/vega/p-b1f65b13.js +1 -0
- package/dist/vega/{p-0c051d2a.entry.js → p-b3f9cc3a.entry.js} +2 -2
- package/dist/vega/p-b693c1ac.entry.js +1 -0
- package/dist/vega/p-b6af0fc1.entry.js +1 -0
- package/dist/vega/p-b9e2add4.entry.js +1 -0
- package/dist/vega/p-bd894860.entry.js +1 -0
- package/dist/vega/p-c0d6a587.entry.js +1 -0
- package/dist/vega/p-c1d97d12.entry.js +1 -0
- package/dist/vega/p-c26e6820.entry.js +1 -0
- package/dist/vega/p-c34487e1.entry.js +1 -0
- package/dist/vega/p-c532b132.entry.js +1 -0
- package/dist/vega/p-ca2fb711.js +1 -0
- package/dist/vega/p-cebf93f1.entry.js +1 -0
- package/dist/vega/p-cfdc148a.entry.js +1 -0
- package/dist/vega/p-d0351d71.entry.js +1 -0
- package/dist/vega/p-d057999f.js +1 -0
- package/dist/vega/{p-c7d70786.js → p-d171cf44.js} +1 -1
- package/dist/vega/p-d2ab6096.entry.js +1 -0
- package/dist/vega/p-d302f052.entry.js +1 -0
- package/dist/vega/p-d35643c5.entry.js +1 -0
- package/dist/vega/p-d400a1d9.entry.js +1 -0
- package/dist/vega/p-d6732a72.entry.js +1 -0
- package/dist/vega/p-d720b06a.entry.js +1 -0
- package/dist/vega/{p-c59042c0.js → p-d884c644.js} +1 -1
- package/dist/vega/p-d987e404.entry.js +1 -0
- package/dist/vega/p-d9b86108.entry.js +1 -0
- package/dist/vega/p-e0b25eaf.js +1 -0
- package/dist/vega/{p-9f3b1d77.js → p-e1e1fcf0.js} +1 -1
- package/dist/vega/p-e27e115d.entry.js +1 -0
- package/dist/vega/p-e43c2a27.js +1 -0
- package/dist/vega/p-e65c8ac7.entry.js +1 -0
- package/dist/vega/p-e79057cc.js +1 -0
- package/dist/vega/p-e89e9769.entry.js +1 -0
- package/dist/vega/{p-781fd6e0.js → p-eac38d87.js} +1 -1
- package/dist/vega/p-ecd64c7f.entry.js +1 -0
- package/dist/vega/p-ed45b3b6.js +1 -0
- package/dist/vega/p-f357cf46.js +1 -0
- package/dist/vega/p-f5b2e72a.entry.js +1 -0
- package/dist/vega/p-f6af3749.js +1 -0
- package/dist/vega/p-f763e2eb.js +1 -0
- package/dist/vega/p-fc622a75.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +3 -4
- package/dist/cjs/dom-node-subject-observer-factory-2e41340d.js +0 -141
- package/dist/cjs/global-slimmer-registry-b3bce7e0.js +0 -297
- package/dist/cjs/index-40a1cd3a.js +0 -15
- package/dist/cjs/index-5792390b.js +0 -1024
- package/dist/cjs/observer-f49483e8.js +0 -32
- package/dist/collection/helpers/validator/test/rules/file-uploader-required-rule.test.js +0 -7
- package/dist/esm/chevron-down-4303bddb.js +0 -9
- package/dist/esm/dom-node-subject-observer-factory-9461cd67.js +0 -138
- package/dist/esm/global-slimmer-registry-17c4efd4.js +0 -283
- package/dist/esm/index-0830dd1d.js +0 -13
- package/dist/esm/index-0863eec6.js +0 -1019
- package/dist/esm/observer-3959f9dd.js +0 -30
- package/dist/esm/vega-event-id-0f8fc134.js +0 -103
- package/dist/vega/p-07a8cf89.entry.js +0 -1
- package/dist/vega/p-07af8ee4.entry.js +0 -1
- package/dist/vega/p-0916da7a.entry.js +0 -1
- package/dist/vega/p-0abae6cc.entry.js +0 -1
- package/dist/vega/p-0e59c3b7.entry.js +0 -1
- package/dist/vega/p-0fe89d42.js +0 -1
- package/dist/vega/p-0fecf145.js +0 -1
- package/dist/vega/p-11786565.entry.js +0 -1
- package/dist/vega/p-13d34a23.entry.js +0 -1
- package/dist/vega/p-14fc5aed.entry.js +0 -1
- package/dist/vega/p-16bb355d.js +0 -1
- package/dist/vega/p-17233d94.entry.js +0 -1
- package/dist/vega/p-1a8dd528.entry.js +0 -1
- package/dist/vega/p-1c298d5a.js +0 -2
- package/dist/vega/p-2b5ab7f9.entry.js +0 -1
- package/dist/vega/p-32f651f7.js +0 -1
- package/dist/vega/p-331a62d5.js +0 -1
- package/dist/vega/p-36395deb.entry.js +0 -1
- package/dist/vega/p-38b93319.entry.js +0 -1
- package/dist/vega/p-4022f395.entry.js +0 -1
- package/dist/vega/p-4163c2c2.js +0 -1
- package/dist/vega/p-4625a2b4.js +0 -1
- package/dist/vega/p-483d0916.entry.js +0 -1
- package/dist/vega/p-4921c38c.entry.js +0 -1
- package/dist/vega/p-4963e445.entry.js +0 -1
- package/dist/vega/p-497eba8c.entry.js +0 -1
- package/dist/vega/p-49db0660.entry.js +0 -1
- package/dist/vega/p-4d25df7d.js +0 -1
- package/dist/vega/p-535f0758.js +0 -1
- package/dist/vega/p-53702f16.js +0 -1
- package/dist/vega/p-53d34f58.entry.js +0 -1
- package/dist/vega/p-5440344e.js +0 -1
- package/dist/vega/p-576fe8cf.entry.js +0 -1
- package/dist/vega/p-590870e4.js +0 -1
- package/dist/vega/p-5915634b.js +0 -1
- package/dist/vega/p-597871ab.entry.js +0 -1
- package/dist/vega/p-5fbac513.js +0 -1
- package/dist/vega/p-603f7aa3.entry.js +0 -1
- package/dist/vega/p-61f6167c.js +0 -1
- package/dist/vega/p-66ffdfdf.entry.js +0 -1
- package/dist/vega/p-6758dc5e.entry.js +0 -1
- package/dist/vega/p-68ad953c.js +0 -1
- package/dist/vega/p-6c6d86da.js +0 -1
- package/dist/vega/p-6e1ab235.js +0 -1
- package/dist/vega/p-6f027906.entry.js +0 -1
- package/dist/vega/p-6f788b49.entry.js +0 -1
- package/dist/vega/p-7372cd79.entry.js +0 -1
- package/dist/vega/p-7df3aa44.entry.js +0 -1
- package/dist/vega/p-810ba5c3.entry.js +0 -1
- package/dist/vega/p-84118b6d.entry.js +0 -1
- package/dist/vega/p-848825ff.entry.js +0 -1
- package/dist/vega/p-84fa8466.js +0 -1
- package/dist/vega/p-87640a4d.entry.js +0 -1
- package/dist/vega/p-8a091eb7.js +0 -1
- package/dist/vega/p-8b084bf9.entry.js +0 -1
- package/dist/vega/p-8f5ffac5.entry.js +0 -1
- package/dist/vega/p-910410ad.entry.js +0 -1
- package/dist/vega/p-943e89b4.js +0 -1
- package/dist/vega/p-99a35465.entry.js +0 -1
- package/dist/vega/p-99cf17e3.entry.js +0 -1
- package/dist/vega/p-9ba085c1.entry.js +0 -1
- package/dist/vega/p-9e9ec748.js +0 -1
- package/dist/vega/p-9f984c33.entry.js +0 -1
- package/dist/vega/p-9fbdeada.js +0 -1
- package/dist/vega/p-a7fdb16a.js +0 -1
- package/dist/vega/p-a828eeef.entry.js +0 -1
- package/dist/vega/p-acc14aa2.js +0 -1
- package/dist/vega/p-ae5751fb.entry.js +0 -1
- package/dist/vega/p-b3e754da.entry.js +0 -1
- package/dist/vega/p-b4e92130.entry.js +0 -1
- package/dist/vega/p-b5990090.js +0 -1
- package/dist/vega/p-b8e42c11.entry.js +0 -1
- package/dist/vega/p-bb6f8b70.entry.js +0 -1
- package/dist/vega/p-c1dfdc13.js +0 -1
- package/dist/vega/p-c51a48d6.entry.js +0 -1
- package/dist/vega/p-d6d10fb3.entry.js +0 -1
- package/dist/vega/p-d7df87b4.entry.js +0 -1
- package/dist/vega/p-daaf3ee3.entry.js +0 -1
- package/dist/vega/p-dadd7db4.entry.js +0 -1
- package/dist/vega/p-db94558e.entry.js +0 -1
- package/dist/vega/p-dba59bd7.entry.js +0 -1
- package/dist/vega/p-e5cd92f0.entry.js +0 -1
- package/dist/vega/p-e5e0394a.entry.js +0 -1
- package/dist/vega/p-ec157238.js +0 -1
- package/dist/vega/p-eddcb385.entry.js +0 -1
- package/dist/vega/p-f2685ec5.entry.js +0 -1
- package/dist/vega/p-f404aa83.js +0 -1
- package/dist/vega/p-f46c930f.js +0 -1
- package/dist/vega/p-f556c3cd.entry.js +0 -1
- package/dist/vega/p-f5876e05.entry.js +0 -1
- package/dist/vega/p-f64fb740.entry.js +0 -1
- package/dist/vega/p-f76e9940.entry.js +0 -1
- package/dist/vega/p-f7728ead.entry.js +0 -1
- package/dist/vega/p-fae41be0.entry.js +0 -1
- package/dist/vega/p-faea1620.js +0 -1
- /package/dist/types/{helpers/validator/test/rules/file-uploader-required-rule.test.d.ts → components/vega-rich-text-editor/test/dto/annotation-actions.test.d.ts} +0 -0
|
@@ -0,0 +1,4887 @@
|
|
|
1
|
+
import { d as MapToComponentField, M as MapToComponentMethod, V as VegaSlimmer, h, H as Host, F as Fragment, I as InjectVegaSlimmer, L as LogUtility, r as registerInstance, e as createEvent, g as getElement } from './global-slimmer-registry-6887a59f.js';
|
|
2
|
+
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-21813c36.js';
|
|
3
|
+
import { g as getActiveElement, s as sanitizeVegaComponent } from './component-051a594c.js';
|
|
4
|
+
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-e5fd0fab.js';
|
|
5
|
+
import { C as ChangeManager } from './change-manager-8f5b72c2.js';
|
|
6
|
+
import { d as domNodeSubjectFactory, D as DomNodeSubjectObserverFactory, c as VegaDropdownClick, V as VegaChange, O as Observer, Q as VegaImageInserted, b as VegaClick, M as VegaPopoverShow, N as VegaPopoverHide } from './dom-node-subject-observer-factory-80358591.js';
|
|
7
|
+
import { a as VegaInternalComponentDidRender, b as VegaInternalRichTextEditorSelectionRangeChange, V as VegaInternalRichTextEditorFlushChanges, o as VegaInternalRichTextImageClick, p as VegaInternalRichTextImageDeleteButtonClicked, k as VegaInternalPopoverUpdateTarget } from './vega-internal-event-id-4af5c6e9.js';
|
|
8
|
+
import { a as ToolbarButtonSlimmer, T as TextColorToolbarButtonSlimmer } from './text-color-toolbar-button-slimmer-d0255b98.js';
|
|
9
|
+
import { V as VegaInternalIconManager } from './internal-icon-manager-7fc7535a.js';
|
|
10
|
+
import { B as BoldAnnotationAction, R as RTETextBlock, T as TextStyleAnnotationAction, a as TextStyleAnnotation, I as IndentAnnotation, b as RTEImageNode, c as RTEListItemBlock, H as HorizontalAlignmentAnnotation, V as VegaRTEContent, d as RemoveChildAction, A as AppendChildNodesAction, e as InsertBlocksBeforeAction, M as MergeTwoBlocksNodesAction, S as SplitBlockWithNodeAction, f as ReplaceChildNodesAction, g as RTEImageBlock, h as RTEListBlock, i as InsertBlocksAfterAction, j as ImageAnnotationAction } from './content-state-acf55eb0.js';
|
|
11
|
+
import { a as NodeAnnotationTypeEnum, M as ModifyContentAction, b as ModifyContentActionType, R as RTENode, s as stateEntityRenderingRegistry, I as InternalAnnotationTypeEnum, V as VegaThemeManager } from './node.abstract-93746055.js';
|
|
12
|
+
import { R as RTETextNode, T as TextSplittableAction, I as ItalicAnnotation, e as UnderlineAnnotation, B as BoldAnnotation, C as ClearFormattingAnnotationAction, f as CodeAnnotationAction, g as StrikethroughAnnotation, A as AnnotationAction, h as SelectionRangeAnnotation, L as LinkAnnotationAction, b as waitForComponentDidRender, Z as ZERO_WIDTH_SPACE, U as UpdateTextAction, i as TextNodeRenderingRegistry } from './text-node-6f7d736c.js';
|
|
13
|
+
import { e as BlockAnnotationTypeEnum } from './block-annotation.abstract-b0554e2b.js';
|
|
14
|
+
import { g as generateUUID } from './create-public-api-runtime-metrics-slimmer-14cb4599.js';
|
|
15
|
+
import { F as FormFieldControllerSlimmer } from './form-field-controller-slimmer-de5fe574.js';
|
|
16
|
+
import { c as createEventEmitSlimmer } from './event-emit-slimmer-c03cf145.js';
|
|
17
|
+
import { c as createSubStateNotifySlimmer } from './sub-state-notify-slimmer-6e97a58a.js';
|
|
18
|
+
import { d as debounce } from './timer-9321173b.js';
|
|
19
|
+
import { S as SynchronizeTaskQueue } from './synchronize-task-queue-ac8acc3b.js';
|
|
20
|
+
import { f as findParent } from './ui-5600b48f.js';
|
|
21
|
+
import { b as FORM_ELEMENT_VALUE_CHANGE, D as DARK_MODE_CHANGE } from './static-subject-title-e06a3840.js';
|
|
22
|
+
import './vega-env-manager-8f8dc473.js';
|
|
23
|
+
import './feature-flag-controller-dfde0cfa.js';
|
|
24
|
+
import './vega-dialog-controller-5b23f68c.js';
|
|
25
|
+
import './icon-manager-3cef32e7.js';
|
|
26
|
+
import './translation-b3fe8e74.js';
|
|
27
|
+
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-8ceabe63.js';
|
|
28
|
+
import { c as chevronDown } from './chevron-down-4a75d28e.js';
|
|
29
|
+
import { t as trashCan } from './trash-can-8819a939.js';
|
|
30
|
+
import { r as remoteInvocationRegistry } from './remote-invocation-registry-2ec6936d.js';
|
|
31
|
+
import './type-guard-158f6d7a.js';
|
|
32
|
+
import './breakpoints-d9faf11c.js';
|
|
33
|
+
import './ui-8424715a.js';
|
|
34
|
+
import './regex-dfe11abf.js';
|
|
35
|
+
import './typography-396de03f.js';
|
|
36
|
+
import './_commonjsHelpers-9943807e.js';
|
|
37
|
+
import './internal-vega-z-index-manager-89e8b6f5.js';
|
|
38
|
+
import './number-4398f2e1.js';
|
|
39
|
+
import './dynamic-slimmer-85746483.js';
|
|
40
|
+
import './page-resize-observer-slimmer-8589ebc8.js';
|
|
41
|
+
import './breakpoints-91116111.js';
|
|
42
|
+
import './internal-vega-event-manager-3a3815d3.js';
|
|
43
|
+
import './string-be824360.js';
|
|
44
|
+
import './mutation-observer-slimmer-ca2cb2e8.js';
|
|
45
|
+
import './mutation-observer-filters-1035b064.js';
|
|
46
|
+
import './array-b668466e.js';
|
|
47
|
+
import './index-44c794b4.js';
|
|
48
|
+
|
|
49
|
+
var __decorate$y = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
50
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
51
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
52
|
+
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;
|
|
53
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
54
|
+
};
|
|
55
|
+
class VegaRichTextEditorRenderer extends VegaSlimmer {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
this.renderHintMessage = () => {
|
|
59
|
+
return h("vega-text", null, this.hint);
|
|
60
|
+
};
|
|
61
|
+
this.renderTextContent = () => {
|
|
62
|
+
return (h("div", { class: {
|
|
63
|
+
'rich-text-editor-container': true,
|
|
64
|
+
'disabled': this.disabled,
|
|
65
|
+
}, style: { minHeight: `${this.rows * 24}px` }, onClick: this.richTextContentFocus, role: "textbox", tabIndex: !this.disabled ? -1 : 0, onKeyDown: createEnterKeyHandlerToTriggerClick(), ref: (node) => (this.richTextContainerRef = node) },
|
|
66
|
+
h("vega-rich-text-content", { ref: (ref) => (this.richTextContentRef = ref), content: this.value }),
|
|
67
|
+
this.renderCharacterCounter()));
|
|
68
|
+
};
|
|
69
|
+
this.renderCharacterCounter = () => {
|
|
70
|
+
return (h("div", { class: {
|
|
71
|
+
'text-editor-counter': true,
|
|
72
|
+
'counter-exceed-max-length': false,
|
|
73
|
+
}, style: { display: 'none' } },
|
|
74
|
+
h("span", null, "0"),
|
|
75
|
+
h("span", null, "/100")));
|
|
76
|
+
};
|
|
77
|
+
this.renderErrorMessage = () => {
|
|
78
|
+
return h("div", { class: "vega-error vega-hidden" });
|
|
79
|
+
};
|
|
80
|
+
this.richTextContentFocus = () => {
|
|
81
|
+
void this.richTextContentRef.vegaFocus();
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Component lifecycle - [componentDidRender]{@link VegaRichTextEditor.componentDidRender}
|
|
86
|
+
*/
|
|
87
|
+
componentDidRender() {
|
|
88
|
+
ChangeManager.notify(domNodeSubjectFactory.getSubject(this.host, VegaInternalComponentDidRender), {});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the HTMLElement reference of the rich text container.
|
|
92
|
+
*
|
|
93
|
+
* @returns {HTMLDivElement} An HTMLElement representing the rich text container is being returned.
|
|
94
|
+
*/
|
|
95
|
+
getRichTextContainerRef() {
|
|
96
|
+
return this.richTextContainerRef;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the HTMLElement reference of the rich text content area.
|
|
100
|
+
*
|
|
101
|
+
* @returns {HTMLVegaRichTextContentElement} An HTMLVegaRichTextContentElement is being returned.
|
|
102
|
+
*/
|
|
103
|
+
getRichTextContentRef() {
|
|
104
|
+
return this.richTextContentRef;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns the HTMLElement reference of the rich text outermost layer.
|
|
108
|
+
*
|
|
109
|
+
* @returns {HTMLVegaFlexElement} An HTMLVegaFlexElement is being returned.
|
|
110
|
+
*/
|
|
111
|
+
getRichTextWrapperRef() {
|
|
112
|
+
return this.richTextWrapperRef;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns the rich text editor component editable element
|
|
116
|
+
*
|
|
117
|
+
* @returns {HTMLDivElement} The div element which has property contenteditable
|
|
118
|
+
*/
|
|
119
|
+
getRTEEditableElementRef() {
|
|
120
|
+
if (this.richTextContentRef && this.richTextContentRef.shadowRoot) {
|
|
121
|
+
return this.richTextContentRef.shadowRoot.querySelector('.rich-text-content');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
render() {
|
|
125
|
+
return h(Host, null, this.renderRichTextEditor());
|
|
126
|
+
}
|
|
127
|
+
renderRichTextEditor() {
|
|
128
|
+
return (h("vega-flex", { direction: "col", gap: "0", ref: (flex) => (this.richTextWrapperRef = flex) },
|
|
129
|
+
this.renderLabel(),
|
|
130
|
+
this.hint && this.renderHintMessage(),
|
|
131
|
+
this.toolbarRenderer.render(),
|
|
132
|
+
this.renderTextContent(),
|
|
133
|
+
this.renderErrorMessage()));
|
|
134
|
+
}
|
|
135
|
+
renderLabel() {
|
|
136
|
+
return (this.label && (h("vega-field-label", { onClick: this.richTextContentFocus, isFieldRequired: this.required, disabled: this.disabled, label: this.label })));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
__decorate$y([
|
|
140
|
+
MapToComponentField()
|
|
141
|
+
], VegaRichTextEditorRenderer.prototype, "host", void 0);
|
|
142
|
+
__decorate$y([
|
|
143
|
+
MapToComponentField()
|
|
144
|
+
], VegaRichTextEditorRenderer.prototype, "toolbarRenderer", void 0);
|
|
145
|
+
__decorate$y([
|
|
146
|
+
MapToComponentField()
|
|
147
|
+
], VegaRichTextEditorRenderer.prototype, "label", void 0);
|
|
148
|
+
__decorate$y([
|
|
149
|
+
MapToComponentField()
|
|
150
|
+
], VegaRichTextEditorRenderer.prototype, "required", void 0);
|
|
151
|
+
__decorate$y([
|
|
152
|
+
MapToComponentField()
|
|
153
|
+
], VegaRichTextEditorRenderer.prototype, "hint", void 0);
|
|
154
|
+
__decorate$y([
|
|
155
|
+
MapToComponentField()
|
|
156
|
+
], VegaRichTextEditorRenderer.prototype, "disabled", void 0);
|
|
157
|
+
__decorate$y([
|
|
158
|
+
MapToComponentField()
|
|
159
|
+
], VegaRichTextEditorRenderer.prototype, "rows", void 0);
|
|
160
|
+
__decorate$y([
|
|
161
|
+
MapToComponentField()
|
|
162
|
+
], VegaRichTextEditorRenderer.prototype, "placeholder", void 0);
|
|
163
|
+
__decorate$y([
|
|
164
|
+
MapToComponentField()
|
|
165
|
+
], VegaRichTextEditorRenderer.prototype, "value", void 0);
|
|
166
|
+
__decorate$y([
|
|
167
|
+
MapToComponentMethod('componentDidRender')
|
|
168
|
+
], VegaRichTextEditorRenderer.prototype, "componentDidRender", null);
|
|
169
|
+
|
|
170
|
+
var __decorate$x = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
171
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
172
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
173
|
+
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;
|
|
174
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
175
|
+
};
|
|
176
|
+
class ToolbarRenderer extends VegaSlimmer {
|
|
177
|
+
constructor() {
|
|
178
|
+
super(...arguments);
|
|
179
|
+
this.getToolbarBtnRenderer = (type) => {
|
|
180
|
+
switch (type) {
|
|
181
|
+
case 'clearStyle':
|
|
182
|
+
return this.clearStyleToolbarButtonSlimmer;
|
|
183
|
+
case 'bold':
|
|
184
|
+
return this.boldToolbarButtonSlimmer;
|
|
185
|
+
case 'textStyles':
|
|
186
|
+
return this.textStylesToolbarButtonSlimmer;
|
|
187
|
+
case 'italic':
|
|
188
|
+
return this.italicToolbarButtonSlimmer;
|
|
189
|
+
case 'underline':
|
|
190
|
+
return this.underlineToolbarButtonSlimmer;
|
|
191
|
+
case 'textColor':
|
|
192
|
+
return this.textColorToolbarButtonSlimmer;
|
|
193
|
+
case 'moreIndent':
|
|
194
|
+
return this.moreIndentToolbarButtonSlimmer;
|
|
195
|
+
case 'lessIndent':
|
|
196
|
+
return this.lessIndentToolbarButtonSlimmer;
|
|
197
|
+
case 'code':
|
|
198
|
+
return this.codeToolbarButtonSlimmer;
|
|
199
|
+
case 'strikethrough':
|
|
200
|
+
return this.strikethroughToolbarButtonSlimmer;
|
|
201
|
+
case 'link':
|
|
202
|
+
return this.linkToolbarButtonSlimmer;
|
|
203
|
+
case 'image':
|
|
204
|
+
return this.imageToolbarButtonSlimmer;
|
|
205
|
+
case 'bulletsNumbers':
|
|
206
|
+
return this.bulletsNumbersToolbarButtonSlimmer;
|
|
207
|
+
case 'horizontalAlignment':
|
|
208
|
+
return this.horizontalAlignmentToolbarButtonSlimmer;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
render() {
|
|
213
|
+
return (h("vega-flex", { gap: "size-8", alignItems: "center", flexWrap: "wrap" }, this.toolbarItems.map((group) => {
|
|
214
|
+
return (h("div", { class: "toolbar-btn-group" }, group.map((item) => {
|
|
215
|
+
return this.getToolbarBtnRenderer(item).render();
|
|
216
|
+
})));
|
|
217
|
+
})));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
__decorate$x([
|
|
221
|
+
MapToComponentField()
|
|
222
|
+
], ToolbarRenderer.prototype, "toolbarItems", void 0);
|
|
223
|
+
__decorate$x([
|
|
224
|
+
MapToComponentField()
|
|
225
|
+
], ToolbarRenderer.prototype, "clearStyleToolbarButtonSlimmer", void 0);
|
|
226
|
+
__decorate$x([
|
|
227
|
+
MapToComponentField()
|
|
228
|
+
], ToolbarRenderer.prototype, "boldToolbarButtonSlimmer", void 0);
|
|
229
|
+
__decorate$x([
|
|
230
|
+
MapToComponentField()
|
|
231
|
+
], ToolbarRenderer.prototype, "textStylesToolbarButtonSlimmer", void 0);
|
|
232
|
+
__decorate$x([
|
|
233
|
+
MapToComponentField()
|
|
234
|
+
], ToolbarRenderer.prototype, "italicToolbarButtonSlimmer", void 0);
|
|
235
|
+
__decorate$x([
|
|
236
|
+
MapToComponentField()
|
|
237
|
+
], ToolbarRenderer.prototype, "underlineToolbarButtonSlimmer", void 0);
|
|
238
|
+
__decorate$x([
|
|
239
|
+
MapToComponentField()
|
|
240
|
+
], ToolbarRenderer.prototype, "textColorToolbarButtonSlimmer", void 0);
|
|
241
|
+
__decorate$x([
|
|
242
|
+
MapToComponentField()
|
|
243
|
+
], ToolbarRenderer.prototype, "bulletsNumbersToolbarButtonSlimmer", void 0);
|
|
244
|
+
__decorate$x([
|
|
245
|
+
MapToComponentField()
|
|
246
|
+
], ToolbarRenderer.prototype, "horizontalAlignmentToolbarButtonSlimmer", void 0);
|
|
247
|
+
__decorate$x([
|
|
248
|
+
MapToComponentField()
|
|
249
|
+
], ToolbarRenderer.prototype, "strikethroughToolbarButtonSlimmer", void 0);
|
|
250
|
+
__decorate$x([
|
|
251
|
+
MapToComponentField()
|
|
252
|
+
], ToolbarRenderer.prototype, "imageToolbarButtonSlimmer", void 0);
|
|
253
|
+
__decorate$x([
|
|
254
|
+
MapToComponentField()
|
|
255
|
+
], ToolbarRenderer.prototype, "moreIndentToolbarButtonSlimmer", void 0);
|
|
256
|
+
__decorate$x([
|
|
257
|
+
MapToComponentField()
|
|
258
|
+
], ToolbarRenderer.prototype, "lessIndentToolbarButtonSlimmer", void 0);
|
|
259
|
+
__decorate$x([
|
|
260
|
+
MapToComponentField()
|
|
261
|
+
], ToolbarRenderer.prototype, "codeToolbarButtonSlimmer", void 0);
|
|
262
|
+
__decorate$x([
|
|
263
|
+
MapToComponentField()
|
|
264
|
+
], ToolbarRenderer.prototype, "linkToolbarButtonSlimmer", void 0);
|
|
265
|
+
|
|
266
|
+
const bold = {
|
|
267
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M0 64C0 46.3 14.3 32 32 32H80 96 224c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128H96 80 32c-17.7 0-32-14.3-32-32s14.3-32 32-32H48V256 96H32C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64H112V224H224zM112 288V416H256c35.3 0 64-28.7 64-64s-28.7-64-64-64H224 112z"/></svg>`,
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
var __decorate$w = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
271
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
272
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
273
|
+
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;
|
|
274
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
275
|
+
};
|
|
276
|
+
class BoldToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
277
|
+
constructor() {
|
|
278
|
+
super({
|
|
279
|
+
icon: 'bold',
|
|
280
|
+
tooltip: {
|
|
281
|
+
text: 'Bold',
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
onClick() {
|
|
286
|
+
const bold = this.isSelected();
|
|
287
|
+
this.selectionController
|
|
288
|
+
.getSelectedNodes()
|
|
289
|
+
.filter((node) => node instanceof RTETextNode)
|
|
290
|
+
.forEach((node) => node.apply(new BoldAnnotationAction(!bold)));
|
|
291
|
+
}
|
|
292
|
+
isSelected() {
|
|
293
|
+
const selectedNodes = this.selectionController
|
|
294
|
+
.getSelectedNodes()
|
|
295
|
+
.filter((node) => node instanceof RTETextNode);
|
|
296
|
+
return (selectedNodes.length > 0 &&
|
|
297
|
+
selectedNodes.every((node) => { var _a; return (_a = node.getAnnotationByType(NodeAnnotationTypeEnum.BOLD)) === null || _a === void 0 ? void 0 : _a.bold; }));
|
|
298
|
+
}
|
|
299
|
+
isDisabled() {
|
|
300
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
301
|
+
return selectedNodes.some((node) => {
|
|
302
|
+
var _a;
|
|
303
|
+
return ((_a = node.getAnnotationByType(NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
304
|
+
node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
(() => {
|
|
309
|
+
VegaInternalIconManager.register({ bold });
|
|
310
|
+
})();
|
|
311
|
+
__decorate$w([
|
|
312
|
+
MapToComponentField()
|
|
313
|
+
], BoldToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
314
|
+
|
|
315
|
+
const italic = {
|
|
316
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M128 64c0-17.7 14.3-32 32-32H352c17.7 0 32 14.3 32 32s-14.3 32-32 32H293.3L160 416h64c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H90.7L224 96H160c-17.7 0-32-14.3-32-32z"/></svg>`,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Action to toggle the italic annotation
|
|
321
|
+
*/
|
|
322
|
+
class ItalicAnnotationAction extends TextSplittableAction {
|
|
323
|
+
constructor(italic) {
|
|
324
|
+
super();
|
|
325
|
+
this.isFlushable = true;
|
|
326
|
+
this.italic = italic;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Converts the action to an annotation
|
|
330
|
+
*
|
|
331
|
+
* @returns {ItalicAnnotation} The annotation
|
|
332
|
+
*/
|
|
333
|
+
toAnnotation() {
|
|
334
|
+
return new ItalicAnnotation(this.italic);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
var __decorate$v = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
339
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
340
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
341
|
+
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;
|
|
342
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
343
|
+
};
|
|
344
|
+
class ItalicToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
345
|
+
constructor() {
|
|
346
|
+
super({
|
|
347
|
+
icon: 'italic',
|
|
348
|
+
tooltip: { text: 'Italic' },
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
isSelected() {
|
|
352
|
+
const selectedNodes = this.selectionController
|
|
353
|
+
.getSelectedNodes()
|
|
354
|
+
.filter((node) => node instanceof RTETextNode);
|
|
355
|
+
return (selectedNodes.length > 0 &&
|
|
356
|
+
selectedNodes.every((node) => { var _a; return (_a = node.getAnnotationByType(NodeAnnotationTypeEnum.ITALIC)) === null || _a === void 0 ? void 0 : _a.italic; }));
|
|
357
|
+
}
|
|
358
|
+
onClick() {
|
|
359
|
+
const italic = this.isSelected();
|
|
360
|
+
this.selectionController
|
|
361
|
+
.getSelectedNodes()
|
|
362
|
+
.filter((node) => node instanceof RTETextNode)
|
|
363
|
+
.forEach((node) => node.apply(new ItalicAnnotationAction(!italic)));
|
|
364
|
+
}
|
|
365
|
+
isDisabled() {
|
|
366
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
367
|
+
return selectedNodes.some((node) => {
|
|
368
|
+
var _a;
|
|
369
|
+
return ((_a = node.getAnnotationByType(NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
370
|
+
node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
(() => {
|
|
375
|
+
VegaInternalIconManager.register({ italic });
|
|
376
|
+
})();
|
|
377
|
+
__decorate$v([
|
|
378
|
+
MapToComponentField()
|
|
379
|
+
], ItalicToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
380
|
+
|
|
381
|
+
const underline = {
|
|
382
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M16 64c0-17.7 14.3-32 32-32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32H128V224c0 53 43 96 96 96s96-43 96-96V96H304c-17.7 0-32-14.3-32-32s14.3-32 32-32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32H384V224c0 88.4-71.6 160-160 160s-160-71.6-160-160V96H48C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32z"/></svg>`,
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Action to toggle the underline annotation
|
|
387
|
+
*/
|
|
388
|
+
class UnderlineAnnotationAction extends TextSplittableAction {
|
|
389
|
+
constructor(underline) {
|
|
390
|
+
super();
|
|
391
|
+
this.isFlushable = true;
|
|
392
|
+
this.underline = underline;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Converts the action to an annotation
|
|
396
|
+
*
|
|
397
|
+
* @returns {UnderlineAnnotation} the annotation
|
|
398
|
+
*/
|
|
399
|
+
toAnnotation() {
|
|
400
|
+
return new UnderlineAnnotation(this.underline);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
var __decorate$u = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
405
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
406
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
407
|
+
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;
|
|
408
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
409
|
+
};
|
|
410
|
+
class UnderlineToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
411
|
+
constructor() {
|
|
412
|
+
super({
|
|
413
|
+
icon: 'underline',
|
|
414
|
+
tooltip: { text: 'Underline' },
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
isSelected() {
|
|
418
|
+
const selectedNodes = this.selectionController
|
|
419
|
+
.getSelectedNodes()
|
|
420
|
+
.filter((node) => node instanceof RTETextNode);
|
|
421
|
+
return (selectedNodes.length > 0 &&
|
|
422
|
+
selectedNodes.every((node) => {
|
|
423
|
+
var _a;
|
|
424
|
+
return (_a = node.getAnnotationByType(NodeAnnotationTypeEnum.UNDERLINE)) === null || _a === void 0 ? void 0 : _a.underline;
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
onClick() {
|
|
428
|
+
const selected = this.isSelected();
|
|
429
|
+
this.selectionController
|
|
430
|
+
.getSelectedNodes()
|
|
431
|
+
.filter((node) => node instanceof RTETextNode)
|
|
432
|
+
.forEach((node) => node.apply(new UnderlineAnnotationAction(!selected)));
|
|
433
|
+
}
|
|
434
|
+
isDisabled() {
|
|
435
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
436
|
+
return selectedNodes.some((node) => {
|
|
437
|
+
var _a;
|
|
438
|
+
return ((_a = node.getAnnotationByType(NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
439
|
+
node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE);
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
(() => {
|
|
444
|
+
VegaInternalIconManager.register({ underline });
|
|
445
|
+
})();
|
|
446
|
+
__decorate$u([
|
|
447
|
+
MapToComponentField()
|
|
448
|
+
], UnderlineToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
449
|
+
|
|
450
|
+
const textSize = {
|
|
451
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M64 128V96h96l0 320H128c-17.7 0-32 14.3-32 32s14.3 32 32 32H256c17.7 0 32-14.3 32-32s-14.3-32-32-32H224l0-320h96v32c0 17.7 14.3 32 32 32s32-14.3 32-32V80c0-26.5-21.5-48-48-48H192 48C21.5 32 0 53.5 0 80v48c0 17.7 14.3 32 32 32s32-14.3 32-32zM384 304V288h64l0 128H432c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H512l0-128h64v16c0 17.7 14.3 32 32 32s32-14.3 32-32V272c0-26.5-21.5-48-48-48H368c-26.5 0-48 21.5-48 48v32c0 17.7 14.3 32 32 32s32-14.3 32-32z"/></svg>`,
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
var __decorate$t = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
455
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
456
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
457
|
+
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;
|
|
458
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
459
|
+
};
|
|
460
|
+
class TextStylesToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
461
|
+
constructor() {
|
|
462
|
+
super({
|
|
463
|
+
icon: 'text-size',
|
|
464
|
+
tooltip: { text: 'Text Styles' },
|
|
465
|
+
});
|
|
466
|
+
this.handleDropdownItemClick = (payload) => {
|
|
467
|
+
const selectedType = payload.detail;
|
|
468
|
+
const boldByDefault = TextStylesToolbarButtonSlimmer.items.find((item) => item.key === selectedType).bold;
|
|
469
|
+
const selectedTextBlocks = this.selectionController
|
|
470
|
+
.getSelectedBlocks()
|
|
471
|
+
.filter((block) => block instanceof RTETextBlock);
|
|
472
|
+
if (selectedTextBlocks.length > 0) {
|
|
473
|
+
selectedTextBlocks.forEach((item) => {
|
|
474
|
+
item.apply(new TextStyleAnnotationAction(selectedType, boldByDefault));
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
void this.focusController.focusOnLastTextNode({ newLine: true }).then(() => {
|
|
479
|
+
this.selectionController
|
|
480
|
+
.getSelectedBlocks()
|
|
481
|
+
.filter((node) => node instanceof RTETextBlock)
|
|
482
|
+
.forEach((item) => {
|
|
483
|
+
item.apply(new TextStyleAnnotationAction(selectedType, boldByDefault));
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
renderBtnWrapper(renderBtn) {
|
|
490
|
+
return (h("vega-dropdown", { selectType: "single", trigger: "click", alignment: "center", selectedSourceKey: this.getSelectedSourceKey(), ref: (ref) => {
|
|
491
|
+
this.addDropdownObserver(ref);
|
|
492
|
+
} },
|
|
493
|
+
renderBtn({ showArrowIcon: true }),
|
|
494
|
+
h("div", Object.assign({ slot: "items" }, super.preventLostFocus()), this.renderDropdownContent())));
|
|
495
|
+
}
|
|
496
|
+
renderDropdownContent() {
|
|
497
|
+
return (h(Fragment, null, TextStylesToolbarButtonSlimmer.items.map((item) => {
|
|
498
|
+
const textStyleAnnotation = new TextStyleAnnotation(item.key);
|
|
499
|
+
const boldAnnotation = new BoldAnnotation(item.bold);
|
|
500
|
+
return (h("vega-dropdown-item", { key: item.key, itemKey: item.key },
|
|
501
|
+
h("vega-box", { padding: { right: 'size-20' } },
|
|
502
|
+
h("div", { style: Object.assign(Object.assign({}, textStyleAnnotation.render()), boldAnnotation.render()) }, item.label))));
|
|
503
|
+
})));
|
|
504
|
+
}
|
|
505
|
+
isSelected() {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
isDisabled() {
|
|
509
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
510
|
+
return selectedNodes.some((node) => node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE));
|
|
511
|
+
}
|
|
512
|
+
addDropdownObserver(dropdownRef) {
|
|
513
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(dropdownRef, VegaDropdownClick, this.handleDropdownItemClick);
|
|
514
|
+
}
|
|
515
|
+
getSelectedSourceKey() {
|
|
516
|
+
const currentSelectedBlocks = this.selectionController
|
|
517
|
+
.getSelectedBlocks()
|
|
518
|
+
.filter((block) => block instanceof RTETextBlock);
|
|
519
|
+
const isSameType = currentSelectedBlocks.length > 0 &&
|
|
520
|
+
currentSelectedBlocks.every((block) => block.type === currentSelectedBlocks[0].type);
|
|
521
|
+
if (isSameType) {
|
|
522
|
+
const blockAnnotation = currentSelectedBlocks[0].getAnnotationByType(BlockAnnotationTypeEnum.TEXT_STYLE);
|
|
523
|
+
return blockAnnotation.textStyle;
|
|
524
|
+
}
|
|
525
|
+
return '';
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
(() => {
|
|
529
|
+
VegaInternalIconManager.register({
|
|
530
|
+
'text-size': textSize,
|
|
531
|
+
});
|
|
532
|
+
})();
|
|
533
|
+
TextStylesToolbarButtonSlimmer.items = [
|
|
534
|
+
{
|
|
535
|
+
key: 'title',
|
|
536
|
+
label: 'Title',
|
|
537
|
+
bold: true,
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
key: 'subtitle',
|
|
541
|
+
label: 'Subtitle',
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
key: 'heading-1',
|
|
545
|
+
label: 'Heading 1',
|
|
546
|
+
bold: true,
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
key: 'heading-2',
|
|
550
|
+
label: 'Heading 2',
|
|
551
|
+
bold: true,
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
key: 'heading-3',
|
|
555
|
+
label: 'Heading 3',
|
|
556
|
+
bold: true,
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
key: 'paragraph',
|
|
560
|
+
label: 'Paragraph',
|
|
561
|
+
},
|
|
562
|
+
];
|
|
563
|
+
__decorate$t([
|
|
564
|
+
MapToComponentField()
|
|
565
|
+
], TextStylesToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
566
|
+
__decorate$t([
|
|
567
|
+
MapToComponentField()
|
|
568
|
+
], TextStylesToolbarButtonSlimmer.prototype, "focusController", void 0);
|
|
569
|
+
|
|
570
|
+
const TextSlash = {
|
|
571
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L355.7 253.5 400.2 96H503L497 120.2c-4.3 17.1 6.1 34.5 23.3 38.8s34.5-6.1 38.8-23.3l11-44.1C577.6 61.3 554.7 32 523.5 32H376.1h-.3H204.5c-22 0-41.2 15-46.6 36.4l-6.3 25.2L38.8 5.1zm168 131.7c.1-.3 .2-.7 .3-1L217 96H333.7L301.3 210.8l-94.5-74.1zM243.3 416H192c-17.7 0-32 14.3-32 32s14.3 32 32 32H352c17.7 0 32-14.3 32-32s-14.3-32-32-32H309.8l17.6-62.1L272.9 311 243.3 416z"/></svg>`,
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
var __decorate$s = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
575
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
576
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
577
|
+
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;
|
|
578
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
579
|
+
};
|
|
580
|
+
class ClearStyleToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
581
|
+
constructor() {
|
|
582
|
+
super({
|
|
583
|
+
icon: 'text-slash',
|
|
584
|
+
tooltip: {
|
|
585
|
+
text: 'Clear Style',
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
isSelected() {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
onClick() {
|
|
593
|
+
this.selectionController
|
|
594
|
+
.getSelectedNodes()
|
|
595
|
+
.filter((node) => node instanceof RTETextNode)
|
|
596
|
+
.forEach((node) => {
|
|
597
|
+
node.apply(new ClearFormattingAnnotationAction());
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
isDisabled() {
|
|
601
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
602
|
+
return selectedNodes.some((node) => node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE));
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
(() => {
|
|
606
|
+
VegaInternalIconManager.register({
|
|
607
|
+
'text-slash': TextSlash,
|
|
608
|
+
});
|
|
609
|
+
})();
|
|
610
|
+
__decorate$s([
|
|
611
|
+
MapToComponentField()
|
|
612
|
+
], ClearStyleToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
613
|
+
|
|
614
|
+
const codeSimple = {
|
|
615
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 214.6 118.6zm146.7 0L498.7 256 361.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3z"/></svg>`,
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
var __decorate$r = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
619
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
620
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
621
|
+
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;
|
|
622
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
623
|
+
};
|
|
624
|
+
class CodeToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
625
|
+
constructor() {
|
|
626
|
+
super({
|
|
627
|
+
icon: 'code-simple',
|
|
628
|
+
tooltip: { text: 'Code' },
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
onClick() {
|
|
632
|
+
const selected = this.isSelected();
|
|
633
|
+
this.selectionController
|
|
634
|
+
.getSelectedNodes()
|
|
635
|
+
.filter((node) => node instanceof RTETextNode)
|
|
636
|
+
.forEach((node) => node.apply(new CodeAnnotationAction(!selected)));
|
|
637
|
+
}
|
|
638
|
+
isSelected() {
|
|
639
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
640
|
+
return (selectedNodes.length > 0 &&
|
|
641
|
+
selectedNodes
|
|
642
|
+
.filter((node) => node instanceof RTETextNode)
|
|
643
|
+
.map((node) => node.getAnnotationByType(NodeAnnotationTypeEnum.CODE))
|
|
644
|
+
.every((annotation) => annotation && annotation.code));
|
|
645
|
+
}
|
|
646
|
+
isDisabled() {
|
|
647
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
648
|
+
return selectedNodes.some((node) => node.getAnnotationByType(NodeAnnotationTypeEnum.LINK) ||
|
|
649
|
+
node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE));
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
(() => {
|
|
653
|
+
VegaInternalIconManager.register({ 'code-simple': codeSimple });
|
|
654
|
+
})();
|
|
655
|
+
__decorate$r([
|
|
656
|
+
MapToComponentField()
|
|
657
|
+
], CodeToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
658
|
+
|
|
659
|
+
const strikethrough = {
|
|
660
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path fill="currentColor" d="M332.2 319.9c17.22 12.17 22.33 26.51 18.61 48.21c-3.031 17.59-10.88 29.34-24.72 36.99c-35.44 19.75-108.5 11.96-186-19.68c-16.34-6.686-35.03 1.156-41.72 17.53s1.188 35.05 17.53 41.71c31.75 12.93 95.69 35.37 157.6 35.37c29.62 0 58.81-5.156 83.72-18.96c30.81-17.09 50.44-45.46 56.72-82.11c3.998-23.27 2.168-42.58-3.488-59.05H332.2zM488 239.9l-176.5-.0309c-15.85-5.613-31.83-10.34-46.7-14.62c-85.47-24.62-110.9-39.05-103.7-81.33c2.5-14.53 10.16-25.96 22.72-34.03c20.47-13.15 64.06-23.84 155.4 .3438c17.09 4.531 34.59-5.654 39.13-22.74c4.531-17.09-5.656-34.59-22.75-39.12c-91.31-24.18-160.7-21.62-206.3 7.654C121.8 73.72 103.6 101.1 98.09 133.1C89.26 184.5 107.9 217.3 137.2 239.9L24 239.9c-13.25 0-24 10.75-24 23.1c0 13.25 10.75 23.1 24 23.1h464c13.25 0 24-10.75 24-23.1C512 250.7 501.3 239.9 488 239.9z"/></svg>`,
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Action to toggle the strikethrough annotation
|
|
665
|
+
*/
|
|
666
|
+
class StrikethroughAnnotationAction extends TextSplittableAction {
|
|
667
|
+
constructor(underline) {
|
|
668
|
+
super();
|
|
669
|
+
this.isFlushable = true;
|
|
670
|
+
this.strikethrough = underline;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Converts the action to an annotation
|
|
674
|
+
*
|
|
675
|
+
* @returns {StrikethroughAnnotation} the annotation
|
|
676
|
+
*/
|
|
677
|
+
toAnnotation() {
|
|
678
|
+
return new StrikethroughAnnotation(this.strikethrough);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
var __decorate$q = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
683
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
684
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
685
|
+
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;
|
|
686
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
687
|
+
};
|
|
688
|
+
class StrikethroughToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
689
|
+
constructor() {
|
|
690
|
+
super({
|
|
691
|
+
icon: 'strikethrough',
|
|
692
|
+
tooltip: { text: 'Strikethrough' },
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
isSelected() {
|
|
696
|
+
const selectedNodes = this.selectionController
|
|
697
|
+
.getSelectedNodes()
|
|
698
|
+
.filter((node) => node instanceof RTETextNode);
|
|
699
|
+
return (selectedNodes.length > 0 &&
|
|
700
|
+
selectedNodes.every((node) => {
|
|
701
|
+
var _a;
|
|
702
|
+
return (_a = node.getAnnotationByType(NodeAnnotationTypeEnum.STRIKETHROUGH)) === null || _a === void 0 ? void 0 : _a.strikethrough;
|
|
703
|
+
}));
|
|
704
|
+
}
|
|
705
|
+
onClick() {
|
|
706
|
+
const selected = this.isSelected();
|
|
707
|
+
this.selectionController
|
|
708
|
+
.getSelectedNodes()
|
|
709
|
+
.filter((node) => node instanceof RTETextNode)
|
|
710
|
+
.forEach((node) => node.apply(new StrikethroughAnnotationAction(!selected)));
|
|
711
|
+
}
|
|
712
|
+
isDisabled() {
|
|
713
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
714
|
+
return selectedNodes.some((node) => {
|
|
715
|
+
var _a;
|
|
716
|
+
return ((_a = node.getAnnotationByType(NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
717
|
+
node.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
(() => {
|
|
722
|
+
VegaInternalIconManager.register({ strikethrough });
|
|
723
|
+
})();
|
|
724
|
+
__decorate$q([
|
|
725
|
+
MapToComponentField()
|
|
726
|
+
], StrikethroughToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
727
|
+
|
|
728
|
+
const link = {
|
|
729
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M562.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L405.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C189.5 251.2 196 330 246 380c56.5 56.5 148 56.5 204.5 0L562.8 267.7zM43.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C57 372 57 321 88.5 289.5L200.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C416.5 260.8 410 182 360 132c-56.5-56.5-148-56.5-204.5 0L43.2 244.3z"/></svg>`,
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Action to change the selection range
|
|
734
|
+
*/
|
|
735
|
+
class SelectionChangeAction extends AnnotationAction {
|
|
736
|
+
constructor(range) {
|
|
737
|
+
super();
|
|
738
|
+
this.isFlushable = false;
|
|
739
|
+
this.range = range;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Converts the action to an annotation
|
|
743
|
+
*
|
|
744
|
+
* @returns {SelectionRangeAnnotation} The annotation
|
|
745
|
+
*/
|
|
746
|
+
toAnnotation() {
|
|
747
|
+
return new SelectionRangeAnnotation(this.range);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
var __decorate$p = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
752
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
753
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
754
|
+
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;
|
|
755
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
756
|
+
};
|
|
757
|
+
class LinkToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
758
|
+
constructor() {
|
|
759
|
+
super({
|
|
760
|
+
icon: 'link',
|
|
761
|
+
tooltip: {
|
|
762
|
+
text: 'Link',
|
|
763
|
+
},
|
|
764
|
+
});
|
|
765
|
+
this.handleLinkEditorChange = ({ detail, }) => {
|
|
766
|
+
switch (detail.action) {
|
|
767
|
+
case 'link': {
|
|
768
|
+
const { url, text } = detail.payload;
|
|
769
|
+
const textChanged = text !== this.currentSelectedText;
|
|
770
|
+
const groupKey = generateUUID();
|
|
771
|
+
this.currentSelectedNodes.forEach((node) => {
|
|
772
|
+
node.apply(new SelectionChangeAction(this.currentRange)).apply(new LinkAnnotationAction({
|
|
773
|
+
link: { href: url, groupKey: groupKey },
|
|
774
|
+
newText: textChanged ? text : undefined,
|
|
775
|
+
needMergeNode: textChanged && this.currentSelectedNodes.length > 1,
|
|
776
|
+
}));
|
|
777
|
+
});
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
renderBtnWrapper(renderBtn) {
|
|
784
|
+
return (h("div", { class: "toolbar-btn-link-wrapper", ref: (ref) => (this.linkBtnWrapperRef = ref) },
|
|
785
|
+
renderBtn(),
|
|
786
|
+
h("vega-rich-text-link-editor", { resetStatusAfterHide: false, status: "linkEdit", ref: (ref) => {
|
|
787
|
+
if (ref) {
|
|
788
|
+
this.linkEditorRef = ref;
|
|
789
|
+
}
|
|
790
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaChange, this.handleLinkEditorChange);
|
|
791
|
+
} })));
|
|
792
|
+
}
|
|
793
|
+
isSelected() {
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
isDisabled() {
|
|
797
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
798
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
799
|
+
return (selectedBlocks.length > 1 ||
|
|
800
|
+
selectedNodes.some((node) => {
|
|
801
|
+
var _a;
|
|
802
|
+
return !(node instanceof RTETextNode) ||
|
|
803
|
+
node.getAnnotationByType(NodeAnnotationTypeEnum.LINK) ||
|
|
804
|
+
((_a = node.getAnnotationByType(NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code);
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
onClick() {
|
|
808
|
+
this.currentRange = this.selectionController.getCurrentRange().toNativeRange();
|
|
809
|
+
this.currentSelectedNodes = this.selectionController.getSelectedNodes();
|
|
810
|
+
if (this.currentRange) {
|
|
811
|
+
this.currentSelectedText = this.currentRange.toString();
|
|
812
|
+
if (this.currentSelectedNodes.length > 0) {
|
|
813
|
+
this.linkEditorRef.record = {
|
|
814
|
+
text: this.currentSelectedText,
|
|
815
|
+
url: '',
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
// Set target prop and call show method at the first time to make sure showing later than overrides method call focusController.focusOnLastTextNode()
|
|
820
|
+
// Element appender will control the show and hide logic except for the first time.
|
|
821
|
+
if (!this.linkEditorRef.target) {
|
|
822
|
+
this.linkEditorRef.target = this.linkBtnWrapperRef;
|
|
823
|
+
void waitForComponentDidRender(this.linkEditorRef).then(() => {
|
|
824
|
+
void this.linkEditorRef.show();
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
(() => {
|
|
830
|
+
VegaInternalIconManager.register({ link: link });
|
|
831
|
+
})();
|
|
832
|
+
__decorate$p([
|
|
833
|
+
MapToComponentField()
|
|
834
|
+
], LinkToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
835
|
+
|
|
836
|
+
const indent = {
|
|
837
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M0 64C0 46.3 14.3 32 32 32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 96 0 81.7 0 64zM192 192c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32zm32 96H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zM0 448c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM127.8 268.6L25.8 347.9C15.3 356.1 0 348.6 0 335.3V176.7c0-13.3 15.3-20.8 25.8-12.6l101.9 79.3c8.2 6.4 8.2 18.9 0 25.3z"/></svg>`,
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Action to toggle block indent annotation
|
|
842
|
+
*/
|
|
843
|
+
class IndentAnnotationAction extends AnnotationAction {
|
|
844
|
+
constructor(indent) {
|
|
845
|
+
super();
|
|
846
|
+
this.isFlushable = true;
|
|
847
|
+
this.indent = indent;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Converts the action to an annotation
|
|
851
|
+
*
|
|
852
|
+
* @returns {IndentAnnotation} The annotation
|
|
853
|
+
*/
|
|
854
|
+
toAnnotation() {
|
|
855
|
+
return new IndentAnnotation(this.indent);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
var __decorate$o = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
860
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
861
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
862
|
+
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;
|
|
863
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
864
|
+
};
|
|
865
|
+
class MoreIndentToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
866
|
+
constructor() {
|
|
867
|
+
super({
|
|
868
|
+
icon: 'indent',
|
|
869
|
+
tooltip: {
|
|
870
|
+
text: 'More Indent',
|
|
871
|
+
},
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
isSelected() {
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
isDisabled() {
|
|
878
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
879
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
880
|
+
return (selectedBlocks.some((node) => node.type === 'list-item') ||
|
|
881
|
+
selectedNodes.some((node) => node instanceof RTEImageNode));
|
|
882
|
+
}
|
|
883
|
+
onClick() {
|
|
884
|
+
this.selectionController.getSelectedBlocks().forEach((item) => {
|
|
885
|
+
var _a, _b;
|
|
886
|
+
const indent = (_b = (_a = item.getAnnotationByType(BlockAnnotationTypeEnum.INDENT)) === null || _a === void 0 ? void 0 : _a.indent) !== null && _b !== void 0 ? _b : 0;
|
|
887
|
+
item.apply(new IndentAnnotationAction(indent + 1));
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
(() => {
|
|
892
|
+
VegaInternalIconManager.register({ indent: indent });
|
|
893
|
+
})();
|
|
894
|
+
__decorate$o([
|
|
895
|
+
MapToComponentField()
|
|
896
|
+
], MoreIndentToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
897
|
+
|
|
898
|
+
const outdent = {
|
|
899
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M6 64C6 46.3 20.3 32 38 32H422c17.7 0 32 14.3 32 32s-14.3 32-32 32H38C20.3 96 6 81.7 6 64zM198 192c0-17.7 14.3-32 32-32H422c17.7 0 32 14.3 32 32s-14.3 32-32 32H230c-17.7 0-32-14.3-32-32zm32 96H422c17.7 0 32 14.3 32 32s-14.3 32-32 32H230c-17.7 0-32-14.3-32-32s14.3-32 32-32zM6 448c0-17.7 14.3-32 32-32H422c17.7 0 32 14.3 32 32s-14.3 32-32 32H38c-17.7 0-32-14.3-32-32zm.2-179.4c-8.2-6.4-8.2-18.9 0-25.3l101.9-79.3c10.5-8.2 25.8-.7 25.8 12.6V335.3c0 13.3-15.3 20.8-25.8 12.6L6.2 268.6z"/></svg>`,
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
var __decorate$n = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
903
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
904
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
905
|
+
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;
|
|
906
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
907
|
+
};
|
|
908
|
+
class LessIndentToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
909
|
+
constructor() {
|
|
910
|
+
super({
|
|
911
|
+
icon: 'outdent',
|
|
912
|
+
tooltip: {
|
|
913
|
+
text: 'Less Indent',
|
|
914
|
+
},
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
isSelected() {
|
|
918
|
+
return false;
|
|
919
|
+
}
|
|
920
|
+
isDisabled() {
|
|
921
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
922
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
923
|
+
return (selectedBlocks.some((node) => node.type === 'list-item') ||
|
|
924
|
+
selectedNodes.some((node) => node instanceof RTEImageNode));
|
|
925
|
+
}
|
|
926
|
+
onClick() {
|
|
927
|
+
this.selectionController.getSelectedBlocks().forEach((item) => {
|
|
928
|
+
var _a, _b;
|
|
929
|
+
const indent = (_b = (_a = item.getAnnotationByType(BlockAnnotationTypeEnum.INDENT)) === null || _a === void 0 ? void 0 : _a.indent) !== null && _b !== void 0 ? _b : 0;
|
|
930
|
+
const newIndent = indent > 1 ? indent - 1 : 0;
|
|
931
|
+
item.apply(new IndentAnnotationAction(newIndent));
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
(() => {
|
|
936
|
+
VegaInternalIconManager.register({ outdent: outdent });
|
|
937
|
+
})();
|
|
938
|
+
__decorate$n([
|
|
939
|
+
MapToComponentField()
|
|
940
|
+
], LessIndentToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
941
|
+
|
|
942
|
+
const image = {
|
|
943
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M0 96C0 60.7 28.7 32 64 32H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h96 32H424c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>`,
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
var __decorate$m = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
947
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
948
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
949
|
+
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;
|
|
950
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
951
|
+
};
|
|
952
|
+
class ImageToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
953
|
+
constructor() {
|
|
954
|
+
super({
|
|
955
|
+
icon: 'image',
|
|
956
|
+
tooltip: { text: 'Image' },
|
|
957
|
+
});
|
|
958
|
+
this.onClick = () => {
|
|
959
|
+
this.inputElementRef.click();
|
|
960
|
+
};
|
|
961
|
+
/**
|
|
962
|
+
* The below method is e2e-test covered in
|
|
963
|
+
* @see{module:should-update-url-properly-when-upload-images}
|
|
964
|
+
*/
|
|
965
|
+
/* istanbul ignore next */
|
|
966
|
+
this.fileInputChange = (e) => {
|
|
967
|
+
e.stopPropagation();
|
|
968
|
+
const input = e.target;
|
|
969
|
+
if (!input.files.length) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const node = this.insertImageController.insertImageToCaretPosition(URL.createObjectURL(input.files[0]));
|
|
973
|
+
if (!this.updateNodeURLMap) {
|
|
974
|
+
this.updateNodeURLMap = new Map();
|
|
975
|
+
}
|
|
976
|
+
this.updateNodeURLMap.set(node, (url) => {
|
|
977
|
+
node.url = url;
|
|
978
|
+
});
|
|
979
|
+
const payload = {
|
|
980
|
+
file: input.files[0],
|
|
981
|
+
sendBackUploadedURLCallback: this.updateNodeURLMap.get(node),
|
|
982
|
+
};
|
|
983
|
+
this.imageInsertedEventEmitter.emit(payload);
|
|
984
|
+
input.value = '';
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
renderBtnWrapper(renderBtn) {
|
|
988
|
+
return (h("vega-box", null,
|
|
989
|
+
renderBtn({ showArrowIcon: false }),
|
|
990
|
+
h("input", { type: "file", style: { display: 'none' }, ref: (node) => (this.inputElementRef = node), accept: "image/*", onChange: this.fileInputChange })));
|
|
991
|
+
}
|
|
992
|
+
isSelected() {
|
|
993
|
+
return false;
|
|
994
|
+
}
|
|
995
|
+
isDisabled() {
|
|
996
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
997
|
+
return selectedNodes.some((node) => node.getAnnotationByType(NodeAnnotationTypeEnum.LINK));
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
(() => {
|
|
1001
|
+
VegaInternalIconManager.register({ image: image });
|
|
1002
|
+
})();
|
|
1003
|
+
__decorate$m([
|
|
1004
|
+
MapToComponentField()
|
|
1005
|
+
], ImageToolbarButtonSlimmer.prototype, "insertImageController", void 0);
|
|
1006
|
+
__decorate$m([
|
|
1007
|
+
MapToComponentField()
|
|
1008
|
+
], ImageToolbarButtonSlimmer.prototype, "imageInsertedEventEmitter", void 0);
|
|
1009
|
+
__decorate$m([
|
|
1010
|
+
MapToComponentField()
|
|
1011
|
+
], ImageToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1012
|
+
|
|
1013
|
+
const ListUL = {
|
|
1014
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"/></svg>`,
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
const ListOL = {
|
|
1018
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M24 56c0-13.3 10.7-24 24-24H80c13.3 0 24 10.7 24 24V176h16c13.3 0 24 10.7 24 24s-10.7 24-24 24H40c-13.3 0-24-10.7-24-24s10.7-24 24-24H56V80H48C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432H120c13.3 0 24 10.7 24 24s-10.7 24-24 24H32c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>`,
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Action to toggle bullet annotation
|
|
1023
|
+
*/
|
|
1024
|
+
class TransformListAction extends ModifyContentAction {
|
|
1025
|
+
constructor(listType, selectedBlocks) {
|
|
1026
|
+
super();
|
|
1027
|
+
this.type = ModifyContentActionType.TRANSFORM_LIST_BLOCK;
|
|
1028
|
+
this.isFlushable = true;
|
|
1029
|
+
this.listType = listType;
|
|
1030
|
+
this.selectedBlocks = selectedBlocks;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Action to toggle bullet annotation
|
|
1036
|
+
*/
|
|
1037
|
+
class TransformParagraphAction extends ModifyContentAction {
|
|
1038
|
+
constructor(selectedBlocks) {
|
|
1039
|
+
super();
|
|
1040
|
+
this.type = ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK;
|
|
1041
|
+
this.isFlushable = true;
|
|
1042
|
+
this.selectedBlocks = selectedBlocks;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
var __decorate$l = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1047
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1048
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1049
|
+
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;
|
|
1050
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1051
|
+
};
|
|
1052
|
+
class BulletsToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1053
|
+
constructor() {
|
|
1054
|
+
super({
|
|
1055
|
+
icon: 'list-ul',
|
|
1056
|
+
tooltip: {
|
|
1057
|
+
text: 'Bullets',
|
|
1058
|
+
},
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
isSelected() {
|
|
1062
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1063
|
+
return this.isListType(selectedBlocks);
|
|
1064
|
+
}
|
|
1065
|
+
onClick() {
|
|
1066
|
+
if (this.isSelected()) {
|
|
1067
|
+
this.deselectBulletList();
|
|
1068
|
+
}
|
|
1069
|
+
else {
|
|
1070
|
+
this.selectBulletList();
|
|
1071
|
+
}
|
|
1072
|
+
void this.popoverRef.hide();
|
|
1073
|
+
}
|
|
1074
|
+
isDisabled() {
|
|
1075
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1076
|
+
return selectedNodes.some((node) => node instanceof RTEImageNode);
|
|
1077
|
+
}
|
|
1078
|
+
isListType(selectedBlocks, type = 'bullet-list') {
|
|
1079
|
+
return (selectedBlocks.length > 0 &&
|
|
1080
|
+
selectedBlocks.every((block) => block instanceof RTEListItemBlock && block.parent.type === type));
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Deselect bullet list item to convert it to default paragraph
|
|
1084
|
+
*/
|
|
1085
|
+
deselectBulletList() {
|
|
1086
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1087
|
+
if (selectedBlocks[0]) {
|
|
1088
|
+
selectedBlocks[0].parent.apply(new TransformParagraphAction(selectedBlocks));
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Select texts or list items or texts and list items to convert it to bullet list
|
|
1093
|
+
*/
|
|
1094
|
+
selectBulletList() {
|
|
1095
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1096
|
+
if (selectedBlocks[0]) {
|
|
1097
|
+
const selectedFirstBlock = selectedBlocks[0].type === 'list-item'
|
|
1098
|
+
? selectedBlocks[0].parent
|
|
1099
|
+
: selectedBlocks[0];
|
|
1100
|
+
selectedFirstBlock.apply(new TransformListAction('bullet-list', selectedBlocks));
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
__decorate$l([
|
|
1105
|
+
MapToComponentField()
|
|
1106
|
+
], BulletsToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1107
|
+
__decorate$l([
|
|
1108
|
+
MapToComponentField()
|
|
1109
|
+
], BulletsToolbarButtonSlimmer.prototype, "popoverRef", void 0);
|
|
1110
|
+
|
|
1111
|
+
var __decorate$k = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1112
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1113
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1114
|
+
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;
|
|
1115
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1116
|
+
};
|
|
1117
|
+
class NumbersToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1118
|
+
constructor() {
|
|
1119
|
+
super({
|
|
1120
|
+
icon: 'list-ol',
|
|
1121
|
+
tooltip: { text: 'Numbers' },
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
isSelected() {
|
|
1125
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1126
|
+
return this.isListType(selectedBlocks);
|
|
1127
|
+
}
|
|
1128
|
+
onClick() {
|
|
1129
|
+
if (this.isSelected()) {
|
|
1130
|
+
this.deselectNumberList();
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
this.selectNumberList();
|
|
1134
|
+
}
|
|
1135
|
+
void this.popoverRef.hide();
|
|
1136
|
+
}
|
|
1137
|
+
isDisabled() {
|
|
1138
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1139
|
+
return selectedNodes.some((node) => node instanceof RTEImageNode);
|
|
1140
|
+
}
|
|
1141
|
+
isListType(selectedBlocks, type = 'number-list') {
|
|
1142
|
+
return (selectedBlocks.length > 0 &&
|
|
1143
|
+
selectedBlocks.every((block) => block instanceof RTEListItemBlock && block.parent.type === type));
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Deselect bullet list item to convert it to default paragraph
|
|
1147
|
+
*/
|
|
1148
|
+
deselectNumberList() {
|
|
1149
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1150
|
+
if (selectedBlocks[0]) {
|
|
1151
|
+
selectedBlocks[0].parent.apply(new TransformParagraphAction(selectedBlocks));
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Select texts or list items or texts and list items to convert it to bullet list
|
|
1156
|
+
*/
|
|
1157
|
+
selectNumberList() {
|
|
1158
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1159
|
+
if (selectedBlocks[0]) {
|
|
1160
|
+
const selectedFirstBlock = selectedBlocks[0].type === 'list-item'
|
|
1161
|
+
? selectedBlocks[0].parent
|
|
1162
|
+
: selectedBlocks[0];
|
|
1163
|
+
selectedFirstBlock.apply(new TransformListAction('number-list', selectedBlocks));
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
__decorate$k([
|
|
1168
|
+
MapToComponentField()
|
|
1169
|
+
], NumbersToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1170
|
+
__decorate$k([
|
|
1171
|
+
MapToComponentField()
|
|
1172
|
+
], NumbersToolbarButtonSlimmer.prototype, "popoverRef", void 0);
|
|
1173
|
+
|
|
1174
|
+
var __decorate$j = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1175
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1176
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1177
|
+
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;
|
|
1178
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1179
|
+
};
|
|
1180
|
+
class BulletsNumbersToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1181
|
+
constructor() {
|
|
1182
|
+
super({
|
|
1183
|
+
icon: 'list-ul',
|
|
1184
|
+
tooltip: {
|
|
1185
|
+
text: 'Bullets',
|
|
1186
|
+
},
|
|
1187
|
+
});
|
|
1188
|
+
this.bulletsToolbarButtonSlimmer = new BulletsToolbarButtonSlimmer();
|
|
1189
|
+
this.numbersToolbarButtonSlimmer = new NumbersToolbarButtonSlimmer();
|
|
1190
|
+
}
|
|
1191
|
+
componentWillRender() {
|
|
1192
|
+
if (this.numbersToolbarButtonSlimmer.isSelected()) {
|
|
1193
|
+
super.setIcon('list-ol');
|
|
1194
|
+
}
|
|
1195
|
+
else {
|
|
1196
|
+
super.setIcon('list-ul');
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
renderBtnWrapper(renderBtn) {
|
|
1200
|
+
return (h("vega-popover", { showArrow: false, trigger: "click", placement: "bottom", alignment: "center", ref: (ref) => (this.popoverRef = ref) },
|
|
1201
|
+
h("div", { slot: "popover-content" }, renderBtn({ showArrowIcon: true })),
|
|
1202
|
+
h("div", { slot: "popover" }, this.renderContent())));
|
|
1203
|
+
}
|
|
1204
|
+
renderContent() {
|
|
1205
|
+
return (h("vega-flex", { gap: "size-8", "justify-content": "center" },
|
|
1206
|
+
h("div", null, this.bulletsToolbarButtonSlimmer.render()),
|
|
1207
|
+
h("div", null, this.numbersToolbarButtonSlimmer.render())));
|
|
1208
|
+
}
|
|
1209
|
+
isSelected() {
|
|
1210
|
+
return false;
|
|
1211
|
+
}
|
|
1212
|
+
isDisabled() {
|
|
1213
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1214
|
+
return selectedNodes.some((node) => node instanceof RTEImageNode);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
(() => {
|
|
1218
|
+
VegaInternalIconManager.register({
|
|
1219
|
+
'list-ul': ListUL,
|
|
1220
|
+
'list-ol': ListOL,
|
|
1221
|
+
});
|
|
1222
|
+
})();
|
|
1223
|
+
__decorate$j([
|
|
1224
|
+
MapToComponentField()
|
|
1225
|
+
], BulletsNumbersToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1226
|
+
__decorate$j([
|
|
1227
|
+
InjectVegaSlimmer()
|
|
1228
|
+
], BulletsNumbersToolbarButtonSlimmer.prototype, "bulletsToolbarButtonSlimmer", void 0);
|
|
1229
|
+
__decorate$j([
|
|
1230
|
+
InjectVegaSlimmer()
|
|
1231
|
+
], BulletsNumbersToolbarButtonSlimmer.prototype, "numbersToolbarButtonSlimmer", void 0);
|
|
1232
|
+
__decorate$j([
|
|
1233
|
+
MapToComponentMethod('componentWillRender')
|
|
1234
|
+
], BulletsNumbersToolbarButtonSlimmer.prototype, "componentWillRender", null);
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Action to toggle block horizontal alignment annotation
|
|
1238
|
+
*/
|
|
1239
|
+
class HorizontalAlignmentAnnotationAction extends AnnotationAction {
|
|
1240
|
+
constructor(textAlign) {
|
|
1241
|
+
super();
|
|
1242
|
+
this.isFlushable = true;
|
|
1243
|
+
this.textAlign = textAlign;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Converts the action to an annotation
|
|
1247
|
+
*
|
|
1248
|
+
* @returns {HorizontalAlignmentAnnotation} The annotation
|
|
1249
|
+
*/
|
|
1250
|
+
toAnnotation() {
|
|
1251
|
+
return new HorizontalAlignmentAnnotation(this.textAlign);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
const AlignLeft = {
|
|
1256
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M288 64c0 17.7-14.3 32-32 32H32C14.3 96 0 81.7 0 64S14.3 32 32 32H256c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H256c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`,
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
var __decorate$i = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1260
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1261
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1262
|
+
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;
|
|
1263
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1264
|
+
};
|
|
1265
|
+
class LeftAlignToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1266
|
+
constructor() {
|
|
1267
|
+
super({
|
|
1268
|
+
icon: 'align-left',
|
|
1269
|
+
tooltip: {
|
|
1270
|
+
text: 'Left Align',
|
|
1271
|
+
},
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
isSelected() {
|
|
1275
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1276
|
+
return (selectedBlocks.length > 0 &&
|
|
1277
|
+
selectedBlocks.every((block) => {
|
|
1278
|
+
var _a;
|
|
1279
|
+
return ((_a = block.getAnnotationByType(BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'left';
|
|
1280
|
+
}));
|
|
1281
|
+
}
|
|
1282
|
+
onClick() {
|
|
1283
|
+
this.selectionController
|
|
1284
|
+
.getSelectedBlocks()
|
|
1285
|
+
.forEach((item) => item.apply(new HorizontalAlignmentAnnotationAction('left')));
|
|
1286
|
+
void this.popoverRef.hide();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
(() => {
|
|
1290
|
+
VegaInternalIconManager.register({
|
|
1291
|
+
'align-left': AlignLeft,
|
|
1292
|
+
});
|
|
1293
|
+
})();
|
|
1294
|
+
__decorate$i([
|
|
1295
|
+
MapToComponentField()
|
|
1296
|
+
], LeftAlignToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1297
|
+
__decorate$i([
|
|
1298
|
+
MapToComponentField()
|
|
1299
|
+
], LeftAlignToolbarButtonSlimmer.prototype, "popoverRef", void 0);
|
|
1300
|
+
|
|
1301
|
+
const AlignCenter = {
|
|
1302
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M352 64c0-17.7-14.3-32-32-32H128c-17.7 0-32 14.3-32 32s14.3 32 32 32H320c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32H32c-17.7 0-32 14.3-32 32s14.3 32 32 32H416c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H32c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32H128c-17.7 0-32 14.3-32 32s14.3 32 32 32H320c17.7 0 32-14.3 32-32z"/></svg>`,
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
var __decorate$h = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1306
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1307
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1308
|
+
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;
|
|
1309
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1310
|
+
};
|
|
1311
|
+
class CenterAlignToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1312
|
+
constructor() {
|
|
1313
|
+
super({
|
|
1314
|
+
icon: 'align-center',
|
|
1315
|
+
tooltip: {
|
|
1316
|
+
text: 'Center Align',
|
|
1317
|
+
},
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
isSelected() {
|
|
1321
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1322
|
+
return (selectedBlocks.length > 0 &&
|
|
1323
|
+
selectedBlocks.every((block) => {
|
|
1324
|
+
var _a;
|
|
1325
|
+
return ((_a = block.getAnnotationByType(BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'center';
|
|
1326
|
+
}));
|
|
1327
|
+
}
|
|
1328
|
+
onClick() {
|
|
1329
|
+
this.selectionController
|
|
1330
|
+
.getSelectedBlocks()
|
|
1331
|
+
.forEach((item) => item.apply(new HorizontalAlignmentAnnotationAction('center')));
|
|
1332
|
+
void this.popoverRef.hide();
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
(() => {
|
|
1336
|
+
VegaInternalIconManager.register({
|
|
1337
|
+
'align-center': AlignCenter,
|
|
1338
|
+
});
|
|
1339
|
+
})();
|
|
1340
|
+
__decorate$h([
|
|
1341
|
+
MapToComponentField()
|
|
1342
|
+
], CenterAlignToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1343
|
+
__decorate$h([
|
|
1344
|
+
MapToComponentField()
|
|
1345
|
+
], CenterAlignToolbarButtonSlimmer.prototype, "popoverRef", void 0);
|
|
1346
|
+
|
|
1347
|
+
const AlignRight = {
|
|
1348
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M448 64c0 17.7-14.3 32-32 32H192c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32H192c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`,
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
var __decorate$g = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1352
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1353
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1354
|
+
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;
|
|
1355
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1356
|
+
};
|
|
1357
|
+
class RightAlignToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1358
|
+
constructor() {
|
|
1359
|
+
super({
|
|
1360
|
+
icon: 'align-right',
|
|
1361
|
+
tooltip: {
|
|
1362
|
+
text: 'Right Align',
|
|
1363
|
+
},
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
isSelected() {
|
|
1367
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1368
|
+
return (selectedBlocks.length > 0 &&
|
|
1369
|
+
selectedBlocks.every((block) => {
|
|
1370
|
+
var _a;
|
|
1371
|
+
return ((_a = block.getAnnotationByType(BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'right';
|
|
1372
|
+
}));
|
|
1373
|
+
}
|
|
1374
|
+
onClick() {
|
|
1375
|
+
this.selectionController
|
|
1376
|
+
.getSelectedBlocks()
|
|
1377
|
+
.forEach((item) => item.apply(new HorizontalAlignmentAnnotationAction('right')));
|
|
1378
|
+
void this.popoverRef.hide();
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
(() => {
|
|
1382
|
+
VegaInternalIconManager.register({
|
|
1383
|
+
'align-right': AlignRight,
|
|
1384
|
+
});
|
|
1385
|
+
})();
|
|
1386
|
+
__decorate$g([
|
|
1387
|
+
MapToComponentField()
|
|
1388
|
+
], RightAlignToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1389
|
+
__decorate$g([
|
|
1390
|
+
MapToComponentField()
|
|
1391
|
+
], RightAlignToolbarButtonSlimmer.prototype, "popoverRef", void 0);
|
|
1392
|
+
|
|
1393
|
+
const AlignJustify = {
|
|
1394
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path fill="currentColor" d="M448 64c0-17.7-14.3-32-32-32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32H32c-17.7 0-32 14.3-32 32s14.3 32 32 32H416c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H32c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32H32c-17.7 0-32 14.3-32 32s14.3 32 32 32H416c17.7 0 32-14.3 32-32z"/></svg>`,
|
|
1395
|
+
};
|
|
1396
|
+
|
|
1397
|
+
var __decorate$f = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1398
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1399
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1400
|
+
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;
|
|
1401
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1402
|
+
};
|
|
1403
|
+
class JustifyAlignToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1404
|
+
constructor() {
|
|
1405
|
+
super({
|
|
1406
|
+
icon: 'align-justify',
|
|
1407
|
+
tooltip: {
|
|
1408
|
+
text: 'Justified',
|
|
1409
|
+
},
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
isSelected() {
|
|
1413
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
1414
|
+
return (selectedBlocks.length > 0 &&
|
|
1415
|
+
selectedBlocks.every((block) => {
|
|
1416
|
+
var _a;
|
|
1417
|
+
return ((_a = block.getAnnotationByType(BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'justify';
|
|
1418
|
+
}));
|
|
1419
|
+
}
|
|
1420
|
+
onClick() {
|
|
1421
|
+
this.selectionController
|
|
1422
|
+
.getSelectedBlocks()
|
|
1423
|
+
.forEach((item) => item.apply(new HorizontalAlignmentAnnotationAction('justify')));
|
|
1424
|
+
void this.popoverRef.hide();
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
(() => {
|
|
1428
|
+
VegaInternalIconManager.register({
|
|
1429
|
+
'align-justify': AlignJustify,
|
|
1430
|
+
});
|
|
1431
|
+
})();
|
|
1432
|
+
__decorate$f([
|
|
1433
|
+
MapToComponentField()
|
|
1434
|
+
], JustifyAlignToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1435
|
+
__decorate$f([
|
|
1436
|
+
MapToComponentField()
|
|
1437
|
+
], JustifyAlignToolbarButtonSlimmer.prototype, "popoverRef", void 0);
|
|
1438
|
+
|
|
1439
|
+
var __decorate$e = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1440
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1441
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1442
|
+
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;
|
|
1443
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1444
|
+
};
|
|
1445
|
+
class HorizontalAlignmentToolbarButtonSlimmer extends ToolbarButtonSlimmer {
|
|
1446
|
+
constructor() {
|
|
1447
|
+
super({
|
|
1448
|
+
icon: 'align-left',
|
|
1449
|
+
tooltip: {
|
|
1450
|
+
text: 'Left Align',
|
|
1451
|
+
},
|
|
1452
|
+
});
|
|
1453
|
+
this.leftAlignToolbarButtonSlimmer = new LeftAlignToolbarButtonSlimmer();
|
|
1454
|
+
this.centerAlignToolbarButtonSlimmer = new CenterAlignToolbarButtonSlimmer();
|
|
1455
|
+
this.rightAlignToolbarButtonSlimmer = new RightAlignToolbarButtonSlimmer();
|
|
1456
|
+
this.justifiedToolbarButtonSlimmer = new JustifyAlignToolbarButtonSlimmer();
|
|
1457
|
+
}
|
|
1458
|
+
componentWillRender() {
|
|
1459
|
+
if (this.leftAlignToolbarButtonSlimmer.isSelected()) {
|
|
1460
|
+
super.setIcon('align-left');
|
|
1461
|
+
}
|
|
1462
|
+
else if (this.centerAlignToolbarButtonSlimmer.isSelected()) {
|
|
1463
|
+
super.setIcon('align-center');
|
|
1464
|
+
}
|
|
1465
|
+
else if (this.rightAlignToolbarButtonSlimmer.isSelected()) {
|
|
1466
|
+
super.setIcon('align-right');
|
|
1467
|
+
}
|
|
1468
|
+
else if (this.justifiedToolbarButtonSlimmer.isSelected()) {
|
|
1469
|
+
super.setIcon('align-justify');
|
|
1470
|
+
}
|
|
1471
|
+
else {
|
|
1472
|
+
super.setIcon('align-left');
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
renderBtnWrapper(renderBtn) {
|
|
1476
|
+
return (h("vega-popover", { trigger: "click", showArrow: false, alignment: "center", placement: "bottom", ref: (ref) => (this.popoverRef = ref) },
|
|
1477
|
+
h("div", { slot: "popover-content" }, renderBtn({ showArrowIcon: true })),
|
|
1478
|
+
h("div", { slot: "popover" }, this.renderContent())));
|
|
1479
|
+
}
|
|
1480
|
+
renderContent() {
|
|
1481
|
+
return (h("vega-flex", { gap: "size-8", "justify-content": "center" },
|
|
1482
|
+
h("div", null, this.leftAlignToolbarButtonSlimmer.render()),
|
|
1483
|
+
h("div", null, this.centerAlignToolbarButtonSlimmer.render()),
|
|
1484
|
+
h("div", null, this.rightAlignToolbarButtonSlimmer.render()),
|
|
1485
|
+
h("div", null, this.justifiedToolbarButtonSlimmer.render())));
|
|
1486
|
+
}
|
|
1487
|
+
isSelected() {
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
__decorate$e([
|
|
1492
|
+
MapToComponentField()
|
|
1493
|
+
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
1494
|
+
__decorate$e([
|
|
1495
|
+
InjectVegaSlimmer()
|
|
1496
|
+
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "leftAlignToolbarButtonSlimmer", void 0);
|
|
1497
|
+
__decorate$e([
|
|
1498
|
+
InjectVegaSlimmer()
|
|
1499
|
+
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "centerAlignToolbarButtonSlimmer", void 0);
|
|
1500
|
+
__decorate$e([
|
|
1501
|
+
InjectVegaSlimmer()
|
|
1502
|
+
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "rightAlignToolbarButtonSlimmer", void 0);
|
|
1503
|
+
__decorate$e([
|
|
1504
|
+
InjectVegaSlimmer()
|
|
1505
|
+
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "justifiedToolbarButtonSlimmer", void 0);
|
|
1506
|
+
__decorate$e([
|
|
1507
|
+
MapToComponentMethod('componentWillRender')
|
|
1508
|
+
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "componentWillRender", null);
|
|
1509
|
+
|
|
1510
|
+
let processing = false;
|
|
1511
|
+
/**
|
|
1512
|
+
* Simulate a selection for browsers that don't support shadow selection.
|
|
1513
|
+
* Cypress test case added in https://github.com/heartlandpayments/Vega/pull/1561/files#diff-83bdbaaf47fc156ab878099aa1f21b0e8ab92abe5852521299f1fb6efab001c2R300
|
|
1514
|
+
*/
|
|
1515
|
+
class ShadowSelection {
|
|
1516
|
+
constructor() {
|
|
1517
|
+
this.rangeCount = 0;
|
|
1518
|
+
this.ranges = [];
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Returns a Range object at a specified index.
|
|
1522
|
+
*
|
|
1523
|
+
* @param {number} index - A specified index.
|
|
1524
|
+
* @returns {Range} - A Range object.
|
|
1525
|
+
*/
|
|
1526
|
+
getRangeAt(index) {
|
|
1527
|
+
return this.ranges[index];
|
|
1528
|
+
}
|
|
1529
|
+
/**
|
|
1530
|
+
* Adds a Range to ranges array.
|
|
1531
|
+
*
|
|
1532
|
+
* @param {Range} range - The range of selection.
|
|
1533
|
+
*/
|
|
1534
|
+
addRange(range) {
|
|
1535
|
+
this.ranges.push(range);
|
|
1536
|
+
this.rangeCount = this.ranges.length;
|
|
1537
|
+
if (!processing) {
|
|
1538
|
+
const windowSelection = window.getSelection();
|
|
1539
|
+
windowSelection.removeAllRanges();
|
|
1540
|
+
windowSelection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Clears all ranges.
|
|
1545
|
+
*/
|
|
1546
|
+
removeAllRanges() {
|
|
1547
|
+
this.ranges = [];
|
|
1548
|
+
this.rangeCount = 0;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Due to the ShadowRoot.getSelection is not a standard API, we add this polyfill to achieve this function.
|
|
1553
|
+
*
|
|
1554
|
+
* - On Chromium, calling document.getSelection will not pierce into the Shadow DOM and gives you some unhelpful high-level element.
|
|
1555
|
+
* But it does expose the non-standard getSelection method on the ShadowRoot.
|
|
1556
|
+
*
|
|
1557
|
+
* - On Firefox, it does not implement ShadowRoot.getSelection,
|
|
1558
|
+
* but document.getSelection will pierce through shadow dom and give you the exact element.
|
|
1559
|
+
*
|
|
1560
|
+
* - On Safari, Selection.getComposedRanges is supported as of v17. On versions before that,
|
|
1561
|
+
* ShadowRoot.getSelection is not supported and apparently document.getSelection does not pierce the Shadow DOM, meaning you are just out of luck.
|
|
1562
|
+
*
|
|
1563
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot#shadowroot.getselection
|
|
1564
|
+
* https://stackoverflow.com/a/70523247
|
|
1565
|
+
*/
|
|
1566
|
+
class ShadowSelectionPolyfill {
|
|
1567
|
+
constructor() {
|
|
1568
|
+
this.supportShadowSelection = typeof window.ShadowRoot.prototype['getSelection'] === 'function';
|
|
1569
|
+
this.supportBeforeInput = typeof window.InputEvent.prototype.getTargetRanges === 'function';
|
|
1570
|
+
this.isFirefox = window.navigator.userAgent.toLowerCase().indexOf('firefox') > 0;
|
|
1571
|
+
this.listen();
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* For Firefox, we directly use document.getSelection()
|
|
1575
|
+
* For other browser which not support shadowroot.getSelection, we use this.selection which is built by us.
|
|
1576
|
+
* For browser which supported shadowroot.getSelection, we use shadowRoot.getselection().
|
|
1577
|
+
*
|
|
1578
|
+
* @param {ShadowRoot} shadow - A shadow.
|
|
1579
|
+
* @returns {Selection} - The shadow selection.
|
|
1580
|
+
*/
|
|
1581
|
+
getSelection(shadow) {
|
|
1582
|
+
if (this.supportShadowSelection) {
|
|
1583
|
+
return shadow['getSelection']();
|
|
1584
|
+
}
|
|
1585
|
+
else {
|
|
1586
|
+
return this.isFirefox
|
|
1587
|
+
? this.getFirefoxSelection()
|
|
1588
|
+
: this.polyfilledShadowSelection;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Get selection in firefox.
|
|
1593
|
+
*
|
|
1594
|
+
* Example:
|
|
1595
|
+
*
|
|
1596
|
+
* <span>span1</span><span>span2</span><span>span3</span>
|
|
1597
|
+
*
|
|
1598
|
+
* In firefox, while selected `span2`, the range be likely to:
|
|
1599
|
+
* range:
|
|
1600
|
+
* startContainer: #text 'span1'
|
|
1601
|
+
* startOffset: 5
|
|
1602
|
+
* endContainer: #text 'span3'
|
|
1603
|
+
* endOffset: 0
|
|
1604
|
+
* start is end of brefore node and end is start of after node.
|
|
1605
|
+
*
|
|
1606
|
+
* So we should modify the startContainer and endContainer here.
|
|
1607
|
+
*
|
|
1608
|
+
* modified range:
|
|
1609
|
+
* startContainer: #text 'span2'
|
|
1610
|
+
* startOffset: 0
|
|
1611
|
+
* endContainer: #text 'span2'
|
|
1612
|
+
* endOffset: 5
|
|
1613
|
+
*
|
|
1614
|
+
* @returns {Selection} - document selection
|
|
1615
|
+
*/
|
|
1616
|
+
getFirefoxSelection() {
|
|
1617
|
+
const selection = document.getSelection();
|
|
1618
|
+
const range = selection.getRangeAt(0);
|
|
1619
|
+
const startNode = range.startContainer;
|
|
1620
|
+
const endNode = range.endContainer;
|
|
1621
|
+
if (startNode !== endNode && startNode.textContent.length === range.startOffset) {
|
|
1622
|
+
const nextSibling = startNode.nodeType === Node.TEXT_NODE
|
|
1623
|
+
? startNode.parentNode.nextSibling
|
|
1624
|
+
: startNode.nextSibling;
|
|
1625
|
+
range.setStart(nextSibling.firstChild, 0);
|
|
1626
|
+
}
|
|
1627
|
+
if (endNode !== startNode && range.endOffset === 0) {
|
|
1628
|
+
const previousSibling = endNode.nodeType === Node.TEXT_NODE
|
|
1629
|
+
? endNode.parentNode.previousSibling
|
|
1630
|
+
: endNode.previousSibling;
|
|
1631
|
+
range.setEnd(previousSibling.lastChild, previousSibling.lastChild.textContent.length);
|
|
1632
|
+
}
|
|
1633
|
+
return selection;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Sets up event listeners for `selectionchange` and `beforeinput` events to simulate shadow selection.
|
|
1637
|
+
*/
|
|
1638
|
+
listen() {
|
|
1639
|
+
if (this.isFirefox || this.supportShadowSelection || !this.supportBeforeInput)
|
|
1640
|
+
return;
|
|
1641
|
+
this.polyfilledShadowSelection = new ShadowSelection();
|
|
1642
|
+
window.addEventListener('selectionchange', () => {
|
|
1643
|
+
if (!processing) {
|
|
1644
|
+
processing = true;
|
|
1645
|
+
const active = getActiveElement();
|
|
1646
|
+
if (active && active.hasAttribute('contenteditable')) {
|
|
1647
|
+
// This command will not actually work, it only trigger the `beforeinput` event,
|
|
1648
|
+
// the `beforeinput` event will prevented this command work.
|
|
1649
|
+
document.execCommand('indent');
|
|
1650
|
+
}
|
|
1651
|
+
else {
|
|
1652
|
+
this.polyfilledShadowSelection.removeAllRanges();
|
|
1653
|
+
}
|
|
1654
|
+
processing = false;
|
|
1655
|
+
}
|
|
1656
|
+
}, true);
|
|
1657
|
+
window.addEventListener('beforeinput', (event) => {
|
|
1658
|
+
if (processing) {
|
|
1659
|
+
const ranges = event.getTargetRanges();
|
|
1660
|
+
const range = ranges[0];
|
|
1661
|
+
const newRange = new Range();
|
|
1662
|
+
newRange.setStart(range.startContainer, range.startOffset);
|
|
1663
|
+
newRange.setEnd(range.endContainer, range.endOffset);
|
|
1664
|
+
this.polyfilledShadowSelection.removeAllRanges();
|
|
1665
|
+
this.polyfilledShadowSelection.addRange(newRange);
|
|
1666
|
+
event.preventDefault();
|
|
1667
|
+
event.stopImmediatePropagation();
|
|
1668
|
+
}
|
|
1669
|
+
}, true);
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
const ShadowSelectionPolyfill$1 = new ShadowSelectionPolyfill();
|
|
1673
|
+
|
|
1674
|
+
/** Manages selection range for a rich text editor, providing methods to set, sync, and create native ranges based on RTENodes and Nodes. */
|
|
1675
|
+
class RTERange {
|
|
1676
|
+
/**
|
|
1677
|
+
* Initial the rte range properties
|
|
1678
|
+
*
|
|
1679
|
+
* @param {Node} [startContainer] The range start element.
|
|
1680
|
+
* @param {Node} [endContainer] The range end element.
|
|
1681
|
+
* @param {number} [startOffset] The range start element content offset, default value is 0.
|
|
1682
|
+
* @param {number} [endOffset] The range end element content offset, default value is 0.
|
|
1683
|
+
* @param {RTENode} [startNode] The range start node, the start node could be null if the start element is root element.
|
|
1684
|
+
* @param {RTENode} [endNode] The range start node, the start node could be null if the start element is root element.
|
|
1685
|
+
* @param {Range} [nativeRange] The browser native range instance.
|
|
1686
|
+
*/
|
|
1687
|
+
constructor(startContainer, endContainer, startOffset = 0, endOffset = 0, startNode, endNode, nativeRange) {
|
|
1688
|
+
this._startOffset = 0;
|
|
1689
|
+
this._endOffset = 0;
|
|
1690
|
+
this._startContainer = startContainer;
|
|
1691
|
+
this._endContainer = endContainer;
|
|
1692
|
+
this._startOffset = startOffset;
|
|
1693
|
+
this._endOffset = endOffset;
|
|
1694
|
+
this._startNode = startNode;
|
|
1695
|
+
this._endNode = endNode;
|
|
1696
|
+
if (nativeRange) {
|
|
1697
|
+
this._oldNativeRange = nativeRange;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Returns the start container as a Node or null if it is not set.
|
|
1702
|
+
* The start container could be null when the dom node should be create after re-render.
|
|
1703
|
+
*
|
|
1704
|
+
* @returns {Nullable<Node>} The range start element.
|
|
1705
|
+
*/
|
|
1706
|
+
get startContainer() {
|
|
1707
|
+
return this._startContainer;
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Returns the end container as a Node or null if it is not set.
|
|
1711
|
+
* The end container could be null when the dom node should be create after re-render.
|
|
1712
|
+
*
|
|
1713
|
+
* @returns {Nullable<Node>} The range start element.
|
|
1714
|
+
*/
|
|
1715
|
+
get endContainer() {
|
|
1716
|
+
return this._endContainer;
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Returns the range start RTE node as a RTENode or null if it is not set.
|
|
1720
|
+
* The start RTENode could be null when the range start node is the root element of the rich text editor.
|
|
1721
|
+
*
|
|
1722
|
+
* @returns {Nullable<RTENode>} The range start element.
|
|
1723
|
+
*/
|
|
1724
|
+
get startNode() {
|
|
1725
|
+
return this._startNode;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Returns the range end RTE node as a RTENode or null if it is not set.
|
|
1729
|
+
* The end RTENode could be null when the range end node is the root element of the rich text editor.
|
|
1730
|
+
*
|
|
1731
|
+
* @returns {Nullable<RTENode>} The range start element.
|
|
1732
|
+
*/
|
|
1733
|
+
get endNode() {
|
|
1734
|
+
return this._endNode;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Returns range's start offset.
|
|
1738
|
+
*
|
|
1739
|
+
* @returns {number} The character length in text node or the element index of parent element.
|
|
1740
|
+
*/
|
|
1741
|
+
get startOffset() {
|
|
1742
|
+
return this._startOffset;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Returns range's start offset.
|
|
1746
|
+
*
|
|
1747
|
+
* @returns {number} The character length in text node or the element index of parent element.
|
|
1748
|
+
*/
|
|
1749
|
+
get endOffset() {
|
|
1750
|
+
return this._endOffset;
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Updates the range options for a Rich Text Editor.
|
|
1754
|
+
* This method will called after modify the content, the start node and end node should be rte node.
|
|
1755
|
+
* This method will called after selectionchange event emit, the start node and end node should be the html node.
|
|
1756
|
+
*
|
|
1757
|
+
* @param {RTERangeOptions} options - An object that contains the following properties:
|
|
1758
|
+
* @param {Range} [nativeRange] - The native range instance
|
|
1759
|
+
* @returns {RTERange} - The new RTERange instance
|
|
1760
|
+
*/
|
|
1761
|
+
updateRTERange(options, nativeRange) {
|
|
1762
|
+
const { startOffset, endOffset } = options;
|
|
1763
|
+
this._startOffset = startOffset;
|
|
1764
|
+
this._endOffset = endOffset;
|
|
1765
|
+
const startNode = options.startNode;
|
|
1766
|
+
const endNode = options.endNode;
|
|
1767
|
+
if (startNode instanceof RTENode) {
|
|
1768
|
+
this._startNode = startNode;
|
|
1769
|
+
this._endNode = endNode;
|
|
1770
|
+
const startContainer = this.getElementByRTENode(this._startNode);
|
|
1771
|
+
const endContainer = this._startNode === this._endNode ? startContainer : this.getElementByRTENode(this._endNode);
|
|
1772
|
+
if (startContainer) {
|
|
1773
|
+
this._startContainer = startContainer;
|
|
1774
|
+
this._endContainer = endContainer;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
else {
|
|
1778
|
+
// The selectionchange callback has a 50 ms delay, so we need to check the next range is the same as the current ret range.
|
|
1779
|
+
this._startContainer = startNode;
|
|
1780
|
+
this._endContainer = endNode;
|
|
1781
|
+
this._startNode = this.getRTENodeByElement(this._startContainer);
|
|
1782
|
+
this._endNode =
|
|
1783
|
+
this._startContainer === this._endContainer
|
|
1784
|
+
? this._startNode
|
|
1785
|
+
: this.getRTENodeByElement(this._endContainer);
|
|
1786
|
+
if (nativeRange) {
|
|
1787
|
+
this._oldNativeRange = nativeRange;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
return new RTERange(this._startContainer, this._endContainer, this._startOffset, this._endOffset, this._startNode, this._endNode, this._oldNativeRange);
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Creates a Range object based on start and end nodes and offsets.
|
|
1794
|
+
* Invoke this method to get the future range state if the range content modified.
|
|
1795
|
+
* Invoke this method to get the native range instance if range start node and end node not defined
|
|
1796
|
+
*
|
|
1797
|
+
* @returns {Nullable<Range>} The range instance. The return value could be null if the start node or end node are not rendered.
|
|
1798
|
+
*/
|
|
1799
|
+
toNativeRange() {
|
|
1800
|
+
const startContainer = this.getElementByRTENode(this._startNode);
|
|
1801
|
+
const endContainer = this._startNode === this._endNode ? startContainer : this.getElementByRTENode(this._endNode);
|
|
1802
|
+
const range = new Range();
|
|
1803
|
+
if (startContainer && endContainer) {
|
|
1804
|
+
range.setStart(startContainer, this._startOffset);
|
|
1805
|
+
range.setEnd(endContainer, this._endOffset);
|
|
1806
|
+
this._startContainer = startContainer;
|
|
1807
|
+
this._endContainer = endContainer;
|
|
1808
|
+
this._oldNativeRange = range;
|
|
1809
|
+
return range;
|
|
1810
|
+
}
|
|
1811
|
+
else if (this._oldNativeRange) {
|
|
1812
|
+
return this._oldNativeRange;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Retrieves the DOM element associated with a given RTENode entity.
|
|
1817
|
+
*
|
|
1818
|
+
* @param {Nullable<RTENode>} node - Represents a node in a Rich Text Editor.
|
|
1819
|
+
* @returns {Nullable<Node>} a Node object or null.
|
|
1820
|
+
*/
|
|
1821
|
+
getElementByRTENode(node) {
|
|
1822
|
+
if (node) {
|
|
1823
|
+
const element = stateEntityRenderingRegistry.getDOMByEntity(node);
|
|
1824
|
+
if (element) {
|
|
1825
|
+
return node instanceof RTEImageNode
|
|
1826
|
+
? findParent(element, 'vega-rich-text-image-editor')
|
|
1827
|
+
: element.firstChild;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Retrieves an RTENode based on the given element by checking its type and parent elements.
|
|
1833
|
+
*
|
|
1834
|
+
* @param {Node} element - An element in the DOM (Document Object Model).
|
|
1835
|
+
* @returns { Nullable<RTENode>} Returns a nullable `RTENode` object.
|
|
1836
|
+
*/
|
|
1837
|
+
getRTENodeByElement(element) {
|
|
1838
|
+
if (element) {
|
|
1839
|
+
const registerElement = element.nodeType === Node.TEXT_NODE
|
|
1840
|
+
? element.parentElement
|
|
1841
|
+
: element.nodeName === 'VEGA-RICH-TEXT-IMAGE-EDITOR'
|
|
1842
|
+
? element.querySelector('img')
|
|
1843
|
+
: element;
|
|
1844
|
+
return stateEntityRenderingRegistry.getEntityByDOM(registerElement);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
var __decorate$d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1850
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1851
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1852
|
+
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;
|
|
1853
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1854
|
+
};
|
|
1855
|
+
/**
|
|
1856
|
+
* The text selection controller
|
|
1857
|
+
*/
|
|
1858
|
+
class SelectionController extends VegaSlimmer {
|
|
1859
|
+
constructor() {
|
|
1860
|
+
super(...arguments);
|
|
1861
|
+
this.currentRange = new RTERange();
|
|
1862
|
+
this.updateCaretPositionTaskQueue = new SynchronizeTaskQueue(1);
|
|
1863
|
+
this.handleSelectionWithDebounce = debounce(this.handleSelectionChange, SelectionController.SELECTION_CHANGE_DEBOUNCE_TIME, this);
|
|
1864
|
+
this.selectedNodes = [];
|
|
1865
|
+
/**
|
|
1866
|
+
* Sets the next selection state with specified start and end nodes, offsets, and a timestamp.
|
|
1867
|
+
*
|
|
1868
|
+
* Example:
|
|
1869
|
+
* Before insert text start offset is 0, the new start offset should update to 1
|
|
1870
|
+
* Before delete text start offset is 1, the new start offset should update to 0
|
|
1871
|
+
*
|
|
1872
|
+
*/
|
|
1873
|
+
this.createUpdateSelectionRangeTask = async () => {
|
|
1874
|
+
// add await Promise.resolve to put the code behind to a micro task
|
|
1875
|
+
await Promise.resolve();
|
|
1876
|
+
const range = this.currentRange.toNativeRange();
|
|
1877
|
+
if (range) {
|
|
1878
|
+
this.setSelectionRange(range);
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.connectedCallback}
|
|
1884
|
+
*/
|
|
1885
|
+
connectedCallback() {
|
|
1886
|
+
this.registerSelectionRangeChangeObserver();
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Component lifecycle - [disconnectedCallback]{@link VegaRichTextEditor.disconnectedCallback}
|
|
1890
|
+
*/
|
|
1891
|
+
disconnectedCallback() {
|
|
1892
|
+
ChangeManager.unregister(domNodeSubjectFactory.getSubject(this.host, VegaInternalRichTextEditorSelectionRangeChange), this.selectionRangeChangeObserver);
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Component lifecycle - [componentDidLoad]{@link VegaRichTextEditor.componentDidLoad}
|
|
1896
|
+
*/
|
|
1897
|
+
componentDidLoad() {
|
|
1898
|
+
document.addEventListener('selectionchange', this.handleSelectionWithDebounce);
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Watches the internal value of the editor
|
|
1902
|
+
*/
|
|
1903
|
+
watchValueUpdate() {
|
|
1904
|
+
this.restoreSelection();
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Update the caret position after the component re-render
|
|
1908
|
+
*/
|
|
1909
|
+
async updateCaretPosition() {
|
|
1910
|
+
if (this.updateCaretPositionTaskQueue.queue.length) {
|
|
1911
|
+
await this.updateCaretPositionTaskQueue.runTask();
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Get the current RTE selection range
|
|
1916
|
+
*
|
|
1917
|
+
* @returns {RTERange} - The current RTE selection range
|
|
1918
|
+
*/
|
|
1919
|
+
getCurrentRange() {
|
|
1920
|
+
return this.currentRange;
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Get the selected rich text node
|
|
1924
|
+
*
|
|
1925
|
+
* @returns {RTENode[]} Selected rich text nodes
|
|
1926
|
+
*/
|
|
1927
|
+
getSelectedNodes() {
|
|
1928
|
+
return Array.from(this.selectionMap.values()).flat();
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Get the selected rich text blocks
|
|
1932
|
+
*
|
|
1933
|
+
* @returns {RTEBlock[]} Selected rich text blocks
|
|
1934
|
+
*/
|
|
1935
|
+
getSelectedBlocks() {
|
|
1936
|
+
return Array.from(this.selectionMap.keys());
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Sets the next selection state with specified start and end nodes, offsets, push the update task to a queue
|
|
1940
|
+
*
|
|
1941
|
+
* @param {SelectionStateType['startNode']} startNode - The starting node of the selection range. It is a Node object representing the node where the selection range starts.
|
|
1942
|
+
* @param {number} startOffset - The `startNode` where the selection range should start. It indicates the position within the `startNode` where the selection should begin.
|
|
1943
|
+
* @param {SelectionStateType['endNode']} [endNode] - The ending node of the selection range. If a value is provided for `endNode`, it will be used as the ending node of the selection range.
|
|
1944
|
+
* @param {number} [endOffset] - The ending offset within the `endNode` where the selection range should end.
|
|
1945
|
+
* @param {boolean} [immediatelyRun] - Should the task run immediately. default is false
|
|
1946
|
+
*/
|
|
1947
|
+
enqueueSelectionRangeFutureState(startNode, startOffset, endNode, endOffset, immediatelyRun = false) {
|
|
1948
|
+
endNode = endNode || startNode;
|
|
1949
|
+
endOffset = endOffset || endOffset === 0 ? endOffset : startOffset;
|
|
1950
|
+
this.currentRange = this.currentRange.updateRTERange({ startNode, endNode, startOffset, endOffset });
|
|
1951
|
+
void this.updateCaretPositionTaskQueue.enqueue({
|
|
1952
|
+
/** Add task to the queue and run it until component did render */
|
|
1953
|
+
run: async () => {
|
|
1954
|
+
try {
|
|
1955
|
+
await this.createUpdateSelectionRangeTask();
|
|
1956
|
+
}
|
|
1957
|
+
catch (e) {
|
|
1958
|
+
LogUtility.error('Set range error.', e);
|
|
1959
|
+
}
|
|
1960
|
+
},
|
|
1961
|
+
}, immediatelyRun);
|
|
1962
|
+
}
|
|
1963
|
+
/**
|
|
1964
|
+
* Set selection with a new range
|
|
1965
|
+
*
|
|
1966
|
+
* @param {Range} range - The range to set
|
|
1967
|
+
*/
|
|
1968
|
+
setSelectionRange(range) {
|
|
1969
|
+
const selection = this.getSelection();
|
|
1970
|
+
selection.removeAllRanges();
|
|
1971
|
+
selection.addRange(range);
|
|
1972
|
+
this.saveSelection();
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Save the current selection range detail
|
|
1976
|
+
*/
|
|
1977
|
+
saveSelection() {
|
|
1978
|
+
const selection = this.getSelection();
|
|
1979
|
+
// The range is out of date if the queue is not empty, so we should not update the RTERange
|
|
1980
|
+
if (selection && selection.rangeCount > 0 && this.updateCaretPositionTaskQueue.queue.length === 0) {
|
|
1981
|
+
const range = selection.getRangeAt(0);
|
|
1982
|
+
const { startContainer: startNode, endContainer: endNode, startOffset, endOffset } = range;
|
|
1983
|
+
this.currentRange = this.currentRange.updateRTERange({ startNode, endNode, startOffset, endOffset }, range);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Restore the selection to the current selected nodes
|
|
1988
|
+
*/
|
|
1989
|
+
restoreSelection() {
|
|
1990
|
+
if (this.selectedNodes.length > 0) {
|
|
1991
|
+
const startNode = this.selectedNodes[0];
|
|
1992
|
+
const endNode = this.selectedNodes.length > 1 ? this.selectedNodes[this.selectedNodes.length - 1] : startNode;
|
|
1993
|
+
if (startNode === endNode && startNode.text.length === 0) {
|
|
1994
|
+
this.enqueueSelectionRangeFutureState(startNode, ZERO_WIDTH_SPACE.length);
|
|
1995
|
+
}
|
|
1996
|
+
else {
|
|
1997
|
+
const { startContainer, endContainer, startOffset, endOffset } = this.currentRange;
|
|
1998
|
+
if (stateEntityRenderingRegistry.getDOMByEntity(startNode) === startContainer.parentElement &&
|
|
1999
|
+
stateEntityRenderingRegistry.getDOMByEntity(endNode) === endContainer.parentElement) {
|
|
2000
|
+
this.enqueueSelectionRangeFutureState(startNode, startOffset, endNode, endOffset);
|
|
2001
|
+
}
|
|
2002
|
+
else {
|
|
2003
|
+
this.enqueueSelectionRangeFutureState(startNode, 0, endNode, endNode.text.length);
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
this.selectedNodes = [];
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Get the rich text content selected range
|
|
2011
|
+
*
|
|
2012
|
+
* @returns {Selection} A [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) object
|
|
2013
|
+
*/
|
|
2014
|
+
getSelection() {
|
|
2015
|
+
const richTextContentRef = this.vegaRichTextEditorRenderer.getRichTextContentRef();
|
|
2016
|
+
return ShadowSelectionPolyfill$1.getSelection(richTextContentRef.shadowRoot);
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Get selected rich text
|
|
2020
|
+
*/
|
|
2021
|
+
handleSelectionChange() {
|
|
2022
|
+
const selection = this.getSelection();
|
|
2023
|
+
if (!selection || selection.rangeCount === 0)
|
|
2024
|
+
return;
|
|
2025
|
+
this.clearSelectionMap();
|
|
2026
|
+
this.saveSelection();
|
|
2027
|
+
const range = selection.getRangeAt(0);
|
|
2028
|
+
const commonAncestor = range.commonAncestorContainer;
|
|
2029
|
+
const selectedNodes = [];
|
|
2030
|
+
/**
|
|
2031
|
+
* Rich text node filter
|
|
2032
|
+
*
|
|
2033
|
+
* @param {Node} node - Start node
|
|
2034
|
+
*/
|
|
2035
|
+
const filterNode = (node) => {
|
|
2036
|
+
if (!range.intersectsNode(node)) {
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
2040
|
+
const currentNode = node.parentElement;
|
|
2041
|
+
const nodeEntity = stateEntityRenderingRegistry.getEntityByDOM(currentNode);
|
|
2042
|
+
if (nodeEntity instanceof RTENode) {
|
|
2043
|
+
selectedNodes.push(nodeEntity);
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2048
|
+
const entityElement = node.nodeName === 'VEGA-RICH-TEXT-IMAGE-EDITOR'
|
|
2049
|
+
? node.querySelector('img')
|
|
2050
|
+
: node;
|
|
2051
|
+
const nodeEntity = stateEntityRenderingRegistry.getEntityByDOM(entityElement);
|
|
2052
|
+
if (nodeEntity instanceof RTENode) {
|
|
2053
|
+
selectedNodes.push(nodeEntity);
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
node.childNodes.forEach(filterNode);
|
|
2058
|
+
};
|
|
2059
|
+
filterNode(commonAncestor);
|
|
2060
|
+
selectedNodes.forEach((node) => {
|
|
2061
|
+
if (this.selectionMap.has(node.parentBlock)) {
|
|
2062
|
+
this.selectionMap.get(node.parentBlock).push(node);
|
|
2063
|
+
}
|
|
2064
|
+
else {
|
|
2065
|
+
this.selectionMap.set(node.parentBlock, [node]);
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
this.getSelectedNodes().forEach((node) => node.apply(new SelectionChangeAction(range)));
|
|
2069
|
+
}
|
|
2070
|
+
/**
|
|
2071
|
+
* Clear the selection map
|
|
2072
|
+
*/
|
|
2073
|
+
clearSelectionMap() {
|
|
2074
|
+
this.getSelectedNodes().forEach((node) => {
|
|
2075
|
+
node.annotationMap.delete(InternalAnnotationTypeEnum.SELECTION_RANGE);
|
|
2076
|
+
});
|
|
2077
|
+
this.selectionMap = new Map();
|
|
2078
|
+
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Check if the selection range change is acceptable
|
|
2081
|
+
*
|
|
2082
|
+
* @returns {boolean} - Returns a boolean value.
|
|
2083
|
+
*/
|
|
2084
|
+
isAcceptableSelectionRangeChange() {
|
|
2085
|
+
return true;
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* Register the selection range change observer
|
|
2089
|
+
*/
|
|
2090
|
+
registerSelectionRangeChangeObserver() {
|
|
2091
|
+
this.selectionRangeChangeObserver = new Observer(this.isAcceptableSelectionRangeChange.bind(this), (payload) => {
|
|
2092
|
+
this.selectedNodes.push(payload.node);
|
|
2093
|
+
});
|
|
2094
|
+
ChangeManager.register(domNodeSubjectFactory.getSubject(this.host, VegaInternalRichTextEditorSelectionRangeChange), this.selectionRangeChangeObserver);
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
SelectionController.SELECTION_CHANGE_DEBOUNCE_TIME = 50;
|
|
2098
|
+
__decorate$d([
|
|
2099
|
+
MapToComponentField()
|
|
2100
|
+
], SelectionController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
2101
|
+
__decorate$d([
|
|
2102
|
+
MapToComponentField({ writable: true })
|
|
2103
|
+
], SelectionController.prototype, "selectionMap", void 0);
|
|
2104
|
+
__decorate$d([
|
|
2105
|
+
MapToComponentField()
|
|
2106
|
+
], SelectionController.prototype, "host", void 0);
|
|
2107
|
+
__decorate$d([
|
|
2108
|
+
MapToComponentField()
|
|
2109
|
+
], SelectionController.prototype, "value", void 0);
|
|
2110
|
+
__decorate$d([
|
|
2111
|
+
MapToComponentField()
|
|
2112
|
+
], SelectionController.prototype, "valueController", void 0);
|
|
2113
|
+
__decorate$d([
|
|
2114
|
+
MapToComponentMethod('connectedCallback')
|
|
2115
|
+
], SelectionController.prototype, "connectedCallback", null);
|
|
2116
|
+
__decorate$d([
|
|
2117
|
+
MapToComponentMethod('disconnectedCallback')
|
|
2118
|
+
], SelectionController.prototype, "disconnectedCallback", null);
|
|
2119
|
+
__decorate$d([
|
|
2120
|
+
MapToComponentMethod('componentDidLoad')
|
|
2121
|
+
], SelectionController.prototype, "componentDidLoad", null);
|
|
2122
|
+
__decorate$d([
|
|
2123
|
+
MapToComponentMethod('watchValueUpdate')
|
|
2124
|
+
], SelectionController.prototype, "watchValueUpdate", null);
|
|
2125
|
+
__decorate$d([
|
|
2126
|
+
MapToComponentMethod('componentDidUpdate')
|
|
2127
|
+
], SelectionController.prototype, "updateCaretPosition", null);
|
|
2128
|
+
|
|
2129
|
+
var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2130
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2131
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2132
|
+
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;
|
|
2133
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2134
|
+
};
|
|
2135
|
+
/**
|
|
2136
|
+
* The value controller is responsible for updating the value of the rich text editor.
|
|
2137
|
+
*/
|
|
2138
|
+
class ValueController extends VegaSlimmer {
|
|
2139
|
+
/**
|
|
2140
|
+
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.connectedCallback}
|
|
2141
|
+
*/
|
|
2142
|
+
connectedCallback() {
|
|
2143
|
+
const flushChangesWithDebounce = debounce(() => {
|
|
2144
|
+
void this.valueController.flushChanges(this.value);
|
|
2145
|
+
}, ValueController.VALUE_CHANGE_DEBOUNCE_TIME, this);
|
|
2146
|
+
this.flushChangeObserver = new Observer(this.isAcceptableFlushChange.bind(this), flushChangesWithDebounce);
|
|
2147
|
+
ChangeManager.register(domNodeSubjectFactory.getSubject(this.host, VegaInternalRichTextEditorFlushChanges), this.flushChangeObserver);
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.disconnectedCallback}
|
|
2151
|
+
*/
|
|
2152
|
+
disconnectedCallback() {
|
|
2153
|
+
ChangeManager.unregister(domNodeSubjectFactory.getSubject(this.host, VegaInternalRichTextEditorFlushChanges), this.flushChangeObserver);
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Watches the value of the editor and updates the internal value.
|
|
2157
|
+
*/
|
|
2158
|
+
watchValueUpdate() {
|
|
2159
|
+
if (!this.value || this.value.blocks.length === 0) {
|
|
2160
|
+
this.value = VegaRTEContent.createEmptyContent();
|
|
2161
|
+
}
|
|
2162
|
+
else {
|
|
2163
|
+
this.changeEventEmitter.emit(this.value);
|
|
2164
|
+
ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
|
|
2165
|
+
host: this.host,
|
|
2166
|
+
detail: this.value,
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* Updates the value of the editor and restore the selection.
|
|
2172
|
+
*
|
|
2173
|
+
* @param {VegaRTEContent} newValue The new value to set.
|
|
2174
|
+
*/
|
|
2175
|
+
async flushChanges(newValue) {
|
|
2176
|
+
this.value = newValue.clone();
|
|
2177
|
+
await waitForComponentDidRender(this.host);
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Determines whether the observer should accept changes.
|
|
2181
|
+
*
|
|
2182
|
+
* @returns {boolean} Always returns true in the current implementation.
|
|
2183
|
+
*/
|
|
2184
|
+
isAcceptableFlushChange() {
|
|
2185
|
+
return true;
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
ValueController.VALUE_CHANGE_DEBOUNCE_TIME = 50;
|
|
2189
|
+
__decorate$c([
|
|
2190
|
+
MapToComponentField()
|
|
2191
|
+
], ValueController.prototype, "host", void 0);
|
|
2192
|
+
__decorate$c([
|
|
2193
|
+
MapToComponentField({ writable: true })
|
|
2194
|
+
], ValueController.prototype, "value", void 0);
|
|
2195
|
+
__decorate$c([
|
|
2196
|
+
MapToComponentField()
|
|
2197
|
+
], ValueController.prototype, "changeEventEmitter", void 0);
|
|
2198
|
+
__decorate$c([
|
|
2199
|
+
MapToComponentField()
|
|
2200
|
+
], ValueController.prototype, "valueController", void 0);
|
|
2201
|
+
__decorate$c([
|
|
2202
|
+
MapToComponentMethod('connectedCallback')
|
|
2203
|
+
], ValueController.prototype, "connectedCallback", null);
|
|
2204
|
+
__decorate$c([
|
|
2205
|
+
MapToComponentMethod('disconnectedCallback')
|
|
2206
|
+
], ValueController.prototype, "disconnectedCallback", null);
|
|
2207
|
+
__decorate$c([
|
|
2208
|
+
MapToComponentMethod('watchValueUpdate')
|
|
2209
|
+
], ValueController.prototype, "watchValueUpdate", null);
|
|
2210
|
+
|
|
2211
|
+
var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2212
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2213
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2214
|
+
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;
|
|
2215
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2216
|
+
};
|
|
2217
|
+
/** The `DarkModeStateControllerSlimmer` class monitors dark mode changes and updates the state accordingly. */
|
|
2218
|
+
class DarkModeStateControllerSlimmer extends VegaSlimmer {
|
|
2219
|
+
/**
|
|
2220
|
+
* Component lifecycle - [connectedCallback]
|
|
2221
|
+
* Register an observer to watch for dark mode updates, which will cause the component to update.
|
|
2222
|
+
*/
|
|
2223
|
+
connectedCallback() {
|
|
2224
|
+
this.observer = new Observer(this.isAcceptObserver.bind(this), (isDark) => {
|
|
2225
|
+
this.isInDarkMode = isDark;
|
|
2226
|
+
});
|
|
2227
|
+
ChangeManager.register(DARK_MODE_CHANGE, this.observer);
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* cancel dark mode observer when disconnectedCallback
|
|
2231
|
+
*/
|
|
2232
|
+
disconnectResizeObserver() {
|
|
2233
|
+
ChangeManager.unregister(DARK_MODE_CHANGE, this.observer);
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Determines whether the observer should accept changes.
|
|
2237
|
+
*
|
|
2238
|
+
* @returns {boolean} Always returns true in the current implementation.
|
|
2239
|
+
*/
|
|
2240
|
+
isAcceptObserver() {
|
|
2241
|
+
return true;
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
__decorate$b([
|
|
2245
|
+
MapToComponentField({ writable: true })
|
|
2246
|
+
], DarkModeStateControllerSlimmer.prototype, "isInDarkMode", void 0);
|
|
2247
|
+
__decorate$b([
|
|
2248
|
+
MapToComponentMethod('connectedCallback')
|
|
2249
|
+
], DarkModeStateControllerSlimmer.prototype, "connectedCallback", null);
|
|
2250
|
+
__decorate$b([
|
|
2251
|
+
MapToComponentMethod('disconnectedCallback')
|
|
2252
|
+
], DarkModeStateControllerSlimmer.prototype, "disconnectResizeObserver", null);
|
|
2253
|
+
|
|
2254
|
+
/**
|
|
2255
|
+
* The rich text content controller
|
|
2256
|
+
*/
|
|
2257
|
+
class RichTextContentController {
|
|
2258
|
+
constructor(editor) {
|
|
2259
|
+
this.editor = editor;
|
|
2260
|
+
}
|
|
2261
|
+
/**
|
|
2262
|
+
* Sync rich text content editable with disabled property
|
|
2263
|
+
*
|
|
2264
|
+
*/
|
|
2265
|
+
syncRichTextContentEditable() {
|
|
2266
|
+
this.editor.richTextContentEditable = !this.editor.disabled;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
/**
|
|
2271
|
+
* Replace the text node selected content to new text
|
|
2272
|
+
*
|
|
2273
|
+
* @example selectedNode.apply(new ReplaceSelectedTextAction(insertText))
|
|
2274
|
+
*/
|
|
2275
|
+
class ReplaceSelectedTextAction extends ModifyContentAction {
|
|
2276
|
+
constructor(text, currentRange) {
|
|
2277
|
+
super();
|
|
2278
|
+
this.type = ModifyContentActionType.REPLACE_SELECTED_TEXT;
|
|
2279
|
+
this.textToBeInsert = '';
|
|
2280
|
+
this.textToBeInsert = text;
|
|
2281
|
+
this.currentRange = currentRange;
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
const ROOT_CONTAINER_CLASS_NAME = 'rich-text-content';
|
|
2286
|
+
/** This code snippet is defining an abstract class named `BaseHandler` with an abstract method `execute`. */
|
|
2287
|
+
class BaseHandler {
|
|
2288
|
+
/**
|
|
2289
|
+
* The function `execute` initializes the current state and selection, and then handles an event if provided.
|
|
2290
|
+
*
|
|
2291
|
+
* @param {VegaRTEContent} currentState - The current state of the VegaRTE content.
|
|
2292
|
+
* @param {SelectionController} selectionController - Manages the selection of items in the user interface.
|
|
2293
|
+
* @param {InputEvent} [event] - It is used to pass an input event to the method for handling.
|
|
2294
|
+
*/
|
|
2295
|
+
execute(currentState, selectionController, event) {
|
|
2296
|
+
this.initCurrentStateAndSelection(currentState, selectionController);
|
|
2297
|
+
this.handleEvent(event);
|
|
2298
|
+
}
|
|
2299
|
+
/**
|
|
2300
|
+
* Replaces the selected nodes with the provided text.
|
|
2301
|
+
*
|
|
2302
|
+
* @param {string} text - The insert text
|
|
2303
|
+
* @returns {RTENode} - The selected start node
|
|
2304
|
+
*/
|
|
2305
|
+
replaceSelectedNodesWithText(text) {
|
|
2306
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2307
|
+
const range = this.selectionController.getCurrentRange();
|
|
2308
|
+
const { startContainer, endContainer } = range;
|
|
2309
|
+
const result = this.removeSelectionRange();
|
|
2310
|
+
const startNode = selectedNodes[0];
|
|
2311
|
+
if (startNode instanceof RTETextNode && text) {
|
|
2312
|
+
startNode.apply(new UpdateTextAction(startNode.text + text));
|
|
2313
|
+
}
|
|
2314
|
+
this.mergeRangeStartAndEnd(startContainer, endContainer);
|
|
2315
|
+
return result;
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* The function `isRootContainer` checks if an HTML element is a root container with a class of 'rich-text-content'.
|
|
2319
|
+
*
|
|
2320
|
+
* @param {HTMLElement} element - HTMLElement
|
|
2321
|
+
* @returns {boolean} The boolean value
|
|
2322
|
+
*/
|
|
2323
|
+
isRootContainer(element) {
|
|
2324
|
+
return (element &&
|
|
2325
|
+
element.nodeType === Node.ELEMENT_NODE &&
|
|
2326
|
+
element.classList.contains(ROOT_CONTAINER_CLASS_NAME));
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Checks if a given HTML element represents an empty paragraph containing only a line break element.
|
|
2330
|
+
*
|
|
2331
|
+
* @param {HTMLElement} node - An HTMLElement node that represents a paragraph element in the HTML document.
|
|
2332
|
+
* @returns {boolean} boolean result
|
|
2333
|
+
*/
|
|
2334
|
+
isEmptyParagraph(node) {
|
|
2335
|
+
return node && node.childNodes && node.childNodes.length === 0;
|
|
2336
|
+
}
|
|
2337
|
+
/**
|
|
2338
|
+
* Removes the selected text at the start and end of a range in a Rich Text Editor.
|
|
2339
|
+
*/
|
|
2340
|
+
removeRangeStartAndEndSelectedText() {
|
|
2341
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2342
|
+
const currentRange = this.selectionController.getCurrentRange();
|
|
2343
|
+
if (selectedNodes[0] instanceof RTETextNode) {
|
|
2344
|
+
selectedNodes[0].apply(new ReplaceSelectedTextAction('', currentRange));
|
|
2345
|
+
}
|
|
2346
|
+
if (selectedNodes.length > 1 && selectedNodes[selectedNodes.length - 1] instanceof RTETextNode) {
|
|
2347
|
+
selectedNodes[selectedNodes.length - 1].apply(new ReplaceSelectedTextAction('', currentRange));
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
/**
|
|
2351
|
+
* Merges text nodes in a rich text editor.
|
|
2352
|
+
*
|
|
2353
|
+
* @param {Node} startContainer - Start text node element
|
|
2354
|
+
* @param {Node} endContainer - End text node element
|
|
2355
|
+
*/
|
|
2356
|
+
mergeRangeStartAndEnd(startContainer, endContainer) {
|
|
2357
|
+
if (startContainer !== endContainer) {
|
|
2358
|
+
if (startContainer.nodeType === Node.TEXT_NODE && endContainer.nodeType === Node.TEXT_NODE) {
|
|
2359
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2360
|
+
const startRTENode = selectedNodes[0];
|
|
2361
|
+
const endRTENode = selectedNodes[selectedNodes.length - 1];
|
|
2362
|
+
if (startRTENode && startRTENode.parentBlock && endRTENode && endRTENode.parentBlock) {
|
|
2363
|
+
const endBlock = endRTENode.parentBlock;
|
|
2364
|
+
if (this.shouldMergeTextNode(startRTENode, endRTENode)) {
|
|
2365
|
+
startRTENode.apply(new UpdateTextAction(startRTENode.text + endRTENode.text));
|
|
2366
|
+
if (startRTENode.parentBlock === endRTENode.parentBlock) {
|
|
2367
|
+
startRTENode.parentBlock.apply(new RemoveChildAction(endRTENode));
|
|
2368
|
+
}
|
|
2369
|
+
else {
|
|
2370
|
+
endRTENode.parentBlock.apply(new RemoveChildAction(endRTENode.parentBlock.nodes[0]));
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
if (startRTENode.parentBlock !== endRTENode.parentBlock) {
|
|
2374
|
+
startRTENode.parentBlock.apply(new AppendChildNodesAction(endBlock.nodes));
|
|
2375
|
+
endBlock.nodes = [];
|
|
2376
|
+
}
|
|
2377
|
+
if (endBlock.nodes.length < 1) {
|
|
2378
|
+
endBlock.parent.apply(new RemoveChildAction(endBlock));
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Removes selected nodes within a range in a rich text editor content.
|
|
2386
|
+
* The method is only used for different nodes are selected
|
|
2387
|
+
*
|
|
2388
|
+
* @returns {RTENode} The range start node, usually the start node is the first item of selectedNodes, if the selectedNodes is all removed, the start node will be a new text node.
|
|
2389
|
+
*/
|
|
2390
|
+
removeSelectionRange() {
|
|
2391
|
+
const range = this.selectionController.getCurrentRange();
|
|
2392
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2393
|
+
const { endOffset, startOffset } = range;
|
|
2394
|
+
const startNode = selectedNodes[0];
|
|
2395
|
+
const endNode = selectedNodes[selectedNodes.length - 1];
|
|
2396
|
+
if (selectedNodes.length > 1) {
|
|
2397
|
+
// Remove all selected nodes except start node and end node(the end image node will be removed), the start node need to get the index of the block
|
|
2398
|
+
const shouldRemovedItems = selectedNodes.filter((item) => {
|
|
2399
|
+
if (item.type !== 'IMAGE') {
|
|
2400
|
+
return item !== startNode && item !== endNode;
|
|
2401
|
+
}
|
|
2402
|
+
else {
|
|
2403
|
+
return item !== startNode && (item !== endNode || (item === endNode && endOffset !== 0));
|
|
2404
|
+
}
|
|
2405
|
+
});
|
|
2406
|
+
shouldRemovedItems.forEach((item) => {
|
|
2407
|
+
item.parentBlock.apply(new RemoveChildAction(item));
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
this.removeRangeStartAndEndSelectedText();
|
|
2411
|
+
/**
|
|
2412
|
+
* if the range start node is image and the item is selected, so we need remove the image item, the image block will be removed if the item is the only item.
|
|
2413
|
+
* but before remove the image block, we need insert a paragraph to make sure the start block and start node could be get correct before insert text or break paragraph action
|
|
2414
|
+
*/
|
|
2415
|
+
if (startNode instanceof RTEImageNode &&
|
|
2416
|
+
startOffset !== 1 &&
|
|
2417
|
+
(endNode !== startNode || endOffset !== 0)) {
|
|
2418
|
+
// the image block will be deleted when the image is the only item
|
|
2419
|
+
if (startNode.parentBlock.nodes.length === 1) {
|
|
2420
|
+
const paragraph = this.createEmptyParagraph();
|
|
2421
|
+
startNode.parentBlock.parent.apply(new InsertBlocksBeforeAction(startNode.parentBlock, paragraph));
|
|
2422
|
+
startNode.parentBlock.apply(new RemoveChildAction(startNode));
|
|
2423
|
+
return paragraph.nodes[0];
|
|
2424
|
+
}
|
|
2425
|
+
else if (startNode === startNode.parentBlock.nodes[0]) {
|
|
2426
|
+
// the start node should be the next image item if the image is first item
|
|
2427
|
+
startNode.parentBlock.apply(new RemoveChildAction(startNode));
|
|
2428
|
+
return startNode.parentBlock.nodes[0];
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
return startNode;
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Creates a new paragraph with an empty text node and returns it.
|
|
2435
|
+
*
|
|
2436
|
+
* @returns {RTETextBlock} An empty paragraph with a unique identifier and a text node appended to it.
|
|
2437
|
+
*/
|
|
2438
|
+
createEmptyParagraph() {
|
|
2439
|
+
const paragraph = new RTETextBlock(generateUUID(), 'paragraph');
|
|
2440
|
+
const textNode = new RTETextNode(`${paragraph.id}1`, '', paragraph);
|
|
2441
|
+
paragraph.apply(new AppendChildNodesAction([textNode]));
|
|
2442
|
+
return paragraph;
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Compares the annotations of two RTETextNodes to determine if they can be merged.
|
|
2446
|
+
*
|
|
2447
|
+
* @param {RTETextNode} nodeA - node A
|
|
2448
|
+
* @param {RTETextNode} nodeB - node B
|
|
2449
|
+
* @returns {boolean} true or false
|
|
2450
|
+
*/
|
|
2451
|
+
shouldMergeTextNode(nodeA, nodeB) {
|
|
2452
|
+
const { annotations: annotationsA } = nodeA.toJSON();
|
|
2453
|
+
const { annotations: annotationsB } = nodeB.toJSON();
|
|
2454
|
+
return JSON.stringify(annotationsA) === JSON.stringify(annotationsB);
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
* The function initializes the current state and selection controller in TypeScript.
|
|
2458
|
+
*
|
|
2459
|
+
* @param {VegaRTEContent} currentState - The current state of a Vega runtime environment content.
|
|
2460
|
+
* @param {SelectionController} selectionController - It is used to manage the selection of content within the VegaRTE editor.
|
|
2461
|
+
*/
|
|
2462
|
+
initCurrentStateAndSelection(currentState, selectionController) {
|
|
2463
|
+
this.currentState = currentState;
|
|
2464
|
+
this.selectionController = selectionController;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/**
|
|
2469
|
+
* Insert a new node before a existing node
|
|
2470
|
+
*
|
|
2471
|
+
* @example currentNode.parentBlock.apply(new InsertNodesBeforeAction(currentNode, newNode, ...))
|
|
2472
|
+
*/
|
|
2473
|
+
class InsertNodesBeforeAction extends ModifyContentAction {
|
|
2474
|
+
constructor(referNode, ...nodesToBeInserted) {
|
|
2475
|
+
super();
|
|
2476
|
+
this.type = ModifyContentActionType.INSERT_NODES_BEFORE;
|
|
2477
|
+
this.referNode = referNode;
|
|
2478
|
+
this.nodesToBeInserted = nodesToBeInserted;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
/** Handles inserting text into a VegaRTEContent based on the current selection and input event. User input character will trigger this callback */
|
|
2483
|
+
class InsertTextHandler extends BaseHandler {
|
|
2484
|
+
/**
|
|
2485
|
+
* Update the state value when user type character
|
|
2486
|
+
*
|
|
2487
|
+
* @param {InputEvent} event - The input event object
|
|
2488
|
+
*/
|
|
2489
|
+
handleEvent(event) {
|
|
2490
|
+
const text = event.data;
|
|
2491
|
+
const currentRange = this.selectionController.getCurrentRange();
|
|
2492
|
+
const { startContainer, startOffset } = currentRange;
|
|
2493
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2494
|
+
if (selectedNodes.length < 2) {
|
|
2495
|
+
if (!selectedNodes.length && this.isRootContainer(startContainer)) {
|
|
2496
|
+
const cursorNode = this.insertTextToRoot(text);
|
|
2497
|
+
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, text.length);
|
|
2498
|
+
}
|
|
2499
|
+
else if (selectedNodes[0] instanceof RTETextNode) {
|
|
2500
|
+
let nextOffset = startOffset + text.length;
|
|
2501
|
+
let updateFlag = false;
|
|
2502
|
+
let cursorNode = selectedNodes[0];
|
|
2503
|
+
if (cursorNode.text === '\n') {
|
|
2504
|
+
cursorNode = this.insertTextToLineBreakNode(cursorNode, text);
|
|
2505
|
+
updateFlag = true;
|
|
2506
|
+
}
|
|
2507
|
+
else {
|
|
2508
|
+
if (startContainer.nodeValue === ZERO_WIDTH_SPACE &&
|
|
2509
|
+
startOffset === ZERO_WIDTH_SPACE.length &&
|
|
2510
|
+
cursorNode.isEmpty()) {
|
|
2511
|
+
startContainer.nodeValue = '';
|
|
2512
|
+
nextOffset = nextOffset - ZERO_WIDTH_SPACE.length;
|
|
2513
|
+
}
|
|
2514
|
+
if (cursorNode instanceof RTETextNode) {
|
|
2515
|
+
updateFlag = true;
|
|
2516
|
+
cursorNode.apply(new ReplaceSelectedTextAction(text, currentRange));
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
updateFlag &&
|
|
2520
|
+
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, Math.min(nextOffset, cursorNode['text'].length));
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
else {
|
|
2524
|
+
// The selected nodes is multiple nodes
|
|
2525
|
+
const cursorNode = this.replaceSelectedNodesWithText(text);
|
|
2526
|
+
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, cursorNode instanceof RTETextNode
|
|
2527
|
+
? Math.min(startOffset + text.length, cursorNode.text.length)
|
|
2528
|
+
: startOffset);
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
* Insert the text in root element when root container is empty, should create text block and text node
|
|
2533
|
+
*
|
|
2534
|
+
* @param {string} text The insert text
|
|
2535
|
+
* @returns {RTETextNode} The new create text node
|
|
2536
|
+
*/
|
|
2537
|
+
insertTextToRoot(text) {
|
|
2538
|
+
if (this.currentState &&
|
|
2539
|
+
this.currentState.blocks[0] &&
|
|
2540
|
+
this.currentState.blocks[0] instanceof RTETextBlock) {
|
|
2541
|
+
const firstNode = this.currentState.blocks[0].nodes[0];
|
|
2542
|
+
firstNode.apply(new UpdateTextAction(text));
|
|
2543
|
+
return firstNode;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
/**
|
|
2547
|
+
* Insert text to a line break node need a special logic if the line break has a next text node.
|
|
2548
|
+
*
|
|
2549
|
+
* @param {RTETextNode} lineBreakNode The current line break node, the text value is \n
|
|
2550
|
+
* @param {string} text The text need to insert
|
|
2551
|
+
* @returns {Nullable<RTETextNode>} The new text node or the current line break node
|
|
2552
|
+
*/
|
|
2553
|
+
insertTextToLineBreakNode(lineBreakNode, text) {
|
|
2554
|
+
const { startOffset, endOffset } = this.selectionController.getCurrentRange();
|
|
2555
|
+
const textBlock = lineBreakNode.parentBlock;
|
|
2556
|
+
const index = textBlock.nodes.indexOf(lineBreakNode);
|
|
2557
|
+
if (startOffset === 0 && startOffset === endOffset && textBlock.nodes[index + 1]) {
|
|
2558
|
+
const newTextNode = lineBreakNode.cloneWithText(text);
|
|
2559
|
+
textBlock.apply(new InsertNodesBeforeAction(lineBreakNode, newTextNode));
|
|
2560
|
+
return newTextNode;
|
|
2561
|
+
}
|
|
2562
|
+
else {
|
|
2563
|
+
lineBreakNode.apply(new UpdateTextAction(text));
|
|
2564
|
+
return lineBreakNode;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
/**
|
|
2570
|
+
* Break the current block after press enter, this action is similar with the SplitBlockWithNodeAction,
|
|
2571
|
+
* The SplitBlockWithNodeAction split the current block to two same type blocks, but this action will create new paragraph or list item when break at start or end.
|
|
2572
|
+
* The property `newBlock` use to store the new create block if need.
|
|
2573
|
+
*
|
|
2574
|
+
* @example currentBlock.apply(new BreakSingleBlockAction(startContainerNode, startOffset))
|
|
2575
|
+
*/
|
|
2576
|
+
class BreakSingleBlockAction extends ModifyContentAction {
|
|
2577
|
+
constructor(startContainerNode, startOffset) {
|
|
2578
|
+
super();
|
|
2579
|
+
this.type = ModifyContentActionType.BREAK_SINGLE_BLOCK;
|
|
2580
|
+
this.startContainerNode = startContainerNode;
|
|
2581
|
+
this.startOffset = startOffset;
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
/** Insert a paragraph in a rich text editor based on the current selection and event. User type enter will trigger this callback */
|
|
2586
|
+
class InsertParagraphHandler extends BaseHandler {
|
|
2587
|
+
/**
|
|
2588
|
+
* Create new paragraph node and add node to state value
|
|
2589
|
+
*/
|
|
2590
|
+
handleEvent() {
|
|
2591
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2592
|
+
if (selectedBlocks.length < 2) {
|
|
2593
|
+
this.breakSingleBlock();
|
|
2594
|
+
}
|
|
2595
|
+
else {
|
|
2596
|
+
this.breakMultipleBlocks();
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
/**
|
|
2600
|
+
* Handles breaking blocks in an RTE editor based on the current selection and position.
|
|
2601
|
+
*/
|
|
2602
|
+
breakMultipleBlocks() {
|
|
2603
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2604
|
+
const range = this.selectionController.getCurrentRange();
|
|
2605
|
+
const cursorNode = this.removeSelectionRange();
|
|
2606
|
+
// If the start or end block contains a list item block, it needs to be processed separately
|
|
2607
|
+
if ((selectedBlocks.length && selectedBlocks[0].type === 'list-item') ||
|
|
2608
|
+
selectedBlocks[selectedBlocks.length - 1].type === 'list-item') {
|
|
2609
|
+
const firstBlock = cursorNode.parentBlock;
|
|
2610
|
+
const lastBlock = selectedBlocks[selectedBlocks.length - 1];
|
|
2611
|
+
/**
|
|
2612
|
+
* First block is list item
|
|
2613
|
+
* --before--
|
|
2614
|
+
* ul
|
|
2615
|
+
* - li
|
|
2616
|
+
* p
|
|
2617
|
+
* - span
|
|
2618
|
+
* --after--
|
|
2619
|
+
* ul
|
|
2620
|
+
* - li
|
|
2621
|
+
* - li
|
|
2622
|
+
*/
|
|
2623
|
+
/**
|
|
2624
|
+
* End block is list item
|
|
2625
|
+
* --before--
|
|
2626
|
+
* p
|
|
2627
|
+
* - span
|
|
2628
|
+
* ul
|
|
2629
|
+
* - li
|
|
2630
|
+
* --after--
|
|
2631
|
+
* p
|
|
2632
|
+
* - span
|
|
2633
|
+
* p
|
|
2634
|
+
* - span
|
|
2635
|
+
*/
|
|
2636
|
+
if (firstBlock.type !== lastBlock.type &&
|
|
2637
|
+
range.startContainer.nodeType === range.endContainer.nodeType) {
|
|
2638
|
+
firstBlock.apply(new MergeTwoBlocksNodesAction(lastBlock));
|
|
2639
|
+
const splitAction = new SplitBlockWithNodeAction(cursorNode, cursorNode['text'].length);
|
|
2640
|
+
firstBlock.apply(splitAction);
|
|
2641
|
+
this.switchCaretPositionToNextElement(splitAction.newBlock);
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, range.startOffset);
|
|
2646
|
+
}
|
|
2647
|
+
/**
|
|
2648
|
+
* Handles breaking a single block in an RTE editor based on the current selection and position.
|
|
2649
|
+
*/
|
|
2650
|
+
breakSingleBlock() {
|
|
2651
|
+
const cursorNode = this.removeSelectionRange();
|
|
2652
|
+
const currentBlock = cursorNode.parentBlock;
|
|
2653
|
+
const { startOffset } = this.selectionController.getCurrentRange();
|
|
2654
|
+
if (currentBlock) {
|
|
2655
|
+
const breakAction = new BreakSingleBlockAction(cursorNode, startOffset);
|
|
2656
|
+
currentBlock.apply(breakAction);
|
|
2657
|
+
this.switchCaretPositionToNextElement(breakAction.newBlock);
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2661
|
+
* Moves the caret to the next block element in a rich text editor.
|
|
2662
|
+
*
|
|
2663
|
+
* @param {RTEBlock} newBlock - Represents a new create block element in a rich text editor.
|
|
2664
|
+
*/
|
|
2665
|
+
switchCaretPositionToNextElement(newBlock) {
|
|
2666
|
+
if (newBlock && newBlock['nodes']) {
|
|
2667
|
+
this.selectionController.enqueueSelectionRangeFutureState(newBlock['nodes'][0], 0);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
/**
|
|
2673
|
+
* Split the block with a split point node
|
|
2674
|
+
*
|
|
2675
|
+
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
2676
|
+
*/
|
|
2677
|
+
class LineBreakSingleBlockAction extends ModifyContentAction {
|
|
2678
|
+
constructor(startContainerNode, startOffset) {
|
|
2679
|
+
super();
|
|
2680
|
+
this.type = ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK;
|
|
2681
|
+
this.startContainerNode = startContainerNode;
|
|
2682
|
+
this.startOffset = startOffset;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
/**
|
|
2687
|
+
* Split the block with a split point node
|
|
2688
|
+
*
|
|
2689
|
+
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
2690
|
+
*/
|
|
2691
|
+
class lineBreakMultipleBlocksAction extends ModifyContentAction {
|
|
2692
|
+
constructor(selectedBlocks) {
|
|
2693
|
+
super();
|
|
2694
|
+
this.type = ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS;
|
|
2695
|
+
this.selectedBlocks = selectedBlocks;
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
/** User press shift + enter will tigger this callback */
|
|
2700
|
+
class InsertLineBreakHandler extends BaseHandler {
|
|
2701
|
+
/**
|
|
2702
|
+
* Create new line break node and add node to state value
|
|
2703
|
+
*/
|
|
2704
|
+
handleEvent() {
|
|
2705
|
+
const range = this.selectionController.getCurrentRange();
|
|
2706
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2707
|
+
if (this.isRootContainer(range.startContainer)) {
|
|
2708
|
+
this.breakNewBlock();
|
|
2709
|
+
}
|
|
2710
|
+
if (selectedBlocks.length < 2) {
|
|
2711
|
+
this.breakSingleBlock();
|
|
2712
|
+
}
|
|
2713
|
+
else {
|
|
2714
|
+
this.breakMultipleBlocks();
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
/**
|
|
2718
|
+
* Insert the \n in text element when root container is empty, should create text block and text node
|
|
2719
|
+
* <p>
|
|
2720
|
+
* <span></span>
|
|
2721
|
+
* <span></span>
|
|
2722
|
+
* </p>
|
|
2723
|
+
*/
|
|
2724
|
+
breakNewBlock() {
|
|
2725
|
+
const newBlock = new RTETextBlock(generateUUID(), 'paragraph');
|
|
2726
|
+
const lineBreakNode = this.createLineBreakNode(newBlock);
|
|
2727
|
+
newBlock.apply(new AppendChildNodesAction([this.createLineBreakNode(newBlock), lineBreakNode]));
|
|
2728
|
+
this.currentState.apply(new AppendChildNodesAction([newBlock]));
|
|
2729
|
+
this.switchCaretPositionToSpecifiedNode(lineBreakNode);
|
|
2730
|
+
}
|
|
2731
|
+
/**
|
|
2732
|
+
* If the selected node is a text node
|
|
2733
|
+
* <p>
|
|
2734
|
+
* <span>text</span>
|
|
2735
|
+
* </p>
|
|
2736
|
+
* Insert a line break and the selected node will be split into three text nodes
|
|
2737
|
+
* <p>
|
|
2738
|
+
* <span>te</span>
|
|
2739
|
+
* <br>
|
|
2740
|
+
* <span>xt</span>
|
|
2741
|
+
* </p>
|
|
2742
|
+
*/
|
|
2743
|
+
breakSingleBlock() {
|
|
2744
|
+
const range = this.selectionController.getCurrentRange();
|
|
2745
|
+
const cursorNode = this.removeSelectionRange();
|
|
2746
|
+
const currentBlock = cursorNode.parentBlock;
|
|
2747
|
+
if (currentBlock) {
|
|
2748
|
+
const lineBreakAction = new LineBreakSingleBlockAction(cursorNode, range.startOffset);
|
|
2749
|
+
currentBlock.apply(lineBreakAction);
|
|
2750
|
+
this.switchCaretPositionToSpecifiedNode(lineBreakAction.lineBreakNode);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
/**
|
|
2754
|
+
* Handles breaking blocks in an RTE editor based on the current selection and position.
|
|
2755
|
+
*/
|
|
2756
|
+
breakMultipleBlocks() {
|
|
2757
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2758
|
+
const cursorNode = this.removeSelectionRange();
|
|
2759
|
+
const lineBreakAction = new lineBreakMultipleBlocksAction(selectedBlocks);
|
|
2760
|
+
cursorNode.parentBlock.apply(lineBreakAction);
|
|
2761
|
+
this.switchCaretPositionToSpecifiedNode(lineBreakAction.lineBreakNode);
|
|
2762
|
+
}
|
|
2763
|
+
/**
|
|
2764
|
+
* Moves the caret to the next node element in a rich text editor.
|
|
2765
|
+
*
|
|
2766
|
+
* @param {RTETextNode} lineBreakNode - Represents a node element in a rich text editor.
|
|
2767
|
+
*/
|
|
2768
|
+
switchCaretPositionToSpecifiedNode(lineBreakNode) {
|
|
2769
|
+
this.selectionController.enqueueSelectionRangeFutureState(this.getNextRTENode(lineBreakNode), 0);
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Returns the next sibling node of a given block element in a rich text editor.
|
|
2773
|
+
*
|
|
2774
|
+
* @param {RTENode} lineBreakNode - The `lineBreakNode` parameter is of type `RTENode`, which is used to represent the new line break element in a rich text editor.
|
|
2775
|
+
* @returns {RTENode} The next sibling node of the current line break element, or the current node if next node is not exists.
|
|
2776
|
+
*/
|
|
2777
|
+
getNextRTENode(lineBreakNode) {
|
|
2778
|
+
const index = lineBreakNode.parentBlock['nodes'].indexOf(lineBreakNode);
|
|
2779
|
+
const nextNode = lineBreakNode.parentBlock['nodes'][index + 1];
|
|
2780
|
+
return nextNode || lineBreakNode;
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Create a null text that will render a br element in a rich text editor.
|
|
2784
|
+
*
|
|
2785
|
+
* @param {RTEBlock} block - Represents a block element in a rich text editor.
|
|
2786
|
+
* @returns {RTETextNode} the new line break node.
|
|
2787
|
+
*/
|
|
2788
|
+
createLineBreakNode(block) {
|
|
2789
|
+
return new RTETextNode(generateUUID(), '\n', block);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
/**
|
|
2794
|
+
* Delete text or image when press delete
|
|
2795
|
+
*
|
|
2796
|
+
* @example currentBlock.apply(new DeleteBlockContentAction(startContainerNode, startOffset))
|
|
2797
|
+
*/
|
|
2798
|
+
class DeleteBlockContentAction extends ModifyContentAction {
|
|
2799
|
+
constructor(startContainerNode, startOffset) {
|
|
2800
|
+
super();
|
|
2801
|
+
this.type = ModifyContentActionType.DELETE_BLOCK_CONTENT;
|
|
2802
|
+
this.startContainerNode = startContainerNode;
|
|
2803
|
+
this.startOffset = startOffset;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
/** Handles the deletion of content within a VegaRTE editor. User press backspace or delete will trigger this method */
|
|
2808
|
+
class DeleteContentHandler extends BaseHandler {
|
|
2809
|
+
/**
|
|
2810
|
+
* Delete the selected node from the current state.
|
|
2811
|
+
*/
|
|
2812
|
+
handleEvent() {
|
|
2813
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2814
|
+
if (selectedBlocks.length < 2) {
|
|
2815
|
+
this.deleteContentWithSingleBlock();
|
|
2816
|
+
}
|
|
2817
|
+
else {
|
|
2818
|
+
this.deleteContentWithMultipleNodes();
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
/**
|
|
2822
|
+
* Handles the deletion of content within a single block in an RTE editor.
|
|
2823
|
+
*/
|
|
2824
|
+
deleteContentWithSingleBlock() {
|
|
2825
|
+
const range = this.selectionController.getCurrentRange();
|
|
2826
|
+
const { startOffset, endOffset, startContainer, endContainer } = range;
|
|
2827
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2828
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2829
|
+
if (startOffset !== endOffset || startContainer !== endContainer) {
|
|
2830
|
+
this.deleteContentWithMultipleNodes();
|
|
2831
|
+
}
|
|
2832
|
+
else if (selectedBlocks[0]) {
|
|
2833
|
+
const deleteAction = new DeleteBlockContentAction(selectedNodes[0], startOffset);
|
|
2834
|
+
selectedBlocks[0].apply(deleteAction);
|
|
2835
|
+
if (deleteAction.previousNode) {
|
|
2836
|
+
const nextOffset = deleteAction.previousNode === selectedNodes[0]
|
|
2837
|
+
? Math.max(0, startOffset - 1)
|
|
2838
|
+
: this.getNodeEndOffset(deleteAction.previousNode);
|
|
2839
|
+
this.selectionController.enqueueSelectionRangeFutureState(deleteAction.previousNode, nextOffset);
|
|
2840
|
+
}
|
|
2841
|
+
else if (deleteAction.nextNode) {
|
|
2842
|
+
this.selectionController.enqueueSelectionRangeFutureState(deleteAction.nextNode, 0);
|
|
2843
|
+
}
|
|
2844
|
+
else if (this.currentState.blocks.length === 0) {
|
|
2845
|
+
// Add a empty paragraph if delete all content to make sure the caret position
|
|
2846
|
+
this.insertDefaultParagraph();
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
/**
|
|
2851
|
+
* Creates a new paragraph element with a text node and appends it to the current state.
|
|
2852
|
+
*/
|
|
2853
|
+
insertDefaultParagraph() {
|
|
2854
|
+
const paragraph = this.createEmptyParagraph();
|
|
2855
|
+
this.currentState.apply(new AppendChildNodesAction([paragraph]));
|
|
2856
|
+
this.selectionController.enqueueSelectionRangeFutureState(paragraph.nodes[0], 1);
|
|
2857
|
+
}
|
|
2858
|
+
/**
|
|
2859
|
+
* Deletes the content within multiple nodes selected by the user.
|
|
2860
|
+
*/
|
|
2861
|
+
deleteContentWithMultipleNodes() {
|
|
2862
|
+
const range = this.selectionController.getCurrentRange();
|
|
2863
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2864
|
+
const cursorNode = this.replaceSelectedNodesWithText('');
|
|
2865
|
+
const lastSelectedNode = selectedNodes[selectedNodes.length - 1];
|
|
2866
|
+
if (selectedNodes.length > 1 &&
|
|
2867
|
+
lastSelectedNode instanceof RTETextNode &&
|
|
2868
|
+
lastSelectedNode.isEmpty()) {
|
|
2869
|
+
lastSelectedNode.parentBlock.apply(new RemoveChildAction(lastSelectedNode));
|
|
2870
|
+
}
|
|
2871
|
+
this.convertFirstBlockToParagraph(cursorNode.parentBlock);
|
|
2872
|
+
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, range.startOffset);
|
|
2873
|
+
}
|
|
2874
|
+
/**
|
|
2875
|
+
* If the first block is not paragraph, convert the block to paragraph after delete all text
|
|
2876
|
+
*
|
|
2877
|
+
* @param {RTEBlock} block - The first block instance
|
|
2878
|
+
*/
|
|
2879
|
+
convertFirstBlockToParagraph(block) {
|
|
2880
|
+
const firstBlock = this.currentState.blocks[0];
|
|
2881
|
+
if (firstBlock === block &&
|
|
2882
|
+
block instanceof RTETextBlock &&
|
|
2883
|
+
block.nodes.length === 1 &&
|
|
2884
|
+
block.nodes[0].isEmpty() &&
|
|
2885
|
+
block.type !== 'paragraph') {
|
|
2886
|
+
const paragraph = this.createEmptyParagraph();
|
|
2887
|
+
paragraph.apply(new ReplaceChildNodesAction(block.nodes));
|
|
2888
|
+
block.parent.apply(new InsertBlocksBeforeAction(block, paragraph));
|
|
2889
|
+
block.parent.apply(new RemoveChildAction(block));
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Returns the end offset of a given node in a Rich Text Editor based on its type and text content.
|
|
2894
|
+
*
|
|
2895
|
+
* @param {RTENode} node - text node or image node
|
|
2896
|
+
* @returns {number} Returns a number value.
|
|
2897
|
+
*/
|
|
2898
|
+
getNodeEndOffset(node) {
|
|
2899
|
+
if (node.type === 'IMAGE') {
|
|
2900
|
+
return 1;
|
|
2901
|
+
}
|
|
2902
|
+
else if (node.type === 'TEXT') {
|
|
2903
|
+
return node['text'] === '\n' ? 0 : node['text'].length;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
/**
|
|
2909
|
+
* Abstract class of element to DTO handler
|
|
2910
|
+
*/
|
|
2911
|
+
class ElementToDTOHandlerAbstract {
|
|
2912
|
+
/**
|
|
2913
|
+
* At new of handler, We need to inherit the style of the parent element
|
|
2914
|
+
* and clone an empty element so that the child elements can be appended.
|
|
2915
|
+
*
|
|
2916
|
+
* @param {HTMLElement} element - Current element.
|
|
2917
|
+
*/
|
|
2918
|
+
constructor(element) {
|
|
2919
|
+
this.setEntityElementStyle(element);
|
|
2920
|
+
this.setElement(element);
|
|
2921
|
+
}
|
|
2922
|
+
/* istanbul ignore next */
|
|
2923
|
+
// eslint-disable-next-line jsdoc/require-returns-check
|
|
2924
|
+
/**
|
|
2925
|
+
* Can be handle, the class inherit this class should implement it.
|
|
2926
|
+
*
|
|
2927
|
+
* @param {HTMLElement} element - Current element.
|
|
2928
|
+
* @returns {boolean} Can be handle.
|
|
2929
|
+
*/
|
|
2930
|
+
static canHandle(element) {
|
|
2931
|
+
throw new Error(`Method not implemented! ${element}`);
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Transform current text block to a DTO.
|
|
2935
|
+
*
|
|
2936
|
+
* @returns {RTETextBlock} Current text block.
|
|
2937
|
+
*/
|
|
2938
|
+
static currentTextBlockElementToDTO() {
|
|
2939
|
+
const element = this.getCurrentTextBlockElement();
|
|
2940
|
+
const firstNode = element.firstChild;
|
|
2941
|
+
if (firstNode && firstNode.nodeName === 'SPAN' && firstNode.textContent === '\n') {
|
|
2942
|
+
firstNode.remove();
|
|
2943
|
+
}
|
|
2944
|
+
if (element.childNodes.length > 0) {
|
|
2945
|
+
const block = RTETextBlock.fromHTML(element, 'paragraph');
|
|
2946
|
+
element.innerHTML = '';
|
|
2947
|
+
return block;
|
|
2948
|
+
}
|
|
2949
|
+
return null;
|
|
2950
|
+
}
|
|
2951
|
+
/**
|
|
2952
|
+
* Get current text block element.
|
|
2953
|
+
*
|
|
2954
|
+
* @returns {HTMLDivElement} - Current text block element.
|
|
2955
|
+
*/
|
|
2956
|
+
static getCurrentTextBlockElement() {
|
|
2957
|
+
return ElementToDTOHandlerAbstract.currentTextBlockElement;
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* While it a empty block. we should use new line span instead this block.
|
|
2961
|
+
*
|
|
2962
|
+
* @param {HTMLElement} blockElement - Current block element.
|
|
2963
|
+
* @returns {boolean} - is handled.
|
|
2964
|
+
*/
|
|
2965
|
+
handleEmptyBlock(blockElement) {
|
|
2966
|
+
if (this.currentVirtualElement.childNodes.length === 0) {
|
|
2967
|
+
(blockElement || ElementToDTOHandlerAbstract.getCurrentTextBlockElement()).append(this.createNewLineSpan());
|
|
2968
|
+
return true;
|
|
2969
|
+
}
|
|
2970
|
+
return false;
|
|
2971
|
+
}
|
|
2972
|
+
/**
|
|
2973
|
+
* Inherit style of parent.
|
|
2974
|
+
*
|
|
2975
|
+
* @param {HTMLElement} element - Current element.
|
|
2976
|
+
*/
|
|
2977
|
+
setEntityElementStyle(element) {
|
|
2978
|
+
if (element.nodeType === Node.TEXT_NODE)
|
|
2979
|
+
return;
|
|
2980
|
+
let currentStyle = element.getAttribute('style') || '';
|
|
2981
|
+
const currentClass = element.classList;
|
|
2982
|
+
const parent = element.parentElement;
|
|
2983
|
+
const parentStyle = parent.getAttribute('style') || '';
|
|
2984
|
+
const parentClass = parent.classList;
|
|
2985
|
+
switch (element.nodeName) {
|
|
2986
|
+
case 'CODE':
|
|
2987
|
+
currentClass.add('v-rte--code');
|
|
2988
|
+
break;
|
|
2989
|
+
case 'STRONG':
|
|
2990
|
+
currentStyle += 'font-weight: bold; ';
|
|
2991
|
+
break;
|
|
2992
|
+
case 'I':
|
|
2993
|
+
case 'EM':
|
|
2994
|
+
currentStyle += 'font-style: italic; ';
|
|
2995
|
+
break;
|
|
2996
|
+
case 'S':
|
|
2997
|
+
currentClass.add('v-rte--strikethrough');
|
|
2998
|
+
break;
|
|
2999
|
+
case 'U':
|
|
3000
|
+
currentClass.add('v-rte--underline');
|
|
3001
|
+
break;
|
|
3002
|
+
}
|
|
3003
|
+
element.setAttribute('style', parentStyle + currentStyle);
|
|
3004
|
+
element.classList.add(...Array.from(parentClass));
|
|
3005
|
+
}
|
|
3006
|
+
/**
|
|
3007
|
+
* Set current element.
|
|
3008
|
+
* while element is a text node, we should wrap it and inherit it style
|
|
3009
|
+
* otherwise, we should clone it and clear content.
|
|
3010
|
+
*
|
|
3011
|
+
* @param {HTMLElement} element - Current element.
|
|
3012
|
+
*/
|
|
3013
|
+
setElement(element) {
|
|
3014
|
+
this.currentEntityElement = element;
|
|
3015
|
+
if (element.nodeType === Node.TEXT_NODE) {
|
|
3016
|
+
const wrapper = document.createElement('span');
|
|
3017
|
+
wrapper.setAttribute('style', element.parentElement.getAttribute('style'));
|
|
3018
|
+
wrapper.setAttribute('class', element.parentElement.getAttribute('class'));
|
|
3019
|
+
wrapper.append(element);
|
|
3020
|
+
this.currentVirtualElement = wrapper;
|
|
3021
|
+
}
|
|
3022
|
+
else {
|
|
3023
|
+
const elementClone = element.cloneNode(true);
|
|
3024
|
+
elementClone.innerHTML = '';
|
|
3025
|
+
this.currentVirtualElement = elementClone;
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Create a new line span.
|
|
3030
|
+
*
|
|
3031
|
+
* @returns {HTMLElement} - new line span.
|
|
3032
|
+
*/
|
|
3033
|
+
createNewLineSpan() {
|
|
3034
|
+
const span = document.createElement('span');
|
|
3035
|
+
span.append('\n');
|
|
3036
|
+
return span;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
ElementToDTOHandlerAbstract.currentTextBlockElement = document.createElement('div');
|
|
3040
|
+
|
|
3041
|
+
/**
|
|
3042
|
+
* Transform image element to DTO.
|
|
3043
|
+
*/
|
|
3044
|
+
class ImageToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3045
|
+
/**
|
|
3046
|
+
* Can be transform.
|
|
3047
|
+
*
|
|
3048
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3049
|
+
* @returns {boolean} Result.
|
|
3050
|
+
*/
|
|
3051
|
+
static canHandle(element) {
|
|
3052
|
+
return (element.nodeType === Node.ELEMENT_NODE &&
|
|
3053
|
+
(element.nodeName === 'IMG' || element.querySelector('vega-rich-text-image-editor') !== null));
|
|
3054
|
+
}
|
|
3055
|
+
/**
|
|
3056
|
+
* Special the child elements of current.
|
|
3057
|
+
*
|
|
3058
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3059
|
+
*/
|
|
3060
|
+
childElements() {
|
|
3061
|
+
return [];
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* Transform element to DTO.
|
|
3065
|
+
* When blockElement is exist, it means that the current element is a child node,
|
|
3066
|
+
* and we need to wait for its root block to be converted into a dto.
|
|
3067
|
+
* Otherwise, the current node is the root node, and we can directly convert it.
|
|
3068
|
+
*
|
|
3069
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3070
|
+
*/
|
|
3071
|
+
handle() {
|
|
3072
|
+
return [
|
|
3073
|
+
ElementToDTOHandlerAbstract.currentTextBlockElementToDTO(),
|
|
3074
|
+
RTEImageBlock.fromHTML(this.currentEntityElement),
|
|
3075
|
+
];
|
|
3076
|
+
}
|
|
3077
|
+
/**
|
|
3078
|
+
* Get the block element for child nodes
|
|
3079
|
+
*
|
|
3080
|
+
* @returns {HTMLElement} - Block element for child nodes.
|
|
3081
|
+
*/
|
|
3082
|
+
getNextBlockElement() {
|
|
3083
|
+
return this.currentVirtualElement;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
/**
|
|
3088
|
+
* Transform link element to DTO.
|
|
3089
|
+
*/
|
|
3090
|
+
class InlineBlockToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3091
|
+
/**
|
|
3092
|
+
* Can be transform.
|
|
3093
|
+
*
|
|
3094
|
+
* @returns {boolean} Result.
|
|
3095
|
+
*/
|
|
3096
|
+
static canHandle() {
|
|
3097
|
+
return true;
|
|
3098
|
+
}
|
|
3099
|
+
/**
|
|
3100
|
+
* Special the child elements of current.
|
|
3101
|
+
*
|
|
3102
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3103
|
+
*/
|
|
3104
|
+
childElements() {
|
|
3105
|
+
return Array.from(this.currentEntityElement.childNodes);
|
|
3106
|
+
}
|
|
3107
|
+
/**
|
|
3108
|
+
* The inline block is a child element, and there is no need to convert it to a dto here
|
|
3109
|
+
*
|
|
3110
|
+
* @returns {RTEContentBlock[]} - Empty dto.
|
|
3111
|
+
*/
|
|
3112
|
+
handle() {
|
|
3113
|
+
return [];
|
|
3114
|
+
}
|
|
3115
|
+
/**
|
|
3116
|
+
* Get the block element for child nodes
|
|
3117
|
+
*
|
|
3118
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3119
|
+
* @returns {Nullable<HTMLElement>} - blockElement.
|
|
3120
|
+
*/
|
|
3121
|
+
getNextBlockElement(blockElement) {
|
|
3122
|
+
return blockElement;
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
/**
|
|
3127
|
+
* Transform link element to DTO.
|
|
3128
|
+
*/
|
|
3129
|
+
class LinkToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3130
|
+
constructor(element) {
|
|
3131
|
+
super(element);
|
|
3132
|
+
}
|
|
3133
|
+
/**
|
|
3134
|
+
* Can be transform.
|
|
3135
|
+
*
|
|
3136
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3137
|
+
* @returns {boolean} Result.
|
|
3138
|
+
*/
|
|
3139
|
+
static canHandle(element) {
|
|
3140
|
+
return ['A'].includes(element.nodeName);
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Special the child elements of current.
|
|
3144
|
+
*
|
|
3145
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3146
|
+
*/
|
|
3147
|
+
childElements() {
|
|
3148
|
+
return Array.from(this.currentEntityElement.childNodes);
|
|
3149
|
+
}
|
|
3150
|
+
/**
|
|
3151
|
+
* Format and append element for it block element.
|
|
3152
|
+
*
|
|
3153
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3154
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3155
|
+
*/
|
|
3156
|
+
handle(blockElement) {
|
|
3157
|
+
const key = generateUUID();
|
|
3158
|
+
Array.from(this.currentVirtualElement.children).forEach((childElement) => {
|
|
3159
|
+
childElement.setAttribute('data-href', this.currentVirtualElement.href);
|
|
3160
|
+
childElement.setAttribute('data-group-key', key);
|
|
3161
|
+
(blockElement || ElementToDTOHandlerAbstract.getCurrentTextBlockElement()).append(childElement);
|
|
3162
|
+
});
|
|
3163
|
+
return [];
|
|
3164
|
+
}
|
|
3165
|
+
/**
|
|
3166
|
+
* Get the block element for child nodes
|
|
3167
|
+
*
|
|
3168
|
+
* @returns {HTMLElement} - Block element for child nodes.
|
|
3169
|
+
*/
|
|
3170
|
+
getNextBlockElement() {
|
|
3171
|
+
return this.currentVirtualElement;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
/**
|
|
3176
|
+
* Transform list element to DTO.
|
|
3177
|
+
*/
|
|
3178
|
+
class ListItemToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3179
|
+
/**
|
|
3180
|
+
* Can be transform.
|
|
3181
|
+
*
|
|
3182
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3183
|
+
* @returns {boolean} Result.
|
|
3184
|
+
*/
|
|
3185
|
+
static canHandle(element) {
|
|
3186
|
+
return ['LI'].includes(element.nodeName);
|
|
3187
|
+
}
|
|
3188
|
+
/**
|
|
3189
|
+
* Special the child elements of current.
|
|
3190
|
+
*
|
|
3191
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3192
|
+
*/
|
|
3193
|
+
childElements() {
|
|
3194
|
+
return Array.from(this.currentEntityElement.childNodes);
|
|
3195
|
+
}
|
|
3196
|
+
/**
|
|
3197
|
+
* Append list item node to it block element.
|
|
3198
|
+
*
|
|
3199
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3200
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3201
|
+
*/
|
|
3202
|
+
handle(blockElement) {
|
|
3203
|
+
blockElement.append(this.currentVirtualElement);
|
|
3204
|
+
return [];
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Get the block element for child nodes
|
|
3208
|
+
*
|
|
3209
|
+
* @returns {HTMLElement} - Block element for child nodes.
|
|
3210
|
+
*/
|
|
3211
|
+
getNextBlockElement() {
|
|
3212
|
+
return this.currentVirtualElement;
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
/**
|
|
3217
|
+
* Transform list element to DTO.
|
|
3218
|
+
*/
|
|
3219
|
+
class ListToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3220
|
+
/**
|
|
3221
|
+
* Can be transform.
|
|
3222
|
+
*
|
|
3223
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3224
|
+
* @returns {boolean} Result.
|
|
3225
|
+
*/
|
|
3226
|
+
static canHandle(element) {
|
|
3227
|
+
return ['UL', 'OL'].includes(element.nodeName);
|
|
3228
|
+
}
|
|
3229
|
+
/**
|
|
3230
|
+
* Special the child elements of current.
|
|
3231
|
+
*
|
|
3232
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3233
|
+
*/
|
|
3234
|
+
childElements() {
|
|
3235
|
+
return Array.from(this.currentEntityElement.childNodes);
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Transform element to DTO.
|
|
3239
|
+
* When blockElement is exist, it means that the current element is a child node,
|
|
3240
|
+
* and we need to append and wait for its root block to be converted into a dto.
|
|
3241
|
+
* Otherwise, the current node is the root node, and we can directly convert it.
|
|
3242
|
+
*
|
|
3243
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3244
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3245
|
+
*/
|
|
3246
|
+
handle(blockElement) {
|
|
3247
|
+
if (this.handleEmptyBlock(blockElement)) {
|
|
3248
|
+
return [];
|
|
3249
|
+
}
|
|
3250
|
+
if (blockElement && ListItemToDTOHandler.canHandle(blockElement)) {
|
|
3251
|
+
blockElement.append(this.currentVirtualElement);
|
|
3252
|
+
return [];
|
|
3253
|
+
}
|
|
3254
|
+
else {
|
|
3255
|
+
return [
|
|
3256
|
+
ElementToDTOHandlerAbstract.currentTextBlockElementToDTO(),
|
|
3257
|
+
RTEListBlock.fromHTML(this.currentVirtualElement),
|
|
3258
|
+
];
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* Get the block element for child nodes
|
|
3263
|
+
*
|
|
3264
|
+
* @returns {HTMLElement} - Block element for child nodes.
|
|
3265
|
+
*/
|
|
3266
|
+
getNextBlockElement() {
|
|
3267
|
+
return this.currentVirtualElement;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
/**
|
|
3272
|
+
* Transform paragraph.
|
|
3273
|
+
*/
|
|
3274
|
+
class ParagraphToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3275
|
+
/**
|
|
3276
|
+
* Can be transform.
|
|
3277
|
+
*
|
|
3278
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3279
|
+
* @returns {boolean} Result.
|
|
3280
|
+
*/
|
|
3281
|
+
static canHandle(element) {
|
|
3282
|
+
return ['DIV', 'P'].includes(element.nodeName);
|
|
3283
|
+
}
|
|
3284
|
+
/**
|
|
3285
|
+
* Special the child elements of current.
|
|
3286
|
+
*
|
|
3287
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3288
|
+
*/
|
|
3289
|
+
childElements() {
|
|
3290
|
+
return Array.from(this.currentEntityElement.childNodes);
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Transform element to DTO.
|
|
3294
|
+
* When blockElement is exist, it means that the current element is a child node,
|
|
3295
|
+
* and we need to wait for its root block to be converted into a dto.
|
|
3296
|
+
* Otherwise, the current node is the root node, and we can directly convert it.
|
|
3297
|
+
*
|
|
3298
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3299
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3300
|
+
*/
|
|
3301
|
+
handle(blockElement) {
|
|
3302
|
+
if (this.handleEmptyBlock(blockElement)) {
|
|
3303
|
+
return [];
|
|
3304
|
+
}
|
|
3305
|
+
if (blockElement && !ParagraphToDTOHandler.canHandle(blockElement)) {
|
|
3306
|
+
blockElement.append(...Array.from(this.currentVirtualElement.childNodes));
|
|
3307
|
+
return [];
|
|
3308
|
+
}
|
|
3309
|
+
else {
|
|
3310
|
+
return [
|
|
3311
|
+
ElementToDTOHandlerAbstract.currentTextBlockElementToDTO(),
|
|
3312
|
+
RTETextBlock.fromHTML(this.currentVirtualElement, 'paragraph'),
|
|
3313
|
+
];
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Get the block element for child nodes
|
|
3318
|
+
*
|
|
3319
|
+
* @returns {HTMLElement} - Block element for child nodes.
|
|
3320
|
+
*/
|
|
3321
|
+
getNextBlockElement() {
|
|
3322
|
+
return this.currentVirtualElement;
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
/**
|
|
3327
|
+
* Transform text block element to DTO.
|
|
3328
|
+
*/
|
|
3329
|
+
class TextBlockToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3330
|
+
/**
|
|
3331
|
+
* Can be transform.
|
|
3332
|
+
*
|
|
3333
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3334
|
+
* @returns {boolean} Result.
|
|
3335
|
+
*/
|
|
3336
|
+
static canHandle(element) {
|
|
3337
|
+
return ['heading-1', 'heading-2', 'heading-3', 'title', 'subtitle'].includes(this.getElementType(element));
|
|
3338
|
+
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Get type of element.
|
|
3341
|
+
*
|
|
3342
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3343
|
+
* @returns {string} type.
|
|
3344
|
+
*/
|
|
3345
|
+
static getElementType(element) {
|
|
3346
|
+
if (element.nodeType !== Node.TEXT_NODE && element.hasAttribute('data-type')) {
|
|
3347
|
+
return element.getAttribute('data-type');
|
|
3348
|
+
}
|
|
3349
|
+
switch (element.nodeName) {
|
|
3350
|
+
case 'H1':
|
|
3351
|
+
return 'heading-1';
|
|
3352
|
+
case 'H2':
|
|
3353
|
+
return 'heading-2';
|
|
3354
|
+
case 'H3':
|
|
3355
|
+
return 'heading-3';
|
|
3356
|
+
default:
|
|
3357
|
+
return '';
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
/**
|
|
3361
|
+
* Special the child elements of current.
|
|
3362
|
+
*
|
|
3363
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3364
|
+
*/
|
|
3365
|
+
childElements() {
|
|
3366
|
+
return Array.from(this.currentEntityElement.childNodes);
|
|
3367
|
+
}
|
|
3368
|
+
/**
|
|
3369
|
+
* Transform element to DTO.
|
|
3370
|
+
* When blockElement is exist, it means that the current element is a child node,
|
|
3371
|
+
* and we need to wait for its root block to be converted into a dto.
|
|
3372
|
+
* Otherwise, the current node is the root node, and we can directly convert it.
|
|
3373
|
+
*
|
|
3374
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3375
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3376
|
+
*/
|
|
3377
|
+
handle(blockElement) {
|
|
3378
|
+
if (this.handleEmptyBlock(blockElement)) {
|
|
3379
|
+
return [];
|
|
3380
|
+
}
|
|
3381
|
+
if (blockElement) {
|
|
3382
|
+
blockElement.append(...Array.from(this.currentVirtualElement.childNodes));
|
|
3383
|
+
return [];
|
|
3384
|
+
}
|
|
3385
|
+
else {
|
|
3386
|
+
return [
|
|
3387
|
+
ElementToDTOHandlerAbstract.currentTextBlockElementToDTO(),
|
|
3388
|
+
RTETextBlock.fromHTML(this.currentVirtualElement, TextBlockToDTOHandler.getElementType(this.currentVirtualElement)),
|
|
3389
|
+
];
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
/**
|
|
3393
|
+
* Get the block element for child nodes
|
|
3394
|
+
*
|
|
3395
|
+
* @returns {HTMLElement} - Block element for child nodes.
|
|
3396
|
+
*/
|
|
3397
|
+
getNextBlockElement() {
|
|
3398
|
+
return this.currentVirtualElement;
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
/**
|
|
3403
|
+
* Transform text element to DTO.
|
|
3404
|
+
*/
|
|
3405
|
+
class TextToDTOHandler extends ElementToDTOHandlerAbstract {
|
|
3406
|
+
/**
|
|
3407
|
+
* Can be transform.
|
|
3408
|
+
*
|
|
3409
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3410
|
+
* @returns {boolean} Result.
|
|
3411
|
+
*/
|
|
3412
|
+
static canHandle(element) {
|
|
3413
|
+
return element.nodeType === Node.TEXT_NODE;
|
|
3414
|
+
}
|
|
3415
|
+
/* istanbul ignore next */
|
|
3416
|
+
/**
|
|
3417
|
+
* Special the child elements of current.
|
|
3418
|
+
*
|
|
3419
|
+
* @returns {HTMLElement[]} - child elements.
|
|
3420
|
+
*/
|
|
3421
|
+
childElements() {
|
|
3422
|
+
return [];
|
|
3423
|
+
}
|
|
3424
|
+
/**
|
|
3425
|
+
* Append text node to it block element.
|
|
3426
|
+
*
|
|
3427
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3428
|
+
* @returns {RTEContentBlock[]} - Block DTO.
|
|
3429
|
+
*/
|
|
3430
|
+
handle(blockElement) {
|
|
3431
|
+
(blockElement || ElementToDTOHandlerAbstract.getCurrentTextBlockElement()).append(this.currentVirtualElement);
|
|
3432
|
+
return [];
|
|
3433
|
+
}
|
|
3434
|
+
/* istanbul ignore next */
|
|
3435
|
+
/**
|
|
3436
|
+
* Get the block element for child nodes
|
|
3437
|
+
*
|
|
3438
|
+
* @param {Nullable<HTMLElement>} blockElement - Current block container.
|
|
3439
|
+
* @returns {Nullable<HTMLElement>} - blockElement.
|
|
3440
|
+
*/
|
|
3441
|
+
getNextBlockElement(blockElement) {
|
|
3442
|
+
return blockElement;
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
/**
|
|
3447
|
+
* Element to DTO processor
|
|
3448
|
+
*/
|
|
3449
|
+
class ElementToDTOProcessor {
|
|
3450
|
+
constructor() {
|
|
3451
|
+
this.elementHandlers = [
|
|
3452
|
+
TextToDTOHandler,
|
|
3453
|
+
ImageToDTOHandler,
|
|
3454
|
+
ListToDTOHandler,
|
|
3455
|
+
ListItemToDTOHandler,
|
|
3456
|
+
TextBlockToDTOHandler,
|
|
3457
|
+
ParagraphToDTOHandler,
|
|
3458
|
+
LinkToDTOHandler,
|
|
3459
|
+
InlineBlockToDTOHandler,
|
|
3460
|
+
];
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* Transform element to block DTO.
|
|
3464
|
+
*
|
|
3465
|
+
* @param {HTMLElement} element - An pasted element.
|
|
3466
|
+
* @returns {RTEContentBlock[]} Block DTO.
|
|
3467
|
+
*/
|
|
3468
|
+
process(element) {
|
|
3469
|
+
const blocks = this.transformDomToDto(Array.from(element.childNodes), null);
|
|
3470
|
+
blocks.push(ElementToDTOHandlerAbstract.currentTextBlockElementToDTO());
|
|
3471
|
+
return blocks.filter(Boolean);
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Transform elements to block DTO.
|
|
3475
|
+
*
|
|
3476
|
+
* @param {HTMLElement[]} elements - An pasted elements.
|
|
3477
|
+
* @param {HTMLElement} blockElement - Current block element.
|
|
3478
|
+
* @returns {RTEContentBlock[]} Block DTO.
|
|
3479
|
+
*/
|
|
3480
|
+
transformDomToDto(elements, blockElement) {
|
|
3481
|
+
const rootBlocks = [];
|
|
3482
|
+
elements.forEach((element) => {
|
|
3483
|
+
if (this.isInvalidElement(element))
|
|
3484
|
+
return;
|
|
3485
|
+
const handler = this.elementHandlers.find((elementHandler) => elementHandler.canHandle(element));
|
|
3486
|
+
const handle = new handler(element);
|
|
3487
|
+
if (element.nodeType !== Node.TEXT_NODE) {
|
|
3488
|
+
rootBlocks.push(...this.transformDomToDto(handle.childElements(), handle.getNextBlockElement(blockElement)));
|
|
3489
|
+
}
|
|
3490
|
+
rootBlocks.push(...handle.handle(blockElement));
|
|
3491
|
+
});
|
|
3492
|
+
return rootBlocks;
|
|
3493
|
+
}
|
|
3494
|
+
/**
|
|
3495
|
+
* Checks if the given element is valid to parse.
|
|
3496
|
+
*
|
|
3497
|
+
* @param {HTMLElement} element - The pasted element.
|
|
3498
|
+
* @returns {boolean} Is valid
|
|
3499
|
+
*/
|
|
3500
|
+
isInvalidElement(element) {
|
|
3501
|
+
if (element.nodeType === Node.COMMENT_NODE)
|
|
3502
|
+
return true;
|
|
3503
|
+
if (element.nodeType === Node.TEXT_NODE && element.nodeValue.includes('\t')) {
|
|
3504
|
+
const value = element.nodeValue.replace(/\n|\t/gm, '');
|
|
3505
|
+
if (value.length === 0)
|
|
3506
|
+
return true;
|
|
3507
|
+
}
|
|
3508
|
+
return ['META', 'BUTTON', 'STYLE'].includes(element.nodeName);
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
/**
|
|
3513
|
+
* Handle user paste
|
|
3514
|
+
*/
|
|
3515
|
+
class InsertPasteHandler extends BaseHandler {
|
|
3516
|
+
constructor() {
|
|
3517
|
+
super(...arguments);
|
|
3518
|
+
this.elementToDTOProcessor = new ElementToDTOProcessor();
|
|
3519
|
+
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Update the state value when user paste html elements.
|
|
3522
|
+
*
|
|
3523
|
+
* @param {InputEvent} event - Paste event.
|
|
3524
|
+
*/
|
|
3525
|
+
handleEvent(event) {
|
|
3526
|
+
const blocks = this.parsePastedElements(event);
|
|
3527
|
+
const { startContainer } = this.selectionController.getCurrentRange();
|
|
3528
|
+
if (this.isRootContainer(startContainer)) {
|
|
3529
|
+
this.insertBlocksToRoot(blocks);
|
|
3530
|
+
}
|
|
3531
|
+
else if (this.isEmptyParagraph(startContainer)) {
|
|
3532
|
+
this.insertBlocksBeforeEmptyBlock(blocks);
|
|
3533
|
+
}
|
|
3534
|
+
else {
|
|
3535
|
+
this.insertBlocksToContent(blocks);
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
/**
|
|
3539
|
+
* Insert the blocks to root
|
|
3540
|
+
*
|
|
3541
|
+
* @param { RTEContentBlock[]} blocks - blocks
|
|
3542
|
+
*/
|
|
3543
|
+
insertBlocksToRoot(blocks) {
|
|
3544
|
+
this.currentState.apply(new AppendChildNodesAction(blocks));
|
|
3545
|
+
}
|
|
3546
|
+
/**
|
|
3547
|
+
* Insert the blocks to content
|
|
3548
|
+
*
|
|
3549
|
+
* @param { RTEContentBlock[]} blocks - blocks
|
|
3550
|
+
*/
|
|
3551
|
+
insertBlocksToContent(blocks) {
|
|
3552
|
+
const cursorNode = this.removeSelectionRange();
|
|
3553
|
+
const currentBlock = cursorNode === null || cursorNode === void 0 ? void 0 : cursorNode.parentBlock;
|
|
3554
|
+
if (currentBlock) {
|
|
3555
|
+
const { startOffset } = this.selectionController.getCurrentRange();
|
|
3556
|
+
const breakAction = new SplitBlockWithNodeAction(cursorNode, startOffset);
|
|
3557
|
+
currentBlock.apply(breakAction);
|
|
3558
|
+
currentBlock.parent.apply(new InsertBlocksAfterAction(currentBlock, ...blocks));
|
|
3559
|
+
this.switchCaretPositionToNextElement(breakAction.newBlock);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
/**
|
|
3563
|
+
* Insert the blocks before to current block
|
|
3564
|
+
*
|
|
3565
|
+
* @param { RTEContentBlock[]} blocks - blocks
|
|
3566
|
+
*/
|
|
3567
|
+
insertBlocksBeforeEmptyBlock(blocks) {
|
|
3568
|
+
const cursorNode = this.removeSelectionRange();
|
|
3569
|
+
/* istanbul ignore next */
|
|
3570
|
+
const currentBlock = cursorNode === null || cursorNode === void 0 ? void 0 : cursorNode.parentBlock;
|
|
3571
|
+
currentBlock.parent.apply(new InsertBlocksBeforeAction(currentBlock, ...blocks));
|
|
3572
|
+
this.switchCaretPositionToNextElement(currentBlock);
|
|
3573
|
+
}
|
|
3574
|
+
/**
|
|
3575
|
+
* Format and parse elements from user paste.
|
|
3576
|
+
*
|
|
3577
|
+
* @param {InputEvent} event - Paste event.
|
|
3578
|
+
* @returns {RTEContentBlock[]} - RTEContentBlock.
|
|
3579
|
+
*/
|
|
3580
|
+
parsePastedElements(event) {
|
|
3581
|
+
const pastedHTML = event.dataTransfer.getData('text/html');
|
|
3582
|
+
const tempContainer = document.createElement('div');
|
|
3583
|
+
tempContainer.innerHTML = pastedHTML;
|
|
3584
|
+
return this.elementToDTOProcessor.process(tempContainer);
|
|
3585
|
+
}
|
|
3586
|
+
/**
|
|
3587
|
+
* Moves the caret to the next block element in a rich text editor.
|
|
3588
|
+
*
|
|
3589
|
+
* @param {RTEBlock} newBlock - Represents a new create block element in a rich text editor.
|
|
3590
|
+
*/
|
|
3591
|
+
switchCaretPositionToNextElement(newBlock) {
|
|
3592
|
+
if (newBlock && newBlock['nodes']) {
|
|
3593
|
+
this.selectionController.enqueueSelectionRangeFutureState(newBlock['nodes'][0], 0);
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
var __decorate$a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
3599
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3600
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3601
|
+
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;
|
|
3602
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3603
|
+
};
|
|
3604
|
+
/** Used to monitoring the user input actions by event listener and mutationObserver */
|
|
3605
|
+
class UserInputController extends VegaSlimmer {
|
|
3606
|
+
constructor() {
|
|
3607
|
+
super(...arguments);
|
|
3608
|
+
this.insertTextHandler = new InsertTextHandler();
|
|
3609
|
+
this.insertParagraphHandler = new InsertParagraphHandler();
|
|
3610
|
+
this.insertLineBreakHandler = new InsertLineBreakHandler();
|
|
3611
|
+
this.deleteContentHandler = new DeleteContentHandler();
|
|
3612
|
+
this.insertPasteHandler = new InsertPasteHandler();
|
|
3613
|
+
this.observerOptions = {
|
|
3614
|
+
characterData: true,
|
|
3615
|
+
characterDataOldValue: true,
|
|
3616
|
+
subtree: true,
|
|
3617
|
+
childList: true,
|
|
3618
|
+
};
|
|
3619
|
+
/**
|
|
3620
|
+
* When a user performs an input action within the editable element, this function is triggered.
|
|
3621
|
+
*
|
|
3622
|
+
* @param {InputEvent} e the before input event object
|
|
3623
|
+
*/
|
|
3624
|
+
this.handleUserInputAction = (e) => {
|
|
3625
|
+
this.removeObserver();
|
|
3626
|
+
e.preventDefault();
|
|
3627
|
+
this.initValueIfEmpty();
|
|
3628
|
+
let updateFlag = false;
|
|
3629
|
+
switch (e.inputType) {
|
|
3630
|
+
case 'insertParagraph':
|
|
3631
|
+
updateFlag = true;
|
|
3632
|
+
this.insertParagraphHandler.execute(this.value, this.selectionController, e);
|
|
3633
|
+
break;
|
|
3634
|
+
case 'insertText':
|
|
3635
|
+
updateFlag = true;
|
|
3636
|
+
this.insertTextHandler.execute(this.value, this.selectionController, e);
|
|
3637
|
+
break;
|
|
3638
|
+
case 'insertLineBreak':
|
|
3639
|
+
updateFlag = true;
|
|
3640
|
+
this.insertLineBreakHandler.execute(this.value, this.selectionController, e);
|
|
3641
|
+
break;
|
|
3642
|
+
case 'deleteContentBackward':
|
|
3643
|
+
updateFlag = true;
|
|
3644
|
+
this.deleteContentHandler.execute(this.value, this.selectionController, e);
|
|
3645
|
+
break;
|
|
3646
|
+
case 'insertFromPaste':
|
|
3647
|
+
updateFlag = true;
|
|
3648
|
+
this.insertPasteHandler.execute(this.value, this.selectionController, e);
|
|
3649
|
+
break;
|
|
3650
|
+
}
|
|
3651
|
+
if (updateFlag) {
|
|
3652
|
+
this.notifyComponentFlushValue();
|
|
3653
|
+
}
|
|
3654
|
+
};
|
|
3655
|
+
/**
|
|
3656
|
+
* Processes mutation records related to character data and updates the text content of a rich text node accordingly.
|
|
3657
|
+
*
|
|
3658
|
+
* @param {MutationRecord[]} records - Each `MutationRecord` object represents a single mutation that occurred in the DOM.
|
|
3659
|
+
*/
|
|
3660
|
+
this.handleObserver = (records) => {
|
|
3661
|
+
let updateFlag = false;
|
|
3662
|
+
if (records.every((record) => record.type === 'characterData')) {
|
|
3663
|
+
records.forEach((record) => {
|
|
3664
|
+
const { target } = record;
|
|
3665
|
+
if (target.nodeType === Node.TEXT_NODE && target.parentElement) {
|
|
3666
|
+
const richTextNode = stateEntityRenderingRegistry.getEntityByDOM(target.parentElement);
|
|
3667
|
+
if (richTextNode && richTextNode['text'] !== target.textContent) {
|
|
3668
|
+
updateFlag = true;
|
|
3669
|
+
richTextNode['text'] = target.textContent;
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
});
|
|
3673
|
+
if (updateFlag) {
|
|
3674
|
+
this.notifyComponentFlushValue();
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
}
|
|
3679
|
+
/**
|
|
3680
|
+
* The function `initMutationObserver` initializes a MutationObserver on an editable HTML element if it exists.
|
|
3681
|
+
*/
|
|
3682
|
+
initMutationObserver() {
|
|
3683
|
+
if (this.mutationObserver) {
|
|
3684
|
+
const editableElement = this.getEditableElementRef();
|
|
3685
|
+
if (editableElement) {
|
|
3686
|
+
this.mutationObserver.disconnect();
|
|
3687
|
+
this.mutationObserver.observe(editableElement, this.observerOptions);
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* Disconnects the mutation observer if it exists.
|
|
3693
|
+
*/
|
|
3694
|
+
removeObserver() {
|
|
3695
|
+
if (this.mutationObserver) {
|
|
3696
|
+
this.mutationObserver.disconnect();
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
/**
|
|
3700
|
+
* Adds event listener to an editable HTML element to handle user input actions.
|
|
3701
|
+
*/
|
|
3702
|
+
addActionListener() {
|
|
3703
|
+
const editableElement = this.getEditableElementRef();
|
|
3704
|
+
if (editableElement) {
|
|
3705
|
+
editableElement.addEventListener('beforeinput', this.handleUserInputAction);
|
|
3706
|
+
editableElement.addEventListener('drop', this.preventDropEvent);
|
|
3707
|
+
}
|
|
3708
|
+
this.mutationObserver = new MutationObserver(this.handleObserver);
|
|
3709
|
+
this.initMutationObserver();
|
|
3710
|
+
}
|
|
3711
|
+
/**
|
|
3712
|
+
* Removes event listener for user input actions from an editable HTML div element.
|
|
3713
|
+
*/
|
|
3714
|
+
removeActionListener() {
|
|
3715
|
+
const editableElement = this.getEditableElementRef();
|
|
3716
|
+
if (editableElement) {
|
|
3717
|
+
editableElement.removeEventListener('beforeinput', this.handleUserInputAction);
|
|
3718
|
+
editableElement.removeEventListener('drop', this.preventDropEvent);
|
|
3719
|
+
}
|
|
3720
|
+
this.removeObserver();
|
|
3721
|
+
}
|
|
3722
|
+
/**
|
|
3723
|
+
* re-connect the observer after the props change and component did render
|
|
3724
|
+
*/
|
|
3725
|
+
reConnectObserver() {
|
|
3726
|
+
this.initMutationObserver();
|
|
3727
|
+
}
|
|
3728
|
+
/**
|
|
3729
|
+
* The function `getEditableElementRef` returns a reference to the editable HTMLDivElement within a rich text editor.
|
|
3730
|
+
*
|
|
3731
|
+
* @returns {HTMLDivElement|null} A reference to an HTMLDivElement element that is editable.
|
|
3732
|
+
*/
|
|
3733
|
+
getEditableElementRef() {
|
|
3734
|
+
if (!this.editableElementRef) {
|
|
3735
|
+
this.editableElementRef = this.vegaRichTextEditorRenderer.getRTEEditableElementRef();
|
|
3736
|
+
}
|
|
3737
|
+
return this.editableElementRef;
|
|
3738
|
+
}
|
|
3739
|
+
/**
|
|
3740
|
+
* Notifies a change manager with the host and value details and logs the current value.
|
|
3741
|
+
*/
|
|
3742
|
+
notifyComponentFlushValue() {
|
|
3743
|
+
void this.valueController.flushChanges(this.value);
|
|
3744
|
+
}
|
|
3745
|
+
/**
|
|
3746
|
+
* Prevents the default behavior of a drag event.
|
|
3747
|
+
*
|
|
3748
|
+
* @param {DragEvent} e - drop event object
|
|
3749
|
+
*/
|
|
3750
|
+
preventDropEvent(e) {
|
|
3751
|
+
e.preventDefault();
|
|
3752
|
+
}
|
|
3753
|
+
/**
|
|
3754
|
+
* Initializes the value to an empty array if it is currently empty.
|
|
3755
|
+
*/
|
|
3756
|
+
initValueIfEmpty() {
|
|
3757
|
+
if (!this.value) {
|
|
3758
|
+
const id = generateUUID();
|
|
3759
|
+
const defaultParagraph = [
|
|
3760
|
+
{ id, type: 'paragraph', nodes: [{ id: `${id}1`, type: 'text', text: '' }] },
|
|
3761
|
+
];
|
|
3762
|
+
void this.valueController.flushChanges(VegaRTEContent.fromJSON(defaultParagraph));
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
__decorate$a([
|
|
3767
|
+
MapToComponentField()
|
|
3768
|
+
], UserInputController.prototype, "host", void 0);
|
|
3769
|
+
__decorate$a([
|
|
3770
|
+
MapToComponentField()
|
|
3771
|
+
], UserInputController.prototype, "value", void 0);
|
|
3772
|
+
__decorate$a([
|
|
3773
|
+
MapToComponentField()
|
|
3774
|
+
], UserInputController.prototype, "valueController", void 0);
|
|
3775
|
+
__decorate$a([
|
|
3776
|
+
MapToComponentField()
|
|
3777
|
+
], UserInputController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
3778
|
+
__decorate$a([
|
|
3779
|
+
MapToComponentField()
|
|
3780
|
+
], UserInputController.prototype, "selectionController", void 0);
|
|
3781
|
+
__decorate$a([
|
|
3782
|
+
MapToComponentMethod('componentDidLoad')
|
|
3783
|
+
], UserInputController.prototype, "addActionListener", null);
|
|
3784
|
+
__decorate$a([
|
|
3785
|
+
MapToComponentMethod('disconnectedCallback')
|
|
3786
|
+
], UserInputController.prototype, "removeActionListener", null);
|
|
3787
|
+
__decorate$a([
|
|
3788
|
+
MapToComponentMethod('componentDidRender')
|
|
3789
|
+
], UserInputController.prototype, "reConnectObserver", null);
|
|
3790
|
+
|
|
3791
|
+
/**
|
|
3792
|
+
* A rule that checks if input range is empty or not
|
|
3793
|
+
*
|
|
3794
|
+
* @implements {FormFieldValidationRule<string[]>}
|
|
3795
|
+
*/
|
|
3796
|
+
class RichTextEditorRequiredRule {
|
|
3797
|
+
/**
|
|
3798
|
+
* It checks if the input is a valid value.
|
|
3799
|
+
*
|
|
3800
|
+
* @param {string[]} input - The value of the input field.
|
|
3801
|
+
* @returns {EvaluateResultTranslation} An object with two properties: isValid and message.
|
|
3802
|
+
*/
|
|
3803
|
+
evaluate(input) {
|
|
3804
|
+
var _a;
|
|
3805
|
+
if (!this.isAcceptedInputType(input)) {
|
|
3806
|
+
throw new Error(`Invalid value ${input} for rich text editor`);
|
|
3807
|
+
}
|
|
3808
|
+
const isValid = ((_a = input === null || input === void 0 ? void 0 : input.blocks) === null || _a === void 0 ? void 0 : _a.length) > 0 && input.blocks.some((block) => block.isNotEmpty());
|
|
3809
|
+
return {
|
|
3810
|
+
isValid,
|
|
3811
|
+
message: isValid ? '' : 'This field is required',
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
/**
|
|
3815
|
+
* If the input is accepted and the status is not disabled and visible, then return true
|
|
3816
|
+
*
|
|
3817
|
+
* @param {unknown} input - The input to be evaluated.
|
|
3818
|
+
* @param {FormFieldStatusMeta} [status] - FormFieldStatusMeta
|
|
3819
|
+
* @returns {boolean} A boolean value.
|
|
3820
|
+
*/
|
|
3821
|
+
canEvaluate(input, status) {
|
|
3822
|
+
return status
|
|
3823
|
+
? this.isAcceptedInputType(input) && !status.disabled && status.visible
|
|
3824
|
+
: this.isAcceptedInputType(input);
|
|
3825
|
+
}
|
|
3826
|
+
/**
|
|
3827
|
+
* If the field is not disabled, visible, and has been touched or modified, then show the error
|
|
3828
|
+
*
|
|
3829
|
+
* @param {FormFieldStatusMeta} status - FormFieldStatusMeta
|
|
3830
|
+
* @returns {boolean} A boolean value.
|
|
3831
|
+
*/
|
|
3832
|
+
shouldShowError(status) {
|
|
3833
|
+
return !status.disabled && status.visible && (status.touched || status.modified);
|
|
3834
|
+
}
|
|
3835
|
+
/**
|
|
3836
|
+
* If the input is undefined or null, return true, otherwise return true if the input is a VegaRTEContent.
|
|
3837
|
+
*
|
|
3838
|
+
* @param {unknown} input - The input value to be validated.
|
|
3839
|
+
* @returns {boolean} A boolean.
|
|
3840
|
+
*/
|
|
3841
|
+
isAcceptedInputType(input) {
|
|
3842
|
+
if (input === undefined || input === null)
|
|
3843
|
+
return true;
|
|
3844
|
+
return input instanceof VegaRTEContent;
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
/**
|
|
3849
|
+
* Insert the image to current block. if the block is not image block, this will split the block to two blocks
|
|
3850
|
+
*
|
|
3851
|
+
* @example block.apply(new InsertImageToBlockAction(node, offset, imageNode))
|
|
3852
|
+
*/
|
|
3853
|
+
class InsertImageToBlockAction extends ModifyContentAction {
|
|
3854
|
+
constructor(splitPointNode, startOffsetOfNode, imageBlockToBeInserted) {
|
|
3855
|
+
super();
|
|
3856
|
+
this.isFlushable = true;
|
|
3857
|
+
this.type = ModifyContentActionType.INSERT_IMAGE_TO_BLOCK;
|
|
3858
|
+
this.splitPointNode = splitPointNode;
|
|
3859
|
+
this.startOffsetOfNode = startOffsetOfNode;
|
|
3860
|
+
this.imageBlockToBeInserted = imageBlockToBeInserted;
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
|
|
3864
|
+
var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
3865
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3866
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3867
|
+
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;
|
|
3868
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3869
|
+
};
|
|
3870
|
+
/** Used to control the insert image tool button actions */
|
|
3871
|
+
class InsertImageController extends VegaSlimmer {
|
|
3872
|
+
/**
|
|
3873
|
+
* Insert a image to current state
|
|
3874
|
+
*
|
|
3875
|
+
* @param {string} imageUrl The image url
|
|
3876
|
+
* @returns {RTEImageNode} RTEImageNode
|
|
3877
|
+
*/
|
|
3878
|
+
insertImageToCaretPosition(imageUrl) {
|
|
3879
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
3880
|
+
const imageBlock = new RTEImageBlock(generateUUID());
|
|
3881
|
+
const newImageNode = new RTEImageNode(generateUUID(), imageUrl, imageBlock);
|
|
3882
|
+
newImageNode.apply(new ImageAnnotationAction('md', ''));
|
|
3883
|
+
imageBlock.apply(new AppendChildNodesAction([newImageNode]));
|
|
3884
|
+
if (selectedBlocks.length < 1 || this.value.blocks.length < 1) {
|
|
3885
|
+
this.value.apply(new AppendChildNodesAction([imageBlock]));
|
|
3886
|
+
void this.valueController.flushChanges(this.value);
|
|
3887
|
+
}
|
|
3888
|
+
else {
|
|
3889
|
+
const { startOffset } = this.selectionController.getCurrentRange();
|
|
3890
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
3891
|
+
selectedBlocks[0].apply(new InsertImageToBlockAction(selectedNodes[0], startOffset, imageBlock));
|
|
3892
|
+
}
|
|
3893
|
+
this.updateCaretPosition(newImageNode);
|
|
3894
|
+
return newImageNode;
|
|
3895
|
+
}
|
|
3896
|
+
/**
|
|
3897
|
+
* Add image selected observer
|
|
3898
|
+
*/
|
|
3899
|
+
registerObserver() {
|
|
3900
|
+
this.registerImageSelectedObserver();
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* remove the observer when component removed
|
|
3904
|
+
*/
|
|
3905
|
+
unRegisterObserver() {
|
|
3906
|
+
this.removeImageSelectedObserver();
|
|
3907
|
+
}
|
|
3908
|
+
/**
|
|
3909
|
+
* Updates the caret position to the parent element of a new image node.
|
|
3910
|
+
*
|
|
3911
|
+
* @param {RTEImageNode} newImageNode - An image node in a rich text editor.
|
|
3912
|
+
*/
|
|
3913
|
+
updateCaretPosition(newImageNode) {
|
|
3914
|
+
this.selectionController.enqueueSelectionRangeFutureState(newImageNode, 1);
|
|
3915
|
+
}
|
|
3916
|
+
/**
|
|
3917
|
+
* The current selected node should be current image node after click image.
|
|
3918
|
+
*/
|
|
3919
|
+
registerImageSelectedObserver() {
|
|
3920
|
+
const richTextContentRef = this.vegaRichTextEditorRenderer.getRichTextContentRef();
|
|
3921
|
+
if (richTextContentRef) {
|
|
3922
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(richTextContentRef, VegaInternalRichTextImageClick, (payload) => {
|
|
3923
|
+
const range = this.selectionController.getCurrentRange();
|
|
3924
|
+
if (!range || range.startContainer !== payload.host || range.startOffset !== 0) {
|
|
3925
|
+
const imageNode = stateEntityRenderingRegistry.getEntityByDOM(payload.host.querySelector('img'));
|
|
3926
|
+
this.selectionController.enqueueSelectionRangeFutureState(imageNode, 0, imageNode, 0, true);
|
|
3927
|
+
}
|
|
3928
|
+
});
|
|
3929
|
+
/*
|
|
3930
|
+
* The below method is e2e-test covered in
|
|
3931
|
+
* @see{module:vega-rich-text-editor-image-click-delete-button}
|
|
3932
|
+
*/
|
|
3933
|
+
/* istanbul ignore next */
|
|
3934
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(richTextContentRef, VegaInternalRichTextImageDeleteButtonClicked, (payload) => {
|
|
3935
|
+
const range = this.selectionController.getCurrentRange();
|
|
3936
|
+
if (!range || range.startContainer !== payload.host || range.startOffset !== 1) {
|
|
3937
|
+
this.selectionController.enqueueSelectionRangeFutureState(payload.host, 1, payload.host, 1, true);
|
|
3938
|
+
}
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
/**
|
|
3943
|
+
* remove the observer after component delete
|
|
3944
|
+
*/
|
|
3945
|
+
removeImageSelectedObserver() {
|
|
3946
|
+
const richTextContentRef = this.vegaRichTextEditorRenderer.getRichTextContentRef();
|
|
3947
|
+
if (richTextContentRef) {
|
|
3948
|
+
DomNodeSubjectObserverFactory.removeUniqueObserverFromNode(richTextContentRef, VegaInternalRichTextImageClick);
|
|
3949
|
+
DomNodeSubjectObserverFactory.removeUniqueObserverFromNode(richTextContentRef, VegaInternalRichTextImageDeleteButtonClicked);
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
__decorate$9([
|
|
3954
|
+
MapToComponentField()
|
|
3955
|
+
], InsertImageController.prototype, "selectionController", void 0);
|
|
3956
|
+
__decorate$9([
|
|
3957
|
+
MapToComponentField()
|
|
3958
|
+
], InsertImageController.prototype, "value", void 0);
|
|
3959
|
+
__decorate$9([
|
|
3960
|
+
MapToComponentField()
|
|
3961
|
+
], InsertImageController.prototype, "valueController", void 0);
|
|
3962
|
+
__decorate$9([
|
|
3963
|
+
MapToComponentField()
|
|
3964
|
+
], InsertImageController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
3965
|
+
__decorate$9([
|
|
3966
|
+
MapToComponentMethod('componentDidLoad')
|
|
3967
|
+
], InsertImageController.prototype, "registerObserver", null);
|
|
3968
|
+
__decorate$9([
|
|
3969
|
+
MapToComponentMethod('disconnectedCallback')
|
|
3970
|
+
], InsertImageController.prototype, "unRegisterObserver", null);
|
|
3971
|
+
|
|
3972
|
+
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
3973
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3974
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3975
|
+
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;
|
|
3976
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3977
|
+
};
|
|
3978
|
+
/**
|
|
3979
|
+
* Focus controller for RTE
|
|
3980
|
+
*/
|
|
3981
|
+
class FocusController extends VegaSlimmer {
|
|
3982
|
+
constructor() {
|
|
3983
|
+
super(...arguments);
|
|
3984
|
+
/**
|
|
3985
|
+
* Do a focus on the last text node of the last block
|
|
3986
|
+
*
|
|
3987
|
+
* @param {RTEContentBlock} lastBlock - The last block of the content
|
|
3988
|
+
*/
|
|
3989
|
+
this.doFocusOnLastTextNode = async (lastBlock) => {
|
|
3990
|
+
this.setCaretRangeToNodeEnd(stateEntityRenderingRegistry.getDOMByEntity(lastBlock.getLastNode()).firstChild);
|
|
3991
|
+
await this.vegaRichTextEditorRenderer.getRichTextContentRef().vegaFocus();
|
|
3992
|
+
};
|
|
3993
|
+
}
|
|
3994
|
+
/**
|
|
3995
|
+
* Focus on the last text node of the last block.
|
|
3996
|
+
*
|
|
3997
|
+
* @param {{ newLine?: boolean }} options - The options of the method
|
|
3998
|
+
* @param {boolean} options.newLine - Should a new line be added before the last text node
|
|
3999
|
+
* @returns {Promise<void>} - A promise that resolves when the focus is set
|
|
4000
|
+
*/
|
|
4001
|
+
async focusOnLastTextNode(options) {
|
|
4002
|
+
const lastBlock = this.value.blocks[this.value.blocks.length - 1];
|
|
4003
|
+
if (!(lastBlock instanceof RTETextBlock) || (options === null || options === void 0 ? void 0 : options.newLine)) {
|
|
4004
|
+
const newTextBlock = RTETextBlock.from({
|
|
4005
|
+
id: generateUUID(),
|
|
4006
|
+
type: 'paragraph',
|
|
4007
|
+
nodes: [{ id: generateUUID(), type: 'text', text: '' }],
|
|
4008
|
+
});
|
|
4009
|
+
lastBlock.parent.apply(new InsertBlocksAfterAction(lastBlock, newTextBlock));
|
|
4010
|
+
await this.valueController.flushChanges(this.value);
|
|
4011
|
+
await this.doFocusOnLastTextNode(newTextBlock);
|
|
4012
|
+
}
|
|
4013
|
+
else {
|
|
4014
|
+
await this.doFocusOnLastTextNode(lastBlock);
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
/**
|
|
4018
|
+
* Move the caret to the end of the node
|
|
4019
|
+
*
|
|
4020
|
+
* @param {Node} targetNode - The node to move the caret to
|
|
4021
|
+
*/
|
|
4022
|
+
setCaretRangeToNodeEnd(targetNode) {
|
|
4023
|
+
const range = new Range();
|
|
4024
|
+
range.setStart(targetNode, targetNode.nodeValue.length);
|
|
4025
|
+
this.selectionController.setSelectionRange(range);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
__decorate$8([
|
|
4029
|
+
MapToComponentField()
|
|
4030
|
+
], FocusController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4031
|
+
__decorate$8([
|
|
4032
|
+
MapToComponentField()
|
|
4033
|
+
], FocusController.prototype, "selectionController", void 0);
|
|
4034
|
+
__decorate$8([
|
|
4035
|
+
MapToComponentField()
|
|
4036
|
+
], FocusController.prototype, "valueController", void 0);
|
|
4037
|
+
__decorate$8([
|
|
4038
|
+
MapToComponentField()
|
|
4039
|
+
], FocusController.prototype, "value", void 0);
|
|
4040
|
+
|
|
4041
|
+
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4042
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4043
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4044
|
+
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;
|
|
4045
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4046
|
+
};
|
|
4047
|
+
/**
|
|
4048
|
+
* Controller for the text node color
|
|
4049
|
+
*/
|
|
4050
|
+
class TextNodeColorController extends VegaSlimmer {
|
|
4051
|
+
/**
|
|
4052
|
+
* Component lifecycle - [connectedCallback]
|
|
4053
|
+
* Register an observer to watch for dark mode updates, which will update the color of text node .
|
|
4054
|
+
*/
|
|
4055
|
+
connectedCallback() {
|
|
4056
|
+
this.observer = new Observer(this.isAcceptObserver.bind(this), (isDark) => {
|
|
4057
|
+
const textNodeElements = TextNodeRenderingRegistry.getTextNodeElements();
|
|
4058
|
+
textNodeElements.forEach((textColorAnnotation, element) => {
|
|
4059
|
+
element.style.color = isDark
|
|
4060
|
+
? textColorAnnotation.textColor.dark
|
|
4061
|
+
: textColorAnnotation.textColor.light;
|
|
4062
|
+
});
|
|
4063
|
+
});
|
|
4064
|
+
ChangeManager.register(DARK_MODE_CHANGE, this.observer);
|
|
4065
|
+
}
|
|
4066
|
+
/**
|
|
4067
|
+
* cancel dark mode observer when disconnectedCallback
|
|
4068
|
+
*/
|
|
4069
|
+
disconnectResizeObserver() {
|
|
4070
|
+
ChangeManager.unregister(DARK_MODE_CHANGE, this.observer);
|
|
4071
|
+
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Determines whether the observer should accept changes.
|
|
4074
|
+
*
|
|
4075
|
+
* @returns {boolean} Always returns true in the current implementation.
|
|
4076
|
+
*/
|
|
4077
|
+
isAcceptObserver() {
|
|
4078
|
+
return true;
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
__decorate$7([
|
|
4082
|
+
MapToComponentMethod('connectedCallback')
|
|
4083
|
+
], TextNodeColorController.prototype, "connectedCallback", null);
|
|
4084
|
+
__decorate$7([
|
|
4085
|
+
MapToComponentMethod('disconnectedCallback')
|
|
4086
|
+
], TextNodeColorController.prototype, "disconnectResizeObserver", null);
|
|
4087
|
+
|
|
4088
|
+
const vegaRichTextEditorCss = ":host{display:block}:host vega-field-label{margin-bottom:8px}:host vega-text{margin-bottom:16px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-secondary, 107, 116, 125, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host vega-text{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host vega-text{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host vega-text{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .rich-text-editor-container{display:flex;box-sizing:content-box;position:relative;box-sizing:content-box;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));border-radius:8px;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));margin-top:12px;overflow:auto;resize:vertical;padding-top:12px;padding-right:16px;padding-bottom:32px;padding-left:16px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .rich-text-editor-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .rich-text-editor-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .rich-text-editor-container{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}:host .rich-text-editor-container:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}:host .rich-text-editor-container:focus-within{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px;border:1px solid rgba(var(--v-border-color-input-field-focus, 19, 98, 226, 1))}:host .rich-text-editor-container.disabled{background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host .rich-text-editor-container.disabled:hover,:host .rich-text-editor-container.disabled:focus-within{border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host .rich-text-editor-container.disabled:focus-within{outline:none}:host .rich-text-editor-container.error{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}:host .rich-text-editor-container.error:hover{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}:host .rich-text-editor-container.error:focus-within{outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:2px;border:1px solid rgba(var(--v-border-color-input-field-danger-focus, 233, 71, 104, 1))}:host .rich-text-editor-container .text-editor-counter{position:absolute;bottom:8px;right:8px;display:flex;padding-left:4px;padding-right:4px;padding-top:2px;padding-bottom:2px;border-radius:4px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-inverted-primary, 252, 252, 252, 1));background-color:rgba(var(--v-bg-textarea-count, 4, 4, 28, 0.6))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .rich-text-editor-container .text-editor-counter{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .rich-text-editor-container .text-editor-counter{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .rich-text-editor-container .text-editor-counter{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .rich-text-editor-container .text-editor-counter.counter-exceed-max-length{background-color:rgba(var(--v-bg-textarea-counter-exceed-max-length, 214, 46, 81))}.toolbar-btn-group{display:flex;justify-content:center;align-items:center}.toolbar-btn-group>*:not(:first-child):not(:last-child) ::part(rich-text-editor-toolbar-button){border-radius:0px}.toolbar-btn-group>*:first-child:not(:last-child) ::part(rich-text-editor-toolbar-button){border-top-left-radius:4px;border-bottom-left-radius:4px;border-top-right-radius:0px;border-bottom-right-radius:0px}.toolbar-btn-group>*:last-child:not(:first-child) ::part(rich-text-editor-toolbar-button){border-top-left-radius:0px;border-bottom-left-radius:0px;border-top-right-radius:4px;border-bottom-right-radius:4px}.toolbar-btn-group>*:not(:first-child) ::part(rich-text-editor-toolbar-button){margin-left:-1px}.toolbar-btn-group .toolbar-btn-color-preview-box{display:flex;border:1px solid rgba(var(--v-border-chip, 205, 209, 211, 1));box-sizing:border-box;border-radius:4px;width:16px;height:16px;cursor:pointer;justify-content:center;align-items:center;margin-left:6px}.toolbar-btn-group .toolbar-btn-link-wrapper{position:relative}.toolbar-btn-group .toolbar-btn-link-wrapper vega-rich-text-link-editor{position:absolute;bottom:0;left:0;right:0}.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-error, 189, 41, 71, 1));display:block;margin-top:12px}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}.vega-hidden{display:none}";
|
|
4089
|
+
|
|
4090
|
+
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4091
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4092
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4093
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4094
|
+
else
|
|
4095
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4096
|
+
if (d = decorators[i])
|
|
4097
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4098
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4099
|
+
};
|
|
4100
|
+
const VegaRichTextEditor = class {
|
|
4101
|
+
constructor(hostRef) {
|
|
4102
|
+
registerInstance(this, hostRef);
|
|
4103
|
+
this.vegaChange = createEvent(this, "vegaChange", 7);
|
|
4104
|
+
this.change = createEvent(this, "change", 7);
|
|
4105
|
+
this.vegaImageInserted = createEvent(this, "vegaImageInserted", 7);
|
|
4106
|
+
this.imageInserted = createEvent(this, "imageInserted", 7);
|
|
4107
|
+
this.globalSlimmers = {};
|
|
4108
|
+
this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
|
|
4109
|
+
this.formFieldController = new FormFieldControllerSlimmer({
|
|
4110
|
+
propertyRules: [
|
|
4111
|
+
{
|
|
4112
|
+
propertyName: 'required',
|
|
4113
|
+
ruleFactory: (isRequired) => isRequired ? new RichTextEditorRequiredRule() : null,
|
|
4114
|
+
},
|
|
4115
|
+
],
|
|
4116
|
+
validationRulesName: 'validationRules',
|
|
4117
|
+
defaultValue: null,
|
|
4118
|
+
attributeGetter: (propertyName) => this[propertyName],
|
|
4119
|
+
inputContainerGetter: () => this.vegaRichTextEditorRenderer.getRichTextContainerRef(),
|
|
4120
|
+
touchableAreaGetter: () => [this.vegaRichTextEditorRenderer.getRichTextContentRef()],
|
|
4121
|
+
});
|
|
4122
|
+
this.changeEventEmitter = createEventEmitSlimmer(VegaRichTextEditor, VegaChange);
|
|
4123
|
+
this.vegaRichTextEditorRenderer = new VegaRichTextEditorRenderer();
|
|
4124
|
+
this.valueController = new ValueController();
|
|
4125
|
+
this.selectionController = new SelectionController();
|
|
4126
|
+
this.focusController = new FocusController();
|
|
4127
|
+
this.darkModeStateControllerSlimmer = new DarkModeStateControllerSlimmer();
|
|
4128
|
+
this.toolbarRenderer = new ToolbarRenderer();
|
|
4129
|
+
this.clearStyleToolbarButtonSlimmer = new ClearStyleToolbarButtonSlimmer();
|
|
4130
|
+
this.boldToolbarButtonSlimmer = new BoldToolbarButtonSlimmer();
|
|
4131
|
+
this.italicToolbarButtonSlimmer = new ItalicToolbarButtonSlimmer();
|
|
4132
|
+
this.underlineToolbarButtonSlimmer = new UnderlineToolbarButtonSlimmer();
|
|
4133
|
+
this.textColorToolbarButtonSlimmer = new TextColorToolbarButtonSlimmer();
|
|
4134
|
+
this.textStylesToolbarButtonSlimmer = new TextStylesToolbarButtonSlimmer();
|
|
4135
|
+
this.codeToolbarButtonSlimmer = new CodeToolbarButtonSlimmer();
|
|
4136
|
+
this.strikethroughToolbarButtonSlimmer = new StrikethroughToolbarButtonSlimmer();
|
|
4137
|
+
this.imageToolbarButtonSlimmer = new ImageToolbarButtonSlimmer();
|
|
4138
|
+
this.linkToolbarButtonSlimmer = new LinkToolbarButtonSlimmer();
|
|
4139
|
+
this.moreIndentToolbarButtonSlimmer = new MoreIndentToolbarButtonSlimmer();
|
|
4140
|
+
this.lessIndentToolbarButtonSlimmer = new LessIndentToolbarButtonSlimmer();
|
|
4141
|
+
this.bulletsNumbersToolbarButtonSlimmer = new BulletsNumbersToolbarButtonSlimmer();
|
|
4142
|
+
this.horizontalAlignmentToolbarButtonSlimmer = new HorizontalAlignmentToolbarButtonSlimmer();
|
|
4143
|
+
this.placeholderNotifySlimmer = createSubStateNotifySlimmer(VegaRichTextEditor, 'placeholder', 'watchPlaceholder');
|
|
4144
|
+
this.disabledNotifySlimmer = createSubStateNotifySlimmer(VegaRichTextEditor, 'richTextContentEditable', 'watchRichTextContentEditable');
|
|
4145
|
+
this.richTextContentController = new RichTextContentController(this);
|
|
4146
|
+
this.userInputController = new UserInputController();
|
|
4147
|
+
this.insertImageController = new InsertImageController();
|
|
4148
|
+
this.imageInsertedEventEmitter = createEventEmitSlimmer(VegaRichTextEditor, VegaImageInserted);
|
|
4149
|
+
this.changeEventPreventSlimmer = new ChildNodesEventPreventSlimmer([VegaChange], () => this.vegaRichTextEditorRenderer.getRichTextWrapperRef());
|
|
4150
|
+
this.textNodeColorController = new TextNodeColorController();
|
|
4151
|
+
this.richTextContentEditable = true;
|
|
4152
|
+
this.selectionMap = new Map();
|
|
4153
|
+
this.isInDarkMode = VegaThemeManager.isDarkMode();
|
|
4154
|
+
/**
|
|
4155
|
+
* Specifies the label for the rich text editor.
|
|
4156
|
+
*
|
|
4157
|
+
* It provides descriptive text that helps identify the
|
|
4158
|
+
* purpose or content expected in the rich text editor.
|
|
4159
|
+
*
|
|
4160
|
+
* @vegaVersion 2.34.0
|
|
4161
|
+
*/
|
|
4162
|
+
this.label = '';
|
|
4163
|
+
/**
|
|
4164
|
+
* Determines whether the rich text editor field is required.
|
|
4165
|
+
*
|
|
4166
|
+
* @vegaVersion 2.34.0
|
|
4167
|
+
*/
|
|
4168
|
+
this.required = false;
|
|
4169
|
+
/**
|
|
4170
|
+
* Specifies a placeholder string that displays as a
|
|
4171
|
+
* temporary hint or example within the rich text editor.
|
|
4172
|
+
*
|
|
4173
|
+
* It indicates the expected format or pattern of
|
|
4174
|
+
* the input within the rich text editor.
|
|
4175
|
+
*
|
|
4176
|
+
* @vegaVersion 2.34.0
|
|
4177
|
+
*/
|
|
4178
|
+
this.placeholder = '';
|
|
4179
|
+
/**
|
|
4180
|
+
* Specifies whether the rich text editor is disabled.
|
|
4181
|
+
*
|
|
4182
|
+
* @vegaVersion 2.34.0
|
|
4183
|
+
*/
|
|
4184
|
+
this.disabled = false;
|
|
4185
|
+
/**
|
|
4186
|
+
* Provides a supplementary prompt message that assists users in
|
|
4187
|
+
* understanding the expected value within the rich text editor.
|
|
4188
|
+
*
|
|
4189
|
+
* @vegaVersion 2.34.0
|
|
4190
|
+
*/
|
|
4191
|
+
this.hint = '';
|
|
4192
|
+
/**
|
|
4193
|
+
* Specifies editable section rows for the rich text editor
|
|
4194
|
+
*
|
|
4195
|
+
* @vegaVersion 2.34.0
|
|
4196
|
+
*/
|
|
4197
|
+
this.rows = 4;
|
|
4198
|
+
/**
|
|
4199
|
+
* Specifies the value of the rich text editor
|
|
4200
|
+
*
|
|
4201
|
+
* @vegaVersion 2.34.0
|
|
4202
|
+
*/
|
|
4203
|
+
// eslint-disable-next-line @stencil/strict-mutable
|
|
4204
|
+
this.value = VegaRTEContent.createEmptyContent();
|
|
4205
|
+
/**
|
|
4206
|
+
* Specifies the built-in toolbar items available in the rich-text editor.
|
|
4207
|
+
*
|
|
4208
|
+
* @vegaVersion 2.34.0
|
|
4209
|
+
*/
|
|
4210
|
+
this.toolbarItems = [
|
|
4211
|
+
['clearStyle'],
|
|
4212
|
+
['textStyles'],
|
|
4213
|
+
['bold', 'italic', 'underline', 'strikethrough', 'code'],
|
|
4214
|
+
['textColor'],
|
|
4215
|
+
['horizontalAlignment', 'bulletsNumbers'],
|
|
4216
|
+
['moreIndent', 'lessIndent'],
|
|
4217
|
+
['link'],
|
|
4218
|
+
['image'],
|
|
4219
|
+
];
|
|
4220
|
+
/**
|
|
4221
|
+
* Specifies the validation status of the rich text editor component.
|
|
4222
|
+
*
|
|
4223
|
+
* @vegaVersion 2.34.0
|
|
4224
|
+
*/
|
|
4225
|
+
/* eslint-disable-next-line @stencil/strict-mutable */
|
|
4226
|
+
this.isValid = null;
|
|
4227
|
+
/**
|
|
4228
|
+
* Determines whether automatic validation should be implemented for
|
|
4229
|
+
* the rich text editor.
|
|
4230
|
+
*
|
|
4231
|
+
* @vegaVersion 2.34.0
|
|
4232
|
+
*/
|
|
4233
|
+
this.autoValidation = true;
|
|
4234
|
+
/**
|
|
4235
|
+
* Defines custom validation rules for the rich text editor.
|
|
4236
|
+
*
|
|
4237
|
+
* @vegaVersion 2.34.0
|
|
4238
|
+
*/
|
|
4239
|
+
this.validationRules = [];
|
|
4240
|
+
}
|
|
4241
|
+
watchRichTextContentEditable() {
|
|
4242
|
+
}
|
|
4243
|
+
watchPlaceholder() {
|
|
4244
|
+
}
|
|
4245
|
+
watchDisabled() {
|
|
4246
|
+
this.richTextContentController.syncRichTextContentEditable();
|
|
4247
|
+
}
|
|
4248
|
+
watchValueUpdate() {
|
|
4249
|
+
}
|
|
4250
|
+
watchValidationRules() {
|
|
4251
|
+
}
|
|
4252
|
+
componentWillLoad() {
|
|
4253
|
+
this.richTextContentController.syncRichTextContentEditable();
|
|
4254
|
+
}
|
|
4255
|
+
render() {
|
|
4256
|
+
return sanitizeVegaComponent(this.vegaRichTextEditorRenderer.render(), this.host);
|
|
4257
|
+
}
|
|
4258
|
+
get host() { return getElement(this); }
|
|
4259
|
+
static get watchers() { return {
|
|
4260
|
+
"richTextContentEditable": ["watchRichTextContentEditable"],
|
|
4261
|
+
"placeholder": ["watchPlaceholder"],
|
|
4262
|
+
"disabled": ["watchDisabled"],
|
|
4263
|
+
"value": ["watchValueUpdate"],
|
|
4264
|
+
"validationRules": ["watchValidationRules"]
|
|
4265
|
+
}; }
|
|
4266
|
+
};
|
|
4267
|
+
__decorate$6([
|
|
4268
|
+
InjectVegaGlobalSlimmer()
|
|
4269
|
+
], VegaRichTextEditor.prototype, "globalSlimmers", void 0);
|
|
4270
|
+
__decorate$6([
|
|
4271
|
+
InjectVegaSlimmer()
|
|
4272
|
+
], VegaRichTextEditor.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
|
|
4273
|
+
__decorate$6([
|
|
4274
|
+
InjectVegaSlimmer()
|
|
4275
|
+
], VegaRichTextEditor.prototype, "formFieldController", void 0);
|
|
4276
|
+
__decorate$6([
|
|
4277
|
+
InjectVegaSlimmer()
|
|
4278
|
+
], VegaRichTextEditor.prototype, "changeEventEmitter", void 0);
|
|
4279
|
+
__decorate$6([
|
|
4280
|
+
InjectVegaSlimmer()
|
|
4281
|
+
], VegaRichTextEditor.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4282
|
+
__decorate$6([
|
|
4283
|
+
InjectVegaSlimmer()
|
|
4284
|
+
], VegaRichTextEditor.prototype, "valueController", void 0);
|
|
4285
|
+
__decorate$6([
|
|
4286
|
+
InjectVegaSlimmer()
|
|
4287
|
+
], VegaRichTextEditor.prototype, "selectionController", void 0);
|
|
4288
|
+
__decorate$6([
|
|
4289
|
+
InjectVegaSlimmer()
|
|
4290
|
+
], VegaRichTextEditor.prototype, "focusController", void 0);
|
|
4291
|
+
__decorate$6([
|
|
4292
|
+
InjectVegaSlimmer()
|
|
4293
|
+
], VegaRichTextEditor.prototype, "darkModeStateControllerSlimmer", void 0);
|
|
4294
|
+
__decorate$6([
|
|
4295
|
+
InjectVegaSlimmer()
|
|
4296
|
+
], VegaRichTextEditor.prototype, "toolbarRenderer", void 0);
|
|
4297
|
+
__decorate$6([
|
|
4298
|
+
InjectVegaSlimmer()
|
|
4299
|
+
], VegaRichTextEditor.prototype, "clearStyleToolbarButtonSlimmer", void 0);
|
|
4300
|
+
__decorate$6([
|
|
4301
|
+
InjectVegaSlimmer()
|
|
4302
|
+
], VegaRichTextEditor.prototype, "boldToolbarButtonSlimmer", void 0);
|
|
4303
|
+
__decorate$6([
|
|
4304
|
+
InjectVegaSlimmer()
|
|
4305
|
+
], VegaRichTextEditor.prototype, "italicToolbarButtonSlimmer", void 0);
|
|
4306
|
+
__decorate$6([
|
|
4307
|
+
InjectVegaSlimmer()
|
|
4308
|
+
], VegaRichTextEditor.prototype, "underlineToolbarButtonSlimmer", void 0);
|
|
4309
|
+
__decorate$6([
|
|
4310
|
+
InjectVegaSlimmer()
|
|
4311
|
+
], VegaRichTextEditor.prototype, "textColorToolbarButtonSlimmer", void 0);
|
|
4312
|
+
__decorate$6([
|
|
4313
|
+
InjectVegaSlimmer()
|
|
4314
|
+
], VegaRichTextEditor.prototype, "textStylesToolbarButtonSlimmer", void 0);
|
|
4315
|
+
__decorate$6([
|
|
4316
|
+
InjectVegaSlimmer()
|
|
4317
|
+
], VegaRichTextEditor.prototype, "codeToolbarButtonSlimmer", void 0);
|
|
4318
|
+
__decorate$6([
|
|
4319
|
+
InjectVegaSlimmer()
|
|
4320
|
+
], VegaRichTextEditor.prototype, "strikethroughToolbarButtonSlimmer", void 0);
|
|
4321
|
+
__decorate$6([
|
|
4322
|
+
InjectVegaSlimmer()
|
|
4323
|
+
], VegaRichTextEditor.prototype, "imageToolbarButtonSlimmer", void 0);
|
|
4324
|
+
__decorate$6([
|
|
4325
|
+
InjectVegaSlimmer()
|
|
4326
|
+
], VegaRichTextEditor.prototype, "linkToolbarButtonSlimmer", void 0);
|
|
4327
|
+
__decorate$6([
|
|
4328
|
+
InjectVegaSlimmer()
|
|
4329
|
+
], VegaRichTextEditor.prototype, "moreIndentToolbarButtonSlimmer", void 0);
|
|
4330
|
+
__decorate$6([
|
|
4331
|
+
InjectVegaSlimmer()
|
|
4332
|
+
], VegaRichTextEditor.prototype, "lessIndentToolbarButtonSlimmer", void 0);
|
|
4333
|
+
__decorate$6([
|
|
4334
|
+
InjectVegaSlimmer()
|
|
4335
|
+
], VegaRichTextEditor.prototype, "bulletsNumbersToolbarButtonSlimmer", void 0);
|
|
4336
|
+
__decorate$6([
|
|
4337
|
+
InjectVegaSlimmer()
|
|
4338
|
+
], VegaRichTextEditor.prototype, "horizontalAlignmentToolbarButtonSlimmer", void 0);
|
|
4339
|
+
__decorate$6([
|
|
4340
|
+
InjectVegaSlimmer()
|
|
4341
|
+
], VegaRichTextEditor.prototype, "placeholderNotifySlimmer", void 0);
|
|
4342
|
+
__decorate$6([
|
|
4343
|
+
InjectVegaSlimmer()
|
|
4344
|
+
], VegaRichTextEditor.prototype, "disabledNotifySlimmer", void 0);
|
|
4345
|
+
__decorate$6([
|
|
4346
|
+
InjectVegaSlimmer()
|
|
4347
|
+
], VegaRichTextEditor.prototype, "richTextContentController", void 0);
|
|
4348
|
+
__decorate$6([
|
|
4349
|
+
InjectVegaSlimmer()
|
|
4350
|
+
], VegaRichTextEditor.prototype, "userInputController", void 0);
|
|
4351
|
+
__decorate$6([
|
|
4352
|
+
InjectVegaSlimmer()
|
|
4353
|
+
], VegaRichTextEditor.prototype, "insertImageController", void 0);
|
|
4354
|
+
__decorate$6([
|
|
4355
|
+
InjectVegaSlimmer()
|
|
4356
|
+
], VegaRichTextEditor.prototype, "imageInsertedEventEmitter", void 0);
|
|
4357
|
+
__decorate$6([
|
|
4358
|
+
InjectVegaSlimmer()
|
|
4359
|
+
], VegaRichTextEditor.prototype, "changeEventPreventSlimmer", void 0);
|
|
4360
|
+
__decorate$6([
|
|
4361
|
+
InjectVegaSlimmer()
|
|
4362
|
+
], VegaRichTextEditor.prototype, "textNodeColorController", void 0);
|
|
4363
|
+
VegaRichTextEditor.style = vegaRichTextEditorCss;
|
|
4364
|
+
|
|
4365
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4366
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4367
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4368
|
+
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;
|
|
4369
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4370
|
+
};
|
|
4371
|
+
class VegaRichTextEditorToolbarButtonRenderer extends VegaSlimmer {
|
|
4372
|
+
constructor() {
|
|
4373
|
+
super(...arguments);
|
|
4374
|
+
this.handleClick = (e) => {
|
|
4375
|
+
if (this.disabled) {
|
|
4376
|
+
e.preventDefault();
|
|
4377
|
+
}
|
|
4378
|
+
else {
|
|
4379
|
+
this.clickEventEmitter.emit(undefined, e);
|
|
4380
|
+
}
|
|
4381
|
+
};
|
|
4382
|
+
}
|
|
4383
|
+
render() {
|
|
4384
|
+
return (h("button", { part: "rich-text-editor-toolbar-button", class: {
|
|
4385
|
+
'rich-text-editor-toolbar-btn': true,
|
|
4386
|
+
'rich-text-editor-toolbar-button-disabled': this.disabled,
|
|
4387
|
+
'rich-text-editor-toolbar-button-selected': this.selected,
|
|
4388
|
+
}, onClick: this.handleClick, disabled: this.disabled },
|
|
4389
|
+
h("vega-flex", { gap: "size-8", justifyContent: "center", alignItems: "center" },
|
|
4390
|
+
h("vega-icon", { size: "size-16", color: this.iconColor, icon: VegaInternalIconManager.getIconKey(this.icon) }),
|
|
4391
|
+
this.showArrowIcon && (h("vega-icon", { size: "size-8", color: "text-secondary", icon: VegaInternalIconManager.getIconKey('chevron-down') }))),
|
|
4392
|
+
h("slot", null)));
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
(() => {
|
|
4396
|
+
VegaInternalIconManager.register({
|
|
4397
|
+
'chevron-down': chevronDown,
|
|
4398
|
+
});
|
|
4399
|
+
})();
|
|
4400
|
+
__decorate$5([
|
|
4401
|
+
MapToComponentField()
|
|
4402
|
+
], VegaRichTextEditorToolbarButtonRenderer.prototype, "disabled", void 0);
|
|
4403
|
+
__decorate$5([
|
|
4404
|
+
MapToComponentField()
|
|
4405
|
+
], VegaRichTextEditorToolbarButtonRenderer.prototype, "selected", void 0);
|
|
4406
|
+
__decorate$5([
|
|
4407
|
+
MapToComponentField()
|
|
4408
|
+
], VegaRichTextEditorToolbarButtonRenderer.prototype, "showArrowIcon", void 0);
|
|
4409
|
+
__decorate$5([
|
|
4410
|
+
MapToComponentField()
|
|
4411
|
+
], VegaRichTextEditorToolbarButtonRenderer.prototype, "icon", void 0);
|
|
4412
|
+
__decorate$5([
|
|
4413
|
+
MapToComponentField()
|
|
4414
|
+
], VegaRichTextEditorToolbarButtonRenderer.prototype, "iconColor", void 0);
|
|
4415
|
+
__decorate$5([
|
|
4416
|
+
MapToComponentField()
|
|
4417
|
+
], VegaRichTextEditorToolbarButtonRenderer.prototype, "clickEventEmitter", void 0);
|
|
4418
|
+
|
|
4419
|
+
const vegaRichTextEditorToolbarButtonCss = ":host{display:inline-block}.rich-text-editor-toolbar-btn{display:flex;justify-content:center;align-items:center;border-radius:4px;border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));padding-top:8px;padding-bottom:8px;padding-left:12px;padding-right:12px;cursor:pointer;position:relative;background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1))}.rich-text-editor-toolbar-btn:hover{background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1));border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1));z-index:1}.rich-text-editor-toolbar-btn:active{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1));z-index:1}.rich-text-editor-toolbar-btn:focus-visible{outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:-1px;z-index:2}.rich-text-editor-toolbar-btn.rich-text-editor-toolbar-button-selected{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));background-color:rgba(var(--v-bg-quaternary, 241, 248, 251, 1));z-index:1}.rich-text-editor-toolbar-btn.rich-text-editor-toolbar-button-disabled{background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}.rich-text-editor-toolbar-btn.rich-text-editor-toolbar-button-disabled vega-icon{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}";
|
|
4420
|
+
|
|
4421
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4422
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4423
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4424
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4425
|
+
else
|
|
4426
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4427
|
+
if (d = decorators[i])
|
|
4428
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4429
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4430
|
+
};
|
|
4431
|
+
const VegaRichTextEditorToolbarButton = class {
|
|
4432
|
+
constructor(hostRef) {
|
|
4433
|
+
registerInstance(this, hostRef);
|
|
4434
|
+
this.vegaClick = createEvent(this, "vegaClick", 7);
|
|
4435
|
+
this.click = createEvent(this, "click", 7);
|
|
4436
|
+
this.globalSlimmers = {};
|
|
4437
|
+
this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
|
|
4438
|
+
this.clickEventEmitter = createEventEmitSlimmer(VegaRichTextEditorToolbarButton, VegaClick);
|
|
4439
|
+
this.eventPrevent = new ChildNodesEventPreventSlimmer([VegaClick], () => this.host, {
|
|
4440
|
+
useCapture: true,
|
|
4441
|
+
customPreventHandle: (e) => {
|
|
4442
|
+
if (this.disabled) {
|
|
4443
|
+
e.stopImmediatePropagation();
|
|
4444
|
+
}
|
|
4445
|
+
},
|
|
4446
|
+
});
|
|
4447
|
+
this.renderer = new VegaRichTextEditorToolbarButtonRenderer();
|
|
4448
|
+
/**
|
|
4449
|
+
* Specifies whether the rich text editor toolbar button element is disabled.
|
|
4450
|
+
*
|
|
4451
|
+
* @vegaVersion 2.34.0
|
|
4452
|
+
*/
|
|
4453
|
+
this.disabled = false;
|
|
4454
|
+
/**
|
|
4455
|
+
* Specifies whether the rich text editor toolbar button element is selected.
|
|
4456
|
+
*
|
|
4457
|
+
* @vegaVersion 2.34.0
|
|
4458
|
+
*/
|
|
4459
|
+
this.selected = false;
|
|
4460
|
+
/**
|
|
4461
|
+
* Specifies whether the rich text editor toolbar button element is showArrowIcon.
|
|
4462
|
+
*
|
|
4463
|
+
* @vegaVersion 2.34.0
|
|
4464
|
+
*/
|
|
4465
|
+
this.showArrowIcon = false;
|
|
4466
|
+
/**
|
|
4467
|
+
* Specifies whether the toolbar button in the rich text editor is represented by an icon.
|
|
4468
|
+
*
|
|
4469
|
+
* @vegaVersion 2.34.0
|
|
4470
|
+
*/
|
|
4471
|
+
this.icon = '';
|
|
4472
|
+
/**
|
|
4473
|
+
* Specifies the color of the toolbar button icon in the rich text editor.
|
|
4474
|
+
*
|
|
4475
|
+
* @vegaVersion 2.34.0
|
|
4476
|
+
*/
|
|
4477
|
+
this.iconColor = 'text-primary';
|
|
4478
|
+
}
|
|
4479
|
+
render() {
|
|
4480
|
+
return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
|
|
4481
|
+
}
|
|
4482
|
+
get host() { return getElement(this); }
|
|
4483
|
+
};
|
|
4484
|
+
__decorate$4([
|
|
4485
|
+
InjectVegaGlobalSlimmer()
|
|
4486
|
+
], VegaRichTextEditorToolbarButton.prototype, "globalSlimmers", void 0);
|
|
4487
|
+
__decorate$4([
|
|
4488
|
+
InjectVegaSlimmer()
|
|
4489
|
+
], VegaRichTextEditorToolbarButton.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
|
|
4490
|
+
__decorate$4([
|
|
4491
|
+
InjectVegaSlimmer()
|
|
4492
|
+
], VegaRichTextEditorToolbarButton.prototype, "clickEventEmitter", void 0);
|
|
4493
|
+
__decorate$4([
|
|
4494
|
+
InjectVegaSlimmer()
|
|
4495
|
+
], VegaRichTextEditorToolbarButton.prototype, "eventPrevent", void 0);
|
|
4496
|
+
__decorate$4([
|
|
4497
|
+
InjectVegaSlimmer()
|
|
4498
|
+
], VegaRichTextEditorToolbarButton.prototype, "renderer", void 0);
|
|
4499
|
+
VegaRichTextEditorToolbarButton.style = vegaRichTextEditorToolbarButtonCss;
|
|
4500
|
+
|
|
4501
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4502
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4503
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4504
|
+
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;
|
|
4505
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4506
|
+
};
|
|
4507
|
+
class VegaRichTextImageEditorRenderer extends VegaSlimmer {
|
|
4508
|
+
constructor() {
|
|
4509
|
+
super(...arguments);
|
|
4510
|
+
this.handleKeyDown = (e) => {
|
|
4511
|
+
if (e.key === 'Enter') {
|
|
4512
|
+
void this.formRef.getValue().then(({ alt }) => {
|
|
4513
|
+
this.changeEventEmitter.emit({ action: 'edit', payload: { size: this.size, alt: alt } });
|
|
4514
|
+
});
|
|
4515
|
+
void this.popoverRef.hide();
|
|
4516
|
+
}
|
|
4517
|
+
};
|
|
4518
|
+
}
|
|
4519
|
+
render() {
|
|
4520
|
+
return (h("vega-popover", { style: { width: '100%' }, trigger: "click", alignment: "start", placement: "bottom", showArrow: false, ref: (ref) => {
|
|
4521
|
+
this.popoverRef = ref;
|
|
4522
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaPopoverShow, () => {
|
|
4523
|
+
this.selected = true;
|
|
4524
|
+
this.notifyImageSelected();
|
|
4525
|
+
void this.formRef.setValue({
|
|
4526
|
+
alt: this.alt,
|
|
4527
|
+
});
|
|
4528
|
+
});
|
|
4529
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaPopoverHide, () => {
|
|
4530
|
+
this.currentPage = 1;
|
|
4531
|
+
this.selected = false;
|
|
4532
|
+
void this.formRef.reset();
|
|
4533
|
+
});
|
|
4534
|
+
} },
|
|
4535
|
+
h("div", { slot: "popover-content" },
|
|
4536
|
+
h("slot", null)),
|
|
4537
|
+
h("div", { slot: "popover" },
|
|
4538
|
+
this.renderImageEditor(),
|
|
4539
|
+
this.renderAltTextEditor())));
|
|
4540
|
+
}
|
|
4541
|
+
findParentContainerRef() {
|
|
4542
|
+
this.parentContainerRef = findParent(this.host, 'vega-rich-text-content');
|
|
4543
|
+
}
|
|
4544
|
+
renderImageEditor() {
|
|
4545
|
+
return (h("vega-box", { display: this.currentPage === 1 ? 'block' : 'none' },
|
|
4546
|
+
h("vega-flex", { gap: "size-12", alignItems: "center" },
|
|
4547
|
+
h("vega-font", { variant: "font-field-label-sm", color: "text-primary" }, "Size:"),
|
|
4548
|
+
h("vega-segment-control", { size: "small", segments: [
|
|
4549
|
+
{ key: 'sm', text: 'Sm' },
|
|
4550
|
+
{ key: 'md', text: 'Md' },
|
|
4551
|
+
{ key: 'lg', text: 'Lg' },
|
|
4552
|
+
], selected: this.size, ref: (ref) => {
|
|
4553
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaChange, (e) => {
|
|
4554
|
+
const size = e.detail;
|
|
4555
|
+
this.size = size;
|
|
4556
|
+
this.changeEventEmitter.emit({
|
|
4557
|
+
action: 'edit',
|
|
4558
|
+
payload: { size: size, alt: this.alt },
|
|
4559
|
+
});
|
|
4560
|
+
});
|
|
4561
|
+
} }),
|
|
4562
|
+
h("vega-button-group", { variant: "tertiary", size: "small", ref: (ref) => {
|
|
4563
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaClick, (payload) => {
|
|
4564
|
+
if (payload.detail === 'Alt Text') {
|
|
4565
|
+
this.currentPage = 2;
|
|
4566
|
+
}
|
|
4567
|
+
else {
|
|
4568
|
+
this.notifyImageDeleteButtonClicked();
|
|
4569
|
+
this.changeEventEmitter.emit({ action: 'delete' });
|
|
4570
|
+
void this.popoverRef.hide();
|
|
4571
|
+
}
|
|
4572
|
+
});
|
|
4573
|
+
} },
|
|
4574
|
+
h("vega-button-group-item", { label: "Alt Text", itemKey: "Alt Text" }),
|
|
4575
|
+
h("vega-button-group-item", { label: "Delete Image", icon: VegaInternalIconManager.getIconKey('trash-can'), iconOnly: true, itemKey: "trash-can" })))));
|
|
4576
|
+
}
|
|
4577
|
+
renderAltTextEditor() {
|
|
4578
|
+
return (h("vega-box", { display: this.currentPage === 2 ? 'block' : 'none' },
|
|
4579
|
+
h("vega-form", { ref: (ref) => (this.formRef = ref) },
|
|
4580
|
+
h("vega-input", { "data-vega-form": "alt", style: { width: '315px' }, label: "Alt Text", ref: (ref) => {
|
|
4581
|
+
void ref.doFocus();
|
|
4582
|
+
}, onKeyDown: this.handleKeyDown }))));
|
|
4583
|
+
}
|
|
4584
|
+
notifyImageSelected() {
|
|
4585
|
+
if (this.parentContainerRef) {
|
|
4586
|
+
ChangeManager.notify(domNodeSubjectFactory.getSubject(this.parentContainerRef, VegaInternalRichTextImageClick), { host: this.host });
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
/*
|
|
4590
|
+
* The below method is e2e-test covered in
|
|
4591
|
+
* {module:vega-rich-text-editor-image-click-delete-button}
|
|
4592
|
+
*/
|
|
4593
|
+
/* istanbul ignore next */
|
|
4594
|
+
notifyImageDeleteButtonClicked() {
|
|
4595
|
+
if (this.parentContainerRef) {
|
|
4596
|
+
ChangeManager.notify(domNodeSubjectFactory.getSubject(this.parentContainerRef, VegaInternalRichTextImageDeleteButtonClicked), { host: this.host });
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4600
|
+
(() => {
|
|
4601
|
+
VegaInternalIconManager.register({ 'trash-can': trashCan });
|
|
4602
|
+
})();
|
|
4603
|
+
__decorate$3([
|
|
4604
|
+
MapToComponentField({ writable: true })
|
|
4605
|
+
], VegaRichTextImageEditorRenderer.prototype, "currentPage", void 0);
|
|
4606
|
+
__decorate$3([
|
|
4607
|
+
MapToComponentField({ writable: true })
|
|
4608
|
+
], VegaRichTextImageEditorRenderer.prototype, "selected", void 0);
|
|
4609
|
+
__decorate$3([
|
|
4610
|
+
MapToComponentField()
|
|
4611
|
+
], VegaRichTextImageEditorRenderer.prototype, "host", void 0);
|
|
4612
|
+
__decorate$3([
|
|
4613
|
+
MapToComponentField()
|
|
4614
|
+
], VegaRichTextImageEditorRenderer.prototype, "alt", void 0);
|
|
4615
|
+
__decorate$3([
|
|
4616
|
+
MapToComponentField({ writable: true })
|
|
4617
|
+
], VegaRichTextImageEditorRenderer.prototype, "size", void 0);
|
|
4618
|
+
__decorate$3([
|
|
4619
|
+
MapToComponentField()
|
|
4620
|
+
], VegaRichTextImageEditorRenderer.prototype, "changeEventEmitter", void 0);
|
|
4621
|
+
__decorate$3([
|
|
4622
|
+
MapToComponentMethod('componentDidLoad')
|
|
4623
|
+
], VegaRichTextImageEditorRenderer.prototype, "findParentContainerRef", null);
|
|
4624
|
+
|
|
4625
|
+
const vegaRichTextImageEditorCss = ":host{display:inline-block}:host(.rte-image-selected){outline:2px solid rgba(var(--v-border-color-tile-selected, 19, 98, 226, 1));outline-offset:-2px}";
|
|
4626
|
+
|
|
4627
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4628
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4629
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4630
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4631
|
+
else
|
|
4632
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4633
|
+
if (d = decorators[i])
|
|
4634
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4635
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4636
|
+
};
|
|
4637
|
+
const VegaRichTextImageEditor = class {
|
|
4638
|
+
constructor(hostRef) {
|
|
4639
|
+
registerInstance(this, hostRef);
|
|
4640
|
+
this.vegaChange = createEvent(this, "vegaChange", 7);
|
|
4641
|
+
this.change = createEvent(this, "change", 7);
|
|
4642
|
+
this.globalSlimmers = {};
|
|
4643
|
+
this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
|
|
4644
|
+
this.renderer = new VegaRichTextImageEditorRenderer();
|
|
4645
|
+
this.changeEventEmitter = createEventEmitSlimmer(VegaRichTextImageEditor, VegaChange);
|
|
4646
|
+
this.currentPage = 1;
|
|
4647
|
+
this.selected = false;
|
|
4648
|
+
/**
|
|
4649
|
+
* Specifies the value of image alt
|
|
4650
|
+
*
|
|
4651
|
+
* @vegaVersion 2.34.0
|
|
4652
|
+
*/
|
|
4653
|
+
this.alt = '';
|
|
4654
|
+
/**
|
|
4655
|
+
* Specifies the size of the image to the container
|
|
4656
|
+
*
|
|
4657
|
+
* @vegaVersion 2.34.0
|
|
4658
|
+
*/
|
|
4659
|
+
this.size = 'md';
|
|
4660
|
+
}
|
|
4661
|
+
render() {
|
|
4662
|
+
return sanitizeVegaComponent(h(Host, { class: { 'rte-image-selected': this.selected } }, this.renderer.render()), this.host);
|
|
4663
|
+
}
|
|
4664
|
+
get host() { return getElement(this); }
|
|
4665
|
+
};
|
|
4666
|
+
__decorate$2([
|
|
4667
|
+
InjectVegaGlobalSlimmer()
|
|
4668
|
+
], VegaRichTextImageEditor.prototype, "globalSlimmers", void 0);
|
|
4669
|
+
__decorate$2([
|
|
4670
|
+
InjectVegaSlimmer()
|
|
4671
|
+
], VegaRichTextImageEditor.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
|
|
4672
|
+
__decorate$2([
|
|
4673
|
+
InjectVegaSlimmer()
|
|
4674
|
+
], VegaRichTextImageEditor.prototype, "renderer", void 0);
|
|
4675
|
+
__decorate$2([
|
|
4676
|
+
InjectVegaSlimmer()
|
|
4677
|
+
], VegaRichTextImageEditor.prototype, "changeEventEmitter", void 0);
|
|
4678
|
+
VegaRichTextImageEditor.style = vegaRichTextImageEditorCss;
|
|
4679
|
+
|
|
4680
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4681
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4682
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4683
|
+
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;
|
|
4684
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4685
|
+
};
|
|
4686
|
+
class VegaRichTextLinkEditorRenderer extends VegaSlimmer {
|
|
4687
|
+
constructor() {
|
|
4688
|
+
super(...arguments);
|
|
4689
|
+
this.handleKeyDown = (e) => {
|
|
4690
|
+
if (e.key === 'Enter') {
|
|
4691
|
+
void this.formRef.getValue().then(({ text, url }) => {
|
|
4692
|
+
if (url.length > 0) {
|
|
4693
|
+
this.changeEventEmitter.emit({
|
|
4694
|
+
action: 'link',
|
|
4695
|
+
payload: { text: text || url, url },
|
|
4696
|
+
});
|
|
4697
|
+
void this.popoverRef.hide();
|
|
4698
|
+
}
|
|
4699
|
+
});
|
|
4700
|
+
}
|
|
4701
|
+
};
|
|
4702
|
+
}
|
|
4703
|
+
/**
|
|
4704
|
+
* Component lifecycle - [componentDidLoad]{@link VegaRichTextLinkEditor.componentDidLoad}
|
|
4705
|
+
*/
|
|
4706
|
+
componentDidLoad() {
|
|
4707
|
+
this.updatePopoverTarget();
|
|
4708
|
+
}
|
|
4709
|
+
/**
|
|
4710
|
+
* Component lifecycle - [componentDidRender]{@link VegaRichTextLinkEditor.componentDidRender}
|
|
4711
|
+
*/
|
|
4712
|
+
componentDidRender() {
|
|
4713
|
+
ChangeManager.notify(domNodeSubjectFactory.getSubject(this.host, VegaInternalComponentDidRender), {});
|
|
4714
|
+
}
|
|
4715
|
+
watchStatusChange() {
|
|
4716
|
+
if (this.status === 'linkEdit') {
|
|
4717
|
+
setTimeout(() => {
|
|
4718
|
+
void this.urlInputRef.doFocus();
|
|
4719
|
+
});
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
watchTargetChange() {
|
|
4723
|
+
this.updatePopoverTarget();
|
|
4724
|
+
}
|
|
4725
|
+
getPopoverRef() {
|
|
4726
|
+
return this.popoverRef;
|
|
4727
|
+
}
|
|
4728
|
+
render() {
|
|
4729
|
+
return (h("vega-popover", { trigger: "click", alignment: "start", placement: "bottom", showArrow: false, ref: (ref) => {
|
|
4730
|
+
this.popoverRef = ref;
|
|
4731
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaPopoverShow, () => {
|
|
4732
|
+
var _a, _b;
|
|
4733
|
+
if (this.status === 'linkEdit') {
|
|
4734
|
+
void this.urlInputRef.doFocus();
|
|
4735
|
+
}
|
|
4736
|
+
void this.formRef.setValue({
|
|
4737
|
+
text: (_a = this.record) === null || _a === void 0 ? void 0 : _a.text,
|
|
4738
|
+
url: (_b = this.record) === null || _b === void 0 ? void 0 : _b.url,
|
|
4739
|
+
});
|
|
4740
|
+
});
|
|
4741
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaPopoverHide, () => {
|
|
4742
|
+
void this.formRef.reset();
|
|
4743
|
+
if (this.resetStatusAfterHide) {
|
|
4744
|
+
this.status = 'editOrUnlinkSelection';
|
|
4745
|
+
}
|
|
4746
|
+
});
|
|
4747
|
+
} },
|
|
4748
|
+
h("span", { slot: "popover-content" },
|
|
4749
|
+
h("slot", null)),
|
|
4750
|
+
h("div", { slot: "popover" },
|
|
4751
|
+
this.renderLinkUnlinkContent(),
|
|
4752
|
+
this.renderLinkEditContent())));
|
|
4753
|
+
}
|
|
4754
|
+
renderLinkUnlinkContent() {
|
|
4755
|
+
return (h("vega-box", { display: this.status === 'editOrUnlinkSelection' ? 'block' : 'none' },
|
|
4756
|
+
h("vega-button-group", { size: "small", variant: "tertiary", ref: (node) => {
|
|
4757
|
+
DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, VegaClick, ({ detail }) => {
|
|
4758
|
+
switch (detail) {
|
|
4759
|
+
case 'edit': {
|
|
4760
|
+
this.status = 'linkEdit';
|
|
4761
|
+
return;
|
|
4762
|
+
}
|
|
4763
|
+
case 'unlink': {
|
|
4764
|
+
this.changeEventEmitter.emit({ action: 'unlink' });
|
|
4765
|
+
void this.popoverRef.hide();
|
|
4766
|
+
}
|
|
4767
|
+
}
|
|
4768
|
+
});
|
|
4769
|
+
} },
|
|
4770
|
+
h("vega-button-group-item", { label: "Edit", itemKey: "edit" }),
|
|
4771
|
+
h("vega-button-group-item", { label: "Unlink", itemKey: "unlink" }))));
|
|
4772
|
+
}
|
|
4773
|
+
renderLinkEditContent() {
|
|
4774
|
+
return (h("vega-box", { display: this.status === 'linkEdit' ? 'block' : 'none' },
|
|
4775
|
+
h("vega-form", { ref: (ref) => (this.formRef = ref) },
|
|
4776
|
+
h("vega-flex", { style: { width: '419px' }, direction: "col", gap: "size-16" },
|
|
4777
|
+
h("vega-input", { "data-vega-form": "url", ref: (ref) => {
|
|
4778
|
+
this.urlInputRef = ref;
|
|
4779
|
+
}, size: "small", label: "URL", onKeyDown: this.handleKeyDown }),
|
|
4780
|
+
h("vega-input", { size: "small", label: "Text", "data-vega-form": "text", onKeyDown: this.handleKeyDown })))));
|
|
4781
|
+
}
|
|
4782
|
+
updatePopoverTarget() {
|
|
4783
|
+
remoteInvocationRegistry.call(domNodeSubjectFactory.getSubject(this.popoverRef, VegaInternalPopoverUpdateTarget), this.target);
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
4786
|
+
__decorate$1([
|
|
4787
|
+
MapToComponentField()
|
|
4788
|
+
], VegaRichTextLinkEditorRenderer.prototype, "host", void 0);
|
|
4789
|
+
__decorate$1([
|
|
4790
|
+
MapToComponentField({ writable: true })
|
|
4791
|
+
], VegaRichTextLinkEditorRenderer.prototype, "status", void 0);
|
|
4792
|
+
__decorate$1([
|
|
4793
|
+
MapToComponentField({ writable: true })
|
|
4794
|
+
], VegaRichTextLinkEditorRenderer.prototype, "record", void 0);
|
|
4795
|
+
__decorate$1([
|
|
4796
|
+
MapToComponentField()
|
|
4797
|
+
], VegaRichTextLinkEditorRenderer.prototype, "changeEventEmitter", void 0);
|
|
4798
|
+
__decorate$1([
|
|
4799
|
+
MapToComponentField()
|
|
4800
|
+
], VegaRichTextLinkEditorRenderer.prototype, "resetStatusAfterHide", void 0);
|
|
4801
|
+
__decorate$1([
|
|
4802
|
+
MapToComponentField()
|
|
4803
|
+
], VegaRichTextLinkEditorRenderer.prototype, "target", void 0);
|
|
4804
|
+
__decorate$1([
|
|
4805
|
+
MapToComponentMethod('componentDidLoad')
|
|
4806
|
+
], VegaRichTextLinkEditorRenderer.prototype, "componentDidLoad", null);
|
|
4807
|
+
__decorate$1([
|
|
4808
|
+
MapToComponentMethod('componentDidRender')
|
|
4809
|
+
], VegaRichTextLinkEditorRenderer.prototype, "componentDidRender", null);
|
|
4810
|
+
__decorate$1([
|
|
4811
|
+
MapToComponentMethod('watchStatusChange')
|
|
4812
|
+
], VegaRichTextLinkEditorRenderer.prototype, "watchStatusChange", null);
|
|
4813
|
+
__decorate$1([
|
|
4814
|
+
MapToComponentMethod('watchTargetChange')
|
|
4815
|
+
], VegaRichTextLinkEditorRenderer.prototype, "watchTargetChange", null);
|
|
4816
|
+
|
|
4817
|
+
const vegaRichTextLinkEditorCss = ":host{display:contents}:host vega-popover{display:inline}";
|
|
4818
|
+
|
|
4819
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4820
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4821
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4822
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4823
|
+
else
|
|
4824
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4825
|
+
if (d = decorators[i])
|
|
4826
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4827
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4828
|
+
};
|
|
4829
|
+
const VegaRichTextLinkEditor = class {
|
|
4830
|
+
constructor(hostRef) {
|
|
4831
|
+
registerInstance(this, hostRef);
|
|
4832
|
+
this.vegaChange = createEvent(this, "vegaChange", 7);
|
|
4833
|
+
this.change = createEvent(this, "change", 7);
|
|
4834
|
+
this.globalSlimmers = {};
|
|
4835
|
+
this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
|
|
4836
|
+
this.renderer = new VegaRichTextLinkEditorRenderer();
|
|
4837
|
+
this.changeEventEmitter = createEventEmitSlimmer(VegaRichTextLinkEditor, VegaChange);
|
|
4838
|
+
/**
|
|
4839
|
+
* Specifies the status of the link editor
|
|
4840
|
+
*
|
|
4841
|
+
* @vegaVersion 2.34.0
|
|
4842
|
+
*/
|
|
4843
|
+
// eslint-disable-next-line @stencil/strict-mutable
|
|
4844
|
+
this.status = 'editOrUnlinkSelection';
|
|
4845
|
+
/**
|
|
4846
|
+
* Specifies whether the status will be reset after hide the popover
|
|
4847
|
+
*
|
|
4848
|
+
* @vegaVersion 2.34.0
|
|
4849
|
+
*/
|
|
4850
|
+
this.resetStatusAfterHide = true;
|
|
4851
|
+
}
|
|
4852
|
+
watchStatusChange() {
|
|
4853
|
+
}
|
|
4854
|
+
watchTargetChange() {
|
|
4855
|
+
}
|
|
4856
|
+
/**
|
|
4857
|
+
* Provide a method to show the link editor popover
|
|
4858
|
+
*
|
|
4859
|
+
* @vegaVersion 2.34.0
|
|
4860
|
+
*/
|
|
4861
|
+
async show() {
|
|
4862
|
+
await this.renderer.getPopoverRef().show();
|
|
4863
|
+
}
|
|
4864
|
+
render() {
|
|
4865
|
+
return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
|
|
4866
|
+
}
|
|
4867
|
+
get host() { return getElement(this); }
|
|
4868
|
+
static get watchers() { return {
|
|
4869
|
+
"status": ["watchStatusChange"],
|
|
4870
|
+
"target": ["watchTargetChange"]
|
|
4871
|
+
}; }
|
|
4872
|
+
};
|
|
4873
|
+
__decorate([
|
|
4874
|
+
InjectVegaGlobalSlimmer()
|
|
4875
|
+
], VegaRichTextLinkEditor.prototype, "globalSlimmers", void 0);
|
|
4876
|
+
__decorate([
|
|
4877
|
+
InjectVegaSlimmer()
|
|
4878
|
+
], VegaRichTextLinkEditor.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
|
|
4879
|
+
__decorate([
|
|
4880
|
+
InjectVegaSlimmer()
|
|
4881
|
+
], VegaRichTextLinkEditor.prototype, "renderer", void 0);
|
|
4882
|
+
__decorate([
|
|
4883
|
+
InjectVegaSlimmer()
|
|
4884
|
+
], VegaRichTextLinkEditor.prototype, "changeEventEmitter", void 0);
|
|
4885
|
+
VegaRichTextLinkEditor.style = vegaRichTextLinkEditorCss;
|
|
4886
|
+
|
|
4887
|
+
export { VegaRichTextEditor as vega_rich_text_editor, VegaRichTextEditorToolbarButton as vega_rich_text_editor_toolbar_button, VegaRichTextImageEditor as vega_rich_text_image_editor, VegaRichTextLinkEditor as vega_rich_text_link_editor };
|