@globalpayments/vega 2.49.1 → 2.51.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/LICENSE +9 -17
- package/dist/cjs/{app-globals-65622aeb.js → app-globals-4ecf85bb.js} +11 -8
- package/dist/cjs/{child-nodes-event-prevent-slimmer-cc193ee1.js → child-nodes-event-prevent-slimmer-29020cc8.js} +1 -1
- package/dist/cjs/{child-nodes-notify-observer-slimmer-5817a53b.js → child-nodes-notify-observer-slimmer-30ba81ac.js} +1 -1
- package/dist/cjs/{content-state-6a48bcb5.js → code-block-2d014e17.js} +212 -975
- package/dist/cjs/{component-73a88c4e.js → component-1e352960.js} +1 -0
- package/dist/cjs/{component-global-style-slimmer-6749808c.js → component-global-style-slimmer-b0b4b997.js} +3 -0
- package/dist/cjs/content-state-6a5da7ec.js +1146 -0
- package/dist/cjs/{dark-mode-style-controller-4adb7fb2.js → dark-mode-style-controller-f9a32d68.js} +8 -0
- package/dist/cjs/{design-token-cba4222e.js → design-token-3f4f0bc3.js} +1 -1
- package/dist/cjs/{dom-node-subject-factory-d5826bff.js → dom-node-subject-factory-769dd00f.js} +1 -1
- package/dist/cjs/{dom-node-subject-observer-factory-a7a3b196.js → dom-node-subject-observer-factory-5aa4cc83.js} +1 -1
- package/dist/cjs/{effect-37695d3d.js → effect-98e88068.js} +2 -8
- package/dist/cjs/{element-appender-slimmer-4a26ecb2.js → element-appender-slimmer-5b1d8ffb.js} +13 -8
- package/dist/cjs/{event-emit-slimmer-8247249c.js → event-emit-slimmer-36036ef7.js} +15 -4
- package/dist/cjs/{form-field-controller-slimmer-4b0af5bc.js → form-field-controller-slimmer-01c01946.js} +9 -7
- package/dist/cjs/{image-annotation-action-9c2b9c8e.js → image-annotation-action-617bbb13.js} +19 -18
- package/dist/cjs/{index-09acd3c9.js → index-7700600c.js} +9 -0
- package/dist/cjs/{index-c4dec3aa.js → index-ebb1bb17.js} +3 -3
- package/dist/cjs/index.cjs.js +21 -20
- package/dist/cjs/{inject-keyboard-manager-b301e887.js → inject-keyboard-manager-dd628ccc.js} +1 -1
- package/dist/cjs/{internal-vega-event-manager-c9948b59.js → internal-vega-event-manager-e98944ac.js} +8 -1
- package/dist/cjs/{keyboard-manager-2ccf4b16.js → keyboard-manager-8c74eeb9.js} +3 -1
- package/dist/cjs/{keyboard-manager-slimmer-900cf2f5.js → keyboard-manager-slimmer-eb364bee.js} +1 -1
- package/dist/cjs/{legend-input-processor-8bcce3bf.js → legend-input-processor-b1f323fa.js} +2 -0
- package/dist/cjs/loader.cjs.js +15 -14
- package/dist/cjs/{page-resize-observer-slimmer-44e08878.js → page-resize-observer-slimmer-efa79728.js} +1 -0
- package/dist/cjs/{public-rules-10ec636d.js → public-rules-a3b7e267.js} +8 -7
- package/dist/cjs/{responsive-format-facade-263d49f6.js → responsive-format-facade-6b81192d.js} +6 -6
- package/dist/cjs/{rich-text-editor-required-rule-5faded94.js → rich-text-editor-required-rule-e9c7c379.js} +1 -1
- package/dist/cjs/selection-controller-1d7c0999.js +762 -0
- package/dist/cjs/{string-input-formatter-slimmer-50322824.js → string-input-formatter-slimmer-a5feb2ed.js} +3 -3
- package/dist/cjs/{style-formatter-ae0ef7fc.js → style-formatter-497d0fa4.js} +1 -1
- package/dist/cjs/{sub-state-notify-slimmer-7f437b19.js → sub-state-notify-slimmer-f68fbf29.js} +2 -2
- package/dist/cjs/{sub-state-observer-slimmer-e90362cd.js → sub-state-observer-slimmer-e06cdf7e.js} +3 -3
- package/dist/cjs/{translation-212b1875.js → translation-e5003a00.js} +5 -0
- package/dist/cjs/{translation-slimmer-d1512c6d.js → translation-slimmer-127a0f83.js} +1 -1
- package/dist/cjs/{ui-13b42af0.js → ui-6c069604.js} +2 -0
- package/dist/cjs/vega-accordion.cjs.entry.js +17 -16
- package/dist/cjs/vega-app-footer.cjs.entry.js +3 -3
- package/dist/cjs/vega-app-header-button.cjs.entry.js +18 -17
- package/dist/cjs/vega-backdrop.cjs.entry.js +3 -3
- package/dist/cjs/vega-banner.cjs.entry.js +7 -7
- package/dist/cjs/vega-bar-chart.cjs.entry.js +3 -3
- package/dist/cjs/vega-box.cjs.entry.js +18 -15
- package/dist/cjs/vega-brand-logo.cjs.entry.js +3 -3
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +8 -8
- package/dist/cjs/vega-button-circle.cjs.entry.js +18 -17
- package/dist/cjs/vega-button-group_2.cjs.entry.js +11 -11
- package/dist/cjs/vega-button-link.cjs.entry.js +8 -8
- package/dist/cjs/vega-button.cjs.entry.js +17 -16
- package/dist/cjs/vega-calendar_3.cjs.entry.js +14 -14
- package/dist/cjs/vega-card.cjs.entry.js +15 -14
- package/dist/cjs/vega-carousel.cjs.entry.js +20 -16
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +14 -14
- package/dist/cjs/vega-chip.cjs.entry.js +18 -17
- package/dist/cjs/vega-code-block.cjs.entry.js +4160 -0
- package/dist/cjs/vega-color-picker.cjs.entry.js +12 -12
- package/dist/cjs/vega-combo-box.cjs.entry.js +15 -15
- package/dist/cjs/vega-counter-badge.cjs.entry.js +2 -2
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +34 -24
- package/dist/cjs/vega-dialog_2.cjs.entry.js +25 -18
- package/dist/cjs/vega-divider.cjs.entry.js +15 -14
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +25 -24
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-field-error.cjs.entry.js +2 -2
- package/dist/cjs/vega-field-label.cjs.entry.js +7 -7
- package/dist/cjs/vega-file-uploader.cjs.entry.js +13 -13
- package/dist/cjs/vega-flag-icon.cjs.entry.js +15 -14
- package/dist/cjs/vega-flex.cjs.entry.js +16 -15
- package/dist/cjs/vega-font.cjs.entry.js +15 -14
- package/dist/cjs/vega-form.cjs.entry.js +15 -15
- package/dist/cjs/vega-grid.cjs.entry.js +15 -14
- package/dist/cjs/vega-hint.cjs.entry.js +2 -2
- package/dist/cjs/vega-icon.cjs.entry.js +19 -15
- package/dist/cjs/vega-image-uploader.cjs.entry.js +22 -19
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +13 -13
- package/dist/cjs/vega-input-numeric.cjs.entry.js +16 -16
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +18 -17
- package/dist/cjs/vega-input-range.cjs.entry.js +16 -16
- package/dist/cjs/vega-input-select.cjs.entry.js +25 -24
- package/dist/cjs/vega-input.cjs.entry.js +35 -17
- package/dist/cjs/{vega-internal-event-id-bfea9b93.js → vega-internal-event-id-6cdc95fe.js} +4 -0
- package/dist/cjs/vega-item-toggle.cjs.entry.js +7 -7
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +26 -20
- package/dist/cjs/vega-line-chart.cjs.entry.js +4 -4
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +15 -13
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +5 -5
- package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +8 -8
- package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +8 -8
- package/dist/cjs/vega-pagination.cjs.entry.js +18 -17
- package/dist/cjs/vega-pie-chart.cjs.entry.js +3 -3
- package/dist/cjs/vega-popover_2.cjs.entry.js +19 -18
- package/dist/cjs/vega-progress-tracker.cjs.entry.js +7 -7
- package/dist/cjs/vega-radio_2.cjs.entry.js +16 -16
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +189 -32
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +814 -1181
- package/dist/cjs/vega-section-title.cjs.entry.js +2 -2
- package/dist/cjs/vega-segment-control.cjs.entry.js +8 -8
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +20 -19
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +15 -15
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +23 -18
- package/dist/cjs/vega-signature-capture.cjs.entry.js +21 -19
- package/dist/cjs/{vega-skeleton-loader-controller-db868c98.js → vega-skeleton-loader-controller-ae2ab090.js} +15 -5
- package/dist/cjs/vega-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/vega-slot-container.cjs.entry.js +1 -1
- package/dist/cjs/vega-stepper.cjs.entry.js +13 -13
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +9 -9
- package/dist/cjs/vega-table_8.cjs.entry.js +377 -286
- package/dist/cjs/vega-text.cjs.entry.js +5 -3
- package/dist/cjs/vega-textarea.cjs.entry.js +13 -13
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +25 -24
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +12 -12
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +18 -17
- package/dist/cjs/vega.cjs.js +15 -14
- package/dist/cjs/{wait-for-vega-handler-0a0738ac.js → wait-for-vega-handler-4491efc9.js} +3 -1
- package/dist/cjs/{y-axis-input-processor-e371c142.js → y-axis-input-processor-19a07af5.js} +1 -1
- package/dist/collection/collection-manifest.json +7 -1
- package/dist/collection/components/vega-box/slimmers/controllers/vega-box-responsive-style-controller.js +1 -0
- package/dist/collection/components/vega-box/slimmers/controllers/vega-box-state-styles-controller.js +1 -0
- package/dist/collection/components/vega-carousel/vega-carousel.js +3 -0
- package/dist/collection/components/vega-code-block/assets/copy.js +3 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/code-block-range.js +129 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/code-highlight-parser.abstract.js +87 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/default-code-highlight-parse-controller.js +34 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/insert-composition-text-controller.js +100 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.js +86 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-content-parse-controller.js +50 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-focus-controller.js +57 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-input-controller.js +240 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-selection-controller.js +133 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-value-controller.js +44 -0
- package/dist/collection/components/vega-code-block/slimmers/renderers/vega-code-block-content-renderer.js +117 -0
- package/dist/collection/components/vega-code-block/slimmers/renderers/vega-code-block-copy-button-renderer.js +67 -0
- package/dist/collection/components/vega-code-block/slimmers/renderers/vega-code-block-renderer.js +122 -0
- package/dist/collection/components/vega-code-block/test/code-block-range.test.js +81 -0
- package/dist/collection/components/vega-code-block/types.js +10 -0
- package/dist/collection/components/vega-code-block/vega-code-block.css +160 -0
- package/dist/collection/components/vega-code-block/vega-code-block.js +404 -0
- package/dist/collection/components/vega-date-picker/slimmers/renderers/vega-date-picker-calendar-month-year-dropdown-renderer.js +5 -0
- package/dist/collection/components/vega-date-picker/slimmers/renderers/vega-date-picker-calendar-renderer.js +4 -0
- package/dist/collection/components/vega-icon/vega-icon.js +4 -1
- package/dist/collection/components/vega-image-uploader/slimmers/controllers/vega-image-uploader-preview-controller.js +2 -0
- package/dist/collection/components/vega-input/slimmers/controllers/vega-input-compact-width-controller.js +1 -0
- package/dist/collection/components/vega-input/vega-input.css +12 -2
- package/dist/collection/components/vega-input/vega-input.js +27 -3
- package/dist/collection/components/vega-input-range/slimmers/renderers/vega-input-range-clear-icon-renderer.js +1 -1
- package/dist/collection/components/vega-input-range/vega-input-range.css +10 -0
- package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +5 -5
- package/dist/collection/components/vega-loader-wrapper/slimmers/controllers/manage-vega-loader-wrapper-z-index-controller.js +1 -0
- package/dist/collection/components/vega-modal/slimmers/controllers/vega-modal-backdrop-controller.js +3 -0
- package/dist/collection/components/vega-modal/slimmers/controllers/vega-modal-open-state-controller.js +2 -0
- package/dist/collection/components/vega-modal/slimmers/controllers/vega-nested-modal-controller.js +1 -0
- package/dist/collection/components/vega-nav/vega-left-nav/slimmers/controllers/vega-left-nav-backdrop-controller.js +3 -0
- package/dist/collection/components/vega-nav/vega-left-nav/slimmers/controllers/vega-left-nav-open-state-controller.js +2 -0
- package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +2 -0
- package/dist/collection/components/vega-rich-text-content/vega-rich-text-content.css +7 -0
- package/dist/collection/components/vega-rich-text-editor/assets/rectangle-code.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/code-node-set-selection-range-strategy.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-text-content-strategy.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-code-block-strategy.js +48 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-insert-image-strategy.js +17 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-remove-self-strategy.js +77 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/switch-out-from-code-block-strategy.js +38 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/update-code-block-strategy.js +14 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.js +4 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/remove-code-block-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/switch-out-from-code-block-action.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/transform-to-code-block-action.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/actions/update-code-block-action.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/code-block.js +98 -0
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +5 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/code-block-node.js +50 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/node.abstract.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/code-block-renderer.js +62 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/code-block-node-renderer.js +78 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/delete-selected-nodes-controller.js +19 -4
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.js +4 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.js +54 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.js +70 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-line-break-handler.js +7 -5
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paragraph-handler.js +7 -5
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.js +24 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/internal-code-block-selection-controller.js +64 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/selection-controller.js +56 -52
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.js +21 -8
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/toolbar-renderer.js +5 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/code-block-toolbar-button-slimmer.js +65 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/code-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.js +6 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.js +3 -1
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/code-block-strategy-registry.test.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/content-state-strategy-registry.test.js +2 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/code-block.test.js +54 -0
- package/dist/collection/components/vega-rich-text-editor/test/e2e-utils.js +5 -0
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.test.js +32 -0
- package/dist/collection/components/vega-rich-text-editor/test/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.test.js +61 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +10 -0
- package/dist/collection/components/vega-sidenav/slimmers/controllers/vega-sidenav-backdrop-controller.js +3 -0
- package/dist/collection/components/vega-sidenav/slimmers/controllers/vega-sidenav-open-status-controller.js +1 -0
- package/dist/collection/components/vega-signature-capture/slimmers/written-mode/controllers/written-mode-svg-controller.js +1 -0
- package/dist/collection/components/vega-table/vega-table-head-cell/slimmers/controllers/vega-table-head-cell-sort-config-controller.js +92 -0
- package/dist/collection/components/vega-table/vega-table-head-cell/vega-table-head-cell.js +6 -0
- package/dist/collection/components/vega-text/slimmers/renderers/vega-text-tooltip-renderer.js +2 -0
- package/dist/collection/components/vega-time-picker/slimmers/renderers/vega-time-picker-range-clear-button-renderer.js +1 -1
- package/dist/collection/components/vega-time-picker/vega-time-picker.css +10 -0
- package/dist/collection/global/scripts/before-vega-load.js +3 -0
- package/dist/collection/helpers/chart/graph-context-factory.js +2 -0
- package/dist/collection/helpers/common/wait-for-vega-handler.js +3 -1
- package/dist/collection/helpers/dialog/vega-dialog-controller.js +2 -0
- package/dist/collection/helpers/event-manager/event-delegated/vega-button-click-strategy.js +1 -0
- package/dist/collection/helpers/event-manager/event-delegated/vega-checkbox-change-strategy.js +1 -0
- package/dist/collection/helpers/event-manager/event-delegated/vega-input-select-change-strategy.js +1 -0
- package/dist/collection/helpers/event-manager/event-delegated/vega-input-strategy.js +1 -0
- package/dist/collection/helpers/event-manager/event-delegated/vega-radio-change-strategy.js +1 -0
- package/dist/collection/helpers/event-manager/event-delegated/vega-textarea-change-strategy.js +1 -0
- package/dist/collection/helpers/event-manager/event-id/component-event-id-map.js +2 -1
- package/dist/collection/helpers/event-manager/event-id/vega-internal-event-id.js +2 -0
- package/dist/collection/helpers/event-manager/slimmers/event-emit-slimmer.js +3 -1
- package/dist/collection/helpers/event-manager/test/event-emit-slimmer.test.js +11 -1
- package/dist/collection/helpers/keyboard/keyboard-manager.js +2 -0
- package/dist/collection/helpers/notify/vega-notify-controller.js +6 -1
- package/dist/collection/helpers/skeleton-loader/vega-skeleton-loader-controller.js +3 -0
- package/dist/collection/helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract.js +47 -0
- package/dist/collection/helpers/slimmers/component-global-style-slimmer.js +3 -0
- package/dist/collection/helpers/slimmers/element-appender/body-positioned-wrapper/default-wrapper.js +1 -0
- package/dist/collection/helpers/slimmers/element-appender/body-positioned-wrapper/position-relative-to-wrapper.js +2 -0
- package/dist/collection/helpers/slimmers/element-appender/element-appender-slimmer.js +2 -0
- package/dist/collection/helpers/slimmers/field-error-ui-controller-strategies/sibling-container-error-label-container-retrieval-strategy.js +1 -0
- package/dist/collection/helpers/slimmers/field-error-ui-controller-strategies/sibling-container-self-retrieval-strategy.js +1 -0
- package/dist/collection/helpers/slimmers/page-resize-observer-slimmer.js +1 -0
- package/dist/collection/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.js +46 -0
- package/dist/collection/helpers/theme/controllers/color-schema-overriding-controller.js +2 -0
- package/dist/collection/helpers/theme/controllers/style-controller.abstract.js +3 -0
- package/dist/collection/helpers/theme/internal-theme-manager.js +3 -0
- package/dist/collection/helpers/translation/locales/en.js +5 -0
- package/dist/collection/helpers/translation/tests/internal-translation-controller.test.js +5 -0
- package/dist/collection/helpers/ui/element-appender.js +1 -1
- package/dist/collection/polyfill/shadow-selection/shadow-selection-polyfill.js +3 -1
- package/dist/collection/utils/component.js +1 -0
- package/dist/collection/utils/e2e-utils.js +3 -0
- package/dist/collection/utils/effect.js +2 -0
- package/dist/collection/utils/safe-document.js +9 -0
- package/dist/collection/utils/test/safe-document.test.js +13 -0
- package/dist/collection/utils/test-utils.js +1 -0
- package/dist/collection/utils/ui.js +3 -0
- package/dist/esm/{app-globals-1f8c30e9.js → app-globals-d96d623d.js} +11 -8
- package/dist/esm/{child-nodes-event-prevent-slimmer-5d45361e.js → child-nodes-event-prevent-slimmer-2b975cbf.js} +1 -1
- package/dist/esm/{child-nodes-notify-observer-slimmer-ddaad39a.js → child-nodes-notify-observer-slimmer-eeed5986.js} +1 -1
- package/dist/esm/{content-state-dbc9f635.js → code-block-ef2f04ca.js} +195 -970
- package/dist/esm/{component-cae24190.js → component-7d906393.js} +1 -0
- package/dist/esm/{component-global-style-slimmer-000e0c11.js → component-global-style-slimmer-dad40b64.js} +3 -0
- package/dist/esm/content-state-69d29a07.js +1140 -0
- package/dist/esm/{dark-mode-style-controller-2ada8e22.js → dark-mode-style-controller-ea798fc8.js} +8 -0
- package/dist/esm/{design-token-0699f0ca.js → design-token-2060cd0d.js} +1 -1
- package/dist/esm/{dom-node-subject-factory-f77cf9cc.js → dom-node-subject-factory-6374611f.js} +2 -2
- package/dist/esm/{dom-node-subject-observer-factory-715dccf9.js → dom-node-subject-observer-factory-c345ca2e.js} +1 -1
- package/dist/esm/{effect-8efd2c3c.js → effect-f50e072d.js} +2 -8
- package/dist/esm/{element-appender-slimmer-96cb54e2.js → element-appender-slimmer-64a77b7f.js} +13 -8
- package/dist/esm/{event-emit-slimmer-b7d511f6.js → event-emit-slimmer-7428cc01.js} +15 -4
- package/dist/esm/{form-field-controller-slimmer-89a72ee7.js → form-field-controller-slimmer-87d80e46.js} +9 -7
- package/dist/esm/{image-annotation-action-1aa938ab.js → image-annotation-action-1497f70e.js} +7 -6
- package/dist/esm/{index-187f71d1.js → index-d0a47531.js} +9 -0
- package/dist/esm/{index-4aa167d6.js → index-f5d2fe61.js} +3 -3
- package/dist/esm/index.js +15 -14
- package/dist/esm/{inject-keyboard-manager-f513be4a.js → inject-keyboard-manager-e39c0fd9.js} +1 -1
- package/dist/esm/{internal-vega-event-manager-87dc436c.js → internal-vega-event-manager-d80c53c5.js} +8 -1
- package/dist/esm/{keyboard-manager-262be5ce.js → keyboard-manager-9564ad83.js} +3 -1
- package/dist/esm/{keyboard-manager-slimmer-42bf9773.js → keyboard-manager-slimmer-2218e6ba.js} +1 -1
- package/dist/esm/{legend-input-processor-8f76ce8a.js → legend-input-processor-1d266967.js} +2 -0
- package/dist/esm/loader.js +15 -14
- package/dist/esm/{page-resize-observer-slimmer-15a84d26.js → page-resize-observer-slimmer-c51f1912.js} +1 -0
- package/dist/esm/{public-rules-5cf6aa95.js → public-rules-3436034b.js} +8 -7
- package/dist/esm/{responsive-format-facade-42f3fcfa.js → responsive-format-facade-8c0ce819.js} +6 -6
- package/dist/esm/{rich-text-editor-required-rule-6a7cd3ee.js → rich-text-editor-required-rule-cc5b6a2d.js} +1 -1
- package/dist/esm/selection-controller-3d6dfc87.js +757 -0
- package/dist/esm/{string-input-formatter-slimmer-c61f82d6.js → string-input-formatter-slimmer-e53b6412.js} +3 -3
- package/dist/esm/{style-formatter-cb00c709.js → style-formatter-1eca1299.js} +1 -1
- package/dist/esm/{sub-state-notify-slimmer-4e3cf09d.js → sub-state-notify-slimmer-b6c8051c.js} +2 -2
- package/dist/esm/{sub-state-observer-slimmer-be7a6ce3.js → sub-state-observer-slimmer-93eeb87d.js} +3 -3
- package/dist/esm/{translation-cf7f020a.js → translation-71e0711d.js} +5 -0
- package/dist/esm/{translation-slimmer-88966d5c.js → translation-slimmer-e6b130bf.js} +1 -1
- package/dist/esm/{ui-ed1283bb.js → ui-7d177fb0.js} +2 -0
- package/dist/esm/vega-accordion.entry.js +17 -16
- package/dist/esm/vega-app-footer.entry.js +3 -3
- package/dist/esm/vega-app-header-button.entry.js +18 -17
- package/dist/esm/vega-backdrop.entry.js +3 -3
- package/dist/esm/vega-banner.entry.js +7 -7
- package/dist/esm/vega-bar-chart.entry.js +3 -3
- package/dist/esm/vega-box.entry.js +18 -15
- package/dist/esm/vega-brand-logo.entry.js +3 -3
- package/dist/esm/vega-breadcrumb.entry.js +8 -8
- package/dist/esm/vega-button-circle.entry.js +18 -17
- package/dist/esm/vega-button-group_2.entry.js +11 -11
- package/dist/esm/vega-button-link.entry.js +8 -8
- package/dist/esm/vega-button.entry.js +17 -16
- package/dist/esm/vega-calendar_3.entry.js +14 -14
- package/dist/esm/vega-card.entry.js +15 -14
- package/dist/esm/vega-carousel.entry.js +20 -16
- package/dist/esm/vega-checkbox_2.entry.js +14 -14
- package/dist/esm/vega-chip.entry.js +18 -17
- package/dist/esm/vega-code-block.entry.js +4156 -0
- package/dist/esm/vega-color-picker.entry.js +12 -12
- package/dist/esm/vega-combo-box.entry.js +15 -15
- package/dist/esm/vega-counter-badge.entry.js +2 -2
- package/dist/esm/vega-date-picker_2.entry.js +34 -24
- package/dist/esm/vega-dialog_2.entry.js +25 -18
- package/dist/esm/vega-divider.entry.js +15 -14
- package/dist/esm/vega-dropdown_5.entry.js +25 -24
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-field-error.entry.js +2 -2
- package/dist/esm/vega-field-label.entry.js +7 -7
- package/dist/esm/vega-file-uploader.entry.js +13 -13
- package/dist/esm/vega-flag-icon.entry.js +15 -14
- package/dist/esm/vega-flex.entry.js +16 -15
- package/dist/esm/vega-font.entry.js +15 -14
- package/dist/esm/vega-form.entry.js +15 -15
- package/dist/esm/vega-grid.entry.js +15 -14
- package/dist/esm/vega-hint.entry.js +2 -2
- package/dist/esm/vega-icon.entry.js +19 -15
- package/dist/esm/vega-image-uploader.entry.js +22 -19
- package/dist/esm/vega-input-credit-card.entry.js +13 -13
- package/dist/esm/vega-input-numeric.entry.js +16 -16
- package/dist/esm/vega-input-phone-number.entry.js +18 -17
- package/dist/esm/vega-input-range.entry.js +16 -16
- package/dist/esm/vega-input-select.entry.js +25 -24
- package/dist/esm/vega-input.entry.js +35 -17
- package/dist/esm/{vega-internal-event-id-85ad403f.js → vega-internal-event-id-178b2743.js} +3 -1
- package/dist/esm/vega-item-toggle.entry.js +7 -7
- package/dist/esm/vega-left-nav_5.entry.js +26 -20
- package/dist/esm/vega-line-chart.entry.js +4 -4
- package/dist/esm/vega-loader-wrapper_2.entry.js +15 -13
- package/dist/esm/vega-page-notification_2.entry.js +5 -5
- package/dist/esm/vega-pagination-page-selector-mobile.entry.js +8 -8
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +8 -8
- package/dist/esm/vega-pagination.entry.js +18 -17
- package/dist/esm/vega-pie-chart.entry.js +3 -3
- package/dist/esm/vega-popover_2.entry.js +19 -18
- package/dist/esm/vega-progress-tracker.entry.js +7 -7
- package/dist/esm/vega-radio_2.entry.js +16 -16
- package/dist/esm/vega-rich-text-content.entry.js +170 -13
- package/dist/esm/vega-rich-text-editor_4.entry.js +679 -1046
- package/dist/esm/vega-section-title.entry.js +2 -2
- package/dist/esm/vega-segment-control.entry.js +8 -8
- package/dist/esm/vega-selection-chip_2.entry.js +20 -19
- package/dist/esm/vega-selection-tile_2.entry.js +15 -15
- package/dist/esm/vega-sidenav_3.entry.js +23 -18
- package/dist/esm/vega-signature-capture.entry.js +21 -19
- package/dist/esm/{vega-skeleton-loader-controller-c2a8bd27.js → vega-skeleton-loader-controller-06f48dd2.js} +15 -5
- package/dist/esm/vega-skeleton.entry.js +2 -2
- package/dist/esm/vega-slot-container.entry.js +1 -1
- package/dist/esm/vega-stepper.entry.js +13 -13
- package/dist/esm/vega-tab-group_2.entry.js +9 -9
- package/dist/esm/vega-table_8.entry.js +377 -286
- package/dist/esm/vega-text.entry.js +5 -3
- package/dist/esm/vega-textarea.entry.js +13 -13
- package/dist/esm/vega-time-picker_2.entry.js +25 -24
- package/dist/esm/vega-toggle-switch.entry.js +12 -12
- package/dist/esm/vega-tooltip_2.entry.js +18 -17
- package/dist/esm/vega.js +15 -14
- package/dist/esm/{wait-for-vega-handler-b18eb955.js → wait-for-vega-handler-e0a928cd.js} +3 -1
- package/dist/esm/{y-axis-input-processor-e090b01c.js → y-axis-input-processor-95995d34.js} +1 -1
- package/dist/types/components/vega-code-block/assets/copy.d.ts +3 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/code-block-range.d.ts +64 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/code-highlight-parser.abstract.d.ts +47 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/default-code-highlight-parse-controller.d.ts +19 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/insert-composition-text-controller.d.ts +50 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.d.ts +43 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-content-parse-controller.d.ts +23 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-focus-controller.d.ts +21 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-input-controller.d.ts +92 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-selection-controller.d.ts +63 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-value-controller.d.ts +21 -0
- package/dist/types/components/vega-code-block/slimmers/renderers/vega-code-block-content-renderer.d.ts +55 -0
- package/dist/types/components/vega-code-block/slimmers/renderers/vega-code-block-copy-button-renderer.d.ts +23 -0
- package/dist/types/components/vega-code-block/slimmers/renderers/vega-code-block-renderer.d.ts +50 -0
- package/dist/types/components/vega-code-block/test/code-block-range.test.d.ts +1 -0
- package/dist/types/components/vega-code-block/types.d.ts +19 -0
- package/dist/types/components/vega-code-block/vega-code-block.d.ts +118 -0
- package/dist/types/components/vega-input/types.d.ts +2 -0
- package/dist/types/components/vega-input/vega-input.d.ts +9 -2
- package/dist/types/components/vega-rich-text-editor/assets/rectangle-code.d.ts +3 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/code-node-set-selection-range-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-delete-node-content-strategy.d.ts +3 -3
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-remove-node-strategy.d.ts +4 -5
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/block-transform-to-code-block-strategy.d.ts +29 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-insert-image-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/code-block-remove-self-strategy.d.ts +28 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/switch-out-from-code-block-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/modify-content-strategies/update-code-block-strategy.d.ts +12 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/modify-content-action.abstract.d.ts +5 -1
- package/dist/types/components/vega-rich-text-editor/dto/actions/remove-code-block-action.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/switch-out-from-code-block-action.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/transform-to-code-block-action.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/actions/update-code-block-action.d.ts +14 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/code-block.d.ts +52 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/code-block-node.d.ts +41 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/node.abstract.d.ts +2 -1
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/code-block-renderer.d.ts +39 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/code-block-node-renderer.d.ts +37 -0
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +16 -4
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.d.ts +31 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.d.ts +42 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.d.ts +7 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/internal-code-block-selection-controller.d.ts +45 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/selection-controller.d.ts +16 -23
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/user-input-controller.d.ts +6 -4
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/toolbar-renderer.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/code-block-toolbar-button-slimmer.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/action-handle-strategies/code-block-strategy-registry.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/dto/blocks/code-block.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/jira-code-to-rte-code-block-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-editor.d.ts +4 -0
- package/dist/types/components/vega-table/interface.d.ts +3 -0
- package/dist/types/components/vega-table/vega-table-head-cell/slimmers/controllers/vega-table-head-cell-sort-config-controller.d.ts +42 -0
- package/dist/types/components/vega-table/vega-table-head-cell/vega-table-head-cell.d.ts +2 -0
- package/dist/types/components.d.ts +98 -3
- package/dist/types/helpers/event-manager/event-id/vega-internal-event-id.d.ts +2 -0
- package/dist/types/helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract.d.ts +20 -0
- package/dist/types/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.d.ts +1 -0
- package/dist/types/helpers/translation/interface.d.ts +6 -1
- package/dist/types/polyfill/shadow-selection/shadow-selection-polyfill.d.ts +26 -0
- package/dist/types/types/components.type.d.ts +2 -1
- package/dist/types/utils/safe-document.d.ts +7 -0
- package/dist/types/utils/test/safe-document.test.d.ts +1 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-a46bc9f1.entry.js → p-06cd4a19.entry.js} +1 -1
- package/dist/vega/p-06fb002a.js +1 -0
- package/dist/vega/{p-b351ace3.entry.js → p-07cdaf74.entry.js} +1 -1
- package/dist/vega/{p-b847a143.entry.js → p-07e40eea.entry.js} +1 -1
- package/dist/vega/{p-913eb7f9.entry.js → p-0ce88865.entry.js} +1 -1
- package/dist/vega/{p-ec1f2d21.entry.js → p-1071f790.entry.js} +1 -1
- package/dist/vega/{p-45e28b9b.js → p-111d41fe.js} +1 -1
- package/dist/vega/p-12929d20.entry.js +1 -0
- package/dist/vega/{p-72ecfd40.js → p-138fcf6e.js} +1 -1
- package/dist/vega/{p-a01f149d.entry.js → p-151dec6a.entry.js} +1 -1
- package/dist/vega/{p-06adb37e.entry.js → p-1b81fc7a.entry.js} +1 -1
- package/dist/vega/{p-56a0b13d.js → p-1df029c2.js} +1 -1
- package/dist/vega/p-21d26bb4.js +2 -0
- package/dist/vega/p-21d4f12e.entry.js +1 -0
- package/dist/vega/{p-4a32a6c0.entry.js → p-21d5656d.entry.js} +1 -1
- package/dist/vega/{p-a7dcb2a3.js → p-21e180f2.js} +1 -1
- package/dist/vega/{p-0079088b.entry.js → p-2329cb73.entry.js} +1 -1
- package/dist/vega/{p-8c388b58.entry.js → p-29fe94b6.entry.js} +1 -1
- package/dist/vega/p-2f5d9aab.js +1 -0
- package/dist/vega/p-30c363d8.entry.js +9 -0
- package/dist/vega/{p-5e34ea25.entry.js → p-32a24ef1.entry.js} +1 -1
- package/dist/vega/p-33bd7e31.js +1 -0
- package/dist/vega/{p-46714da3.entry.js → p-36827489.entry.js} +1 -1
- package/dist/vega/{p-81fbfb6d.entry.js → p-388abe56.entry.js} +1 -1
- package/dist/vega/p-3b34389d.js +1 -0
- package/dist/vega/p-3eb2d433.js +1 -0
- package/dist/vega/{p-2da83c2a.js → p-3fa7d356.js} +1 -1
- package/dist/vega/p-425ba7d6.js +1 -0
- package/dist/vega/p-447a2b18.entry.js +1 -0
- package/dist/vega/{p-8d283666.js → p-4ab3df00.js} +1 -1
- package/dist/vega/{p-b649e86e.entry.js → p-4bca12ee.entry.js} +1 -1
- package/dist/vega/{p-b2bca332.entry.js → p-5016b57e.entry.js} +1 -1
- package/dist/vega/p-52905c68.entry.js +1 -0
- package/dist/vega/p-52bdeea0.entry.js +1 -0
- package/dist/vega/p-53803447.entry.js +1 -0
- package/dist/vega/{p-54f17c2e.entry.js → p-53815555.entry.js} +1 -1
- package/dist/vega/{p-d7937711.js → p-55563f5f.js} +1 -1
- package/dist/vega/{p-48517a5d.entry.js → p-578ac47f.entry.js} +1 -1
- package/dist/vega/p-586139ce.entry.js +1 -0
- package/dist/vega/p-597732e9.entry.js +1 -0
- package/dist/vega/{p-0969877b.entry.js → p-5c9efff8.entry.js} +1 -1
- package/dist/vega/{p-5e3a15a1.js → p-5e530257.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-60164904.entry.js +1 -0
- package/dist/vega/p-613ee009.js +1 -0
- package/dist/vega/p-61b72038.entry.js +1 -0
- package/dist/vega/p-642da014.entry.js +1 -0
- package/dist/vega/{p-9803042f.entry.js → p-647734d1.entry.js} +1 -1
- package/dist/vega/{p-cd205d96.js → p-65cca90f.js} +1 -1
- package/dist/vega/{p-6586e2a2.entry.js → p-66145767.entry.js} +1 -1
- package/dist/vega/p-6681efd5.js +1 -0
- package/dist/vega/{p-45f696b4.js → p-6b7dca3e.js} +1 -1
- package/dist/vega/{p-5160a6b9.entry.js → p-6ceb2d26.entry.js} +1 -1
- package/dist/vega/{p-6f81fe1e.js → p-6e01f0a2.js} +1 -1
- package/dist/vega/p-6f3dd430.entry.js +1 -0
- package/dist/vega/p-71d897e5.entry.js +1 -0
- package/dist/vega/{p-8ba43640.entry.js → p-72a4edf2.entry.js} +1 -1
- package/dist/vega/{p-bcb10ae3.entry.js → p-7503fe08.entry.js} +1 -1
- package/dist/vega/p-7add21f8.entry.js +1 -0
- package/dist/vega/{p-bfb344e1.entry.js → p-7df1ad72.entry.js} +1 -1
- package/dist/vega/{p-aea89be5.entry.js → p-7e70938a.entry.js} +1 -1
- package/dist/vega/{p-5064a804.js → p-864de9a1.js} +1 -1
- package/dist/vega/{p-10a40dfb.entry.js → p-86713a15.entry.js} +1 -1
- package/dist/vega/p-8a0d7805.entry.js +1 -0
- package/dist/vega/{p-89ab72e3.js → p-8bdc9e75.js} +1 -1
- package/dist/vega/{p-6cabdb36.js → p-8e31e7ea.js} +1 -1
- package/dist/vega/p-901b20d6.entry.js +1 -0
- package/dist/vega/p-90954fe4.entry.js +1 -0
- package/dist/vega/{p-6d7d923b.js → p-9c0cda62.js} +1 -1
- package/dist/vega/p-9d3292b7.entry.js +1 -0
- package/dist/vega/p-9eab97ee.entry.js +1 -0
- package/dist/vega/p-a0bd5bd7.entry.js +1 -0
- package/dist/vega/{p-54add0d2.js → p-a0dab2d0.js} +1 -1
- package/dist/vega/{p-83ef9e7d.entry.js → p-a1fbf49b.entry.js} +1 -1
- package/dist/vega/{p-d0007822.entry.js → p-aab6f547.entry.js} +1 -1
- package/dist/vega/p-b264d92e.entry.js +1 -0
- package/dist/vega/p-b51fa6ac.entry.js +1 -0
- package/dist/vega/p-b7594b78.entry.js +1 -0
- package/dist/vega/{p-6a830bc5.entry.js → p-c192c2d2.entry.js} +1 -1
- package/dist/vega/p-c4447540.entry.js +1 -0
- package/dist/vega/p-c8023434.entry.js +1 -0
- package/dist/vega/p-c91190df.entry.js +1 -0
- package/dist/vega/{p-647025dd.entry.js → p-cada532e.entry.js} +1 -1
- package/dist/vega/p-d0f0a908.entry.js +1 -0
- package/dist/vega/{p-02d7d948.entry.js → p-d53b262c.entry.js} +1 -1
- package/dist/vega/p-d64b20c2.js +1 -0
- package/dist/vega/{p-a5c39ba2.entry.js → p-d9cb6ec4.entry.js} +1 -1
- package/dist/vega/p-e16e23b7.entry.js +1 -0
- package/dist/vega/{p-1971d980.entry.js → p-e37ac14f.entry.js} +1 -1
- package/dist/vega/p-e5f1fd0b.entry.js +1 -0
- package/dist/vega/p-e7b00bf0.js +1 -0
- package/dist/vega/{p-147e3cbd.entry.js → p-e81b672b.entry.js} +1 -1
- package/dist/vega/{p-cfda64fd.entry.js → p-e860318d.entry.js} +1 -1
- package/dist/vega/p-ea723616.entry.js +1 -0
- package/dist/vega/{p-8ade44bf.js → p-eb832119.js} +1 -1
- package/dist/vega/{p-27003a81.entry.js → p-ec7d98f0.entry.js} +1 -1
- package/dist/vega/{p-a821bcf3.js → p-eea36d3c.js} +1 -1
- package/dist/vega/{p-252e42c7.entry.js → p-f0f787a2.entry.js} +1 -1
- package/dist/vega/p-f2f31686.entry.js +1 -0
- package/dist/vega/{p-27e56c67.entry.js → p-f41ae5e0.entry.js} +1 -1
- package/dist/vega/p-f4a13f3f.js +1 -0
- package/dist/vega/p-f9a9fca6.entry.js +1 -0
- package/dist/vega/{p-2fadef27.entry.js → p-fac5990f.entry.js} +1 -1
- package/dist/vega/p-fd0b2509.entry.js +1 -0
- package/dist/vega/p-fecb4044.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +3 -2
- package/dist/vega/p-06c5fe97.entry.js +0 -1
- package/dist/vega/p-0ed7a098.entry.js +0 -1
- package/dist/vega/p-0f6b3a89.entry.js +0 -1
- package/dist/vega/p-136f665b.entry.js +0 -1
- package/dist/vega/p-1503f791.js +0 -1
- package/dist/vega/p-16fd7c32.js +0 -1
- package/dist/vega/p-1a263af1.entry.js +0 -1
- package/dist/vega/p-1af4771a.entry.js +0 -1
- package/dist/vega/p-1c298d5a.js +0 -2
- package/dist/vega/p-1c63afd2.entry.js +0 -1
- package/dist/vega/p-1e05b7b4.entry.js +0 -1
- package/dist/vega/p-1ea863a6.entry.js +0 -1
- package/dist/vega/p-271b30b9.entry.js +0 -1
- package/dist/vega/p-2d1d4f33.entry.js +0 -1
- package/dist/vega/p-353b3ded.entry.js +0 -1
- package/dist/vega/p-44b0a005.js +0 -1
- package/dist/vega/p-47ff95ba.entry.js +0 -1
- package/dist/vega/p-4e76904e.entry.js +0 -1
- package/dist/vega/p-4ec0d36f.entry.js +0 -1
- package/dist/vega/p-5c954088.entry.js +0 -1
- package/dist/vega/p-61eb7f32.entry.js +0 -1
- package/dist/vega/p-646a9198.entry.js +0 -1
- package/dist/vega/p-6e898779.js +0 -1
- package/dist/vega/p-7088ead9.entry.js +0 -1
- package/dist/vega/p-77492977.entry.js +0 -1
- package/dist/vega/p-804f71b3.js +0 -1
- package/dist/vega/p-8789d34d.entry.js +0 -1
- package/dist/vega/p-8813c0ac.entry.js +0 -1
- package/dist/vega/p-8a85c7af.entry.js +0 -1
- package/dist/vega/p-98c64d77.entry.js +0 -1
- package/dist/vega/p-9f3539a4.entry.js +0 -1
- package/dist/vega/p-b42aea55.entry.js +0 -1
- package/dist/vega/p-b5d70ee0.entry.js +0 -1
- package/dist/vega/p-bc2dd43d.js +0 -1
- package/dist/vega/p-bf1894ec.js +0 -1
- package/dist/vega/p-c754b32c.js +0 -1
- package/dist/vega/p-c9a4e79a.entry.js +0 -1
- package/dist/vega/p-dbc82247.js +0 -1
- package/dist/vega/p-e2e36d2b.entry.js +0 -1
- package/dist/vega/p-ef8272b5.entry.js +0 -1
- package/dist/vega/p-f4c1d961.js +0 -1
- package/dist/vega/p-f5279deb.entry.js +0 -1
- package/dist/vega/p-f8033cd3.entry.js +0 -1
- package/dist/vega/p-fe63bd50.entry.js +0 -1
- /package/dist/vega/{p-eda5b7fd.js → p-05b10af4.js} +0 -0
- /package/dist/vega/{p-50677c8e.js → p-0c8bd757.js} +0 -0
- /package/dist/vega/{p-af7a3154.js → p-13effc6b.js} +0 -0
- /package/dist/vega/{p-ecfa7534.js → p-272440e8.js} +0 -0
- /package/dist/vega/{p-9b797118.js → p-519a7d55.js} +0 -0
- /package/dist/vega/{p-c0291e2e.js → p-834434d5.js} +0 -0
- /package/dist/vega/{p-bf953152.js → p-d5776087.js} +0 -0
- /package/dist/vega/{p-0fd6c35b.js → p-fa5eb496.js} +0 -0
|
@@ -2,44 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-7700600c.js');
|
|
6
6
|
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
|
|
7
7
|
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-dcb32c24.js');
|
|
8
|
-
const component = require('./component-
|
|
8
|
+
const component = require('./component-1e352960.js');
|
|
9
9
|
const accessibility = require('./accessibility-bfa227f6.js');
|
|
10
10
|
const changeManager = require('./change-manager-a297e4d2.js');
|
|
11
|
-
const domNodeSubjectFactory = require('./dom-node-subject-factory-
|
|
12
|
-
const vegaInternalEventId = require('./vega-internal-event-id-
|
|
13
|
-
const imageAnnotationAction = require('./image-annotation-action-
|
|
11
|
+
const domNodeSubjectFactory = require('./dom-node-subject-factory-769dd00f.js');
|
|
12
|
+
const vegaInternalEventId = require('./vega-internal-event-id-6cdc95fe.js');
|
|
13
|
+
const imageAnnotationAction = require('./image-annotation-action-617bbb13.js');
|
|
14
14
|
const internalIconManager = require('./internal-icon-manager-00f49470.js');
|
|
15
|
-
const
|
|
16
|
-
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-
|
|
15
|
+
const codeBlock = require('./code-block-2d014e17.js');
|
|
16
|
+
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-5aa4cc83.js');
|
|
17
17
|
const createPublicApiRuntimeMetricsSlimmer = require('./create-public-api-runtime-metrics-slimmer-a3d17afb.js');
|
|
18
|
-
const index$1 = require('./index-
|
|
19
|
-
const formFieldControllerSlimmer = require('./form-field-controller-slimmer-
|
|
20
|
-
const eventEmitSlimmer = require('./event-emit-slimmer-
|
|
21
|
-
const subStateNotifySlimmer = require('./sub-state-notify-slimmer-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const observer = require('./observer-f49483e8.js');
|
|
25
|
-
const ui = require('./ui-13b42af0.js');
|
|
18
|
+
const index$1 = require('./index-ebb1bb17.js');
|
|
19
|
+
const formFieldControllerSlimmer = require('./form-field-controller-slimmer-01c01946.js');
|
|
20
|
+
const eventEmitSlimmer = require('./event-emit-slimmer-36036ef7.js');
|
|
21
|
+
const subStateNotifySlimmer = require('./sub-state-notify-slimmer-f68fbf29.js');
|
|
22
|
+
const contentState = require('./content-state-6a5da7ec.js');
|
|
23
|
+
const selectionController = require('./selection-controller-1d7c0999.js');
|
|
26
24
|
const staticSubjectTitle = require('./static-subject-title-7e7d791a.js');
|
|
25
|
+
const observer = require('./observer-f49483e8.js');
|
|
26
|
+
const timer = require('./timer-5f33058b.js');
|
|
27
27
|
const darkModeStateControllerSlimmer = require('./dark-mode-state-controller-slimmer-add5d8a8.js');
|
|
28
28
|
const typeGuard = require('./type-guard-4ba85fdc.js');
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
29
|
+
const ui = require('./ui-6c069604.js');
|
|
30
|
+
const richTextEditorRequiredRule = require('./rich-text-editor-required-rule-e9c7c379.js');
|
|
31
|
+
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-29020cc8.js');
|
|
32
|
+
const translationSlimmer = require('./translation-slimmer-127a0f83.js');
|
|
33
|
+
const darkModeStyleController = require('./dark-mode-style-controller-f9a32d68.js');
|
|
34
|
+
const keyboardManagerSlimmer = require('./keyboard-manager-slimmer-eb364bee.js');
|
|
34
35
|
const chevronDown = require('./chevron-down-9847bf78.js');
|
|
35
36
|
const trashCan = require('./trash-can-46a5e19a.js');
|
|
36
37
|
const remoteInvocationRegistry = require('./remote-invocation-registry-fc22fdd0.js');
|
|
37
38
|
require('./icon-manager-9a47399c.js');
|
|
38
39
|
require('./dynamic-slimmer-f31fdfd7.js');
|
|
39
|
-
require('./wait-for-vega-handler-
|
|
40
|
+
require('./wait-for-vega-handler-4491efc9.js');
|
|
40
41
|
require('./string-21427167.js');
|
|
41
|
-
require('./translation-
|
|
42
|
-
require('./page-resize-observer-slimmer-
|
|
42
|
+
require('./translation-e5003a00.js');
|
|
43
|
+
require('./page-resize-observer-slimmer-efa79728.js');
|
|
43
44
|
require('./ui-32e69595.js');
|
|
44
45
|
require('./breakpoints-ebde4837.js');
|
|
45
46
|
require('./internal-form-field-validation-rule.abstract-07cdff46.js');
|
|
@@ -47,15 +48,16 @@ require('./mutation-observer-slimmer-895b3d3e.js');
|
|
|
47
48
|
require('./mutation-observer-filters-38cebc6d.js');
|
|
48
49
|
require('./array-249289f2.js');
|
|
49
50
|
require('./number-4816603d.js');
|
|
50
|
-
require('./sub-state-observer-slimmer-
|
|
51
|
-
require('./internal-vega-event-manager-
|
|
51
|
+
require('./sub-state-observer-slimmer-e06cdf7e.js');
|
|
52
|
+
require('./internal-vega-event-manager-e98944ac.js');
|
|
53
|
+
require('./synchronize-task-queue-1ee80e94.js');
|
|
52
54
|
require('./regex-c1f70fd4.js');
|
|
53
55
|
require('./typography-4560e7f1.js');
|
|
54
56
|
require('./vega-env-manager-23b8b23c.js');
|
|
55
57
|
require('./feature-flag-controller-5e58aae4.js');
|
|
56
58
|
require('./index-8b247c17.js');
|
|
57
59
|
require('./_commonjsHelpers-537d719a.js');
|
|
58
|
-
require('./keyboard-manager-
|
|
60
|
+
require('./keyboard-manager-8c74eeb9.js');
|
|
59
61
|
|
|
60
62
|
var __decorate$A = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
61
63
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -217,6 +219,8 @@ class ToolbarRenderer extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
217
219
|
return this.bulletsNumbersToolbarButtonSlimmer;
|
|
218
220
|
case 'horizontalAlignment':
|
|
219
221
|
return this.horizontalAlignmentToolbarButtonSlimmer;
|
|
222
|
+
case 'codeBlock':
|
|
223
|
+
return this.codeBlockToolbarButtonSlimmer;
|
|
220
224
|
}
|
|
221
225
|
};
|
|
222
226
|
}
|
|
@@ -273,6 +277,9 @@ __decorate$z([
|
|
|
273
277
|
__decorate$z([
|
|
274
278
|
globalSlimmerRegistry.MapToComponentField()
|
|
275
279
|
], ToolbarRenderer.prototype, "linkToolbarButtonSlimmer", void 0);
|
|
280
|
+
__decorate$z([
|
|
281
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
282
|
+
], ToolbarRenderer.prototype, "codeBlockToolbarButtonSlimmer", void 0);
|
|
276
283
|
|
|
277
284
|
const bold = {
|
|
278
285
|
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>`,
|
|
@@ -297,23 +304,24 @@ class BoldToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlimme
|
|
|
297
304
|
const bold = this.isSelected();
|
|
298
305
|
this.selectionController
|
|
299
306
|
.getSelectedNodes()
|
|
300
|
-
.filter((node) => node instanceof
|
|
301
|
-
.forEach((node) => node.apply(new
|
|
307
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
308
|
+
.forEach((node) => node.apply(new codeBlock.BoldAnnotationAction(!bold)));
|
|
302
309
|
}
|
|
303
310
|
isSelected() {
|
|
304
311
|
const selectedNodes = this.selectionController
|
|
305
312
|
.getSelectedNodes()
|
|
306
|
-
.filter((node) => node instanceof
|
|
313
|
+
.filter((node) => node instanceof codeBlock.RTETextNode);
|
|
307
314
|
return (selectedNodes.length > 0 &&
|
|
308
|
-
selectedNodes.every((node) => { var _a; return (_a = node.getAnnotationByType(
|
|
315
|
+
selectedNodes.every((node) => { var _a; return (_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.BOLD)) === null || _a === void 0 ? void 0 : _a.bold; }));
|
|
309
316
|
}
|
|
310
317
|
isDisabled() {
|
|
311
318
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
312
319
|
return (super.isDisabled() ||
|
|
313
320
|
selectedNodes.some((node) => {
|
|
314
321
|
var _a;
|
|
315
|
-
return
|
|
316
|
-
node.getAnnotationByType(
|
|
322
|
+
return node instanceof codeBlock.RTECodeBlockNode ||
|
|
323
|
+
((_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
324
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE);
|
|
317
325
|
}));
|
|
318
326
|
}
|
|
319
327
|
}
|
|
@@ -331,7 +339,7 @@ const italic = {
|
|
|
331
339
|
/**
|
|
332
340
|
* Action to toggle the italic annotation
|
|
333
341
|
*/
|
|
334
|
-
class ItalicAnnotationAction extends
|
|
342
|
+
class ItalicAnnotationAction extends codeBlock.TextSplittableAction {
|
|
335
343
|
constructor(italic) {
|
|
336
344
|
super();
|
|
337
345
|
this.isFlushable = true;
|
|
@@ -343,7 +351,7 @@ class ItalicAnnotationAction extends contentState.TextSplittableAction {
|
|
|
343
351
|
* @returns {ItalicAnnotation} The annotation
|
|
344
352
|
*/
|
|
345
353
|
toAnnotation() {
|
|
346
|
-
return new
|
|
354
|
+
return new codeBlock.ItalicAnnotation(this.italic);
|
|
347
355
|
}
|
|
348
356
|
}
|
|
349
357
|
|
|
@@ -363,15 +371,15 @@ class ItalicToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlim
|
|
|
363
371
|
isSelected() {
|
|
364
372
|
const selectedNodes = this.selectionController
|
|
365
373
|
.getSelectedNodes()
|
|
366
|
-
.filter((node) => node instanceof
|
|
374
|
+
.filter((node) => node instanceof codeBlock.RTETextNode);
|
|
367
375
|
return (selectedNodes.length > 0 &&
|
|
368
|
-
selectedNodes.every((node) => { var _a; return (_a = node.getAnnotationByType(
|
|
376
|
+
selectedNodes.every((node) => { var _a; return (_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.ITALIC)) === null || _a === void 0 ? void 0 : _a.italic; }));
|
|
369
377
|
}
|
|
370
378
|
onClick() {
|
|
371
379
|
const italic = this.isSelected();
|
|
372
380
|
this.selectionController
|
|
373
381
|
.getSelectedNodes()
|
|
374
|
-
.filter((node) => node instanceof
|
|
382
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
375
383
|
.forEach((node) => node.apply(new ItalicAnnotationAction(!italic)));
|
|
376
384
|
}
|
|
377
385
|
isDisabled() {
|
|
@@ -379,8 +387,9 @@ class ItalicToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlim
|
|
|
379
387
|
return (super.isDisabled() ||
|
|
380
388
|
selectedNodes.some((node) => {
|
|
381
389
|
var _a;
|
|
382
|
-
return
|
|
383
|
-
node.getAnnotationByType(
|
|
390
|
+
return node instanceof codeBlock.RTECodeBlockNode ||
|
|
391
|
+
((_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
392
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE);
|
|
384
393
|
}));
|
|
385
394
|
}
|
|
386
395
|
}
|
|
@@ -398,7 +407,7 @@ const underline = {
|
|
|
398
407
|
/**
|
|
399
408
|
* Action to toggle the underline annotation
|
|
400
409
|
*/
|
|
401
|
-
class UnderlineAnnotationAction extends
|
|
410
|
+
class UnderlineAnnotationAction extends codeBlock.TextSplittableAction {
|
|
402
411
|
constructor(underline) {
|
|
403
412
|
super();
|
|
404
413
|
this.isFlushable = true;
|
|
@@ -410,7 +419,7 @@ class UnderlineAnnotationAction extends contentState.TextSplittableAction {
|
|
|
410
419
|
* @returns {Annotation} the annotation
|
|
411
420
|
*/
|
|
412
421
|
toAnnotation() {
|
|
413
|
-
return new
|
|
422
|
+
return new codeBlock.UnderlineAnnotation(this.underline);
|
|
414
423
|
}
|
|
415
424
|
}
|
|
416
425
|
|
|
@@ -430,18 +439,18 @@ class UnderlineToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonS
|
|
|
430
439
|
isSelected() {
|
|
431
440
|
const selectedNodes = this.selectionController
|
|
432
441
|
.getSelectedNodes()
|
|
433
|
-
.filter((node) => node instanceof
|
|
442
|
+
.filter((node) => node instanceof codeBlock.RTETextNode);
|
|
434
443
|
return (selectedNodes.length > 0 &&
|
|
435
444
|
selectedNodes.every((node) => {
|
|
436
445
|
var _a;
|
|
437
|
-
return (_a = node.getAnnotationByType(
|
|
446
|
+
return (_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.UNDERLINE)) === null || _a === void 0 ? void 0 : _a.underline;
|
|
438
447
|
}));
|
|
439
448
|
}
|
|
440
449
|
onClick() {
|
|
441
450
|
const selected = this.isSelected();
|
|
442
451
|
this.selectionController
|
|
443
452
|
.getSelectedNodes()
|
|
444
|
-
.filter((node) => node instanceof
|
|
453
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
445
454
|
.forEach((node) => node.apply(new UnderlineAnnotationAction(!selected)));
|
|
446
455
|
}
|
|
447
456
|
isDisabled() {
|
|
@@ -449,8 +458,9 @@ class UnderlineToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonS
|
|
|
449
458
|
return (super.isDisabled() ||
|
|
450
459
|
selectedNodes.some((node) => {
|
|
451
460
|
var _a;
|
|
452
|
-
return
|
|
453
|
-
node.getAnnotationByType(
|
|
461
|
+
return node instanceof codeBlock.RTECodeBlockNode ||
|
|
462
|
+
((_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
463
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE);
|
|
454
464
|
}));
|
|
455
465
|
}
|
|
456
466
|
}
|
|
@@ -482,19 +492,19 @@ class TextStylesToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
482
492
|
const boldByDefault = TextStylesToolbarButtonSlimmer.items.find((item) => item.key === selectedType).bold;
|
|
483
493
|
const selectedTextBlocks = this.selectionController
|
|
484
494
|
.getSelectedBlocks()
|
|
485
|
-
.filter((block) => block instanceof
|
|
495
|
+
.filter((block) => block instanceof codeBlock.RTETextBlock);
|
|
486
496
|
if (selectedTextBlocks.length > 0) {
|
|
487
497
|
selectedTextBlocks.forEach((item) => {
|
|
488
|
-
item.apply(new
|
|
498
|
+
item.apply(new codeBlock.TextStyleAnnotationAction(selectedType, boldByDefault));
|
|
489
499
|
});
|
|
490
500
|
}
|
|
491
501
|
else {
|
|
492
502
|
void this.focusController.focusOnLastTextNode({ newLine: true }).then(() => {
|
|
493
503
|
this.selectionController
|
|
494
504
|
.getSelectedBlocks()
|
|
495
|
-
.filter((node) => node instanceof
|
|
505
|
+
.filter((node) => node instanceof codeBlock.RTETextBlock)
|
|
496
506
|
.forEach((item) => {
|
|
497
|
-
item.apply(new
|
|
507
|
+
item.apply(new codeBlock.TextStyleAnnotationAction(selectedType, boldByDefault));
|
|
498
508
|
});
|
|
499
509
|
});
|
|
500
510
|
}
|
|
@@ -509,8 +519,8 @@ class TextStylesToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
509
519
|
}
|
|
510
520
|
renderDropdownContent() {
|
|
511
521
|
return (index.h(index.Fragment, null, TextStylesToolbarButtonSlimmer.items.map((item) => {
|
|
512
|
-
const textStyleAnnotation = new
|
|
513
|
-
const boldAnnotation = new
|
|
522
|
+
const textStyleAnnotation = new codeBlock.TextStyleAnnotation(item.key);
|
|
523
|
+
const boldAnnotation = new codeBlock.BoldAnnotation(item.bold);
|
|
514
524
|
return (index.h("vega-dropdown-item", { key: item.key, itemKey: item.key },
|
|
515
525
|
index.h("vega-box", { padding: { right: 'size-20' } },
|
|
516
526
|
index.h("div", { style: Object.assign(Object.assign({}, textStyleAnnotation.render()), boldAnnotation.render()) }, this.translationSlimmer.t(item.label)))));
|
|
@@ -522,7 +532,8 @@ class TextStylesToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
522
532
|
isDisabled() {
|
|
523
533
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
524
534
|
return (super.isDisabled() ||
|
|
525
|
-
selectedNodes.some((node) => node.
|
|
535
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTECodeBlockNode ||
|
|
536
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE)));
|
|
526
537
|
}
|
|
527
538
|
addDropdownObserver(dropdownRef) {
|
|
528
539
|
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(dropdownRef, domNodeSubjectFactory.VegaDropdownClick, this.handleDropdownItemClick);
|
|
@@ -530,11 +541,11 @@ class TextStylesToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
530
541
|
getSelectedSourceKey() {
|
|
531
542
|
const currentSelectedBlocks = this.selectionController
|
|
532
543
|
.getSelectedBlocks()
|
|
533
|
-
.filter((block) => block instanceof
|
|
544
|
+
.filter((block) => block instanceof codeBlock.RTETextBlock);
|
|
534
545
|
const isSameType = currentSelectedBlocks.length > 0 &&
|
|
535
546
|
currentSelectedBlocks.every((block) => block.type === currentSelectedBlocks[0].type);
|
|
536
547
|
if (isSameType) {
|
|
537
|
-
const blockAnnotation = currentSelectedBlocks[0].getAnnotationByType(
|
|
548
|
+
const blockAnnotation = currentSelectedBlocks[0].getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.TEXT_STYLE);
|
|
538
549
|
return blockAnnotation.textStyle;
|
|
539
550
|
}
|
|
540
551
|
return '';
|
|
@@ -607,15 +618,16 @@ class ClearStyleToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
607
618
|
onClick() {
|
|
608
619
|
this.selectionController
|
|
609
620
|
.getSelectedNodes()
|
|
610
|
-
.filter((node) => node instanceof
|
|
621
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
611
622
|
.forEach((node) => {
|
|
612
|
-
node.apply(new
|
|
623
|
+
node.apply(new codeBlock.ClearFormattingAnnotationAction());
|
|
613
624
|
});
|
|
614
625
|
}
|
|
615
626
|
isDisabled() {
|
|
616
627
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
617
628
|
return (super.isDisabled() ||
|
|
618
|
-
selectedNodes.some((node) => node.
|
|
629
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTECodeBlockNode ||
|
|
630
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE)));
|
|
619
631
|
}
|
|
620
632
|
}
|
|
621
633
|
(() => {
|
|
@@ -648,22 +660,23 @@ class CodeToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlimme
|
|
|
648
660
|
const selected = this.isSelected();
|
|
649
661
|
this.selectionController
|
|
650
662
|
.getSelectedNodes()
|
|
651
|
-
.filter((node) => node instanceof
|
|
652
|
-
.forEach((node) => node.apply(new
|
|
663
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
664
|
+
.forEach((node) => node.apply(new codeBlock.CodeAnnotationAction(!selected)));
|
|
653
665
|
}
|
|
654
666
|
isSelected() {
|
|
655
667
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
656
668
|
return (selectedNodes.length > 0 &&
|
|
657
669
|
selectedNodes
|
|
658
|
-
.filter((node) => node instanceof
|
|
659
|
-
.map((node) => node.getAnnotationByType(
|
|
670
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
671
|
+
.map((node) => node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.CODE))
|
|
660
672
|
.every((annotation) => annotation && annotation.code));
|
|
661
673
|
}
|
|
662
674
|
isDisabled() {
|
|
663
675
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
664
676
|
return (super.isDisabled() ||
|
|
665
|
-
selectedNodes.some((node) => node.
|
|
666
|
-
node.getAnnotationByType(
|
|
677
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTECodeBlockNode ||
|
|
678
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.LINK) ||
|
|
679
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE)));
|
|
667
680
|
}
|
|
668
681
|
}
|
|
669
682
|
(() => {
|
|
@@ -680,7 +693,7 @@ const strikethrough = {
|
|
|
680
693
|
/**
|
|
681
694
|
* Action to toggle the strikethrough annotation
|
|
682
695
|
*/
|
|
683
|
-
class StrikethroughAnnotationAction extends
|
|
696
|
+
class StrikethroughAnnotationAction extends codeBlock.TextSplittableAction {
|
|
684
697
|
constructor(underline) {
|
|
685
698
|
super();
|
|
686
699
|
this.isFlushable = true;
|
|
@@ -692,7 +705,7 @@ class StrikethroughAnnotationAction extends contentState.TextSplittableAction {
|
|
|
692
705
|
* @returns {Annotation} the annotation
|
|
693
706
|
*/
|
|
694
707
|
toAnnotation() {
|
|
695
|
-
return new
|
|
708
|
+
return new codeBlock.StrikethroughAnnotation(this.strikethrough);
|
|
696
709
|
}
|
|
697
710
|
}
|
|
698
711
|
|
|
@@ -712,18 +725,18 @@ class StrikethroughToolbarButtonSlimmer extends imageAnnotationAction.ToolbarBut
|
|
|
712
725
|
isSelected() {
|
|
713
726
|
const selectedNodes = this.selectionController
|
|
714
727
|
.getSelectedNodes()
|
|
715
|
-
.filter((node) => node instanceof
|
|
728
|
+
.filter((node) => node instanceof codeBlock.RTETextNode);
|
|
716
729
|
return (selectedNodes.length > 0 &&
|
|
717
730
|
selectedNodes.every((node) => {
|
|
718
731
|
var _a;
|
|
719
|
-
return (_a = node.getAnnotationByType(
|
|
732
|
+
return (_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.STRIKETHROUGH)) === null || _a === void 0 ? void 0 : _a.strikethrough;
|
|
720
733
|
}));
|
|
721
734
|
}
|
|
722
735
|
onClick() {
|
|
723
736
|
const selected = this.isSelected();
|
|
724
737
|
this.selectionController
|
|
725
738
|
.getSelectedNodes()
|
|
726
|
-
.filter((node) => node instanceof
|
|
739
|
+
.filter((node) => node instanceof codeBlock.RTETextNode)
|
|
727
740
|
.forEach((node) => node.apply(new StrikethroughAnnotationAction(!selected)));
|
|
728
741
|
}
|
|
729
742
|
isDisabled() {
|
|
@@ -731,8 +744,9 @@ class StrikethroughToolbarButtonSlimmer extends imageAnnotationAction.ToolbarBut
|
|
|
731
744
|
return (super.isDisabled() ||
|
|
732
745
|
selectedNodes.some((node) => {
|
|
733
746
|
var _a;
|
|
734
|
-
return
|
|
735
|
-
node.getAnnotationByType(
|
|
747
|
+
return node instanceof codeBlock.RTECodeBlockNode ||
|
|
748
|
+
((_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code) ||
|
|
749
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.IMAGE);
|
|
736
750
|
}));
|
|
737
751
|
}
|
|
738
752
|
}
|
|
@@ -747,25 +761,6 @@ const link = {
|
|
|
747
761
|
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>`,
|
|
748
762
|
};
|
|
749
763
|
|
|
750
|
-
/**
|
|
751
|
-
* Action to change the selection range
|
|
752
|
-
*/
|
|
753
|
-
class SelectionChangeAction extends contentState.AnnotationAction {
|
|
754
|
-
constructor(range) {
|
|
755
|
-
super();
|
|
756
|
-
this.isFlushable = false;
|
|
757
|
-
this.range = range;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Converts the action to an annotation
|
|
761
|
-
*
|
|
762
|
-
* @returns {SelectionRangeAnnotation} The annotation
|
|
763
|
-
*/
|
|
764
|
-
toAnnotation() {
|
|
765
|
-
return new contentState.SelectionRangeAnnotation(this.range);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
|
|
769
764
|
var __decorate$r = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
770
765
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
771
766
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -787,7 +782,7 @@ class LinkToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlimme
|
|
|
787
782
|
const textChanged = text !== this.currentSelectedText;
|
|
788
783
|
const groupKey = createPublicApiRuntimeMetricsSlimmer.generateUUID();
|
|
789
784
|
this.currentSelectedNodes.forEach((node) => {
|
|
790
|
-
node.apply(new SelectionChangeAction(this.currentRange)).apply(new
|
|
785
|
+
node.apply(new codeBlock.SelectionChangeAction(this.currentRange)).apply(new codeBlock.LinkAnnotationAction({
|
|
791
786
|
link: { href: url, groupKey: groupKey },
|
|
792
787
|
newText: textChanged ? text : undefined,
|
|
793
788
|
needMergeNode: textChanged && this.currentSelectedNodes.length > 1,
|
|
@@ -818,9 +813,9 @@ class LinkToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlimme
|
|
|
818
813
|
selectedBlocks.length > 1 ||
|
|
819
814
|
selectedNodes.some((node) => {
|
|
820
815
|
var _a;
|
|
821
|
-
return !(node instanceof
|
|
822
|
-
node.getAnnotationByType(
|
|
823
|
-
((_a = node.getAnnotationByType(
|
|
816
|
+
return !(node instanceof codeBlock.RTETextNode) ||
|
|
817
|
+
node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.LINK) ||
|
|
818
|
+
((_a = node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code);
|
|
824
819
|
}));
|
|
825
820
|
}
|
|
826
821
|
onClick() {
|
|
@@ -859,7 +854,7 @@ const indent = {
|
|
|
859
854
|
/**
|
|
860
855
|
* Action to toggle block indent annotation
|
|
861
856
|
*/
|
|
862
|
-
class IndentAnnotationAction extends
|
|
857
|
+
class IndentAnnotationAction extends codeBlock.AnnotationAction {
|
|
863
858
|
constructor(indent) {
|
|
864
859
|
super();
|
|
865
860
|
this.isFlushable = true;
|
|
@@ -871,7 +866,7 @@ class IndentAnnotationAction extends contentState.AnnotationAction {
|
|
|
871
866
|
* @returns {Annotation} The annotation
|
|
872
867
|
*/
|
|
873
868
|
toAnnotation() {
|
|
874
|
-
return new
|
|
869
|
+
return new codeBlock.IndentAnnotation(this.indent);
|
|
875
870
|
}
|
|
876
871
|
}
|
|
877
872
|
|
|
@@ -897,13 +892,13 @@ class MoreIndentToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
897
892
|
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
898
893
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
899
894
|
return (super.isDisabled() ||
|
|
900
|
-
selectedBlocks.some((node) => node.type === 'list-item') ||
|
|
901
|
-
selectedNodes.some((node) => node instanceof
|
|
895
|
+
selectedBlocks.some((node) => node.type === 'list-item' || node.type === 'code-block') ||
|
|
896
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTEImageNode));
|
|
902
897
|
}
|
|
903
898
|
onClick() {
|
|
904
899
|
this.selectionController.getSelectedBlocks().forEach((item) => {
|
|
905
900
|
var _a, _b;
|
|
906
|
-
const indent = (_b = (_a = item.getAnnotationByType(
|
|
901
|
+
const indent = (_b = (_a = item.getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.INDENT)) === null || _a === void 0 ? void 0 : _a.indent) !== null && _b !== void 0 ? _b : 0;
|
|
907
902
|
item.apply(new IndentAnnotationAction(indent + 1));
|
|
908
903
|
});
|
|
909
904
|
}
|
|
@@ -941,13 +936,13 @@ class LessIndentToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
941
936
|
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
942
937
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
943
938
|
return (super.isDisabled() ||
|
|
944
|
-
selectedBlocks.some((node) => node.type === 'list-item') ||
|
|
945
|
-
selectedNodes.some((node) => node instanceof
|
|
939
|
+
selectedBlocks.some((node) => node.type === 'list-item' || node.type === 'code-block') ||
|
|
940
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTEImageNode));
|
|
946
941
|
}
|
|
947
942
|
onClick() {
|
|
948
943
|
this.selectionController.getSelectedBlocks().forEach((item) => {
|
|
949
944
|
var _a, _b;
|
|
950
|
-
const indent = (_b = (_a = item.getAnnotationByType(
|
|
945
|
+
const indent = (_b = (_a = item.getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.INDENT)) === null || _a === void 0 ? void 0 : _a.indent) !== null && _b !== void 0 ? _b : 0;
|
|
951
946
|
const newIndent = indent > 1 ? indent - 1 : 0;
|
|
952
947
|
item.apply(new IndentAnnotationAction(newIndent));
|
|
953
948
|
});
|
|
@@ -969,10 +964,10 @@ const image = {
|
|
|
969
964
|
*
|
|
970
965
|
* @example currentImageNode.apply(new ImageUpdateUrlAction(url))
|
|
971
966
|
*/
|
|
972
|
-
class ImageUpdateUrlAction extends
|
|
967
|
+
class ImageUpdateUrlAction extends codeBlock.ModifyContentAction {
|
|
973
968
|
constructor(newUrl) {
|
|
974
969
|
super();
|
|
975
|
-
this.type =
|
|
970
|
+
this.type = codeBlock.ModifyContentActionType.UPDATE_IMAGE_NODE_URL;
|
|
976
971
|
this.url = newUrl;
|
|
977
972
|
}
|
|
978
973
|
}
|
|
@@ -1029,7 +1024,7 @@ class ImageToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlimm
|
|
|
1029
1024
|
isDisabled() {
|
|
1030
1025
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1031
1026
|
return (super.isDisabled() ||
|
|
1032
|
-
selectedNodes.some((node) => node.getAnnotationByType(
|
|
1027
|
+
selectedNodes.some((node) => node.getAnnotationByType(codeBlock.NodeAnnotationTypeEnum.LINK)));
|
|
1033
1028
|
}
|
|
1034
1029
|
}
|
|
1035
1030
|
(() => {
|
|
@@ -1056,10 +1051,10 @@ const ListOL = {
|
|
|
1056
1051
|
/**
|
|
1057
1052
|
* Action to toggle bullet annotation
|
|
1058
1053
|
*/
|
|
1059
|
-
class TransformListAction extends
|
|
1054
|
+
class TransformListAction extends codeBlock.ModifyContentAction {
|
|
1060
1055
|
constructor(listType, selectedBlocks) {
|
|
1061
1056
|
super();
|
|
1062
|
-
this.type =
|
|
1057
|
+
this.type = codeBlock.ModifyContentActionType.TRANSFORM_LIST_BLOCK;
|
|
1063
1058
|
this.isFlushable = true;
|
|
1064
1059
|
this.listType = listType;
|
|
1065
1060
|
this.selectedBlocks = selectedBlocks;
|
|
@@ -1069,10 +1064,10 @@ class TransformListAction extends contentState.ModifyContentAction {
|
|
|
1069
1064
|
/**
|
|
1070
1065
|
* Action to toggle bullet annotation
|
|
1071
1066
|
*/
|
|
1072
|
-
class TransformParagraphAction extends
|
|
1067
|
+
class TransformParagraphAction extends codeBlock.ModifyContentAction {
|
|
1073
1068
|
constructor(selectedBlocks) {
|
|
1074
1069
|
super();
|
|
1075
|
-
this.type =
|
|
1070
|
+
this.type = codeBlock.ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK;
|
|
1076
1071
|
this.isFlushable = true;
|
|
1077
1072
|
this.selectedBlocks = selectedBlocks;
|
|
1078
1073
|
}
|
|
@@ -1108,7 +1103,8 @@ class BulletsToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSli
|
|
|
1108
1103
|
}
|
|
1109
1104
|
isDisabled() {
|
|
1110
1105
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1111
|
-
return super.isDisabled() ||
|
|
1106
|
+
return (super.isDisabled() ||
|
|
1107
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTEImageNode || node instanceof codeBlock.RTECodeBlockNode));
|
|
1112
1108
|
}
|
|
1113
1109
|
isListType(selectedBlocks, type = 'bullet-list') {
|
|
1114
1110
|
return (selectedBlocks.length > 0 &&
|
|
@@ -1171,7 +1167,8 @@ class NumbersToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSli
|
|
|
1171
1167
|
}
|
|
1172
1168
|
isDisabled() {
|
|
1173
1169
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1174
|
-
return super.isDisabled() ||
|
|
1170
|
+
return (super.isDisabled() ||
|
|
1171
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTEImageNode || node instanceof codeBlock.RTECodeBlockNode));
|
|
1175
1172
|
}
|
|
1176
1173
|
isListType(selectedBlocks, type = 'number-list') {
|
|
1177
1174
|
return (selectedBlocks.length > 0 &&
|
|
@@ -1246,7 +1243,8 @@ class BulletsNumbersToolbarButtonSlimmer extends imageAnnotationAction.ToolbarBu
|
|
|
1246
1243
|
}
|
|
1247
1244
|
isDisabled() {
|
|
1248
1245
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1249
|
-
return super.isDisabled() ||
|
|
1246
|
+
return (super.isDisabled() ||
|
|
1247
|
+
selectedNodes.some((node) => node instanceof codeBlock.RTEImageNode || node instanceof codeBlock.RTECodeBlockNode));
|
|
1250
1248
|
}
|
|
1251
1249
|
}
|
|
1252
1250
|
(() => {
|
|
@@ -1271,7 +1269,7 @@ __decorate$l([
|
|
|
1271
1269
|
/**
|
|
1272
1270
|
* Action to toggle block horizontal alignment annotation
|
|
1273
1271
|
*/
|
|
1274
|
-
class HorizontalAlignmentAnnotationAction extends
|
|
1272
|
+
class HorizontalAlignmentAnnotationAction extends codeBlock.AnnotationAction {
|
|
1275
1273
|
constructor(textAlign) {
|
|
1276
1274
|
super();
|
|
1277
1275
|
this.isFlushable = true;
|
|
@@ -1283,7 +1281,7 @@ class HorizontalAlignmentAnnotationAction extends contentState.AnnotationAction
|
|
|
1283
1281
|
* @returns {HorizontalAlignmentAnnotation} The annotation
|
|
1284
1282
|
*/
|
|
1285
1283
|
toAnnotation() {
|
|
1286
|
-
return new
|
|
1284
|
+
return new codeBlock.HorizontalAlignmentAnnotation(this.textAlign);
|
|
1287
1285
|
}
|
|
1288
1286
|
}
|
|
1289
1287
|
|
|
@@ -1311,7 +1309,7 @@ class LeftAlignToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonS
|
|
|
1311
1309
|
return (selectedBlocks.length > 0 &&
|
|
1312
1310
|
selectedBlocks.every((block) => {
|
|
1313
1311
|
var _a;
|
|
1314
|
-
return ((_a = block.getAnnotationByType(
|
|
1312
|
+
return ((_a = block.getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'left';
|
|
1315
1313
|
}));
|
|
1316
1314
|
}
|
|
1317
1315
|
onClick() {
|
|
@@ -1357,7 +1355,7 @@ class CenterAlignToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButto
|
|
|
1357
1355
|
return (selectedBlocks.length > 0 &&
|
|
1358
1356
|
selectedBlocks.every((block) => {
|
|
1359
1357
|
var _a;
|
|
1360
|
-
return ((_a = block.getAnnotationByType(
|
|
1358
|
+
return ((_a = block.getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'center';
|
|
1361
1359
|
}));
|
|
1362
1360
|
}
|
|
1363
1361
|
onClick() {
|
|
@@ -1403,7 +1401,7 @@ class RightAlignToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButton
|
|
|
1403
1401
|
return (selectedBlocks.length > 0 &&
|
|
1404
1402
|
selectedBlocks.every((block) => {
|
|
1405
1403
|
var _a;
|
|
1406
|
-
return ((_a = block.getAnnotationByType(
|
|
1404
|
+
return ((_a = block.getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'right';
|
|
1407
1405
|
}));
|
|
1408
1406
|
}
|
|
1409
1407
|
onClick() {
|
|
@@ -1449,7 +1447,7 @@ class JustifyAlignToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButt
|
|
|
1449
1447
|
return (selectedBlocks.length > 0 &&
|
|
1450
1448
|
selectedBlocks.every((block) => {
|
|
1451
1449
|
var _a;
|
|
1452
|
-
return ((_a = block.getAnnotationByType(
|
|
1450
|
+
return ((_a = block.getAnnotationByType(codeBlock.BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'justify';
|
|
1453
1451
|
}));
|
|
1454
1452
|
}
|
|
1455
1453
|
onClick() {
|
|
@@ -1522,6 +1520,12 @@ class HorizontalAlignmentToolbarButtonSlimmer extends imageAnnotationAction.Tool
|
|
|
1522
1520
|
isSelected() {
|
|
1523
1521
|
return false;
|
|
1524
1522
|
}
|
|
1523
|
+
isDisabled() {
|
|
1524
|
+
return (super.isDisabled() ||
|
|
1525
|
+
this.selectionController
|
|
1526
|
+
.getSelectedBlocks()
|
|
1527
|
+
.some((block) => block.type === 'code-block'));
|
|
1528
|
+
}
|
|
1525
1529
|
}
|
|
1526
1530
|
__decorate$g([
|
|
1527
1531
|
globalSlimmerRegistry.MapToComponentField()
|
|
@@ -1542,951 +1546,256 @@ __decorate$g([
|
|
|
1542
1546
|
globalSlimmerRegistry.MapToComponentMethod('componentWillRender')
|
|
1543
1547
|
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "componentWillRender", null);
|
|
1544
1548
|
|
|
1545
|
-
let processing = false;
|
|
1546
1549
|
/**
|
|
1547
|
-
*
|
|
1548
|
-
* Cypress test case added in https://github.com/heartlandpayments/Vega/pull/1561/files#diff-83bdbaaf47fc156ab878099aa1f21b0e8ab92abe5852521299f1fb6efab001c2R300
|
|
1550
|
+
* Represents the state of the RTE
|
|
1549
1551
|
*/
|
|
1550
|
-
class
|
|
1551
|
-
constructor() {
|
|
1552
|
-
this.
|
|
1553
|
-
this.
|
|
1552
|
+
class RTEEditorState {
|
|
1553
|
+
constructor(content, selection) {
|
|
1554
|
+
this.content = content.clone(true);
|
|
1555
|
+
this.selection = selection.clone();
|
|
1556
|
+
this.refreshSelectionNodes();
|
|
1554
1557
|
}
|
|
1555
1558
|
/**
|
|
1556
|
-
*
|
|
1559
|
+
* Clones the editor state, updating the content and selection based on the provided content.
|
|
1557
1560
|
*
|
|
1558
|
-
* @
|
|
1559
|
-
* @returns {Range} - A Range object.
|
|
1561
|
+
* @returns {RTEEditorState} A new instance of RTEEditorState with the updated content and selection.
|
|
1560
1562
|
*/
|
|
1561
|
-
|
|
1562
|
-
return this.
|
|
1563
|
-
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Adds a Range to ranges array.
|
|
1566
|
-
*
|
|
1567
|
-
* @param {Range} range - The range of selection.
|
|
1568
|
-
*/
|
|
1569
|
-
addRange(range) {
|
|
1570
|
-
this.ranges.push(range);
|
|
1571
|
-
this.rangeCount = this.ranges.length;
|
|
1572
|
-
if (!processing) {
|
|
1573
|
-
const windowSelection = window.getSelection();
|
|
1574
|
-
windowSelection.removeAllRanges();
|
|
1575
|
-
windowSelection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
|
|
1576
|
-
}
|
|
1563
|
+
clone() {
|
|
1564
|
+
return new RTEEditorState(this.content, this.selection);
|
|
1577
1565
|
}
|
|
1578
1566
|
/**
|
|
1579
|
-
*
|
|
1567
|
+
* Refreshes the selection nodes in the editor state.
|
|
1580
1568
|
*/
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1569
|
+
refreshSelectionNodes() {
|
|
1570
|
+
const { startNode: oldStartNode, endNode: oldEndNode, startOffset, endOffset, } = this.selection.range;
|
|
1571
|
+
if (oldStartNode && oldEndNode) {
|
|
1572
|
+
const startNode = this.content.findNodeById(oldStartNode.id);
|
|
1573
|
+
const endNode = this.content.findNodeById(oldEndNode.id);
|
|
1574
|
+
if (startNode && endNode) {
|
|
1575
|
+
this.selection.range.updateRTERange({
|
|
1576
|
+
startNode,
|
|
1577
|
+
endNode,
|
|
1578
|
+
startOffset,
|
|
1579
|
+
endOffset,
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1584
1583
|
}
|
|
1585
1584
|
}
|
|
1585
|
+
|
|
1586
|
+
var __decorate$f = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1587
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1588
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1589
|
+
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;
|
|
1590
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1591
|
+
};
|
|
1586
1592
|
/**
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1589
|
-
* - On Chromium, calling document.getSelection will not pierce into the Shadow DOM and gives you some unhelpful high-level element.
|
|
1590
|
-
* But it does expose the non-standard getSelection method on the ShadowRoot.
|
|
1591
|
-
*
|
|
1592
|
-
* - On Firefox, it does not implement ShadowRoot.getSelection,
|
|
1593
|
-
* but document.getSelection will pierce through shadow dom and give you the exact element.
|
|
1594
|
-
*
|
|
1595
|
-
* - On Safari, Selection.getComposedRanges is supported as of v17. On versions before that,
|
|
1596
|
-
* ShadowRoot.getSelection is not supported and apparently document.getSelection does not pierce the Shadow DOM, meaning you are just out of luck.
|
|
1597
|
-
*
|
|
1598
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot#shadowroot.getselection
|
|
1599
|
-
* https://stackoverflow.com/a/70523247
|
|
1593
|
+
* The value controller is responsible for updating the value of the rich text editor.
|
|
1600
1594
|
*/
|
|
1601
|
-
class
|
|
1602
|
-
constructor() {
|
|
1603
|
-
this.supportShadowSelection = typeof window.ShadowRoot.prototype['getSelection'] === 'function';
|
|
1604
|
-
this.supportBeforeInput = typeof window.InputEvent.prototype.getTargetRanges === 'function';
|
|
1605
|
-
this.isFirefox = window.navigator.userAgent.toLowerCase().indexOf('firefox') > 0;
|
|
1606
|
-
this.listen();
|
|
1607
|
-
}
|
|
1595
|
+
class ValueController extends globalSlimmerRegistry.VegaSlimmer {
|
|
1608
1596
|
/**
|
|
1609
|
-
*
|
|
1610
|
-
* For other browser which not support shadowroot.getSelection, we use this.selection which is built by us.
|
|
1611
|
-
* For browser which supported shadowroot.getSelection, we use shadowRoot.getselection().
|
|
1612
|
-
*
|
|
1613
|
-
* @param {ShadowRoot} shadow - A shadow.
|
|
1614
|
-
* @returns {Nullable<Selection>} - The shadow selection.
|
|
1597
|
+
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.connectedCallback}
|
|
1615
1598
|
*/
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
? this.getFirefoxSelection()
|
|
1623
|
-
: this.polyfilledShadowSelection;
|
|
1624
|
-
}
|
|
1599
|
+
connectedCallback() {
|
|
1600
|
+
const flushChangesWithDebounce = timer.debounce(() => {
|
|
1601
|
+
void this.valueController.flushChanges(this.value);
|
|
1602
|
+
}, ValueController.VALUE_CHANGE_DEBOUNCE_TIME, this);
|
|
1603
|
+
this.flushChangeObserver = new observer.Observer(this.isAcceptableFlushChange.bind(this), flushChangesWithDebounce);
|
|
1604
|
+
changeManager.ChangeManager.register(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges), this.flushChangeObserver);
|
|
1625
1605
|
}
|
|
1626
1606
|
/**
|
|
1627
|
-
*
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
* <span>span1</span><span>span2</span><span>span3</span>
|
|
1632
|
-
*
|
|
1633
|
-
* In firefox, while selected `span2`, the range be likely to:
|
|
1634
|
-
* range:
|
|
1635
|
-
* startContainer: #text 'span1'
|
|
1636
|
-
* startOffset: 5
|
|
1637
|
-
* endContainer: #text 'span3'
|
|
1638
|
-
* endOffset: 0
|
|
1639
|
-
* start is end of brefore node and end is start of after node.
|
|
1640
|
-
*
|
|
1641
|
-
* So we should modify the startContainer and endContainer here.
|
|
1642
|
-
*
|
|
1643
|
-
* modified range:
|
|
1644
|
-
* startContainer: #text 'span2'
|
|
1645
|
-
* startOffset: 0
|
|
1646
|
-
* endContainer: #text 'span2'
|
|
1647
|
-
* endOffset: 5
|
|
1648
|
-
*
|
|
1649
|
-
* @returns {Selection} - document selection
|
|
1650
|
-
*/
|
|
1651
|
-
getFirefoxSelection() {
|
|
1652
|
-
const selection = document.getSelection();
|
|
1653
|
-
const range = selection.getRangeAt(0);
|
|
1654
|
-
const startNode = range.startContainer;
|
|
1655
|
-
const endNode = range.endContainer;
|
|
1656
|
-
if (startNode !== endNode && startNode.textContent.length === range.startOffset) {
|
|
1657
|
-
const nextSibling = startNode.nodeType === Node.TEXT_NODE
|
|
1658
|
-
? startNode.parentNode.nextSibling
|
|
1659
|
-
: startNode.nextSibling;
|
|
1660
|
-
range.setStart(nextSibling.firstChild, 0);
|
|
1661
|
-
}
|
|
1662
|
-
if (endNode !== startNode && range.endOffset === 0) {
|
|
1663
|
-
const previousSibling = endNode.nodeType === Node.TEXT_NODE
|
|
1664
|
-
? endNode.parentNode.previousSibling
|
|
1665
|
-
: endNode.previousSibling;
|
|
1666
|
-
range.setEnd(previousSibling.lastChild, previousSibling.lastChild.textContent.length);
|
|
1667
|
-
}
|
|
1668
|
-
return selection;
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* Sets up event listeners for `selectionchange` and `beforeinput` events to simulate shadow selection.
|
|
1672
|
-
*/
|
|
1673
|
-
listen() {
|
|
1674
|
-
if (this.isFirefox || this.supportShadowSelection || !this.supportBeforeInput)
|
|
1675
|
-
return;
|
|
1676
|
-
this.polyfilledShadowSelection = new ShadowSelection();
|
|
1677
|
-
window.addEventListener('selectionchange', () => {
|
|
1678
|
-
if (!processing) {
|
|
1679
|
-
processing = true;
|
|
1680
|
-
const active = component.getActiveElement();
|
|
1681
|
-
if (active && active.hasAttribute('contenteditable')) {
|
|
1682
|
-
// This command will not actually work, it only trigger the `beforeinput` event,
|
|
1683
|
-
// the `beforeinput` event will prevented this command work.
|
|
1684
|
-
document.execCommand('indent');
|
|
1685
|
-
}
|
|
1686
|
-
else {
|
|
1687
|
-
this.polyfilledShadowSelection.removeAllRanges();
|
|
1688
|
-
}
|
|
1689
|
-
processing = false;
|
|
1690
|
-
}
|
|
1691
|
-
}, true);
|
|
1692
|
-
window.addEventListener('beforeinput', (event) => {
|
|
1693
|
-
if (processing) {
|
|
1694
|
-
const ranges = event.getTargetRanges();
|
|
1695
|
-
const range = ranges[0];
|
|
1696
|
-
const newRange = new Range();
|
|
1697
|
-
newRange.setStart(range.startContainer, range.startOffset);
|
|
1698
|
-
newRange.setEnd(range.endContainer, range.endOffset);
|
|
1699
|
-
this.polyfilledShadowSelection.removeAllRanges();
|
|
1700
|
-
this.polyfilledShadowSelection.addRange(newRange);
|
|
1701
|
-
event.preventDefault();
|
|
1702
|
-
event.stopImmediatePropagation();
|
|
1703
|
-
}
|
|
1704
|
-
}, true);
|
|
1607
|
+
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.disconnectedCallback}
|
|
1608
|
+
*/
|
|
1609
|
+
disconnectedCallback() {
|
|
1610
|
+
changeManager.ChangeManager.unregister(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges), this.flushChangeObserver);
|
|
1705
1611
|
}
|
|
1706
|
-
}
|
|
1707
|
-
const ShadowSelectionPolyfill$1 = new ShadowSelectionPolyfill();
|
|
1708
|
-
|
|
1709
|
-
/** Manages selection range for a rich text editor, providing methods to set, sync, and create native ranges based on RTENodes and Nodes. */
|
|
1710
|
-
class RTERange {
|
|
1711
1612
|
/**
|
|
1712
|
-
*
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
* @param {number} [endOffset] The range end element content offset, default value is 0.
|
|
1718
|
-
* @param {RTENode} [startNode] The range start node, the start node could be null if the start element is root element.
|
|
1719
|
-
* @param {RTENode} [endNode] The range start node, the start node could be null if the start element is root element.
|
|
1720
|
-
* @param {Range} [nativeRange] The browser native range instance.
|
|
1721
|
-
*/
|
|
1722
|
-
constructor(startContainer, endContainer, startOffset = 0, endOffset = 0, startNode, endNode, nativeRange) {
|
|
1723
|
-
this._startOffset = 0;
|
|
1724
|
-
this._endOffset = 0;
|
|
1725
|
-
this._startContainer = startContainer;
|
|
1726
|
-
this._endContainer = endContainer;
|
|
1727
|
-
this._startOffset = startOffset;
|
|
1728
|
-
this._endOffset = endOffset;
|
|
1729
|
-
this._startNode = startNode;
|
|
1730
|
-
this._endNode = endNode;
|
|
1731
|
-
if (nativeRange) {
|
|
1732
|
-
this._oldNativeRange = nativeRange;
|
|
1613
|
+
* Component lifecycle - [componentWillLoad]{@link VegaRichTextEditor.componentWillLoad}
|
|
1614
|
+
*/
|
|
1615
|
+
componentWillLoad() {
|
|
1616
|
+
if (this.value && !(this.value instanceof contentState.VegaRTEContent)) {
|
|
1617
|
+
this.value = contentState.VegaRTEContent.fromJSON(this.value);
|
|
1733
1618
|
}
|
|
1734
1619
|
}
|
|
1735
1620
|
/**
|
|
1736
|
-
*
|
|
1737
|
-
* The start container could be null when the dom node should be create after re-render.
|
|
1738
|
-
*
|
|
1739
|
-
* @returns {Nullable<Node>} The range start element.
|
|
1621
|
+
* Watches the value of the editor and updates the internal value.
|
|
1740
1622
|
*/
|
|
1741
|
-
|
|
1742
|
-
|
|
1623
|
+
watchValueUpdate() {
|
|
1624
|
+
if (this.value && !(this.value instanceof contentState.VegaRTEContent)) {
|
|
1625
|
+
this.value = contentState.VegaRTEContent.fromJSON(this.value);
|
|
1626
|
+
}
|
|
1627
|
+
else if (!this.value || this.value.blocks.length === 0) {
|
|
1628
|
+
this.value = contentState.VegaRTEContent.createEmptyContent();
|
|
1629
|
+
}
|
|
1630
|
+
else {
|
|
1631
|
+
this.changeEventEmitter.emit(this.value);
|
|
1632
|
+
changeManager.ChangeManager.notify(staticSubjectTitle.FORM_ELEMENT_VALUE_CHANGE, {
|
|
1633
|
+
host: this.host,
|
|
1634
|
+
detail: this.value,
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1743
1637
|
}
|
|
1744
1638
|
/**
|
|
1745
|
-
*
|
|
1746
|
-
* The end container could be null when the dom node should be create after re-render.
|
|
1639
|
+
* Updates the value of the editor and restore the selection.
|
|
1747
1640
|
*
|
|
1748
|
-
* @
|
|
1641
|
+
* @param {VegaRTEContent} newValue The new value to set.
|
|
1642
|
+
* @param {boolean} recordHistory - Whether to record the change in history.
|
|
1749
1643
|
*/
|
|
1750
|
-
|
|
1751
|
-
|
|
1644
|
+
async flushChanges(newValue, recordHistory = true) {
|
|
1645
|
+
if (recordHistory) {
|
|
1646
|
+
this.historyController.registerHistory(new RTEEditorState(newValue, new selectionController.RTESelectionState(this.selectionController.getCurrentRange())));
|
|
1647
|
+
}
|
|
1648
|
+
this.value = newValue.clone();
|
|
1649
|
+
await index$1.waitForComponentDidRender(this.host);
|
|
1752
1650
|
}
|
|
1753
1651
|
/**
|
|
1754
|
-
*
|
|
1755
|
-
* The start RTENode could be null when the range start node is the root element of the rich text editor.
|
|
1652
|
+
* Determines whether the observer should accept changes.
|
|
1756
1653
|
*
|
|
1757
|
-
* @returns {
|
|
1654
|
+
* @returns {boolean} Always returns true in the current implementation.
|
|
1758
1655
|
*/
|
|
1759
|
-
|
|
1760
|
-
return
|
|
1656
|
+
isAcceptableFlushChange() {
|
|
1657
|
+
return true;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
ValueController.VALUE_CHANGE_DEBOUNCE_TIME = 50;
|
|
1661
|
+
__decorate$f([
|
|
1662
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
1663
|
+
], ValueController.prototype, "host", void 0);
|
|
1664
|
+
__decorate$f([
|
|
1665
|
+
globalSlimmerRegistry.MapToComponentField({ writable: true })
|
|
1666
|
+
], ValueController.prototype, "value", void 0);
|
|
1667
|
+
__decorate$f([
|
|
1668
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
1669
|
+
], ValueController.prototype, "changeEventEmitter", void 0);
|
|
1670
|
+
__decorate$f([
|
|
1671
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
1672
|
+
], ValueController.prototype, "valueController", void 0);
|
|
1673
|
+
__decorate$f([
|
|
1674
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
1675
|
+
], ValueController.prototype, "historyController", void 0);
|
|
1676
|
+
__decorate$f([
|
|
1677
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
1678
|
+
], ValueController.prototype, "selectionController", void 0);
|
|
1679
|
+
__decorate$f([
|
|
1680
|
+
globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
|
|
1681
|
+
], ValueController.prototype, "connectedCallback", null);
|
|
1682
|
+
__decorate$f([
|
|
1683
|
+
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
1684
|
+
], ValueController.prototype, "disconnectedCallback", null);
|
|
1685
|
+
__decorate$f([
|
|
1686
|
+
globalSlimmerRegistry.MapToComponentMethod('componentWillLoad')
|
|
1687
|
+
], ValueController.prototype, "componentWillLoad", null);
|
|
1688
|
+
__decorate$f([
|
|
1689
|
+
globalSlimmerRegistry.MapToComponentMethod('watchValueUpdate')
|
|
1690
|
+
], ValueController.prototype, "watchValueUpdate", null);
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* The rich text content controller
|
|
1694
|
+
*/
|
|
1695
|
+
class RichTextContentController {
|
|
1696
|
+
constructor(editor) {
|
|
1697
|
+
this.editor = editor;
|
|
1761
1698
|
}
|
|
1762
1699
|
/**
|
|
1763
|
-
*
|
|
1764
|
-
* The end RTENode could be null when the range end node is the root element of the rich text editor.
|
|
1700
|
+
* Sync rich text content editable with disabled property
|
|
1765
1701
|
*
|
|
1766
|
-
* @returns {Nullable<RTENode>} The range start element.
|
|
1767
1702
|
*/
|
|
1768
|
-
|
|
1769
|
-
|
|
1703
|
+
syncRichTextContentEditable() {
|
|
1704
|
+
this.editor.richTextContentEditable = !this.editor.disabled;
|
|
1770
1705
|
}
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
const ROOT_CONTAINER_CLASS_NAME = 'rich-text-content';
|
|
1709
|
+
/** This code snippet is defining an abstract class named `BaseHandler` with an abstract method `execute`. */
|
|
1710
|
+
class BaseHandler {
|
|
1771
1711
|
/**
|
|
1772
|
-
*
|
|
1712
|
+
* The function `execute` initializes the current state and selection, and then handles an event if provided.
|
|
1773
1713
|
*
|
|
1774
|
-
* @
|
|
1714
|
+
* @param {VegaRTEContent} currentState - The current state of the VegaRTE content.
|
|
1715
|
+
* @param {SelectionController} selectionController - Manages the selection of items in the user interface.
|
|
1716
|
+
* @param {HTMLElement} richTextEditor - The current rich text editor component
|
|
1717
|
+
* @param {InputEvent} [event] - It is used to pass an input event to the method for handling.
|
|
1775
1718
|
*/
|
|
1776
|
-
|
|
1777
|
-
|
|
1719
|
+
execute(currentState, selectionController, richTextEditor, event) {
|
|
1720
|
+
this.initCurrentStateAndSelection(currentState, selectionController);
|
|
1721
|
+
this.setCurrentRichTextEditor(richTextEditor);
|
|
1722
|
+
this.handleEvent(event);
|
|
1778
1723
|
}
|
|
1779
1724
|
/**
|
|
1780
|
-
*
|
|
1725
|
+
* The function `isRootContainer` checks if an HTML element is a root container with a class of 'rich-text-content'.
|
|
1781
1726
|
*
|
|
1782
|
-
* @
|
|
1727
|
+
* @param {HTMLElement} element - HTMLElement
|
|
1728
|
+
* @returns {boolean} The boolean value
|
|
1783
1729
|
*/
|
|
1784
|
-
|
|
1785
|
-
return
|
|
1730
|
+
isRootContainer(element) {
|
|
1731
|
+
return (element &&
|
|
1732
|
+
element.nodeType === Node.ELEMENT_NODE &&
|
|
1733
|
+
element.classList.contains(ROOT_CONTAINER_CLASS_NAME));
|
|
1786
1734
|
}
|
|
1787
1735
|
/**
|
|
1788
|
-
*
|
|
1789
|
-
* This method will called after modify the content, the start node and end node should be rte node.
|
|
1790
|
-
* This method will called after selectionchange event emit, the start node and end node should be the html node.
|
|
1736
|
+
* Checks if a given HTML element represents an empty paragraph containing only a line break element.
|
|
1791
1737
|
*
|
|
1792
|
-
* @param {
|
|
1793
|
-
* @
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
const { startOffset, endOffset } = options;
|
|
1798
|
-
this._startOffset = startOffset;
|
|
1799
|
-
this._endOffset = endOffset;
|
|
1800
|
-
const startNode = options.startNode;
|
|
1801
|
-
const endNode = options.endNode;
|
|
1802
|
-
if (startNode instanceof contentState.RTENode) {
|
|
1803
|
-
this._startNode = startNode;
|
|
1804
|
-
this._endNode = endNode;
|
|
1805
|
-
const startContainer = this.getElementByRTENode(this._startNode);
|
|
1806
|
-
const endContainer = this._startNode === this._endNode ? startContainer : this.getElementByRTENode(this._endNode);
|
|
1807
|
-
if (startContainer) {
|
|
1808
|
-
this._startContainer = startContainer;
|
|
1809
|
-
this._endContainer = endContainer;
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
else {
|
|
1813
|
-
// The selectionchange callback has a 50 ms delay, so we need to check the next range is the same as the current ret range.
|
|
1814
|
-
this._startContainer = startNode;
|
|
1815
|
-
this._endContainer = endNode;
|
|
1816
|
-
this._startNode = this.getRTENodeByElement(this._startContainer);
|
|
1817
|
-
this._endNode =
|
|
1818
|
-
this._startContainer === this._endContainer
|
|
1819
|
-
? this._startNode
|
|
1820
|
-
: this.getRTENodeByElement(this._endContainer);
|
|
1821
|
-
if (nativeRange) {
|
|
1822
|
-
this._oldNativeRange = nativeRange;
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
return new RTERange(this._startContainer, this._endContainer, this._startOffset, this._endOffset, this._startNode, this._endNode, this._oldNativeRange);
|
|
1738
|
+
* @param {HTMLElement} node - An HTMLElement node that represents a paragraph element in the HTML document.
|
|
1739
|
+
* @returns {boolean} boolean result
|
|
1740
|
+
*/
|
|
1741
|
+
isEmptyParagraph(node) {
|
|
1742
|
+
return node && node.childNodes && node.childNodes.length === 0;
|
|
1826
1743
|
}
|
|
1827
1744
|
/**
|
|
1828
|
-
*
|
|
1745
|
+
* Removes selected nodes within a range in a rich text editor content.
|
|
1746
|
+
* The method is only used for different nodes are selected
|
|
1829
1747
|
*
|
|
1830
|
-
* @
|
|
1748
|
+
* @param {boolean} [mergeNode] Merge start node and end node or not, default value is false.
|
|
1749
|
+
* @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.
|
|
1831
1750
|
*/
|
|
1832
|
-
|
|
1833
|
-
|
|
1751
|
+
removeSelectionRange(mergeNode = false) {
|
|
1752
|
+
changeManager.ChangeManager.notify(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.richTextEditorRef, vegaInternalEventId.VegaInternalRichTextEditDeleteSelectedNodes), { host: this.richTextEditorRef, detail: mergeNode });
|
|
1753
|
+
const range = this.selectionController.getCurrentRange();
|
|
1754
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
1755
|
+
return range.startNode || selectedNodes[0];
|
|
1834
1756
|
}
|
|
1835
1757
|
/**
|
|
1836
|
-
* Creates a
|
|
1837
|
-
* Invoke this method to get the future range state if the range content modified.
|
|
1838
|
-
* Invoke this method to get the native range instance if range start node and end node not defined
|
|
1758
|
+
* Creates a new paragraph with an empty text node and returns it.
|
|
1839
1759
|
*
|
|
1840
|
-
* @returns {
|
|
1760
|
+
* @returns {RTETextBlock} An empty paragraph with a unique identifier and a text node appended to it.
|
|
1841
1761
|
*/
|
|
1842
|
-
|
|
1843
|
-
const
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
range.setStart(startContainer, this._startOffset);
|
|
1848
|
-
range.setEnd(endContainer, this._endOffset);
|
|
1849
|
-
this._startContainer = startContainer;
|
|
1850
|
-
this._endContainer = endContainer;
|
|
1851
|
-
this._oldNativeRange = range;
|
|
1852
|
-
return range;
|
|
1853
|
-
}
|
|
1854
|
-
else if (this._oldNativeRange) {
|
|
1855
|
-
return this._oldNativeRange;
|
|
1856
|
-
}
|
|
1762
|
+
createEmptyParagraph() {
|
|
1763
|
+
const paragraph = new codeBlock.RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
1764
|
+
const textNode = new codeBlock.RTETextNode(`${paragraph.id}1`, '', paragraph);
|
|
1765
|
+
paragraph.apply(new codeBlock.AppendChildNodesAction([textNode]));
|
|
1766
|
+
return paragraph;
|
|
1857
1767
|
}
|
|
1858
1768
|
/**
|
|
1859
|
-
*
|
|
1769
|
+
* The function initializes the current state and selection controller in TypeScript.
|
|
1860
1770
|
*
|
|
1861
|
-
* @param {
|
|
1862
|
-
* @
|
|
1863
|
-
*/
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
if (element) {
|
|
1868
|
-
return node instanceof contentState.RTEImageNode
|
|
1869
|
-
? ui.findParent(element, 'vega-rich-text-image-editor')
|
|
1870
|
-
: element.firstChild;
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1771
|
+
* @param {VegaRTEContent} currentState - The current state of a Vega runtime environment content.
|
|
1772
|
+
* @param {SelectionController} selectionController - It is used to manage the selection of content within the VegaRTE editor.
|
|
1773
|
+
*/
|
|
1774
|
+
initCurrentStateAndSelection(currentState, selectionController) {
|
|
1775
|
+
this.currentState = currentState;
|
|
1776
|
+
this.selectionController = selectionController;
|
|
1873
1777
|
}
|
|
1874
1778
|
/**
|
|
1875
|
-
*
|
|
1779
|
+
* Queries the rich text editor element from the input event target.
|
|
1876
1780
|
*
|
|
1877
|
-
* @param {
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
if (element) {
|
|
1882
|
-
const registerElement = element.nodeType === Node.TEXT_NODE
|
|
1883
|
-
? element.parentElement
|
|
1884
|
-
: element.nodeName === 'VEGA-RICH-TEXT-IMAGE-EDITOR'
|
|
1885
|
-
? element.querySelector('img')
|
|
1886
|
-
: element;
|
|
1887
|
-
return contentState.stateEntityRenderingRegistry.getEntityByDOM(registerElement);
|
|
1888
|
-
}
|
|
1781
|
+
* @param {HTMLElement} richTextEditor - The current rich text editor component
|
|
1782
|
+
*/
|
|
1783
|
+
setCurrentRichTextEditor(richTextEditor) {
|
|
1784
|
+
this.richTextEditorRef = richTextEditor;
|
|
1889
1785
|
}
|
|
1890
1786
|
}
|
|
1891
1787
|
|
|
1892
1788
|
/**
|
|
1893
|
-
*
|
|
1789
|
+
* Insert a new node before a existing node
|
|
1790
|
+
*
|
|
1791
|
+
* @example currentNode.parentBlock.apply(new InsertNodesBeforeAction(currentNode, newNode, ...))
|
|
1894
1792
|
*/
|
|
1895
|
-
class
|
|
1896
|
-
constructor(
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
*
|
|
1902
|
-
* @returns {RTESelectionState} A new instance of RTESelectionState with the updated range.
|
|
1903
|
-
*/
|
|
1904
|
-
clone() {
|
|
1905
|
-
const newRange = this.range.clone();
|
|
1906
|
-
return new RTESelectionState(newRange);
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
var __decorate$f = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1911
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1912
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1913
|
-
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;
|
|
1914
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1915
|
-
};
|
|
1916
|
-
/**
|
|
1917
|
-
* The text selection controller
|
|
1918
|
-
*/
|
|
1919
|
-
class SelectionController extends globalSlimmerRegistry.VegaSlimmer {
|
|
1920
|
-
constructor() {
|
|
1921
|
-
super(...arguments);
|
|
1922
|
-
this.currentRange = new RTERange();
|
|
1923
|
-
this.updateCaretPositionTaskQueue = new synchronizeTaskQueue.SynchronizeTaskQueue(1);
|
|
1924
|
-
this.handleSelectionWithDebounce = timer.debounce(this.handleSelectionChange, SelectionController.SELECTION_CHANGE_DEBOUNCE_TIME, this);
|
|
1925
|
-
this.pendingRestoreSelectionNodes = [];
|
|
1926
|
-
/**
|
|
1927
|
-
* Sets the next selection state with specified start and end nodes, offsets, and a timestamp.
|
|
1928
|
-
*
|
|
1929
|
-
* Example:
|
|
1930
|
-
* Before insert text start offset is 0, the new start offset should update to 1
|
|
1931
|
-
* Before delete text start offset is 1, the new start offset should update to 0
|
|
1932
|
-
*
|
|
1933
|
-
*/
|
|
1934
|
-
this.createUpdateSelectionRangeTask = async () => {
|
|
1935
|
-
// add await Promise.resolve to put the code behind to a micro task
|
|
1936
|
-
await Promise.resolve();
|
|
1937
|
-
const range = this.currentRange.toNativeRange();
|
|
1938
|
-
if (range) {
|
|
1939
|
-
this.setSelectionRange(range);
|
|
1940
|
-
}
|
|
1941
|
-
};
|
|
1942
|
-
}
|
|
1943
|
-
/**
|
|
1944
|
-
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.connectedCallback}
|
|
1945
|
-
*/
|
|
1946
|
-
connectedCallback() {
|
|
1947
|
-
this.registerSelectionRangeChangeObserver();
|
|
1948
|
-
}
|
|
1949
|
-
/**
|
|
1950
|
-
* Component lifecycle - [disconnectedCallback]{@link VegaRichTextEditor.disconnectedCallback}
|
|
1951
|
-
*/
|
|
1952
|
-
disconnectedCallback() {
|
|
1953
|
-
changeManager.ChangeManager.unregister(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalRichTextEditorSelectionRangeChange), this.selectionRangeChangeObserver);
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* Component lifecycle - [componentDidLoad]{@link VegaRichTextEditor.componentDidLoad}
|
|
1957
|
-
*/
|
|
1958
|
-
componentDidLoad() {
|
|
1959
|
-
document.addEventListener('selectionchange', this.handleSelectionWithDebounce);
|
|
1960
|
-
}
|
|
1961
|
-
/**
|
|
1962
|
-
* Watches the internal value of the editor
|
|
1963
|
-
*/
|
|
1964
|
-
watchValueUpdate() {
|
|
1965
|
-
this.prepareRestoreSelectionState();
|
|
1966
|
-
this.restoreSelection();
|
|
1967
|
-
}
|
|
1968
|
-
/**
|
|
1969
|
-
* Update the caret position after the component re-render
|
|
1970
|
-
*/
|
|
1971
|
-
async updateCaretPosition() {
|
|
1972
|
-
if (this.updateCaretPositionTaskQueue.queue.length) {
|
|
1973
|
-
await this.updateCaretPositionTaskQueue.runTask();
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
/**
|
|
1977
|
-
* Get the current RTE selection range
|
|
1978
|
-
*
|
|
1979
|
-
* @returns {RTERange} - The current RTE selection range
|
|
1980
|
-
*/
|
|
1981
|
-
getCurrentRange() {
|
|
1982
|
-
return this.currentRange;
|
|
1983
|
-
}
|
|
1984
|
-
/**
|
|
1985
|
-
* Get the selected rich text node
|
|
1986
|
-
*
|
|
1987
|
-
* @returns {RTENode[]} Selected rich text nodes
|
|
1988
|
-
*/
|
|
1989
|
-
getSelectedNodes() {
|
|
1990
|
-
return Array.from(this.selectionMap.values()).flat();
|
|
1991
|
-
}
|
|
1992
|
-
/**
|
|
1993
|
-
* Get the selected rich text blocks
|
|
1994
|
-
*
|
|
1995
|
-
* @returns {RTEBlock[]} Selected rich text blocks
|
|
1996
|
-
*/
|
|
1997
|
-
getSelectedBlocks() {
|
|
1998
|
-
return Array.from(this.selectionMap.keys());
|
|
1999
|
-
}
|
|
2000
|
-
/**
|
|
2001
|
-
* Set the selection state
|
|
2002
|
-
*
|
|
2003
|
-
* @param {RTESelectionState} state - The selection state to set
|
|
2004
|
-
*/
|
|
2005
|
-
setSelectionState(state) {
|
|
2006
|
-
this.selectionState = state;
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Sets the next selection state with specified start and end nodes, offsets, push the update task to a queue
|
|
2010
|
-
*
|
|
2011
|
-
* @param {SelectionStateType['startNode']} startNode - The starting node of the selection range. It is a Node object representing the node where the selection range starts.
|
|
2012
|
-
* @param {number} startOffset - The `startNode` where the selection range should start. It indicates the position within the `startNode` where the selection should begin.
|
|
2013
|
-
* @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.
|
|
2014
|
-
* @param {number} [endOffset] - The ending offset within the `endNode` where the selection range should end.
|
|
2015
|
-
* @param {boolean} [immediatelyRun] - Should the task run immediately. default is false
|
|
2016
|
-
*/
|
|
2017
|
-
enqueueSelectionRangeFutureState(startNode, startOffset, endNode, endOffset, immediatelyRun = false) {
|
|
2018
|
-
endNode = endNode || startNode;
|
|
2019
|
-
endOffset = endOffset || endOffset === 0 ? endOffset : startOffset;
|
|
2020
|
-
this.currentRange = this.currentRange.updateRTERange({ startNode, endNode, startOffset, endOffset });
|
|
2021
|
-
void this.updateCaretPositionTaskQueue.enqueue({
|
|
2022
|
-
/** Add task to the queue and run it until component did render */
|
|
2023
|
-
run: async () => {
|
|
2024
|
-
try {
|
|
2025
|
-
await this.createUpdateSelectionRangeTask();
|
|
2026
|
-
}
|
|
2027
|
-
catch (e) {
|
|
2028
|
-
globalSlimmerRegistry.LogUtility.error('Set range error.', e);
|
|
2029
|
-
}
|
|
2030
|
-
},
|
|
2031
|
-
}, immediatelyRun);
|
|
2032
|
-
}
|
|
2033
|
-
/**
|
|
2034
|
-
* Set selection with a new range
|
|
2035
|
-
*
|
|
2036
|
-
* @param {Range} range - The range to set
|
|
2037
|
-
*/
|
|
2038
|
-
setSelectionRange(range) {
|
|
2039
|
-
const selection = this.getSelection();
|
|
2040
|
-
if (selection) {
|
|
2041
|
-
selection.removeAllRanges();
|
|
2042
|
-
selection.addRange(range);
|
|
2043
|
-
this.saveSelection();
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
/**
|
|
2047
|
-
* Save the current selection range detail
|
|
2048
|
-
*/
|
|
2049
|
-
saveSelection() {
|
|
2050
|
-
const selection = this.getSelection();
|
|
2051
|
-
// The range is out of date if the queue is not empty, or the range is update by the composition text insert, so we should not update the RTERange
|
|
2052
|
-
if (selection &&
|
|
2053
|
-
selection.rangeCount > 0 &&
|
|
2054
|
-
this.updateCaretPositionTaskQueue.queue.length === 0 &&
|
|
2055
|
-
!this.insertCompositionTextController.isComposing()) {
|
|
2056
|
-
const range = selection.getRangeAt(0);
|
|
2057
|
-
const { startContainer: startNode, endContainer: endNode, startOffset, endOffset } = range;
|
|
2058
|
-
this.currentRange = this.currentRange.updateRTERange({ startNode, endNode, startOffset, endOffset }, range);
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
/**
|
|
2062
|
-
* Restore the selection to the current selected nodes
|
|
2063
|
-
*/
|
|
2064
|
-
restoreSelection() {
|
|
2065
|
-
if (this.selectionState) {
|
|
2066
|
-
const { startNode, endNode, startOffset, endOffset } = this.selectionState.range;
|
|
2067
|
-
if (startNode instanceof contentState.RTETextNode && startNode === endNode && startNode.text.length === 0) {
|
|
2068
|
-
this.enqueueSelectionRangeFutureState(startNode, contentState.ZERO_WIDTH_SPACE.length);
|
|
2069
|
-
}
|
|
2070
|
-
else {
|
|
2071
|
-
this.enqueueSelectionRangeFutureState(startNode, startOffset, endNode, endOffset);
|
|
2072
|
-
}
|
|
2073
|
-
this.selectionState = null;
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
/**
|
|
2077
|
-
* Get the rich text content selected range
|
|
2078
|
-
*
|
|
2079
|
-
* @returns {Selection} A [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) object
|
|
2080
|
-
*/
|
|
2081
|
-
getSelection() {
|
|
2082
|
-
const richTextContentRef = this.vegaRichTextEditorRenderer.getRichTextContentRef();
|
|
2083
|
-
return ShadowSelectionPolyfill$1.getSelection(richTextContentRef.shadowRoot);
|
|
2084
|
-
}
|
|
2085
|
-
/**
|
|
2086
|
-
* Get selected rich text
|
|
2087
|
-
*/
|
|
2088
|
-
handleSelectionChange() {
|
|
2089
|
-
if (this.disabled)
|
|
2090
|
-
return;
|
|
2091
|
-
const selection = this.getSelection();
|
|
2092
|
-
if (!selection || selection.rangeCount === 0)
|
|
2093
|
-
return;
|
|
2094
|
-
this.clearSelectionMap();
|
|
2095
|
-
this.saveSelection();
|
|
2096
|
-
const range = selection.getRangeAt(0);
|
|
2097
|
-
const commonAncestor = range.commonAncestorContainer;
|
|
2098
|
-
const selectedNodes = [];
|
|
2099
|
-
/**
|
|
2100
|
-
* Rich text node filter
|
|
2101
|
-
*
|
|
2102
|
-
* @param {Node} node - Start node
|
|
2103
|
-
*/
|
|
2104
|
-
const filterNode = (node) => {
|
|
2105
|
-
if (!range.intersectsNode(node)) {
|
|
2106
|
-
return;
|
|
2107
|
-
}
|
|
2108
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
2109
|
-
const currentNode = node.parentElement;
|
|
2110
|
-
const nodeEntity = contentState.stateEntityRenderingRegistry.getEntityByDOM(currentNode);
|
|
2111
|
-
if (nodeEntity instanceof contentState.RTENode) {
|
|
2112
|
-
selectedNodes.push(nodeEntity);
|
|
2113
|
-
return;
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2117
|
-
const entityElement = node.nodeName === 'VEGA-RICH-TEXT-IMAGE-EDITOR'
|
|
2118
|
-
? node.querySelector('img')
|
|
2119
|
-
: node;
|
|
2120
|
-
const nodeEntity = contentState.stateEntityRenderingRegistry.getEntityByDOM(entityElement);
|
|
2121
|
-
if (nodeEntity instanceof contentState.RTENode) {
|
|
2122
|
-
selectedNodes.push(nodeEntity);
|
|
2123
|
-
return;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
node.childNodes.forEach(filterNode);
|
|
2127
|
-
};
|
|
2128
|
-
filterNode(commonAncestor);
|
|
2129
|
-
selectedNodes.forEach((node) => {
|
|
2130
|
-
if (this.selectionMap.has(node.parentBlock)) {
|
|
2131
|
-
this.selectionMap.get(node.parentBlock).push(node);
|
|
2132
|
-
}
|
|
2133
|
-
else {
|
|
2134
|
-
this.selectionMap.set(node.parentBlock, [node]);
|
|
2135
|
-
}
|
|
2136
|
-
});
|
|
2137
|
-
this.getSelectedNodes().forEach((node) => node.apply(new SelectionChangeAction(range)));
|
|
2138
|
-
}
|
|
2139
|
-
/**
|
|
2140
|
-
* Clear the selection map
|
|
2141
|
-
*/
|
|
2142
|
-
clearSelectionMap() {
|
|
2143
|
-
this.getSelectedNodes().forEach((node) => {
|
|
2144
|
-
node.annotationMap.delete(contentState.InternalAnnotationTypeEnum.SELECTION_RANGE);
|
|
2145
|
-
});
|
|
2146
|
-
this.selectionMap = new Map();
|
|
2147
|
-
}
|
|
2148
|
-
/**
|
|
2149
|
-
* Check if the selection range change is acceptable
|
|
2150
|
-
*
|
|
2151
|
-
* @returns {boolean} - Returns a boolean value.
|
|
2152
|
-
*/
|
|
2153
|
-
isAcceptableSelectionRangeChange() {
|
|
2154
|
-
return true;
|
|
2155
|
-
}
|
|
2156
|
-
/**
|
|
2157
|
-
* Register the selection range change observer
|
|
2158
|
-
*/
|
|
2159
|
-
registerSelectionRangeChangeObserver() {
|
|
2160
|
-
this.selectionRangeChangeObserver = new observer.Observer(this.isAcceptableSelectionRangeChange.bind(this), (payload) => {
|
|
2161
|
-
this.pendingRestoreSelectionNodes.push(payload.node);
|
|
2162
|
-
});
|
|
2163
|
-
changeManager.ChangeManager.register(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalRichTextEditorSelectionRangeChange), this.selectionRangeChangeObserver);
|
|
2164
|
-
}
|
|
2165
|
-
/**
|
|
2166
|
-
* Prepare the selection state to restore
|
|
2167
|
-
*/
|
|
2168
|
-
prepareRestoreSelectionState() {
|
|
2169
|
-
if (this.pendingRestoreSelectionNodes.length > 0) {
|
|
2170
|
-
const startNode = this.pendingRestoreSelectionNodes[0];
|
|
2171
|
-
const endNode = this.pendingRestoreSelectionNodes.length > 1
|
|
2172
|
-
? this.pendingRestoreSelectionNodes[this.pendingRestoreSelectionNodes.length - 1]
|
|
2173
|
-
: startNode;
|
|
2174
|
-
const { startOffset, endOffset, endContainer, startContainer } = this.currentRange;
|
|
2175
|
-
const nodesInCurrentRange = contentState.stateEntityRenderingRegistry.getDOMByEntity(startNode) === startContainer.parentElement &&
|
|
2176
|
-
contentState.stateEntityRenderingRegistry.getDOMByEntity(endNode) === endContainer.parentElement;
|
|
2177
|
-
if (nodesInCurrentRange) {
|
|
2178
|
-
this.currentRange = this.currentRange.updateRTERange({
|
|
2179
|
-
startNode,
|
|
2180
|
-
endNode,
|
|
2181
|
-
startOffset,
|
|
2182
|
-
endOffset,
|
|
2183
|
-
});
|
|
2184
|
-
this.selectionState = new RTESelectionState(this.currentRange);
|
|
2185
|
-
}
|
|
2186
|
-
else {
|
|
2187
|
-
this.currentRange = this.currentRange.updateRTERange({
|
|
2188
|
-
startNode,
|
|
2189
|
-
endNode,
|
|
2190
|
-
startOffset: 0,
|
|
2191
|
-
endOffset: endNode.text.length,
|
|
2192
|
-
});
|
|
2193
|
-
this.selectionState = new RTESelectionState(this.currentRange);
|
|
2194
|
-
}
|
|
2195
|
-
this.pendingRestoreSelectionNodes = [];
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
|
-
SelectionController.SELECTION_CHANGE_DEBOUNCE_TIME = 50;
|
|
2200
|
-
__decorate$f([
|
|
2201
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2202
|
-
], SelectionController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
2203
|
-
__decorate$f([
|
|
2204
|
-
globalSlimmerRegistry.MapToComponentField({ writable: true })
|
|
2205
|
-
], SelectionController.prototype, "selectionMap", void 0);
|
|
2206
|
-
__decorate$f([
|
|
2207
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2208
|
-
], SelectionController.prototype, "host", void 0);
|
|
2209
|
-
__decorate$f([
|
|
2210
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2211
|
-
], SelectionController.prototype, "value", void 0);
|
|
2212
|
-
__decorate$f([
|
|
2213
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2214
|
-
], SelectionController.prototype, "disabled", void 0);
|
|
2215
|
-
__decorate$f([
|
|
2216
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2217
|
-
], SelectionController.prototype, "valueController", void 0);
|
|
2218
|
-
__decorate$f([
|
|
2219
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2220
|
-
], SelectionController.prototype, "insertCompositionTextController", void 0);
|
|
2221
|
-
__decorate$f([
|
|
2222
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2223
|
-
], SelectionController.prototype, "historyController", void 0);
|
|
2224
|
-
__decorate$f([
|
|
2225
|
-
globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
|
|
2226
|
-
], SelectionController.prototype, "connectedCallback", null);
|
|
2227
|
-
__decorate$f([
|
|
2228
|
-
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
2229
|
-
], SelectionController.prototype, "disconnectedCallback", null);
|
|
2230
|
-
__decorate$f([
|
|
2231
|
-
globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
|
|
2232
|
-
], SelectionController.prototype, "componentDidLoad", null);
|
|
2233
|
-
__decorate$f([
|
|
2234
|
-
globalSlimmerRegistry.MapToComponentMethod('watchValueUpdate')
|
|
2235
|
-
], SelectionController.prototype, "watchValueUpdate", null);
|
|
2236
|
-
__decorate$f([
|
|
2237
|
-
globalSlimmerRegistry.MapToComponentMethod('componentDidUpdate')
|
|
2238
|
-
], SelectionController.prototype, "updateCaretPosition", null);
|
|
2239
|
-
|
|
2240
|
-
/**
|
|
2241
|
-
* Represents the state of the RTE
|
|
2242
|
-
*/
|
|
2243
|
-
class RTEEditorState {
|
|
2244
|
-
constructor(content, selection) {
|
|
2245
|
-
this.content = content.clone(true);
|
|
2246
|
-
this.selection = selection.clone();
|
|
2247
|
-
this.refreshSelectionNodes();
|
|
2248
|
-
}
|
|
2249
|
-
/**
|
|
2250
|
-
* Clones the editor state, updating the content and selection based on the provided content.
|
|
2251
|
-
*
|
|
2252
|
-
* @returns {RTEEditorState} A new instance of RTEEditorState with the updated content and selection.
|
|
2253
|
-
*/
|
|
2254
|
-
clone() {
|
|
2255
|
-
return new RTEEditorState(this.content, this.selection);
|
|
2256
|
-
}
|
|
2257
|
-
/**
|
|
2258
|
-
* Refreshes the selection nodes in the editor state.
|
|
2259
|
-
*/
|
|
2260
|
-
refreshSelectionNodes() {
|
|
2261
|
-
const { startNode: oldStartNode, endNode: oldEndNode, startOffset, endOffset, } = this.selection.range;
|
|
2262
|
-
if (oldStartNode && oldEndNode) {
|
|
2263
|
-
const startNode = this.content.findNodeById(oldStartNode.id);
|
|
2264
|
-
const endNode = this.content.findNodeById(oldEndNode.id);
|
|
2265
|
-
if (startNode && endNode) {
|
|
2266
|
-
this.selection.range.updateRTERange({
|
|
2267
|
-
startNode,
|
|
2268
|
-
endNode,
|
|
2269
|
-
startOffset,
|
|
2270
|
-
endOffset,
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
var __decorate$e = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2278
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2279
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2280
|
-
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;
|
|
2281
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2282
|
-
};
|
|
2283
|
-
/**
|
|
2284
|
-
* The value controller is responsible for updating the value of the rich text editor.
|
|
2285
|
-
*/
|
|
2286
|
-
class ValueController extends globalSlimmerRegistry.VegaSlimmer {
|
|
2287
|
-
/**
|
|
2288
|
-
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.connectedCallback}
|
|
2289
|
-
*/
|
|
2290
|
-
connectedCallback() {
|
|
2291
|
-
const flushChangesWithDebounce = timer.debounce(() => {
|
|
2292
|
-
void this.valueController.flushChanges(this.value);
|
|
2293
|
-
}, ValueController.VALUE_CHANGE_DEBOUNCE_TIME, this);
|
|
2294
|
-
this.flushChangeObserver = new observer.Observer(this.isAcceptableFlushChange.bind(this), flushChangesWithDebounce);
|
|
2295
|
-
changeManager.ChangeManager.register(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges), this.flushChangeObserver);
|
|
2296
|
-
}
|
|
2297
|
-
/**
|
|
2298
|
-
* Component lifecycle - [connectedCallback]{@link VegaRichTextEditor.disconnectedCallback}
|
|
2299
|
-
*/
|
|
2300
|
-
disconnectedCallback() {
|
|
2301
|
-
changeManager.ChangeManager.unregister(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.host, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges), this.flushChangeObserver);
|
|
2302
|
-
}
|
|
2303
|
-
/**
|
|
2304
|
-
* Component lifecycle - [componentWillLoad]{@link VegaRichTextEditor.componentWillLoad}
|
|
2305
|
-
*/
|
|
2306
|
-
componentWillLoad() {
|
|
2307
|
-
if (this.value && !(this.value instanceof contentState.VegaRTEContent)) {
|
|
2308
|
-
this.value = contentState.VegaRTEContent.fromJSON(this.value);
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
/**
|
|
2312
|
-
* Watches the value of the editor and updates the internal value.
|
|
2313
|
-
*/
|
|
2314
|
-
watchValueUpdate() {
|
|
2315
|
-
if (this.value && !(this.value instanceof contentState.VegaRTEContent)) {
|
|
2316
|
-
this.value = contentState.VegaRTEContent.fromJSON(this.value);
|
|
2317
|
-
}
|
|
2318
|
-
else if (!this.value || this.value.blocks.length === 0) {
|
|
2319
|
-
this.value = contentState.VegaRTEContent.createEmptyContent();
|
|
2320
|
-
}
|
|
2321
|
-
else {
|
|
2322
|
-
this.changeEventEmitter.emit(this.value);
|
|
2323
|
-
changeManager.ChangeManager.notify(staticSubjectTitle.FORM_ELEMENT_VALUE_CHANGE, {
|
|
2324
|
-
host: this.host,
|
|
2325
|
-
detail: this.value,
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
/**
|
|
2330
|
-
* Updates the value of the editor and restore the selection.
|
|
2331
|
-
*
|
|
2332
|
-
* @param {VegaRTEContent} newValue The new value to set.
|
|
2333
|
-
* @param {boolean} recordHistory - Whether to record the change in history.
|
|
2334
|
-
*/
|
|
2335
|
-
async flushChanges(newValue, recordHistory = true) {
|
|
2336
|
-
if (recordHistory) {
|
|
2337
|
-
this.historyController.registerHistory(new RTEEditorState(newValue, new RTESelectionState(this.selectionController.getCurrentRange())));
|
|
2338
|
-
}
|
|
2339
|
-
this.value = newValue.clone();
|
|
2340
|
-
await index$1.waitForComponentDidRender(this.host);
|
|
2341
|
-
}
|
|
2342
|
-
/**
|
|
2343
|
-
* Determines whether the observer should accept changes.
|
|
2344
|
-
*
|
|
2345
|
-
* @returns {boolean} Always returns true in the current implementation.
|
|
2346
|
-
*/
|
|
2347
|
-
isAcceptableFlushChange() {
|
|
2348
|
-
return true;
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
ValueController.VALUE_CHANGE_DEBOUNCE_TIME = 50;
|
|
2352
|
-
__decorate$e([
|
|
2353
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2354
|
-
], ValueController.prototype, "host", void 0);
|
|
2355
|
-
__decorate$e([
|
|
2356
|
-
globalSlimmerRegistry.MapToComponentField({ writable: true })
|
|
2357
|
-
], ValueController.prototype, "value", void 0);
|
|
2358
|
-
__decorate$e([
|
|
2359
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2360
|
-
], ValueController.prototype, "changeEventEmitter", void 0);
|
|
2361
|
-
__decorate$e([
|
|
2362
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2363
|
-
], ValueController.prototype, "valueController", void 0);
|
|
2364
|
-
__decorate$e([
|
|
2365
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2366
|
-
], ValueController.prototype, "historyController", void 0);
|
|
2367
|
-
__decorate$e([
|
|
2368
|
-
globalSlimmerRegistry.MapToComponentField()
|
|
2369
|
-
], ValueController.prototype, "selectionController", void 0);
|
|
2370
|
-
__decorate$e([
|
|
2371
|
-
globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
|
|
2372
|
-
], ValueController.prototype, "connectedCallback", null);
|
|
2373
|
-
__decorate$e([
|
|
2374
|
-
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
2375
|
-
], ValueController.prototype, "disconnectedCallback", null);
|
|
2376
|
-
__decorate$e([
|
|
2377
|
-
globalSlimmerRegistry.MapToComponentMethod('componentWillLoad')
|
|
2378
|
-
], ValueController.prototype, "componentWillLoad", null);
|
|
2379
|
-
__decorate$e([
|
|
2380
|
-
globalSlimmerRegistry.MapToComponentMethod('watchValueUpdate')
|
|
2381
|
-
], ValueController.prototype, "watchValueUpdate", null);
|
|
2382
|
-
|
|
2383
|
-
/**
|
|
2384
|
-
* The rich text content controller
|
|
2385
|
-
*/
|
|
2386
|
-
class RichTextContentController {
|
|
2387
|
-
constructor(editor) {
|
|
2388
|
-
this.editor = editor;
|
|
2389
|
-
}
|
|
2390
|
-
/**
|
|
2391
|
-
* Sync rich text content editable with disabled property
|
|
2392
|
-
*
|
|
2393
|
-
*/
|
|
2394
|
-
syncRichTextContentEditable() {
|
|
2395
|
-
this.editor.richTextContentEditable = !this.editor.disabled;
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
const ROOT_CONTAINER_CLASS_NAME = 'rich-text-content';
|
|
2400
|
-
/** This code snippet is defining an abstract class named `BaseHandler` with an abstract method `execute`. */
|
|
2401
|
-
class BaseHandler {
|
|
2402
|
-
/**
|
|
2403
|
-
* The function `execute` initializes the current state and selection, and then handles an event if provided.
|
|
2404
|
-
*
|
|
2405
|
-
* @param {VegaRTEContent} currentState - The current state of the VegaRTE content.
|
|
2406
|
-
* @param {SelectionController} selectionController - Manages the selection of items in the user interface.
|
|
2407
|
-
* @param {HTMLElement} richTextEditor - The current rich text editor component
|
|
2408
|
-
* @param {InputEvent} [event] - It is used to pass an input event to the method for handling.
|
|
2409
|
-
*/
|
|
2410
|
-
execute(currentState, selectionController, richTextEditor, event) {
|
|
2411
|
-
this.initCurrentStateAndSelection(currentState, selectionController);
|
|
2412
|
-
this.setCurrentRichTextEditor(richTextEditor);
|
|
2413
|
-
this.handleEvent(event);
|
|
2414
|
-
}
|
|
2415
|
-
/**
|
|
2416
|
-
* The function `isRootContainer` checks if an HTML element is a root container with a class of 'rich-text-content'.
|
|
2417
|
-
*
|
|
2418
|
-
* @param {HTMLElement} element - HTMLElement
|
|
2419
|
-
* @returns {boolean} The boolean value
|
|
2420
|
-
*/
|
|
2421
|
-
isRootContainer(element) {
|
|
2422
|
-
return (element &&
|
|
2423
|
-
element.nodeType === Node.ELEMENT_NODE &&
|
|
2424
|
-
element.classList.contains(ROOT_CONTAINER_CLASS_NAME));
|
|
2425
|
-
}
|
|
2426
|
-
/**
|
|
2427
|
-
* Checks if a given HTML element represents an empty paragraph containing only a line break element.
|
|
2428
|
-
*
|
|
2429
|
-
* @param {HTMLElement} node - An HTMLElement node that represents a paragraph element in the HTML document.
|
|
2430
|
-
* @returns {boolean} boolean result
|
|
2431
|
-
*/
|
|
2432
|
-
isEmptyParagraph(node) {
|
|
2433
|
-
return node && node.childNodes && node.childNodes.length === 0;
|
|
2434
|
-
}
|
|
2435
|
-
/**
|
|
2436
|
-
* Removes selected nodes within a range in a rich text editor content.
|
|
2437
|
-
* The method is only used for different nodes are selected
|
|
2438
|
-
*
|
|
2439
|
-
* @param {boolean} [mergeNode] Merge start node and end node or not, default value is false.
|
|
2440
|
-
* @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.
|
|
2441
|
-
*/
|
|
2442
|
-
removeSelectionRange(mergeNode = false) {
|
|
2443
|
-
changeManager.ChangeManager.notify(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(this.richTextEditorRef, vegaInternalEventId.VegaInternalRichTextEditDeleteSelectedNodes), { host: this.richTextEditorRef, detail: mergeNode });
|
|
2444
|
-
const range = this.selectionController.getCurrentRange();
|
|
2445
|
-
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
2446
|
-
return range.startNode || selectedNodes[0];
|
|
2447
|
-
}
|
|
2448
|
-
/**
|
|
2449
|
-
* Creates a new paragraph with an empty text node and returns it.
|
|
2450
|
-
*
|
|
2451
|
-
* @returns {RTETextBlock} An empty paragraph with a unique identifier and a text node appended to it.
|
|
2452
|
-
*/
|
|
2453
|
-
createEmptyParagraph() {
|
|
2454
|
-
const paragraph = new contentState.RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
2455
|
-
const textNode = new contentState.RTETextNode(`${paragraph.id}1`, '', paragraph);
|
|
2456
|
-
paragraph.apply(new contentState.AppendChildNodesAction([textNode]));
|
|
2457
|
-
return paragraph;
|
|
2458
|
-
}
|
|
2459
|
-
/**
|
|
2460
|
-
* The function initializes the current state and selection controller in TypeScript.
|
|
2461
|
-
*
|
|
2462
|
-
* @param {VegaRTEContent} currentState - The current state of a Vega runtime environment content.
|
|
2463
|
-
* @param {SelectionController} selectionController - It is used to manage the selection of content within the VegaRTE editor.
|
|
2464
|
-
*/
|
|
2465
|
-
initCurrentStateAndSelection(currentState, selectionController) {
|
|
2466
|
-
this.currentState = currentState;
|
|
2467
|
-
this.selectionController = selectionController;
|
|
2468
|
-
}
|
|
2469
|
-
/**
|
|
2470
|
-
* Queries the rich text editor element from the input event target.
|
|
2471
|
-
*
|
|
2472
|
-
* @param {HTMLElement} richTextEditor - The current rich text editor component
|
|
2473
|
-
*/
|
|
2474
|
-
setCurrentRichTextEditor(richTextEditor) {
|
|
2475
|
-
this.richTextEditorRef = richTextEditor;
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
|
|
2479
|
-
/**
|
|
2480
|
-
* Insert a new node before a existing node
|
|
2481
|
-
*
|
|
2482
|
-
* @example currentNode.parentBlock.apply(new InsertNodesBeforeAction(currentNode, newNode, ...))
|
|
2483
|
-
*/
|
|
2484
|
-
class InsertNodesBeforeAction extends contentState.ModifyContentAction {
|
|
2485
|
-
constructor(referNode, ...nodesToBeInserted) {
|
|
2486
|
-
super();
|
|
2487
|
-
this.type = contentState.ModifyContentActionType.INSERT_NODES_BEFORE;
|
|
2488
|
-
this.referNode = referNode;
|
|
2489
|
-
this.nodesToBeInserted = nodesToBeInserted;
|
|
1793
|
+
class InsertNodesBeforeAction extends codeBlock.ModifyContentAction {
|
|
1794
|
+
constructor(referNode, ...nodesToBeInserted) {
|
|
1795
|
+
super();
|
|
1796
|
+
this.type = codeBlock.ModifyContentActionType.INSERT_NODES_BEFORE;
|
|
1797
|
+
this.referNode = referNode;
|
|
1798
|
+
this.nodesToBeInserted = nodesToBeInserted;
|
|
2490
1799
|
}
|
|
2491
1800
|
}
|
|
2492
1801
|
|
|
@@ -2495,10 +1804,10 @@ class InsertNodesBeforeAction extends contentState.ModifyContentAction {
|
|
|
2495
1804
|
*
|
|
2496
1805
|
* @example selectedNode.apply(new ReplaceSelectedTextAction(insertText))
|
|
2497
1806
|
*/
|
|
2498
|
-
class ReplaceSelectedTextAction extends
|
|
1807
|
+
class ReplaceSelectedTextAction extends codeBlock.ModifyContentAction {
|
|
2499
1808
|
constructor(text, currentRange) {
|
|
2500
1809
|
super();
|
|
2501
|
-
this.type =
|
|
1810
|
+
this.type = codeBlock.ModifyContentActionType.REPLACE_SELECTED_TEXT;
|
|
2502
1811
|
this.textToBeInsert = '';
|
|
2503
1812
|
this.textToBeInsert = text;
|
|
2504
1813
|
this.currentRange = currentRange;
|
|
@@ -2522,7 +1831,7 @@ class InsertTextHandler extends BaseHandler {
|
|
|
2522
1831
|
const cursorNode = this.insertTextToRoot(text);
|
|
2523
1832
|
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, text.length);
|
|
2524
1833
|
}
|
|
2525
|
-
else if (selectedNodes[0] instanceof
|
|
1834
|
+
else if (selectedNodes[0] instanceof codeBlock.RTETextNode) {
|
|
2526
1835
|
let nextOffset = startOffset + text.length;
|
|
2527
1836
|
let updateFlag = false;
|
|
2528
1837
|
let cursorNode = selectedNodes[0];
|
|
@@ -2531,13 +1840,13 @@ class InsertTextHandler extends BaseHandler {
|
|
|
2531
1840
|
updateFlag = true;
|
|
2532
1841
|
}
|
|
2533
1842
|
else {
|
|
2534
|
-
if (startContainer.nodeValue ===
|
|
2535
|
-
startOffset ===
|
|
1843
|
+
if (startContainer.nodeValue === codeBlock.ZERO_WIDTH_SPACE &&
|
|
1844
|
+
startOffset === codeBlock.ZERO_WIDTH_SPACE.length &&
|
|
2536
1845
|
cursorNode.isEmpty()) {
|
|
2537
1846
|
startContainer.nodeValue = '';
|
|
2538
|
-
nextOffset = nextOffset -
|
|
1847
|
+
nextOffset = nextOffset - codeBlock.ZERO_WIDTH_SPACE.length;
|
|
2539
1848
|
}
|
|
2540
|
-
if (cursorNode instanceof
|
|
1849
|
+
if (cursorNode instanceof codeBlock.RTETextNode) {
|
|
2541
1850
|
updateFlag = true;
|
|
2542
1851
|
cursorNode.apply(new ReplaceSelectedTextAction(text, currentRange));
|
|
2543
1852
|
}
|
|
@@ -2549,7 +1858,7 @@ class InsertTextHandler extends BaseHandler {
|
|
|
2549
1858
|
else {
|
|
2550
1859
|
// The selected nodes is multiple nodes
|
|
2551
1860
|
const cursorNode = this.removeSelectionRange(true);
|
|
2552
|
-
if (cursorNode instanceof
|
|
1861
|
+
if (cursorNode instanceof codeBlock.RTETextNode) {
|
|
2553
1862
|
cursorNode.apply(new ReplaceSelectedTextAction(text, currentRange));
|
|
2554
1863
|
this.selectionController.enqueueSelectionRangeFutureState(cursorNode, Math.min(startOffset + text.length, cursorNode.text.length));
|
|
2555
1864
|
}
|
|
@@ -2564,9 +1873,9 @@ class InsertTextHandler extends BaseHandler {
|
|
|
2564
1873
|
insertTextToRoot(text) {
|
|
2565
1874
|
if (this.currentState &&
|
|
2566
1875
|
this.currentState.blocks[0] &&
|
|
2567
|
-
this.currentState.blocks[0] instanceof
|
|
1876
|
+
this.currentState.blocks[0] instanceof codeBlock.RTETextBlock) {
|
|
2568
1877
|
const firstNode = this.currentState.blocks[0].nodes[0];
|
|
2569
|
-
firstNode.apply(new
|
|
1878
|
+
firstNode.apply(new codeBlock.UpdateTextAction(text));
|
|
2570
1879
|
return firstNode;
|
|
2571
1880
|
}
|
|
2572
1881
|
}
|
|
@@ -2587,7 +1896,7 @@ class InsertTextHandler extends BaseHandler {
|
|
|
2587
1896
|
return newTextNode;
|
|
2588
1897
|
}
|
|
2589
1898
|
else {
|
|
2590
|
-
lineBreakNode.apply(new
|
|
1899
|
+
lineBreakNode.apply(new codeBlock.UpdateTextAction(text));
|
|
2591
1900
|
return lineBreakNode;
|
|
2592
1901
|
}
|
|
2593
1902
|
}
|
|
@@ -2600,11 +1909,13 @@ class InsertParagraphHandler extends BaseHandler {
|
|
|
2600
1909
|
*/
|
|
2601
1910
|
handleEvent() {
|
|
2602
1911
|
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
2603
|
-
if (selectedBlocks.length
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
1912
|
+
if (selectedBlocks.length) {
|
|
1913
|
+
if (selectedBlocks.length < 2) {
|
|
1914
|
+
this.breakSingleBlock();
|
|
1915
|
+
}
|
|
1916
|
+
else {
|
|
1917
|
+
this.breakMultipleBlocks();
|
|
1918
|
+
}
|
|
2608
1919
|
}
|
|
2609
1920
|
}
|
|
2610
1921
|
/**
|
|
@@ -2646,8 +1957,8 @@ class InsertParagraphHandler extends BaseHandler {
|
|
|
2646
1957
|
*/
|
|
2647
1958
|
if (firstBlock.type !== lastBlock.type &&
|
|
2648
1959
|
range.startContainer.nodeType === range.endContainer.nodeType) {
|
|
2649
|
-
firstBlock.apply(new
|
|
2650
|
-
const splitAction = new
|
|
1960
|
+
firstBlock.apply(new codeBlock.MergeTwoBlocksNodesAction(lastBlock));
|
|
1961
|
+
const splitAction = new codeBlock.SplitBlockWithNodeAction(cursorNode, cursorNode['text'].length);
|
|
2651
1962
|
firstBlock.apply(splitAction);
|
|
2652
1963
|
this.switchCaretPositionToNextElement(splitAction.newBlock);
|
|
2653
1964
|
return;
|
|
@@ -2685,10 +1996,10 @@ class InsertParagraphHandler extends BaseHandler {
|
|
|
2685
1996
|
*
|
|
2686
1997
|
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
2687
1998
|
*/
|
|
2688
|
-
class LineBreakSingleBlockAction extends
|
|
1999
|
+
class LineBreakSingleBlockAction extends codeBlock.ModifyContentAction {
|
|
2689
2000
|
constructor(startContainerNode, startOffset) {
|
|
2690
2001
|
super();
|
|
2691
|
-
this.type =
|
|
2002
|
+
this.type = codeBlock.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK;
|
|
2692
2003
|
this.startContainerNode = startContainerNode;
|
|
2693
2004
|
this.startOffset = startOffset;
|
|
2694
2005
|
}
|
|
@@ -2699,10 +2010,10 @@ class LineBreakSingleBlockAction extends contentState.ModifyContentAction {
|
|
|
2699
2010
|
*
|
|
2700
2011
|
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
2701
2012
|
*/
|
|
2702
|
-
class lineBreakMultipleBlocksAction extends
|
|
2013
|
+
class lineBreakMultipleBlocksAction extends codeBlock.ModifyContentAction {
|
|
2703
2014
|
constructor(selectedBlocks) {
|
|
2704
2015
|
super();
|
|
2705
|
-
this.type =
|
|
2016
|
+
this.type = codeBlock.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS;
|
|
2706
2017
|
this.selectedBlocks = selectedBlocks;
|
|
2707
2018
|
}
|
|
2708
2019
|
}
|
|
@@ -2718,11 +2029,13 @@ class InsertLineBreakHandler extends BaseHandler {
|
|
|
2718
2029
|
if (this.isRootContainer(range.startContainer)) {
|
|
2719
2030
|
this.breakNewBlock();
|
|
2720
2031
|
}
|
|
2721
|
-
if (selectedBlocks.length
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2032
|
+
if (selectedBlocks.length) {
|
|
2033
|
+
if (selectedBlocks.length < 2) {
|
|
2034
|
+
this.breakSingleBlock();
|
|
2035
|
+
}
|
|
2036
|
+
else {
|
|
2037
|
+
this.breakMultipleBlocks();
|
|
2038
|
+
}
|
|
2726
2039
|
}
|
|
2727
2040
|
}
|
|
2728
2041
|
/**
|
|
@@ -2735,7 +2048,7 @@ class InsertLineBreakHandler extends BaseHandler {
|
|
|
2735
2048
|
breakNewBlock() {
|
|
2736
2049
|
if (this.currentState &&
|
|
2737
2050
|
this.currentState.blocks[0] &&
|
|
2738
|
-
this.currentState.blocks[0] instanceof
|
|
2051
|
+
this.currentState.blocks[0] instanceof codeBlock.RTETextBlock) {
|
|
2739
2052
|
const lineBreakAction = new LineBreakSingleBlockAction(this.currentState.blocks[0].nodes[0], 0);
|
|
2740
2053
|
this.currentState.blocks[0].apply(lineBreakAction);
|
|
2741
2054
|
this.switchCaretPositionToSpecifiedNode(lineBreakAction.lineBreakNode);
|
|
@@ -2799,10 +2112,10 @@ class InsertLineBreakHandler extends BaseHandler {
|
|
|
2799
2112
|
*
|
|
2800
2113
|
* @example currentBlock.apply(new DeleteBlockContentAction(startContainerNode, startOffset))
|
|
2801
2114
|
*/
|
|
2802
|
-
class DeleteBlockContentAction extends
|
|
2115
|
+
class DeleteBlockContentAction extends codeBlock.ModifyContentAction {
|
|
2803
2116
|
constructor(startContainerNode, startOffset) {
|
|
2804
2117
|
super();
|
|
2805
|
-
this.type =
|
|
2118
|
+
this.type = codeBlock.ModifyContentActionType.DELETE_BLOCK_CONTENT;
|
|
2806
2119
|
this.startContainerNode = startContainerNode;
|
|
2807
2120
|
this.startOffset = startOffset;
|
|
2808
2121
|
}
|
|
@@ -2859,9 +2172,9 @@ class DeleteContentHandler extends BaseHandler {
|
|
|
2859
2172
|
const cursorNode = this.removeSelectionRange(true);
|
|
2860
2173
|
const lastSelectedNode = selectedNodes[selectedNodes.length - 1];
|
|
2861
2174
|
if (selectedNodes.length > 1 &&
|
|
2862
|
-
lastSelectedNode instanceof
|
|
2175
|
+
lastSelectedNode instanceof codeBlock.RTETextNode &&
|
|
2863
2176
|
lastSelectedNode.isEmpty()) {
|
|
2864
|
-
lastSelectedNode.parentBlock.apply(new
|
|
2177
|
+
lastSelectedNode.parentBlock.apply(new codeBlock.RemoveChildAction(lastSelectedNode));
|
|
2865
2178
|
}
|
|
2866
2179
|
this.convertFirstBlockToParagraph(cursorNode.parentBlock);
|
|
2867
2180
|
}
|
|
@@ -2873,14 +2186,14 @@ class DeleteContentHandler extends BaseHandler {
|
|
|
2873
2186
|
convertFirstBlockToParagraph(block) {
|
|
2874
2187
|
const firstBlock = this.currentState.blocks[0];
|
|
2875
2188
|
if (firstBlock === block &&
|
|
2876
|
-
block instanceof
|
|
2189
|
+
block instanceof codeBlock.RTETextBlock &&
|
|
2877
2190
|
block.nodes.length === 1 &&
|
|
2878
2191
|
block.nodes[0].isEmpty() &&
|
|
2879
2192
|
block.type !== 'paragraph') {
|
|
2880
2193
|
const paragraph = this.createEmptyParagraph();
|
|
2881
|
-
paragraph.apply(new
|
|
2882
|
-
block.parent.apply(new
|
|
2883
|
-
block.parent.apply(new
|
|
2194
|
+
paragraph.apply(new codeBlock.ReplaceChildNodesAction(block.nodes));
|
|
2195
|
+
block.parent.apply(new codeBlock.InsertBlocksBeforeAction(block, paragraph));
|
|
2196
|
+
block.parent.apply(new codeBlock.RemoveChildAction(block));
|
|
2884
2197
|
}
|
|
2885
2198
|
}
|
|
2886
2199
|
/**
|
|
@@ -2888,7 +2201,7 @@ class DeleteContentHandler extends BaseHandler {
|
|
|
2888
2201
|
*/
|
|
2889
2202
|
insertDefaultParagraph() {
|
|
2890
2203
|
const paragraph = this.createEmptyParagraph();
|
|
2891
|
-
this.currentState.apply(new
|
|
2204
|
+
this.currentState.apply(new codeBlock.AppendChildNodesAction([paragraph]));
|
|
2892
2205
|
this.selectionController.enqueueSelectionRangeFutureState(paragraph.nodes[0], 1);
|
|
2893
2206
|
}
|
|
2894
2207
|
/**
|
|
@@ -3112,13 +2425,13 @@ class BlockToRTEBlockStrategyAbstract extends ElementToDTOStrategy {
|
|
|
3112
2425
|
const color = element.style.color;
|
|
3113
2426
|
const hexColor = (_a = ui.rgbToHex(color)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
3114
2427
|
if (hexColor) {
|
|
3115
|
-
const colorSchema =
|
|
2428
|
+
const colorSchema = codeBlock.RTE_TEXT_COLORS.find((schema) => schema.light === hexColor || schema.dark === hexColor);
|
|
3116
2429
|
if (colorSchema)
|
|
3117
2430
|
return colorSchema.key;
|
|
3118
2431
|
return null;
|
|
3119
2432
|
}
|
|
3120
2433
|
else {
|
|
3121
|
-
for (const color of
|
|
2434
|
+
for (const color of codeBlock.RTE_TEXT_COLORS) {
|
|
3122
2435
|
if (element.style.color.includes(color.key)) {
|
|
3123
2436
|
return color.key;
|
|
3124
2437
|
}
|
|
@@ -3245,7 +2558,7 @@ class ContinueInlineToRTETextBlockStrategy extends BlockToRTEBlockStrategyAbstra
|
|
|
3245
2558
|
const nodes = this.generateChildNodes(elementsArray, this.generateTextNodeAnnotations(parent));
|
|
3246
2559
|
if (nodes.length === 0)
|
|
3247
2560
|
return null;
|
|
3248
|
-
return
|
|
2561
|
+
return codeBlock.RTETextBlock.from({
|
|
3249
2562
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
3250
2563
|
type: 'paragraph',
|
|
3251
2564
|
nodes: nodes,
|
|
@@ -3410,7 +2723,7 @@ class InlineBlockToRTETextBlockStrategy extends BlockToRTEBlockStrategyAbstract
|
|
|
3410
2723
|
const nodes = this.generateChildNodes(elementsArray);
|
|
3411
2724
|
if (nodes.length === 0)
|
|
3412
2725
|
return null;
|
|
3413
|
-
return
|
|
2726
|
+
return codeBlock.RTETextBlock.from({
|
|
3414
2727
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
3415
2728
|
type: this.getElementType(elementsArray[0]),
|
|
3416
2729
|
nodes: nodes,
|
|
@@ -3626,12 +2939,117 @@ class OlToRTEListBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
|
3626
2939
|
* @returns {boolean} - boolean.
|
|
3627
2940
|
*/
|
|
3628
2941
|
shouldProceedToElementChildren() {
|
|
3629
|
-
return true;
|
|
2942
|
+
return true;
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
/** Transform img in span or other inline element to image block DTO */
|
|
2947
|
+
class SpanImageToRTEImageBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
2948
|
+
/**
|
|
2949
|
+
* Can be handle.
|
|
2950
|
+
*
|
|
2951
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
2952
|
+
* @param {number} currentIndex - Current element index.
|
|
2953
|
+
* @returns {number} - can be handled element count.
|
|
2954
|
+
*/
|
|
2955
|
+
canHandle(elementsArray, currentIndex) {
|
|
2956
|
+
const element = elementsArray[currentIndex];
|
|
2957
|
+
return element.nodeType === Node.ELEMENT_NODE &&
|
|
2958
|
+
element.textContent === '' &&
|
|
2959
|
+
element.querySelector('img')
|
|
2960
|
+
? 1
|
|
2961
|
+
: 0;
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Parse to a image block.
|
|
2965
|
+
*
|
|
2966
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
2967
|
+
* @returns {Nullable<RTEContentBlock>} - Image block.
|
|
2968
|
+
*/
|
|
2969
|
+
handle(elementsArray) {
|
|
2970
|
+
const element = elementsArray[0].querySelector('img');
|
|
2971
|
+
return contentState.RTEImageBlock.from({
|
|
2972
|
+
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
2973
|
+
type: 'image',
|
|
2974
|
+
nodes: [
|
|
2975
|
+
{
|
|
2976
|
+
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
2977
|
+
type: 'image',
|
|
2978
|
+
url: element.src,
|
|
2979
|
+
annotations: {
|
|
2980
|
+
size: 'md',
|
|
2981
|
+
alt: element.alt,
|
|
2982
|
+
},
|
|
2983
|
+
},
|
|
2984
|
+
],
|
|
2985
|
+
annotations: this.generateBlockAnnotations(element),
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
/* istanbul ignore next */
|
|
2989
|
+
/**
|
|
2990
|
+
* Append child blocks.
|
|
2991
|
+
*/
|
|
2992
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
2993
|
+
appendChildBlocks() { }
|
|
2994
|
+
/**
|
|
2995
|
+
* Should continue process to child elements.
|
|
2996
|
+
*
|
|
2997
|
+
* @returns {boolean} - boolean.
|
|
2998
|
+
*/
|
|
2999
|
+
shouldProceedToElementChildren() {
|
|
3000
|
+
return false;
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
/** Transform child element of UL element which are not LI element to list item block DTO */
|
|
3005
|
+
class ULNotLiChildToRTEListItemBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3006
|
+
/**
|
|
3007
|
+
* Can be handle.
|
|
3008
|
+
*
|
|
3009
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3010
|
+
* @param {number} currentIndex - Current element index.
|
|
3011
|
+
* @returns {number} - can be handled element count.
|
|
3012
|
+
*/
|
|
3013
|
+
canHandle(elementsArray, currentIndex) {
|
|
3014
|
+
const element = elementsArray[currentIndex];
|
|
3015
|
+
const parent = element.parentElement;
|
|
3016
|
+
return element.nodeName !== 'LI' && parent && ['UL', 'OL'].includes(parent.nodeName) ? 1 : 0;
|
|
3017
|
+
}
|
|
3018
|
+
/**
|
|
3019
|
+
* Parse to a list item block.
|
|
3020
|
+
*
|
|
3021
|
+
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3022
|
+
* @returns {Nullable<RTEContentBlock>} - List item block.
|
|
3023
|
+
*/
|
|
3024
|
+
handle(elementsArray) {
|
|
3025
|
+
const nodes = this.generateChildNodes(elementsArray);
|
|
3026
|
+
if (nodes.length === 0)
|
|
3027
|
+
return null;
|
|
3028
|
+
return contentState.RTEListItemBlock.from({
|
|
3029
|
+
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
3030
|
+
type: 'list-item',
|
|
3031
|
+
nodes: nodes,
|
|
3032
|
+
annotations: {},
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
/* istanbul ignore next */
|
|
3036
|
+
/**
|
|
3037
|
+
* Append child blocks.
|
|
3038
|
+
*/
|
|
3039
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3040
|
+
appendChildBlocks() { }
|
|
3041
|
+
/**
|
|
3042
|
+
* Should continue process to child elements.
|
|
3043
|
+
*
|
|
3044
|
+
* @returns {boolean} - boolean.
|
|
3045
|
+
*/
|
|
3046
|
+
shouldProceedToElementChildren() {
|
|
3047
|
+
return false;
|
|
3630
3048
|
}
|
|
3631
3049
|
}
|
|
3632
3050
|
|
|
3633
|
-
/** Transform
|
|
3634
|
-
class
|
|
3051
|
+
/** Transform other editor code element which has attribute data-language to RTE code block DTO */
|
|
3052
|
+
class JiraCodeToRTECodeBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
3635
3053
|
/**
|
|
3636
3054
|
* Can be handle.
|
|
3637
3055
|
*
|
|
@@ -3640,37 +3058,31 @@ class SpanImageToRTEImageBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
|
3640
3058
|
* @returns {number} - can be handled element count.
|
|
3641
3059
|
*/
|
|
3642
3060
|
canHandle(elementsArray, currentIndex) {
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
element.querySelector('img')
|
|
3061
|
+
return (elementsArray[currentIndex].tagName === 'PRE' ||
|
|
3062
|
+
elementsArray[currentIndex].tagName === 'CODE') &&
|
|
3063
|
+
elementsArray[currentIndex].hasAttribute('data-language')
|
|
3647
3064
|
? 1
|
|
3648
3065
|
: 0;
|
|
3649
3066
|
}
|
|
3650
3067
|
/**
|
|
3651
|
-
* Parse to a
|
|
3068
|
+
* Parse to a code block.
|
|
3652
3069
|
*
|
|
3653
3070
|
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3654
|
-
* @returns {Nullable<
|
|
3071
|
+
* @returns {Nullable<RTECodeBlock>} - Code block.
|
|
3655
3072
|
*/
|
|
3656
3073
|
handle(elementsArray) {
|
|
3657
|
-
const
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
},
|
|
3670
|
-
},
|
|
3671
|
-
],
|
|
3672
|
-
annotations: this.generateBlockAnnotations(element),
|
|
3673
|
-
});
|
|
3074
|
+
const codeRef = elementsArray[0];
|
|
3075
|
+
if (codeRef) {
|
|
3076
|
+
const content = codeRef.textContent;
|
|
3077
|
+
const language = codeRef.dataset
|
|
3078
|
+
.language;
|
|
3079
|
+
return codeBlock.RTECodeBlock.from({
|
|
3080
|
+
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
3081
|
+
type: 'code-block',
|
|
3082
|
+
content,
|
|
3083
|
+
language,
|
|
3084
|
+
});
|
|
3085
|
+
}
|
|
3674
3086
|
}
|
|
3675
3087
|
/* istanbul ignore next */
|
|
3676
3088
|
/**
|
|
@@ -3688,36 +3100,48 @@ class SpanImageToRTEImageBlockStrategy extends BlockToRTEBlockStrategyAbstract {
|
|
|
3688
3100
|
}
|
|
3689
3101
|
}
|
|
3690
3102
|
|
|
3691
|
-
/** Transform
|
|
3692
|
-
class
|
|
3103
|
+
/** Transform vega-code-block element to code block DTO */
|
|
3104
|
+
class VegaCodeBlockToRTECodeBlockStrategy extends JiraCodeToRTECodeBlockStrategy {
|
|
3693
3105
|
/**
|
|
3694
3106
|
* Can be handle.
|
|
3695
3107
|
*
|
|
3108
|
+
* TODO: Update the browser clipboard data to fix the issue with nested vega-code-block elements.
|
|
3109
|
+
* In safari the html snippet will be like: <vega-code-block><p><span>paragraph</span></p><vega-code-block></vega-code-block></vega-code-block>
|
|
3110
|
+
* The vega-code-block nested inside the vega-code-block, so we need to check the child element.
|
|
3111
|
+
*
|
|
3696
3112
|
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3697
3113
|
* @param {number} currentIndex - Current element index.
|
|
3698
3114
|
* @returns {number} - can be handled element count.
|
|
3699
3115
|
*/
|
|
3700
3116
|
canHandle(elementsArray, currentIndex) {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3117
|
+
return (elementsArray[currentIndex].tagName === 'VEGA-CODE-BLOCK' &&
|
|
3118
|
+
!!elementsArray[currentIndex].querySelector('vega-code-block') === false) ||
|
|
3119
|
+
this.isCodeBlockContainer(elementsArray[currentIndex])
|
|
3120
|
+
? 1
|
|
3121
|
+
: 0;
|
|
3704
3122
|
}
|
|
3705
3123
|
/**
|
|
3706
|
-
* Parse to a
|
|
3124
|
+
* Parse to a code block.
|
|
3707
3125
|
*
|
|
3708
3126
|
* @param {HTMLElement[]} elementsArray - Current elements.
|
|
3709
|
-
* @returns {Nullable<
|
|
3127
|
+
* @returns {Nullable<RTECodeBlock>} - Code block.
|
|
3710
3128
|
*/
|
|
3711
3129
|
handle(elementsArray) {
|
|
3712
|
-
const
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3130
|
+
const codeBlockElement = this.isCodeBlockContainer(elementsArray[0])
|
|
3131
|
+
? elementsArray[0].querySelector('vega-code-block')
|
|
3132
|
+
: elementsArray[0];
|
|
3133
|
+
const code = codeBlockElement.querySelector('code');
|
|
3134
|
+
if (code) {
|
|
3135
|
+
return super.handle([code]); // Call the parent method to handle the code element
|
|
3136
|
+
}
|
|
3137
|
+
else if (codeBlockElement.hasAttribute('data-content')) {
|
|
3138
|
+
// The code element in shadow dom could be empty in firefox.
|
|
3139
|
+
// eslint-disable-next-line no-restricted-globals
|
|
3140
|
+
const code = document.createElement('code');
|
|
3141
|
+
code.textContent = codeBlockElement.dataset.content;
|
|
3142
|
+
code.dataset.language = codeBlockElement.dataset.language;
|
|
3143
|
+
return super.handle([code]); // Call the parent method to handle the code element
|
|
3144
|
+
}
|
|
3721
3145
|
}
|
|
3722
3146
|
/* istanbul ignore next */
|
|
3723
3147
|
/**
|
|
@@ -3733,6 +3157,17 @@ class ULNotLiChildToRTEListItemBlockStrategy extends BlockToRTEBlockStrategyAbst
|
|
|
3733
3157
|
shouldProceedToElementChildren() {
|
|
3734
3158
|
return false;
|
|
3735
3159
|
}
|
|
3160
|
+
/**
|
|
3161
|
+
* Checks if the given element is a code block container.
|
|
3162
|
+
*
|
|
3163
|
+
* @param {HTMLElement} element - The element to check.
|
|
3164
|
+
* @returns {boolean} - Boolean result.
|
|
3165
|
+
*/
|
|
3166
|
+
isCodeBlockContainer(element) {
|
|
3167
|
+
return (element.tagName === 'PRE' &&
|
|
3168
|
+
element.classList.contains('code-block-container') &&
|
|
3169
|
+
element.querySelectorAll('vega-code-block').length === 1);
|
|
3170
|
+
}
|
|
3736
3171
|
}
|
|
3737
3172
|
|
|
3738
3173
|
/** Element to DTO processor */
|
|
@@ -3743,6 +3178,8 @@ class ElementToDtoStrategyProcessor {
|
|
|
3743
3178
|
new OlToRTEListBlockStrategy(),
|
|
3744
3179
|
new ULNotLiChildToRTEListItemBlockStrategy(),
|
|
3745
3180
|
new LiToRTEListItemBlockStrategy(),
|
|
3181
|
+
new VegaCodeBlockToRTECodeBlockStrategy(),
|
|
3182
|
+
new JiraCodeToRTECodeBlockStrategy(),
|
|
3746
3183
|
new InlineBlockToRTETextBlockStrategy(),
|
|
3747
3184
|
new ImgToRTEImageBlockStrategy(),
|
|
3748
3185
|
new VegaImageToRTEImageBlockStrategy(),
|
|
@@ -3830,7 +3267,7 @@ class InsertPasteHandler extends BaseHandler {
|
|
|
3830
3267
|
* @param { RTEContentBlock[]} blocks - blocks
|
|
3831
3268
|
*/
|
|
3832
3269
|
insertBlocksToRoot(blocks) {
|
|
3833
|
-
this.currentState.apply(new
|
|
3270
|
+
this.currentState.apply(new codeBlock.AppendChildNodesAction(blocks));
|
|
3834
3271
|
}
|
|
3835
3272
|
/**
|
|
3836
3273
|
* Insert the blocks to content
|
|
@@ -3842,9 +3279,9 @@ class InsertPasteHandler extends BaseHandler {
|
|
|
3842
3279
|
if (cursorNode && cursorNode.parentBlock) {
|
|
3843
3280
|
const currentBlock = cursorNode.parentBlock;
|
|
3844
3281
|
const { startOffset } = this.selectionController.getCurrentRange();
|
|
3845
|
-
const breakAction = new
|
|
3282
|
+
const breakAction = new codeBlock.SplitBlockWithNodeAction(cursorNode, startOffset);
|
|
3846
3283
|
currentBlock.apply(breakAction);
|
|
3847
|
-
currentBlock.parent.apply(new
|
|
3284
|
+
currentBlock.parent.apply(new codeBlock.InsertBlocksAfterAction(currentBlock, ...blocks));
|
|
3848
3285
|
this.switchCaretPositionToNextElement(breakAction.newBlock);
|
|
3849
3286
|
}
|
|
3850
3287
|
}
|
|
@@ -3857,8 +3294,10 @@ class InsertPasteHandler extends BaseHandler {
|
|
|
3857
3294
|
const cursorNode = this.removeSelectionRange();
|
|
3858
3295
|
/* istanbul ignore next */
|
|
3859
3296
|
const currentBlock = cursorNode === null || cursorNode === void 0 ? void 0 : cursorNode.parentBlock;
|
|
3860
|
-
|
|
3861
|
-
|
|
3297
|
+
if (currentBlock) {
|
|
3298
|
+
currentBlock.parent.apply(new codeBlock.InsertBlocksBeforeAction(currentBlock, ...blocks));
|
|
3299
|
+
this.switchCaretPositionToNextElement(currentBlock);
|
|
3300
|
+
}
|
|
3862
3301
|
}
|
|
3863
3302
|
/**
|
|
3864
3303
|
* Format and parse elements from user paste.
|
|
@@ -3867,7 +3306,12 @@ class InsertPasteHandler extends BaseHandler {
|
|
|
3867
3306
|
* @returns {RTEContentBlock[]} - RTEContentBlock.
|
|
3868
3307
|
*/
|
|
3869
3308
|
parsePastedElements(event) {
|
|
3870
|
-
|
|
3309
|
+
let pastedHTML = event.dataTransfer.getData('text/html');
|
|
3310
|
+
if (!pastedHTML) {
|
|
3311
|
+
const pastedText = event.dataTransfer.getData('text/plain');
|
|
3312
|
+
pastedHTML = this.parsePlainText(pastedText);
|
|
3313
|
+
}
|
|
3314
|
+
// eslint-disable-next-line no-restricted-globals
|
|
3871
3315
|
const tempContainer = document.createElement('div');
|
|
3872
3316
|
tempContainer.innerHTML = pastedHTML;
|
|
3873
3317
|
return this.elementToDTOProcessor
|
|
@@ -3886,9 +3330,23 @@ class InsertPasteHandler extends BaseHandler {
|
|
|
3886
3330
|
this.selectionController.enqueueSelectionRangeFutureState(newBlock['nodes'][0], 0);
|
|
3887
3331
|
}
|
|
3888
3332
|
}
|
|
3333
|
+
/**
|
|
3334
|
+
* Parses the content of a plain text and formats it into HTML.
|
|
3335
|
+
*
|
|
3336
|
+
* @param {string} content - The content of plain text.
|
|
3337
|
+
* @returns {string} - The formatted HTML string.
|
|
3338
|
+
*/
|
|
3339
|
+
parsePlainText(content) {
|
|
3340
|
+
const lines = content.split('\n');
|
|
3341
|
+
return lines
|
|
3342
|
+
.map((line) => {
|
|
3343
|
+
return `<span>${line}</span>`;
|
|
3344
|
+
})
|
|
3345
|
+
.join('<span>\n</span>');
|
|
3346
|
+
}
|
|
3889
3347
|
}
|
|
3890
3348
|
|
|
3891
|
-
var __decorate$
|
|
3349
|
+
var __decorate$e = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
3892
3350
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3893
3351
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3894
3352
|
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;
|
|
@@ -3913,7 +3371,8 @@ class UserInputController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
3913
3371
|
e.preventDefault();
|
|
3914
3372
|
this.initValueIfEmpty();
|
|
3915
3373
|
// The insertCompositionText type input event can not be prevented, so we process the current action by insertCompositionTextController.
|
|
3916
|
-
|
|
3374
|
+
// If the focus node is a non-editable element, we do not process the input event.
|
|
3375
|
+
if (inputType === 'insertCompositionText' || this.isFocusNodeNonEditable()) {
|
|
3917
3376
|
return;
|
|
3918
3377
|
}
|
|
3919
3378
|
this.insertCompositionTextController.removeObserver();
|
|
@@ -3941,7 +3400,7 @@ class UserInputController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
3941
3400
|
break;
|
|
3942
3401
|
}
|
|
3943
3402
|
if (updateFlag) {
|
|
3944
|
-
this.
|
|
3403
|
+
void this.valueController.flushChanges(this.value);
|
|
3945
3404
|
}
|
|
3946
3405
|
};
|
|
3947
3406
|
}
|
|
@@ -3976,12 +3435,6 @@ class UserInputController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
3976
3435
|
}
|
|
3977
3436
|
return this.editableElementRef;
|
|
3978
3437
|
}
|
|
3979
|
-
/**
|
|
3980
|
-
* Notifies a change manager with the host and value details and logs the current value.
|
|
3981
|
-
*/
|
|
3982
|
-
notifyComponentFlushValue() {
|
|
3983
|
-
void this.valueController.flushChanges(this.value);
|
|
3984
|
-
}
|
|
3985
3438
|
/**
|
|
3986
3439
|
* Prevents the default behavior of a drag event.
|
|
3987
3440
|
*
|
|
@@ -4002,29 +3455,46 @@ class UserInputController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4002
3455
|
void this.valueController.flushChanges(contentState.VegaRTEContent.fromJSON(defaultParagraph));
|
|
4003
3456
|
}
|
|
4004
3457
|
}
|
|
3458
|
+
/**
|
|
3459
|
+
* The code block placeholder element is non-editable, so we need to check if the focus node is a code block placeholder element.
|
|
3460
|
+
*
|
|
3461
|
+
* @returns {boolean} - Returns true if the focus node is a code block placeholder element, otherwise false.
|
|
3462
|
+
*/
|
|
3463
|
+
isFocusNodeNonEditable() {
|
|
3464
|
+
const { startContainer, endContainer } = this.selectionController.getCurrentRange();
|
|
3465
|
+
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
3466
|
+
if (startContainer && startContainer === endContainer && selectedNodes.length === 0) {
|
|
3467
|
+
const focusElement = startContainer.nodeType === Node.ELEMENT_NODE
|
|
3468
|
+
? startContainer
|
|
3469
|
+
: startContainer.parentElement;
|
|
3470
|
+
return (focusElement &&
|
|
3471
|
+
focusElement.classList.contains(codeBlock.RTECodeBlock.CODE_BLOCK_PLACEHOLDER_CLASS_NAME));
|
|
3472
|
+
}
|
|
3473
|
+
return false;
|
|
3474
|
+
}
|
|
4005
3475
|
}
|
|
4006
|
-
__decorate$
|
|
3476
|
+
__decorate$e([
|
|
4007
3477
|
globalSlimmerRegistry.MapToComponentField()
|
|
4008
3478
|
], UserInputController.prototype, "host", void 0);
|
|
4009
|
-
__decorate$
|
|
3479
|
+
__decorate$e([
|
|
4010
3480
|
globalSlimmerRegistry.MapToComponentField()
|
|
4011
3481
|
], UserInputController.prototype, "value", void 0);
|
|
4012
|
-
__decorate$
|
|
3482
|
+
__decorate$e([
|
|
4013
3483
|
globalSlimmerRegistry.MapToComponentField()
|
|
4014
3484
|
], UserInputController.prototype, "valueController", void 0);
|
|
4015
|
-
__decorate$
|
|
3485
|
+
__decorate$e([
|
|
4016
3486
|
globalSlimmerRegistry.MapToComponentField()
|
|
4017
3487
|
], UserInputController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4018
|
-
__decorate$
|
|
3488
|
+
__decorate$e([
|
|
4019
3489
|
globalSlimmerRegistry.MapToComponentField()
|
|
4020
3490
|
], UserInputController.prototype, "selectionController", void 0);
|
|
4021
|
-
__decorate$
|
|
3491
|
+
__decorate$e([
|
|
4022
3492
|
globalSlimmerRegistry.MapToComponentField()
|
|
4023
3493
|
], UserInputController.prototype, "insertCompositionTextController", void 0);
|
|
4024
|
-
__decorate$
|
|
3494
|
+
__decorate$e([
|
|
4025
3495
|
globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
|
|
4026
3496
|
], UserInputController.prototype, "addActionListener", null);
|
|
4027
|
-
__decorate$
|
|
3497
|
+
__decorate$e([
|
|
4028
3498
|
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
4029
3499
|
], UserInputController.prototype, "removeActionListener", null);
|
|
4030
3500
|
|
|
@@ -4033,18 +3503,18 @@ __decorate$d([
|
|
|
4033
3503
|
*
|
|
4034
3504
|
* @example block.apply(new InsertImageToBlockAction(node, offset, imageNode))
|
|
4035
3505
|
*/
|
|
4036
|
-
class InsertImageToBlockAction extends
|
|
3506
|
+
class InsertImageToBlockAction extends codeBlock.ModifyContentAction {
|
|
4037
3507
|
constructor(splitPointNode, startOffsetOfNode, imageBlockToBeInserted) {
|
|
4038
3508
|
super();
|
|
4039
3509
|
this.isFlushable = true;
|
|
4040
|
-
this.type =
|
|
3510
|
+
this.type = codeBlock.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK;
|
|
4041
3511
|
this.splitPointNode = splitPointNode;
|
|
4042
3512
|
this.startOffsetOfNode = startOffsetOfNode;
|
|
4043
3513
|
this.imageBlockToBeInserted = imageBlockToBeInserted;
|
|
4044
3514
|
}
|
|
4045
3515
|
}
|
|
4046
3516
|
|
|
4047
|
-
var __decorate$
|
|
3517
|
+
var __decorate$d = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4048
3518
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4049
3519
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4050
3520
|
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;
|
|
@@ -4061,11 +3531,11 @@ class InsertImageController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4061
3531
|
insertImageToCaretPosition(imageUrl) {
|
|
4062
3532
|
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
4063
3533
|
const imageBlock = new contentState.RTEImageBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
4064
|
-
const newImageNode = new
|
|
3534
|
+
const newImageNode = new codeBlock.RTEImageNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), imageUrl, imageBlock);
|
|
4065
3535
|
newImageNode.apply(new imageAnnotationAction.ImageAnnotationAction('md', ''));
|
|
4066
|
-
imageBlock.apply(new
|
|
3536
|
+
imageBlock.apply(new codeBlock.AppendChildNodesAction([newImageNode]));
|
|
4067
3537
|
if (selectedBlocks.length < 1 || this.value.blocks.length < 1) {
|
|
4068
|
-
this.value.apply(new
|
|
3538
|
+
this.value.apply(new codeBlock.AppendChildNodesAction([imageBlock]));
|
|
4069
3539
|
void this.valueController.flushChanges(this.value);
|
|
4070
3540
|
}
|
|
4071
3541
|
else {
|
|
@@ -4105,7 +3575,7 @@ class InsertImageController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4105
3575
|
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(richTextContentRef, vegaInternalEventId.VegaInternalRichTextImageClick, (payload) => {
|
|
4106
3576
|
const range = this.selectionController.getCurrentRange();
|
|
4107
3577
|
if (!range || range.startContainer !== payload.host || range.startOffset !== 0) {
|
|
4108
|
-
const imageNode =
|
|
3578
|
+
const imageNode = codeBlock.stateEntityRenderingRegistry.getEntityByDOM(payload.host.querySelector('img'));
|
|
4109
3579
|
this.selectionController.enqueueSelectionRangeFutureState(imageNode, 0, imageNode, 0, true);
|
|
4110
3580
|
}
|
|
4111
3581
|
});
|
|
@@ -4133,26 +3603,26 @@ class InsertImageController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4133
3603
|
}
|
|
4134
3604
|
}
|
|
4135
3605
|
}
|
|
4136
|
-
__decorate$
|
|
3606
|
+
__decorate$d([
|
|
4137
3607
|
globalSlimmerRegistry.MapToComponentField()
|
|
4138
3608
|
], InsertImageController.prototype, "selectionController", void 0);
|
|
4139
|
-
__decorate$
|
|
3609
|
+
__decorate$d([
|
|
4140
3610
|
globalSlimmerRegistry.MapToComponentField()
|
|
4141
3611
|
], InsertImageController.prototype, "value", void 0);
|
|
4142
|
-
__decorate$
|
|
3612
|
+
__decorate$d([
|
|
4143
3613
|
globalSlimmerRegistry.MapToComponentField()
|
|
4144
3614
|
], InsertImageController.prototype, "valueController", void 0);
|
|
4145
|
-
__decorate$
|
|
3615
|
+
__decorate$d([
|
|
4146
3616
|
globalSlimmerRegistry.MapToComponentField()
|
|
4147
3617
|
], InsertImageController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4148
|
-
__decorate$
|
|
3618
|
+
__decorate$d([
|
|
4149
3619
|
globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
|
|
4150
3620
|
], InsertImageController.prototype, "registerObserver", null);
|
|
4151
|
-
__decorate$
|
|
3621
|
+
__decorate$d([
|
|
4152
3622
|
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
4153
3623
|
], InsertImageController.prototype, "unRegisterObserver", null);
|
|
4154
3624
|
|
|
4155
|
-
var __decorate$
|
|
3625
|
+
var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4156
3626
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4157
3627
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4158
3628
|
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;
|
|
@@ -4170,7 +3640,7 @@ class FocusController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4170
3640
|
* @param {RTEContentBlock} lastBlock - The last block of the content
|
|
4171
3641
|
*/
|
|
4172
3642
|
this.doFocusOnLastTextNode = async (lastBlock) => {
|
|
4173
|
-
this.setCaretRangeToNodeEnd(
|
|
3643
|
+
this.setCaretRangeToNodeEnd(codeBlock.stateEntityRenderingRegistry.getDOMByEntity(lastBlock.getLastNode()).firstChild);
|
|
4174
3644
|
await this.vegaRichTextEditorRenderer.getRichTextContentRef().vegaFocus();
|
|
4175
3645
|
};
|
|
4176
3646
|
}
|
|
@@ -4183,13 +3653,13 @@ class FocusController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4183
3653
|
*/
|
|
4184
3654
|
async focusOnLastTextNode(options) {
|
|
4185
3655
|
const lastBlock = this.value.blocks[this.value.blocks.length - 1];
|
|
4186
|
-
if (!(lastBlock instanceof
|
|
4187
|
-
const newTextBlock =
|
|
3656
|
+
if (!(lastBlock instanceof codeBlock.RTETextBlock) || (options === null || options === void 0 ? void 0 : options.newLine)) {
|
|
3657
|
+
const newTextBlock = codeBlock.RTETextBlock.from({
|
|
4188
3658
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
4189
3659
|
type: 'paragraph',
|
|
4190
3660
|
nodes: [{ id: createPublicApiRuntimeMetricsSlimmer.generateUUID(), type: 'text', text: '' }],
|
|
4191
3661
|
});
|
|
4192
|
-
lastBlock.parent.apply(new
|
|
3662
|
+
lastBlock.parent.apply(new codeBlock.InsertBlocksAfterAction(lastBlock, newTextBlock));
|
|
4193
3663
|
await this.valueController.flushChanges(this.value);
|
|
4194
3664
|
await this.doFocusOnLastTextNode(newTextBlock);
|
|
4195
3665
|
}
|
|
@@ -4208,20 +3678,20 @@ class FocusController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4208
3678
|
this.selectionController.setSelectionRange(range);
|
|
4209
3679
|
}
|
|
4210
3680
|
}
|
|
4211
|
-
__decorate$
|
|
3681
|
+
__decorate$c([
|
|
4212
3682
|
globalSlimmerRegistry.MapToComponentField()
|
|
4213
3683
|
], FocusController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4214
|
-
__decorate$
|
|
3684
|
+
__decorate$c([
|
|
4215
3685
|
globalSlimmerRegistry.MapToComponentField()
|
|
4216
3686
|
], FocusController.prototype, "selectionController", void 0);
|
|
4217
|
-
__decorate$
|
|
3687
|
+
__decorate$c([
|
|
4218
3688
|
globalSlimmerRegistry.MapToComponentField()
|
|
4219
3689
|
], FocusController.prototype, "valueController", void 0);
|
|
4220
|
-
__decorate$
|
|
3690
|
+
__decorate$c([
|
|
4221
3691
|
globalSlimmerRegistry.MapToComponentField()
|
|
4222
3692
|
], FocusController.prototype, "value", void 0);
|
|
4223
3693
|
|
|
4224
|
-
var __decorate$
|
|
3694
|
+
var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4225
3695
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4226
3696
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4227
3697
|
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;
|
|
@@ -4261,14 +3731,14 @@ class TextNodeColorController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4261
3731
|
return true;
|
|
4262
3732
|
}
|
|
4263
3733
|
}
|
|
4264
|
-
__decorate$
|
|
3734
|
+
__decorate$b([
|
|
4265
3735
|
globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
|
|
4266
3736
|
], TextNodeColorController.prototype, "connectedCallback", null);
|
|
4267
|
-
__decorate$
|
|
3737
|
+
__decorate$b([
|
|
4268
3738
|
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
4269
3739
|
], TextNodeColorController.prototype, "disconnectResizeObserver", null);
|
|
4270
3740
|
|
|
4271
|
-
var __decorate$
|
|
3741
|
+
var __decorate$a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4272
3742
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4273
3743
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4274
3744
|
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;
|
|
@@ -4296,9 +3766,9 @@ class InsertCompositionTextController extends globalSlimmerRegistry.VegaSlimmer
|
|
|
4296
3766
|
records.forEach((record) => {
|
|
4297
3767
|
const { target, oldValue } = record;
|
|
4298
3768
|
if (target.nodeType === Node.TEXT_NODE && target.parentElement) {
|
|
4299
|
-
const richTextNode =
|
|
3769
|
+
const richTextNode = codeBlock.stateEntityRenderingRegistry.getEntityByDOM(target.parentElement);
|
|
4300
3770
|
const newValue = target.textContent;
|
|
4301
|
-
if (richTextNode instanceof
|
|
3771
|
+
if (richTextNode instanceof codeBlock.RTETextNode) {
|
|
4302
3772
|
updateFlag = this.updateCurrentNodeText(richTextNode, newValue, oldValue);
|
|
4303
3773
|
}
|
|
4304
3774
|
else if (newValue) {
|
|
@@ -4428,7 +3898,7 @@ class InsertCompositionTextController extends globalSlimmerRegistry.VegaSlimmer
|
|
|
4428
3898
|
if (richTextNode.text !== insertText) {
|
|
4429
3899
|
const { startOffset } = this.selectionController.getCurrentRange();
|
|
4430
3900
|
const currentIsLineBreakNode = richTextNode.text === '\n';
|
|
4431
|
-
richTextNode.apply(new
|
|
3901
|
+
richTextNode.apply(new codeBlock.UpdateTextAction(insertText));
|
|
4432
3902
|
if (currentIsLineBreakNode) {
|
|
4433
3903
|
this.appendLineBreakNode(richTextNode);
|
|
4434
3904
|
}
|
|
@@ -4456,11 +3926,11 @@ class InsertCompositionTextController extends globalSlimmerRegistry.VegaSlimmer
|
|
|
4456
3926
|
* @returns {string} The result text.
|
|
4457
3927
|
*/
|
|
4458
3928
|
removeZeroWidthSpace(text) {
|
|
4459
|
-
if (text.startsWith(
|
|
4460
|
-
return text.slice(
|
|
3929
|
+
if (text.startsWith(codeBlock.ZERO_WIDTH_SPACE)) {
|
|
3930
|
+
return text.slice(codeBlock.ZERO_WIDTH_SPACE.length);
|
|
4461
3931
|
}
|
|
4462
|
-
else if (text.endsWith(
|
|
4463
|
-
return text.slice(0, text.length -
|
|
3932
|
+
else if (text.endsWith(codeBlock.ZERO_WIDTH_SPACE)) {
|
|
3933
|
+
return text.slice(0, text.length - codeBlock.ZERO_WIDTH_SPACE.length);
|
|
4464
3934
|
}
|
|
4465
3935
|
return text;
|
|
4466
3936
|
}
|
|
@@ -4476,35 +3946,35 @@ class InsertCompositionTextController extends globalSlimmerRegistry.VegaSlimmer
|
|
|
4476
3946
|
this.editableElementRef.dispatchEvent(inputEvent);
|
|
4477
3947
|
}
|
|
4478
3948
|
}
|
|
4479
|
-
__decorate$
|
|
3949
|
+
__decorate$a([
|
|
4480
3950
|
globalSlimmerRegistry.MapToComponentField()
|
|
4481
3951
|
], InsertCompositionTextController.prototype, "selectionController", void 0);
|
|
4482
|
-
__decorate$
|
|
3952
|
+
__decorate$a([
|
|
4483
3953
|
globalSlimmerRegistry.MapToComponentField()
|
|
4484
3954
|
], InsertCompositionTextController.prototype, "host", void 0);
|
|
4485
|
-
__decorate$
|
|
3955
|
+
__decorate$a([
|
|
4486
3956
|
globalSlimmerRegistry.MapToComponentField()
|
|
4487
3957
|
], InsertCompositionTextController.prototype, "value", void 0);
|
|
4488
|
-
__decorate$
|
|
3958
|
+
__decorate$a([
|
|
4489
3959
|
globalSlimmerRegistry.MapToComponentField()
|
|
4490
3960
|
], InsertCompositionTextController.prototype, "valueController", void 0);
|
|
4491
|
-
__decorate$
|
|
3961
|
+
__decorate$a([
|
|
4492
3962
|
globalSlimmerRegistry.MapToComponentField()
|
|
4493
3963
|
], InsertCompositionTextController.prototype, "userInputController", void 0);
|
|
4494
|
-
__decorate$
|
|
3964
|
+
__decorate$a([
|
|
4495
3965
|
globalSlimmerRegistry.MapToComponentField()
|
|
4496
3966
|
], InsertCompositionTextController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4497
|
-
__decorate$
|
|
3967
|
+
__decorate$a([
|
|
4498
3968
|
globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
|
|
4499
3969
|
], InsertCompositionTextController.prototype, "addCompositionTextEventListener", null);
|
|
4500
|
-
__decorate$
|
|
3970
|
+
__decorate$a([
|
|
4501
3971
|
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
4502
3972
|
], InsertCompositionTextController.prototype, "removeCompositionTextEventListener", null);
|
|
4503
|
-
__decorate$
|
|
3973
|
+
__decorate$a([
|
|
4504
3974
|
globalSlimmerRegistry.MapToComponentMethod('componentDidRender')
|
|
4505
3975
|
], InsertCompositionTextController.prototype, "reConnectObserver", null);
|
|
4506
3976
|
|
|
4507
|
-
var __decorate$
|
|
3977
|
+
var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4508
3978
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4509
3979
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4510
3980
|
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;
|
|
@@ -4562,7 +4032,10 @@ class DeleteSelectedNodesController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4562
4032
|
if (selectedNodes.length > 1) {
|
|
4563
4033
|
// 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
|
|
4564
4034
|
const shouldRemovedItems = selectedNodes.filter((item) => {
|
|
4565
|
-
if (item
|
|
4035
|
+
if (item instanceof codeBlock.RTECodeBlockNode) {
|
|
4036
|
+
return item !== startNode;
|
|
4037
|
+
}
|
|
4038
|
+
else if (item.type !== 'IMAGE') {
|
|
4566
4039
|
return item !== startNode && item !== endNode;
|
|
4567
4040
|
}
|
|
4568
4041
|
else {
|
|
@@ -4570,30 +4043,37 @@ class DeleteSelectedNodesController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4570
4043
|
}
|
|
4571
4044
|
});
|
|
4572
4045
|
shouldRemovedItems.forEach((item) => {
|
|
4573
|
-
item.parentBlock.apply(new
|
|
4046
|
+
item.parentBlock.apply(new codeBlock.RemoveChildAction(item));
|
|
4574
4047
|
});
|
|
4575
4048
|
}
|
|
4576
4049
|
this.removeRangeStartAndEndSelectedText();
|
|
4577
4050
|
/**
|
|
4578
4051
|
* 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.
|
|
4579
|
-
* 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
|
|
4052
|
+
* 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.
|
|
4053
|
+
* the code block node should do the same logic.
|
|
4580
4054
|
*/
|
|
4581
|
-
if (startNode instanceof
|
|
4055
|
+
if (startNode instanceof codeBlock.RTEImageNode &&
|
|
4582
4056
|
startOffset !== 1 &&
|
|
4583
4057
|
(endNode !== startNode || endOffset !== 0)) {
|
|
4584
4058
|
// the image block will be deleted when the image is the only item
|
|
4585
4059
|
if (startNode.parentBlock.nodes.length === 1) {
|
|
4586
4060
|
const paragraph = this.createEmptyParagraph();
|
|
4587
|
-
startNode.parentBlock.parent.apply(new
|
|
4588
|
-
startNode.parentBlock.apply(new
|
|
4061
|
+
startNode.parentBlock.parent.apply(new codeBlock.InsertBlocksBeforeAction(startNode.parentBlock, paragraph));
|
|
4062
|
+
startNode.parentBlock.apply(new codeBlock.RemoveChildAction(startNode));
|
|
4589
4063
|
return paragraph.nodes[0];
|
|
4590
4064
|
}
|
|
4591
4065
|
else if (startNode === startNode.parentBlock.nodes[0]) {
|
|
4592
4066
|
// the start node should be the next image item if the image is first item
|
|
4593
|
-
startNode.parentBlock.apply(new
|
|
4067
|
+
startNode.parentBlock.apply(new codeBlock.RemoveChildAction(startNode));
|
|
4594
4068
|
return startNode.parentBlock.nodes[0];
|
|
4595
4069
|
}
|
|
4596
4070
|
}
|
|
4071
|
+
else if (startNode instanceof codeBlock.RTECodeBlockNode) {
|
|
4072
|
+
const paragraph = this.createEmptyParagraph();
|
|
4073
|
+
startNode.parentBlock.parent.apply(new codeBlock.InsertBlocksBeforeAction(startNode.parentBlock, paragraph));
|
|
4074
|
+
startNode.parentBlock.apply(new codeBlock.RemoveChildAction(startNode));
|
|
4075
|
+
return paragraph.nodes[0];
|
|
4076
|
+
}
|
|
4597
4077
|
return startNode;
|
|
4598
4078
|
}
|
|
4599
4079
|
/**
|
|
@@ -4602,10 +4082,10 @@ class DeleteSelectedNodesController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4602
4082
|
removeRangeStartAndEndSelectedText() {
|
|
4603
4083
|
const selectedNodes = this.selectionController.getSelectedNodes();
|
|
4604
4084
|
const currentRange = this.selectionController.getCurrentRange();
|
|
4605
|
-
if (selectedNodes[0] instanceof
|
|
4085
|
+
if (selectedNodes[0] instanceof codeBlock.RTETextNode) {
|
|
4606
4086
|
selectedNodes[0].apply(new ReplaceSelectedTextAction('', currentRange));
|
|
4607
4087
|
}
|
|
4608
|
-
if (selectedNodes.length > 1 && selectedNodes[selectedNodes.length - 1] instanceof
|
|
4088
|
+
if (selectedNodes.length > 1 && selectedNodes[selectedNodes.length - 1] instanceof codeBlock.RTETextNode) {
|
|
4609
4089
|
selectedNodes[selectedNodes.length - 1].apply(new ReplaceSelectedTextAction('', currentRange));
|
|
4610
4090
|
}
|
|
4611
4091
|
}
|
|
@@ -4615,9 +4095,9 @@ class DeleteSelectedNodesController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4615
4095
|
* @returns {RTETextBlock} An empty paragraph with a unique identifier and a text node appended to it.
|
|
4616
4096
|
*/
|
|
4617
4097
|
createEmptyParagraph() {
|
|
4618
|
-
const paragraph = new
|
|
4619
|
-
const textNode = new
|
|
4620
|
-
paragraph.apply(new
|
|
4098
|
+
const paragraph = new codeBlock.RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
4099
|
+
const textNode = new codeBlock.RTETextNode(`${paragraph.id}1`, '', paragraph);
|
|
4100
|
+
paragraph.apply(new codeBlock.AppendChildNodesAction([textNode]));
|
|
4621
4101
|
return paragraph;
|
|
4622
4102
|
}
|
|
4623
4103
|
/**
|
|
@@ -4635,20 +4115,22 @@ class DeleteSelectedNodesController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4635
4115
|
if (startRTENode && startRTENode.parentBlock && endRTENode && endRTENode.parentBlock) {
|
|
4636
4116
|
const endBlock = endRTENode.parentBlock;
|
|
4637
4117
|
if (this.shouldMergeTextNode(startRTENode, endRTENode)) {
|
|
4638
|
-
startRTENode.apply(new
|
|
4118
|
+
startRTENode.apply(new codeBlock.UpdateTextAction(startRTENode.text + endRTENode.text));
|
|
4639
4119
|
if (startRTENode.parentBlock === endRTENode.parentBlock) {
|
|
4640
|
-
startRTENode.parentBlock.apply(new
|
|
4120
|
+
startRTENode.parentBlock.apply(new codeBlock.RemoveChildAction(endRTENode));
|
|
4641
4121
|
}
|
|
4642
4122
|
else {
|
|
4643
|
-
endRTENode.parentBlock.apply(new
|
|
4123
|
+
endRTENode.parentBlock.apply(new codeBlock.RemoveChildAction(endRTENode.parentBlock.nodes[0]));
|
|
4644
4124
|
}
|
|
4645
4125
|
}
|
|
4646
|
-
if (startRTENode
|
|
4647
|
-
|
|
4126
|
+
if (startRTENode instanceof codeBlock.RTETextNode &&
|
|
4127
|
+
endRTENode instanceof codeBlock.RTETextNode &&
|
|
4128
|
+
startRTENode.parentBlock !== endRTENode.parentBlock) {
|
|
4129
|
+
startRTENode.parentBlock.apply(new codeBlock.AppendChildNodesAction(endBlock.nodes));
|
|
4648
4130
|
endBlock.nodes = [];
|
|
4649
4131
|
}
|
|
4650
4132
|
if (endBlock.nodes.length < 1) {
|
|
4651
|
-
endBlock.parent.apply(new
|
|
4133
|
+
endBlock.parent.apply(new codeBlock.RemoveChildAction(endBlock));
|
|
4652
4134
|
}
|
|
4653
4135
|
}
|
|
4654
4136
|
}
|
|
@@ -4664,26 +4146,28 @@ class DeleteSelectedNodesController extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
4664
4146
|
shouldMergeTextNode(nodeA, nodeB) {
|
|
4665
4147
|
const { annotations: annotationsA } = nodeA.toJSON();
|
|
4666
4148
|
const { annotations: annotationsB } = nodeB.toJSON();
|
|
4667
|
-
return
|
|
4149
|
+
return (nodeA instanceof codeBlock.RTETextNode &&
|
|
4150
|
+
nodeB instanceof codeBlock.RTETextNode &&
|
|
4151
|
+
JSON.stringify(annotationsA) === JSON.stringify(annotationsB));
|
|
4668
4152
|
}
|
|
4669
4153
|
}
|
|
4670
|
-
__decorate$
|
|
4154
|
+
__decorate$9([
|
|
4671
4155
|
globalSlimmerRegistry.MapToComponentField()
|
|
4672
4156
|
], DeleteSelectedNodesController.prototype, "host", void 0);
|
|
4673
|
-
__decorate$
|
|
4157
|
+
__decorate$9([
|
|
4674
4158
|
globalSlimmerRegistry.MapToComponentField()
|
|
4675
4159
|
], DeleteSelectedNodesController.prototype, "selectionController", void 0);
|
|
4676
|
-
__decorate$
|
|
4160
|
+
__decorate$9([
|
|
4677
4161
|
globalSlimmerRegistry.MapToComponentField()
|
|
4678
4162
|
], DeleteSelectedNodesController.prototype, "value", void 0);
|
|
4679
|
-
__decorate$
|
|
4163
|
+
__decorate$9([
|
|
4680
4164
|
globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
|
|
4681
4165
|
], DeleteSelectedNodesController.prototype, "addDeleteObserver", null);
|
|
4682
|
-
__decorate$
|
|
4166
|
+
__decorate$9([
|
|
4683
4167
|
globalSlimmerRegistry.MapToComponentMethod('disconnectedCallback')
|
|
4684
4168
|
], DeleteSelectedNodesController.prototype, "removeDeleteObserver", null);
|
|
4685
4169
|
|
|
4686
|
-
var __decorate$
|
|
4170
|
+
var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4687
4171
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4688
4172
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4689
4173
|
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;
|
|
@@ -4699,7 +4183,7 @@ class HistoryController extends keyboardManagerSlimmer.KeyboardManagerSlimmer {
|
|
|
4699
4183
|
this.undoStack = [];
|
|
4700
4184
|
this.registerHistoryDelay = 300;
|
|
4701
4185
|
this.registerHistoryDebounced = timer.debounce(() => {
|
|
4702
|
-
this.internalRegisterHistory(new RTEEditorState(this.value, new RTESelectionState(this.selectionController.getCurrentRange())));
|
|
4186
|
+
this.internalRegisterHistory(new RTEEditorState(this.value, new selectionController.RTESelectionState(this.selectionController.getCurrentRange())));
|
|
4703
4187
|
}, this.registerHistoryDelay, this);
|
|
4704
4188
|
}
|
|
4705
4189
|
/**
|
|
@@ -4707,7 +4191,7 @@ class HistoryController extends keyboardManagerSlimmer.KeyboardManagerSlimmer {
|
|
|
4707
4191
|
*/
|
|
4708
4192
|
registerInitState() {
|
|
4709
4193
|
if (this.value) {
|
|
4710
|
-
this.internalRegisterHistory(new RTEEditorState(this.value, new RTESelectionState(this.selectionController.getCurrentRange())));
|
|
4194
|
+
this.internalRegisterHistory(new RTEEditorState(this.value, new selectionController.RTESelectionState(this.selectionController.getCurrentRange())));
|
|
4711
4195
|
}
|
|
4712
4196
|
}
|
|
4713
4197
|
/**
|
|
@@ -4797,25 +4281,166 @@ class HistoryController extends keyboardManagerSlimmer.KeyboardManagerSlimmer {
|
|
|
4797
4281
|
];
|
|
4798
4282
|
}
|
|
4799
4283
|
}
|
|
4800
|
-
__decorate$
|
|
4284
|
+
__decorate$8([
|
|
4801
4285
|
globalSlimmerRegistry.MapToComponentField()
|
|
4802
4286
|
], HistoryController.prototype, "host", void 0);
|
|
4803
|
-
__decorate$
|
|
4287
|
+
__decorate$8([
|
|
4804
4288
|
globalSlimmerRegistry.MapToComponentField()
|
|
4805
4289
|
], HistoryController.prototype, "vegaRichTextEditorRenderer", void 0);
|
|
4806
|
-
__decorate$
|
|
4290
|
+
__decorate$8([
|
|
4807
4291
|
globalSlimmerRegistry.MapToComponentField()
|
|
4808
4292
|
], HistoryController.prototype, "valueController", void 0);
|
|
4809
|
-
__decorate$
|
|
4293
|
+
__decorate$8([
|
|
4810
4294
|
globalSlimmerRegistry.MapToComponentField()
|
|
4811
4295
|
], HistoryController.prototype, "value", void 0);
|
|
4812
|
-
__decorate$
|
|
4296
|
+
__decorate$8([
|
|
4813
4297
|
globalSlimmerRegistry.MapToComponentField()
|
|
4814
4298
|
], HistoryController.prototype, "selectionController", void 0);
|
|
4815
|
-
__decorate$
|
|
4299
|
+
__decorate$8([
|
|
4816
4300
|
globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
|
|
4817
4301
|
], HistoryController.prototype, "registerInitState", null);
|
|
4818
4302
|
|
|
4303
|
+
const rectangleCode = {
|
|
4304
|
+
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="M320.1 175L384.1 239C394.3 248.4 394.3 263.6 384.1 272.1L320.1 336.1C311.6 346.3 296.4 346.3 287 336.1C277.7 327.6 277.7 312.4 287 303L334.1 256L287 208.1C277.7 199.6 277.7 184.4 287 175C296.4 165.7 311.6 165.7 320.1 175V175zM177.9 256L224.1 303C234.3 312.4 234.3 327.6 224.1 336.1C215.6 346.3 200.4 346.3 191 336.1L127 272.1C117.7 263.6 117.7 248.4 127 239L191 175C200.4 165.7 215.6 165.7 224.1 175C234.3 184.4 234.3 199.6 224.1 208.1L177.9 256zM448 32C483.3 32 512 60.65 512 96V416C512 451.3 483.3 480 448 480H64C28.65 480 0 451.3 0 416V96C0 60.65 28.65 32 64 32H448zM448 80H64C55.16 80 48 87.16 48 96V416C48 424.8 55.16 432 64 432H448C456.8 432 464 424.8 464 416V96C464 87.16 456.8 80 448 80z"/></svg>`,
|
|
4305
|
+
};
|
|
4306
|
+
|
|
4307
|
+
/**
|
|
4308
|
+
* Transform the selected blocks to a code block.
|
|
4309
|
+
*
|
|
4310
|
+
* @example firstBlock.parent.apply(new TransformToCodeBlockAction(selectedBlocks))
|
|
4311
|
+
*/
|
|
4312
|
+
class TransformToCodeBlockAction extends codeBlock.ModifyContentAction {
|
|
4313
|
+
constructor(selectedBlocks) {
|
|
4314
|
+
super();
|
|
4315
|
+
this.type = codeBlock.ModifyContentActionType.TRANSFORM_TO_CODE_BLOCK;
|
|
4316
|
+
this.selectedBlocks = selectedBlocks;
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
|
|
4320
|
+
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
4321
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4322
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4323
|
+
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;
|
|
4324
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4325
|
+
};
|
|
4326
|
+
/**
|
|
4327
|
+
* The code block toolbar button slimmer.
|
|
4328
|
+
*/
|
|
4329
|
+
class CodeBlockToolbarButtonSlimmer extends imageAnnotationAction.ToolbarButtonSlimmer {
|
|
4330
|
+
constructor() {
|
|
4331
|
+
super({
|
|
4332
|
+
icon: 'rectangle-code',
|
|
4333
|
+
tooltip: { text: 'Code Block' },
|
|
4334
|
+
});
|
|
4335
|
+
}
|
|
4336
|
+
/**
|
|
4337
|
+
* The selected blocks should convert to a code block.
|
|
4338
|
+
*/
|
|
4339
|
+
onClick() {
|
|
4340
|
+
const selected = this.isSelected();
|
|
4341
|
+
if (!selected) {
|
|
4342
|
+
const selectedBlocks = this.selectionController.getSelectedBlocks();
|
|
4343
|
+
const parentBlock = selectedBlocks[0].parent;
|
|
4344
|
+
const transformToCodeBlockAction = new TransformToCodeBlockAction(selectedBlocks);
|
|
4345
|
+
parentBlock.apply(transformToCodeBlockAction);
|
|
4346
|
+
void this.valueController.flushChanges(this.value);
|
|
4347
|
+
this.selectionController.enqueueSelectionRangeFutureState(transformToCodeBlockAction.newCodeBlock.nodes[0], 0);
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
/**
|
|
4351
|
+
* The button will be selected if the selected blocks all code block.
|
|
4352
|
+
*
|
|
4353
|
+
* @returns {boolean} - The code block should selected or not.
|
|
4354
|
+
*/
|
|
4355
|
+
isSelected() {
|
|
4356
|
+
const selectBlocks = this.selectionController.getSelectedBlocks();
|
|
4357
|
+
if (selectBlocks.length && selectBlocks.every((block) => block.type === 'code-block')) {
|
|
4358
|
+
return true;
|
|
4359
|
+
}
|
|
4360
|
+
return false;
|
|
4361
|
+
}
|
|
4362
|
+
isDisabled() {
|
|
4363
|
+
const selectBlocks = this.selectionController.getSelectedBlocks();
|
|
4364
|
+
return (super.isDisabled() ||
|
|
4365
|
+
selectBlocks.some((block) => block.type === 'image' || block.type === 'list-item'));
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
(() => {
|
|
4369
|
+
internalIconManager.VegaInternalIconManager.register({ 'rectangle-code': rectangleCode });
|
|
4370
|
+
})();
|
|
4371
|
+
__decorate$7([
|
|
4372
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
4373
|
+
], CodeBlockToolbarButtonSlimmer.prototype, "selectionController", void 0);
|
|
4374
|
+
__decorate$7([
|
|
4375
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
4376
|
+
], CodeBlockToolbarButtonSlimmer.prototype, "valueController", void 0);
|
|
4377
|
+
__decorate$7([
|
|
4378
|
+
globalSlimmerRegistry.MapToComponentField()
|
|
4379
|
+
], CodeBlockToolbarButtonSlimmer.prototype, "value", void 0);
|
|
4380
|
+
|
|
4381
|
+
/**
|
|
4382
|
+
* The rich text internal code block selection controller.
|
|
4383
|
+
*/
|
|
4384
|
+
class InternalCodeBlockSelectionController extends selectionController.AutoRunWhenReRenderTaskQueueSlimmer {
|
|
4385
|
+
constructor() {
|
|
4386
|
+
super(1);
|
|
4387
|
+
this.focusNodeOffset = 0;
|
|
4388
|
+
/**
|
|
4389
|
+
* The method invoke after the component re-render.
|
|
4390
|
+
*/
|
|
4391
|
+
this.doTask = async () => {
|
|
4392
|
+
await this.focusTheCodeBlock(this.shouldFocusNode);
|
|
4393
|
+
};
|
|
4394
|
+
}
|
|
4395
|
+
/**
|
|
4396
|
+
* Update the internal code block selection.
|
|
4397
|
+
*
|
|
4398
|
+
* @param {RTECodeBlockNode} startNode - The internal code block node DTO.
|
|
4399
|
+
* @param {number} startOffset - The content offset.
|
|
4400
|
+
* @param {boolean} immediatelyRun - Whether to invoke the method immediately.
|
|
4401
|
+
*/
|
|
4402
|
+
enqueueSelectionRangeFutureState(startNode, startOffset, immediatelyRun) {
|
|
4403
|
+
this.shouldFocusNode = startNode;
|
|
4404
|
+
this.focusNodeOffset = startOffset;
|
|
4405
|
+
super.enqueueTheTaskIntoQueue(immediatelyRun);
|
|
4406
|
+
}
|
|
4407
|
+
/**
|
|
4408
|
+
* Check the code block is actually selected or not. Because the Code block is a shadow dom, so can't detect the content selected state.
|
|
4409
|
+
* We add two placeholder spans at the begin and end position, we could check the placeholder spans selected state to make sure the code block is selected or not.
|
|
4410
|
+
*
|
|
4411
|
+
*
|
|
4412
|
+
* @example
|
|
4413
|
+
* <div>
|
|
4414
|
+
* <span></span>
|
|
4415
|
+
* <vega-code-block></vega-code-block>
|
|
4416
|
+
* <span><span>
|
|
4417
|
+
* </div>
|
|
4418
|
+
* @param {RTECodeBlock} codeBlock - The code block DTO.
|
|
4419
|
+
* @param {Range} range - The range instance.
|
|
4420
|
+
* @returns {boolean} - The boolean result.
|
|
4421
|
+
*/
|
|
4422
|
+
isCodeBlockSelected(codeBlock$1, range) {
|
|
4423
|
+
const codeBlockNode = codeBlock$1.nodes[0];
|
|
4424
|
+
const entityDom = codeBlock.stateEntityRenderingRegistry.getDOMByEntity(codeBlockNode);
|
|
4425
|
+
return (codeBlock$1.isSelected() ||
|
|
4426
|
+
(entityDom &&
|
|
4427
|
+
range.intersectsNode(entityDom.nextSibling) &&
|
|
4428
|
+
range.intersectsNode(entityDom.previousSibling)));
|
|
4429
|
+
}
|
|
4430
|
+
/**
|
|
4431
|
+
* Focus the code block component.
|
|
4432
|
+
*
|
|
4433
|
+
* @param {RTECodeBlockNode} node - The code block node DTO.
|
|
4434
|
+
*/
|
|
4435
|
+
async focusTheCodeBlock(node) {
|
|
4436
|
+
await Promise.resolve();
|
|
4437
|
+
const entityDom = codeBlock.stateEntityRenderingRegistry.getDOMByEntity(node);
|
|
4438
|
+
if (entityDom) {
|
|
4439
|
+
void entityDom.doFocus();
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
|
|
4819
4444
|
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:3px;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));cursor:not-allowed}: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.disabled vega-rich-text-content{pointer-events:none;opacity:0.35}: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:3px;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;justify-content:center;align-items:center;margin-left:6px}.toolbar-btn-group .toolbar-btn-color-preview-box.disabled{opacity:0.35}.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}";
|
|
4820
4445
|
|
|
4821
4446
|
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -4854,7 +4479,7 @@ const VegaRichTextEditor = class {
|
|
|
4854
4479
|
this.changeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaRichTextEditor, domNodeSubjectFactory.VegaChange);
|
|
4855
4480
|
this.vegaRichTextEditorRenderer = new VegaRichTextEditorRenderer();
|
|
4856
4481
|
this.valueController = new ValueController();
|
|
4857
|
-
this.selectionController = new SelectionController();
|
|
4482
|
+
this.selectionController = new selectionController.SelectionController();
|
|
4858
4483
|
this.focusController = new FocusController();
|
|
4859
4484
|
this.darkModeStateControllerSlimmer = new darkModeStateControllerSlimmer.DarkModeStateControllerSlimmer();
|
|
4860
4485
|
this.toolbarRenderer = new ToolbarRenderer();
|
|
@@ -4872,6 +4497,7 @@ const VegaRichTextEditor = class {
|
|
|
4872
4497
|
this.lessIndentToolbarButtonSlimmer = new LessIndentToolbarButtonSlimmer();
|
|
4873
4498
|
this.bulletsNumbersToolbarButtonSlimmer = new BulletsNumbersToolbarButtonSlimmer();
|
|
4874
4499
|
this.horizontalAlignmentToolbarButtonSlimmer = new HorizontalAlignmentToolbarButtonSlimmer();
|
|
4500
|
+
this.codeBlockToolbarButtonSlimmer = new CodeBlockToolbarButtonSlimmer();
|
|
4875
4501
|
this.placeholderNotifySlimmer = subStateNotifySlimmer.createSubStateNotifySlimmer(VegaRichTextEditor, 'placeholder', 'watchPlaceholder');
|
|
4876
4502
|
this.disabledNotifySlimmer = subStateNotifySlimmer.createSubStateNotifySlimmer(VegaRichTextEditor, 'richTextContentEditable', 'watchRichTextContentEditable');
|
|
4877
4503
|
this.richTextContentController = new RichTextContentController(this);
|
|
@@ -4883,6 +4509,7 @@ const VegaRichTextEditor = class {
|
|
|
4883
4509
|
this.textNodeColorController = new TextNodeColorController();
|
|
4884
4510
|
this.deleteSelectedNodesController = new DeleteSelectedNodesController();
|
|
4885
4511
|
this.historyController = new HistoryController();
|
|
4512
|
+
this.internalCodeBlockSelectionController = new InternalCodeBlockSelectionController();
|
|
4886
4513
|
this.richTextContentEditable = true;
|
|
4887
4514
|
this.selectionMap = new Map();
|
|
4888
4515
|
this.isInDarkMode = darkModeStyleController.VegaInternalThemeManager.isDarkMode();
|
|
@@ -5077,6 +4704,9 @@ __decorate$6([
|
|
|
5077
4704
|
__decorate$6([
|
|
5078
4705
|
globalSlimmerRegistry.InjectVegaSlimmer()
|
|
5079
4706
|
], VegaRichTextEditor.prototype, "horizontalAlignmentToolbarButtonSlimmer", void 0);
|
|
4707
|
+
__decorate$6([
|
|
4708
|
+
globalSlimmerRegistry.InjectVegaSlimmer()
|
|
4709
|
+
], VegaRichTextEditor.prototype, "codeBlockToolbarButtonSlimmer", void 0);
|
|
5080
4710
|
__decorate$6([
|
|
5081
4711
|
globalSlimmerRegistry.InjectVegaSlimmer()
|
|
5082
4712
|
], VegaRichTextEditor.prototype, "placeholderNotifySlimmer", void 0);
|
|
@@ -5110,6 +4740,9 @@ __decorate$6([
|
|
|
5110
4740
|
__decorate$6([
|
|
5111
4741
|
globalSlimmerRegistry.InjectVegaSlimmer()
|
|
5112
4742
|
], VegaRichTextEditor.prototype, "historyController", void 0);
|
|
4743
|
+
__decorate$6([
|
|
4744
|
+
globalSlimmerRegistry.InjectVegaSlimmer()
|
|
4745
|
+
], VegaRichTextEditor.prototype, "internalCodeBlockSelectionController", void 0);
|
|
5113
4746
|
VegaRichTextEditor.style = vegaRichTextEditorCss;
|
|
5114
4747
|
|
|
5115
4748
|
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|