@heartlandone/vega 2.34.1 → 2.35.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-48582633.js → app-globals-fb3693cc.js} +22 -21
- package/dist/cjs/{change-manager-bda1d107.js → change-manager-a297e4d2.js} +1 -1
- package/dist/cjs/{child-nodes-event-prevent-slimmer-e1a6e5ad.js → child-nodes-event-prevent-slimmer-96c3c4ae.js} +3 -3
- package/dist/cjs/{child-nodes-notify-observer-slimmer-03a3f79e.js → child-nodes-notify-observer-slimmer-be92f366.js} +5 -5
- package/dist/cjs/{component-63af66ea.js → component-73a88c4e.js} +1 -1
- package/dist/cjs/{component-global-style-slimmer-6b64a26c.js → component-global-style-slimmer-6749808c.js} +1 -1
- package/dist/cjs/{component-usage-runtime-metrics-019d3c00.js → component-usage-runtime-metrics-dcb32c24.js} +1 -1
- package/dist/cjs/content-state-3e4467a3.js +134 -0
- package/dist/cjs/{create-public-api-runtime-metrics-slimmer-8c6a8fb7.js → create-public-api-runtime-metrics-slimmer-54c3f73b.js} +2 -2
- package/dist/cjs/{date-ffe382a4.js → date-0a6bb035.js} +1 -1
- package/dist/cjs/{deprecated-property-slimmer-f36e3779.js → deprecated-property-slimmer-fc729fd9.js} +2 -2
- package/dist/cjs/{design-token-908e3f69.js → design-token-30c069c1.js} +3 -3
- package/dist/cjs/{dom-node-subject-observer-factory-093462f1.js → dom-node-subject-factory-3ec114b8.js} +1 -41
- package/dist/cjs/dom-node-subject-observer-factory-5f0eae19.js +44 -0
- package/dist/cjs/{dynamic-slimmer-dc30600a.js → dynamic-slimmer-f31fdfd7.js} +1 -1
- package/dist/cjs/{element-appender-slimmer-0dd70e61.js → element-appender-slimmer-700b7004.js} +6 -6
- package/dist/cjs/{event-emit-slimmer-a46bb411.js → event-emit-slimmer-9c223f73.js} +7 -6
- package/dist/cjs/{feature-flag-controller-e97b5f29.js → feature-flag-controller-7b22e598.js} +1 -1
- package/dist/cjs/{form-field-controller-slimmer-9aeabcdc.js → form-field-controller-slimmer-7ef32059.js} +16 -15
- package/dist/cjs/global-slimmer-registry-b3bce7e0.js +297 -0
- package/dist/cjs/{icon-manager-36dcfb65.js → icon-manager-edc2400b.js} +2 -2
- package/dist/cjs/{text-color-toolbar-button-slimmer-21a166e4.js → image-annotation-action-d3e1699c.js} +78 -27
- package/dist/cjs/{global-slimmer-registry-dd2691b8.js → index-09acd3c9.js} +282 -296
- package/dist/cjs/index.cjs.js +27 -28
- package/dist/cjs/{inject-keyboard-manager-af37c861.js → inject-keyboard-manager-4a5c27a2.js} +1 -1
- package/dist/cjs/{internal-icon-manager-2282a62f.js → internal-icon-manager-5ccb9443.js} +1 -1
- package/dist/cjs/{internal-vega-event-manager-d7643ec6.js → internal-vega-event-manager-e5e4bcf4.js} +72 -72
- package/dist/cjs/{internal-vega-z-index-manager-e24e4309.js → internal-vega-z-index-manager-f03ddb37.js} +1 -1
- package/dist/cjs/{keyboard-manager-5afbc8f1.js → keyboard-manager-2df53b2f.js} +1 -1
- package/dist/cjs/{keyboard-manager-slimmer-9be2a880.js → keyboard-manager-slimmer-feba3a83.js} +2 -2
- package/dist/cjs/{content-state-6a5b9736.js → list-block-91116257.js} +1346 -402
- package/dist/cjs/loader.cjs.js +21 -21
- package/dist/cjs/{mutation-observer-slimmer-98bbbdf0.js → mutation-observer-slimmer-895b3d3e.js} +1 -1
- package/dist/cjs/{node.abstract-f8075f84.js → node-annotation.abstract-e5d3a859.js} +37 -48
- package/dist/cjs/{page-resize-observer-slimmer-e54fa9d4.js → page-resize-observer-slimmer-bb1eaebe.js} +1 -1
- package/dist/cjs/{remote-invocation-registry-71a45468.js → remote-invocation-registry-ff9af278.js} +3 -3
- package/dist/cjs/{responsive-format-facade-74079f1b.js → responsive-format-facade-4363a00d.js} +1 -1
- package/dist/cjs/{state-background-color-formatter-d32a1098.js → state-background-color-formatter-e585a027.js} +1 -1
- package/dist/cjs/{string-input-formatter-slimmer-297765c0.js → string-input-formatter-slimmer-6155c9f5.js} +1 -1
- package/dist/cjs/{style-formatter-5deb065f.js → style-formatter-63218b76.js} +1 -1
- package/dist/cjs/{sub-state-notify-slimmer-73201c53.js → sub-state-notify-slimmer-c2e08e06.js} +8 -8
- package/dist/cjs/{sub-state-observer-slimmer-10c0d402.js → sub-state-observer-slimmer-b97e46b5.js} +8 -8
- package/dist/cjs/{translation-f6b7ee84.js → translation-b9be41e0.js} +3 -3
- package/dist/cjs/{translation-slimmer-90f9f71f.js → translation-slimmer-ec76c5a2.js} +2 -2
- package/dist/cjs/{ui-b5906704.js → ui-5fd9b267.js} +1 -1
- package/dist/cjs/vega-accordion.cjs.entry.js +41 -39
- package/dist/cjs/vega-app-footer.cjs.entry.js +13 -12
- package/dist/cjs/vega-app-header-button.cjs.entry.js +42 -40
- package/dist/cjs/vega-backdrop.cjs.entry.js +9 -8
- package/dist/cjs/vega-banner.cjs.entry.js +36 -34
- package/dist/cjs/vega-bar-chart.cjs.entry.js +6 -5
- package/dist/cjs/vega-box.cjs.entry.js +13 -12
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +34 -32
- package/dist/cjs/vega-button-circle.cjs.entry.js +25 -23
- package/dist/cjs/vega-button-group_2.cjs.entry.js +32 -30
- package/dist/cjs/vega-button-link.cjs.entry.js +26 -24
- package/dist/cjs/vega-button.cjs.entry.js +26 -24
- package/dist/cjs/vega-calendar_3.cjs.entry.js +135 -133
- package/dist/cjs/vega-card.cjs.entry.js +11 -10
- package/dist/cjs/vega-carousel.cjs.entry.js +25 -23
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +46 -44
- package/dist/cjs/vega-chip.cjs.entry.js +36 -34
- package/dist/cjs/vega-color-picker.cjs.entry.js +26 -24
- package/dist/cjs/vega-combo-box.cjs.entry.js +46 -44
- package/dist/cjs/vega-counter-badge.cjs.entry.js +10 -9
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +56 -54
- package/dist/cjs/{vega-dialog-controller-aaf1f43e.js → vega-dialog-controller-fe610705.js} +2 -2
- package/dist/cjs/vega-dialog_2.cjs.entry.js +47 -45
- package/dist/cjs/vega-divider.cjs.entry.js +11 -10
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +132 -130
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-field-error.cjs.entry.js +8 -7
- package/dist/cjs/vega-field-label.cjs.entry.js +22 -20
- package/dist/cjs/vega-file-uploader.cjs.entry.js +67 -65
- package/dist/cjs/vega-flex.cjs.entry.js +14 -13
- package/dist/cjs/vega-font.cjs.entry.js +14 -13
- package/dist/cjs/vega-form.cjs.entry.js +38 -36
- package/dist/cjs/vega-grid.cjs.entry.js +11 -10
- package/dist/cjs/vega-hint.cjs.entry.js +7 -6
- package/dist/cjs/vega-icon.cjs.entry.js +16 -15
- package/dist/cjs/vega-image-uploader.cjs.entry.js +51 -49
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +37 -35
- package/dist/cjs/vega-input-numeric.cjs.entry.js +30 -28
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +49 -47
- package/dist/cjs/vega-input-range.cjs.entry.js +40 -38
- package/dist/cjs/vega-input-select.cjs.entry.js +62 -60
- package/dist/cjs/vega-input.cjs.entry.js +46 -44
- package/dist/cjs/vega-item-toggle.cjs.entry.js +21 -19
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +102 -100
- package/dist/cjs/vega-line-chart.cjs.entry.js +7 -6
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +16 -15
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +20 -18
- package/dist/cjs/vega-pagination.cjs.entry.js +52 -50
- package/dist/cjs/vega-pie-chart.cjs.entry.js +7 -6
- package/dist/cjs/vega-popover_2.cjs.entry.js +34 -32
- package/dist/cjs/vega-progress-tracker.cjs.entry.js +29 -27
- package/dist/cjs/vega-radio_2.cjs.entry.js +50 -48
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +321 -23
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +336 -334
- package/dist/cjs/vega-section-title.cjs.entry.js +15 -14
- package/dist/cjs/vega-segment-control.cjs.entry.js +24 -22
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +49 -47
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +61 -59
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +46 -44
- package/dist/cjs/vega-signature-capture.cjs.entry.js +40 -38
- package/dist/cjs/{block-annotation.abstract-4d88b939.js → vega-skeleton-loader-controller-7dac484f.js} +7 -21
- package/dist/cjs/vega-skeleton.cjs.entry.js +26 -25
- package/dist/cjs/vega-slot-container.cjs.entry.js +6 -5
- package/dist/cjs/vega-stepper.cjs.entry.js +34 -32
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +54 -52
- package/dist/cjs/vega-table_8.cjs.entry.js +184 -182
- package/dist/cjs/vega-text.cjs.entry.js +9 -8
- package/dist/cjs/vega-textarea.cjs.entry.js +34 -32
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +83 -81
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +23 -21
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +20 -19
- package/dist/cjs/vega.cjs.js +21 -21
- package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +22 -1
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-group-annotation.js +0 -90
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +0 -24
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +67 -13
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +45 -12
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +68 -8
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +111 -36
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +23 -50
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/node.abstract.js +0 -25
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/text-node.js +95 -19
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/block-renderer.abstract.js +37 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/image-block-renderer.js +13 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/list-block-renderer.js +12 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/list-item-block-renderer.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.js +123 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/image-node-renderer.js +48 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/node-renderer.abstract.js +37 -0
- package/dist/collection/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.js +26 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/image-block.test.js +0 -10
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/list-block.test.js +0 -48
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/list-item.test.js +0 -40
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/text-block.test.js +0 -39
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/image-node.test.js +0 -14
- package/dist/collection/components/vega-rich-text-editor/test/dto/nodes/text-node.test.js +0 -34
- package/dist/esm/{app-globals-48531a04.js → app-globals-5b154b6d.js} +13 -12
- package/dist/esm/{change-manager-8f5b72c2.js → change-manager-6a7eb88c.js} +1 -1
- package/dist/esm/{child-nodes-event-prevent-slimmer-8ceabe63.js → child-nodes-event-prevent-slimmer-97aae8a8.js} +3 -3
- package/dist/esm/{child-nodes-notify-observer-slimmer-afc15e00.js → child-nodes-notify-observer-slimmer-289caacc.js} +4 -4
- package/dist/esm/{component-051a594c.js → component-cae24190.js} +1 -1
- package/dist/esm/{component-global-style-slimmer-631f956f.js → component-global-style-slimmer-000e0c11.js} +1 -1
- package/dist/esm/{component-usage-runtime-metrics-21813c36.js → component-usage-runtime-metrics-385c7124.js} +1 -1
- package/dist/esm/content-state-f39c4bbf.js +132 -0
- package/dist/esm/{create-public-api-runtime-metrics-slimmer-14cb4599.js → create-public-api-runtime-metrics-slimmer-9ab05523.js} +2 -2
- package/dist/esm/{date-655c0af8.js → date-732bc749.js} +1 -1
- package/dist/esm/{deprecated-property-slimmer-9ea5019c.js → deprecated-property-slimmer-43d184b3.js} +2 -2
- package/dist/esm/{design-token-20fdba82.js → design-token-d06bc718.js} +3 -3
- package/dist/esm/{dom-node-subject-observer-factory-80358591.js → dom-node-subject-factory-5831cdd4.js} +2 -41
- package/dist/esm/dom-node-subject-observer-factory-dc486a8b.js +42 -0
- package/dist/esm/{dynamic-slimmer-85746483.js → dynamic-slimmer-90b8af32.js} +1 -1
- package/dist/esm/{element-appender-slimmer-4dfa326d.js → element-appender-slimmer-d71e3109.js} +6 -6
- package/dist/esm/{event-emit-slimmer-c03cf145.js → event-emit-slimmer-f285e3ac.js} +6 -5
- package/dist/esm/{feature-flag-controller-dfde0cfa.js → feature-flag-controller-4b3fe6f8.js} +1 -1
- package/dist/esm/{form-field-controller-slimmer-de5fe574.js → form-field-controller-slimmer-af969d03.js} +10 -9
- package/dist/esm/global-slimmer-registry-17c4efd4.js +283 -0
- package/dist/esm/{icon-manager-3cef32e7.js → icon-manager-b889176b.js} +2 -2
- package/dist/esm/{text-color-toolbar-button-slimmer-b2270b64.js → image-annotation-action-a8e00f28.js} +55 -6
- package/dist/esm/{global-slimmer-registry-6887a59f.js → index-187f71d1.js} +283 -284
- package/dist/esm/index.js +20 -21
- package/dist/esm/{inject-keyboard-manager-45309420.js → inject-keyboard-manager-b0135018.js} +1 -1
- package/dist/esm/{internal-icon-manager-7fc7535a.js → internal-icon-manager-900a5bb4.js} +1 -1
- package/dist/esm/{internal-vega-event-manager-3a3815d3.js → internal-vega-event-manager-07e1b3d9.js} +2 -2
- package/dist/esm/{internal-vega-z-index-manager-89e8b6f5.js → internal-vega-z-index-manager-7d2b54c3.js} +1 -1
- package/dist/esm/{keyboard-manager-2c06eafe.js → keyboard-manager-4c898a0d.js} +1 -1
- package/dist/esm/{keyboard-manager-slimmer-fd177285.js → keyboard-manager-slimmer-f80d6835.js} +2 -2
- package/dist/esm/{content-state-4b036bf1.js → list-block-ba82c846.js} +1225 -299
- package/dist/esm/loader.js +19 -19
- package/dist/esm/{mutation-observer-slimmer-ca2cb2e8.js → mutation-observer-slimmer-6cef9549.js} +1 -1
- package/dist/esm/{node.abstract-93746055.js → node-annotation.abstract-d7d52bce.js} +35 -47
- package/dist/esm/{page-resize-observer-slimmer-8589ebc8.js → page-resize-observer-slimmer-beb7b0bd.js} +1 -1
- 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/{remote-invocation-registry-2ec6936d.js → remote-invocation-registry-d97fa3bc.js} +2 -2
- package/dist/esm/{responsive-format-facade-559ec469.js → responsive-format-facade-c2ab9c87.js} +1 -1
- package/dist/esm/{state-background-color-formatter-16031a43.js → state-background-color-formatter-121ae7d3.js} +1 -1
- package/dist/esm/{string-input-formatter-slimmer-c9fb1fa1.js → string-input-formatter-slimmer-73fa06e6.js} +1 -1
- package/dist/esm/{style-formatter-51845b6d.js → style-formatter-f91471e8.js} +1 -1
- package/dist/esm/{sub-state-notify-slimmer-6e97a58a.js → sub-state-notify-slimmer-48bad548.js} +4 -4
- package/dist/esm/{sub-state-observer-slimmer-0968ce04.js → sub-state-observer-slimmer-403cc4e7.js} +4 -4
- package/dist/esm/{translation-b3fe8e74.js → translation-a98970d8.js} +3 -3
- package/dist/esm/{translation-slimmer-860cd766.js → translation-slimmer-5ee9912b.js} +2 -2
- package/dist/esm/{ui-5600b48f.js → ui-62e4be97.js} +1 -1
- package/dist/esm/vega-accordion.entry.js +17 -15
- package/dist/esm/vega-app-footer.entry.js +4 -3
- package/dist/esm/vega-app-header-button.entry.js +20 -18
- package/dist/esm/vega-backdrop.entry.js +5 -4
- package/dist/esm/vega-banner.entry.js +15 -13
- package/dist/esm/vega-bar-chart.entry.js +3 -2
- package/dist/esm/vega-box.entry.js +10 -9
- package/dist/esm/vega-breadcrumb.entry.js +13 -11
- package/dist/esm/vega-button-circle.entry.js +16 -14
- package/dist/esm/vega-button-group_2.entry.js +15 -13
- package/dist/esm/vega-button-link.entry.js +13 -11
- package/dist/esm/vega-button.entry.js +15 -13
- package/dist/esm/vega-calendar_3.entry.js +23 -21
- package/dist/esm/vega-card.entry.js +8 -7
- package/dist/esm/vega-carousel.entry.js +14 -12
- package/dist/esm/vega-checkbox_2.entry.js +19 -17
- package/dist/esm/vega-chip.entry.js +17 -15
- package/dist/esm/vega-color-picker.entry.js +16 -14
- package/dist/esm/vega-combo-box.entry.js +20 -18
- package/dist/esm/vega-counter-badge.entry.js +4 -3
- package/dist/esm/vega-date-picker_2.entry.js +31 -29
- package/dist/esm/{vega-dialog-controller-5b23f68c.js → vega-dialog-controller-34eb8967.js} +2 -2
- package/dist/esm/vega-dialog_2.entry.js +20 -18
- package/dist/esm/vega-divider.entry.js +8 -7
- package/dist/esm/vega-dropdown_5.entry.js +27 -25
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-field-error.entry.js +5 -4
- package/dist/esm/vega-field-label.entry.js +11 -9
- package/dist/esm/vega-file-uploader.entry.js +19 -17
- package/dist/esm/vega-flex.entry.js +11 -10
- package/dist/esm/vega-font.entry.js +9 -8
- package/dist/esm/vega-form.entry.js +19 -17
- package/dist/esm/vega-grid.entry.js +8 -7
- package/dist/esm/vega-hint.entry.js +4 -3
- package/dist/esm/vega-icon.entry.js +11 -10
- package/dist/esm/vega-image-uploader.entry.js +21 -19
- package/dist/esm/vega-input-credit-card.entry.js +20 -18
- package/dist/esm/vega-input-numeric.entry.js +21 -19
- package/dist/esm/vega-input-phone-number.entry.js +21 -19
- package/dist/esm/vega-input-range.entry.js +19 -17
- package/dist/esm/vega-input-select.entry.js +22 -20
- package/dist/esm/vega-input.entry.js +18 -16
- package/dist/esm/vega-item-toggle.entry.js +12 -10
- package/dist/esm/vega-left-nav_5.entry.js +24 -22
- package/dist/esm/vega-line-chart.entry.js +4 -3
- package/dist/esm/vega-loader-wrapper_2.entry.js +7 -6
- package/dist/esm/vega-page-notification_2.entry.js +8 -6
- package/dist/esm/vega-pagination.entry.js +16 -14
- package/dist/esm/vega-pie-chart.entry.js +4 -3
- package/dist/esm/vega-popover_2.entry.js +18 -16
- package/dist/esm/vega-progress-tracker.entry.js +12 -10
- package/dist/esm/vega-radio_2.entry.js +21 -19
- package/dist/esm/vega-rich-text-content.entry.js +315 -17
- package/dist/esm/vega-rich-text-editor_4.entry.js +31 -29
- package/dist/esm/vega-section-title.entry.js +4 -3
- package/dist/esm/vega-segment-control.entry.js +12 -10
- package/dist/esm/vega-selection-chip_2.entry.js +21 -19
- package/dist/esm/vega-selection-tile_2.entry.js +21 -19
- package/dist/esm/vega-sidenav_3.entry.js +19 -17
- package/dist/esm/vega-signature-capture.entry.js +22 -20
- package/dist/esm/{block-annotation.abstract-b0554e2b.js → vega-skeleton-loader-controller-0aaaf1fa.js} +8 -21
- package/dist/esm/vega-skeleton.entry.js +4 -3
- package/dist/esm/vega-slot-container.entry.js +3 -2
- package/dist/esm/vega-stepper.entry.js +18 -16
- package/dist/esm/vega-tab-group_2.entry.js +14 -12
- package/dist/esm/vega-table_8.entry.js +25 -23
- package/dist/esm/vega-text.entry.js +5 -4
- package/dist/esm/vega-textarea.entry.js +18 -16
- package/dist/esm/vega-time-picker_2.entry.js +25 -23
- package/dist/esm/vega-toggle-switch.entry.js +16 -14
- package/dist/esm/vega-tooltip_2.entry.js +13 -12
- package/dist/esm/vega.js +19 -19
- package/dist/types/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-group-annotation.d.ts +0 -6
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +2 -15
- package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +68 -4
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +45 -3
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +68 -3
- package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +110 -5
- package/dist/types/components/vega-rich-text-editor/dto/nodes/image-node.d.ts +21 -5
- package/dist/types/components/vega-rich-text-editor/dto/nodes/node.abstract.d.ts +1 -14
- package/dist/types/components/vega-rich-text-editor/dto/nodes/text-node.d.ts +86 -2
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/block-renderer.abstract.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/image-block-renderer.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/list-block-renderer.d.ts +8 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/list-item-block-renderer.d.ts +9 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/blocks/text-block-renderer.d.ts +15 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/image-node-renderer.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/node-renderer.abstract.d.ts +22 -0
- package/dist/types/components/vega-rich-text-editor/dto/renderers/nodes/text-node-renderer.d.ts +10 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-000b3ab0.js +1 -0
- package/dist/vega/p-00738ae9.entry.js +1 -0
- package/dist/vega/p-01d0dbe6.entry.js +1 -0
- package/dist/vega/{p-b3f9cc3a.entry.js → p-0283712e.entry.js} +2 -2
- package/dist/vega/p-032df16f.js +1 -0
- package/dist/vega/p-05f5e22b.entry.js +1 -0
- package/dist/vega/p-0945a58d.entry.js +1 -0
- package/dist/vega/p-09c5de7f.entry.js +1 -0
- package/dist/vega/p-0a8b91f5.entry.js +1 -0
- package/dist/vega/{p-f763e2eb.js → p-0af4bda9.js} +1 -1
- package/dist/vega/p-0bd9b1d9.entry.js +1 -0
- package/dist/vega/p-0c2eb135.entry.js +1 -0
- package/dist/vega/p-0da2de05.entry.js +1 -0
- package/dist/vega/p-0ee10fd7.js +1 -0
- package/dist/vega/p-12ad8ada.entry.js +1 -0
- package/dist/vega/p-14514252.entry.js +1 -0
- package/dist/vega/{p-11a19ca0.js → p-149d2801.js} +1 -1
- package/dist/vega/p-14f85e30.entry.js +1 -0
- package/dist/vega/p-19556584.entry.js +1 -0
- package/dist/vega/p-1b3e0a9f.entry.js +1 -0
- package/dist/vega/p-1c298d5a.js +2 -0
- package/dist/vega/p-1d805cc0.entry.js +1 -0
- package/dist/vega/p-1dd9f841.entry.js +1 -0
- package/dist/vega/p-211df22a.entry.js +1 -0
- package/dist/vega/p-2205ee4c.js +1 -0
- package/dist/vega/p-29b09aad.js +1 -0
- package/dist/vega/{p-443ad3b3.js → p-2d0d575f.js} +1 -1
- package/dist/vega/p-2f32a9ba.js +1 -0
- package/dist/vega/{p-368d0060.js → p-2fbda931.js} +1 -1
- package/dist/vega/p-33b62194.js +1 -0
- package/dist/vega/p-36db2554.entry.js +1 -0
- package/dist/vega/p-3a6c9b9d.entry.js +1 -0
- package/dist/vega/p-42df8a42.js +1 -0
- package/dist/vega/{p-8f93242a.js → p-4387d550.js} +1 -1
- package/dist/vega/p-45c88f7f.entry.js +1 -0
- package/dist/vega/p-45dd4698.entry.js +1 -0
- package/dist/vega/p-465fa96d.entry.js +1 -0
- package/dist/vega/{p-3b4bde3e.js → p-4b500240.js} +1 -1
- package/dist/vega/{p-e0b25eaf.js → p-4f0b56fc.js} +1 -1
- package/dist/vega/p-5298fd92.entry.js +1 -0
- package/dist/vega/p-5915634b.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-70151c27.js → p-5f589974.js} +1 -1
- package/dist/vega/p-61116634.entry.js +1 -0
- package/dist/vega/p-618b35e4.entry.js +1 -0
- package/dist/vega/p-625771d7.entry.js +1 -0
- package/dist/vega/p-6661a462.entry.js +1 -0
- package/dist/vega/{p-62774231.js → p-6705c68a.js} +1 -1
- package/dist/vega/p-68f0aa72.entry.js +1 -0
- package/dist/vega/{p-59bdf9b8.js → p-6a334573.js} +1 -1
- package/dist/vega/p-6a3989dd.js +1 -0
- package/dist/vega/{p-0e0c47ad.js → p-6a5a5c7b.js} +1 -1
- package/dist/vega/p-6c09b79a.entry.js +1 -0
- package/dist/vega/p-6d23c08b.entry.js +1 -0
- package/dist/vega/p-6d43b123.entry.js +1 -0
- package/dist/vega/p-6e1ab235.js +1 -0
- package/dist/vega/p-71eeb279.entry.js +1 -0
- package/dist/vega/p-72eee5e2.js +1 -0
- package/dist/vega/{p-eac38d87.js → p-781fd6e0.js} +1 -1
- package/dist/vega/{p-1995e98e.js → p-79ec5d69.js} +1 -1
- package/dist/vega/p-8067bd31.entry.js +1 -0
- package/dist/vega/{p-3f1b542a.js → p-81dbada7.js} +1 -1
- package/dist/vega/{p-a6a7d0c9.js → p-8284a445.js} +1 -1
- package/dist/vega/p-84113217.entry.js +1 -0
- package/dist/vega/p-843b13e6.entry.js +1 -0
- package/dist/vega/p-84f2f342.js +1 -0
- package/dist/vega/p-85365f8b.js +1 -0
- package/dist/vega/p-8ab356e8.entry.js +1 -0
- package/dist/vega/p-8ba43640.entry.js +1 -0
- package/dist/vega/p-8be7b62c.entry.js +1 -0
- package/dist/vega/p-8d69f9ef.entry.js +1 -0
- package/dist/vega/p-91aa058f.entry.js +1 -0
- package/dist/vega/{p-8c26227e.js → p-926596cc.js} +1 -1
- package/dist/vega/p-92707b74.entry.js +1 -0
- package/dist/vega/p-96f0ef53.entry.js +1 -0
- package/dist/vega/p-97453cd8.entry.js +1 -0
- package/dist/vega/{p-843a0c1c.js → p-987fbbd0.js} +1 -1
- package/dist/vega/{p-296cc56b.js → p-9b797118.js} +1 -1
- package/dist/vega/p-a01f149d.entry.js +1 -0
- package/dist/vega/p-a0e90d5d.entry.js +1 -0
- package/dist/vega/{p-3953c705.js → p-af7a3154.js} +1 -1
- package/dist/vega/p-b2bca332.entry.js +1 -0
- package/dist/vega/p-b450bf46.entry.js +1 -0
- package/dist/vega/p-b5990090.js +1 -0
- package/dist/vega/p-b64981de.entry.js +1 -0
- package/dist/vega/p-b6815874.js +1 -0
- package/dist/vega/p-b688a71b.js +1 -0
- package/dist/vega/p-b9a09a76.js +1 -0
- package/dist/vega/p-bcb10ae3.entry.js +1 -0
- package/dist/vega/{p-39836361.js → p-be12fa36.js} +1 -1
- package/dist/vega/p-c02f650e.entry.js +1 -0
- package/dist/vega/p-c2b276f7.entry.js +1 -0
- package/dist/vega/p-c51a3e3c.entry.js +1 -0
- package/dist/vega/p-c88acd87.entry.js +1 -0
- package/dist/vega/p-cb8f8458.entry.js +1 -0
- package/dist/vega/p-cda26bdf.entry.js +1 -0
- package/dist/vega/p-d09d153f.entry.js +1 -0
- package/dist/vega/p-d994874a.entry.js +1 -0
- package/dist/vega/p-dbec03ed.entry.js +1 -0
- package/dist/vega/p-dcdac4d0.entry.js +1 -0
- package/dist/vega/p-de13b747.entry.js +1 -0
- package/dist/vega/p-de25326f.js +1 -0
- package/dist/vega/{p-e1e1fcf0.js → p-de664bdd.js} +1 -1
- package/dist/vega/p-e04d4ba3.entry.js +1 -0
- package/dist/vega/p-e8f540d8.js +1 -0
- package/dist/vega/p-e923637d.entry.js +1 -0
- package/dist/vega/p-efbea85a.entry.js +1 -0
- package/dist/vega/{p-81ead59a.js → p-f31bb1fd.js} +1 -1
- package/dist/vega/p-f690539e.entry.js +1 -0
- package/dist/vega/p-f6b89936.entry.js +1 -0
- package/dist/vega/p-f84fd31c.js +1 -0
- package/dist/vega/p-fe388812.entry.js +1 -0
- package/dist/vega/{p-acf7f903.js → p-ff4bafa3.js} +1 -1
- package/dist/vega/p-ff50c204.entry.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +3 -2
- package/dist/cjs/text-node-494856f3.js +0 -955
- package/dist/esm/text-node-a652ca87.js +0 -933
- package/dist/vega/p-0190095c.entry.js +0 -1
- package/dist/vega/p-034e6348.entry.js +0 -1
- package/dist/vega/p-0cd2b50f.entry.js +0 -1
- package/dist/vega/p-10393104.js +0 -1
- package/dist/vega/p-109a00cf.entry.js +0 -1
- package/dist/vega/p-11cb477b.js +0 -1
- package/dist/vega/p-1564cc4d.entry.js +0 -1
- package/dist/vega/p-18886765.entry.js +0 -1
- package/dist/vega/p-19b26168.entry.js +0 -1
- package/dist/vega/p-21992602.entry.js +0 -1
- package/dist/vega/p-22563151.entry.js +0 -1
- package/dist/vega/p-23795da1.entry.js +0 -1
- package/dist/vega/p-29277e41.entry.js +0 -1
- package/dist/vega/p-2a7e9422.entry.js +0 -1
- package/dist/vega/p-2ca6d977.entry.js +0 -1
- package/dist/vega/p-2e419309.entry.js +0 -1
- package/dist/vega/p-3039bef8.js +0 -1
- package/dist/vega/p-34939c97.entry.js +0 -1
- package/dist/vega/p-3897bb2d.entry.js +0 -1
- package/dist/vega/p-390c5236.entry.js +0 -1
- package/dist/vega/p-3ce31dc3.js +0 -1
- package/dist/vega/p-452e284a.js +0 -1
- package/dist/vega/p-4c41dd64.js +0 -1
- package/dist/vega/p-55beac7f.entry.js +0 -1
- package/dist/vega/p-57405834.entry.js +0 -1
- package/dist/vega/p-584dcd9b.js +0 -1
- package/dist/vega/p-589e6041.entry.js +0 -1
- package/dist/vega/p-5e95402a.entry.js +0 -1
- package/dist/vega/p-5eee21b4.entry.js +0 -1
- package/dist/vega/p-62cea2e7.entry.js +0 -1
- package/dist/vega/p-65b79fd7.js +0 -1
- package/dist/vega/p-6741e2b9.entry.js +0 -1
- package/dist/vega/p-6a084fe1.entry.js +0 -1
- package/dist/vega/p-6b286226.entry.js +0 -1
- package/dist/vega/p-6b722905.entry.js +0 -1
- package/dist/vega/p-6e4b2752.entry.js +0 -1
- package/dist/vega/p-7209d03b.js +0 -1
- package/dist/vega/p-734ea281.entry.js +0 -1
- package/dist/vega/p-76fc408e.entry.js +0 -1
- package/dist/vega/p-7a9f453e.entry.js +0 -1
- package/dist/vega/p-80ccd894.entry.js +0 -1
- package/dist/vega/p-84c597c8.entry.js +0 -1
- package/dist/vega/p-8836c1b9.js +0 -1
- package/dist/vega/p-8b78c6a3.entry.js +0 -1
- package/dist/vega/p-8be45a45.entry.js +0 -1
- package/dist/vega/p-8d7b45f7.entry.js +0 -1
- package/dist/vega/p-8e17b9dd.entry.js +0 -1
- package/dist/vega/p-8f004647.entry.js +0 -1
- package/dist/vega/p-925a2137.js +0 -1
- package/dist/vega/p-92f88033.entry.js +0 -1
- package/dist/vega/p-94de7a02.entry.js +0 -1
- package/dist/vega/p-9968e71d.entry.js +0 -1
- package/dist/vega/p-9c1eeff2.js +0 -2
- package/dist/vega/p-9d1b9e70.entry.js +0 -1
- package/dist/vega/p-9e732a26.entry.js +0 -1
- package/dist/vega/p-9f39dd10.js +0 -1
- package/dist/vega/p-a5ffe912.js +0 -1
- package/dist/vega/p-a6104aa7.js +0 -1
- package/dist/vega/p-a6169ad6.entry.js +0 -1
- package/dist/vega/p-a8bf559a.js +0 -1
- package/dist/vega/p-afec17ad.entry.js +0 -1
- package/dist/vega/p-b693c1ac.entry.js +0 -1
- package/dist/vega/p-b9e2add4.entry.js +0 -1
- package/dist/vega/p-bd894860.entry.js +0 -1
- package/dist/vega/p-c0d6a587.entry.js +0 -1
- package/dist/vega/p-c26e6820.entry.js +0 -1
- package/dist/vega/p-c34487e1.entry.js +0 -1
- package/dist/vega/p-c532b132.entry.js +0 -1
- package/dist/vega/p-ca2fb711.js +0 -1
- package/dist/vega/p-cebf93f1.entry.js +0 -1
- package/dist/vega/p-cfdc148a.entry.js +0 -1
- package/dist/vega/p-d0351d71.entry.js +0 -1
- package/dist/vega/p-d2ab6096.entry.js +0 -1
- package/dist/vega/p-d35643c5.entry.js +0 -1
- package/dist/vega/p-d400a1d9.entry.js +0 -1
- package/dist/vega/p-d6732a72.entry.js +0 -1
- package/dist/vega/p-d720b06a.entry.js +0 -1
- package/dist/vega/p-d987e404.entry.js +0 -1
- package/dist/vega/p-d9b86108.entry.js +0 -1
- package/dist/vega/p-e27e115d.entry.js +0 -1
- package/dist/vega/p-e65c8ac7.entry.js +0 -1
- package/dist/vega/p-e79057cc.js +0 -1
- package/dist/vega/p-e89e9769.entry.js +0 -1
- package/dist/vega/p-ecd64c7f.entry.js +0 -1
- package/dist/vega/p-f5b2e72a.entry.js +0 -1
- package/dist/vega/p-f6af3749.js +0 -1
- package/dist/vega/p-fc622a75.js +0 -1
|
@@ -1,22 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const changeManager = require('./change-manager-
|
|
6
|
-
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-093462f1.js');
|
|
7
|
-
const node_abstract = require('./node.abstract-f8075f84.js');
|
|
3
|
+
const nodeAnnotation_abstract = require('./node-annotation.abstract-e5d3a859.js');
|
|
4
|
+
const domNodeSubjectFactory = require('./dom-node-subject-factory-3ec114b8.js');
|
|
5
|
+
const changeManager = require('./change-manager-a297e4d2.js');
|
|
8
6
|
const vegaInternalEventId = require('./vega-internal-event-id-85b68849.js');
|
|
9
7
|
const typeGuard = require('./type-guard-4ba85fdc.js');
|
|
10
|
-
|
|
11
|
-
const createPublicApiRuntimeMetricsSlimmer = require('./create-public-api-runtime-metrics-slimmer-
|
|
8
|
+
require('./global-slimmer-registry-b3bce7e0.js');
|
|
9
|
+
const createPublicApiRuntimeMetricsSlimmer = require('./create-public-api-runtime-metrics-slimmer-54c3f73b.js');
|
|
10
|
+
|
|
11
|
+
/* istanbul ignore next */
|
|
12
|
+
/**
|
|
13
|
+
* Wait for all vega elements to be ready.
|
|
14
|
+
*
|
|
15
|
+
* The below method is e2e-test covered in @see{module:wait-for-vega-should-work-as-expected}
|
|
16
|
+
*/
|
|
17
|
+
const waitForVega = async () => {
|
|
18
|
+
return nodeAnnotation_abstract.WaitForVega.handle();
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Wait for the component has been rendered.
|
|
22
|
+
*
|
|
23
|
+
* @param {HTMLStencilElement} componentRef - The reference to the component that needs to be rendered.
|
|
24
|
+
* @returns {Promise<unknown>} A promise that resolves when the component has been rendered.
|
|
25
|
+
*/
|
|
26
|
+
const waitForComponentDidRender = async (componentRef) => {
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
const observer = new domNodeSubjectFactory.Observer(isAcceptableComponentDidRender.bind(null), () => {
|
|
29
|
+
changeManager.ChangeManager.unregister(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(componentRef, vegaInternalEventId.VegaInternalComponentDidRender), observer);
|
|
30
|
+
resolve(null);
|
|
31
|
+
});
|
|
32
|
+
changeManager.ChangeManager.register(domNodeSubjectFactory.domNodeSubjectFactory.getSubject(componentRef, vegaInternalEventId.VegaInternalComponentDidRender), observer);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Determines whether the observer should accept changes.
|
|
37
|
+
*
|
|
38
|
+
* @returns {boolean} Always returns true in the current implementation.
|
|
39
|
+
*/
|
|
40
|
+
const isAcceptableComponentDidRender = () => {
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
12
43
|
|
|
13
44
|
/**
|
|
14
45
|
* Annotation to make block with horizontal alignment
|
|
15
46
|
*/
|
|
16
|
-
class HorizontalAlignmentAnnotation extends
|
|
47
|
+
class HorizontalAlignmentAnnotation extends nodeAnnotation_abstract.BlockAnnotation {
|
|
17
48
|
constructor(textAlign) {
|
|
18
49
|
super();
|
|
19
|
-
this.type =
|
|
50
|
+
this.type = nodeAnnotation_abstract.BlockAnnotationTypeEnum.ALIGNMENT;
|
|
20
51
|
this.textAlign = textAlign;
|
|
21
52
|
}
|
|
22
53
|
/**
|
|
@@ -26,7 +57,7 @@ class HorizontalAlignmentAnnotation extends blockAnnotation_abstract.BlockAnnota
|
|
|
26
57
|
* @returns {[BlockAnnotationTypeEnum.ALIGNMENT, HorizontalAlignmentAnnotation]} Map item for the annotation
|
|
27
58
|
*/
|
|
28
59
|
static from(textAlign) {
|
|
29
|
-
return [
|
|
60
|
+
return [nodeAnnotation_abstract.BlockAnnotationTypeEnum.ALIGNMENT, new HorizontalAlignmentAnnotation(textAlign)];
|
|
30
61
|
}
|
|
31
62
|
/**
|
|
32
63
|
* Generate the JSON item of the annotation
|
|
@@ -59,10 +90,10 @@ class HorizontalAlignmentAnnotation extends blockAnnotation_abstract.BlockAnnota
|
|
|
59
90
|
/**
|
|
60
91
|
* Annotation for block indentation
|
|
61
92
|
*/
|
|
62
|
-
class IndentAnnotation extends
|
|
93
|
+
class IndentAnnotation extends nodeAnnotation_abstract.BlockAnnotation {
|
|
63
94
|
constructor(indent) {
|
|
64
95
|
super();
|
|
65
|
-
this.type =
|
|
96
|
+
this.type = nodeAnnotation_abstract.BlockAnnotationTypeEnum.INDENT;
|
|
66
97
|
this.indent = Math.max(0, indent);
|
|
67
98
|
}
|
|
68
99
|
/**
|
|
@@ -72,7 +103,7 @@ class IndentAnnotation extends blockAnnotation_abstract.BlockAnnotation {
|
|
|
72
103
|
* @returns {[BlockAnnotationTypeEnum.INDENT, IndentAnnotation]} Map item for the annotation
|
|
73
104
|
*/
|
|
74
105
|
static from(indent) {
|
|
75
|
-
return [
|
|
106
|
+
return [nodeAnnotation_abstract.BlockAnnotationTypeEnum.INDENT, new IndentAnnotation(indent)];
|
|
76
107
|
}
|
|
77
108
|
/**
|
|
78
109
|
* Generate the JSON item of the annotation
|
|
@@ -141,10 +172,10 @@ class BlockBaseOperator {
|
|
|
141
172
|
}
|
|
142
173
|
|
|
143
174
|
/** Append blocks or nodes to a block */
|
|
144
|
-
class AppendChildNodesAction extends
|
|
175
|
+
class AppendChildNodesAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
145
176
|
constructor(childNodes) {
|
|
146
177
|
super();
|
|
147
|
-
this.type =
|
|
178
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES;
|
|
148
179
|
this.entityToBeAppended = childNodes;
|
|
149
180
|
}
|
|
150
181
|
}
|
|
@@ -155,14 +186,48 @@ class AppendChildNodesAction extends node_abstract.ModifyContentAction {
|
|
|
155
186
|
* @example needRemovedNode.parentBlock.apply(new RemoveChildAction(needRemovedNode))
|
|
156
187
|
* @example needRemovedBlock.parent.apply(new RemoveChildAction(needRemovedBlock))
|
|
157
188
|
*/
|
|
158
|
-
class RemoveChildAction extends
|
|
189
|
+
class RemoveChildAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
159
190
|
constructor(childNode) {
|
|
160
191
|
super();
|
|
161
|
-
this.type =
|
|
192
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD;
|
|
162
193
|
this.entityToBeRemoved = childNode;
|
|
163
194
|
}
|
|
164
195
|
}
|
|
165
196
|
|
|
197
|
+
const RTE_TEXT_COLORS = [
|
|
198
|
+
{
|
|
199
|
+
key: 'black',
|
|
200
|
+
light: '#111128',
|
|
201
|
+
dark: '#E3E3E8',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
key: 'gray',
|
|
205
|
+
light: '#5E5E6D',
|
|
206
|
+
dark: '#B9B9C1',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: 'green',
|
|
210
|
+
light: '#01801F',
|
|
211
|
+
dark: '#59D977',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
key: 'red',
|
|
215
|
+
light: '#BD2947',
|
|
216
|
+
dark: '#FFB2B5',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: 'purple',
|
|
220
|
+
light: '#563D82',
|
|
221
|
+
dark: '#BEB2FF',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
key: 'teal',
|
|
225
|
+
light: '#17758F',
|
|
226
|
+
dark: '#4CD8FF',
|
|
227
|
+
},
|
|
228
|
+
];
|
|
229
|
+
const ZERO_WIDTH_SPACE = '\u200b';
|
|
230
|
+
|
|
166
231
|
/**
|
|
167
232
|
* Abstract class for block
|
|
168
233
|
*/
|
|
@@ -199,7 +264,7 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
199
264
|
*/
|
|
200
265
|
toJSON() {
|
|
201
266
|
const annotations = Array.from(this.annotationMap.values())
|
|
202
|
-
.filter((annotation) => annotation instanceof
|
|
267
|
+
.filter((annotation) => annotation instanceof nodeAnnotation_abstract.BlockAnnotation)
|
|
203
268
|
.reduce((record, annotation) => {
|
|
204
269
|
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
205
270
|
}, {});
|
|
@@ -222,9 +287,9 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
222
287
|
apply(action) {
|
|
223
288
|
this.doApply(action);
|
|
224
289
|
if (action.isFlushable) {
|
|
225
|
-
const domNode =
|
|
290
|
+
const domNode = nodeAnnotation_abstract.stateEntityRenderingRegistry.getDOMByEntity(this);
|
|
226
291
|
if (domNode) {
|
|
227
|
-
const nodeSubject =
|
|
292
|
+
const nodeSubject = domNodeSubjectFactory.domNodeSubjectFactory.getSubjectFromParentNodeByEventId(domNode, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges);
|
|
228
293
|
if (nodeSubject) {
|
|
229
294
|
changeManager.ChangeManager.notify(nodeSubject, {});
|
|
230
295
|
}
|
|
@@ -237,7 +302,7 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
237
302
|
* @param {AnnotationAction|ModifyContentAction} action - Annotation action
|
|
238
303
|
*/
|
|
239
304
|
doApply(action) {
|
|
240
|
-
if (action instanceof
|
|
305
|
+
if (action instanceof nodeAnnotation_abstract.ModifyContentAction) {
|
|
241
306
|
this.doModifyActionApply(action);
|
|
242
307
|
}
|
|
243
308
|
else {
|
|
@@ -254,29 +319,6 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
254
319
|
this.annotationMap.set(annotation.type, annotation);
|
|
255
320
|
typeof this.doAnnotationActionApply === 'function' && this.doAnnotationActionApply(action);
|
|
256
321
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Get styles from annotations
|
|
259
|
-
*
|
|
260
|
-
* @returns {AnnotationStyle} - Annotation style
|
|
261
|
-
*/
|
|
262
|
-
getStyles() {
|
|
263
|
-
return Array.from(this.annotationMap.values())
|
|
264
|
-
.filter((annotation) => annotation instanceof blockAnnotation_abstract.BlockAnnotation)
|
|
265
|
-
.map((annotation) => annotation.render())
|
|
266
|
-
.filter(typeGuard.isNonNullable)
|
|
267
|
-
.reduce((current, obj) => (Object.assign(Object.assign({}, current), obj)), {});
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Get classes from annotations
|
|
271
|
-
*
|
|
272
|
-
* @returns {AnnotationStyle} - Annotation style
|
|
273
|
-
*/
|
|
274
|
-
getClasses() {
|
|
275
|
-
return Array.from(this.annotationMap.values())
|
|
276
|
-
.map((annotation) => { var _a; return (_a = annotation.renderClass) === null || _a === void 0 ? void 0 : _a.call(annotation); })
|
|
277
|
-
.filter(typeGuard.isNonNullable)
|
|
278
|
-
.reduce((pre, cur) => [pre, cur].join(' '), '');
|
|
279
|
-
}
|
|
280
322
|
/**
|
|
281
323
|
* Appends a list of RTENode objects to the current node's child nodes and sets the parent block of each node to the current node.
|
|
282
324
|
*
|
|
@@ -297,7 +339,7 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
297
339
|
if (this.type === secondBlock.type || (this.type !== 'image' && secondBlock.type !== 'image')) {
|
|
298
340
|
let shouldMergeNodes = secondBlock['nodes'];
|
|
299
341
|
if (this.type !== 'image') {
|
|
300
|
-
shouldMergeNodes = secondBlock['nodes'].filter((node) => node['text'] && node['text'] !==
|
|
342
|
+
shouldMergeNodes = secondBlock['nodes'].filter((node) => node['text'] && node['text'] !== ZERO_WIDTH_SPACE);
|
|
301
343
|
}
|
|
302
344
|
this.apply(new AppendChildNodesAction(shouldMergeNodes));
|
|
303
345
|
secondBlock.parent.apply(new RemoveChildAction(secondBlock));
|
|
@@ -490,10 +532,10 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
490
532
|
/**
|
|
491
533
|
* Annotation for image
|
|
492
534
|
*/
|
|
493
|
-
class ImageAnnotation extends
|
|
535
|
+
class ImageAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
494
536
|
constructor(size = 'md', alt) {
|
|
495
537
|
super();
|
|
496
|
-
this.type =
|
|
538
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.IMAGE;
|
|
497
539
|
this.size = size;
|
|
498
540
|
this.alt = alt;
|
|
499
541
|
}
|
|
@@ -505,7 +547,7 @@ class ImageAnnotation extends node_abstract.NodeAnnotation {
|
|
|
505
547
|
* @returns {[NodeAnnotationTypeEnum.IMAGE, ImageAnnotation]} Map item for the annotation
|
|
506
548
|
*/
|
|
507
549
|
static from(size, alt) {
|
|
508
|
-
return [
|
|
550
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.IMAGE, new ImageAnnotation(size, alt)];
|
|
509
551
|
}
|
|
510
552
|
/**
|
|
511
553
|
* Generate the JSON representation of the annotation
|
|
@@ -543,48 +585,41 @@ class ImageAnnotation extends node_abstract.NodeAnnotation {
|
|
|
543
585
|
}
|
|
544
586
|
|
|
545
587
|
/**
|
|
546
|
-
*
|
|
588
|
+
* Image node
|
|
547
589
|
*/
|
|
548
|
-
class
|
|
549
|
-
constructor(size, alt) {
|
|
550
|
-
super();
|
|
551
|
-
this.isFlushable = true;
|
|
552
|
-
this.size = size;
|
|
553
|
-
this.alt = alt;
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Converts the action to an annotation
|
|
557
|
-
*
|
|
558
|
-
* @returns {ImageAnnotation} The annotation
|
|
559
|
-
*/
|
|
560
|
-
toAnnotation() {
|
|
561
|
-
return new ImageAnnotation(this.size, this.alt);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
class RTEImageNode extends node_abstract.RTENode {
|
|
590
|
+
class RTEImageNode extends nodeAnnotation_abstract.RTENode {
|
|
566
591
|
constructor(id, url, parentBlock, annotationMap) {
|
|
567
592
|
super(id, annotationMap);
|
|
568
|
-
this.type =
|
|
593
|
+
this.type = nodeAnnotation_abstract.NodeTypeEnum.IMAGE;
|
|
569
594
|
this.url = url;
|
|
570
595
|
this.parentBlock = parentBlock;
|
|
571
596
|
}
|
|
572
|
-
|
|
573
|
-
|
|
597
|
+
/**
|
|
598
|
+
* Converts a VegaRTEImageNode into an RTEImageNode by mapping nodes and creating annotations.
|
|
599
|
+
*
|
|
600
|
+
* @param {VegaRTEImageNode} node - The node to be converted.
|
|
601
|
+
* @param {RTEImageBlock} parentBlock - The parent block
|
|
602
|
+
* @returns {RTEImageBlock} An instance of `RTEImageBlock`
|
|
603
|
+
*/
|
|
604
|
+
static from(node, parentBlock) {
|
|
605
|
+
const imageNode = new RTEImageNode(node.id, node.url, parentBlock);
|
|
574
606
|
let annotations;
|
|
575
|
-
if (!
|
|
607
|
+
if (!node.annotations || Object.keys(node.annotations).length === 0) {
|
|
576
608
|
annotations = { size: 'md' };
|
|
577
609
|
}
|
|
578
610
|
else {
|
|
579
|
-
annotations =
|
|
611
|
+
annotations = node.annotations;
|
|
580
612
|
}
|
|
581
613
|
imageNode.annotationMap = new Map(Object.keys(annotations)
|
|
582
614
|
.map(() => ImageAnnotation.from(annotations.size, annotations.alt))
|
|
583
615
|
.filter(typeGuard.isNonNullable));
|
|
584
616
|
return imageNode;
|
|
585
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* @inheritDoc
|
|
620
|
+
*/
|
|
586
621
|
toJSON() {
|
|
587
|
-
const imageAnnotation = this.annotationMap.get(
|
|
622
|
+
const imageAnnotation = this.annotationMap.get(nodeAnnotation_abstract.NodeAnnotationTypeEnum.IMAGE);
|
|
588
623
|
const annotations = {};
|
|
589
624
|
if (imageAnnotation === null || imageAnnotation === void 0 ? void 0 : imageAnnotation.size) {
|
|
590
625
|
annotations.size = imageAnnotation.size;
|
|
@@ -594,55 +629,20 @@ class RTEImageNode extends node_abstract.RTENode {
|
|
|
594
629
|
}
|
|
595
630
|
return Object.assign(Object.assign({ id: this.id }, (Object.keys(annotations).length > 0 ? { annotations } : {})), { type: 'image', url: this.url });
|
|
596
631
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
const alt = imageAnnotation === null || imageAnnotation === void 0 ? void 0 : imageAnnotation.alt;
|
|
601
|
-
const handleChange = ({ detail, }) => {
|
|
602
|
-
switch (detail.action) {
|
|
603
|
-
case 'edit': {
|
|
604
|
-
const size = detail.payload.size;
|
|
605
|
-
const alt = detail.payload.alt;
|
|
606
|
-
this.apply(new ImageAnnotationAction(size, alt));
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
/*
|
|
610
|
-
* The below method is e2e-test covered in
|
|
611
|
-
* @see{module:vega-rich-text-editor-image-click-delete-button}
|
|
612
|
-
*/
|
|
613
|
-
/* istanbul ignore next */
|
|
614
|
-
case 'delete': {
|
|
615
|
-
const event = new InputEvent('beforeinput', {
|
|
616
|
-
inputType: 'deleteContentBackward',
|
|
617
|
-
bubbles: true,
|
|
618
|
-
});
|
|
619
|
-
setTimeout(() => {
|
|
620
|
-
node_abstract.stateEntityRenderingRegistry.getDOMByEntity(this).dispatchEvent(event);
|
|
621
|
-
}, 50);
|
|
622
|
-
break;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
return editable ? (globalSlimmerRegistry.h("vega-rich-text-image-editor", { style: this.getStyles(), size: size, alt: alt, ref: (ref) => {
|
|
627
|
-
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, domNodeSubjectObserverFactory.VegaChange, handleChange);
|
|
628
|
-
} }, this.renderImage(editable, alt))) : (this.renderImage(editable, alt));
|
|
629
|
-
}
|
|
632
|
+
/**
|
|
633
|
+
* @inheritDoc
|
|
634
|
+
*/
|
|
630
635
|
doAnnotationActionApply(action) {
|
|
631
636
|
const annotation = action.toAnnotation();
|
|
632
637
|
this.annotationMap.set(annotation.type, annotation);
|
|
633
638
|
}
|
|
634
639
|
// placeholder method
|
|
635
640
|
/* istanbul ignore next */
|
|
641
|
+
/**
|
|
642
|
+
* @inheritDoc
|
|
643
|
+
*/
|
|
636
644
|
doModifyActionApply(action) {
|
|
637
645
|
}
|
|
638
|
-
registerRef(ref) {
|
|
639
|
-
if (ref) {
|
|
640
|
-
node_abstract.stateEntityRenderingRegistry.register(ref, this);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
renderImage(editable, alt) {
|
|
644
|
-
return (globalSlimmerRegistry.h("img", { style: editable ? { width: '100%' } : this.getStyles(), alt: alt, src: this.url, ref: this.registerRef.bind(this) }));
|
|
645
|
-
}
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
/**
|
|
@@ -650,10 +650,10 @@ class RTEImageNode extends node_abstract.RTENode {
|
|
|
650
650
|
*
|
|
651
651
|
* @example block.apply(new ReplaceChildNodesAction(newNodes))
|
|
652
652
|
*/
|
|
653
|
-
class ReplaceChildNodesAction extends
|
|
653
|
+
class ReplaceChildNodesAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
654
654
|
constructor(newChildNodes) {
|
|
655
655
|
super();
|
|
656
|
-
this.type =
|
|
656
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES;
|
|
657
657
|
this.newChildNodes = newChildNodes;
|
|
658
658
|
}
|
|
659
659
|
}
|
|
@@ -663,37 +663,862 @@ class ReplaceChildNodesAction extends node_abstract.ModifyContentAction {
|
|
|
663
663
|
*
|
|
664
664
|
* @example currentBlock.parent.apply(new InsertBlocksAfterAction(currentBlock, newBlock, ...))
|
|
665
665
|
*/
|
|
666
|
-
class InsertBlocksAfterAction extends
|
|
666
|
+
class InsertBlocksAfterAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
667
667
|
constructor(referBlock, ...blocksToBeInserted) {
|
|
668
668
|
super();
|
|
669
|
-
this.type =
|
|
669
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_AFTER;
|
|
670
670
|
this.referBlock = referBlock;
|
|
671
671
|
this.blocksToBeInserted = blocksToBeInserted;
|
|
672
672
|
}
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* Split the block with a split point node.
|
|
677
|
-
* The property `newBlock` use to store the new create block if need.
|
|
678
|
-
*
|
|
679
|
-
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
680
|
-
*/
|
|
681
|
-
class SplitBlockWithNodeAction extends
|
|
682
|
-
constructor(splitPointNode, startOffsetOfNode) {
|
|
683
|
-
super();
|
|
684
|
-
this.type =
|
|
685
|
-
this.splitPointNode = splitPointNode;
|
|
686
|
-
this.startOffsetOfNode = startOffsetOfNode;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Split the block with a split point node.
|
|
677
|
+
* The property `newBlock` use to store the new create block if need.
|
|
678
|
+
*
|
|
679
|
+
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
680
|
+
*/
|
|
681
|
+
class SplitBlockWithNodeAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
682
|
+
constructor(splitPointNode, startOffsetOfNode) {
|
|
683
|
+
super();
|
|
684
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE;
|
|
685
|
+
this.splitPointNode = splitPointNode;
|
|
686
|
+
this.startOffsetOfNode = startOffsetOfNode;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Abstract class for annotation actions
|
|
692
|
+
*/
|
|
693
|
+
class AnnotationAction {
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Abstract class for which can be splittable
|
|
698
|
+
*/
|
|
699
|
+
class TextSplittableAction extends AnnotationAction {
|
|
700
|
+
constructor() {
|
|
701
|
+
super(...arguments);
|
|
702
|
+
/**
|
|
703
|
+
* Whether the action should split the node
|
|
704
|
+
*/
|
|
705
|
+
this.doSplit = true;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Annotation to represent a selection range
|
|
711
|
+
*/
|
|
712
|
+
class SelectionRangeAnnotation extends nodeAnnotation_abstract.Annotation {
|
|
713
|
+
constructor(range) {
|
|
714
|
+
super();
|
|
715
|
+
this.type = nodeAnnotation_abstract.InternalAnnotationTypeEnum.SELECTION_RANGE;
|
|
716
|
+
this.range = range;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Annotation to make text with strikethrough
|
|
722
|
+
*/
|
|
723
|
+
class StrikethroughAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
724
|
+
constructor(underline) {
|
|
725
|
+
super();
|
|
726
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.STRIKETHROUGH;
|
|
727
|
+
this.strikethrough = underline;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Generate the map item for the annotation
|
|
731
|
+
*
|
|
732
|
+
* @param {Nullable<boolean>} strikethrough - Strikethrough annotation
|
|
733
|
+
* @returns {[NodeAnnotationTypeEnum.STRIKETHROUGH, StrikethroughAnnotation]} Map item for the annotation
|
|
734
|
+
*/
|
|
735
|
+
static from(strikethrough) {
|
|
736
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.STRIKETHROUGH, new StrikethroughAnnotation(strikethrough)];
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Generate the JSON representation of the annotation
|
|
740
|
+
*
|
|
741
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
742
|
+
*/
|
|
743
|
+
toJSON() {
|
|
744
|
+
return {
|
|
745
|
+
strikethrough: this.strikethrough,
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Generate the class for the annotation
|
|
750
|
+
*
|
|
751
|
+
* @returns {Nullable<string>} - Annotation class
|
|
752
|
+
*/
|
|
753
|
+
renderClass() {
|
|
754
|
+
return this.strikethrough ? 'v-rte--strikethrough' : null;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Generate the style for the annotation
|
|
758
|
+
*
|
|
759
|
+
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
760
|
+
*/
|
|
761
|
+
render() {
|
|
762
|
+
return null;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Annotation to make text with underline
|
|
768
|
+
*/
|
|
769
|
+
class UnderlineAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
770
|
+
constructor(underline) {
|
|
771
|
+
super();
|
|
772
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.UNDERLINE;
|
|
773
|
+
this.underline = underline;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Generate the map item for the annotation
|
|
777
|
+
*
|
|
778
|
+
* @param {boolean} underline - Underline annotation
|
|
779
|
+
* @returns {[NodeAnnotationTypeEnum.UNDERLINE, UnderlineAnnotation]} Map item for the annotation
|
|
780
|
+
*/
|
|
781
|
+
static from(underline) {
|
|
782
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.UNDERLINE, new UnderlineAnnotation(underline)];
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Generate the JSON representation of the annotation
|
|
786
|
+
*
|
|
787
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
788
|
+
*/
|
|
789
|
+
toJSON() {
|
|
790
|
+
return {
|
|
791
|
+
underline: this.underline,
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Generate the class for the annotation
|
|
796
|
+
*
|
|
797
|
+
* @returns {Nullable<string>} - Annotation class
|
|
798
|
+
*/
|
|
799
|
+
renderClass() {
|
|
800
|
+
return this.underline ? 'v-rte--underline' : null;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Generate the style for the annotation
|
|
804
|
+
*
|
|
805
|
+
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
806
|
+
*/
|
|
807
|
+
render() {
|
|
808
|
+
return null;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Annotation to make text Italic
|
|
814
|
+
*/
|
|
815
|
+
class ItalicAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
816
|
+
constructor(italic) {
|
|
817
|
+
super();
|
|
818
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.ITALIC;
|
|
819
|
+
this.italic = italic;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Generate the map item for the annotation
|
|
823
|
+
*
|
|
824
|
+
* @param {boolean} italic - Italic annotation
|
|
825
|
+
* @returns {Nullable<[NodeAnnotationTypeEnum.ITALIC, ItalicAnnotation]>} Map item for the annotation
|
|
826
|
+
*/
|
|
827
|
+
static from(italic) {
|
|
828
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.ITALIC, new ItalicAnnotation(italic)];
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Generate the JSON representation of the annotation
|
|
832
|
+
*
|
|
833
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
834
|
+
*/
|
|
835
|
+
toJSON() {
|
|
836
|
+
return {
|
|
837
|
+
italic: this.italic,
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Generate the style for the annotation
|
|
842
|
+
*
|
|
843
|
+
* @returns {Nullable<AnnotationStyle>} Italic style
|
|
844
|
+
*/
|
|
845
|
+
render() {
|
|
846
|
+
return this.italic ? { 'font-style': 'italic' } : null;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Annotation to make text bold
|
|
852
|
+
*/
|
|
853
|
+
class BoldAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
854
|
+
constructor(bold) {
|
|
855
|
+
super();
|
|
856
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.BOLD;
|
|
857
|
+
this.bold = bold;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Generate the map item for the annotation
|
|
861
|
+
*
|
|
862
|
+
* @param {boolean} bold - Bold annotation
|
|
863
|
+
* @returns {[NodeAnnotationTypeEnum.BOLD, BoldAnnotation]} Map item for the annotation
|
|
864
|
+
*/
|
|
865
|
+
static from(bold) {
|
|
866
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.BOLD, new BoldAnnotation(bold)];
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Generate the JSON representation of the annotation
|
|
870
|
+
*
|
|
871
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
872
|
+
*/
|
|
873
|
+
toJSON() {
|
|
874
|
+
return {
|
|
875
|
+
bold: this.bold,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Generate the style for the annotation
|
|
880
|
+
*
|
|
881
|
+
* @returns {Nullable<AnnotationStyle>} Bold style
|
|
882
|
+
*/
|
|
883
|
+
render() {
|
|
884
|
+
return this.bold ? { 'font-weight': '700' } : null;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Annotation to host which annotations will be clear formatting
|
|
890
|
+
*/
|
|
891
|
+
class ClearFormattingAnnotation extends nodeAnnotation_abstract.Annotation {
|
|
892
|
+
constructor() {
|
|
893
|
+
super(...arguments);
|
|
894
|
+
this.type = nodeAnnotation_abstract.InternalAnnotationTypeEnum.CLEAR_FORMATTING;
|
|
895
|
+
this.items = [
|
|
896
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.BOLD,
|
|
897
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.ITALIC,
|
|
898
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.UNDERLINE,
|
|
899
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.STRIKETHROUGH,
|
|
900
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.TEXT_COLOR,
|
|
901
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.CODE,
|
|
902
|
+
];
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Annotation to make text code
|
|
908
|
+
*/
|
|
909
|
+
class CodeAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
910
|
+
constructor(code) {
|
|
911
|
+
super();
|
|
912
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.CODE;
|
|
913
|
+
this.code = code;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Generate the map item for the annotation
|
|
917
|
+
*
|
|
918
|
+
* @param {boolean} code - Bold annotation
|
|
919
|
+
* @returns {[NodeAnnotationTypeEnum.CODE, CodeAnnotation]} Map item for the annotation
|
|
920
|
+
*/
|
|
921
|
+
static from(code) {
|
|
922
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.CODE, new CodeAnnotation(code)];
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Generate the JSON representation of the annotation
|
|
926
|
+
*
|
|
927
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
928
|
+
*/
|
|
929
|
+
toJSON() {
|
|
930
|
+
return {
|
|
931
|
+
code: this.code,
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Generate the class for the annotation
|
|
936
|
+
*
|
|
937
|
+
* @returns {Nullable<string>} - Annotation class
|
|
938
|
+
*/
|
|
939
|
+
renderClass() {
|
|
940
|
+
return this.code ? 'v-rte--code' : null;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Generate the style for the annotation
|
|
944
|
+
*
|
|
945
|
+
* @returns {Nullable<AnnotationStyle>} Bold style
|
|
946
|
+
*/
|
|
947
|
+
render() {
|
|
948
|
+
return null;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Annotation to make text with text color
|
|
954
|
+
*/
|
|
955
|
+
class TextColorAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
956
|
+
constructor(textColor) {
|
|
957
|
+
super();
|
|
958
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.TEXT_COLOR;
|
|
959
|
+
this.textColor = this.formatTextColor(textColor);
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Generate the map item for the annotation
|
|
963
|
+
*
|
|
964
|
+
* @param {string} textColor - text color annotation
|
|
965
|
+
* @returns {[NodeAnnotationTypeEnum.TEXT_COLOR, TextColorAnnotation]} Map item for the annotation
|
|
966
|
+
*/
|
|
967
|
+
static from(textColor) {
|
|
968
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.TEXT_COLOR, new TextColorAnnotation(textColor)];
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Generate the JSON representation of the annotation
|
|
972
|
+
*
|
|
973
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
974
|
+
*/
|
|
975
|
+
toJSON() {
|
|
976
|
+
return {
|
|
977
|
+
textColor: this.textColor.key,
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Generate the class for the annotation
|
|
982
|
+
*
|
|
983
|
+
* @returns {Nullable<string>} - Annotation class
|
|
984
|
+
*/
|
|
985
|
+
renderClass() {
|
|
986
|
+
return null;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Generate the style for the annotation
|
|
990
|
+
*
|
|
991
|
+
* @returns {Nullable<AnnotationStyle>} - Annotation style
|
|
992
|
+
*/
|
|
993
|
+
render() {
|
|
994
|
+
return {
|
|
995
|
+
color: nodeAnnotation_abstract.VegaThemeManager.isDarkMode() ? this.textColor.dark : this.textColor.light,
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* format text color
|
|
1000
|
+
*
|
|
1001
|
+
* @param {string} textColor - text color
|
|
1002
|
+
* @returns {VegaRTEColorSchema} - VegaRTEColorSchema
|
|
1003
|
+
*/
|
|
1004
|
+
formatTextColor(textColor) {
|
|
1005
|
+
return (RTE_TEXT_COLORS.find((item) => item.key === textColor) || RTE_TEXT_COLORS[0]);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Annotation to make text a link
|
|
1011
|
+
*/
|
|
1012
|
+
class LinkAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
1013
|
+
constructor(link) {
|
|
1014
|
+
super();
|
|
1015
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK;
|
|
1016
|
+
this.link = link;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Generate the map item for the annotation
|
|
1020
|
+
*
|
|
1021
|
+
* @param {VegaRTELink} link - Bold annotation
|
|
1022
|
+
* @returns {[NodeAnnotationTypeEnum.LINK, LinkAnnotation]} Map item for the annotation
|
|
1023
|
+
*/
|
|
1024
|
+
static from(link) {
|
|
1025
|
+
return [
|
|
1026
|
+
nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK,
|
|
1027
|
+
new LinkAnnotation({ href: link.href, groupKey: link.groupKey }),
|
|
1028
|
+
];
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Generate the JSON representation of the annotation
|
|
1032
|
+
*
|
|
1033
|
+
* @returns {Record<string, unknown>} JSON representation of the annotation
|
|
1034
|
+
*/
|
|
1035
|
+
toJSON() {
|
|
1036
|
+
return { link: { href: this.link.href, groupKey: this.link.groupKey } };
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Verify whether two link annotation is same or not
|
|
1040
|
+
*
|
|
1041
|
+
* @param {LinkAnnotation} annotation - Compared annotation
|
|
1042
|
+
* @returns {boolean} Whether two link annotation is same or not
|
|
1043
|
+
*/
|
|
1044
|
+
toEqual(annotation) {
|
|
1045
|
+
return this.link.groupKey === annotation.link.groupKey;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Generate the style for the annotation
|
|
1049
|
+
*
|
|
1050
|
+
* @returns {Nullable<AnnotationStyle>} Link style
|
|
1051
|
+
*/
|
|
1052
|
+
render() {
|
|
1053
|
+
return null;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Action to toggle link annotation
|
|
1059
|
+
*/
|
|
1060
|
+
class LinkAnnotationAction extends TextSplittableAction {
|
|
1061
|
+
constructor({ link, newText, needMergeNode, doSplit, }) {
|
|
1062
|
+
super();
|
|
1063
|
+
this.isFlushable = true;
|
|
1064
|
+
this.link = link;
|
|
1065
|
+
this.needMergeNode = needMergeNode;
|
|
1066
|
+
this.newText = newText;
|
|
1067
|
+
if (typeGuard.isNonNullable(doSplit)) {
|
|
1068
|
+
this.doSplit = doSplit;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Converts the action to an annotation
|
|
1073
|
+
*
|
|
1074
|
+
* @returns {LinkAnnotation} the annotation
|
|
1075
|
+
*/
|
|
1076
|
+
toAnnotation() {
|
|
1077
|
+
return new LinkAnnotation(this.link);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Action to toggle code annotation
|
|
1083
|
+
*/
|
|
1084
|
+
class CodeAnnotationAction extends TextSplittableAction {
|
|
1085
|
+
constructor(code) {
|
|
1086
|
+
super();
|
|
1087
|
+
this.isFlushable = true;
|
|
1088
|
+
this.code = code;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Converts the action to an annotation
|
|
1092
|
+
*
|
|
1093
|
+
* @returns {CodeAnnotation} the annotation
|
|
1094
|
+
*/
|
|
1095
|
+
toAnnotation() {
|
|
1096
|
+
return new CodeAnnotation(this.code);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Action to toggle clear formatting
|
|
1102
|
+
*/
|
|
1103
|
+
class ClearFormattingAnnotationAction extends TextSplittableAction {
|
|
1104
|
+
constructor() {
|
|
1105
|
+
super(...arguments);
|
|
1106
|
+
this.isFlushable = true;
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Converts the action to an annotation
|
|
1110
|
+
*
|
|
1111
|
+
* @returns {ClearFormattingAnnotation} the annotation
|
|
1112
|
+
*/
|
|
1113
|
+
toAnnotation() {
|
|
1114
|
+
return new ClearFormattingAnnotation();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Update the text node property text action
|
|
1120
|
+
*
|
|
1121
|
+
* @example textNode.apply(new UpdateTextAction(newText))
|
|
1122
|
+
*/
|
|
1123
|
+
class UpdateTextAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
1124
|
+
constructor(text) {
|
|
1125
|
+
super();
|
|
1126
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.UPDATE_TEXT;
|
|
1127
|
+
this.newTextContent = '';
|
|
1128
|
+
this.newTextContent = text;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Annotation to represent a link of grouped nodes
|
|
1134
|
+
*/
|
|
1135
|
+
class LinkGroupAnnotation extends nodeAnnotation_abstract.Annotation {
|
|
1136
|
+
constructor(groupKey) {
|
|
1137
|
+
super();
|
|
1138
|
+
this.type = nodeAnnotation_abstract.InternalAnnotationTypeEnum.LINK_GROUP;
|
|
1139
|
+
this.linkGroups = new Map();
|
|
1140
|
+
this.linkGroups = new Map([[groupKey, []]]);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Action to link a group of nodes
|
|
1146
|
+
*/
|
|
1147
|
+
class LinkGroupAnnotationAction extends AnnotationAction {
|
|
1148
|
+
constructor(groupKey, nodes) {
|
|
1149
|
+
super();
|
|
1150
|
+
this.isFlushable = false;
|
|
1151
|
+
this.groupKey = groupKey;
|
|
1152
|
+
this.nodes = nodes;
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Converts the action to an annotation
|
|
1156
|
+
*
|
|
1157
|
+
* @returns {LinkGroupAnnotation} The annotation
|
|
1158
|
+
*/
|
|
1159
|
+
toAnnotation() {
|
|
1160
|
+
return new LinkGroupAnnotation(this.groupKey);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* Sync up selection action
|
|
1166
|
+
*/
|
|
1167
|
+
class SyncUpSelectionAction extends AnnotationAction {
|
|
1168
|
+
constructor() {
|
|
1169
|
+
super();
|
|
1170
|
+
this.isFlushable = false;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* annotation null
|
|
1174
|
+
*
|
|
1175
|
+
* @returns {Nullable<Annotation>} null
|
|
1176
|
+
*/
|
|
1177
|
+
toAnnotation() {
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Delete the node annotation by type
|
|
1184
|
+
*/
|
|
1185
|
+
class DeleteNodeAnnotationAction extends AnnotationAction {
|
|
1186
|
+
constructor(annotationType) {
|
|
1187
|
+
super();
|
|
1188
|
+
this.isFlushable = true;
|
|
1189
|
+
this.annotationType = annotationType;
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Don't need this for this action
|
|
1193
|
+
*
|
|
1194
|
+
* @returns {Nullable<Annotation>} undefined
|
|
1195
|
+
*/
|
|
1196
|
+
toAnnotation() {
|
|
1197
|
+
return undefined;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Text node
|
|
1203
|
+
*/
|
|
1204
|
+
class RTETextNode extends nodeAnnotation_abstract.RTENode {
|
|
1205
|
+
constructor(id, text, parentBlock, annotationMap) {
|
|
1206
|
+
super(id, annotationMap);
|
|
1207
|
+
this.type = nodeAnnotation_abstract.NodeTypeEnum.TEXT;
|
|
1208
|
+
this.parentBlock = parentBlock;
|
|
1209
|
+
this.text = text;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Creates an RTETextNode from a VegaRTETextNode with annotations and a parent RTETextBlock.
|
|
1213
|
+
*
|
|
1214
|
+
* @param {VegaRTETextNode} richText - A rich text node
|
|
1215
|
+
* @param {RTETextBlock} parentBlock - Parent block
|
|
1216
|
+
* @returns {RTETextNode} an RTETextNode
|
|
1217
|
+
*/
|
|
1218
|
+
static from(richText, parentBlock) {
|
|
1219
|
+
const textNode = new RTETextNode(richText.id, richText.text, parentBlock);
|
|
1220
|
+
const { annotations } = richText;
|
|
1221
|
+
if (annotations) {
|
|
1222
|
+
textNode.annotationMap = new Map(Object.keys(annotations)
|
|
1223
|
+
.map((type) => {
|
|
1224
|
+
if (annotations.link) {
|
|
1225
|
+
parentBlock.apply(new LinkGroupAnnotationAction(annotations.link.groupKey, [textNode]));
|
|
1226
|
+
}
|
|
1227
|
+
return this.createAnnotationEntity(type, annotations[type]);
|
|
1228
|
+
})
|
|
1229
|
+
.filter(typeGuard.isNonNullable));
|
|
1230
|
+
}
|
|
1231
|
+
return textNode;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Creates different types of text annotations based on the provided type and value.
|
|
1235
|
+
*
|
|
1236
|
+
* @param {keyof VegaRTETextAnnotations} type - The key of the type.
|
|
1237
|
+
* @param {unknown} value - The value that will be used to create the specific type of annotation entity based on the `type` provided.
|
|
1238
|
+
* @returns {Nullable<[RTENodeAnnotationMapKey, RTENodeAnnotationMapValue]>} Returning a nullable tuple containing a key and a
|
|
1239
|
+
* value from the `RTENodeAnnotationMapKey` and `RTENodeAnnotationMapValue` types.
|
|
1240
|
+
*/
|
|
1241
|
+
static createAnnotationEntity(type, value) {
|
|
1242
|
+
switch (type) {
|
|
1243
|
+
case 'bold':
|
|
1244
|
+
return BoldAnnotation.from(value);
|
|
1245
|
+
case 'italic':
|
|
1246
|
+
return ItalicAnnotation.from(value);
|
|
1247
|
+
case 'underline':
|
|
1248
|
+
return UnderlineAnnotation.from(value);
|
|
1249
|
+
case 'strikethrough':
|
|
1250
|
+
return StrikethroughAnnotation.from(value);
|
|
1251
|
+
case 'code':
|
|
1252
|
+
return CodeAnnotation.from(value);
|
|
1253
|
+
case 'textColor':
|
|
1254
|
+
return TextColorAnnotation.from(value);
|
|
1255
|
+
case 'link':
|
|
1256
|
+
return LinkAnnotation.from(value);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* @inheritDoc
|
|
1261
|
+
*/
|
|
1262
|
+
toJSON() {
|
|
1263
|
+
const annotations = Array.from(this.annotationMap.values())
|
|
1264
|
+
.filter((annotation) => annotation instanceof nodeAnnotation_abstract.NodeAnnotation)
|
|
1265
|
+
.reduce((record, annotation) => {
|
|
1266
|
+
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
1267
|
+
}, {});
|
|
1268
|
+
return Object.assign(Object.assign({ id: this.id }, (Object.keys(annotations).length > 0 ? { annotations } : {})), { type: 'text', text: this.text });
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Creates a new RTETextNode with the specified text and copies the parent block and annotation map from the original node.
|
|
1272
|
+
*
|
|
1273
|
+
* @param {string} text - The text content of the RTETextNode that will be created.
|
|
1274
|
+
* @returns {RTETextNode} An new RTETextNode
|
|
1275
|
+
*/
|
|
1276
|
+
cloneWithText(text) {
|
|
1277
|
+
return new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), text, this.parentBlock, new Map(this.annotationMap));
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Checks if a node is empty
|
|
1281
|
+
*
|
|
1282
|
+
* @returns {boolean} It returns `true` if the node is empty
|
|
1283
|
+
*/
|
|
1284
|
+
isEmpty() {
|
|
1285
|
+
return !this.text || this.text === ZERO_WIDTH_SPACE || this.text === '\n';
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* @inheritDoc
|
|
1289
|
+
*/
|
|
1290
|
+
doAnnotationActionApply(action) {
|
|
1291
|
+
const selectionRangeAnnotation = this.getAnnotationByType(nodeAnnotation_abstract.InternalAnnotationTypeEnum.SELECTION_RANGE);
|
|
1292
|
+
if (action instanceof TextSplittableAction && action.doSplit && selectionRangeAnnotation) {
|
|
1293
|
+
const { startContainer, endContainer, startOffset, endOffset } = selectionRangeAnnotation.range;
|
|
1294
|
+
const noTextRangeSelected = startContainer === endContainer && startOffset === endOffset;
|
|
1295
|
+
this.parentBlock.nodes = this.parentBlock.nodes.flatMap((item) => {
|
|
1296
|
+
if (item.id === this.id) {
|
|
1297
|
+
if (noTextRangeSelected) {
|
|
1298
|
+
return this.insertNewNode(startOffset, action);
|
|
1299
|
+
}
|
|
1300
|
+
if (this.shouldSplitSelection(selectionRangeAnnotation.range)) {
|
|
1301
|
+
return this.splitTextNode(action, selectionRangeAnnotation.range);
|
|
1302
|
+
}
|
|
1303
|
+
else {
|
|
1304
|
+
this.applyActionToNode(this, action);
|
|
1305
|
+
return this;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
return item;
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
this.applyActionToNode(this, action);
|
|
1313
|
+
}
|
|
1314
|
+
this.parentBlock.mergeNodes(action);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* @inheritDoc
|
|
1318
|
+
*/
|
|
1319
|
+
doModifyActionApply(action) {
|
|
1320
|
+
switch (action.type) {
|
|
1321
|
+
case nodeAnnotation_abstract.ModifyContentActionType.UPDATE_TEXT:
|
|
1322
|
+
this.updateText(action.newTextContent);
|
|
1323
|
+
break;
|
|
1324
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_SELECTED_TEXT:
|
|
1325
|
+
this.replaceSelectedText(action.textToBeInsert, action.currentRange);
|
|
1326
|
+
break;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Split text node with range
|
|
1331
|
+
*
|
|
1332
|
+
* @param {TextSplittableAction} action - Annotation action
|
|
1333
|
+
* @param {Range} range - Selection range
|
|
1334
|
+
* @returns {RTETextNode[] | this} RTETextNode array
|
|
1335
|
+
*/
|
|
1336
|
+
splitTextNode(action, range) {
|
|
1337
|
+
const { startContainer, endContainer, startOffset } = range;
|
|
1338
|
+
const startNode = startContainer.parentElement;
|
|
1339
|
+
const endNode = endContainer.parentElement;
|
|
1340
|
+
/**
|
|
1341
|
+
* Split the text from the start offset to the end offset
|
|
1342
|
+
*
|
|
1343
|
+
* @param {string} text - The text string
|
|
1344
|
+
* @param {number} startOffset - The start offset position
|
|
1345
|
+
* @param {number} endOffset - The end offset position
|
|
1346
|
+
* @returns {RTETextNode[]} - The split text node array
|
|
1347
|
+
*/
|
|
1348
|
+
const splitText = (text, startOffset, endOffset) => {
|
|
1349
|
+
const beforeText = text.substring(0, startOffset);
|
|
1350
|
+
const selectedText = text.substring(startOffset, endOffset);
|
|
1351
|
+
const afterText = text.substring(endOffset);
|
|
1352
|
+
return [
|
|
1353
|
+
this.cloneWithText(beforeText),
|
|
1354
|
+
this.cloneWithText(selectedText),
|
|
1355
|
+
this.cloneWithText(afterText),
|
|
1356
|
+
];
|
|
1357
|
+
};
|
|
1358
|
+
const startItemDto = startNode && nodeAnnotation_abstract.stateEntityRenderingRegistry.getEntityByDOM(startNode);
|
|
1359
|
+
const endItemDto = endNode && nodeAnnotation_abstract.stateEntityRenderingRegistry.getEntityByDOM(endNode);
|
|
1360
|
+
if (startItemDto && startItemDto.id === this.id) {
|
|
1361
|
+
const endOffset = startContainer === endContainer ? range.endOffset : this.text.length;
|
|
1362
|
+
const [beforeNode, selectedNode, afterNode] = splitText(this.text, startOffset, endOffset);
|
|
1363
|
+
this.applyActionToNode(selectedNode, action);
|
|
1364
|
+
return [beforeNode, selectedNode, afterNode].filter((node) => !!node.text);
|
|
1365
|
+
}
|
|
1366
|
+
else if (endItemDto && endItemDto.id === this.id) {
|
|
1367
|
+
const [beforeNode, selectedNode, afterNode] = splitText(this.text, 0, range.endOffset);
|
|
1368
|
+
this.applyActionToNode(selectedNode, action);
|
|
1369
|
+
return [beforeNode, selectedNode, afterNode].filter((node) => !!node.text);
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
this.applyActionToNode(this, action);
|
|
1373
|
+
return this;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Apply action to node
|
|
1378
|
+
*
|
|
1379
|
+
* @param {RTETextNode} node - Text node
|
|
1380
|
+
* @param {AnnotationAction} action - AnnotationAction
|
|
1381
|
+
*/
|
|
1382
|
+
applyActionToNode(node, action) {
|
|
1383
|
+
const annotation = action.toAnnotation();
|
|
1384
|
+
if (action instanceof SyncUpSelectionAction) {
|
|
1385
|
+
this.syncUpSelectedNodes(node);
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
// Sync up RTETextNode selected state to selection controller for any action apply, except selection range change.
|
|
1389
|
+
if (!(annotation instanceof SelectionRangeAnnotation)) {
|
|
1390
|
+
this.syncUpSelectedNodes(node);
|
|
1391
|
+
}
|
|
1392
|
+
if (action instanceof DeleteNodeAnnotationAction) {
|
|
1393
|
+
this.annotationMap.delete(action.annotationType);
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
if (annotation instanceof ClearFormattingAnnotation) {
|
|
1397
|
+
annotation.items.forEach((item) => {
|
|
1398
|
+
node.deleteAnnotationByType(item);
|
|
1399
|
+
});
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
if (annotation instanceof nodeAnnotation_abstract.NodeAnnotation || annotation instanceof SelectionRangeAnnotation) {
|
|
1403
|
+
if (action instanceof LinkAnnotationAction) {
|
|
1404
|
+
if (typeGuard.isNonNullable(action.newText)) {
|
|
1405
|
+
node.text = action.newText;
|
|
1406
|
+
}
|
|
1407
|
+
this.parentBlock.apply(new LinkGroupAnnotationAction(action.link.groupKey, [node]));
|
|
1408
|
+
}
|
|
1409
|
+
if (action instanceof CodeAnnotationAction) {
|
|
1410
|
+
this.applyActionToNode(node, new ClearFormattingAnnotationAction());
|
|
1411
|
+
}
|
|
1412
|
+
node.annotationMap.set(annotation.type, annotation);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Replaces the selected text within a given range with a new text in a TypeScript class.
|
|
1418
|
+
*
|
|
1419
|
+
* @param {string} text - The new text that will replace the currently selected text within the specified range.
|
|
1420
|
+
* @param {RTERange} currentRange - A range of text within a Rich Text Editor (RTE).
|
|
1421
|
+
*/
|
|
1422
|
+
replaceSelectedText(text, currentRange) {
|
|
1423
|
+
if (currentRange && currentRange.startContainer && currentRange.endContainer) {
|
|
1424
|
+
const { startContainer, endContainer, startOffset, endOffset } = currentRange;
|
|
1425
|
+
const startNode = startContainer.parentElement;
|
|
1426
|
+
const endNode = endContainer.parentElement;
|
|
1427
|
+
const startItemDto = startNode && nodeAnnotation_abstract.stateEntityRenderingRegistry.getEntityByDOM(startNode);
|
|
1428
|
+
const endItemDto = endNode && nodeAnnotation_abstract.stateEntityRenderingRegistry.getEntityByDOM(endNode);
|
|
1429
|
+
let startIndex = 0, endIndex = this.text.length;
|
|
1430
|
+
if (startItemDto && startItemDto === this) {
|
|
1431
|
+
startIndex = startOffset;
|
|
1432
|
+
endIndex = startContainer === endContainer ? endOffset : endIndex;
|
|
1433
|
+
}
|
|
1434
|
+
else if (endItemDto && endItemDto === this) {
|
|
1435
|
+
endIndex = endOffset;
|
|
1436
|
+
}
|
|
1437
|
+
this.apply(new UpdateTextAction(this.text.slice(0, startIndex) + text + this.text.slice(endIndex)));
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Updates the text content of a node and unlink the node if it is a link node and the text is deleted.
|
|
1442
|
+
*
|
|
1443
|
+
* @param {string} newText - The new text string
|
|
1444
|
+
*/
|
|
1445
|
+
updateText(newText) {
|
|
1446
|
+
this.text = newText;
|
|
1447
|
+
// The link node should unlink when delete all text
|
|
1448
|
+
if (!this.text && this.isLinkNode()) {
|
|
1449
|
+
this.annotationMap.delete(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Checks if a node has an annotation with the key 'LINK'.
|
|
1454
|
+
*
|
|
1455
|
+
* @returns {boolean} A boolean value indicating whether the `annotationMap` has a key 'LINK'.
|
|
1456
|
+
*/
|
|
1457
|
+
isLinkNode() {
|
|
1458
|
+
return this.annotationMap.has('LINK');
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Whether a given range should be split based on various conditions within the range.
|
|
1462
|
+
*
|
|
1463
|
+
* @param {Range} range - Selection range
|
|
1464
|
+
* @returns {boolean} Returns a boolean value indicating whether the
|
|
1465
|
+
* selection range should be split.
|
|
1466
|
+
*/
|
|
1467
|
+
shouldSplitSelection(range) {
|
|
1468
|
+
const { startContainer, endContainer, startOffset, endOffset } = range;
|
|
1469
|
+
const isCrossNode = startContainer !== endContainer;
|
|
1470
|
+
const isPartialStart = startOffset > 0;
|
|
1471
|
+
const isPartialEnd = endOffset < (endContainer.textContent ? endContainer.textContent.length : 0);
|
|
1472
|
+
const isPartialSelection = isPartialStart || isPartialEnd;
|
|
1473
|
+
return isCrossNode || isPartialSelection;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Sync up the selected node by change manager
|
|
1477
|
+
*
|
|
1478
|
+
* @param {RTETextNode} selectedNode - The selected node
|
|
1479
|
+
*/
|
|
1480
|
+
syncUpSelectedNodes(selectedNode) {
|
|
1481
|
+
const currentNodeDom = nodeAnnotation_abstract.stateEntityRenderingRegistry.getDOMByEntity(this);
|
|
1482
|
+
if (currentNodeDom) {
|
|
1483
|
+
const nodeSubject = domNodeSubjectFactory.domNodeSubjectFactory.getSubjectFromParentNodeByEventId(currentNodeDom, vegaInternalEventId.VegaInternalRichTextEditorSelectionRangeChange);
|
|
1484
|
+
if (nodeSubject) {
|
|
1485
|
+
changeManager.ChangeManager.notify(nodeSubject, { node: selectedNode });
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Insert the new node at the start offset
|
|
1491
|
+
*
|
|
1492
|
+
* @param {number} startOffset - The start position offset
|
|
1493
|
+
* @param {AnnotationAction} action - AnnotationAction
|
|
1494
|
+
* @returns {RTETextNode[]} - RTETextNode array
|
|
1495
|
+
*/
|
|
1496
|
+
insertNewNode(startOffset, action) {
|
|
1497
|
+
if (startOffset === 0) {
|
|
1498
|
+
const newNode = this.cloneWithText('');
|
|
1499
|
+
this.applyActionToNode(newNode, action);
|
|
1500
|
+
return [newNode, this];
|
|
1501
|
+
}
|
|
1502
|
+
if (startOffset === this.text.length) {
|
|
1503
|
+
const newNode = this.cloneWithText('');
|
|
1504
|
+
this.applyActionToNode(newNode, action);
|
|
1505
|
+
return [this, newNode];
|
|
1506
|
+
}
|
|
1507
|
+
const beforeNode = this.cloneWithText(this.text.substring(0, startOffset));
|
|
1508
|
+
const newNode = this.cloneWithText('');
|
|
1509
|
+
const afterNode = this.cloneWithText(this.text.substring(startOffset));
|
|
1510
|
+
this.applyActionToNode(newNode, action);
|
|
1511
|
+
return [beforeNode, newNode, afterNode];
|
|
687
1512
|
}
|
|
688
1513
|
}
|
|
689
1514
|
|
|
690
1515
|
/**
|
|
691
1516
|
* Text style annotation
|
|
692
1517
|
*/
|
|
693
|
-
class TextStyleAnnotation extends
|
|
1518
|
+
class TextStyleAnnotation extends nodeAnnotation_abstract.BlockAnnotation {
|
|
694
1519
|
constructor(textStyle) {
|
|
695
1520
|
super();
|
|
696
|
-
this.type =
|
|
1521
|
+
this.type = nodeAnnotation_abstract.BlockAnnotationTypeEnum.TEXT_STYLE;
|
|
697
1522
|
this.textStyle = textStyle;
|
|
698
1523
|
}
|
|
699
1524
|
/**
|
|
@@ -703,7 +1528,7 @@ class TextStyleAnnotation extends blockAnnotation_abstract.BlockAnnotation {
|
|
|
703
1528
|
* @returns {[BlockAnnotationTypeEnum.TEXT_STYLE, TextStyleAnnotation]} Map item for the annotation
|
|
704
1529
|
*/
|
|
705
1530
|
static from(textStyle) {
|
|
706
|
-
return [
|
|
1531
|
+
return [nodeAnnotation_abstract.BlockAnnotationTypeEnum.TEXT_STYLE, new TextStyleAnnotation(textStyle)];
|
|
707
1532
|
}
|
|
708
1533
|
/**
|
|
709
1534
|
* Generate the JSON representation of the annotation
|
|
@@ -751,7 +1576,7 @@ class TextStyleAnnotation extends blockAnnotation_abstract.BlockAnnotation {
|
|
|
751
1576
|
/**
|
|
752
1577
|
* Action to change the text style of a block
|
|
753
1578
|
*/
|
|
754
|
-
class TextStyleAnnotationAction extends
|
|
1579
|
+
class TextStyleAnnotationAction extends AnnotationAction {
|
|
755
1580
|
constructor(textStyle, bold) {
|
|
756
1581
|
super();
|
|
757
1582
|
this.isFlushable = true;
|
|
@@ -771,7 +1596,7 @@ class TextStyleAnnotationAction extends textNode.AnnotationAction {
|
|
|
771
1596
|
/**
|
|
772
1597
|
* Action to toggle bold annotation
|
|
773
1598
|
*/
|
|
774
|
-
class BoldAnnotationAction extends
|
|
1599
|
+
class BoldAnnotationAction extends TextSplittableAction {
|
|
775
1600
|
constructor(bold) {
|
|
776
1601
|
super();
|
|
777
1602
|
this.isFlushable = true;
|
|
@@ -783,7 +1608,7 @@ class BoldAnnotationAction extends textNode.TextSplittableAction {
|
|
|
783
1608
|
* @returns {BoldAnnotation} the annotation
|
|
784
1609
|
*/
|
|
785
1610
|
toAnnotation() {
|
|
786
|
-
return new
|
|
1611
|
+
return new BoldAnnotation(this.bold);
|
|
787
1612
|
}
|
|
788
1613
|
}
|
|
789
1614
|
|
|
@@ -792,10 +1617,10 @@ class BoldAnnotationAction extends textNode.TextSplittableAction {
|
|
|
792
1617
|
*
|
|
793
1618
|
* @example firstBlock.apply(new MergeTwoBlocksNodesAction(secondBlock))
|
|
794
1619
|
*/
|
|
795
|
-
class MergeTwoBlocksNodesAction extends
|
|
1620
|
+
class MergeTwoBlocksNodesAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
796
1621
|
constructor(blockNeedToBeMerged) {
|
|
797
1622
|
super();
|
|
798
|
-
this.type =
|
|
1623
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES;
|
|
799
1624
|
this.blockNeedToBeMerged = blockNeedToBeMerged;
|
|
800
1625
|
}
|
|
801
1626
|
}
|
|
@@ -805,10 +1630,10 @@ class MergeTwoBlocksNodesAction extends node_abstract.ModifyContentAction {
|
|
|
805
1630
|
*
|
|
806
1631
|
* @example currentBlock.parent.apply(new InsertBlocksBeforeAction(currentBlock, newBlock, ...))
|
|
807
1632
|
*/
|
|
808
|
-
class InsertBlocksBeforeAction extends
|
|
1633
|
+
class InsertBlocksBeforeAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
809
1634
|
constructor(referBlock, ...blocksToBeInserted) {
|
|
810
1635
|
super();
|
|
811
|
-
this.type =
|
|
1636
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_BEFORE;
|
|
812
1637
|
this.referBlock = referBlock;
|
|
813
1638
|
this.blocksToBeInserted = blocksToBeInserted;
|
|
814
1639
|
}
|
|
@@ -829,10 +1654,16 @@ class RTETextBlock extends RTEBlock {
|
|
|
829
1654
|
this.annotationMap = new Map([TextStyleAnnotation.from('paragraph')]);
|
|
830
1655
|
}
|
|
831
1656
|
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Converts a VegaRTETextBlock into an RTETextBlock.
|
|
1659
|
+
*
|
|
1660
|
+
* @param {VegaRTETextBlock} block - The block object
|
|
1661
|
+
* @returns {RTETextBlock} A RTETextBlock class
|
|
1662
|
+
*/
|
|
832
1663
|
static from(block) {
|
|
833
1664
|
const textBlock = new RTETextBlock(block.id, block.type);
|
|
834
1665
|
const { annotations } = block;
|
|
835
|
-
textBlock.nodes = block.nodes.map((richText) =>
|
|
1666
|
+
textBlock.nodes = block.nodes.map((richText) => RTETextNode.from(richText, textBlock));
|
|
836
1667
|
if (annotations) {
|
|
837
1668
|
Object.entries(annotations).forEach(([type, value]) => {
|
|
838
1669
|
const item = this.createAnnotationEntity(type, value);
|
|
@@ -863,15 +1694,26 @@ class RTETextBlock extends RTEBlock {
|
|
|
863
1694
|
return super.createAnnotationEntity(type, value);
|
|
864
1695
|
}
|
|
865
1696
|
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Checks if a given text block type is one of the acceptable text styles.
|
|
1699
|
+
*
|
|
1700
|
+
* @param {VegaRTETextBlockType} type - The text block type
|
|
1701
|
+
* @returns {boolean} Return a boolean value indicating whether the `type` parameter is valid.
|
|
1702
|
+
*/
|
|
866
1703
|
static isAcceptableTextStyle(type) {
|
|
867
1704
|
return ['title', 'subtitle', 'paragraph', 'heading-1', 'heading-2', 'heading-3'].includes(type);
|
|
868
1705
|
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Merges RTETextNode nodes based on certain conditions.
|
|
1708
|
+
*
|
|
1709
|
+
* @param {AnnotationAction} action - AnnotationAction
|
|
1710
|
+
*/
|
|
869
1711
|
mergeNodes(action) {
|
|
870
1712
|
this.nodes = this.nodes.reduce((prev, cur) => {
|
|
871
1713
|
const lastNode = prev.at(-1);
|
|
872
|
-
if (action instanceof
|
|
873
|
-
const lastNodeLinkAnnotation = lastNode === null || lastNode === void 0 ? void 0 : lastNode.getAnnotationByType(
|
|
874
|
-
const curNodeLinkAnnotation = cur.getAnnotationByType(
|
|
1714
|
+
if (action instanceof LinkAnnotationAction && action.needMergeNode) {
|
|
1715
|
+
const lastNodeLinkAnnotation = lastNode === null || lastNode === void 0 ? void 0 : lastNode.getAnnotationByType(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
1716
|
+
const curNodeLinkAnnotation = cur.getAnnotationByType(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
875
1717
|
if (lastNodeLinkAnnotation &&
|
|
876
1718
|
curNodeLinkAnnotation &&
|
|
877
1719
|
lastNodeLinkAnnotation.toEqual(curNodeLinkAnnotation)) {
|
|
@@ -882,38 +1724,39 @@ class RTETextBlock extends RTEBlock {
|
|
|
882
1724
|
return [...prev, cur];
|
|
883
1725
|
}, []);
|
|
884
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* @inheritDoc
|
|
1729
|
+
*/
|
|
885
1730
|
toJSON() {
|
|
886
1731
|
return Object.assign(Object.assign({}, super.toJSON()), { type: this.type, nodes: this.nodes.map((node) => node.toJSON()) });
|
|
887
1732
|
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Clone the nodes to a new block
|
|
1735
|
+
*
|
|
1736
|
+
* @param {RTEBlock} nodes - The nodes will be copied
|
|
1737
|
+
* @returns {RTEBlock} New block
|
|
1738
|
+
*/
|
|
888
1739
|
cloneWithNodes(nodes) {
|
|
889
1740
|
const block = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), this.type);
|
|
890
1741
|
block.nodes = [];
|
|
891
1742
|
block.apply(new AppendChildNodesAction(nodes));
|
|
892
1743
|
return block;
|
|
893
1744
|
}
|
|
1745
|
+
/**
|
|
1746
|
+
* @inheritDoc
|
|
1747
|
+
*/
|
|
894
1748
|
isNotEmpty() {
|
|
895
1749
|
return this.nodes.length > 0 && this.nodes.some((node) => !node.isEmpty());
|
|
896
1750
|
}
|
|
1751
|
+
/**
|
|
1752
|
+
* @inheritDoc
|
|
1753
|
+
*/
|
|
897
1754
|
getLastNode() {
|
|
898
1755
|
return this.nodes[this.nodes.length - 1];
|
|
899
1756
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
this.renderNodes(renderContext),
|
|
904
|
-
children));
|
|
905
|
-
}
|
|
906
|
-
registerRef(ref) {
|
|
907
|
-
if (ref) {
|
|
908
|
-
node_abstract.stateEntityRenderingRegistry.register(ref, this);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
renderNodes(renderConfig = {}) {
|
|
912
|
-
const linkGroupAnnotation = this.getAnnotationByType(node_abstract.InternalAnnotationTypeEnum.LINK_GROUP);
|
|
913
|
-
return linkGroupAnnotation
|
|
914
|
-
? linkGroupAnnotation.renderNodes(this.nodes, renderConfig)
|
|
915
|
-
: this.nodes.map((node) => node.render());
|
|
916
|
-
}
|
|
1757
|
+
/**
|
|
1758
|
+
* @inheritDoc
|
|
1759
|
+
*/
|
|
917
1760
|
doAnnotationActionApply(action) {
|
|
918
1761
|
if (action instanceof TextStyleAnnotationAction) {
|
|
919
1762
|
if (this.type !== 'list-item') {
|
|
@@ -928,17 +1771,17 @@ class RTETextBlock extends RTEBlock {
|
|
|
928
1771
|
}
|
|
929
1772
|
else {
|
|
930
1773
|
this.nodes.forEach((node) => {
|
|
931
|
-
node.apply(new
|
|
1774
|
+
node.apply(new DeleteNodeAnnotationAction(nodeAnnotation_abstract.NodeAnnotationTypeEnum.BOLD));
|
|
932
1775
|
});
|
|
933
1776
|
}
|
|
934
1777
|
return;
|
|
935
1778
|
}
|
|
936
|
-
if (action instanceof
|
|
937
|
-
const linkGroupAnnotation = this.getAnnotationByType(
|
|
1779
|
+
if (action instanceof LinkGroupAnnotationAction) {
|
|
1780
|
+
const linkGroupAnnotation = this.getAnnotationByType(nodeAnnotation_abstract.InternalAnnotationTypeEnum.LINK_GROUP);
|
|
938
1781
|
if (linkGroupAnnotation) {
|
|
939
1782
|
const linkGroup = linkGroupAnnotation.linkGroups.get(action.groupKey);
|
|
940
1783
|
linkGroupAnnotation.linkGroups.set(action.groupKey, [...linkGroup, ...action.nodes]);
|
|
941
|
-
this.annotationMap.set(
|
|
1784
|
+
this.annotationMap.set(nodeAnnotation_abstract.InternalAnnotationTypeEnum.LINK_GROUP, linkGroupAnnotation);
|
|
942
1785
|
}
|
|
943
1786
|
return;
|
|
944
1787
|
}
|
|
@@ -950,44 +1793,44 @@ class RTETextBlock extends RTEBlock {
|
|
|
950
1793
|
*/
|
|
951
1794
|
doModifyActionApply(action) {
|
|
952
1795
|
switch (action.type) {
|
|
953
|
-
case
|
|
1796
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
954
1797
|
this.removeChildNode(action);
|
|
955
1798
|
break;
|
|
956
|
-
case
|
|
1799
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
957
1800
|
this.appendChildNodes(action.entityToBeAppended);
|
|
958
1801
|
break;
|
|
959
|
-
case
|
|
1802
|
+
case nodeAnnotation_abstract.ModifyContentActionType.CLEAR_CHILD_NODES:
|
|
960
1803
|
this.nodes = [];
|
|
961
1804
|
break;
|
|
962
|
-
case
|
|
1805
|
+
case nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
|
|
963
1806
|
action.newBlock = this.splitTextNodeBlock(action.splitPointNode, action.startOffsetOfNode);
|
|
964
1807
|
break;
|
|
965
|
-
case
|
|
1808
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES:
|
|
966
1809
|
this.nodes = [];
|
|
967
1810
|
this.appendChildNodes(action.newChildNodes);
|
|
968
1811
|
break;
|
|
969
|
-
case
|
|
1812
|
+
case nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
|
|
970
1813
|
this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
|
|
971
1814
|
break;
|
|
972
|
-
case
|
|
1815
|
+
case nodeAnnotation_abstract.ModifyContentActionType.BREAK_SINGLE_BLOCK:
|
|
973
1816
|
action.newBlock = this.breakSingleTextBlock(action.startContainerNode, action.startOffset);
|
|
974
1817
|
break;
|
|
975
|
-
case
|
|
1818
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
|
|
976
1819
|
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
|
|
977
1820
|
break;
|
|
978
|
-
case
|
|
1821
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
|
|
979
1822
|
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
|
|
980
1823
|
break;
|
|
981
|
-
case
|
|
1824
|
+
case nodeAnnotation_abstract.ModifyContentActionType.TRANSFORM_LIST_BLOCK:
|
|
982
1825
|
this.convertParagraphToList(action);
|
|
983
1826
|
break;
|
|
984
|
-
case
|
|
1827
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_BLOCK_CONTENT:
|
|
985
1828
|
this.deleteNodeContent(action);
|
|
986
1829
|
break;
|
|
987
|
-
case
|
|
1830
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
988
1831
|
this.insertImage(action);
|
|
989
1832
|
break;
|
|
990
|
-
case
|
|
1833
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_BEFORE:
|
|
991
1834
|
this.replaceNodeWithNodes(action.referNode, [
|
|
992
1835
|
...action.nodesToBeInserted,
|
|
993
1836
|
action.referNode,
|
|
@@ -995,6 +1838,13 @@ class RTETextBlock extends RTEBlock {
|
|
|
995
1838
|
break;
|
|
996
1839
|
}
|
|
997
1840
|
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Splits a text node at a specified offset within a block of nodes and returns a new block with the split nodes.
|
|
1843
|
+
*
|
|
1844
|
+
* @param {RTETextNode} splitNode - The text node that will be split
|
|
1845
|
+
* @param {number} startOffsetOfNode - The index at which will split the text content of the `splitNode`.
|
|
1846
|
+
* @returns {Nullable<RTEBlock>} return either an RTEBlock object or null.
|
|
1847
|
+
*/
|
|
998
1848
|
splitTextNodeBlock(splitNode, startOffsetOfNode) {
|
|
999
1849
|
if (splitNode) {
|
|
1000
1850
|
const beforeText = splitNode.text.slice(0, startOffsetOfNode);
|
|
@@ -1016,16 +1866,37 @@ class RTETextBlock extends RTEBlock {
|
|
|
1016
1866
|
}
|
|
1017
1867
|
}
|
|
1018
1868
|
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Checks if the caret position is at the start of a specified RTETextNode.
|
|
1871
|
+
*
|
|
1872
|
+
* @param {RTETextNode} node - `RTETextNode` - a node representing an image in a rich text editor.
|
|
1873
|
+
* @param {number} startOffset - The position within the text node where the caret is located.
|
|
1874
|
+
* @returns {boolean} a boolean value, which indicates whether the caret position is at the start of the RTETextNode.
|
|
1875
|
+
*/
|
|
1019
1876
|
isCaretPositionAtStart(node, startOffset) {
|
|
1020
1877
|
return node === this.nodes[0] && startOffset === 0;
|
|
1021
1878
|
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Checks if the caret position is at the end of a specified RTETextNode.
|
|
1881
|
+
*
|
|
1882
|
+
* @param {RTETextNode} node - `RTETextNode` - a node representing an image in a rich text editor.
|
|
1883
|
+
* @param {number} startOffset - The position within the text node where the caret is located.
|
|
1884
|
+
* @returns {boolean} a boolean value, which indicates whether the caret position is at the start of the RTETextNode.
|
|
1885
|
+
*/
|
|
1022
1886
|
isCaretPositionAtEnd(node, startOffset) {
|
|
1023
1887
|
const lastNode = this.nodes[this.nodes.length - 1];
|
|
1024
1888
|
return node === lastNode && (node.isEmpty() || startOffset === lastNode.text.length);
|
|
1025
1889
|
}
|
|
1890
|
+
/**
|
|
1891
|
+
* lineBreakSingleBlock
|
|
1892
|
+
*
|
|
1893
|
+
* @param {RTETextNode} splitNode -
|
|
1894
|
+
* @param {number} startOffsetOfNode -
|
|
1895
|
+
* @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
|
|
1896
|
+
*/
|
|
1026
1897
|
lineBreakSingleBlock(splitNode, startOffsetOfNode) {
|
|
1027
1898
|
if (splitNode) {
|
|
1028
|
-
const lineBreakNode = new
|
|
1899
|
+
const lineBreakNode = new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', this);
|
|
1029
1900
|
const beforeText = splitNode.text.slice(0, startOffsetOfNode);
|
|
1030
1901
|
const afterText = splitNode.text.slice(startOffsetOfNode);
|
|
1031
1902
|
const nodesSplitIndex = this.nodes.indexOf(splitNode);
|
|
@@ -1043,20 +1914,31 @@ class RTETextBlock extends RTEBlock {
|
|
|
1043
1914
|
return lineBreakNode;
|
|
1044
1915
|
}
|
|
1045
1916
|
}
|
|
1917
|
+
/**
|
|
1918
|
+
* lineBreakMultipleBlocks
|
|
1919
|
+
*
|
|
1920
|
+
* @param {RTEBlock[]} selectedBlocks -
|
|
1921
|
+
* @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
|
|
1922
|
+
*/
|
|
1046
1923
|
lineBreakMultipleBlocks(selectedBlocks) {
|
|
1047
1924
|
const beforeNodes = this['nodes'];
|
|
1048
|
-
const lineBreakNode = new
|
|
1925
|
+
const lineBreakNode = new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', this);
|
|
1049
1926
|
const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
|
|
1050
1927
|
this.mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes);
|
|
1051
1928
|
return lineBreakNode;
|
|
1052
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* deleteNodeContent
|
|
1932
|
+
*
|
|
1933
|
+
* @param {DeleteBlockContentAction} action - ModifyContentAction
|
|
1934
|
+
*/
|
|
1053
1935
|
deleteNodeContent(action) {
|
|
1054
1936
|
const startContainerNode = action.startContainerNode;
|
|
1055
1937
|
const startOffset = action.startOffset;
|
|
1056
1938
|
if (startOffset !== 0 && !startContainerNode.isEmpty()) {
|
|
1057
1939
|
const newText = startContainerNode.text.slice(0, startOffset - 1) +
|
|
1058
1940
|
startContainerNode.text.slice(startOffset);
|
|
1059
|
-
startContainerNode.apply(new
|
|
1941
|
+
startContainerNode.apply(new UpdateTextAction(newText));
|
|
1060
1942
|
if (newText) {
|
|
1061
1943
|
action.previousNode = startContainerNode;
|
|
1062
1944
|
return;
|
|
@@ -1091,6 +1973,7 @@ class RTETextBlock extends RTEBlock {
|
|
|
1091
1973
|
}
|
|
1092
1974
|
/**
|
|
1093
1975
|
* Remove line break
|
|
1976
|
+
*
|
|
1094
1977
|
* @example caret at the first line
|
|
1095
1978
|
* \n
|
|
1096
1979
|
* test
|
|
@@ -1100,11 +1983,12 @@ class RTETextBlock extends RTEBlock {
|
|
|
1100
1983
|
}
|
|
1101
1984
|
/**
|
|
1102
1985
|
* Remove line break
|
|
1986
|
+
*
|
|
1103
1987
|
* @example caret at the begin of second line
|
|
1104
1988
|
* \n
|
|
1105
1989
|
* test
|
|
1106
1990
|
*/
|
|
1107
|
-
if (previousNode instanceof
|
|
1991
|
+
if (previousNode instanceof RTETextNode && previousNode.isEmpty()) {
|
|
1108
1992
|
const shouldRemoveNode = previousNode;
|
|
1109
1993
|
previousNode = this.getPreviousNode(previousNode);
|
|
1110
1994
|
shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
|
|
@@ -1125,35 +2009,37 @@ class RTETextBlock extends RTEBlock {
|
|
|
1125
2009
|
}
|
|
1126
2010
|
}
|
|
1127
2011
|
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Remove the child node
|
|
2014
|
+
*
|
|
2015
|
+
* @param {RemoveChildAction} action - Modify action
|
|
2016
|
+
*/
|
|
1128
2017
|
removeChildNode(action) {
|
|
1129
2018
|
this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
|
|
1130
2019
|
if (this.nodes.length === 0) {
|
|
1131
2020
|
this.parent.apply(new RemoveChildAction(this));
|
|
1132
2021
|
}
|
|
1133
2022
|
}
|
|
2023
|
+
/**
|
|
2024
|
+
* mergeLineBreakNodes
|
|
2025
|
+
*
|
|
2026
|
+
* @param {RTENode[]} beforeNodes -
|
|
2027
|
+
* @param {RTETextNode} lineBreakNode -
|
|
2028
|
+
* @param {RTENode[]} afterNodes -
|
|
2029
|
+
*/
|
|
1134
2030
|
mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes) {
|
|
1135
2031
|
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
1136
|
-
afterNodes.push(new
|
|
2032
|
+
afterNodes.push(new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', this, beforeNodes[beforeNodes.length - 1] && beforeNodes[beforeNodes.length - 1].annotationMap));
|
|
1137
2033
|
}
|
|
1138
2034
|
this.apply(new ReplaceChildNodesAction([...beforeNodes, lineBreakNode, ...afterNodes]));
|
|
1139
2035
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
case 'heading-2':
|
|
1148
|
-
return `h2`;
|
|
1149
|
-
case 'heading-3':
|
|
1150
|
-
return `h3`;
|
|
1151
|
-
case 'paragraph':
|
|
1152
|
-
return 'p';
|
|
1153
|
-
case 'list-item':
|
|
1154
|
-
return 'li';
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
2036
|
+
/**
|
|
2037
|
+
* breakSingleTextBlock
|
|
2038
|
+
*
|
|
2039
|
+
* @param {RTETextNode} splitNode -
|
|
2040
|
+
* @param {number} startOffsetOfNode -
|
|
2041
|
+
* @returns {Nullable<RTEBlock>} Nullable<RTEBlock>
|
|
2042
|
+
*/
|
|
1157
2043
|
breakSingleTextBlock(splitNode, startOffsetOfNode) {
|
|
1158
2044
|
const newParagraph = this.copyInlineStyleToNewParagraph(splitNode);
|
|
1159
2045
|
if (this.isCaretPositionAtEnd(splitNode, startOffsetOfNode)) {
|
|
@@ -1169,6 +2055,11 @@ class RTETextBlock extends RTEBlock {
|
|
|
1169
2055
|
}
|
|
1170
2056
|
return newParagraph;
|
|
1171
2057
|
}
|
|
2058
|
+
/**
|
|
2059
|
+
* convertParagraphToList
|
|
2060
|
+
*
|
|
2061
|
+
* @param {TransformListAction} action - ModifyContentAction
|
|
2062
|
+
*/
|
|
1172
2063
|
convertParagraphToList(action) {
|
|
1173
2064
|
const bulletList = this.parent.createList(action.listType);
|
|
1174
2065
|
const listItems = action.selectedBlocks.map((node) => this.parent.toListItem(node));
|
|
@@ -1178,6 +2069,11 @@ class RTETextBlock extends RTEBlock {
|
|
|
1178
2069
|
node.parent.apply(new RemoveChildAction(node));
|
|
1179
2070
|
});
|
|
1180
2071
|
}
|
|
2072
|
+
/**
|
|
2073
|
+
* insertImage
|
|
2074
|
+
*
|
|
2075
|
+
* @param {InsertImageToBlockAction} action - ModifyContentAction
|
|
2076
|
+
*/
|
|
1181
2077
|
insertImage(action) {
|
|
1182
2078
|
const splitNode = action.splitPointNode;
|
|
1183
2079
|
const startOffsetOfNode = action.startOffsetOfNode;
|
|
@@ -1194,10 +2090,16 @@ class RTETextBlock extends RTEBlock {
|
|
|
1194
2090
|
this.parent.apply(new InsertBlocksAfterAction(this, newImageBlock));
|
|
1195
2091
|
}
|
|
1196
2092
|
}
|
|
2093
|
+
/**
|
|
2094
|
+
* copyInlineStyleToNewParagraph
|
|
2095
|
+
*
|
|
2096
|
+
* @param {RTETextNode} needCopedNode -
|
|
2097
|
+
* @returns {RTETextBlock} RTETextBlock
|
|
2098
|
+
*/
|
|
1197
2099
|
copyInlineStyleToNewParagraph(needCopedNode) {
|
|
1198
2100
|
const textNode = needCopedNode.cloneWithText('');
|
|
1199
2101
|
// The link annotation don't need inherited
|
|
1200
|
-
textNode.annotationMap.delete(
|
|
2102
|
+
textNode.annotationMap.delete(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
1201
2103
|
const newParagraph = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
1202
2104
|
newParagraph.apply(new AppendChildNodesAction([textNode]));
|
|
1203
2105
|
return newParagraph;
|
|
@@ -1213,6 +2115,12 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1213
2115
|
this.type = 'image';
|
|
1214
2116
|
this.nodes = [];
|
|
1215
2117
|
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Converts a VegaRTEImageBlock object into an RTEImageBlock object by mapping nodes and creating annotations.
|
|
2120
|
+
*
|
|
2121
|
+
* @param {VegaRTEImageBlock} block - The block object to be converted.
|
|
2122
|
+
* @returns {RTEImageBlock} An instance of `RTEImageBlock`
|
|
2123
|
+
*/
|
|
1216
2124
|
static from(block) {
|
|
1217
2125
|
const imageBlock = new RTEImageBlock(block.id);
|
|
1218
2126
|
const { annotations } = block;
|
|
@@ -1227,68 +2135,72 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1227
2135
|
}
|
|
1228
2136
|
return imageBlock;
|
|
1229
2137
|
}
|
|
2138
|
+
/**
|
|
2139
|
+
* @inheritDoc
|
|
2140
|
+
*/
|
|
1230
2141
|
toJSON() {
|
|
1231
2142
|
return Object.assign(Object.assign({}, super.toJSON()), { type: 'image', nodes: this.nodes.map((node) => node.toJSON()) });
|
|
1232
2143
|
}
|
|
2144
|
+
/**
|
|
2145
|
+
* @inheritDoc
|
|
2146
|
+
*/
|
|
1233
2147
|
isNotEmpty() {
|
|
1234
2148
|
return this.nodes.length > 0 && this.nodes.some((node) => node.url.length > 0);
|
|
1235
2149
|
}
|
|
2150
|
+
/**
|
|
2151
|
+
* @inheritDoc
|
|
2152
|
+
*/
|
|
1236
2153
|
getLastNode() {
|
|
1237
2154
|
return this.nodes[this.nodes.length - 1];
|
|
1238
2155
|
}
|
|
1239
|
-
render(renderContext) {
|
|
1240
|
-
return (globalSlimmerRegistry.h("div", { style: Object.assign({}, this.getStyles()), ref: this.registerRef.bind(this), class: super.getClasses() }, this.nodes.map((node) => {
|
|
1241
|
-
return node.render(renderContext);
|
|
1242
|
-
})));
|
|
1243
|
-
}
|
|
1244
2156
|
/**
|
|
1245
|
-
* Apply modify action to block
|
|
2157
|
+
* Apply a modify action to block
|
|
1246
2158
|
*
|
|
1247
2159
|
* @param {ModifyContentAction} action - Modify action
|
|
1248
2160
|
*/
|
|
1249
2161
|
doModifyActionApply(action) {
|
|
1250
2162
|
switch (action.type) {
|
|
1251
|
-
case
|
|
2163
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1252
2164
|
this.removeChildNode(action);
|
|
1253
2165
|
break;
|
|
1254
|
-
case
|
|
2166
|
+
case nodeAnnotation_abstract.ModifyContentActionType.CLEAR_CHILD_NODES:
|
|
1255
2167
|
this.nodes = [];
|
|
1256
2168
|
break;
|
|
1257
|
-
case
|
|
2169
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1258
2170
|
this.appendChildNodes(action.entityToBeAppended);
|
|
1259
2171
|
break;
|
|
1260
|
-
case
|
|
2172
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES:
|
|
1261
2173
|
this.nodes = [];
|
|
1262
2174
|
this.appendChildNodes(action.newChildNodes);
|
|
1263
2175
|
break;
|
|
1264
|
-
case
|
|
2176
|
+
case nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
|
|
1265
2177
|
action.newBlock = this.splitImageNodes(action.splitPointNode, action.startOffsetOfNode);
|
|
1266
2178
|
break;
|
|
1267
|
-
case
|
|
2179
|
+
case nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
|
|
1268
2180
|
this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
|
|
1269
2181
|
break;
|
|
1270
|
-
case
|
|
2182
|
+
case nodeAnnotation_abstract.ModifyContentActionType.BREAK_SINGLE_BLOCK:
|
|
1271
2183
|
action.newBlock = this.breakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1272
2184
|
break;
|
|
1273
|
-
case
|
|
2185
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
|
|
1274
2186
|
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1275
2187
|
break;
|
|
1276
|
-
case
|
|
2188
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
|
|
1277
2189
|
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
|
|
1278
2190
|
break;
|
|
1279
|
-
case
|
|
2191
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_BLOCK_CONTENT:
|
|
1280
2192
|
this.deleteNodeContent(action);
|
|
1281
2193
|
break;
|
|
1282
|
-
case
|
|
2194
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1283
2195
|
this.insertImage(action);
|
|
1284
2196
|
break;
|
|
1285
|
-
case
|
|
2197
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_AFTER:
|
|
1286
2198
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1287
2199
|
action.referNode,
|
|
1288
2200
|
...action.nodesToBeInserted,
|
|
1289
2201
|
]);
|
|
1290
2202
|
break;
|
|
1291
|
-
case
|
|
2203
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_BEFORE:
|
|
1292
2204
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1293
2205
|
...action.nodesToBeInserted,
|
|
1294
2206
|
action.referNode,
|
|
@@ -1296,11 +2208,11 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1296
2208
|
break;
|
|
1297
2209
|
}
|
|
1298
2210
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
2211
|
+
/**
|
|
2212
|
+
* Removes a specified child node from a list of nodes and triggers a parent action if the list becomes empty.
|
|
2213
|
+
*
|
|
2214
|
+
* @param {RemoveChildAction} action - Action to be performed when removing a child node from the list of nodes.
|
|
2215
|
+
*/
|
|
1304
2216
|
removeChildNode(action) {
|
|
1305
2217
|
this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
|
|
1306
2218
|
if (this.nodes.length === 0) {
|
|
@@ -1313,6 +2225,7 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1313
2225
|
*
|
|
1314
2226
|
* @param {RTEImageNode} imageNode The split point image node
|
|
1315
2227
|
* @param {number} imageOffset The cursor point 0 | 1
|
|
2228
|
+
* @returns {Nullable<RTEBlock>} The new block after split
|
|
1316
2229
|
*/
|
|
1317
2230
|
splitImageNodes(imageNode, imageOffset) {
|
|
1318
2231
|
const nodesSplitIndex = this.nodes.indexOf(imageNode);
|
|
@@ -1325,12 +2238,25 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1325
2238
|
return newBlock;
|
|
1326
2239
|
}
|
|
1327
2240
|
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Creates a new RTEImageBlock instance with the provided RTEImageNode instances appended to it.
|
|
2243
|
+
*
|
|
2244
|
+
* @param {RTEImageNode[]} nodes - An array of RTEImageNode objects that will be used to create a new RTEImageBlock instance.
|
|
2245
|
+
* @returns {RTEImageBlock} A new `RTEImageBlock` object with the provided `nodes` appended to it.
|
|
2246
|
+
*/
|
|
1328
2247
|
cloneWithNodes(nodes) {
|
|
1329
2248
|
const block = new RTEImageBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1330
2249
|
block.nodes = [];
|
|
1331
2250
|
block.apply(new AppendChildNodesAction(nodes));
|
|
1332
2251
|
return block;
|
|
1333
2252
|
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Used to split a block of text at a specific position and insert a new paragraph block.
|
|
2255
|
+
*
|
|
2256
|
+
* @param {RTEImageNode} splitNode - The node that needs to be split into separate blocks.
|
|
2257
|
+
* @param {number} startOffsetOfNode - The index or position within the `splitNode` where the block should be broken or split.
|
|
2258
|
+
* @returns {Nullable<RTEBlock>} Returns either a new paragraph block or the new block created after splitting the original block.
|
|
2259
|
+
*/
|
|
1334
2260
|
breakSingleBlock(splitNode, startOffsetOfNode) {
|
|
1335
2261
|
const newParagraph = RTETextBlock.from({
|
|
1336
2262
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
@@ -1350,19 +2276,46 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1350
2276
|
}
|
|
1351
2277
|
return newParagraph;
|
|
1352
2278
|
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Breaks a single block of text at a specified offset and returns the first node of the new paragraph if created.
|
|
2281
|
+
*
|
|
2282
|
+
* @param {RTEImageNode} splitNode - It represents a node in a rich text editor that contains an image.
|
|
2283
|
+
* @param {number} startOffset - The index at which the line break should occur within the `RTEImageNode` block.
|
|
2284
|
+
* @returns {Nullable<RTETextNode>} Returning the first node of the `newParagraph` block if `newParagraph` is not null.
|
|
2285
|
+
*/
|
|
1353
2286
|
lineBreakSingleBlock(splitNode, startOffset) {
|
|
1354
2287
|
const newParagraph = this.breakSingleBlock(splitNode, startOffset);
|
|
1355
2288
|
if (newParagraph) {
|
|
1356
2289
|
return newParagraph['nodes'][0];
|
|
1357
2290
|
}
|
|
1358
2291
|
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Checks if the caret position is at the start of a specified RTEImageNode.
|
|
2294
|
+
*
|
|
2295
|
+
* @param {RTEImageNode} node - `RTEImageNode` - a node representing an image in a rich text editor.
|
|
2296
|
+
* @param {number} startOffset - The position within the text node where the caret is located.
|
|
2297
|
+
* @returns {boolean} a boolean value, which indicates whether the caret position is at the start of the RTEImageNode.
|
|
2298
|
+
*/
|
|
1359
2299
|
isCaretPositionAtStart(node, startOffset) {
|
|
1360
2300
|
return node === this.nodes[0] && startOffset === 0;
|
|
1361
2301
|
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Checks if the caret position is at the end of a given RTEImageNode.
|
|
2304
|
+
*
|
|
2305
|
+
* @param {RTEImageNode} node - `node` is a RTEImageNode
|
|
2306
|
+
* @param {number} startOffset - The position within the `RTEImageNode` where the caret is located.
|
|
2307
|
+
* @returns {boolean}Returns a boolean value indicating whether the caret position is at the end of the `RTEImageNode`.
|
|
2308
|
+
*/
|
|
1362
2309
|
isCaretPositionAtEnd(node, startOffset) {
|
|
1363
2310
|
const lastNode = this.nodes[this.nodes.length - 1];
|
|
1364
2311
|
return node === lastNode && startOffset === 1;
|
|
1365
2312
|
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Inserts a new paragraph block with a line break after a selected block of text in a rich text editor.
|
|
2315
|
+
*
|
|
2316
|
+
* @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.
|
|
2317
|
+
* @returns {Nullable<RTETextNode>} Returns a Nullable RTETextNode.
|
|
2318
|
+
*/
|
|
1366
2319
|
lineBreakMultipleBlocks(selectedBlocks) {
|
|
1367
2320
|
const newParagraph = RTETextBlock.from({
|
|
1368
2321
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
@@ -1372,11 +2325,16 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1372
2325
|
this.parent.apply(new InsertBlocksAfterAction(this, newParagraph));
|
|
1373
2326
|
const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
|
|
1374
2327
|
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
1375
|
-
afterNodes.push(new
|
|
2328
|
+
afterNodes.push(new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', newParagraph));
|
|
1376
2329
|
}
|
|
1377
2330
|
newParagraph.apply(new AppendChildNodesAction(afterNodes));
|
|
1378
2331
|
return newParagraph['nodes'][0];
|
|
1379
2332
|
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Deletes content from a block node based on specific conditions.
|
|
2335
|
+
*
|
|
2336
|
+
* @param {DeleteBlockContentAction} action - Delete block content action
|
|
2337
|
+
*/
|
|
1380
2338
|
deleteNodeContent(action) {
|
|
1381
2339
|
const startContainerNode = action
|
|
1382
2340
|
.startContainerNode, startOffset = action.startOffset;
|
|
@@ -1437,15 +2395,24 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1437
2395
|
}
|
|
1438
2396
|
}
|
|
1439
2397
|
|
|
2398
|
+
/**
|
|
2399
|
+
* List item block
|
|
2400
|
+
*/
|
|
1440
2401
|
class RTEListItemBlock extends RTETextBlock {
|
|
1441
2402
|
constructor(id, children) {
|
|
1442
2403
|
super(id, 'list-item');
|
|
1443
2404
|
this.children = [];
|
|
1444
2405
|
this.children = children;
|
|
1445
2406
|
}
|
|
2407
|
+
/**
|
|
2408
|
+
* Converts a VegaRTEListItemBlock object to an RTEListItemBlock
|
|
2409
|
+
*
|
|
2410
|
+
* @param {VegaRTEListBlock} block - Converts a `VegaRTEListItemBlock` object into an `RTEListItemBlock`.
|
|
2411
|
+
* @returns {RTEListBlock} Return an instance of `RTEListItemBlock`
|
|
2412
|
+
*/
|
|
1446
2413
|
static from(block) {
|
|
1447
2414
|
const listItemBlock = new RTEListItemBlock(block.id);
|
|
1448
|
-
listItemBlock.nodes = block.nodes.map((richText) =>
|
|
2415
|
+
listItemBlock.nodes = block.nodes.map((richText) => RTETextNode.from(richText, listItemBlock));
|
|
1449
2416
|
if (block.children) {
|
|
1450
2417
|
listItemBlock.children = block.children.map((child) => {
|
|
1451
2418
|
const listBlock = RTEListBlock.from(child);
|
|
@@ -1464,16 +2431,25 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1464
2431
|
}
|
|
1465
2432
|
return listItemBlock;
|
|
1466
2433
|
}
|
|
2434
|
+
/**
|
|
2435
|
+
* @inheritDoc
|
|
2436
|
+
*/
|
|
1467
2437
|
toJSON() {
|
|
1468
2438
|
var _a;
|
|
1469
2439
|
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()) });
|
|
1470
2440
|
}
|
|
2441
|
+
/**
|
|
2442
|
+
* @inheritDoc
|
|
2443
|
+
*/
|
|
1471
2444
|
cloneWithNodes(nodes) {
|
|
1472
2445
|
const block = new RTEListItemBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1473
2446
|
block.nodes = [];
|
|
1474
2447
|
block.apply(new AppendChildNodesAction(nodes));
|
|
1475
2448
|
return block;
|
|
1476
2449
|
}
|
|
2450
|
+
/**
|
|
2451
|
+
* @inheritDoc
|
|
2452
|
+
*/
|
|
1477
2453
|
isNotEmpty() {
|
|
1478
2454
|
if (this.children) {
|
|
1479
2455
|
return super.isNotEmpty() || this.children.some((block) => block.isNotEmpty());
|
|
@@ -1482,6 +2458,9 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1482
2458
|
return super.isNotEmpty();
|
|
1483
2459
|
}
|
|
1484
2460
|
}
|
|
2461
|
+
/**
|
|
2462
|
+
* @inheritDoc
|
|
2463
|
+
*/
|
|
1485
2464
|
getLastNode() {
|
|
1486
2465
|
if (this.children && this.children.length > 0) {
|
|
1487
2466
|
const childListBlock = this.children[this.children.length - 1];
|
|
@@ -1489,9 +2468,6 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1489
2468
|
}
|
|
1490
2469
|
return super.getLastNode();
|
|
1491
2470
|
}
|
|
1492
|
-
render(renderContext) {
|
|
1493
|
-
return super.render(renderContext, this.renderChildren(renderContext));
|
|
1494
|
-
}
|
|
1495
2471
|
/**
|
|
1496
2472
|
* Apply a modify action to block
|
|
1497
2473
|
*
|
|
@@ -1499,47 +2475,47 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1499
2475
|
*/
|
|
1500
2476
|
doModifyActionApply(action) {
|
|
1501
2477
|
switch (action.type) {
|
|
1502
|
-
case
|
|
2478
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1503
2479
|
this.removeListChildNode(action);
|
|
1504
2480
|
break;
|
|
1505
|
-
case
|
|
2481
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_NEST_LIST:
|
|
1506
2482
|
this.removeNestList(action);
|
|
1507
2483
|
break;
|
|
1508
|
-
case
|
|
2484
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1509
2485
|
this.appendChildNodes(action.entityToBeAppended);
|
|
1510
2486
|
break;
|
|
1511
|
-
case
|
|
2487
|
+
case nodeAnnotation_abstract.ModifyContentActionType.CLEAR_CHILD_NODES:
|
|
1512
2488
|
this.nodes = [];
|
|
1513
2489
|
break;
|
|
1514
|
-
case
|
|
2490
|
+
case nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
|
|
1515
2491
|
this.splitListItemBlock(action);
|
|
1516
2492
|
break;
|
|
1517
|
-
case
|
|
2493
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES:
|
|
1518
2494
|
this.nodes = [];
|
|
1519
2495
|
this.appendChildNodes(action.newChildNodes);
|
|
1520
2496
|
break;
|
|
1521
|
-
case
|
|
2497
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_NEST_LIST:
|
|
1522
2498
|
this.replaceNestList(action.newList);
|
|
1523
2499
|
break;
|
|
1524
|
-
case
|
|
2500
|
+
case nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
|
|
1525
2501
|
this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
|
|
1526
2502
|
break;
|
|
1527
|
-
case
|
|
2503
|
+
case nodeAnnotation_abstract.ModifyContentActionType.BREAK_SINGLE_BLOCK:
|
|
1528
2504
|
action.newBlock = this.breakSingleListItemBlock(action.startContainerNode, action.startOffset);
|
|
1529
2505
|
break;
|
|
1530
|
-
case
|
|
2506
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
|
|
1531
2507
|
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1532
2508
|
break;
|
|
1533
|
-
case
|
|
2509
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
|
|
1534
2510
|
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
|
|
1535
2511
|
break;
|
|
1536
|
-
case
|
|
2512
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_BLOCK_CONTENT:
|
|
1537
2513
|
this.deleteListNodeContent(action);
|
|
1538
2514
|
break;
|
|
1539
|
-
case
|
|
2515
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1540
2516
|
this.parent.apply(action);
|
|
1541
2517
|
break;
|
|
1542
|
-
case
|
|
2518
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_BEFORE:
|
|
1543
2519
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1544
2520
|
...action.nodesToBeInserted,
|
|
1545
2521
|
action.referNode,
|
|
@@ -1547,16 +2523,22 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1547
2523
|
break;
|
|
1548
2524
|
}
|
|
1549
2525
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
2526
|
+
/**
|
|
2527
|
+
* Remove the list child node
|
|
2528
|
+
*
|
|
2529
|
+
* @param {RemoveChildAction} action - Modify action
|
|
2530
|
+
*/
|
|
1554
2531
|
removeListChildNode(action) {
|
|
1555
2532
|
this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
|
|
1556
2533
|
if (this.nodes.length === 0 && (!this.children || !this.children.length)) {
|
|
1557
2534
|
this.parent.apply(new RemoveChildAction(this));
|
|
1558
2535
|
}
|
|
1559
2536
|
}
|
|
2537
|
+
/**
|
|
2538
|
+
* Remove the nest list
|
|
2539
|
+
*
|
|
2540
|
+
* @param {RemoveNestListAction} action - Modify action
|
|
2541
|
+
*/
|
|
1560
2542
|
removeNestList(action) {
|
|
1561
2543
|
if (this.children) {
|
|
1562
2544
|
if (this.children.length > 1) {
|
|
@@ -1567,15 +2549,34 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1567
2549
|
}
|
|
1568
2550
|
}
|
|
1569
2551
|
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Iterates through a list of RTEListBlock and sets their parent property to the current object, then replaces the children property with the new list.
|
|
2554
|
+
*
|
|
2555
|
+
* @param {RTEListBlock[]} newList - new list that you want to replace the existing children of the current object with.
|
|
2556
|
+
*/
|
|
1570
2557
|
replaceNestList(newList) {
|
|
1571
2558
|
newList.forEach((listBlock) => {
|
|
1572
2559
|
listBlock.parent = this;
|
|
1573
2560
|
});
|
|
1574
2561
|
this.children = newList;
|
|
1575
2562
|
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Split list item block
|
|
2565
|
+
*
|
|
2566
|
+
* @param {SplitBlockWithNodeAction} action - Modify action
|
|
2567
|
+
*/
|
|
1576
2568
|
splitListItemBlock(action) {
|
|
1577
2569
|
action.newBlock = this.splitTextNodeBlock(action.splitPointNode, action.startOffsetOfNode);
|
|
1578
2570
|
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Breaks a single list item block at a specific position.
|
|
2573
|
+
*
|
|
2574
|
+
* @param {RTETextNode} splitNode - The node that needs to be split within a list item block.
|
|
2575
|
+
* @param {number} startOffsetOfNode - The index within the `splitNode` where the break operation should occur.
|
|
2576
|
+
* @returns {Nullable<RTEBlock>} Returns either a new `RTEListItemBlock` if the caret
|
|
2577
|
+
* position is at the end of the `splitNode`, or it returns the result of splitting the block at the
|
|
2578
|
+
* caret position if it is neither at the start nor at the end.
|
|
2579
|
+
*/
|
|
1579
2580
|
breakSingleListItemBlock(splitNode, startOffsetOfNode) {
|
|
1580
2581
|
const newListItem = new RTEListItemBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1581
2582
|
const newBreakNode = this.copyInlineStyleToNewNode(splitNode);
|
|
@@ -1593,6 +2594,12 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1593
2594
|
}
|
|
1594
2595
|
return newListItem;
|
|
1595
2596
|
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Breaks a list item at the end and handles the insertion of a new list item or paragraph accordingly.
|
|
2599
|
+
*
|
|
2600
|
+
* @param {RTEListItemBlock} newListItem - Item that represents a new list item to be added to the existing list.
|
|
2601
|
+
* @returns {RTEBlock} Returns a `RTEBlock`.
|
|
2602
|
+
*/
|
|
1596
2603
|
breakListItemAtEnd(newListItem) {
|
|
1597
2604
|
const lastItem = this.parent.blocks[this.parent.blocks.length - 1];
|
|
1598
2605
|
const currentItemIsEmpty = this.nodes.length === 1 && this.nodes[0].isEmpty();
|
|
@@ -1619,6 +2626,11 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1619
2626
|
}
|
|
1620
2627
|
return newListItem;
|
|
1621
2628
|
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Delete list node content
|
|
2631
|
+
*
|
|
2632
|
+
* @param {DeleteBlockContentAction} action - Modify action
|
|
2633
|
+
*/
|
|
1622
2634
|
deleteListNodeContent(action) {
|
|
1623
2635
|
const startContainerNode = action.startContainerNode;
|
|
1624
2636
|
const listBlock = startContainerNode.parentBlock.parent;
|
|
@@ -1627,10 +2639,16 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1627
2639
|
listBlock.parent.apply(new RemoveChildAction(listBlock));
|
|
1628
2640
|
}
|
|
1629
2641
|
}
|
|
2642
|
+
/**
|
|
2643
|
+
* Copy the inline style to new node
|
|
2644
|
+
*
|
|
2645
|
+
* @param {RTETextNode} needCopedNode - The node that needed to be copied to
|
|
2646
|
+
* @returns {RTETextNode} Returns a `RTETextNode`.
|
|
2647
|
+
*/
|
|
1630
2648
|
copyInlineStyleToNewNode(needCopedNode) {
|
|
1631
2649
|
const textNode = needCopedNode.cloneWithText('');
|
|
1632
|
-
// The link annotation
|
|
1633
|
-
textNode.annotationMap.delete(
|
|
2650
|
+
// The link annotation doesn't need to inherit
|
|
2651
|
+
textNode.annotationMap.delete(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
1634
2652
|
return textNode;
|
|
1635
2653
|
}
|
|
1636
2654
|
}
|
|
@@ -1640,14 +2658,17 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1640
2658
|
*
|
|
1641
2659
|
* @example needRemovedNestList.parent.apply(new RemoveNestListAction(needRemovedNestList))
|
|
1642
2660
|
*/
|
|
1643
|
-
class RemoveNestListAction extends
|
|
2661
|
+
class RemoveNestListAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
1644
2662
|
constructor(childList) {
|
|
1645
2663
|
super();
|
|
1646
|
-
this.type =
|
|
2664
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.DELETE_NEST_LIST;
|
|
1647
2665
|
this.nestListBlockToBeRemoved = childList;
|
|
1648
2666
|
}
|
|
1649
2667
|
}
|
|
1650
2668
|
|
|
2669
|
+
/**
|
|
2670
|
+
* List block
|
|
2671
|
+
*/
|
|
1651
2672
|
class RTEListBlock extends RTEBlock {
|
|
1652
2673
|
constructor(id, type) {
|
|
1653
2674
|
super(id);
|
|
@@ -1655,6 +2676,12 @@ class RTEListBlock extends RTEBlock {
|
|
|
1655
2676
|
this.blocks = [];
|
|
1656
2677
|
this.type = type;
|
|
1657
2678
|
}
|
|
2679
|
+
/**
|
|
2680
|
+
* Converts a VegaRTEListBlock object to an RTEListBlock
|
|
2681
|
+
*
|
|
2682
|
+
* @param {VegaRTEListBlock} block - Converts a `VegaRTEListBlock` object into an `RTEListBlock`.
|
|
2683
|
+
* @returns {RTEListBlock} Return an instance of `RTEListBlock`
|
|
2684
|
+
*/
|
|
1658
2685
|
static from(block) {
|
|
1659
2686
|
const listBlock = new RTEListBlock(block.id, block.type);
|
|
1660
2687
|
listBlock.blocks = block.blocks.map((item) => {
|
|
@@ -1664,20 +2691,25 @@ class RTEListBlock extends RTEBlock {
|
|
|
1664
2691
|
});
|
|
1665
2692
|
return listBlock;
|
|
1666
2693
|
}
|
|
2694
|
+
/**
|
|
2695
|
+
* @inheritDoc
|
|
2696
|
+
*/
|
|
1667
2697
|
toJSON() {
|
|
1668
2698
|
return Object.assign(Object.assign({}, super.toJSON()), { id: this.id, type: this.type, blocks: this.blocks.map((block) => block.toJSON()) });
|
|
1669
2699
|
}
|
|
2700
|
+
/**
|
|
2701
|
+
* @inheritDoc
|
|
2702
|
+
*/
|
|
1670
2703
|
isNotEmpty() {
|
|
1671
2704
|
return (this.blocks.length > 0 &&
|
|
1672
2705
|
this.blocks.some((listItemBlock) => listItemBlock.isNotEmpty()));
|
|
1673
2706
|
}
|
|
2707
|
+
/**
|
|
2708
|
+
* @inheritDoc
|
|
2709
|
+
*/
|
|
1674
2710
|
getLastNode() {
|
|
1675
2711
|
return this.blocks[this.blocks.length - 1].getLastNode();
|
|
1676
2712
|
}
|
|
1677
|
-
render(renderContext) {
|
|
1678
|
-
const BlockTag = this.type === 'number-list' ? 'ol' : 'ul';
|
|
1679
|
-
return (globalSlimmerRegistry.h(BlockTag, { ref: this.registerRef.bind(this) }, this.blocks.map((block) => block.render(renderContext))));
|
|
1680
|
-
}
|
|
1681
2713
|
/**
|
|
1682
2714
|
* Apply a modify action to block
|
|
1683
2715
|
*
|
|
@@ -1685,46 +2717,52 @@ class RTEListBlock extends RTEBlock {
|
|
|
1685
2717
|
*/
|
|
1686
2718
|
doModifyActionApply(action) {
|
|
1687
2719
|
switch (action.type) {
|
|
1688
|
-
case
|
|
2720
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1689
2721
|
this.removeListItemBlock(action.entityToBeRemoved);
|
|
1690
2722
|
break;
|
|
1691
|
-
case
|
|
2723
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_AFTER:
|
|
1692
2724
|
this.replaceBlockWithBlocks(action.referBlock, [
|
|
1693
2725
|
action.referBlock,
|
|
1694
2726
|
...action.blocksToBeInserted,
|
|
1695
2727
|
]);
|
|
1696
2728
|
break;
|
|
1697
|
-
case
|
|
2729
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_BEFORE:
|
|
1698
2730
|
this.replaceBlockWithBlocks(action.referBlock, [
|
|
1699
2731
|
...action.blocksToBeInserted,
|
|
1700
2732
|
action.referBlock,
|
|
1701
2733
|
]);
|
|
1702
2734
|
break;
|
|
1703
|
-
case
|
|
2735
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1704
2736
|
this.appendChildBlocks(action.entityToBeAppended);
|
|
1705
2737
|
break;
|
|
1706
|
-
case
|
|
2738
|
+
case nodeAnnotation_abstract.ModifyContentActionType.TRANSFORM_LIST_BLOCK:
|
|
1707
2739
|
this.convertToList(action);
|
|
1708
2740
|
break;
|
|
1709
|
-
case
|
|
2741
|
+
case nodeAnnotation_abstract.ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK:
|
|
1710
2742
|
this.convertToParagraph(action);
|
|
1711
2743
|
break;
|
|
1712
|
-
case
|
|
2744
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1713
2745
|
this.insertImage(action);
|
|
1714
2746
|
break;
|
|
1715
2747
|
}
|
|
1716
2748
|
}
|
|
2749
|
+
/**
|
|
2750
|
+
* Converts a RTEListItemBlock to a RTETextBlock representing a paragraph.
|
|
2751
|
+
*
|
|
2752
|
+
* @param {RTEListItemBlock} block - The block that will be covered
|
|
2753
|
+
* @returns {RTETextBlock} Returns a `RTETextBlock`.
|
|
2754
|
+
*/
|
|
1717
2755
|
toParagraph(block) {
|
|
1718
2756
|
const textBlock = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
1719
2757
|
textBlock.apply(new AppendChildNodesAction(block['nodes']));
|
|
1720
2758
|
textBlock['annotationMap'] = block['annotationMap'];
|
|
1721
2759
|
return textBlock;
|
|
1722
2760
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
2761
|
+
/**
|
|
2762
|
+
* Covert block to List
|
|
2763
|
+
*
|
|
2764
|
+
* @param {TransformListAction} action - Modify action
|
|
2765
|
+
*/
|
|
1728
2766
|
convertToList(action) {
|
|
1729
2767
|
const selectedBlocks = action.selectedBlocks;
|
|
1730
2768
|
const bulletList = this.parent.createList(action.listType);
|
|
@@ -1734,7 +2772,7 @@ class RTEListBlock extends RTEBlock {
|
|
|
1734
2772
|
bulletList.apply(new AppendChildNodesAction(this.blocks));
|
|
1735
2773
|
this.parent.apply(new InsertBlocksAfterAction(this, bulletList));
|
|
1736
2774
|
this.parent.apply(new RemoveChildAction(this));
|
|
1737
|
-
selectedBlocks.forEach((block) => block.nodes.map((node) => node.apply(new
|
|
2775
|
+
selectedBlocks.forEach((block) => block.nodes.map((node) => node.apply(new SyncUpSelectionAction())));
|
|
1738
2776
|
}
|
|
1739
2777
|
else {
|
|
1740
2778
|
const listItems = action.selectedBlocks.map((block) => this.parent.toListItem(block));
|
|
@@ -1748,12 +2786,17 @@ class RTEListBlock extends RTEBlock {
|
|
|
1748
2786
|
}
|
|
1749
2787
|
}
|
|
1750
2788
|
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Covert block to paragraph
|
|
2791
|
+
*
|
|
2792
|
+
* @param {TransformListAction} action - Modify action
|
|
2793
|
+
*/
|
|
1751
2794
|
convertToParagraph(action) {
|
|
1752
2795
|
let isSelectedFirstBlock = false;
|
|
1753
2796
|
let isSelectedLastBlock = false;
|
|
1754
2797
|
const selectedBlocks = action.selectedBlocks;
|
|
1755
2798
|
const currentParagraph = selectedBlocks.map((block) => {
|
|
1756
|
-
block.nodes.map((node) => node.apply(new
|
|
2799
|
+
block.nodes.map((node) => node.apply(new SyncUpSelectionAction()));
|
|
1757
2800
|
if (block === this.blocks[0])
|
|
1758
2801
|
isSelectedFirstBlock = true;
|
|
1759
2802
|
if (block === this.blocks[this.blocks.length - 1])
|
|
@@ -1783,6 +2826,11 @@ class RTEListBlock extends RTEBlock {
|
|
|
1783
2826
|
this.parent.apply(new RemoveChildAction(this));
|
|
1784
2827
|
}
|
|
1785
2828
|
}
|
|
2829
|
+
/**
|
|
2830
|
+
* Inserts an image block into a rich text editor block based on the parent block type.
|
|
2831
|
+
*
|
|
2832
|
+
* @param {InsertImageToBlockAction} action - Modify action
|
|
2833
|
+
*/
|
|
1786
2834
|
insertImage(action) {
|
|
1787
2835
|
const imageBlock = action.imageBlockToBeInserted;
|
|
1788
2836
|
if (this.parent['type'] !== 'list-item') {
|
|
@@ -1792,10 +2840,15 @@ class RTEListBlock extends RTEBlock {
|
|
|
1792
2840
|
this.parent.apply(action);
|
|
1793
2841
|
}
|
|
1794
2842
|
}
|
|
2843
|
+
/**
|
|
2844
|
+
* Removes a specified block and handles the removal of nested lists if necessary.
|
|
2845
|
+
*
|
|
2846
|
+
* @param {RTEBlock} blockToBeRemoved - block that will be removed
|
|
2847
|
+
*/
|
|
1795
2848
|
removeListItemBlock(blockToBeRemoved) {
|
|
1796
2849
|
super.removeChildBlock(blockToBeRemoved);
|
|
1797
2850
|
if (this.blocks.length === 0 && this.parent) {
|
|
1798
|
-
// The parent is a list item mean the current block is a nest list, so we need use RemoveNestListAction to remove the item
|
|
2851
|
+
// The parent is a list item mean the current block is a nest list, so we need to use RemoveNestListAction to remove the item
|
|
1799
2852
|
if (this.parent instanceof RTEListItemBlock) {
|
|
1800
2853
|
this.parent.apply(new RemoveNestListAction(this));
|
|
1801
2854
|
}
|
|
@@ -1806,149 +2859,40 @@ class RTEListBlock extends RTEBlock {
|
|
|
1806
2859
|
}
|
|
1807
2860
|
}
|
|
1808
2861
|
|
|
1809
|
-
|
|
1810
|
-
* Class representing the content state of the rich text editor.
|
|
1811
|
-
*/
|
|
1812
|
-
class VegaRTEContent extends BlockBaseOperator {
|
|
1813
|
-
constructor(blocks) {
|
|
1814
|
-
super();
|
|
1815
|
-
blocks.forEach((block) => {
|
|
1816
|
-
block.parent = this;
|
|
1817
|
-
});
|
|
1818
|
-
this.blocks = blocks;
|
|
1819
|
-
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Converts a JSON array of blocks to a class array of RTEContentBlock.
|
|
1822
|
-
*
|
|
1823
|
-
* @param {VegaRTEContentBlock[]} value The JSON array of blocks to convert.
|
|
1824
|
-
* @returns {RTEContentBlock[]} The converted array of RTEContentBlock.
|
|
1825
|
-
*/
|
|
1826
|
-
static fromJSON(value) {
|
|
1827
|
-
const blocks = value.map((block) => {
|
|
1828
|
-
switch (block.type) {
|
|
1829
|
-
case 'paragraph':
|
|
1830
|
-
case 'title':
|
|
1831
|
-
case 'subtitle':
|
|
1832
|
-
case 'heading-1':
|
|
1833
|
-
case 'heading-2':
|
|
1834
|
-
case 'heading-3': {
|
|
1835
|
-
return RTETextBlock.from(block);
|
|
1836
|
-
}
|
|
1837
|
-
case 'image':
|
|
1838
|
-
return RTEImageBlock.from(block);
|
|
1839
|
-
case 'bullet-list':
|
|
1840
|
-
case 'number-list':
|
|
1841
|
-
return RTEListBlock.from(block);
|
|
1842
|
-
default: {
|
|
1843
|
-
throw new Error(`[Vega] Unknown block type: ${block.type}`);
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
});
|
|
1847
|
-
return new VegaRTEContent(blocks);
|
|
1848
|
-
}
|
|
1849
|
-
/**
|
|
1850
|
-
* Create an empty content state
|
|
1851
|
-
*
|
|
1852
|
-
* @returns {VegaRTEContent} An empty content state
|
|
1853
|
-
*/
|
|
1854
|
-
static createEmptyContent() {
|
|
1855
|
-
return VegaRTEContent.fromJSON([
|
|
1856
|
-
{
|
|
1857
|
-
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
1858
|
-
type: 'paragraph',
|
|
1859
|
-
nodes: [
|
|
1860
|
-
{
|
|
1861
|
-
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
1862
|
-
type: 'text',
|
|
1863
|
-
text: '',
|
|
1864
|
-
},
|
|
1865
|
-
],
|
|
1866
|
-
},
|
|
1867
|
-
]);
|
|
1868
|
-
}
|
|
1869
|
-
/**
|
|
1870
|
-
* Clones the content state.
|
|
1871
|
-
*
|
|
1872
|
-
* @returns {VegaRTEContent} The cloned content state.
|
|
1873
|
-
*/
|
|
1874
|
-
clone() {
|
|
1875
|
-
return new VegaRTEContent([...this.blocks]);
|
|
1876
|
-
}
|
|
1877
|
-
/**
|
|
1878
|
-
* Converts the content state to a JSON array of blocks.
|
|
1879
|
-
*
|
|
1880
|
-
* @returns {VegaRTEContentBlock[]} The JSON array of blocks.
|
|
1881
|
-
*/
|
|
1882
|
-
toJSON() {
|
|
1883
|
-
return this.blocks.map((block) => block.toJSON());
|
|
1884
|
-
}
|
|
1885
|
-
/**
|
|
1886
|
-
* Internal method to add the block item, remove the block item
|
|
1887
|
-
*
|
|
1888
|
-
* @param {ModifyContentAction} action - Modify content action
|
|
1889
|
-
*/
|
|
1890
|
-
apply(action) {
|
|
1891
|
-
switch (action.type) {
|
|
1892
|
-
case node_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1893
|
-
this.removeChildBlock(action.entityToBeRemoved);
|
|
1894
|
-
break;
|
|
1895
|
-
case node_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1896
|
-
this.appendChildBlocks(action.entityToBeAppended);
|
|
1897
|
-
break;
|
|
1898
|
-
case node_abstract.ModifyContentActionType.INSERT_BLOCKS_AFTER:
|
|
1899
|
-
this.replaceBlockWithBlocks(action.referBlock, [
|
|
1900
|
-
action.referBlock,
|
|
1901
|
-
...action.blocksToBeInserted,
|
|
1902
|
-
]);
|
|
1903
|
-
break;
|
|
1904
|
-
case node_abstract.ModifyContentActionType.INSERT_BLOCKS_BEFORE:
|
|
1905
|
-
this.replaceBlockWithBlocks(action.referBlock, [
|
|
1906
|
-
...action.blocksToBeInserted,
|
|
1907
|
-
action.referBlock,
|
|
1908
|
-
]);
|
|
1909
|
-
break;
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
/**
|
|
1913
|
-
* Convert text to list.
|
|
1914
|
-
*
|
|
1915
|
-
* @param {RTETextBlock} block - block
|
|
1916
|
-
* @returns {RTEListItemBlock} list item block dto.
|
|
1917
|
-
*/
|
|
1918
|
-
toListItem(block) {
|
|
1919
|
-
block.nodes.map((node) => node.apply(new textNode.SyncUpSelectionAction()));
|
|
1920
|
-
const listItemBlock = new RTEListItemBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1921
|
-
listItemBlock.apply(new AppendChildNodesAction(block['nodes']));
|
|
1922
|
-
listItemBlock['annotationMap'] = block['annotationMap'];
|
|
1923
|
-
return listItemBlock;
|
|
1924
|
-
}
|
|
1925
|
-
/**
|
|
1926
|
-
* create list.
|
|
1927
|
-
*
|
|
1928
|
-
* @param {ListType} type - type
|
|
1929
|
-
* @returns {RTEListBlock} list block dto.
|
|
1930
|
-
*/
|
|
1931
|
-
createList(type) {
|
|
1932
|
-
return new RTEListBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), type);
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
|
|
2862
|
+
exports.AnnotationAction = AnnotationAction;
|
|
1936
2863
|
exports.AppendChildNodesAction = AppendChildNodesAction;
|
|
2864
|
+
exports.BlockBaseOperator = BlockBaseOperator;
|
|
2865
|
+
exports.BoldAnnotation = BoldAnnotation;
|
|
1937
2866
|
exports.BoldAnnotationAction = BoldAnnotationAction;
|
|
2867
|
+
exports.ClearFormattingAnnotationAction = ClearFormattingAnnotationAction;
|
|
2868
|
+
exports.CodeAnnotationAction = CodeAnnotationAction;
|
|
1938
2869
|
exports.HorizontalAlignmentAnnotation = HorizontalAlignmentAnnotation;
|
|
1939
|
-
exports.
|
|
2870
|
+
exports.ImageAnnotation = ImageAnnotation;
|
|
1940
2871
|
exports.IndentAnnotation = IndentAnnotation;
|
|
1941
2872
|
exports.InsertBlocksAfterAction = InsertBlocksAfterAction;
|
|
1942
2873
|
exports.InsertBlocksBeforeAction = InsertBlocksBeforeAction;
|
|
2874
|
+
exports.ItalicAnnotation = ItalicAnnotation;
|
|
2875
|
+
exports.LinkAnnotationAction = LinkAnnotationAction;
|
|
1943
2876
|
exports.MergeTwoBlocksNodesAction = MergeTwoBlocksNodesAction;
|
|
1944
2877
|
exports.RTEImageBlock = RTEImageBlock;
|
|
1945
2878
|
exports.RTEImageNode = RTEImageNode;
|
|
1946
2879
|
exports.RTEListBlock = RTEListBlock;
|
|
1947
2880
|
exports.RTEListItemBlock = RTEListItemBlock;
|
|
1948
2881
|
exports.RTETextBlock = RTETextBlock;
|
|
2882
|
+
exports.RTETextNode = RTETextNode;
|
|
2883
|
+
exports.RTE_TEXT_COLORS = RTE_TEXT_COLORS;
|
|
1949
2884
|
exports.RemoveChildAction = RemoveChildAction;
|
|
1950
2885
|
exports.ReplaceChildNodesAction = ReplaceChildNodesAction;
|
|
2886
|
+
exports.SelectionRangeAnnotation = SelectionRangeAnnotation;
|
|
1951
2887
|
exports.SplitBlockWithNodeAction = SplitBlockWithNodeAction;
|
|
2888
|
+
exports.StrikethroughAnnotation = StrikethroughAnnotation;
|
|
2889
|
+
exports.SyncUpSelectionAction = SyncUpSelectionAction;
|
|
2890
|
+
exports.TextColorAnnotation = TextColorAnnotation;
|
|
2891
|
+
exports.TextSplittableAction = TextSplittableAction;
|
|
1952
2892
|
exports.TextStyleAnnotation = TextStyleAnnotation;
|
|
1953
2893
|
exports.TextStyleAnnotationAction = TextStyleAnnotationAction;
|
|
1954
|
-
exports.
|
|
2894
|
+
exports.UnderlineAnnotation = UnderlineAnnotation;
|
|
2895
|
+
exports.UpdateTextAction = UpdateTextAction;
|
|
2896
|
+
exports.ZERO_WIDTH_SPACE = ZERO_WIDTH_SPACE;
|
|
2897
|
+
exports.waitForComponentDidRender = waitForComponentDidRender;
|
|
2898
|
+
exports.waitForVega = waitForVega;
|