@heartlandone/vega 2.49.1 → 2.50.0-RTE-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-65622aeb.js → app-globals-8e811cac.js} +6 -6
- package/dist/cjs/{child-nodes-event-prevent-slimmer-cc193ee1.js → child-nodes-event-prevent-slimmer-26ecfb15.js} +1 -1
- package/dist/cjs/{content-state-6a48bcb5.js → code-block-4cd8bccd.js} +1166 -1131
- package/dist/cjs/content-state-6cb98931.js +2496 -0
- package/dist/cjs/{design-token-cba4222e.js → design-token-8b48cb59.js} +1 -1
- package/dist/cjs/{element-appender-slimmer-4a26ecb2.js → element-appender-slimmer-d6b975e6.js} +3 -3
- package/dist/cjs/{event-emit-slimmer-8247249c.js → event-emit-slimmer-ee7a8c06.js} +1 -1
- package/dist/cjs/{form-field-controller-slimmer-4b0af5bc.js → form-field-controller-slimmer-88cbb139.js} +4 -4
- package/dist/cjs/{image-annotation-action-9c2b9c8e.js → image-annotation-action-f36b1a72.js} +65 -35
- package/dist/cjs/{index-c4dec3aa.js → index-4dd54e6b.js} +1 -1
- package/dist/cjs/{index-09acd3c9.js → index-7700600c.js} +9 -0
- package/dist/cjs/index.cjs.js +17 -16
- package/dist/cjs/{internal-vega-event-manager-c9948b59.js → internal-vega-event-manager-58afcde7.js} +1 -0
- package/dist/cjs/loader.cjs.js +11 -9
- package/dist/cjs/{public-rules-10ec636d.js → public-rules-555271e0.js} +8 -6
- package/dist/cjs/{responsive-format-facade-263d49f6.js → responsive-format-facade-8ce41c8a.js} +3 -3
- package/dist/cjs/{rich-text-editor-required-rule-5faded94.js → rich-text-editor-required-rule-d1b38bf7.js} +1 -1
- package/dist/cjs/selection-controller-828990cc.js +765 -0
- package/dist/cjs/string-39438062.js +24 -0
- package/dist/cjs/{string-input-formatter-slimmer-50322824.js → string-input-formatter-slimmer-9e7d7ce2.js} +2 -2
- package/dist/cjs/{style-formatter-ae0ef7fc.js → style-formatter-2294d77f.js} +1 -1
- package/dist/cjs/{sub-state-notify-slimmer-7f437b19.js → sub-state-notify-slimmer-f3ee01b7.js} +1 -1
- package/dist/cjs/{sub-state-observer-slimmer-e90362cd.js → sub-state-observer-slimmer-e1a00b74.js} +1 -1
- 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/vega-accordion.cjs.entry.js +11 -9
- package/dist/cjs/vega-app-footer.cjs.entry.js +1 -1
- package/dist/cjs/vega-app-header-button.cjs.entry.js +12 -10
- package/dist/cjs/vega-backdrop.cjs.entry.js +1 -1
- package/dist/cjs/vega-banner.cjs.entry.js +3 -3
- package/dist/cjs/vega-bar-chart.cjs.entry.js +1 -1
- package/dist/cjs/vega-box.cjs.entry.js +11 -9
- package/dist/cjs/vega-brand-logo.cjs.entry.js +1 -1
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +4 -4
- package/dist/cjs/vega-button-circle.cjs.entry.js +12 -10
- package/dist/cjs/vega-button-group_2.cjs.entry.js +7 -7
- package/dist/cjs/vega-button-link.cjs.entry.js +4 -4
- package/dist/cjs/vega-button.cjs.entry.js +11 -9
- package/dist/cjs/vega-calendar_3.cjs.entry.js +9 -9
- package/dist/cjs/vega-card.cjs.entry.js +10 -8
- package/dist/cjs/vega-carousel.cjs.entry.js +10 -8
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +9 -9
- package/dist/cjs/vega-chip.cjs.entry.js +12 -10
- package/dist/cjs/vega-code-block.cjs.entry.js +4073 -0
- package/dist/cjs/vega-color-picker.cjs.entry.js +8 -8
- package/dist/cjs/vega-combo-box.cjs.entry.js +9 -9
- package/dist/cjs/vega-counter-badge.cjs.entry.js +1 -1
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +17 -16
- package/dist/cjs/vega-dialog_2.cjs.entry.js +12 -10
- package/dist/cjs/vega-divider.cjs.entry.js +10 -8
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +15 -13
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-field-error.cjs.entry.js +1 -1
- package/dist/cjs/vega-field-label.cjs.entry.js +3 -3
- package/dist/cjs/vega-file-uploader.cjs.entry.js +9 -9
- package/dist/cjs/vega-flag-icon.cjs.entry.js +10 -8
- package/dist/cjs/vega-flex.cjs.entry.js +11 -9
- package/dist/cjs/vega-font.cjs.entry.js +10 -8
- package/dist/cjs/vega-form.cjs.entry.js +10 -10
- package/dist/cjs/vega-grid.cjs.entry.js +10 -8
- package/dist/cjs/vega-hint.cjs.entry.js +1 -1
- package/dist/cjs/vega-icon.cjs.entry.js +10 -8
- package/dist/cjs/vega-image-uploader.cjs.entry.js +14 -13
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +9 -9
- package/dist/cjs/vega-input-numeric.cjs.entry.js +10 -10
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +12 -11
- package/dist/cjs/vega-input-range.cjs.entry.js +10 -10
- package/dist/cjs/vega-input-select.cjs.entry.js +19 -18
- package/dist/cjs/vega-input.cjs.entry.js +10 -10
- package/dist/cjs/{vega-internal-event-id-bfea9b93.js → vega-internal-event-id-62371952.js} +2 -0
- package/dist/cjs/vega-item-toggle.cjs.entry.js +3 -3
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +13 -11
- package/dist/cjs/vega-line-chart.cjs.entry.js +1 -1
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +9 -7
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +1 -1
- package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +4 -4
- package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +4 -4
- package/dist/cjs/vega-pagination.cjs.entry.js +12 -10
- package/dist/cjs/vega-pie-chart.cjs.entry.js +1 -1
- package/dist/cjs/vega-popover_2.cjs.entry.js +11 -9
- package/dist/cjs/vega-progress-tracker.cjs.entry.js +3 -3
- package/dist/cjs/vega-radio_2.cjs.entry.js +9 -9
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +311 -137
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +1225 -2502
- package/dist/cjs/vega-section-title.cjs.entry.js +1 -1
- package/dist/cjs/vega-segment-control.cjs.entry.js +3 -3
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +14 -13
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +10 -10
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +12 -10
- package/dist/cjs/vega-signature-capture.cjs.entry.js +14 -13
- package/dist/cjs/{vega-skeleton-loader-controller-db868c98.js → vega-skeleton-loader-controller-83e05b6c.js} +1 -1
- package/dist/cjs/vega-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/vega-slot-container.cjs.entry.js +1 -1
- package/dist/cjs/vega-stepper.cjs.entry.js +9 -9
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-table_8.cjs.entry.js +14 -12
- package/dist/cjs/vega-text.cjs.entry.js +1 -1
- package/dist/cjs/vega-textarea.cjs.entry.js +9 -9
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +15 -14
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +8 -8
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +10 -8
- package/dist/cjs/vega.cjs.js +11 -9
- package/dist/collection/collection-manifest.json +7 -1
- package/dist/collection/components/vega-code-block/assets/copy.js +3 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/code-highlight-parser.abstract.js +62 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/default-code-highlight-parse-controller.js +48 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.js +99 -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 +255 -0
- package/dist/collection/components/vega-code-block/slimmers/controllers/vega-code-block-selection-controller.js +266 -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 +123 -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/types.js +10 -0
- package/dist/collection/components/vega-code-block/vega-code-block.css +158 -0
- package/dist/collection/components/vega-code-block/vega-code-block.js +399 -0
- package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +5 -5
- 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 +60 -5
- package/dist/collection/components/vega-rich-text-editor/assets/file-code.js +3 -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/action-handle-strategy.abstract.js +24 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-horizontal-alignment-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-indent-strategy.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-text-style-strategy.js +1 -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/apply-annotation-strategies/node-update-annotation-map-strategy.js +14 -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/custom-style-annotation-action.js +20 -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/annotations/block-annotation.abstract.js +1 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/bold-annotation.js +13 -5
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/clear-formatting-annotation.js +2 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/code-annotation.js +14 -9
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/common-annotation.abstract.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/custom-attribute-annotation.js +65 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/custom-class-annotation.js +54 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/custom-style-annotation.js +57 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.js +26 -10
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/image-annotation.js +16 -7
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/indent-annotation.js +8 -2
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/italic-annotation.js +13 -5
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-annotation.js +12 -9
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-group-annotation.js +89 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/list-annotation.js +41 -0
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.js +9 -9
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-color-annotation.js +3 -7
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-style-annotation.js +74 -12
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/underline-annotation.js +9 -9
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +69 -2
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/code-block.js +106 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +15 -1
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +50 -0
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +12 -1
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +66 -2
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +29 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/code-block-node.js +56 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +26 -9
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/node.abstract.js +81 -0
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +15 -2
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-renderer.abstract.js +5 -22
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.js +9 -93
- 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/blocks/image-block-renderer.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/link-wrapper-renderer.js +121 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/list-block-renderer.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/list-item-block-renderer.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.js +2 -23
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/code-block-node-renderer.js +81 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/image-node-renderer.js +47 -7
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/node-renderer.abstract.js +0 -27
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.js +3 -2
- 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/block-to-rte-block-strategy.abstract.js +155 -15
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.js +2 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.js +6 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-rte-image-block-strategy.abstract.js +38 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy.js +3 -20
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy.js +59 -5
- 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/li-to-rte-list-item-block-strategy.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ol-to-rte-list-block-strategy.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy.js +3 -20
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-not-li-child-to-rte-list-item-block.js +7 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy.js +69 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-image-to-rte-image-block-strategy.js +4 -7
- 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 +25 -10
- 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 +59 -53
- 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 +10 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.js +5 -3
- 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 +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/center-align-toolbar-button-slimmer.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.js +8 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/justify-align-toolbar-button-slimmer.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/left-align-toolbar-button-slimmer.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/right-align-toolbar-button-slimmer.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.js +2 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.js +3 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.js +60 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.js +6 -4
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/toolbar-button-slimmer.abstract.js +3 -2
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.js +5 -3
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/visual-mode-toolbar-button-slimmer.abstract.js +28 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-renderer.js +31 -3
- 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/action-handle-strategies/image-block-strategy-register.test.js +3 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/action-handle-strategies/text-block-strategy-register.test.js +23 -1
- package/dist/collection/components/vega-rich-text-editor/test/dto/annotations.test.js +247 -27
- 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/dto/content-state.test.js +1793 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/image-node.test.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/text-node.test.js +41 -4
- 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.css +7 -0
- package/dist/collection/components/vega-rich-text-editor/vega-rich-text-editor.js +18 -1
- package/dist/collection/helpers/code-format/code-formatter.js +108 -0
- package/dist/collection/helpers/code-format/test/code-formatter.test.js +362 -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 +1 -0
- package/dist/collection/helpers/slimmers/auto-run-when-re-render-task-queue-slimmer.abstract.js +47 -0
- package/dist/collection/helpers/slimmers/test/auto-run-when-re-render-task-queue-slimmer.test.js +46 -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/polyfill/shadow-selection/shadow-selection-polyfill.js +17 -15
- package/dist/collection/polyfill/shadow-selection/test/shadow-selection-polyfill.test.js +1 -0
- package/dist/collection/polyfill/test-polyfill/unit/methods.js +9 -0
- package/dist/collection/utils/string.js +10 -0
- package/dist/esm/{app-globals-1f8c30e9.js → app-globals-9058ac3b.js} +6 -6
- package/dist/esm/{child-nodes-event-prevent-slimmer-5d45361e.js → child-nodes-event-prevent-slimmer-1142fb79.js} +1 -1
- package/dist/esm/{content-state-dbc9f635.js → code-block-8b5bd928.js} +1141 -1122
- package/dist/esm/content-state-8c3f862b.js +2489 -0
- package/dist/esm/{design-token-0699f0ca.js → design-token-bd436e0d.js} +1 -1
- package/dist/esm/{dom-node-subject-factory-f77cf9cc.js → dom-node-subject-factory-eb6bba5d.js} +1 -1
- package/dist/esm/{dom-node-subject-observer-factory-715dccf9.js → dom-node-subject-observer-factory-6083d518.js} +1 -1
- package/dist/esm/{element-appender-slimmer-96cb54e2.js → element-appender-slimmer-baf5e249.js} +5 -5
- package/dist/esm/{event-emit-slimmer-b7d511f6.js → event-emit-slimmer-480d3b54.js} +3 -3
- package/dist/esm/{form-field-controller-slimmer-89a72ee7.js → form-field-controller-slimmer-bfb4034d.js} +6 -6
- package/dist/esm/{image-annotation-action-1aa938ab.js → image-annotation-action-a8b860ad.js} +57 -28
- package/dist/esm/{index-187f71d1.js → index-d0a47531.js} +9 -0
- package/dist/esm/{index-4aa167d6.js → index-db0ec3ee.js} +2 -2
- package/dist/esm/index.js +12 -11
- package/dist/esm/{internal-vega-event-manager-87dc436c.js → internal-vega-event-manager-56c6469a.js} +2 -1
- package/dist/esm/loader.js +12 -10
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/{public-rules-5cf6aa95.js → public-rules-90fbd41a.js} +8 -6
- package/dist/esm/{responsive-format-facade-42f3fcfa.js → responsive-format-facade-827de03a.js} +3 -3
- package/dist/esm/{rich-text-editor-required-rule-6a7cd3ee.js → rich-text-editor-required-rule-0d470d82.js} +1 -1
- package/dist/esm/selection-controller-dd4f4407.js +759 -0
- package/dist/esm/string-a953eafc.js +21 -0
- package/dist/esm/{string-input-formatter-slimmer-c61f82d6.js → string-input-formatter-slimmer-0d30b976.js} +3 -3
- package/dist/esm/{style-formatter-cb00c709.js → style-formatter-232842f5.js} +1 -1
- package/dist/esm/{sub-state-notify-slimmer-4e3cf09d.js → sub-state-notify-slimmer-04e06501.js} +2 -2
- package/dist/esm/{sub-state-observer-slimmer-be7a6ce3.js → sub-state-observer-slimmer-b4c2ddc3.js} +2 -2
- 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/vega-accordion.entry.js +13 -11
- package/dist/esm/vega-app-footer.entry.js +1 -1
- package/dist/esm/vega-app-header-button.entry.js +14 -12
- package/dist/esm/vega-backdrop.entry.js +1 -1
- package/dist/esm/vega-banner.entry.js +5 -5
- package/dist/esm/vega-bar-chart.entry.js +1 -1
- package/dist/esm/vega-box.entry.js +12 -10
- package/dist/esm/vega-brand-logo.entry.js +1 -1
- package/dist/esm/vega-breadcrumb.entry.js +6 -6
- package/dist/esm/vega-button-circle.entry.js +14 -12
- package/dist/esm/vega-button-group_2.entry.js +9 -9
- package/dist/esm/vega-button-link.entry.js +6 -6
- package/dist/esm/vega-button.entry.js +13 -11
- package/dist/esm/vega-calendar_3.entry.js +11 -11
- package/dist/esm/vega-card.entry.js +11 -9
- package/dist/esm/vega-carousel.entry.js +12 -10
- package/dist/esm/vega-checkbox_2.entry.js +11 -11
- package/dist/esm/vega-chip.entry.js +14 -12
- package/dist/esm/vega-code-block.entry.js +4069 -0
- package/dist/esm/vega-color-picker.entry.js +10 -10
- package/dist/esm/vega-combo-box.entry.js +11 -11
- package/dist/esm/vega-counter-badge.entry.js +1 -1
- package/dist/esm/vega-date-picker_2.entry.js +19 -18
- package/dist/esm/vega-dialog_2.entry.js +14 -12
- package/dist/esm/vega-divider.entry.js +11 -9
- package/dist/esm/vega-dropdown_5.entry.js +17 -15
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-field-error.entry.js +1 -1
- package/dist/esm/vega-field-label.entry.js +5 -5
- package/dist/esm/vega-file-uploader.entry.js +11 -11
- package/dist/esm/vega-flag-icon.entry.js +11 -9
- package/dist/esm/vega-flex.entry.js +12 -10
- package/dist/esm/vega-font.entry.js +11 -9
- package/dist/esm/vega-form.entry.js +12 -12
- package/dist/esm/vega-grid.entry.js +11 -9
- package/dist/esm/vega-hint.entry.js +1 -1
- package/dist/esm/vega-icon.entry.js +11 -9
- package/dist/esm/vega-image-uploader.entry.js +16 -15
- package/dist/esm/vega-input-credit-card.entry.js +11 -11
- package/dist/esm/vega-input-numeric.entry.js +12 -12
- package/dist/esm/vega-input-phone-number.entry.js +14 -13
- package/dist/esm/vega-input-range.entry.js +12 -12
- package/dist/esm/vega-input-select.entry.js +21 -20
- package/dist/esm/vega-input.entry.js +12 -12
- package/dist/esm/{vega-internal-event-id-85ad403f.js → vega-internal-event-id-820393ad.js} +2 -1
- package/dist/esm/vega-item-toggle.entry.js +5 -5
- package/dist/esm/vega-left-nav_5.entry.js +15 -13
- package/dist/esm/vega-line-chart.entry.js +1 -1
- package/dist/esm/vega-loader-wrapper_2.entry.js +10 -8
- package/dist/esm/vega-page-notification_2.entry.js +3 -3
- package/dist/esm/vega-pagination-page-selector-mobile.entry.js +6 -6
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +6 -6
- package/dist/esm/vega-pagination.entry.js +14 -12
- package/dist/esm/vega-pie-chart.entry.js +1 -1
- package/dist/esm/vega-popover_2.entry.js +13 -11
- package/dist/esm/vega-progress-tracker.entry.js +5 -5
- package/dist/esm/vega-radio_2.entry.js +11 -11
- package/dist/esm/vega-rich-text-content.entry.js +305 -131
- package/dist/esm/vega-rich-text-editor_4.entry.js +1132 -2409
- package/dist/esm/vega-section-title.entry.js +1 -1
- package/dist/esm/vega-segment-control.entry.js +5 -5
- package/dist/esm/vega-selection-chip_2.entry.js +16 -15
- package/dist/esm/vega-selection-tile_2.entry.js +12 -12
- package/dist/esm/vega-sidenav_3.entry.js +14 -12
- package/dist/esm/vega-signature-capture.entry.js +16 -15
- package/dist/esm/{vega-skeleton-loader-controller-c2a8bd27.js → vega-skeleton-loader-controller-878e1b28.js} +1 -1
- package/dist/esm/vega-skeleton.entry.js +1 -1
- package/dist/esm/vega-slot-container.entry.js +1 -1
- package/dist/esm/vega-stepper.entry.js +11 -11
- package/dist/esm/vega-tab-group_2.entry.js +6 -6
- package/dist/esm/vega-table_8.entry.js +16 -14
- package/dist/esm/vega-text.entry.js +1 -1
- package/dist/esm/vega-textarea.entry.js +11 -11
- package/dist/esm/vega-time-picker_2.entry.js +17 -16
- package/dist/esm/vega-toggle-switch.entry.js +10 -10
- package/dist/esm/vega-tooltip_2.entry.js +12 -10
- package/dist/esm/vega.js +12 -10
- package/dist/types/components/vega-code-block/assets/copy.d.ts +3 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/code-highlight-parser.abstract.d.ts +40 -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/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 +100 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/vega-code-block-selection-controller.d.ts +93 -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 +57 -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/types.d.ts +19 -0
- package/dist/types/components/vega-code-block/vega-code-block.d.ts +116 -0
- package/dist/types/components/vega-rich-text-editor/assets/file-code.d.ts +3 -0
- 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/action-handle-strategy.abstract.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-horizontal-alignment-strategy.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/action-handle-strategies/apply-annotation-strategies/block-update-indent-strategy.d.ts +15 -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/custom-style-annotation-action.d.ts +17 -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/annotations/annotation.abstract.d.ts +2 -1
- package/dist/types/components/vega-rich-text-editor/dto/annotations/block-annotation.abstract.d.ts +17 -4
- package/dist/types/components/vega-rich-text-editor/dto/annotations/bold-annotation.d.ts +7 -5
- package/dist/types/components/vega-rich-text-editor/dto/annotations/clear-formatting-annotation.d.ts +2 -1
- package/dist/types/components/vega-rich-text-editor/dto/annotations/code-annotation.d.ts +5 -9
- package/dist/types/components/vega-rich-text-editor/dto/annotations/common-annotation.abstract.d.ts +20 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/custom-attribute-annotation.d.ts +43 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/custom-class-annotation.d.ts +40 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/custom-style-annotation.d.ts +42 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.d.ts +5 -9
- package/dist/types/components/vega-rich-text-editor/dto/annotations/image-annotation.d.ts +7 -5
- package/dist/types/components/vega-rich-text-editor/dto/annotations/indent-annotation.d.ts +5 -1
- package/dist/types/components/vega-rich-text-editor/dto/annotations/italic-annotation.d.ts +7 -5
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-annotation.d.ts +6 -4
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-group-annotation.d.ts +48 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/list-annotation.d.ts +25 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/node-annotation.abstract.d.ts +15 -3
- package/dist/types/components/vega-rich-text-editor/dto/annotations/strikethrough-annotation.d.ts +5 -9
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-color-annotation.d.ts +3 -7
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-style-annotation.d.ts +7 -5
- package/dist/types/components/vega-rich-text-editor/dto/annotations/underline-annotation.d.ts +5 -9
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +39 -4
- package/dist/types/components/vega-rich-text-editor/dto/blocks/code-block.d.ts +56 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +20 -2
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +14 -4
- package/dist/types/components/vega-rich-text-editor/dto/content-state.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/code-block-node.d.ts +45 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/image-node.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/dto/nodes/node.abstract.d.ts +46 -2
- package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +7 -2
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-renderer.abstract.d.ts +4 -11
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-text-nodes-renderer.abstract.d.ts +7 -5
- 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/blocks/link-wrapper-renderer.d.ts +24 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.d.ts +0 -1
- 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/dto/renderers/nodes/image-node-renderer.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/node-renderer.abstract.d.ts +1 -15
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +65 -26
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/block-to-rte-block-strategy.abstract.d.ts +64 -6
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.d.ts +3 -1
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-rte-image-block-strategy.abstract.d.ts +20 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy.d.ts +30 -1
- 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/ol-to-rte-list-block-strategy.d.ts +2 -3
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy.d.ts +2 -3
- 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/element-to-dto-strategy/vega-image-to-rte-image-block-strategy.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.d.ts +7 -1
- 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 +17 -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 +2 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bold-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-numbers-toolbar-button-slimmer.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/bullets-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/bullets-numbers/numbers-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/clear-style-toolbar-button-slimmer.d.ts +2 -2
- 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/code-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/center-align-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/horizontal-alignment-toolbar-button-slimmer.d.ts +4 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/justify-align-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/left-align-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/horizontal-alignment/right-align-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/image-toolbar-button-slimmer.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/italic-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/less-indent-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/more-indent-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/source-edit-toolbar-button-slimmer.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/strikethrough-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/text-color-toolbar-button-slimmer.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/text-styles-toolbar-button-slimmer.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/toolbar-button-slimmer.abstract.d.ts +3 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/underline-toolbar-button-slimmer.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/tools/visual-mode-toolbar-button-slimmer.abstract.d.ts +17 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/renderers/vega-rich-text-editor-renderer.d.ts +8 -2
- 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/dto/content-state.test.d.ts +1 -1
- 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 +7 -0
- package/dist/types/components.d.ts +95 -0
- package/dist/types/helpers/code-format/code-formatter.d.ts +34 -0
- package/dist/types/helpers/code-format/test/code-formatter.test.d.ts +1 -0
- package/dist/types/helpers/event-manager/event-id/vega-internal-event-id.d.ts +1 -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 +1 -0
- package/dist/types/utils/string.d.ts +7 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-0104207d.entry.js +1 -0
- package/dist/vega/p-010f1715.entry.js +1 -0
- package/dist/vega/p-01593f9d.js +1 -0
- package/dist/vega/p-020b04ed.js +1 -0
- package/dist/vega/p-02841589.js +1 -0
- package/dist/vega/p-03cfb331.entry.js +9 -0
- package/dist/vega/{p-b649e86e.entry.js → p-0bff8716.entry.js} +1 -1
- package/dist/vega/p-1056a049.entry.js +1 -0
- package/dist/vega/p-10e41bbe.js +1 -0
- package/dist/vega/{p-83ef9e7d.entry.js → p-12e6173c.entry.js} +1 -1
- package/dist/vega/{p-54add0d2.js → p-1397ba3f.js} +1 -1
- package/dist/vega/p-13d9a1fd.entry.js +1 -0
- package/dist/vega/p-13eae47f.entry.js +1 -0
- package/dist/vega/p-1630864e.entry.js +1 -0
- package/dist/vega/p-1b335e30.entry.js +1 -0
- package/dist/vega/{p-8ade44bf.js → p-1e194737.js} +1 -1
- package/dist/vega/{p-252e42c7.entry.js → p-1f346008.entry.js} +1 -1
- package/dist/vega/p-1f86ab76.entry.js +1 -0
- package/dist/vega/p-1fe746ab.entry.js +1 -0
- package/dist/vega/{p-8c388b58.entry.js → p-211c028f.entry.js} +1 -1
- package/dist/vega/p-21d26bb4.js +2 -0
- package/dist/vega/{p-b351ace3.entry.js → p-23e6f2b2.entry.js} +1 -1
- package/dist/vega/p-268aea63.js +1 -0
- package/dist/vega/{p-a01f149d.entry.js → p-27ccf34d.entry.js} +1 -1
- package/dist/vega/{p-913eb7f9.entry.js → p-29f9be26.entry.js} +1 -1
- package/dist/vega/{p-27003a81.entry.js → p-30dcf606.entry.js} +1 -1
- package/dist/vega/{p-89ab72e3.js → p-3c20ae84.js} +1 -1
- package/dist/vega/p-4172fb81.js +1 -0
- package/dist/vega/{p-45f696b4.js → p-419697c6.js} +1 -1
- package/dist/vega/p-427e4cee.entry.js +1 -0
- package/dist/vega/p-4604ed0e.entry.js +1 -0
- package/dist/vega/{p-8d283666.js → p-4ab3df00.js} +1 -1
- package/dist/vega/{p-72ecfd40.js → p-4e8fb53a.js} +1 -1
- package/dist/vega/p-50a3ae3d.js +1 -0
- package/dist/vega/{p-b847a143.entry.js → p-50b80d76.entry.js} +1 -1
- package/dist/vega/p-531ffb18.entry.js +1 -0
- package/dist/vega/p-53daeb45.entry.js +1 -0
- package/dist/vega/p-54fdd401.entry.js +1 -0
- package/dist/vega/{p-47ff95ba.entry.js → p-5741ecf0.entry.js} +1 -1
- package/dist/vega/{p-6cabdb36.js → p-58f8928a.js} +1 -1
- package/dist/vega/{p-4a32a6c0.entry.js → p-5c4cb804.entry.js} +1 -1
- package/dist/vega/{p-a46bc9f1.entry.js → p-5ce386c8.entry.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-0079088b.entry.js → p-5fd5a538.entry.js} +1 -1
- package/dist/vega/{p-0969877b.entry.js → p-64f452fe.entry.js} +1 -1
- package/dist/vega/p-66759f4e.js +1 -0
- package/dist/vega/{p-bc2dd43d.js → p-6ea42854.js} +1 -1
- package/dist/vega/p-70f25341.entry.js +1 -0
- package/dist/vega/{p-ec1f2d21.entry.js → p-737bccb9.entry.js} +1 -1
- package/dist/vega/{p-bcb10ae3.entry.js → p-7503fe08.entry.js} +1 -1
- package/dist/vega/{p-46714da3.entry.js → p-7b0a4688.entry.js} +1 -1
- package/dist/vega/p-7def7b74.entry.js +1 -0
- package/dist/vega/{p-48517a5d.entry.js → p-7f5a85c6.entry.js} +1 -1
- package/dist/vega/p-825ae7c4.js +1 -0
- package/dist/vega/p-831c4144.entry.js +1 -0
- package/dist/vega/p-85dc08b4.entry.js +1 -0
- package/dist/vega/{p-a821bcf3.js → p-86782109.js} +1 -1
- package/dist/vega/p-87459914.js +1 -0
- package/dist/vega/{p-1971d980.entry.js → p-87a1fc77.entry.js} +1 -1
- package/dist/vega/p-89565247.entry.js +1 -0
- package/dist/vega/{p-7088ead9.entry.js → p-89e915e9.entry.js} +1 -1
- package/dist/vega/{p-81fbfb6d.entry.js → p-8aa7e56e.entry.js} +1 -1
- package/dist/vega/p-94263ece.entry.js +1 -0
- package/dist/vega/{p-d0007822.entry.js → p-9524e48a.entry.js} +1 -1
- package/dist/vega/{p-147e3cbd.entry.js → p-991b4717.entry.js} +1 -1
- package/dist/vega/{p-647025dd.entry.js → p-99b9b320.entry.js} +1 -1
- package/dist/vega/{p-aea89be5.entry.js → p-9ba14b7c.entry.js} +1 -1
- package/dist/vega/p-9cb79f8d.entry.js +1 -0
- package/dist/vega/p-9e3f52f0.entry.js +1 -0
- package/dist/vega/{p-6586e2a2.entry.js → p-a0e122a6.entry.js} +1 -1
- package/dist/vega/{p-9803042f.entry.js → p-b0fe6c0f.entry.js} +1 -1
- package/dist/vega/{p-b2bca332.entry.js → p-b518e1a0.entry.js} +1 -1
- package/dist/vega/p-b538e81a.entry.js +1 -0
- package/dist/vega/p-b824baf7.entry.js +1 -0
- package/dist/vega/{p-2fadef27.entry.js → p-b959b4d4.entry.js} +1 -1
- package/dist/vega/{p-54f17c2e.entry.js → p-bb4f0fa1.entry.js} +1 -1
- package/dist/vega/{p-2da83c2a.js → p-bbb39d6f.js} +1 -1
- package/dist/vega/{p-cfda64fd.entry.js → p-bc8fd0ee.entry.js} +1 -1
- package/dist/vega/p-bcaf8375.entry.js +1 -0
- package/dist/vega/{p-02d7d948.entry.js → p-bec90ff3.entry.js} +1 -1
- package/dist/vega/p-c6b94dde.entry.js +1 -0
- package/dist/vega/{p-c754b32c.js → p-ce6b62c4.js} +1 -1
- package/dist/vega/{p-5e34ea25.entry.js → p-d00fbc11.entry.js} +1 -1
- package/dist/vega/{p-10a40dfb.entry.js → p-d2a2af2c.entry.js} +1 -1
- package/dist/vega/p-d64b20c2.js +1 -0
- package/dist/vega/p-da779940.entry.js +1 -0
- package/dist/vega/{p-a7dcb2a3.js → p-db910162.js} +1 -1
- package/dist/vega/{p-6f81fe1e.js → p-e1a2a701.js} +1 -1
- package/dist/vega/p-e3694aa5.entry.js +1 -0
- package/dist/vega/p-e7318c4c.entry.js +1 -0
- package/dist/vega/{p-a5c39ba2.entry.js → p-e8fc027e.entry.js} +1 -1
- package/dist/vega/{p-6a830bc5.entry.js → p-e92ecb78.entry.js} +1 -1
- package/dist/vega/p-e969c3f4.entry.js +1 -0
- package/dist/vega/{p-61eb7f32.entry.js → p-ec8b7f01.entry.js} +1 -1
- package/dist/vega/p-eed9bda2.entry.js +1 -0
- package/dist/vega/p-f4c54c98.entry.js +1 -0
- package/dist/vega/{p-5160a6b9.entry.js → p-f5fc80bc.entry.js} +1 -1
- package/dist/vega/p-f67be7ef.js +1 -0
- package/dist/vega/{p-5e3a15a1.js → p-f9fafc55.js} +1 -1
- package/dist/vega/{p-27e56c67.entry.js → p-fc21fb2d.entry.js} +1 -1
- package/dist/vega/p-fed9220b.entry.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +2 -1
- package/dist/cjs/string-21427167.js +0 -13
- package/dist/esm/string-be824360.js +0 -11
- package/dist/vega/p-06adb37e.entry.js +0 -1
- package/dist/vega/p-06c5fe97.entry.js +0 -1
- package/dist/vega/p-0bb29d98.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-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-646a9198.entry.js +0 -1
- package/dist/vega/p-6d7d923b.js +0 -1
- package/dist/vega/p-6e898779.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-8ba43640.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-bf1894ec.js +0 -1
- package/dist/vega/p-bfb344e1.entry.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
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { i as isNonNullable } from './type-guard-158f6d7a.js';
|
|
1
2
|
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
|
|
2
|
-
import { d as domNodeSubjectFactory } from './dom-node-subject-factory-
|
|
3
|
-
import { a as VegaInternalRichTextEditorFlushChanges, b as VegaInternalRichTextEditorSelectionRangeChange } from './vega-internal-event-id-
|
|
3
|
+
import { d as domNodeSubjectFactory } from './dom-node-subject-factory-eb6bba5d.js';
|
|
4
|
+
import { a as VegaInternalRichTextEditorFlushChanges, b as VegaInternalRichTextEditorSelectionRangeChange } from './vega-internal-event-id-820393ad.js';
|
|
4
5
|
import { L as LogUtility } from './global-slimmer-registry-17c4efd4.js';
|
|
5
|
-
import {
|
|
6
|
+
import { c as camelToDashCase } from './string-a953eafc.js';
|
|
6
7
|
import { g as generateUUID } from './create-public-api-runtime-metrics-slimmer-8ada793f.js';
|
|
7
8
|
import { V as VegaInternalThemeManager } from './dark-mode-style-controller-2ada8e22.js';
|
|
8
9
|
|
|
@@ -23,6 +24,7 @@ var BlockAnnotationTypeEnum;
|
|
|
23
24
|
BlockAnnotationTypeEnum["ALIGNMENT"] = "ALIGNMENT";
|
|
24
25
|
BlockAnnotationTypeEnum["TEXT_STYLE"] = "TEXT_STYLE";
|
|
25
26
|
BlockAnnotationTypeEnum["INDENT"] = "INDENT";
|
|
27
|
+
BlockAnnotationTypeEnum["LIST"] = "LIST";
|
|
26
28
|
})(BlockAnnotationTypeEnum || (BlockAnnotationTypeEnum = {}));
|
|
27
29
|
/**
|
|
28
30
|
* BlockAnnotation is an abstract class that represents a block annotation.
|
|
@@ -101,6 +103,10 @@ var ModifyContentActionType;
|
|
|
101
103
|
ModifyContentActionType["DELETE_BLOCK_CONTENT"] = "DELETE_BLOCK_CONTENT";
|
|
102
104
|
ModifyContentActionType["INSERT_IMAGE_TO_BLOCK"] = "INSERT_IMAGE_TO_BLOCK";
|
|
103
105
|
ModifyContentActionType["UPDATE_IMAGE_NODE_URL"] = "UPDATE_IMAGE_NODE_URL";
|
|
106
|
+
ModifyContentActionType["TRANSFORM_TO_CODE_BLOCK"] = "TRANSFORM_TO_CODE_BLOCK";
|
|
107
|
+
ModifyContentActionType["UPDATE_CODE_BLOCK"] = "UPDATE_CODE_BLOCK";
|
|
108
|
+
ModifyContentActionType["SWITCH_OUT_FROM_CODE_BLOCK"] = "SWITCH_OUT_FROM_CODE_BLOCK";
|
|
109
|
+
ModifyContentActionType["DELETE_CODE_BLOCK"] = "DELETE_CODE_BLOCK";
|
|
104
110
|
})(ModifyContentActionType || (ModifyContentActionType = {}));
|
|
105
111
|
/**
|
|
106
112
|
* Abstract class for update node content, delete node, insert node
|
|
@@ -140,12 +146,20 @@ class HorizontalAlignmentAnnotation extends BlockAnnotation {
|
|
|
140
146
|
};
|
|
141
147
|
}
|
|
142
148
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @returns {string} - Annotation class
|
|
149
|
+
* @inheritDoc
|
|
146
150
|
*/
|
|
147
|
-
renderClass() {
|
|
148
|
-
|
|
151
|
+
renderClass(options) {
|
|
152
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
153
|
+
return null;
|
|
154
|
+
switch (this.textAlign) {
|
|
155
|
+
case 'right':
|
|
156
|
+
case 'center':
|
|
157
|
+
case 'justify':
|
|
158
|
+
return `v-rte--horizontal-alignment-${this.textAlign}`;
|
|
159
|
+
case 'left':
|
|
160
|
+
default:
|
|
161
|
+
return `v-rte--horizontal-alignment-left`;
|
|
162
|
+
}
|
|
149
163
|
}
|
|
150
164
|
/**
|
|
151
165
|
* @inheritDoc
|
|
@@ -154,12 +168,20 @@ class HorizontalAlignmentAnnotation extends BlockAnnotation {
|
|
|
154
168
|
return new HorizontalAlignmentAnnotation(this.textAlign);
|
|
155
169
|
}
|
|
156
170
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
171
|
+
* @inheritDoc
|
|
160
172
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
renderStyle(options) {
|
|
174
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
175
|
+
return null;
|
|
176
|
+
switch (this.textAlign) {
|
|
177
|
+
case 'right':
|
|
178
|
+
case 'center':
|
|
179
|
+
case 'justify':
|
|
180
|
+
return { textAlign: this.textAlign };
|
|
181
|
+
case 'left':
|
|
182
|
+
default:
|
|
183
|
+
return { textAlign: 'left' };
|
|
184
|
+
}
|
|
163
185
|
}
|
|
164
186
|
}
|
|
165
187
|
|
|
@@ -195,13 +217,19 @@ class IndentAnnotation extends BlockAnnotation {
|
|
|
195
217
|
clone() {
|
|
196
218
|
return new IndentAnnotation(this.indent);
|
|
197
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* @inheritDoc
|
|
222
|
+
*/
|
|
223
|
+
renderClass() {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
198
226
|
/**
|
|
199
227
|
* Generate the style for the annotation
|
|
200
228
|
*
|
|
201
229
|
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
202
230
|
*/
|
|
203
|
-
|
|
204
|
-
return this.indent > 0 ? {
|
|
231
|
+
renderStyle() {
|
|
232
|
+
return this.indent > 0 ? { marginLeft: `${this.indent * 16}px` } : null;
|
|
205
233
|
}
|
|
206
234
|
}
|
|
207
235
|
|
|
@@ -260,6 +288,193 @@ class ActionHandleStrategyRegistry {
|
|
|
260
288
|
}
|
|
261
289
|
ActionHandleStrategyRegistry.registry = new Map();
|
|
262
290
|
|
|
291
|
+
var CommonAnnotationTypeEnum;
|
|
292
|
+
(function (CommonAnnotationTypeEnum) {
|
|
293
|
+
CommonAnnotationTypeEnum["CUSTOM_ATTRIBUTE"] = "CUSTOM_ATTRIBUTE";
|
|
294
|
+
CommonAnnotationTypeEnum["CUSTOM_CLASS"] = "CUSTOM_CLASS";
|
|
295
|
+
CommonAnnotationTypeEnum["CUSTOM_STYLE"] = "CUSTOM_STYLE";
|
|
296
|
+
})(CommonAnnotationTypeEnum || (CommonAnnotationTypeEnum = {}));
|
|
297
|
+
/**
|
|
298
|
+
* CommonAnnotation is an abstract class that represents common annotation for block and node.
|
|
299
|
+
*/
|
|
300
|
+
class CommonAnnotation extends Annotation {
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Annotation to add custom attributes of element
|
|
305
|
+
*/
|
|
306
|
+
class CustomAttributeAnnotation extends CommonAnnotation {
|
|
307
|
+
constructor(customAttribute) {
|
|
308
|
+
super();
|
|
309
|
+
this.type = CommonAnnotationTypeEnum.CUSTOM_ATTRIBUTE;
|
|
310
|
+
this.customAttribute = customAttribute;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Generate the map item for the annotation
|
|
314
|
+
*
|
|
315
|
+
* @param {Record<string, string>} customizeAttribute - custom attribute annotation
|
|
316
|
+
* @returns {[CommonAnnotationTypeEnum.CUSTOM_ATTRIBUTE, CustomAttributeAnnotation]} Map item for the annotation
|
|
317
|
+
*/
|
|
318
|
+
static from(customizeAttribute) {
|
|
319
|
+
return [CommonAnnotationTypeEnum.CUSTOM_ATTRIBUTE, new CustomAttributeAnnotation(customizeAttribute)];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Generate the JSON representation of the annotation
|
|
323
|
+
*
|
|
324
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
325
|
+
*/
|
|
326
|
+
toJSON() {
|
|
327
|
+
return {
|
|
328
|
+
customAttribute: this.customAttribute,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Create a new custom attribute annotation
|
|
333
|
+
*
|
|
334
|
+
* @returns {CustomAttributeAnnotation} - Custom attribute annotation
|
|
335
|
+
*/
|
|
336
|
+
clone() {
|
|
337
|
+
return new CustomAttributeAnnotation(this.customAttribute);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Generate the custom attribute of current element, excluding 'style' and 'class'
|
|
341
|
+
*
|
|
342
|
+
* @param {string[]} filterAttr - should filter these existed attrs
|
|
343
|
+
* @returns {string[]} - Custom attributes
|
|
344
|
+
*/
|
|
345
|
+
toString(filterAttr = []) {
|
|
346
|
+
const filterAttrKeys = filterAttr.map((attr) => attr.split('=')[0]);
|
|
347
|
+
return Object.keys(this.customAttribute)
|
|
348
|
+
.map((key) => {
|
|
349
|
+
return !filterAttrKeys.includes(key) ? `${key}="${this.customAttribute[key]}"` : null;
|
|
350
|
+
})
|
|
351
|
+
.filter(isNonNullable);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Generate the custom attribute for the annotation
|
|
355
|
+
*
|
|
356
|
+
* @param {RTERenderCustomAttributes} options - should filter these certain attrs
|
|
357
|
+
* @returns {Record<string, string>} custom attribute
|
|
358
|
+
*/
|
|
359
|
+
render(options = {}) {
|
|
360
|
+
var _a;
|
|
361
|
+
const customAttribute = Object.assign({}, this.customAttribute);
|
|
362
|
+
(_a = options.filterAttributes) === null || _a === void 0 ? void 0 : _a.forEach((attr) => delete customAttribute[attr]);
|
|
363
|
+
return customAttribute;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Annotation to add custom class of element
|
|
369
|
+
*/
|
|
370
|
+
class CustomClassAnnotation extends CommonAnnotation {
|
|
371
|
+
constructor(customClass) {
|
|
372
|
+
super();
|
|
373
|
+
this.type = CommonAnnotationTypeEnum.CUSTOM_CLASS;
|
|
374
|
+
this.customClass = customClass;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Generate the map item for the annotation
|
|
378
|
+
*
|
|
379
|
+
* @param {string[]} customClass - custom class annotation
|
|
380
|
+
* @returns {[CommonAnnotationTypeEnum.CUSTOM_CLASS, CustomClassAnnotation]} Map item for the annotation
|
|
381
|
+
*/
|
|
382
|
+
static from(customClass) {
|
|
383
|
+
return [CommonAnnotationTypeEnum.CUSTOM_CLASS, new CustomClassAnnotation(customClass)];
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Generate the JSON representation of the annotation
|
|
387
|
+
*
|
|
388
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
389
|
+
*/
|
|
390
|
+
toJSON() {
|
|
391
|
+
return {
|
|
392
|
+
customClass: this.customClass,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Create a new custom class annotation
|
|
397
|
+
*
|
|
398
|
+
* @returns {CustomClassAnnotation} - Custom class annotation
|
|
399
|
+
*/
|
|
400
|
+
clone() {
|
|
401
|
+
return new CustomClassAnnotation(this.customClass);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Generate the custom class of current element
|
|
405
|
+
*
|
|
406
|
+
* @returns {string} - Custom class
|
|
407
|
+
*/
|
|
408
|
+
toString() {
|
|
409
|
+
return `class="${this.customClass.join(' ')}"`;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Generate the custom attribute for the annotation
|
|
413
|
+
*
|
|
414
|
+
* @returns {string[]} custom classes
|
|
415
|
+
*/
|
|
416
|
+
renderClass() {
|
|
417
|
+
return this.customClass;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Annotation to add custom attributes of element
|
|
423
|
+
*/
|
|
424
|
+
class CustomStyleAnnotation extends CommonAnnotation {
|
|
425
|
+
constructor(customStyle) {
|
|
426
|
+
super();
|
|
427
|
+
this.type = CommonAnnotationTypeEnum.CUSTOM_STYLE;
|
|
428
|
+
this.customStyle = customStyle;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Generate the map item for the annotation
|
|
432
|
+
*
|
|
433
|
+
* @param {AnnotationStyle} customStyle - custom attribute annotation
|
|
434
|
+
* @returns {[CommonAnnotationTypeEnum.CUSTOM_STYLE, CustomStyleAnnotation]} Map item for the annotation
|
|
435
|
+
*/
|
|
436
|
+
static from(customStyle) {
|
|
437
|
+
return [CommonAnnotationTypeEnum.CUSTOM_STYLE, new CustomStyleAnnotation(customStyle)];
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Generate the JSON representation of the annotation
|
|
441
|
+
*
|
|
442
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
443
|
+
*/
|
|
444
|
+
toJSON() {
|
|
445
|
+
return {
|
|
446
|
+
customStyle: this.customStyle,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Create a new custom attribute annotation
|
|
451
|
+
*
|
|
452
|
+
* @returns {CustomStyleAnnotation} - Custom attribute annotation
|
|
453
|
+
*/
|
|
454
|
+
clone() {
|
|
455
|
+
return new CustomStyleAnnotation(this.customStyle);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Generate the custom attribute for the annotation
|
|
459
|
+
*
|
|
460
|
+
* @returns {AnnotationStyle} custom attribute
|
|
461
|
+
*/
|
|
462
|
+
renderStyle() {
|
|
463
|
+
return this.customStyle;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Remove the style
|
|
467
|
+
*
|
|
468
|
+
* @param {string[]} styleKeys - custom attribute annotation
|
|
469
|
+
* @returns {AnnotationStyle} Map item for the annotation
|
|
470
|
+
*/
|
|
471
|
+
removeStyles(styleKeys) {
|
|
472
|
+
const customStyle = Object.assign({}, this.customStyle);
|
|
473
|
+
styleKeys.forEach((item) => delete customStyle[item]);
|
|
474
|
+
return customStyle;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
263
478
|
/**
|
|
264
479
|
* Abstract class for block
|
|
265
480
|
*/
|
|
@@ -277,7 +492,7 @@ class RTEBlock {
|
|
|
277
492
|
* @param {unknown} value - The `value` parameter in the `createAnnotationEntity` function is the value
|
|
278
493
|
* that will be used to create the annotation entity. It can be of any type depending on the specific
|
|
279
494
|
* annotation being created.
|
|
280
|
-
* @returns {Nullable<
|
|
495
|
+
* @returns {Nullable<BlockAnnotationsEntity>} The `createAnnotationEntity` function returns a nullable tuple containing a
|
|
281
496
|
* `BlockAnnotationTypeEnum` and a `BlockAnnotation` object.
|
|
282
497
|
*/
|
|
283
498
|
static createAnnotationEntity(type, value) {
|
|
@@ -286,6 +501,12 @@ class RTEBlock {
|
|
|
286
501
|
return HorizontalAlignmentAnnotation.from(value);
|
|
287
502
|
case 'indent':
|
|
288
503
|
return IndentAnnotation.from(value);
|
|
504
|
+
case 'customAttribute':
|
|
505
|
+
return CustomAttributeAnnotation.from(value);
|
|
506
|
+
case 'customClass':
|
|
507
|
+
return CustomClassAnnotation.from(value);
|
|
508
|
+
case 'customStyle':
|
|
509
|
+
return CustomStyleAnnotation.from(value);
|
|
289
510
|
}
|
|
290
511
|
}
|
|
291
512
|
/**
|
|
@@ -295,7 +516,7 @@ class RTEBlock {
|
|
|
295
516
|
*/
|
|
296
517
|
toJSON() {
|
|
297
518
|
const annotations = Array.from(this.annotationMap.values())
|
|
298
|
-
.filter((annotation) => annotation instanceof BlockAnnotation)
|
|
519
|
+
.filter((annotation) => annotation instanceof BlockAnnotation || annotation instanceof CommonAnnotation)
|
|
299
520
|
.reduce((record, annotation) => {
|
|
300
521
|
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
301
522
|
}, {});
|
|
@@ -328,6 +549,61 @@ class RTEBlock {
|
|
|
328
549
|
}
|
|
329
550
|
}
|
|
330
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Get styles from annotations
|
|
554
|
+
*
|
|
555
|
+
* @param {RTERenderContext} [options={ standalone: false }] - Options to control style mode
|
|
556
|
+
* @returns {AnnotationStyle} - Annotation styles
|
|
557
|
+
*/
|
|
558
|
+
getStyles(options = { standalone: false }) {
|
|
559
|
+
return Array.from(this.annotationMap.values())
|
|
560
|
+
.filter((annotation) => annotation instanceof BlockAnnotation || annotation instanceof CustomStyleAnnotation)
|
|
561
|
+
.map((annotation) => annotation.renderStyle(options))
|
|
562
|
+
.filter(isNonNullable)
|
|
563
|
+
.reduce((current, obj) => (Object.assign(Object.assign({}, current), obj)), {});
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Get classes from annotations
|
|
567
|
+
*
|
|
568
|
+
* @param {RTERenderContext} [options={ standalone: false }] - Options to control standalone mode
|
|
569
|
+
* @returns {string} - Annotation style
|
|
570
|
+
*/
|
|
571
|
+
getClasses(options = { standalone: false }) {
|
|
572
|
+
return Array.from(this.annotationMap.values())
|
|
573
|
+
.filter((annotation) => annotation instanceof BlockAnnotation || annotation instanceof CustomClassAnnotation)
|
|
574
|
+
.map((annotation) => annotation.renderClass(options))
|
|
575
|
+
.filter(isNonNullable)
|
|
576
|
+
.reduce((pre, cur) => [pre, cur].join(' ').trim(), '');
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Get custom attribute annotation, excluding "class" and "style"
|
|
580
|
+
*
|
|
581
|
+
* @returns {Nullable<CustomAttributeAnnotation>} - custom attribute annotation
|
|
582
|
+
*/
|
|
583
|
+
getCustomAttributesAnnotation() {
|
|
584
|
+
return this.annotationMap.get(CommonAnnotationTypeEnum.CUSTOM_ATTRIBUTE);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Generate attributes as string
|
|
588
|
+
*
|
|
589
|
+
* @param {...string} attrs - Additional attributes to include
|
|
590
|
+
* @returns {string} - Attributes as string
|
|
591
|
+
*/
|
|
592
|
+
generateAttributeString(...attrs) {
|
|
593
|
+
var _a;
|
|
594
|
+
const styles = Object.entries(Object.assign({}, this.getStyles({ standalone: true })))
|
|
595
|
+
.map(([key, value]) => `${camelToDashCase(key)}: ${value};`)
|
|
596
|
+
.join('');
|
|
597
|
+
const customClassAnnotation = this.annotationMap.get(CommonAnnotationTypeEnum.CUSTOM_CLASS);
|
|
598
|
+
const customAttributeString = ((_a = this.getCustomAttributesAnnotation()) === null || _a === void 0 ? void 0 : _a.toString(attrs)) || [];
|
|
599
|
+
const attributes = [
|
|
600
|
+
...customAttributeString,
|
|
601
|
+
customClassAnnotation === null || customClassAnnotation === void 0 ? void 0 : customClassAnnotation.toString(),
|
|
602
|
+
styles ? `style="${styles}"` : null,
|
|
603
|
+
...attrs,
|
|
604
|
+
].filter(isNonNullable);
|
|
605
|
+
return attributes.length ? ` ${attributes.join(' ')}` : '';
|
|
606
|
+
}
|
|
331
607
|
/**
|
|
332
608
|
* Apply action to block
|
|
333
609
|
*
|
|
@@ -361,10 +637,29 @@ class RTEBlock {
|
|
|
361
637
|
}
|
|
362
638
|
}
|
|
363
639
|
|
|
640
|
+
var NodeAnnotationTypeEnum;
|
|
641
|
+
(function (NodeAnnotationTypeEnum) {
|
|
642
|
+
NodeAnnotationTypeEnum["BOLD"] = "BOLD";
|
|
643
|
+
NodeAnnotationTypeEnum["ITALIC"] = "ITALIC";
|
|
644
|
+
NodeAnnotationTypeEnum["UNDERLINE"] = "UNDERLINE";
|
|
645
|
+
NodeAnnotationTypeEnum["STRIKETHROUGH"] = "STRIKETHROUGH";
|
|
646
|
+
NodeAnnotationTypeEnum["SELECTION_RANGE"] = "SELECTION_RANGE";
|
|
647
|
+
NodeAnnotationTypeEnum["IMAGE"] = "IMAGE";
|
|
648
|
+
NodeAnnotationTypeEnum["CODE"] = "CODE";
|
|
649
|
+
NodeAnnotationTypeEnum["TEXT_COLOR"] = "TEXT_COLOR";
|
|
650
|
+
NodeAnnotationTypeEnum["LINK"] = "LINK";
|
|
651
|
+
})(NodeAnnotationTypeEnum || (NodeAnnotationTypeEnum = {}));
|
|
652
|
+
/**
|
|
653
|
+
* Abstract class for all annotations
|
|
654
|
+
*/
|
|
655
|
+
class NodeAnnotation extends Annotation {
|
|
656
|
+
}
|
|
657
|
+
|
|
364
658
|
var NodeTypeEnum;
|
|
365
659
|
(function (NodeTypeEnum) {
|
|
366
660
|
NodeTypeEnum["TEXT"] = "TEXT";
|
|
367
661
|
NodeTypeEnum["IMAGE"] = "IMAGE";
|
|
662
|
+
NodeTypeEnum["CODE_BLOCK_NODE"] = "CODE_BLOCK_NODE";
|
|
368
663
|
})(NodeTypeEnum || (NodeTypeEnum = {}));
|
|
369
664
|
/**
|
|
370
665
|
* Abstract class for all nodes
|
|
@@ -377,6 +672,24 @@ class RTENode {
|
|
|
377
672
|
this.annotationMap = annotationMap;
|
|
378
673
|
}
|
|
379
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* Creates different types of text annotations based on the provided type and value.
|
|
677
|
+
*
|
|
678
|
+
* @param {keyof VegaRTETextAnnotations} type - The key of the type.
|
|
679
|
+
* @param {unknown} value - The value that will be used to create the specific type of annotation entity based on the `type` provided.
|
|
680
|
+
* @returns {Nullable<[RTENodeAnnotationMapKey, RTENodeAnnotationMapValue]>} Returning a nullable tuple containing a key and a
|
|
681
|
+
* value from the `RTENodeAnnotationMapKey` and `RTENodeAnnotationMapValue` types.
|
|
682
|
+
*/
|
|
683
|
+
static createAnnotationEntity(type, value) {
|
|
684
|
+
switch (type) {
|
|
685
|
+
case 'customAttribute':
|
|
686
|
+
return CustomAttributeAnnotation.from(value);
|
|
687
|
+
case 'customClass':
|
|
688
|
+
return CustomClassAnnotation.from(value);
|
|
689
|
+
case 'customStyle':
|
|
690
|
+
return CustomStyleAnnotation.from(value);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
380
693
|
/**
|
|
381
694
|
* Get annotation by type
|
|
382
695
|
*
|
|
@@ -409,6 +722,61 @@ class RTENode {
|
|
|
409
722
|
}
|
|
410
723
|
return this;
|
|
411
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* Get styles from annotations
|
|
727
|
+
*
|
|
728
|
+
* @param {RTERenderContext} [options={ standalone: false }] - Options to control style mode
|
|
729
|
+
* @returns {AnnotationStyle} - Annotation styles
|
|
730
|
+
*/
|
|
731
|
+
getStyles(options = { standalone: false }) {
|
|
732
|
+
return Array.from(this.annotationMap.values())
|
|
733
|
+
.filter((annotation) => annotation instanceof NodeAnnotation || annotation instanceof CustomStyleAnnotation)
|
|
734
|
+
.map((annotation) => annotation.renderStyle(options))
|
|
735
|
+
.filter(Boolean)
|
|
736
|
+
.reduce((current, obj) => (Object.assign(Object.assign({}, current), obj)), {});
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Get classes from annotations
|
|
740
|
+
*
|
|
741
|
+
* @param {RTERenderContext} [options={ standalone: false }] - Options to control style mode
|
|
742
|
+
* @returns {string} - Annotation style
|
|
743
|
+
*/
|
|
744
|
+
getClasses(options = { standalone: false }) {
|
|
745
|
+
return Array.from(this.annotationMap.values())
|
|
746
|
+
.filter((annotation) => annotation instanceof NodeAnnotation || annotation instanceof CustomClassAnnotation)
|
|
747
|
+
.map((annotation) => annotation.renderClass(options))
|
|
748
|
+
.filter(isNonNullable)
|
|
749
|
+
.reduce((pre, cur) => [pre, cur].join(' ').trim(), '');
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Get custom attribute annotation, excluding "class" and "style"
|
|
753
|
+
*
|
|
754
|
+
* @returns {CustomAttributeAnnotation} - custom attribute annotation
|
|
755
|
+
*/
|
|
756
|
+
getCustomAttributesAnnotation() {
|
|
757
|
+
return this.annotationMap.get(CommonAnnotationTypeEnum.CUSTOM_ATTRIBUTE);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Generate attributes as string
|
|
761
|
+
*
|
|
762
|
+
* @param {...string} attrs - Additional attributes to include
|
|
763
|
+
* @returns {string} - Attributes as string
|
|
764
|
+
*/
|
|
765
|
+
generateAttributeString(...attrs) {
|
|
766
|
+
var _a;
|
|
767
|
+
const styles = Object.entries(Object.assign({}, this.getStyles({ standalone: true })))
|
|
768
|
+
.map(([key, value]) => `${camelToDashCase(key)}: ${value};`)
|
|
769
|
+
.join('');
|
|
770
|
+
const customClassAnnotation = this.annotationMap.get(CommonAnnotationTypeEnum.CUSTOM_CLASS);
|
|
771
|
+
const customAttributeString = ((_a = this.getCustomAttributesAnnotation()) === null || _a === void 0 ? void 0 : _a.toString(attrs)) || [];
|
|
772
|
+
const attributes = [
|
|
773
|
+
...customAttributeString,
|
|
774
|
+
customClassAnnotation === null || customClassAnnotation === void 0 ? void 0 : customClassAnnotation.toString(),
|
|
775
|
+
styles ? `style="${styles}"` : null,
|
|
776
|
+
...attrs,
|
|
777
|
+
].filter(isNonNullable);
|
|
778
|
+
return attributes.length ? ` ${attributes.join(' ')}` : '';
|
|
779
|
+
}
|
|
412
780
|
/**
|
|
413
781
|
* apply annotation action or modify content action
|
|
414
782
|
*
|
|
@@ -444,24 +812,6 @@ class RTENode {
|
|
|
444
812
|
}
|
|
445
813
|
}
|
|
446
814
|
|
|
447
|
-
var NodeAnnotationTypeEnum;
|
|
448
|
-
(function (NodeAnnotationTypeEnum) {
|
|
449
|
-
NodeAnnotationTypeEnum["BOLD"] = "BOLD";
|
|
450
|
-
NodeAnnotationTypeEnum["ITALIC"] = "ITALIC";
|
|
451
|
-
NodeAnnotationTypeEnum["UNDERLINE"] = "UNDERLINE";
|
|
452
|
-
NodeAnnotationTypeEnum["STRIKETHROUGH"] = "STRIKETHROUGH";
|
|
453
|
-
NodeAnnotationTypeEnum["SELECTION_RANGE"] = "SELECTION_RANGE";
|
|
454
|
-
NodeAnnotationTypeEnum["IMAGE"] = "IMAGE";
|
|
455
|
-
NodeAnnotationTypeEnum["CODE"] = "CODE";
|
|
456
|
-
NodeAnnotationTypeEnum["TEXT_COLOR"] = "TEXT_COLOR";
|
|
457
|
-
NodeAnnotationTypeEnum["LINK"] = "LINK";
|
|
458
|
-
})(NodeAnnotationTypeEnum || (NodeAnnotationTypeEnum = {}));
|
|
459
|
-
/**
|
|
460
|
-
* Abstract class for all annotations
|
|
461
|
-
*/
|
|
462
|
-
class NodeAnnotation extends Annotation {
|
|
463
|
-
}
|
|
464
|
-
|
|
465
815
|
/**
|
|
466
816
|
* Annotation for image
|
|
467
817
|
*/
|
|
@@ -504,20 +854,29 @@ class ImageAnnotation extends NodeAnnotation {
|
|
|
504
854
|
return new ImageAnnotation(this.size, this.alt);
|
|
505
855
|
}
|
|
506
856
|
/**
|
|
507
|
-
*
|
|
508
|
-
|
|
509
|
-
|
|
857
|
+
* @inheritDoc
|
|
858
|
+
*/
|
|
859
|
+
renderClass(options) {
|
|
860
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
861
|
+
return null;
|
|
862
|
+
return `v-rte--image-size-${this.size}`;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* @inheritDoc
|
|
510
866
|
*/
|
|
511
|
-
|
|
867
|
+
renderStyle(options) {
|
|
868
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
869
|
+
return null;
|
|
870
|
+
const baseStyle = { verticalAlign: 'bottom' };
|
|
512
871
|
switch (this.size) {
|
|
513
872
|
case 'sm': {
|
|
514
|
-
return { width: '25%' };
|
|
873
|
+
return Object.assign(Object.assign({}, baseStyle), { width: '25%' });
|
|
515
874
|
}
|
|
516
875
|
case 'md': {
|
|
517
|
-
return { width: '50%' };
|
|
876
|
+
return Object.assign(Object.assign({}, baseStyle), { width: '50%' });
|
|
518
877
|
}
|
|
519
878
|
case 'lg': {
|
|
520
|
-
return { width: '100%' };
|
|
879
|
+
return Object.assign(Object.assign({}, baseStyle), { width: '100%' });
|
|
521
880
|
}
|
|
522
881
|
}
|
|
523
882
|
}
|
|
@@ -585,6 +944,28 @@ class ActionHandleStrategy {
|
|
|
585
944
|
const lastNode = target.nodes[target.nodes.length - 1];
|
|
586
945
|
return node === lastNode && startOffset === 1;
|
|
587
946
|
}
|
|
947
|
+
/**
|
|
948
|
+
* Update the custom style annotation of a block or node
|
|
949
|
+
*
|
|
950
|
+
* @param {RTEBlock | RTETextNode} item - block or node
|
|
951
|
+
* @param {string[]} styleKeys - custom style keys, for examples ['fontSize', 'fontWeight'].
|
|
952
|
+
*/
|
|
953
|
+
updateCustomStyleAnnotation(item, styleKeys) {
|
|
954
|
+
const customStyleAnnotation = item.annotationMap.get(CommonAnnotationTypeEnum.CUSTOM_STYLE);
|
|
955
|
+
if (customStyleAnnotation && this.isCustomStyle(customStyleAnnotation, styleKeys)) {
|
|
956
|
+
item.annotationMap.set(customStyleAnnotation.type, new CustomStyleAnnotation(customStyleAnnotation.removeStyles(styleKeys)));
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Determines if the custom style annotation includes any the custom style.
|
|
961
|
+
*
|
|
962
|
+
* @param {CustomStyleAnnotation} customStyleAnnotation - custom style annotation
|
|
963
|
+
* @param {string[]} styleKeys - custom style keys, for examples ['fontSize', 'fontWeight'].
|
|
964
|
+
* @returns {boolean} - True if the custom key includes the custom style, false otherwise.
|
|
965
|
+
*/
|
|
966
|
+
isCustomStyle(customStyleAnnotation, styleKeys) {
|
|
967
|
+
return styleKeys.some((item) => Object.keys(customStyleAnnotation.customStyle).includes(item));
|
|
968
|
+
}
|
|
588
969
|
}
|
|
589
970
|
|
|
590
971
|
/**
|
|
@@ -645,7 +1026,12 @@ class RTEImageNode extends RTENode {
|
|
|
645
1026
|
annotations = node.annotations;
|
|
646
1027
|
}
|
|
647
1028
|
imageNode.annotationMap = new Map(Object.keys(annotations)
|
|
648
|
-
.map(() =>
|
|
1029
|
+
.map((type) => {
|
|
1030
|
+
if (type === 'size' || type === 'alt') {
|
|
1031
|
+
return ImageAnnotation.from(annotations.size, annotations.alt);
|
|
1032
|
+
}
|
|
1033
|
+
return this.createAnnotationEntity(type, annotations[type]);
|
|
1034
|
+
})
|
|
649
1035
|
.filter(isNonNullable));
|
|
650
1036
|
return imageNode;
|
|
651
1037
|
}
|
|
@@ -653,14 +1039,13 @@ class RTEImageNode extends RTENode {
|
|
|
653
1039
|
* @inheritDoc
|
|
654
1040
|
*/
|
|
655
1041
|
toJSON() {
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
661
|
-
if (
|
|
662
|
-
annotations.alt
|
|
663
|
-
}
|
|
1042
|
+
const annotations = Array.from(this.annotationMap.values())
|
|
1043
|
+
.filter((annotation) => annotation instanceof ImageAnnotation || annotation instanceof CommonAnnotation)
|
|
1044
|
+
.reduce((record, annotation) => {
|
|
1045
|
+
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
1046
|
+
}, {});
|
|
1047
|
+
if (annotations.alt == '')
|
|
1048
|
+
delete annotations.alt;
|
|
664
1049
|
return Object.assign(Object.assign({ id: this.id }, (Object.keys(annotations).length > 0 ? { annotations } : {})), { type: 'image', url: this.url });
|
|
665
1050
|
}
|
|
666
1051
|
/**
|
|
@@ -669,6 +1054,18 @@ class RTEImageNode extends RTENode {
|
|
|
669
1054
|
clone() {
|
|
670
1055
|
return new RTEImageNode(this.id, this.url, this.parentBlock, super.cloneAnnotations());
|
|
671
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* @inheritDoc
|
|
1059
|
+
*/
|
|
1060
|
+
toHtml() {
|
|
1061
|
+
const imageAnnotation = this.getAnnotationByType(NodeAnnotationTypeEnum.IMAGE);
|
|
1062
|
+
const attrStr = super.generateAttributeString(...[
|
|
1063
|
+
imageAnnotation && imageAnnotation.alt ? `alt="${imageAnnotation.alt}"` : null,
|
|
1064
|
+
`src="${this.url}"`,
|
|
1065
|
+
`data-size="${imageAnnotation.size}"`,
|
|
1066
|
+
].filter(isNonNullable));
|
|
1067
|
+
return `<img${attrStr}>`;
|
|
1068
|
+
}
|
|
672
1069
|
/**
|
|
673
1070
|
* @inheritDoc
|
|
674
1071
|
*/
|
|
@@ -856,76 +1253,24 @@ class BlockDeleteNodeContentStrategy extends ActionHandleStrategy {
|
|
|
856
1253
|
}
|
|
857
1254
|
}
|
|
858
1255
|
|
|
1256
|
+
/** Append blocks or nodes to a block */
|
|
1257
|
+
class AppendChildNodesAction extends ModifyContentAction {
|
|
1258
|
+
constructor(childNodes) {
|
|
1259
|
+
super();
|
|
1260
|
+
this.type = ModifyContentActionType.APPEND_CHILD_NODES;
|
|
1261
|
+
this.entityToBeAppended = childNodes;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
859
1265
|
/**
|
|
860
|
-
*
|
|
1266
|
+
* Append the second block child nodes to the first block child nodes and remove the second block strategy.
|
|
861
1267
|
*/
|
|
862
|
-
class
|
|
863
|
-
/**
|
|
864
|
-
* @inheritDoc
|
|
865
|
-
*/
|
|
866
|
-
handleAction(action, target) {
|
|
867
|
-
this.deleteNodeContent(action, target);
|
|
868
|
-
}
|
|
1268
|
+
class BlockMergeNodesStrategy extends ActionHandleStrategy {
|
|
869
1269
|
/**
|
|
870
|
-
*
|
|
1270
|
+
* Merges the child nodes of two RTEBlocks if they have the same type or both are not images.
|
|
871
1271
|
*
|
|
872
|
-
* @param {
|
|
873
|
-
* @param {RTEImageBlock} target - The image block.
|
|
874
|
-
*/
|
|
875
|
-
deleteNodeContent(action, target) {
|
|
876
|
-
const startContainerNode = action
|
|
877
|
-
.startContainerNode, startOffset = action.startOffset;
|
|
878
|
-
let previousNode = this.getPreviousNode(startContainerNode);
|
|
879
|
-
let nextNode = null;
|
|
880
|
-
if (startOffset === 1) {
|
|
881
|
-
const parentBlock = target;
|
|
882
|
-
if (this.isContentFirstNode(startContainerNode)) {
|
|
883
|
-
nextNode = this.getNextNode(startContainerNode);
|
|
884
|
-
}
|
|
885
|
-
if (parentBlock.nodes.length === 1) {
|
|
886
|
-
parentBlock.parent.apply(new RemoveChildAction(parentBlock));
|
|
887
|
-
}
|
|
888
|
-
else {
|
|
889
|
-
parentBlock.apply(new RemoveChildAction(startContainerNode));
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
else {
|
|
893
|
-
const shouldRemoveNode = previousNode;
|
|
894
|
-
if (shouldRemoveNode && shouldRemoveNode instanceof RTEImageNode) {
|
|
895
|
-
previousNode = this.getPreviousNode(shouldRemoveNode);
|
|
896
|
-
shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
|
|
897
|
-
if (!previousNode) {
|
|
898
|
-
action.nextNode = startContainerNode;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
if (previousNode) {
|
|
903
|
-
action.previousNode = previousNode;
|
|
904
|
-
}
|
|
905
|
-
else if (nextNode) {
|
|
906
|
-
action.nextNode = nextNode;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
/** Append blocks or nodes to a block */
|
|
912
|
-
class AppendChildNodesAction extends ModifyContentAction {
|
|
913
|
-
constructor(childNodes) {
|
|
914
|
-
super();
|
|
915
|
-
this.type = ModifyContentActionType.APPEND_CHILD_NODES;
|
|
916
|
-
this.entityToBeAppended = childNodes;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
/**
|
|
921
|
-
* Append the second block child nodes to the first block child nodes and remove the second block strategy.
|
|
922
|
-
*/
|
|
923
|
-
class BlockMergeNodesStrategy extends ActionHandleStrategy {
|
|
924
|
-
/**
|
|
925
|
-
* Merges the child nodes of two RTEBlocks if they have the same type or both are not images.
|
|
926
|
-
*
|
|
927
|
-
* @param {MergeTwoBlocksNodesAction} action - The merge block nodes action instance.
|
|
928
|
-
* @param {RTETextBlock | RTEImageBlock} target - The first text block or image block.
|
|
1272
|
+
* @param {MergeTwoBlocksNodesAction} action - The merge block nodes action instance.
|
|
1273
|
+
* @param {RTETextBlock | RTEImageBlock} target - The first text block or image block.
|
|
929
1274
|
*/
|
|
930
1275
|
handleAction(action, target) {
|
|
931
1276
|
const anotherBlock = action.blockNeedToBeMerged;
|
|
@@ -949,7 +1294,7 @@ class BlockRemoveNodeStrategy extends ActionHandleStrategy {
|
|
|
949
1294
|
* Remove the block if the block nodes is empty after delete the current node.
|
|
950
1295
|
*
|
|
951
1296
|
* @param {RemoveChildAction} action - The remove child action instance.
|
|
952
|
-
* @param {
|
|
1297
|
+
* @param {RTEBlockWithNodes} target - The parent block of the node that will be removed.
|
|
953
1298
|
*/
|
|
954
1299
|
handleAction(action, target) {
|
|
955
1300
|
const arrayFixed = target.nodes;
|
|
@@ -1024,51 +1369,6 @@ class ReplaceChildNodesAction extends ModifyContentAction {
|
|
|
1024
1369
|
}
|
|
1025
1370
|
}
|
|
1026
1371
|
|
|
1027
|
-
/**
|
|
1028
|
-
* Split the current image block with a special position strategy.
|
|
1029
|
-
*/
|
|
1030
|
-
class BlockSplitWithImageNodeStrategy extends ActionHandleStrategy {
|
|
1031
|
-
/**
|
|
1032
|
-
* @inheritDoc
|
|
1033
|
-
*/
|
|
1034
|
-
handleAction(action, target) {
|
|
1035
|
-
action.newBlock = this.splitImageNodes(action.splitPointNode, action.startOffsetOfNode, target);
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* The image offset should be 0 or 1
|
|
1039
|
-
* <vega-rich-text-image-editor><img /></vega-rich-text-image-editor>
|
|
1040
|
-
*
|
|
1041
|
-
* @param {RTEImageNode} imageNode The split point image node.
|
|
1042
|
-
* @param {number} imageOffset The cursor point 0 | 1.
|
|
1043
|
-
* @param {RTEImageBlock} target The image block.
|
|
1044
|
-
* @returns {Nullable<RTEBlock>} The new block after split
|
|
1045
|
-
*/
|
|
1046
|
-
splitImageNodes(imageNode, imageOffset, target) {
|
|
1047
|
-
const nodesSplitIndex = target.nodes.indexOf(imageNode);
|
|
1048
|
-
if (nodesSplitIndex > -1) {
|
|
1049
|
-
const beforeNodes = target.nodes.slice(0, nodesSplitIndex + imageOffset);
|
|
1050
|
-
const afterNodes = target.nodes.slice(nodesSplitIndex + imageOffset);
|
|
1051
|
-
target.apply(new ReplaceChildNodesAction(beforeNodes));
|
|
1052
|
-
const newBlock = this.cloneWithNodes(afterNodes, target);
|
|
1053
|
-
target.parent.apply(new InsertBlocksAfterAction(target, newBlock));
|
|
1054
|
-
return newBlock;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Creates a new RTEImageBlock instance with the provided RTEImageNode instances appended to it.
|
|
1059
|
-
*
|
|
1060
|
-
* @param {RTEImageNode[]} nodes - An array of RTEImageNode objects that will be used to create a new RTEImageBlock instance.
|
|
1061
|
-
* @param {RTEImageBlock} target The image block.
|
|
1062
|
-
* @returns {RTEImageBlock} A new `RTEImageBlock` object with the provided `nodes` appended to it.
|
|
1063
|
-
*/
|
|
1064
|
-
cloneWithNodes(nodes, target) {
|
|
1065
|
-
const block = target.createNewImageBlock();
|
|
1066
|
-
block.nodes = [];
|
|
1067
|
-
block.apply(new AppendChildNodesAction(nodes));
|
|
1068
|
-
return block;
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
1372
|
/**
|
|
1073
1373
|
* Insert a new block before a existing block
|
|
1074
1374
|
*
|
|
@@ -1165,20 +1465,20 @@ class StrikethroughAnnotation extends NodeAnnotation {
|
|
|
1165
1465
|
return new StrikethroughAnnotation(this.strikethrough);
|
|
1166
1466
|
}
|
|
1167
1467
|
/**
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
* @returns {Nullable<string>} - Annotation class
|
|
1468
|
+
* @inheritDoc
|
|
1171
1469
|
*/
|
|
1172
|
-
renderClass() {
|
|
1470
|
+
renderClass(options) {
|
|
1471
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
1472
|
+
return null;
|
|
1173
1473
|
return this.strikethrough ? 'v-rte--strikethrough' : null;
|
|
1174
1474
|
}
|
|
1175
1475
|
/**
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
1476
|
+
* @inheritDoc
|
|
1179
1477
|
*/
|
|
1180
|
-
|
|
1181
|
-
|
|
1478
|
+
renderStyle(options) {
|
|
1479
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
1480
|
+
return null;
|
|
1481
|
+
return this.strikethrough ? { textDecoration: 'line-through' } : null;
|
|
1182
1482
|
}
|
|
1183
1483
|
}
|
|
1184
1484
|
|
|
@@ -1217,20 +1517,20 @@ class UnderlineAnnotation extends NodeAnnotation {
|
|
|
1217
1517
|
return new UnderlineAnnotation(this.underline);
|
|
1218
1518
|
}
|
|
1219
1519
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
* @returns {Nullable<string>} - Annotation class
|
|
1520
|
+
* @inheritDoc
|
|
1223
1521
|
*/
|
|
1224
|
-
renderClass() {
|
|
1522
|
+
renderClass(options) {
|
|
1523
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
1524
|
+
return null;
|
|
1225
1525
|
return this.underline ? 'v-rte--underline' : null;
|
|
1226
1526
|
}
|
|
1227
1527
|
/**
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
1528
|
+
* @inheritDoc
|
|
1231
1529
|
*/
|
|
1232
|
-
|
|
1233
|
-
|
|
1530
|
+
renderStyle(options) {
|
|
1531
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
1532
|
+
return null;
|
|
1533
|
+
return this.underline ? { textDecoration: 'underline' } : null;
|
|
1234
1534
|
}
|
|
1235
1535
|
}
|
|
1236
1536
|
|
|
@@ -1269,12 +1569,20 @@ class ItalicAnnotation extends NodeAnnotation {
|
|
|
1269
1569
|
return new ItalicAnnotation(this.italic);
|
|
1270
1570
|
}
|
|
1271
1571
|
/**
|
|
1272
|
-
*
|
|
1273
|
-
|
|
1274
|
-
|
|
1572
|
+
* @inheritDoc
|
|
1573
|
+
*/
|
|
1574
|
+
renderClass(options) {
|
|
1575
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
1576
|
+
return null;
|
|
1577
|
+
return this.italic ? 'v-rte--italic' : null;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* @inheritDoc
|
|
1275
1581
|
*/
|
|
1276
|
-
|
|
1277
|
-
|
|
1582
|
+
renderStyle(options) {
|
|
1583
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
1584
|
+
return null;
|
|
1585
|
+
return this.italic ? { fontStyle: 'italic' } : null;
|
|
1278
1586
|
}
|
|
1279
1587
|
}
|
|
1280
1588
|
|
|
@@ -1313,12 +1621,20 @@ class BoldAnnotation extends NodeAnnotation {
|
|
|
1313
1621
|
return new BoldAnnotation(this.bold);
|
|
1314
1622
|
}
|
|
1315
1623
|
/**
|
|
1316
|
-
*
|
|
1317
|
-
|
|
1318
|
-
|
|
1624
|
+
* @inheritDoc
|
|
1625
|
+
*/
|
|
1626
|
+
renderClass(options) {
|
|
1627
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
1628
|
+
return null;
|
|
1629
|
+
return this.bold ? 'v-rte--bold' : null;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* @inheritDoc
|
|
1319
1633
|
*/
|
|
1320
|
-
|
|
1321
|
-
|
|
1634
|
+
renderStyle(options) {
|
|
1635
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
1636
|
+
return null;
|
|
1637
|
+
return this.bold ? { fontWeight: '700' } : null;
|
|
1322
1638
|
}
|
|
1323
1639
|
}
|
|
1324
1640
|
|
|
@@ -1357,20 +1673,25 @@ class CodeAnnotation extends NodeAnnotation {
|
|
|
1357
1673
|
return new CodeAnnotation(this.code);
|
|
1358
1674
|
}
|
|
1359
1675
|
/**
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1362
|
-
* @returns {Nullable<string>} - Annotation class
|
|
1676
|
+
* @inheritDoc
|
|
1363
1677
|
*/
|
|
1364
|
-
renderClass() {
|
|
1678
|
+
renderClass(options) {
|
|
1679
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
1680
|
+
return null;
|
|
1365
1681
|
return this.code ? 'v-rte--code' : null;
|
|
1366
1682
|
}
|
|
1367
1683
|
/**
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
* @returns {Nullable<AnnotationStyle>} Bold style
|
|
1684
|
+
* @inheritDoc
|
|
1371
1685
|
*/
|
|
1372
|
-
|
|
1373
|
-
|
|
1686
|
+
renderStyle(options) {
|
|
1687
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
1688
|
+
return null;
|
|
1689
|
+
return this.code
|
|
1690
|
+
? {
|
|
1691
|
+
fontFamily: 'Roboto Mono',
|
|
1692
|
+
whiteSpace: 'pre-wrap',
|
|
1693
|
+
}
|
|
1694
|
+
: null;
|
|
1374
1695
|
}
|
|
1375
1696
|
}
|
|
1376
1697
|
|
|
@@ -1443,19 +1764,15 @@ class TextColorAnnotation extends NodeAnnotation {
|
|
|
1443
1764
|
return new TextColorAnnotation(this.textColor.key);
|
|
1444
1765
|
}
|
|
1445
1766
|
/**
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
* @returns {Nullable<string>} - Annotation class
|
|
1767
|
+
* @inheritDoc
|
|
1449
1768
|
*/
|
|
1450
1769
|
renderClass() {
|
|
1451
1770
|
return null;
|
|
1452
1771
|
}
|
|
1453
1772
|
/**
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1456
|
-
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
1773
|
+
* @inheritDoc
|
|
1457
1774
|
*/
|
|
1458
|
-
|
|
1775
|
+
renderStyle() {
|
|
1459
1776
|
return {
|
|
1460
1777
|
color: VegaInternalThemeManager.isDarkMode() ? this.textColor.dark : this.textColor.light,
|
|
1461
1778
|
};
|
|
@@ -1487,10 +1804,7 @@ class LinkAnnotation extends NodeAnnotation {
|
|
|
1487
1804
|
* @returns {[NodeAnnotationTypeEnum.LINK, LinkAnnotation]} Map item for the annotation
|
|
1488
1805
|
*/
|
|
1489
1806
|
static from(link) {
|
|
1490
|
-
return [
|
|
1491
|
-
NodeAnnotationTypeEnum.LINK,
|
|
1492
|
-
new LinkAnnotation({ href: link.href, groupKey: link.groupKey }),
|
|
1493
|
-
];
|
|
1807
|
+
return [NodeAnnotationTypeEnum.LINK, new LinkAnnotation(link)];
|
|
1494
1808
|
}
|
|
1495
1809
|
/**
|
|
1496
1810
|
* Generate the JSON representation of the annotation
|
|
@@ -1498,7 +1812,9 @@ class LinkAnnotation extends NodeAnnotation {
|
|
|
1498
1812
|
* @returns {Record<'link', VegaRTELink>} JSON representation of the annotation
|
|
1499
1813
|
*/
|
|
1500
1814
|
toJSON() {
|
|
1501
|
-
return {
|
|
1815
|
+
return {
|
|
1816
|
+
link: this.link,
|
|
1817
|
+
};
|
|
1502
1818
|
}
|
|
1503
1819
|
/**
|
|
1504
1820
|
* @inheritDoc
|
|
@@ -1516,11 +1832,15 @@ class LinkAnnotation extends NodeAnnotation {
|
|
|
1516
1832
|
return this.link.groupKey === annotation.link.groupKey;
|
|
1517
1833
|
}
|
|
1518
1834
|
/**
|
|
1519
|
-
*
|
|
1520
|
-
*
|
|
1521
|
-
* @returns {Nullable<AnnotationStyle>} Link style
|
|
1835
|
+
* @inheritDoc
|
|
1522
1836
|
*/
|
|
1523
|
-
|
|
1837
|
+
renderClass() {
|
|
1838
|
+
return null;
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* @inheritDoc
|
|
1842
|
+
*/
|
|
1843
|
+
renderStyle() {
|
|
1524
1844
|
return null;
|
|
1525
1845
|
}
|
|
1526
1846
|
}
|
|
@@ -1542,6 +1862,94 @@ class LinkGroupAnnotation extends Annotation {
|
|
|
1542
1862
|
});
|
|
1543
1863
|
return clonedAnnotation;
|
|
1544
1864
|
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Convert the custom style, class and attribute to string which html can used
|
|
1867
|
+
*
|
|
1868
|
+
* @param {linkAnnotation} linkAnnotation current link annotation which saved custom style, class and attribute.
|
|
1869
|
+
* @param {RTERenderContext} options - options.
|
|
1870
|
+
* @returns {string} - string.
|
|
1871
|
+
*/
|
|
1872
|
+
toString(linkAnnotation, options) {
|
|
1873
|
+
const attributes = this.toJsx(linkAnnotation, options);
|
|
1874
|
+
return Object.entries(attributes)
|
|
1875
|
+
.map(([key, value]) => {
|
|
1876
|
+
const valueString = typeof value === 'string' ? value : this.formatStyleToString(value);
|
|
1877
|
+
return `${camelToDashCase(key)}="${valueString}"`;
|
|
1878
|
+
})
|
|
1879
|
+
.join(' ');
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Convert the custom style, class and attribute to JSX attributes
|
|
1883
|
+
*
|
|
1884
|
+
* @param {linkAnnotation} linkAnnotation current link annotation which saved custom style, class and attribute.
|
|
1885
|
+
* @param {RTERenderContext} options - options.
|
|
1886
|
+
* @returns {Record<string, string | AnnotationStyle>} JSX used attributes.
|
|
1887
|
+
*/
|
|
1888
|
+
toJsx(linkAnnotation, options) {
|
|
1889
|
+
const linkStyle = this.getStyle(linkAnnotation, options);
|
|
1890
|
+
const linkClass = this.getClass(linkAnnotation, options);
|
|
1891
|
+
const attributes = this.getAttribute(linkAnnotation);
|
|
1892
|
+
if (linkClass.length > 0) {
|
|
1893
|
+
attributes.class = linkClass.join(' ');
|
|
1894
|
+
}
|
|
1895
|
+
if (linkStyle && Object.keys(linkStyle).length > 0) {
|
|
1896
|
+
attributes.style = linkStyle;
|
|
1897
|
+
}
|
|
1898
|
+
return attributes;
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Get the custom class for the annotation
|
|
1902
|
+
*
|
|
1903
|
+
* @param {linkAnnotation} linkAnnotation current link annotation which saved custom style, class and attribute.
|
|
1904
|
+
* @param {RTERenderContext} options - options.
|
|
1905
|
+
* @returns {string[]} Link class
|
|
1906
|
+
*/
|
|
1907
|
+
getClass(linkAnnotation, options) {
|
|
1908
|
+
const linkClass = [];
|
|
1909
|
+
if (linkAnnotation.link.customClass)
|
|
1910
|
+
linkClass.push(...linkAnnotation.link.customClass);
|
|
1911
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
1912
|
+
linkClass.push('v-rte--link');
|
|
1913
|
+
return linkClass;
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Get the custom style for the annotation
|
|
1917
|
+
*
|
|
1918
|
+
* @param {LinkAnnotation} linkAnnotation current link annotation which saved custom style, class and attribute.
|
|
1919
|
+
* @param {RTERenderContext} options - options.
|
|
1920
|
+
* @returns {AnnotationStyle} Link style
|
|
1921
|
+
*/
|
|
1922
|
+
getStyle(linkAnnotation, options) {
|
|
1923
|
+
const linkStyle = {};
|
|
1924
|
+
if (linkAnnotation.link.customStyle)
|
|
1925
|
+
Object.assign(linkStyle, linkAnnotation.link.customStyle);
|
|
1926
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
1927
|
+
linkStyle.color = 'rgba(var(--v-text-link, 19, 98, 226, 1))';
|
|
1928
|
+
return linkStyle;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Get the custom attribute for the annotation
|
|
1932
|
+
*
|
|
1933
|
+
* @param {LinkAnnotation} linkAnnotation current link annotation which saved custom style, class and attribute.
|
|
1934
|
+
* @returns {Record<string, string>} Link attributes
|
|
1935
|
+
*/
|
|
1936
|
+
getAttribute(linkAnnotation) {
|
|
1937
|
+
const { href, customAttribute = {} } = linkAnnotation.link;
|
|
1938
|
+
customAttribute.href = href;
|
|
1939
|
+
customAttribute.target = customAttribute.target || '_blank';
|
|
1940
|
+
return customAttribute;
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Convert style to string which can be used to html string.
|
|
1944
|
+
*
|
|
1945
|
+
* @param {AnnotationStyle} style Style object.
|
|
1946
|
+
* @returns {string} Style string
|
|
1947
|
+
*/
|
|
1948
|
+
formatStyleToString(style) {
|
|
1949
|
+
return Object.entries(style)
|
|
1950
|
+
.map(([key, value]) => `${camelToDashCase(key)}: ${value};`)
|
|
1951
|
+
.join(' ');
|
|
1952
|
+
}
|
|
1545
1953
|
}
|
|
1546
1954
|
|
|
1547
1955
|
/**
|
|
@@ -1790,6 +2198,25 @@ class NodeSplitTextStrategy extends ActionHandleStrategy {
|
|
|
1790
2198
|
}
|
|
1791
2199
|
}
|
|
1792
2200
|
|
|
2201
|
+
/**
|
|
2202
|
+
* Action to toggle bold annotation
|
|
2203
|
+
*/
|
|
2204
|
+
class BoldAnnotationAction extends TextSplittableAction {
|
|
2205
|
+
constructor(bold) {
|
|
2206
|
+
super();
|
|
2207
|
+
this.isFlushable = true;
|
|
2208
|
+
this.bold = bold;
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Converts the action to an annotation
|
|
2212
|
+
*
|
|
2213
|
+
* @returns {BoldAnnotation} the annotation
|
|
2214
|
+
*/
|
|
2215
|
+
toAnnotation() {
|
|
2216
|
+
return new BoldAnnotation(this.bold);
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
|
|
1793
2220
|
/**
|
|
1794
2221
|
* Annotation to host which annotations will be clear formatting
|
|
1795
2222
|
*/
|
|
@@ -1804,6 +2231,7 @@ class ClearFormattingAnnotation extends Annotation {
|
|
|
1804
2231
|
NodeAnnotationTypeEnum.STRIKETHROUGH,
|
|
1805
2232
|
NodeAnnotationTypeEnum.TEXT_COLOR,
|
|
1806
2233
|
NodeAnnotationTypeEnum.CODE,
|
|
2234
|
+
CommonAnnotationTypeEnum.CUSTOM_STYLE,
|
|
1807
2235
|
];
|
|
1808
2236
|
}
|
|
1809
2237
|
}
|
|
@@ -1864,6 +2292,25 @@ class DeleteNodeAnnotationAction extends AnnotationAction {
|
|
|
1864
2292
|
}
|
|
1865
2293
|
}
|
|
1866
2294
|
|
|
2295
|
+
/**
|
|
2296
|
+
* Action to toggle the italic annotation
|
|
2297
|
+
*/
|
|
2298
|
+
class ItalicAnnotationAction extends TextSplittableAction {
|
|
2299
|
+
constructor(italic) {
|
|
2300
|
+
super();
|
|
2301
|
+
this.isFlushable = true;
|
|
2302
|
+
this.italic = italic;
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Converts the action to an annotation
|
|
2306
|
+
*
|
|
2307
|
+
* @returns {ItalicAnnotation} The annotation
|
|
2308
|
+
*/
|
|
2309
|
+
toAnnotation() {
|
|
2310
|
+
return new ItalicAnnotation(this.italic);
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
|
|
1867
2314
|
/**
|
|
1868
2315
|
* Action to toggle link annotation
|
|
1869
2316
|
*/
|
|
@@ -1888,6 +2335,44 @@ class LinkAnnotationAction extends TextSplittableAction {
|
|
|
1888
2335
|
}
|
|
1889
2336
|
}
|
|
1890
2337
|
|
|
2338
|
+
/**
|
|
2339
|
+
* Action to toggle the strikethrough annotation
|
|
2340
|
+
*/
|
|
2341
|
+
class StrikethroughAnnotationAction extends TextSplittableAction {
|
|
2342
|
+
constructor(underline) {
|
|
2343
|
+
super();
|
|
2344
|
+
this.isFlushable = true;
|
|
2345
|
+
this.strikethrough = underline;
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Converts the action to an annotation
|
|
2349
|
+
*
|
|
2350
|
+
* @returns {Annotation} the annotation
|
|
2351
|
+
*/
|
|
2352
|
+
toAnnotation() {
|
|
2353
|
+
return new StrikethroughAnnotation(this.strikethrough);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
/**
|
|
2358
|
+
* Action to toggle the underline annotation
|
|
2359
|
+
*/
|
|
2360
|
+
class UnderlineAnnotationAction extends TextSplittableAction {
|
|
2361
|
+
constructor(underline) {
|
|
2362
|
+
super();
|
|
2363
|
+
this.isFlushable = true;
|
|
2364
|
+
this.underline = underline;
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Converts the action to an annotation
|
|
2368
|
+
*
|
|
2369
|
+
* @returns {Annotation} the annotation
|
|
2370
|
+
*/
|
|
2371
|
+
toAnnotation() {
|
|
2372
|
+
return new UnderlineAnnotation(this.underline);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
1891
2376
|
/**
|
|
1892
2377
|
* The current strategy used to modify the text node annotation map.
|
|
1893
2378
|
*/
|
|
@@ -1920,6 +2405,16 @@ class NodeUpdateAnnotationMapStrategy extends ActionHandleStrategy {
|
|
|
1920
2405
|
if (action instanceof CodeAnnotationAction) {
|
|
1921
2406
|
this.handleAction(new ClearFormattingAnnotationAction(), target);
|
|
1922
2407
|
}
|
|
2408
|
+
if (action instanceof BoldAnnotationAction) {
|
|
2409
|
+
this.updateCustomStyleAnnotation(target, ['fontWeight']);
|
|
2410
|
+
}
|
|
2411
|
+
if (action instanceof ItalicAnnotationAction) {
|
|
2412
|
+
this.updateCustomStyleAnnotation(target, ['fontStyle']);
|
|
2413
|
+
}
|
|
2414
|
+
if (action instanceof UnderlineAnnotationAction ||
|
|
2415
|
+
action instanceof StrikethroughAnnotationAction) {
|
|
2416
|
+
this.updateCustomStyleAnnotation(target, ['textDecoration']);
|
|
2417
|
+
}
|
|
1923
2418
|
target.annotationMap.set(annotation.type, annotation);
|
|
1924
2419
|
return;
|
|
1925
2420
|
}
|
|
@@ -1983,18 +2478,30 @@ class RTETextNode extends RTENode {
|
|
|
1983
2478
|
case 'link':
|
|
1984
2479
|
return LinkAnnotation.from(value);
|
|
1985
2480
|
}
|
|
2481
|
+
return RTENode.createAnnotationEntity(type, value);
|
|
1986
2482
|
}
|
|
1987
2483
|
/**
|
|
1988
2484
|
* @inheritDoc
|
|
1989
2485
|
*/
|
|
1990
2486
|
toJSON() {
|
|
1991
2487
|
const annotations = Array.from(this.annotationMap.values())
|
|
1992
|
-
.filter((annotation) => annotation instanceof NodeAnnotation)
|
|
2488
|
+
.filter((annotation) => annotation instanceof NodeAnnotation || annotation instanceof CommonAnnotation)
|
|
1993
2489
|
.reduce((record, annotation) => {
|
|
1994
2490
|
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
1995
2491
|
}, {});
|
|
1996
2492
|
return Object.assign(Object.assign({ id: this.id }, (Object.keys(annotations).length > 0 ? { annotations } : {})), { type: 'text', text: this.text });
|
|
1997
2493
|
}
|
|
2494
|
+
/**
|
|
2495
|
+
* @inheritDoc
|
|
2496
|
+
*/
|
|
2497
|
+
toHtml() {
|
|
2498
|
+
var _a;
|
|
2499
|
+
const NodeTag = ((_a = this.getAnnotationByType(NodeAnnotationTypeEnum.CODE)) === null || _a === void 0 ? void 0 : _a.code)
|
|
2500
|
+
? 'code'
|
|
2501
|
+
: 'span';
|
|
2502
|
+
const attrStr = super.generateAttributeString();
|
|
2503
|
+
return `<${NodeTag}${attrStr}>${this.text}</${NodeTag}>`;
|
|
2504
|
+
}
|
|
1998
2505
|
/**
|
|
1999
2506
|
* Creates a new RTETextNode with the specified text and copies the parent block and annotation map from the original node.
|
|
2000
2507
|
*
|
|
@@ -2120,44 +2627,106 @@ class TextStyleAnnotation extends BlockAnnotation {
|
|
|
2120
2627
|
return new TextStyleAnnotation(this.textStyle);
|
|
2121
2628
|
}
|
|
2122
2629
|
/**
|
|
2123
|
-
*
|
|
2124
|
-
|
|
2125
|
-
|
|
2630
|
+
* @inheritDoc
|
|
2631
|
+
*/
|
|
2632
|
+
renderClass(options) {
|
|
2633
|
+
if (options === null || options === void 0 ? void 0 : options.standalone)
|
|
2634
|
+
return null;
|
|
2635
|
+
return `v-rte--text-style-${this.textStyle}`;
|
|
2636
|
+
}
|
|
2637
|
+
/**
|
|
2638
|
+
* @inheritDoc
|
|
2126
2639
|
*/
|
|
2127
|
-
|
|
2640
|
+
renderStyle(options) {
|
|
2641
|
+
if (!(options === null || options === void 0 ? void 0 : options.standalone))
|
|
2642
|
+
return null;
|
|
2128
2643
|
const paragraphStyle = {
|
|
2129
2644
|
fontFamily: 'Inter',
|
|
2130
2645
|
fontSize: '16px',
|
|
2131
2646
|
lineHeight: '22px',
|
|
2132
2647
|
fontWeight: '500',
|
|
2648
|
+
marginTop: '0px',
|
|
2649
|
+
marginBottom: '0px',
|
|
2133
2650
|
};
|
|
2134
2651
|
switch (this.textStyle) {
|
|
2135
2652
|
case 'paragraph': {
|
|
2136
2653
|
return paragraphStyle;
|
|
2137
2654
|
}
|
|
2138
2655
|
case 'title': {
|
|
2139
|
-
return {
|
|
2656
|
+
return {
|
|
2657
|
+
fontFamily: 'Inter',
|
|
2658
|
+
fontSize: '36px',
|
|
2659
|
+
lineHeight: '40px',
|
|
2660
|
+
fontWeight: '500',
|
|
2661
|
+
};
|
|
2140
2662
|
}
|
|
2141
2663
|
case 'subtitle': {
|
|
2142
|
-
return {
|
|
2664
|
+
return {
|
|
2665
|
+
fontFamily: 'Inter',
|
|
2666
|
+
fontSize: '28px',
|
|
2667
|
+
lineHeight: '32px',
|
|
2668
|
+
fontWeight: '500',
|
|
2669
|
+
};
|
|
2143
2670
|
}
|
|
2144
2671
|
case 'heading-1': {
|
|
2145
|
-
return {
|
|
2672
|
+
return {
|
|
2673
|
+
fontFamily: 'Inter',
|
|
2674
|
+
fontSize: '22px',
|
|
2675
|
+
lineHeight: '24px',
|
|
2676
|
+
fontWeight: '500',
|
|
2677
|
+
marginTop: '0px',
|
|
2678
|
+
marginBottom: '0px',
|
|
2679
|
+
};
|
|
2146
2680
|
}
|
|
2147
2681
|
case 'heading-2': {
|
|
2148
|
-
return {
|
|
2682
|
+
return {
|
|
2683
|
+
fontFamily: 'Inter',
|
|
2684
|
+
fontSize: '20px',
|
|
2685
|
+
lineHeight: '24px',
|
|
2686
|
+
fontWeight: '500',
|
|
2687
|
+
marginTop: '0px',
|
|
2688
|
+
marginBottom: '0px',
|
|
2689
|
+
};
|
|
2149
2690
|
}
|
|
2150
2691
|
case 'heading-3': {
|
|
2151
|
-
return {
|
|
2692
|
+
return {
|
|
2693
|
+
fontFamily: 'Inter',
|
|
2694
|
+
fontSize: '18px',
|
|
2695
|
+
lineHeight: '22px',
|
|
2696
|
+
fontWeight: '500',
|
|
2697
|
+
marginTop: '0px',
|
|
2698
|
+
marginBottom: '0px',
|
|
2699
|
+
};
|
|
2152
2700
|
}
|
|
2153
2701
|
case 'heading-4': {
|
|
2154
|
-
return {
|
|
2702
|
+
return {
|
|
2703
|
+
fontFamily: 'Inter',
|
|
2704
|
+
fontSize: '16px',
|
|
2705
|
+
lineHeight: '22px',
|
|
2706
|
+
fontWeight: '500',
|
|
2707
|
+
marginTop: '0px',
|
|
2708
|
+
marginBottom: '0px',
|
|
2709
|
+
};
|
|
2155
2710
|
}
|
|
2156
2711
|
case 'heading-5': {
|
|
2157
|
-
return {
|
|
2712
|
+
return {
|
|
2713
|
+
fontFamily: 'Inter',
|
|
2714
|
+
fontSize: '14px',
|
|
2715
|
+
lineHeight: '22px',
|
|
2716
|
+
fontWeight: '500',
|
|
2717
|
+
marginTop: '0px',
|
|
2718
|
+
marginBottom: '0px',
|
|
2719
|
+
};
|
|
2158
2720
|
}
|
|
2159
2721
|
case 'heading-6': {
|
|
2160
|
-
return {
|
|
2722
|
+
return {
|
|
2723
|
+
fontFamily: 'Inter',
|
|
2724
|
+
fontSize: '12px',
|
|
2725
|
+
lineHeight: '22px',
|
|
2726
|
+
fontWeight: '500',
|
|
2727
|
+
marginTop: '0px',
|
|
2728
|
+
marginBottom: '0px',
|
|
2729
|
+
};
|
|
2161
2730
|
}
|
|
2162
2731
|
}
|
|
2163
2732
|
}
|
|
@@ -2183,25 +2752,6 @@ class TextStyleAnnotationAction extends AnnotationAction {
|
|
|
2183
2752
|
}
|
|
2184
2753
|
}
|
|
2185
2754
|
|
|
2186
|
-
/**
|
|
2187
|
-
* Action to toggle bold annotation
|
|
2188
|
-
*/
|
|
2189
|
-
class BoldAnnotationAction extends TextSplittableAction {
|
|
2190
|
-
constructor(bold) {
|
|
2191
|
-
super();
|
|
2192
|
-
this.isFlushable = true;
|
|
2193
|
-
this.bold = bold;
|
|
2194
|
-
}
|
|
2195
|
-
/**
|
|
2196
|
-
* Converts the action to an annotation
|
|
2197
|
-
*
|
|
2198
|
-
* @returns {BoldAnnotation} the annotation
|
|
2199
|
-
*/
|
|
2200
|
-
toAnnotation() {
|
|
2201
|
-
return new BoldAnnotation(this.bold);
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
2755
|
/**
|
|
2206
2756
|
* Update the text block text style strategy.
|
|
2207
2757
|
*/
|
|
@@ -2228,6 +2778,7 @@ class BlockUpdateTextStyleStrategy extends ActionHandleStrategy {
|
|
|
2228
2778
|
node.apply(new DeleteNodeAnnotationAction(NodeAnnotationTypeEnum.BOLD));
|
|
2229
2779
|
});
|
|
2230
2780
|
}
|
|
2781
|
+
this.updateCustomStyleAnnotation(target, ['fontFamily', 'lineHeight', 'fontWeight', 'fontSize']);
|
|
2231
2782
|
}
|
|
2232
2783
|
}
|
|
2233
2784
|
|
|
@@ -2514,7 +3065,9 @@ class BlockDeleteTextContentStrategy extends BlockDeleteNodeContentStrategy {
|
|
|
2514
3065
|
if (startContainerNode.isEmpty()) {
|
|
2515
3066
|
target.apply(new RemoveChildAction(startContainerNode));
|
|
2516
3067
|
}
|
|
2517
|
-
previousNode.parentBlock.
|
|
3068
|
+
if (target.type === previousNode.parentBlock.type) {
|
|
3069
|
+
previousNode.parentBlock.apply(new MergeTwoBlocksNodesAction(target));
|
|
3070
|
+
}
|
|
2518
3071
|
}
|
|
2519
3072
|
else {
|
|
2520
3073
|
if (this.isContentFirstNode(startContainerNode) && startContainerNode.isEmpty()) {
|
|
@@ -2654,22 +3207,90 @@ class BlockTransformToListStrategy extends ActionHandleStrategy {
|
|
|
2654
3207
|
}
|
|
2655
3208
|
|
|
2656
3209
|
/**
|
|
2657
|
-
*
|
|
3210
|
+
* Action to toggle block horizontal alignment annotation
|
|
2658
3211
|
*/
|
|
2659
|
-
class
|
|
2660
|
-
constructor(
|
|
2661
|
-
super(
|
|
2662
|
-
this.
|
|
2663
|
-
this.
|
|
2664
|
-
if (RTETextBlock.isAcceptableTextStyle(type)) {
|
|
2665
|
-
this.annotationMap = new Map([TextStyleAnnotation.from(type)]);
|
|
2666
|
-
}
|
|
2667
|
-
else {
|
|
2668
|
-
this.annotationMap = new Map([TextStyleAnnotation.from('paragraph')]);
|
|
2669
|
-
}
|
|
3212
|
+
class HorizontalAlignmentAnnotationAction extends AnnotationAction {
|
|
3213
|
+
constructor(textAlign) {
|
|
3214
|
+
super();
|
|
3215
|
+
this.isFlushable = true;
|
|
3216
|
+
this.textAlign = textAlign;
|
|
2670
3217
|
}
|
|
2671
3218
|
/**
|
|
2672
|
-
* Converts
|
|
3219
|
+
* Converts the action to an annotation
|
|
3220
|
+
*
|
|
3221
|
+
* @returns {HorizontalAlignmentAnnotation} The annotation
|
|
3222
|
+
*/
|
|
3223
|
+
toAnnotation() {
|
|
3224
|
+
return new HorizontalAlignmentAnnotation(this.textAlign);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
/**
|
|
3229
|
+
* Update the text block and image block horizontal alignment strategy.
|
|
3230
|
+
*/
|
|
3231
|
+
class BlockUpdateHorizontalAlignmentStrategy extends ActionHandleStrategy {
|
|
3232
|
+
/**
|
|
3233
|
+
* Updating the horizontal alignment of a block requires cascading updates to the custom style.
|
|
3234
|
+
*
|
|
3235
|
+
* @param {HorizontalAlignmentAnnotationAction} _action - The horizontal alignment annotation action.
|
|
3236
|
+
* @param {RTETextBlock} target - The current text block.
|
|
3237
|
+
*/
|
|
3238
|
+
handleAction(_action, target) {
|
|
3239
|
+
this.updateCustomStyleAnnotation(target, ['textAlign']);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
/**
|
|
3244
|
+
* Update the text block and image block horizontal alignment strategy.
|
|
3245
|
+
*/
|
|
3246
|
+
class BlockUpdateIndentStrategy extends ActionHandleStrategy {
|
|
3247
|
+
/**
|
|
3248
|
+
* Updating the indent of a block requires cascading updates to the custom style.
|
|
3249
|
+
*
|
|
3250
|
+
* @param {IndentAnnotationAction} _action - The indent annotation action.
|
|
3251
|
+
* @param {RTETextBlock} target - The current text block.
|
|
3252
|
+
*/
|
|
3253
|
+
handleAction(_action, target) {
|
|
3254
|
+
this.updateCustomStyleAnnotation(target, ['marginLeft']);
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
/**
|
|
3259
|
+
* Action to toggle block indent annotation
|
|
3260
|
+
*/
|
|
3261
|
+
class IndentAnnotationAction extends AnnotationAction {
|
|
3262
|
+
constructor(indent) {
|
|
3263
|
+
super();
|
|
3264
|
+
this.isFlushable = true;
|
|
3265
|
+
this.indent = indent;
|
|
3266
|
+
}
|
|
3267
|
+
/**
|
|
3268
|
+
* Converts the action to an annotation
|
|
3269
|
+
*
|
|
3270
|
+
* @returns {Annotation} The annotation
|
|
3271
|
+
*/
|
|
3272
|
+
toAnnotation() {
|
|
3273
|
+
return new IndentAnnotation(this.indent);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
/**
|
|
3278
|
+
* Text block
|
|
3279
|
+
*/
|
|
3280
|
+
class RTETextBlock extends RTEBlock {
|
|
3281
|
+
constructor(id, type) {
|
|
3282
|
+
super(id);
|
|
3283
|
+
this.nodes = [];
|
|
3284
|
+
this.type = type;
|
|
3285
|
+
if (RTETextBlock.isAcceptableTextStyle(type)) {
|
|
3286
|
+
this.annotationMap = new Map([TextStyleAnnotation.from(type)]);
|
|
3287
|
+
}
|
|
3288
|
+
else {
|
|
3289
|
+
this.annotationMap = new Map([TextStyleAnnotation.from('paragraph')]);
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Converts a VegaRTETextBlock into an RTETextBlock.
|
|
2673
3294
|
*
|
|
2674
3295
|
* @param {VegaRTETextBlock} block - The block object
|
|
2675
3296
|
* @returns {RTETextBlock} A RTETextBlock class
|
|
@@ -2697,7 +3318,7 @@ class RTETextBlock extends RTEBlock {
|
|
|
2697
3318
|
* @param {unknown} value - The `value` parameter in the `createAnnotationEntity` function is the value
|
|
2698
3319
|
* that will be used to create the annotation entity. It can be of any type depending on the specific
|
|
2699
3320
|
* annotation being created.
|
|
2700
|
-
* @returns {Nullable<
|
|
3321
|
+
* @returns {Nullable<BlockAnnotationsEntity>} The `createAnnotationEntity` function returns a nullable tuple containing a
|
|
2701
3322
|
* `BlockAnnotationTypeEnum` and a `BlockAnnotation` object.
|
|
2702
3323
|
*/
|
|
2703
3324
|
static createAnnotationEntity(type, value) {
|
|
@@ -2754,6 +3375,36 @@ class RTETextBlock extends RTEBlock {
|
|
|
2754
3375
|
toJSON() {
|
|
2755
3376
|
return Object.assign(Object.assign({}, super.toJSON()), { type: this.type, nodes: this.nodes.map((node) => node.toJSON()) });
|
|
2756
3377
|
}
|
|
3378
|
+
/**
|
|
3379
|
+
* @inheritDoc
|
|
3380
|
+
*/
|
|
3381
|
+
toHtml() {
|
|
3382
|
+
const BlockTag = this.getBlockTag();
|
|
3383
|
+
const attrStr = super.generateAttributeString();
|
|
3384
|
+
const linkGroupAnnotation = this.getAnnotationByType(InternalAnnotationTypeEnum.LINK_GROUP);
|
|
3385
|
+
let nodesHtml = this.nodes.map((node) => node.toHtml()).join('');
|
|
3386
|
+
if (linkGroupAnnotation && this.nodes.length > 0) {
|
|
3387
|
+
//TODO: should revert to above code while https://gethired.atlassian.net/browse/VD-6513 have be fixed.
|
|
3388
|
+
// const linkAnnotation: Nullable<LinkAnnotation> =
|
|
3389
|
+
// this.nodes[0].getAnnotationByType<LinkAnnotation>(NodeAnnotationTypeEnum.LINK);
|
|
3390
|
+
let linkAnnotation;
|
|
3391
|
+
this.nodes.find((node) => {
|
|
3392
|
+
const link = node.getAnnotationByType(NodeAnnotationTypeEnum.LINK);
|
|
3393
|
+
if (link) {
|
|
3394
|
+
linkAnnotation = link;
|
|
3395
|
+
return true;
|
|
3396
|
+
}
|
|
3397
|
+
});
|
|
3398
|
+
if (linkAnnotation) {
|
|
3399
|
+
nodesHtml = [
|
|
3400
|
+
`<a ${linkGroupAnnotation.toString(linkAnnotation, { standalone: true })}>`,
|
|
3401
|
+
nodesHtml,
|
|
3402
|
+
`</a>`,
|
|
3403
|
+
].join('');
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
return [`<${BlockTag}${attrStr}>`, nodesHtml, `</${BlockTag}>`].join('');
|
|
3407
|
+
}
|
|
2757
3408
|
/**
|
|
2758
3409
|
* Clone the nodes to a new block
|
|
2759
3410
|
*
|
|
@@ -2800,6 +3451,33 @@ class RTETextBlock extends RTEBlock {
|
|
|
2800
3451
|
createNewParagraph() {
|
|
2801
3452
|
return new RTETextBlock(generateUUID(), 'paragraph');
|
|
2802
3453
|
}
|
|
3454
|
+
/**
|
|
3455
|
+
* Get the HTML tag for the block based on its type.
|
|
3456
|
+
*
|
|
3457
|
+
* @returns {RTETextBlockTagType} The HTML tag for the block.
|
|
3458
|
+
*/
|
|
3459
|
+
getBlockTag() {
|
|
3460
|
+
switch (this.type) {
|
|
3461
|
+
case 'title':
|
|
3462
|
+
case 'subtitle':
|
|
3463
|
+
return `div`;
|
|
3464
|
+
case 'heading-1':
|
|
3465
|
+
return `h1`;
|
|
3466
|
+
case 'heading-2':
|
|
3467
|
+
return `h2`;
|
|
3468
|
+
case 'heading-3':
|
|
3469
|
+
return `h3`;
|
|
3470
|
+
case 'heading-4':
|
|
3471
|
+
return `h4`;
|
|
3472
|
+
case 'heading-5':
|
|
3473
|
+
return `h5`;
|
|
3474
|
+
case 'heading-6':
|
|
3475
|
+
return `h6`;
|
|
3476
|
+
case 'paragraph':
|
|
3477
|
+
default:
|
|
3478
|
+
return 'p';
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
2803
3481
|
/**
|
|
2804
3482
|
* @inheritDoc
|
|
2805
3483
|
*/
|
|
@@ -2812,6 +3490,8 @@ class RTETextBlock extends RTEBlock {
|
|
|
2812
3490
|
}
|
|
2813
3491
|
(() => {
|
|
2814
3492
|
ActionHandleStrategyRegistry.register(TextStyleAnnotationAction.name, RTETextBlock.name, new BlockUpdateTextStyleStrategy());
|
|
3493
|
+
ActionHandleStrategyRegistry.register(HorizontalAlignmentAnnotationAction.name, RTETextBlock.name, new BlockUpdateHorizontalAlignmentStrategy());
|
|
3494
|
+
ActionHandleStrategyRegistry.register(IndentAnnotationAction.name, RTETextBlock.name, new BlockUpdateIndentStrategy());
|
|
2815
3495
|
ActionHandleStrategyRegistry.register(LinkGroupAnnotationAction.name, RTETextBlock.name, new BlockUpdateLinkGroupStrategy());
|
|
2816
3496
|
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTETextBlock.name, new BlockRemoveNodeStrategy());
|
|
2817
3497
|
ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTETextBlock.name, new BlockAppendNodesStrategy());
|
|
@@ -2828,994 +3508,333 @@ class RTETextBlock extends RTEBlock {
|
|
|
2828
3508
|
})();
|
|
2829
3509
|
|
|
2830
3510
|
/**
|
|
2831
|
-
*
|
|
3511
|
+
* Remove the code block from the value, call this action if want to flush value after action.
|
|
2832
3512
|
*/
|
|
2833
|
-
class
|
|
3513
|
+
class CodeBlockRemoveSelfStrategy extends BlockDeleteNodeContentStrategy {
|
|
2834
3514
|
/**
|
|
2835
3515
|
* @inheritDoc
|
|
2836
3516
|
*/
|
|
2837
|
-
handleAction(
|
|
2838
|
-
|
|
3517
|
+
handleAction(_action, target) {
|
|
3518
|
+
const node = target.nodes[0];
|
|
3519
|
+
const parent = target.parent;
|
|
3520
|
+
if (parent) {
|
|
3521
|
+
let focusNode = this.getPreviousNode(node);
|
|
3522
|
+
let offset = this.getRTENodeEndOffset(focusNode);
|
|
3523
|
+
if (!focusNode) {
|
|
3524
|
+
focusNode = this.getNextNode(node);
|
|
3525
|
+
offset = 0;
|
|
3526
|
+
}
|
|
3527
|
+
parent.apply(new RemoveChildAction(target));
|
|
3528
|
+
const focusElement = focusNode
|
|
3529
|
+
? stateEntityRenderingRegistry.getDOMByEntity(focusNode)
|
|
3530
|
+
: null;
|
|
3531
|
+
if (parent.blocks.length === 0) {
|
|
3532
|
+
const defaultParagraph = RTETextBlock.from({
|
|
3533
|
+
id: generateUUID(),
|
|
3534
|
+
type: 'paragraph',
|
|
3535
|
+
nodes: [{ id: generateUUID(), type: 'text', text: '' }],
|
|
3536
|
+
});
|
|
3537
|
+
target.parent.apply(new AppendChildNodesAction([defaultParagraph]));
|
|
3538
|
+
focusNode = defaultParagraph.nodes[0];
|
|
3539
|
+
offset = 0;
|
|
3540
|
+
}
|
|
3541
|
+
this.notifyUpdateSelection(focusNode, focusElement, offset, target);
|
|
3542
|
+
}
|
|
2839
3543
|
}
|
|
2840
3544
|
/**
|
|
2841
|
-
*
|
|
3545
|
+
* Update the rich text next selection range.
|
|
2842
3546
|
*
|
|
2843
|
-
* @param {
|
|
2844
|
-
* @param {
|
|
2845
|
-
* @param {
|
|
2846
|
-
* @
|
|
3547
|
+
* @param {RTENode} focusNode - The next focus node dto.
|
|
3548
|
+
* @param {Nullable<HTMLElement>} focusElement - The next focus element. The update selection task could run directly when the element is exist.
|
|
3549
|
+
* @param {number} offset - The next focus text offset.
|
|
3550
|
+
* @param {RTECodeBlock} target - The code block dto.
|
|
2847
3551
|
*/
|
|
2848
|
-
|
|
2849
|
-
const
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
3552
|
+
notifyUpdateSelection(focusNode, focusElement, offset, target) {
|
|
3553
|
+
const targetDom = stateEntityRenderingRegistry.getDOMByEntity(target);
|
|
3554
|
+
if (targetDom) {
|
|
3555
|
+
const nodeSubject = domNodeSubjectFactory.getSubjectFromParentNodeByEventId(targetDom, VegaInternalRichTextEditorSelectionRangeChange);
|
|
3556
|
+
if (nodeSubject) {
|
|
3557
|
+
ChangeManager.notify(nodeSubject, {
|
|
3558
|
+
node: focusNode,
|
|
3559
|
+
updateDirectly: focusElement ? true : false,
|
|
3560
|
+
offset,
|
|
3561
|
+
});
|
|
3562
|
+
}
|
|
2859
3563
|
}
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
* Get the node content end offset.
|
|
3567
|
+
*
|
|
3568
|
+
* @param {Nullable<RTENode>} node - The RTENode.
|
|
3569
|
+
* @returns {number} - The number value.
|
|
3570
|
+
*/
|
|
3571
|
+
getRTENodeEndOffset(node) {
|
|
3572
|
+
if (node && node.type !== 'CODE_BLOCK_NODE') {
|
|
3573
|
+
return node['type'] !== 'IMAGE' ? node['text'].length : 1;
|
|
2864
3574
|
}
|
|
2865
|
-
return
|
|
3575
|
+
return 0;
|
|
2866
3576
|
}
|
|
2867
3577
|
}
|
|
2868
3578
|
|
|
2869
3579
|
/**
|
|
2870
|
-
*
|
|
2871
|
-
* The SplitBlockWithNodeAction split the current block to two same type blocks, but this action will create new paragraph or list item when break at start or end.
|
|
2872
|
-
* The property `newBlock` use to store the new create block if need.
|
|
3580
|
+
* Update the code block content or language action.
|
|
2873
3581
|
*
|
|
2874
|
-
* @example
|
|
3582
|
+
* @example codeNode.apply(new UpdateCodeBlockAction(content, language))
|
|
2875
3583
|
*/
|
|
2876
|
-
class
|
|
2877
|
-
constructor(
|
|
3584
|
+
class UpdateCodeBlockAction extends ModifyContentAction {
|
|
3585
|
+
constructor(content, language) {
|
|
2878
3586
|
super();
|
|
2879
|
-
this.
|
|
2880
|
-
this.
|
|
2881
|
-
this.
|
|
3587
|
+
this.isFlushable = true;
|
|
3588
|
+
this.type = ModifyContentActionType.UPDATE_CODE_BLOCK;
|
|
3589
|
+
this.content = content;
|
|
3590
|
+
this.language = language;
|
|
2882
3591
|
}
|
|
2883
3592
|
}
|
|
2884
3593
|
|
|
2885
3594
|
/**
|
|
2886
|
-
*
|
|
3595
|
+
* Remove the line break and insert new paragraph after code block.
|
|
2887
3596
|
*/
|
|
2888
|
-
class
|
|
3597
|
+
class SwitchOutFromCodeBlockStrategy extends ActionHandleStrategy {
|
|
2889
3598
|
/**
|
|
2890
|
-
*
|
|
2891
|
-
*
|
|
2892
|
-
* @param {LineBreakSingleBlockAction} action - The action instance.
|
|
2893
|
-
* @param {RTEImageBlock} target - The image block.
|
|
3599
|
+
* @inheritDoc
|
|
2894
3600
|
*/
|
|
2895
3601
|
handleAction(action, target) {
|
|
2896
|
-
const
|
|
2897
|
-
|
|
2898
|
-
const
|
|
2899
|
-
|
|
2900
|
-
|
|
3602
|
+
const { content, language } = action;
|
|
3603
|
+
const textArray = content.split('\n');
|
|
3604
|
+
const updateAction = new UpdateCodeBlockAction(textArray.slice(0, textArray.length - 2).join('\n'), language);
|
|
3605
|
+
updateAction.isFlushable = false;
|
|
3606
|
+
target.nodes[0].apply(updateAction);
|
|
3607
|
+
const textBlock = RTETextBlock.from({
|
|
3608
|
+
id: generateUUID(),
|
|
3609
|
+
type: 'paragraph',
|
|
3610
|
+
nodes: [{ id: generateUUID(), text: '', type: 'text' }],
|
|
3611
|
+
});
|
|
3612
|
+
target.parent.apply(new InsertBlocksAfterAction(target, textBlock));
|
|
3613
|
+
// Focus the next text node after value update.
|
|
3614
|
+
const currentNodeDom = stateEntityRenderingRegistry.getDOMByEntity(target);
|
|
3615
|
+
if (currentNodeDom) {
|
|
3616
|
+
const nodeSubject = domNodeSubjectFactory.getSubjectFromParentNodeByEventId(currentNodeDom, VegaInternalRichTextEditorSelectionRangeChange);
|
|
3617
|
+
if (nodeSubject) {
|
|
3618
|
+
ChangeManager.notify(nodeSubject, { node: textBlock.nodes[0] });
|
|
3619
|
+
}
|
|
2901
3620
|
}
|
|
2902
3621
|
}
|
|
2903
3622
|
}
|
|
2904
3623
|
|
|
2905
3624
|
/**
|
|
2906
|
-
*
|
|
3625
|
+
* Update the language or content of code block strategy.
|
|
2907
3626
|
*/
|
|
2908
|
-
class
|
|
3627
|
+
class UpdateCodeBlockStrategy extends ActionHandleStrategy {
|
|
2909
3628
|
/**
|
|
2910
3629
|
* @inheritDoc
|
|
2911
3630
|
*/
|
|
2912
3631
|
handleAction(action, target) {
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
* Inserts a new paragraph block with a line break after a selected block of text in a rich text editor.
|
|
2917
|
-
*
|
|
2918
|
-
* @param {RTEBlock[]} selectedBlocks - An array of RTEBlock objects that represent the blocks that have been selected for a specific action in the Rich Text Editor.
|
|
2919
|
-
* @param {RTEImageBlock} target - The image block.
|
|
2920
|
-
* @returns {Nullable<RTETextNode>} Returns a Nullable RTETextNode.
|
|
2921
|
-
*/
|
|
2922
|
-
lineBreakMultipleBlocks(selectedBlocks, target) {
|
|
2923
|
-
const newParagraph = RTETextBlock.from({
|
|
2924
|
-
id: generateUUID(),
|
|
2925
|
-
type: 'paragraph',
|
|
2926
|
-
nodes: [{ id: generateUUID(), type: 'text', text: '\n' }],
|
|
2927
|
-
});
|
|
2928
|
-
target.parent.apply(new InsertBlocksAfterAction(target, newParagraph));
|
|
2929
|
-
const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
|
|
2930
|
-
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
2931
|
-
afterNodes.push(new RTETextNode(generateUUID(), '\n', newParagraph));
|
|
2932
|
-
}
|
|
2933
|
-
newParagraph.apply(new AppendChildNodesAction(afterNodes));
|
|
2934
|
-
return newParagraph['nodes'][0];
|
|
2935
|
-
}
|
|
2936
|
-
/**
|
|
2937
|
-
* Concat the child nodes of multiple RTEBlocks if both are not images.
|
|
2938
|
-
*
|
|
2939
|
-
* @param {RTEBlock[]} blocks - multiple block of content in a rich text editor, such as a paragraph, heading, image, etc.
|
|
2940
|
-
* @returns {RTENode[]} Array of connected block nodes
|
|
2941
|
-
*/
|
|
2942
|
-
concatBlocksNodes(blocks) {
|
|
2943
|
-
const nodes = [];
|
|
2944
|
-
blocks.map((block) => {
|
|
2945
|
-
if (block.type !== 'image') {
|
|
2946
|
-
nodes.push(...block['nodes']);
|
|
2947
|
-
block.parent.apply(new RemoveChildAction(block));
|
|
2948
|
-
}
|
|
2949
|
-
});
|
|
2950
|
-
return nodes;
|
|
3632
|
+
const { content, language } = action;
|
|
3633
|
+
target.language = language;
|
|
3634
|
+
target.text = content;
|
|
2951
3635
|
}
|
|
2952
3636
|
}
|
|
2953
3637
|
|
|
2954
3638
|
/**
|
|
2955
|
-
*
|
|
3639
|
+
* Action to change the selection range
|
|
2956
3640
|
*/
|
|
2957
|
-
class
|
|
3641
|
+
class SelectionChangeAction extends AnnotationAction {
|
|
3642
|
+
constructor(range) {
|
|
3643
|
+
super();
|
|
3644
|
+
this.isFlushable = false;
|
|
3645
|
+
this.range = range;
|
|
3646
|
+
}
|
|
2958
3647
|
/**
|
|
2959
|
-
*
|
|
3648
|
+
* Converts the action to an annotation
|
|
3649
|
+
*
|
|
3650
|
+
* @returns {SelectionRangeAnnotation} The annotation
|
|
2960
3651
|
*/
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
const startOffsetOfNode = action.startOffsetOfNode;
|
|
2964
|
-
const newImageBlock = action.imageBlockToBeInserted;
|
|
2965
|
-
const newImageNodes = newImageBlock.nodes;
|
|
2966
|
-
if (target.nodes.length < 1) {
|
|
2967
|
-
target.apply(new AppendChildNodesAction(newImageNodes));
|
|
2968
|
-
}
|
|
2969
|
-
else if (this.isCaretPositionAtImageBlockEnd(target, splitNode, startOffsetOfNode)) {
|
|
2970
|
-
target.parent.apply(new InsertBlocksAfterAction(target, newImageBlock));
|
|
2971
|
-
}
|
|
2972
|
-
else if (this.isCaretPositionAtImageBlockStart(target, splitNode, startOffsetOfNode)) {
|
|
2973
|
-
target.parent.apply(new InsertBlocksBeforeAction(target, newImageBlock));
|
|
2974
|
-
}
|
|
2975
|
-
else {
|
|
2976
|
-
target.apply(new SplitBlockWithNodeAction(splitNode, startOffsetOfNode));
|
|
2977
|
-
target.parent.apply(new InsertBlocksAfterAction(target, newImageBlock));
|
|
2978
|
-
}
|
|
3652
|
+
toAnnotation() {
|
|
3653
|
+
return new SelectionRangeAnnotation(this.range);
|
|
2979
3654
|
}
|
|
2980
3655
|
}
|
|
2981
3656
|
|
|
2982
3657
|
/**
|
|
2983
|
-
*
|
|
3658
|
+
* Update the code block node annotation map strategy.
|
|
2984
3659
|
*/
|
|
2985
|
-
class
|
|
3660
|
+
class CodeNodeSetSelectionRangeAnnotationStrategy extends ActionHandleStrategy {
|
|
2986
3661
|
/**
|
|
2987
3662
|
* @inheritDoc
|
|
2988
3663
|
*/
|
|
2989
3664
|
handleAction(action, target) {
|
|
2990
|
-
|
|
2991
|
-
const nodes = [referNode, ...action.nodesToBeInserted];
|
|
2992
|
-
this.replaceNodeWithNodes(target, referNode, nodes);
|
|
3665
|
+
target.annotationMap.set(InternalAnnotationTypeEnum.SELECTION_RANGE, action.toAnnotation());
|
|
2993
3666
|
}
|
|
2994
3667
|
}
|
|
2995
3668
|
|
|
2996
3669
|
/**
|
|
2997
|
-
*
|
|
3670
|
+
* RTE code node DTO class.
|
|
2998
3671
|
*/
|
|
2999
|
-
class
|
|
3000
|
-
constructor(id) {
|
|
3672
|
+
class RTECodeBlockNode extends RTENode {
|
|
3673
|
+
constructor(id, content, language, parentBlock) {
|
|
3001
3674
|
super(id);
|
|
3002
|
-
this.type =
|
|
3003
|
-
this.
|
|
3675
|
+
this.type = NodeTypeEnum.CODE_BLOCK_NODE;
|
|
3676
|
+
this.text = '';
|
|
3677
|
+
this.annotationMap = new Map();
|
|
3678
|
+
this.text = content;
|
|
3679
|
+
this.parentBlock = parentBlock;
|
|
3680
|
+
this.language = language;
|
|
3004
3681
|
}
|
|
3005
3682
|
/**
|
|
3006
|
-
*
|
|
3683
|
+
* The code node toJSON method will called internal.
|
|
3007
3684
|
*
|
|
3008
|
-
* @
|
|
3009
|
-
* @returns {RTEImageBlock} An instance of `RTEImageBlock`
|
|
3010
|
-
*/
|
|
3011
|
-
static from(block) {
|
|
3012
|
-
const imageBlock = new RTEImageBlock(block.id);
|
|
3013
|
-
const { annotations } = block;
|
|
3014
|
-
imageBlock.nodes = block.nodes.map((image) => RTEImageNode.from(image, imageBlock));
|
|
3015
|
-
if (annotations) {
|
|
3016
|
-
Object.entries(annotations).forEach(([type, value]) => {
|
|
3017
|
-
const item = this.createAnnotationEntity(type, value);
|
|
3018
|
-
if (isNonNullable(item)) {
|
|
3019
|
-
imageBlock.annotationMap.set(...item);
|
|
3020
|
-
}
|
|
3021
|
-
});
|
|
3022
|
-
}
|
|
3023
|
-
return imageBlock;
|
|
3024
|
-
}
|
|
3025
|
-
/**
|
|
3026
|
-
* @inheritDoc
|
|
3685
|
+
* @returns {VegaRTECodeNode} - An object contains content property.
|
|
3027
3686
|
*/
|
|
3028
3687
|
toJSON() {
|
|
3029
|
-
return
|
|
3688
|
+
return { id: this.id, type: 'text', text: this.text, language: this.language };
|
|
3030
3689
|
}
|
|
3031
3690
|
/**
|
|
3032
3691
|
* @inheritDoc
|
|
3033
3692
|
*/
|
|
3034
|
-
|
|
3035
|
-
return
|
|
3693
|
+
toHtml() {
|
|
3694
|
+
return `<code style='box-sizing: border-box;color: rgba(var(--v-text-primary, 32, 54, 69, 1));text-align: left;font-family: "Roboto Mono";font-weight: 400;line-height: 22px;font-size: 16px;white-space: pre-wrap;min-height: 22px;tab-size: 2px;'>${this.text}</code>`;
|
|
3036
3695
|
}
|
|
3037
3696
|
/**
|
|
3038
3697
|
* @inheritDoc
|
|
3039
3698
|
*/
|
|
3040
|
-
|
|
3041
|
-
return this.
|
|
3699
|
+
clone() {
|
|
3700
|
+
return new RTECodeBlockNode(this.id, this.text, this.language, this.parentBlock);
|
|
3042
3701
|
}
|
|
3043
3702
|
/**
|
|
3044
|
-
*
|
|
3045
|
-
*
|
|
3046
|
-
* @returns {RTEImageBlock} - The empty image block.
|
|
3703
|
+
* @inheritDoc
|
|
3047
3704
|
*/
|
|
3048
|
-
|
|
3049
|
-
|
|
3705
|
+
doAnnotationActionApply(action) {
|
|
3706
|
+
ActionHandleStrategyRegistry.executeTheStrategy(action, this);
|
|
3050
3707
|
}
|
|
3051
3708
|
/**
|
|
3052
3709
|
* @inheritDoc
|
|
3053
3710
|
*/
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
clonedBlock.nodes = this.nodes.map((node) => {
|
|
3057
|
-
const clonedNode = node.clone();
|
|
3058
|
-
clonedNode.parentBlock = clonedBlock;
|
|
3059
|
-
return clonedNode;
|
|
3060
|
-
});
|
|
3061
|
-
clonedBlock.annotationMap = super.cloneAnnotations();
|
|
3062
|
-
clonedBlock.parent = this.parent;
|
|
3063
|
-
return clonedBlock;
|
|
3711
|
+
doModifyActionApply(action) {
|
|
3712
|
+
ActionHandleStrategyRegistry.executeTheStrategy(action, this);
|
|
3064
3713
|
}
|
|
3065
3714
|
}
|
|
3066
3715
|
(() => {
|
|
3067
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.
|
|
3068
|
-
ActionHandleStrategyRegistry.register(
|
|
3069
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEImageBlock.name, new BlockRemoveNodeStrategy());
|
|
3070
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEImageBlock.name, new BlockAppendNodesStrategy());
|
|
3071
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_CHILD_NODES, RTEImageBlock.name, new BlockReplaceNodesStrategy());
|
|
3072
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEImageBlock.name, new BlockSplitWithImageNodeStrategy());
|
|
3073
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.BREAK_SINGLE_BLOCK, RTEImageBlock.name, new ImageInsertNewParagraphStrategy());
|
|
3074
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEImageBlock.name, new ImageInsertLineBreakStrategy());
|
|
3075
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEImageBlock.name, new ImageInsertLineBreakWithBlocksStrategy());
|
|
3076
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEImageBlock.name, new ImageBlockInsertImageStrategy());
|
|
3077
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_BEFORE, RTEImageBlock.name, new BlockInsertNodesBeforeNodeStrategy());
|
|
3078
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_AFTER, RTEImageBlock.name, new BlockInsertNodesAfterNodeStrategy());
|
|
3716
|
+
ActionHandleStrategyRegistry.register(ModifyContentActionType.UPDATE_CODE_BLOCK, RTECodeBlockNode.name, new UpdateCodeBlockStrategy());
|
|
3717
|
+
ActionHandleStrategyRegistry.register(SelectionChangeAction.name, RTECodeBlockNode.name, new CodeNodeSetSelectionRangeAnnotationStrategy());
|
|
3079
3718
|
})();
|
|
3080
3719
|
|
|
3081
3720
|
/**
|
|
3082
|
-
*
|
|
3721
|
+
* Insert image behind after code block strategy.
|
|
3083
3722
|
*/
|
|
3084
|
-
class
|
|
3723
|
+
class CodeBlockInsertImageStrategy extends ActionHandleStrategy {
|
|
3085
3724
|
/**
|
|
3086
|
-
*
|
|
3725
|
+
* Insert image block at behind of the RTE code block.
|
|
3087
3726
|
*
|
|
3088
|
-
* @param {
|
|
3089
|
-
* @param {
|
|
3727
|
+
* @param {InsertImageToBlockAction} action - The insert image action instance.
|
|
3728
|
+
* @param {RTECodeBlock} target - The code block.
|
|
3090
3729
|
*/
|
|
3091
3730
|
handleAction(action, target) {
|
|
3092
|
-
const
|
|
3093
|
-
|
|
3094
|
-
if (listBlock.blocks.length === 0) {
|
|
3095
|
-
listBlock.parent.apply(new RemoveChildAction(listBlock));
|
|
3096
|
-
}
|
|
3731
|
+
const imageBlock = action.imageBlockToBeInserted;
|
|
3732
|
+
target.parent.apply(new InsertBlocksAfterAction(target, imageBlock));
|
|
3097
3733
|
}
|
|
3098
3734
|
}
|
|
3099
3735
|
|
|
3736
|
+
var CodeLanguage;
|
|
3737
|
+
(function (CodeLanguage) {
|
|
3738
|
+
CodeLanguage["CSS"] = "css";
|
|
3739
|
+
CodeLanguage["HTML"] = "html";
|
|
3740
|
+
CodeLanguage["JavaScript"] = "js";
|
|
3741
|
+
CodeLanguage["JSX"] = "jsx";
|
|
3742
|
+
CodeLanguage["Plain Text"] = "plainText";
|
|
3743
|
+
CodeLanguage["TypeScript"] = "ts";
|
|
3744
|
+
CodeLanguage["TSX"] = "tsx";
|
|
3745
|
+
})(CodeLanguage || (CodeLanguage = {}));
|
|
3746
|
+
|
|
3100
3747
|
/**
|
|
3101
|
-
*
|
|
3748
|
+
* The code block DTO class.
|
|
3102
3749
|
*/
|
|
3103
|
-
class
|
|
3750
|
+
class RTECodeBlock extends RTEBlock {
|
|
3751
|
+
constructor(id, content, language) {
|
|
3752
|
+
super(id);
|
|
3753
|
+
this.type = 'code-block';
|
|
3754
|
+
this.nodes = [new RTECodeBlockNode(`${id}-1`, content, language, this)];
|
|
3755
|
+
}
|
|
3104
3756
|
/**
|
|
3105
|
-
*
|
|
3757
|
+
* Converts a VegaRTECodeBlock into an RTECodeBlock.
|
|
3106
3758
|
*
|
|
3107
|
-
* @param {
|
|
3108
|
-
* @
|
|
3759
|
+
* @param {VegaRTECodeBlock} block - The block object
|
|
3760
|
+
* @returns {RTECodeBlock} A RTECodeBlock class
|
|
3109
3761
|
*/
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
if (target.nodes.length === 0 && (!target.children || !target.children.length)) {
|
|
3113
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3114
|
-
}
|
|
3762
|
+
static from(block) {
|
|
3763
|
+
return new RTECodeBlock(block.id, block.content, block.language);
|
|
3115
3764
|
}
|
|
3116
|
-
}
|
|
3117
|
-
|
|
3118
|
-
/**
|
|
3119
|
-
* Remove list item nest list block strategy.
|
|
3120
|
-
*/
|
|
3121
|
-
class ListItemRemoveNestListStrategy extends ActionHandleStrategy {
|
|
3122
3765
|
/**
|
|
3123
|
-
*
|
|
3124
|
-
*
|
|
3125
|
-
* @param {RemoveNestListAction} action - The action instance.
|
|
3126
|
-
* @param {RTEListItemBlock} target - The list item block.
|
|
3766
|
+
* @inheritDoc
|
|
3127
3767
|
*/
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
}
|
|
3768
|
+
toJSON() {
|
|
3769
|
+
const { language, text } = this.nodes[0];
|
|
3770
|
+
return {
|
|
3771
|
+
id: this.id,
|
|
3772
|
+
type: 'code-block',
|
|
3773
|
+
content: text,
|
|
3774
|
+
language,
|
|
3775
|
+
};
|
|
3137
3776
|
}
|
|
3138
|
-
}
|
|
3139
|
-
|
|
3140
|
-
/**
|
|
3141
|
-
* Replace list item nest list strategy.
|
|
3142
|
-
*/
|
|
3143
|
-
class ListItemReplaceNestListStrategy extends ActionHandleStrategy {
|
|
3144
3777
|
/**
|
|
3145
3778
|
* @inheritDoc
|
|
3146
3779
|
*/
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
});
|
|
3151
|
-
target.children = action.newList;
|
|
3780
|
+
toHtml() {
|
|
3781
|
+
const { language = CodeLanguage['Plain Text'] } = this.nodes[0];
|
|
3782
|
+
return `<pre data-language="${language}" style="background-color: rgba(var(--v-bg-secondary, 245, 247, 247, 1)); padding: 12px">${this.nodes.map((node) => node.toHtml())}</pre>`;
|
|
3152
3783
|
}
|
|
3153
|
-
}
|
|
3154
|
-
|
|
3155
|
-
/**
|
|
3156
|
-
* Insert new paragraph into current list item block at special position.
|
|
3157
|
-
*/
|
|
3158
|
-
class ListItemInsertNewParagraphStrategy extends ActionHandleStrategy {
|
|
3159
3784
|
/**
|
|
3160
3785
|
* @inheritDoc
|
|
3161
3786
|
*/
|
|
3162
|
-
|
|
3163
|
-
|
|
3787
|
+
clone() {
|
|
3788
|
+
const cloneCodeBlock = RTECodeBlock.from(this.toJSON());
|
|
3789
|
+
cloneCodeBlock.parent = this.parent;
|
|
3790
|
+
return cloneCodeBlock;
|
|
3164
3791
|
}
|
|
3165
3792
|
/**
|
|
3166
|
-
*
|
|
3793
|
+
* Apply action to block
|
|
3167
3794
|
*
|
|
3168
|
-
* @param {
|
|
3169
|
-
* @param {number} startOffsetOfNode - The index within the `splitNode` where the break operation should occur.
|
|
3170
|
-
* @param {RTEListItemBlock} target - The list item block.
|
|
3171
|
-
* @returns {Nullable<RTEBlock>} Returns either a new `RTEListItemBlock` if the caret
|
|
3172
|
-
* position is at the end of the `splitNode`, or it returns the result of splitting the block at the
|
|
3173
|
-
* caret position if it is neither at the start nor at the end.
|
|
3795
|
+
* @param {ModifyContentAction} action - modify content action.
|
|
3174
3796
|
*/
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
newListItem.apply(new AppendChildNodesAction([newBreakNode]));
|
|
3179
|
-
if (this.isCaretPositionAtTextBlockEnd(target, splitNode, startOffsetOfNode)) {
|
|
3180
|
-
return this.breakListItemAtEnd(newListItem, target);
|
|
3797
|
+
apply(action) {
|
|
3798
|
+
if (action instanceof ModifyContentAction) {
|
|
3799
|
+
ActionHandleStrategyRegistry.executeTheStrategy(action, this);
|
|
3181
3800
|
}
|
|
3182
|
-
|
|
3183
|
-
|
|
3801
|
+
if (action.isFlushable) {
|
|
3802
|
+
const domNode = stateEntityRenderingRegistry.getDOMByEntity(this);
|
|
3803
|
+
if (domNode) {
|
|
3804
|
+
const nodeSubject = domNodeSubjectFactory.getSubjectFromParentNodeByEventId(domNode, VegaInternalRichTextEditorFlushChanges);
|
|
3805
|
+
if (nodeSubject) {
|
|
3806
|
+
ChangeManager.notify(nodeSubject, {});
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3184
3809
|
}
|
|
3185
|
-
else {
|
|
3186
|
-
const splitBlockAction = new SplitBlockWithNodeAction(splitNode, startOffsetOfNode);
|
|
3187
|
-
target.apply(splitBlockAction);
|
|
3188
|
-
return splitBlockAction.newBlock;
|
|
3189
|
-
}
|
|
3190
|
-
return newListItem;
|
|
3191
|
-
}
|
|
3192
|
-
/**
|
|
3193
|
-
* Breaks a list item at the end and handles the insertion of a new list item or paragraph accordingly.
|
|
3194
|
-
*
|
|
3195
|
-
* @param {RTEListItemBlock} newListItem - Item that represents a new list item to be added to the existing list.
|
|
3196
|
-
* @param {RTEListItemBlock} target - The list item block.
|
|
3197
|
-
* @returns {RTEBlock} Returns a `RTEBlock`.
|
|
3198
|
-
*/
|
|
3199
|
-
breakListItemAtEnd(newListItem, target) {
|
|
3200
|
-
const lastItem = target.parent.blocks[target.parent.blocks.length - 1];
|
|
3201
|
-
const currentItemIsEmpty = target.nodes.length === 1 && target.nodes[0].isEmpty();
|
|
3202
|
-
if (target === lastItem && currentItemIsEmpty) {
|
|
3203
|
-
const parentParent = target.parent.parent;
|
|
3204
|
-
if (parentParent['type'] !== 'list-item') {
|
|
3205
|
-
const newParagraph = RTETextBlock.from({
|
|
3206
|
-
id: generateUUID(),
|
|
3207
|
-
type: 'paragraph',
|
|
3208
|
-
nodes: [],
|
|
3209
|
-
});
|
|
3210
|
-
newParagraph.apply(new AppendChildNodesAction(newListItem.nodes));
|
|
3211
|
-
parentParent.apply(new InsertBlocksAfterAction(target.parent, newParagraph));
|
|
3212
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3213
|
-
return newParagraph;
|
|
3214
|
-
}
|
|
3215
|
-
else {
|
|
3216
|
-
parentParent.parent.apply(new InsertBlocksAfterAction(parentParent, newListItem));
|
|
3217
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3218
|
-
}
|
|
3219
|
-
}
|
|
3220
|
-
else {
|
|
3221
|
-
target.parent.apply(new InsertBlocksAfterAction(target, newListItem));
|
|
3222
|
-
}
|
|
3223
|
-
return newListItem;
|
|
3224
|
-
}
|
|
3225
|
-
/**
|
|
3226
|
-
* Copy the inline style to new node
|
|
3227
|
-
*
|
|
3228
|
-
* @param {RTETextNode} needCopedNode - The node that needed to be copied to
|
|
3229
|
-
* @returns {RTETextNode} Returns a `RTETextNode`.
|
|
3230
|
-
*/
|
|
3231
|
-
copyInlineStyleToNewNode(needCopedNode) {
|
|
3232
|
-
const textNode = needCopedNode.cloneWithText('');
|
|
3233
|
-
// The link annotation doesn't need to inherit
|
|
3234
|
-
textNode.annotationMap.delete(NodeAnnotationTypeEnum.LINK);
|
|
3235
|
-
return textNode;
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
|
|
3239
|
-
/**
|
|
3240
|
-
* Insert image node to list item block strategy.
|
|
3241
|
-
*/
|
|
3242
|
-
class ListItemInsertImageStrategy extends ActionHandleStrategy {
|
|
3243
|
-
/**
|
|
3244
|
-
* The image node can not insert into list item block, so insert image after parent list block.
|
|
3245
|
-
*
|
|
3246
|
-
* @param {InsertImageToBlockAction} action - The action instance.
|
|
3247
|
-
* @param {RTEListItemBlock} target - The list item block.
|
|
3248
|
-
*/
|
|
3249
|
-
handleAction(action, target) {
|
|
3250
|
-
target.parent.apply(action);
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
|
|
3254
|
-
/**
|
|
3255
|
-
* List item block
|
|
3256
|
-
*/
|
|
3257
|
-
class RTEListItemBlock extends RTETextBlock {
|
|
3258
|
-
constructor(id, children) {
|
|
3259
|
-
super(id, 'list-item');
|
|
3260
|
-
this.children = [];
|
|
3261
|
-
this.children = children;
|
|
3262
|
-
}
|
|
3263
|
-
/**
|
|
3264
|
-
* Converts a VegaRTEListItemBlock object to an RTEListItemBlock
|
|
3265
|
-
*
|
|
3266
|
-
* @param {VegaRTEListBlock} block - Converts a `VegaRTEListItemBlock` object into an `RTEListItemBlock`.
|
|
3267
|
-
* @returns {RTEListItemBlock} Return an instance of `RTEListItemBlock`
|
|
3268
|
-
*/
|
|
3269
|
-
static from(block) {
|
|
3270
|
-
const listItemBlock = new RTEListItemBlock(block.id);
|
|
3271
|
-
listItemBlock.nodes = block.nodes.map((richText) => RTETextNode.from(richText, listItemBlock));
|
|
3272
|
-
if (block.children) {
|
|
3273
|
-
listItemBlock.children = block.children.map((child) => {
|
|
3274
|
-
const listBlock = RTEListBlock.from(child);
|
|
3275
|
-
listBlock.parent = listItemBlock;
|
|
3276
|
-
return listBlock;
|
|
3277
|
-
});
|
|
3278
|
-
}
|
|
3279
|
-
const { annotations } = block;
|
|
3280
|
-
if (annotations) {
|
|
3281
|
-
Object.entries(annotations).forEach(([type, value]) => {
|
|
3282
|
-
const item = this.createAnnotationEntity(type, value);
|
|
3283
|
-
if (isNonNullable(item)) {
|
|
3284
|
-
listItemBlock.annotationMap.set(...item);
|
|
3285
|
-
}
|
|
3286
|
-
});
|
|
3287
|
-
}
|
|
3288
|
-
return listItemBlock;
|
|
3289
|
-
}
|
|
3290
|
-
/**
|
|
3291
|
-
* @inheritDoc
|
|
3292
|
-
*/
|
|
3293
|
-
toJSON() {
|
|
3294
|
-
var _a;
|
|
3295
|
-
return Object.assign(Object.assign({}, super.toJSON()), { type: 'list-item', children: (_a = this.children) === null || _a === void 0 ? void 0 : _a.map((block) => block.toJSON()) });
|
|
3296
|
-
}
|
|
3297
|
-
/**
|
|
3298
|
-
* @inheritDoc
|
|
3299
|
-
*/
|
|
3300
|
-
cloneWithNodes(nodes) {
|
|
3301
|
-
const block = new RTEListItemBlock(generateUUID());
|
|
3302
|
-
block.nodes = [];
|
|
3303
|
-
block.apply(new AppendChildNodesAction(nodes));
|
|
3304
|
-
return block;
|
|
3305
|
-
}
|
|
3306
|
-
/**
|
|
3307
|
-
* @inheritDoc
|
|
3308
|
-
*/
|
|
3309
|
-
getLastNode() {
|
|
3310
|
-
if (this.children && this.children.length > 0) {
|
|
3311
|
-
const childListBlock = this.children[this.children.length - 1];
|
|
3312
|
-
return childListBlock.getLastNode();
|
|
3313
|
-
}
|
|
3314
|
-
return super.getLastNode();
|
|
3315
|
-
}
|
|
3316
|
-
/**
|
|
3317
|
-
* Create a new list item block.
|
|
3318
|
-
*
|
|
3319
|
-
* @returns {RTEListItemBlock} - A list item block.
|
|
3320
|
-
*/
|
|
3321
|
-
createNewListItem() {
|
|
3322
|
-
return new RTEListItemBlock(generateUUID());
|
|
3323
|
-
}
|
|
3324
|
-
/**
|
|
3325
|
-
* @inheritDoc
|
|
3326
|
-
*/
|
|
3327
|
-
clone() {
|
|
3328
|
-
var _a;
|
|
3329
|
-
const block = new RTEListItemBlock(this.id);
|
|
3330
|
-
block.nodes = this.nodes.map((node) => {
|
|
3331
|
-
const clonedNode = node.clone();
|
|
3332
|
-
clonedNode.parentBlock = block;
|
|
3333
|
-
return clonedNode;
|
|
3334
|
-
});
|
|
3335
|
-
block.annotationMap = super.cloneAnnotations();
|
|
3336
|
-
block.children = (_a = this.children) === null || _a === void 0 ? void 0 : _a.map((child) => {
|
|
3337
|
-
const clonedChild = child.clone();
|
|
3338
|
-
clonedChild.parent = block;
|
|
3339
|
-
return clonedChild;
|
|
3340
|
-
});
|
|
3341
|
-
block.parent = this.parent;
|
|
3342
|
-
return block;
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
(() => {
|
|
3346
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_BLOCK_CONTENT, RTEListItemBlock.name, new ListItemDeleteTextContentStrategy());
|
|
3347
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new BlockInsertLineBreakStrategy());
|
|
3348
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS, RTEListItemBlock.name, new BlockInsertLineBreakWithBlocksStrategy());
|
|
3349
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEListItemBlock.name, new ListItemRemoveNodeStrategy());
|
|
3350
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_NEST_LIST, RTEListItemBlock.name, new ListItemRemoveNestListStrategy());
|
|
3351
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEListItemBlock.name, new BlockAppendNodesStrategy());
|
|
3352
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.SPLIT_BLOCK_WITH_NODE, RTEListItemBlock.name, new BlockSplitWithTextNodeStrategy());
|
|
3353
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_CHILD_NODES, RTEListItemBlock.name, new BlockReplaceNodesStrategy());
|
|
3354
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.REPLACE_NEST_LIST, RTEListItemBlock.name, new ListItemReplaceNestListStrategy());
|
|
3355
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.MERGE_TWO_BLOCKS_NODES, RTEListItemBlock.name, new BlockMergeNodesStrategy());
|
|
3356
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.BREAK_SINGLE_BLOCK, RTEListItemBlock.name, new ListItemInsertNewParagraphStrategy());
|
|
3357
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListItemBlock.name, new ListItemInsertImageStrategy());
|
|
3358
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_NODES_BEFORE, RTEListItemBlock.name, new BlockInsertNodesBeforeNodeStrategy());
|
|
3359
|
-
})();
|
|
3360
|
-
|
|
3361
|
-
/**
|
|
3362
|
-
* Insert block array at the front of the block strategy.
|
|
3363
|
-
*/
|
|
3364
|
-
class BlockInsertBlocksBeforeStrategy extends ActionHandleStrategy {
|
|
3365
|
-
/**
|
|
3366
|
-
* @inheritDoc
|
|
3367
|
-
*/
|
|
3368
|
-
handleAction(action, target) {
|
|
3369
|
-
this.replaceBlockWithBlocks(target, action.referBlock, [
|
|
3370
|
-
...action.blocksToBeInserted,
|
|
3371
|
-
action.referBlock,
|
|
3372
|
-
]);
|
|
3373
|
-
}
|
|
3374
|
-
/**
|
|
3375
|
-
* Replaces a specific block with an array of blocks within a RTEContentBlock array.
|
|
3376
|
-
*
|
|
3377
|
-
* @param {RTEListBlock|VegaRTEContent} target - The list block or the VegaRTEContent instance.
|
|
3378
|
-
* @param {RTEBlock} referBlock - Used as a reference block to identify the block that needs to be replaced in the `blocks` array.
|
|
3379
|
-
* @param {RTEBlock[]} blocks - An array of RTEBlock objects that you want to replace the `referBlock` with in the `blocks` array.
|
|
3380
|
-
*/
|
|
3381
|
-
replaceBlockWithBlocks(target, referBlock, blocks) {
|
|
3382
|
-
if (target.blocks) {
|
|
3383
|
-
blocks.forEach((block) => {
|
|
3384
|
-
block.parent = target;
|
|
3385
|
-
});
|
|
3386
|
-
const arrayFixed = target.blocks;
|
|
3387
|
-
target.blocks = arrayFixed.flatMap((block) => {
|
|
3388
|
-
if (block === referBlock) {
|
|
3389
|
-
return blocks;
|
|
3390
|
-
}
|
|
3391
|
-
else {
|
|
3392
|
-
return block;
|
|
3393
|
-
}
|
|
3394
|
-
});
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
|
|
3399
|
-
/**
|
|
3400
|
-
* Insert block array at the behind of the block strategy.
|
|
3401
|
-
*/
|
|
3402
|
-
class BlockInsertBlocksAfterStrategy extends BlockInsertBlocksBeforeStrategy {
|
|
3403
|
-
/**
|
|
3404
|
-
* @inheritDoc
|
|
3405
|
-
*/
|
|
3406
|
-
handleAction(action, target) {
|
|
3407
|
-
this.replaceBlockWithBlocks(target, action.referBlock, [
|
|
3408
|
-
action.referBlock,
|
|
3409
|
-
...action.blocksToBeInserted,
|
|
3410
|
-
]);
|
|
3411
|
-
}
|
|
3412
|
-
}
|
|
3413
|
-
|
|
3414
|
-
/**
|
|
3415
|
-
* Append new block array to list block or VegaRTEContent instance strategy.
|
|
3416
|
-
*/
|
|
3417
|
-
class BlockAppendBlocksStrategy extends ActionHandleStrategy {
|
|
3418
|
-
/**
|
|
3419
|
-
* @inheritDoc
|
|
3420
|
-
*/
|
|
3421
|
-
handleAction(action, target) {
|
|
3422
|
-
const newBlocks = action.entityToBeAppended;
|
|
3423
|
-
if (target.blocks) {
|
|
3424
|
-
newBlocks.forEach((block) => {
|
|
3425
|
-
block.parent = target;
|
|
3426
|
-
});
|
|
3427
|
-
const arrayFixed = target.blocks;
|
|
3428
|
-
target.blocks = arrayFixed.concat(newBlocks);
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
}
|
|
3432
|
-
|
|
3433
|
-
/**
|
|
3434
|
-
* Delete the nest list block action
|
|
3435
|
-
*
|
|
3436
|
-
* @example needRemovedNestList.parent.apply(new RemoveNestListAction(needRemovedNestList))
|
|
3437
|
-
*/
|
|
3438
|
-
class RemoveNestListAction extends ModifyContentAction {
|
|
3439
|
-
constructor(childList) {
|
|
3440
|
-
super();
|
|
3441
|
-
this.type = ModifyContentActionType.DELETE_NEST_LIST;
|
|
3442
|
-
this.nestListBlockToBeRemoved = childList;
|
|
3443
|
-
}
|
|
3444
|
-
}
|
|
3445
|
-
|
|
3446
|
-
/**
|
|
3447
|
-
* List block or VegaRTEContent remove child block strategy.
|
|
3448
|
-
*/
|
|
3449
|
-
class BlockRemoveChildBlockStrategy extends ActionHandleStrategy {
|
|
3450
|
-
/**
|
|
3451
|
-
* @inheritDoc
|
|
3452
|
-
*/
|
|
3453
|
-
handleAction(action, target) {
|
|
3454
|
-
const blockToBeRemoved = action.entityToBeRemoved;
|
|
3455
|
-
if (target.blocks) {
|
|
3456
|
-
target.blocks = target.blocks.filter((block) => block !== blockToBeRemoved);
|
|
3457
|
-
}
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
|
|
3461
|
-
/**
|
|
3462
|
-
* List remove list item strategy.
|
|
3463
|
-
*/
|
|
3464
|
-
class ListRemoveListItemStrategy extends BlockRemoveChildBlockStrategy {
|
|
3465
|
-
/**
|
|
3466
|
-
* Remove the list item, check the list item and remove self if the list item is empty.
|
|
3467
|
-
*
|
|
3468
|
-
* @param {RemoveChildAction} action - The remove action instance.
|
|
3469
|
-
* @param {RTEListBlock} target - The list block.
|
|
3470
|
-
*/
|
|
3471
|
-
handleAction(action, target) {
|
|
3472
|
-
super.handleAction(action, target);
|
|
3473
|
-
const parent = target.parent;
|
|
3474
|
-
if (target.blocks.length === 0 && parent) {
|
|
3475
|
-
// The parent is a list item mean the current block is a nest list, so we need to use RemoveNestListAction to remove the item
|
|
3476
|
-
if (parent['type'] === 'list-item') {
|
|
3477
|
-
parent.apply(new RemoveNestListAction(target));
|
|
3478
|
-
}
|
|
3479
|
-
else {
|
|
3480
|
-
parent.apply(new RemoveChildAction(target));
|
|
3481
|
-
}
|
|
3482
|
-
}
|
|
3483
|
-
}
|
|
3484
|
-
}
|
|
3485
|
-
|
|
3486
|
-
/**
|
|
3487
|
-
* Convert the selected blocks to list strategy.
|
|
3488
|
-
*/
|
|
3489
|
-
class ListTransformToListStrategy extends ActionHandleStrategy {
|
|
3490
|
-
/**
|
|
3491
|
-
* @inheritDoc
|
|
3492
|
-
*/
|
|
3493
|
-
handleAction(action, target) {
|
|
3494
|
-
const selectedBlocks = action.selectedBlocks;
|
|
3495
|
-
const bulletList = target.parent.createList(action.listType);
|
|
3496
|
-
const isSameList = selectedBlocks.every((block) => block.parent === target);
|
|
3497
|
-
if (isSameList) {
|
|
3498
|
-
// Select one or more list items belonging to the same list, and all items in this list should be updated
|
|
3499
|
-
bulletList.apply(new AppendChildNodesAction(target.blocks));
|
|
3500
|
-
target.parent.apply(new InsertBlocksAfterAction(target, bulletList));
|
|
3501
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3502
|
-
selectedBlocks.forEach((block) => block.nodes.map((node) => node.apply(new SyncUpSelectionAction())));
|
|
3503
|
-
}
|
|
3504
|
-
else {
|
|
3505
|
-
const listItems = action.selectedBlocks.map((block) => target.parent.toListItem(block));
|
|
3506
|
-
bulletList.apply(new AppendChildNodesAction(listItems));
|
|
3507
|
-
target.parent.apply(new InsertBlocksAfterAction(target, bulletList));
|
|
3508
|
-
action.selectedBlocks.forEach((block) => {
|
|
3509
|
-
block.parent.apply(new RemoveChildAction(block));
|
|
3510
|
-
});
|
|
3511
|
-
if (target.blocks.length === 0) {
|
|
3512
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
}
|
|
3516
|
-
}
|
|
3517
|
-
|
|
3518
|
-
/**
|
|
3519
|
-
* Convert the selected list block to paragraph strategy.
|
|
3520
|
-
*/
|
|
3521
|
-
class ListTransformToParagraphStrategy extends ActionHandleStrategy {
|
|
3522
|
-
/**
|
|
3523
|
-
* @inheritDoc
|
|
3524
|
-
*/
|
|
3525
|
-
handleAction(action, target) {
|
|
3526
|
-
let isSelectedFirstBlock = false;
|
|
3527
|
-
let isSelectedLastBlock = false;
|
|
3528
|
-
const selectedBlocks = action.selectedBlocks;
|
|
3529
|
-
const currentParagraph = selectedBlocks.map((block) => {
|
|
3530
|
-
block.nodes.map((node) => node.apply(new SyncUpSelectionAction()));
|
|
3531
|
-
if (block === target.blocks[0])
|
|
3532
|
-
isSelectedFirstBlock = true;
|
|
3533
|
-
if (block === target.blocks[target.blocks.length - 1])
|
|
3534
|
-
isSelectedLastBlock = true;
|
|
3535
|
-
return this.toParagraph(block);
|
|
3536
|
-
});
|
|
3537
|
-
if (isSelectedFirstBlock) {
|
|
3538
|
-
target.parent.apply(new InsertBlocksBeforeAction(target, ...currentParagraph));
|
|
3539
|
-
}
|
|
3540
|
-
else if (isSelectedLastBlock) {
|
|
3541
|
-
target.parent.apply(new InsertBlocksAfterAction(target, ...currentParagraph));
|
|
3542
|
-
}
|
|
3543
|
-
else {
|
|
3544
|
-
const startIndex = target.blocks.indexOf(selectedBlocks[0]);
|
|
3545
|
-
const lastIndex = target.blocks.indexOf(selectedBlocks[selectedBlocks.length - 1]);
|
|
3546
|
-
const firstBulletList = target.parent.createList(target.type);
|
|
3547
|
-
firstBulletList.apply(new AppendChildNodesAction(target.blocks.slice(0, startIndex)));
|
|
3548
|
-
const lastBulletList = target.parent.createList(target.type);
|
|
3549
|
-
lastBulletList.apply(new AppendChildNodesAction(target.blocks.slice(lastIndex + 1)));
|
|
3550
|
-
target.parent.apply(new InsertBlocksBeforeAction(target, firstBulletList, ...currentParagraph, lastBulletList));
|
|
3551
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3552
|
-
}
|
|
3553
|
-
selectedBlocks.map((block) => {
|
|
3554
|
-
target.apply(new RemoveChildAction(block));
|
|
3555
|
-
});
|
|
3556
|
-
if (target.blocks.length === 0) {
|
|
3557
|
-
target.parent.apply(new RemoveChildAction(target));
|
|
3558
|
-
}
|
|
3559
|
-
}
|
|
3560
|
-
/**
|
|
3561
|
-
* Converts a RTEListItemBlock to a RTETextBlock representing a paragraph.
|
|
3562
|
-
*
|
|
3563
|
-
* @param {RTEListItemBlock} block - The block that will be covered
|
|
3564
|
-
* @returns {RTETextBlock} Returns a `RTETextBlock`.
|
|
3565
|
-
*/
|
|
3566
|
-
toParagraph(block) {
|
|
3567
|
-
const textBlock = new RTETextBlock(generateUUID(), 'paragraph');
|
|
3568
|
-
textBlock.apply(new AppendChildNodesAction(block['nodes']));
|
|
3569
|
-
textBlock['annotationMap'] = block['annotationMap'];
|
|
3570
|
-
return textBlock;
|
|
3571
|
-
}
|
|
3572
|
-
}
|
|
3573
|
-
|
|
3574
|
-
/**
|
|
3575
|
-
* Insert image to list block strategy.
|
|
3576
|
-
*/
|
|
3577
|
-
class ListInsertImageStrategy extends ActionHandleStrategy {
|
|
3578
|
-
/**
|
|
3579
|
-
* Insert image block at behind of the list item block.
|
|
3580
|
-
*
|
|
3581
|
-
* @param {InsertImageToBlockAction} action - The insert image action instance.
|
|
3582
|
-
* @param {RTEListBlock} target - The list block.
|
|
3583
|
-
*/
|
|
3584
|
-
handleAction(action, target) {
|
|
3585
|
-
const imageBlock = action.imageBlockToBeInserted;
|
|
3586
|
-
if (target.parent['type'] !== 'list-item') {
|
|
3587
|
-
target.parent.apply(new InsertBlocksAfterAction(target, imageBlock));
|
|
3588
|
-
}
|
|
3589
|
-
else {
|
|
3590
|
-
target.parent.apply(action);
|
|
3591
|
-
}
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
|
|
3595
|
-
/**
|
|
3596
|
-
* List block
|
|
3597
|
-
*/
|
|
3598
|
-
class RTEListBlock extends RTEBlock {
|
|
3599
|
-
constructor(id, type) {
|
|
3600
|
-
super(id);
|
|
3601
|
-
this.type = 'bullet-list';
|
|
3602
|
-
this.blocks = [];
|
|
3603
|
-
this.type = type;
|
|
3604
|
-
}
|
|
3605
|
-
/**
|
|
3606
|
-
* Converts a VegaRTEListBlock object to an RTEListBlock
|
|
3607
|
-
*
|
|
3608
|
-
* @param {VegaRTEListBlock} block - Converts a `VegaRTEListBlock` object into an `RTEListBlock`.
|
|
3609
|
-
* @returns {RTEListBlock} Return an instance of `RTEListBlock`
|
|
3610
|
-
*/
|
|
3611
|
-
static from(block) {
|
|
3612
|
-
const listBlock = new RTEListBlock(block.id, block.type);
|
|
3613
|
-
listBlock.blocks = block.blocks.map((item) => {
|
|
3614
|
-
const listItemBlock = RTEListItemBlock.from(item);
|
|
3615
|
-
listItemBlock.parent = listBlock;
|
|
3616
|
-
return listItemBlock;
|
|
3617
|
-
});
|
|
3618
|
-
return listBlock;
|
|
3619
|
-
}
|
|
3620
|
-
/**
|
|
3621
|
-
* @inheritDoc
|
|
3622
|
-
*/
|
|
3623
|
-
toJSON() {
|
|
3624
|
-
return Object.assign(Object.assign({}, super.toJSON()), { id: this.id, type: this.type, blocks: this.blocks.map((block) => block.toJSON()) });
|
|
3625
3810
|
}
|
|
3626
3811
|
/**
|
|
3627
3812
|
* @inheritDoc
|
|
3628
3813
|
*/
|
|
3629
3814
|
isNotEmpty() {
|
|
3630
|
-
return this.
|
|
3815
|
+
return !!this.nodes.length;
|
|
3631
3816
|
}
|
|
3632
3817
|
/**
|
|
3633
3818
|
* @inheritDoc
|
|
3634
3819
|
*/
|
|
3635
3820
|
getLastNode() {
|
|
3636
|
-
return this.
|
|
3637
|
-
}
|
|
3638
|
-
/**
|
|
3639
|
-
* @inheritDoc
|
|
3640
|
-
*/
|
|
3641
|
-
clone() {
|
|
3642
|
-
const clonedListBlock = new RTEListBlock(this.id, this.type);
|
|
3643
|
-
clonedListBlock.blocks = this.blocks.map((item) => {
|
|
3644
|
-
const clonedListItemBlock = item.clone();
|
|
3645
|
-
clonedListItemBlock.parent = clonedListBlock;
|
|
3646
|
-
return clonedListItemBlock;
|
|
3647
|
-
});
|
|
3648
|
-
clonedListBlock.annotationMap = super.cloneAnnotations();
|
|
3649
|
-
clonedListBlock.parent = this.parent;
|
|
3650
|
-
return clonedListBlock;
|
|
3651
|
-
}
|
|
3652
|
-
}
|
|
3653
|
-
(() => {
|
|
3654
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTEListBlock.name, new ListRemoveListItemStrategy());
|
|
3655
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_BLOCKS_BEFORE, RTEListBlock.name, new BlockInsertBlocksBeforeStrategy());
|
|
3656
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_BLOCKS_AFTER, RTEListBlock.name, new BlockInsertBlocksAfterStrategy());
|
|
3657
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.APPEND_CHILD_NODES, RTEListBlock.name, new BlockAppendBlocksStrategy());
|
|
3658
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.TRANSFORM_LIST_BLOCK, RTEListBlock.name, new ListTransformToListStrategy());
|
|
3659
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK, RTEListBlock.name, new ListTransformToParagraphStrategy());
|
|
3660
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTEListBlock.name, new ListInsertImageStrategy());
|
|
3661
|
-
})();
|
|
3662
|
-
|
|
3663
|
-
/**
|
|
3664
|
-
* Class representing the content state of the rich text editor.
|
|
3665
|
-
*/
|
|
3666
|
-
class VegaRTEContent {
|
|
3667
|
-
constructor(blocks) {
|
|
3668
|
-
blocks.forEach((block) => {
|
|
3669
|
-
block.parent = this;
|
|
3670
|
-
});
|
|
3671
|
-
this.blocks = blocks;
|
|
3672
|
-
}
|
|
3673
|
-
/**
|
|
3674
|
-
* Converts a JSON array of blocks to a class array of RTEContentBlock.
|
|
3675
|
-
*
|
|
3676
|
-
* @param {VegaRTEContentBlock[]} value The JSON array of blocks to convert.
|
|
3677
|
-
* @returns {VegaRTEContent} The converted array of RTEContentBlock.
|
|
3678
|
-
*/
|
|
3679
|
-
static fromJSON(value) {
|
|
3680
|
-
const blocks = value.map((block) => {
|
|
3681
|
-
switch (block.type) {
|
|
3682
|
-
case 'paragraph':
|
|
3683
|
-
case 'title':
|
|
3684
|
-
case 'subtitle':
|
|
3685
|
-
case 'heading-1':
|
|
3686
|
-
case 'heading-2':
|
|
3687
|
-
case 'heading-3': {
|
|
3688
|
-
return RTETextBlock.from(block);
|
|
3689
|
-
}
|
|
3690
|
-
case 'image':
|
|
3691
|
-
return RTEImageBlock.from(block);
|
|
3692
|
-
case 'bullet-list':
|
|
3693
|
-
case 'number-list':
|
|
3694
|
-
return RTEListBlock.from(block);
|
|
3695
|
-
default: {
|
|
3696
|
-
throw new Error(`[Vega] Unknown block type: ${block.type}`);
|
|
3697
|
-
}
|
|
3698
|
-
}
|
|
3699
|
-
});
|
|
3700
|
-
return new VegaRTEContent(blocks);
|
|
3701
|
-
}
|
|
3702
|
-
/**
|
|
3703
|
-
* Create an empty content state
|
|
3704
|
-
*
|
|
3705
|
-
* @returns {VegaRTEContent} An empty content state
|
|
3706
|
-
*/
|
|
3707
|
-
static createEmptyContent() {
|
|
3708
|
-
return VegaRTEContent.fromJSON([
|
|
3709
|
-
{
|
|
3710
|
-
id: generateUUID(),
|
|
3711
|
-
type: 'paragraph',
|
|
3712
|
-
nodes: [
|
|
3713
|
-
{
|
|
3714
|
-
id: generateUUID(),
|
|
3715
|
-
type: 'text',
|
|
3716
|
-
text: '',
|
|
3717
|
-
},
|
|
3718
|
-
],
|
|
3719
|
-
},
|
|
3720
|
-
]);
|
|
3821
|
+
return this.nodes[0];
|
|
3721
3822
|
}
|
|
3722
3823
|
/**
|
|
3723
|
-
*
|
|
3824
|
+
* The code block is selected or not.
|
|
3724
3825
|
*
|
|
3725
|
-
* @
|
|
3726
|
-
* @returns {VegaRTEContent} The cloned content state.
|
|
3826
|
+
* @returns {boolean} - The boolean result.
|
|
3727
3827
|
*/
|
|
3728
|
-
|
|
3729
|
-
return
|
|
3730
|
-
? new VegaRTEContent(this.blocks.map((block) => block.clone()))
|
|
3731
|
-
: new VegaRTEContent([...this.blocks]);
|
|
3732
|
-
}
|
|
3733
|
-
/**
|
|
3734
|
-
* Converts the content state to a JSON array of blocks.
|
|
3735
|
-
*
|
|
3736
|
-
* @returns {VegaRTEContentBlock[]} The JSON array of blocks.
|
|
3737
|
-
*/
|
|
3738
|
-
toJSON() {
|
|
3739
|
-
return this.blocks.map((block) => block.toJSON());
|
|
3740
|
-
}
|
|
3741
|
-
/**
|
|
3742
|
-
* Internal method to add the block item, remove the block item
|
|
3743
|
-
*
|
|
3744
|
-
* @param {ModifyContentAction} action - Modify content action
|
|
3745
|
-
*/
|
|
3746
|
-
apply(action) {
|
|
3747
|
-
ActionHandleStrategyRegistry.executeTheStrategy(action, this);
|
|
3748
|
-
}
|
|
3749
|
-
/**
|
|
3750
|
-
* Convert text to list.
|
|
3751
|
-
*
|
|
3752
|
-
* @param {RTETextBlock} block - block
|
|
3753
|
-
* @returns {RTEListItemBlock} list item block dto.
|
|
3754
|
-
*/
|
|
3755
|
-
toListItem(block) {
|
|
3756
|
-
block.nodes.map((node) => node.apply(new SyncUpSelectionAction()));
|
|
3757
|
-
const listItemBlock = new RTEListItemBlock(generateUUID());
|
|
3758
|
-
listItemBlock.apply(new AppendChildNodesAction(block['nodes']));
|
|
3759
|
-
listItemBlock['annotationMap'] = block['annotationMap'];
|
|
3760
|
-
return listItemBlock;
|
|
3761
|
-
}
|
|
3762
|
-
/**
|
|
3763
|
-
* create list.
|
|
3764
|
-
*
|
|
3765
|
-
* @param {ListType} type - type
|
|
3766
|
-
* @returns {RTEListBlock} list block dto.
|
|
3767
|
-
*/
|
|
3768
|
-
createList(type) {
|
|
3769
|
-
return new RTEListBlock(generateUUID(), type);
|
|
3770
|
-
}
|
|
3771
|
-
/**
|
|
3772
|
-
* Finds a node by its ID in the content.
|
|
3773
|
-
*
|
|
3774
|
-
* @param {string} id - The ID of the node to find.
|
|
3775
|
-
* @returns {Nullable<RTENode>} The found node or null if not found.
|
|
3776
|
-
*/
|
|
3777
|
-
findNodeById(id) {
|
|
3778
|
-
return this.findNodeInBlocksById(id, this.blocks);
|
|
3779
|
-
}
|
|
3780
|
-
/**
|
|
3781
|
-
* Recursively searches for a node by its ID in the given blocks.
|
|
3782
|
-
*
|
|
3783
|
-
* @param {string} id - The ID of the node to find.
|
|
3784
|
-
* @param {RTEContentBlock[]} blocks - The blocks to search within.
|
|
3785
|
-
* @returns {Nullable<RTENode>} The found node or null if not found.
|
|
3786
|
-
*/
|
|
3787
|
-
findNodeInBlocksById(id, blocks) {
|
|
3788
|
-
for (const block of blocks) {
|
|
3789
|
-
if ('nodes' in block) {
|
|
3790
|
-
for (const node of block.nodes) {
|
|
3791
|
-
if (node.id === id) {
|
|
3792
|
-
return node;
|
|
3793
|
-
}
|
|
3794
|
-
}
|
|
3795
|
-
}
|
|
3796
|
-
if (block instanceof RTEListItemBlock && block.children) {
|
|
3797
|
-
for (const cBlock of block.children) {
|
|
3798
|
-
const foundNode = this.findNodeInBlocksById(id, cBlock.blocks);
|
|
3799
|
-
if (foundNode) {
|
|
3800
|
-
return foundNode;
|
|
3801
|
-
}
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
if (block instanceof RTEListBlock && block.blocks) {
|
|
3805
|
-
const foundNode = this.findNodeInBlocksById(id, block.blocks);
|
|
3806
|
-
if (foundNode) {
|
|
3807
|
-
return foundNode;
|
|
3808
|
-
}
|
|
3809
|
-
}
|
|
3810
|
-
}
|
|
3811
|
-
return null;
|
|
3828
|
+
isSelected() {
|
|
3829
|
+
return this.nodes[0].annotationMap.has(InternalAnnotationTypeEnum.SELECTION_RANGE);
|
|
3812
3830
|
}
|
|
3813
3831
|
}
|
|
3814
3832
|
(() => {
|
|
3815
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.
|
|
3816
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.
|
|
3817
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.
|
|
3818
|
-
ActionHandleStrategyRegistry.register(ModifyContentActionType.
|
|
3833
|
+
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CODE_BLOCK, RTECodeBlock.name, new CodeBlockRemoveSelfStrategy());
|
|
3834
|
+
ActionHandleStrategyRegistry.register(ModifyContentActionType.DELETE_CHILD, RTECodeBlock.name, new BlockRemoveNodeStrategy());
|
|
3835
|
+
ActionHandleStrategyRegistry.register(ModifyContentActionType.SWITCH_OUT_FROM_CODE_BLOCK, RTECodeBlock.name, new SwitchOutFromCodeBlockStrategy());
|
|
3836
|
+
ActionHandleStrategyRegistry.register(ModifyContentActionType.INSERT_IMAGE_TO_BLOCK, RTECodeBlock.name, new CodeBlockInsertImageStrategy());
|
|
3819
3837
|
})();
|
|
3838
|
+
RTECodeBlock.CODE_BLOCK_PLACEHOLDER_CLASS_NAME = 'code-block-placeholder-element';
|
|
3820
3839
|
|
|
3821
|
-
export {
|
|
3840
|
+
export { UnderlineAnnotationAction as $, ActionHandleStrategy as A, BlockDeleteNodeContentStrategy as B, CustomStyleAnnotation as C, RTE_TEXT_COLORS as D, RTENode as E, stateEntityRenderingRegistry as F, InternalAnnotationTypeEnum as G, HorizontalAlignmentAnnotationAction as H, InsertBlocksAfterAction as I, ImageAnnotation as J, CommonAnnotationTypeEnum as K, LinkAnnotationAction as L, ModifyContentAction as M, NodeAnnotationTypeEnum as N, NodeAnnotation as O, SelectionChangeAction as P, TextColorAnnotation as Q, RemoveChildAction as R, SplitBlockWithNodeAction as S, TextSplittableAction as T, UpdateCodeBlockAction as U, RTECodeBlockNode as V, AnnotationAction as W, CodeLanguage as X, BoldAnnotationAction as Y, ZERO_WIDTH_SPACE as Z, ItalicAnnotationAction as _, RTEImageNode as a, TextStyleAnnotationAction as a0, TextStyleAnnotation as a1, BoldAnnotation as a2, ClearFormattingAnnotationAction as a3, CodeAnnotationAction as a4, StrikethroughAnnotationAction as a5, IndentAnnotationAction as a6, UpdateTextAction as a7, MergeTwoBlocksNodesAction as a8, ReplaceChildNodesAction as b, AppendChildNodesAction as c, RTETextBlock as d, InsertBlocksBeforeAction as e, ModifyContentActionType as f, RTETextNode as g, BlockReplaceNodeWithNodesStrategy as h, RTEBlock as i, ActionHandleStrategyRegistry as j, BlockMergeNodesStrategy as k, BlockRemoveNodeStrategy as l, BlockAppendNodesStrategy as m, BlockReplaceNodesStrategy as n, BlockInsertNodesBeforeNodeStrategy as o, BlockUpdateHorizontalAlignmentStrategy as p, BlockDeleteTextContentStrategy as q, BlockInsertLineBreakStrategy as r, BlockInsertLineBreakWithBlocksStrategy as s, BlockSplitWithTextNodeStrategy as t, SyncUpSelectionAction as u, BlockAnnotation as v, BlockAnnotationTypeEnum as w, CustomClassAnnotation as x, CustomAttributeAnnotation as y, RTECodeBlock as z };
|