@heartlandone/vega 2.34.0 → 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-4e819773.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-b1c9f40e.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-3a2724f6.js → list-block-91116257.js} +1393 -679
- 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 +57 -52
- 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 +952 -737
- 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 +185 -183
- 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-pagination/vega-pagination.js +5 -2
- 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/bold-annotation.js +0 -10
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/code-annotation.js +0 -9
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.js +0 -44
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/image-annotation.js +0 -10
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/indent-annotation.js +0 -42
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/italic-annotation.js +0 -9
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/link-annotation.js +0 -14
- 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/annotations/strikethrough-annotation.js +0 -11
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-color-annotation.js +0 -26
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/text-style-annotation.js +0 -44
- package/dist/collection/components/vega-rich-text-editor/dto/annotations/underline-annotation.js +0 -11
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/block.abstract.js +0 -42
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/image-block.js +67 -26
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-block.js +45 -31
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/list-item-block.js +68 -35
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/text-block.js +113 -50
- package/dist/collection/components/vega-rich-text-editor/dto/nodes/image-node.js +23 -60
- 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 -51
- 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/slimmers/controllers/helper/element-to-dto-strategy/block-to-rte-block-strategy.abstract.js +258 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.js +71 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.js +70 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy.abstract.js +37 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy.js +55 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy.js +85 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/li-to-rte-list-item-block-strategy.js +49 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ol-to-rte-list-block-strategy.js +50 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy.js +60 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy.js +50 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-image-to-rte-image-block-strategy.js +56 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/input-event-handler/insert-paste-handler.js +7 -3
- 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/collection/components/vega-table/vega-table-head-cell/vega-table-head-cell.css +3 -0
- package/dist/esm/{app-globals-9971ccfd.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-d0255b98.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-acf55eb0.js → list-block-ba82c846.js} +1273 -577
- 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 +21 -16
- 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 +657 -442
- 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 +26 -24
- 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-pagination/vega-pagination.d.ts +1 -0
- 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/bold-annotation.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/dto/annotations/code-annotation.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/dto/annotations/horizontal-alignment-annotation.d.ts +0 -14
- package/dist/types/components/vega-rich-text-editor/dto/annotations/image-annotation.d.ts +0 -8
- package/dist/types/components/vega-rich-text-editor/dto/annotations/indent-annotation.d.ts +0 -14
- package/dist/types/components/vega-rich-text-editor/dto/annotations/italic-annotation.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/dto/annotations/link-annotation.d.ts +0 -7
- 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/annotations/strikethrough-annotation.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-color-annotation.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/dto/annotations/text-style-annotation.d.ts +0 -14
- package/dist/types/components/vega-rich-text-editor/dto/annotations/underline-annotation.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/dto/blocks/block.abstract.d.ts +2 -23
- package/dist/types/components/vega-rich-text-editor/dto/blocks/image-block.d.ts +68 -5
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-block.d.ts +45 -4
- package/dist/types/components/vega-rich-text-editor/dto/blocks/list-item-block.d.ts +68 -4
- package/dist/types/components/vega-rich-text-editor/dto/blocks/text-block.d.ts +110 -6
- package/dist/types/components/vega-rich-text-editor/dto/nodes/image-node.d.ts +21 -6
- 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 -4
- 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/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/block-to-rte-block-strategy.abstract.d.ts +111 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy.d.ts +32 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy-processor.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/element-to-dto-strategy.abstract.d.ts +32 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy.d.ts +31 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy.d.ts +38 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/li-to-rte-list-item-block-strategy.d.ts +35 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ol-to-rte-list-block-strategy.d.ts +36 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy.d.ts +31 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy.d.ts +36 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-strategy/vega-image-to-rte-image-block-strategy.d.ts +31 -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-0d12da5a.js +0 -1077
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-handler.abstract.js +0 -135
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-processor.js +0 -74
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/image-to-dto-handler.js +0 -47
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/inline-block-to-dto-handler.js +0 -39
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/link-to-dto-handler.js +0 -50
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-item-to-dto-handler.js +0 -41
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-to-dto-handler.js +0 -57
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/paragraph-to-dto-handler.js +0 -56
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-block-to-dto-handler.js +0 -77
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-to-dto-handler.js +0 -44
- package/dist/esm/text-node-6f7d736c.js +0 -1055
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-handler.abstract.d.ts +0 -67
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/element-to-dto-processor.d.ts +0 -29
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/image-to-dto-handler.d.ts +0 -37
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/inline-block-to-dto-handler.d.ts +0 -35
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/link-to-dto-handler.d.ts +0 -37
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-item-to-dto-handler.d.ts +0 -36
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/list-to-dto-handler.d.ts +0 -39
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/paragraph-to-dto-handler.d.ts +0 -39
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-block-to-dto-handler.d.ts +0 -46
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/helper/element-to-dto-handler/text-to-dto-handler.d.ts +0 -37
- package/dist/vega/p-034e6348.entry.js +0 -1
- package/dist/vega/p-0cd2b50f.entry.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-2fc3af2f.js +0 -1
- package/dist/vega/p-3039bef8.js +0 -1
- package/dist/vega/p-315667f1.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-49f4a666.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-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-728b029a.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-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-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-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-b6af0fc1.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-c1d97d12.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-d302f052.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-e43c2a27.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,51 +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 [
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Generate the map item for the annotation by html element
|
|
33
|
-
*
|
|
34
|
-
* @param {HTMLElement} node - An html element.
|
|
35
|
-
* @returns {[BlockAnnotationTypeEnum.ALIGNMENT, HorizontalAlignmentAnnotation]} Map item for the annotation
|
|
36
|
-
*/
|
|
37
|
-
static fromHTML(node) {
|
|
38
|
-
const alignment = this.getTextAlign(node);
|
|
39
|
-
return alignment ? this.from(alignment) : null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Get the text alignment of an HTML element.
|
|
43
|
-
*
|
|
44
|
-
* @param {HTMLElement} node - An HTMLElement.
|
|
45
|
-
* @returns {Nullable<VegaRTEBlockAlignment>} text alignment.
|
|
46
|
-
*/
|
|
47
|
-
static getTextAlign(node) {
|
|
48
|
-
const classList = node.classList;
|
|
49
|
-
if (classList.contains(`v-rte--horizontal-alignment-left`)) {
|
|
50
|
-
return 'left';
|
|
51
|
-
}
|
|
52
|
-
else if (classList.contains(`v-rte--horizontal-alignment-center`)) {
|
|
53
|
-
return 'center';
|
|
54
|
-
}
|
|
55
|
-
else if (classList.contains(`v-rte--horizontal-alignment-right`)) {
|
|
56
|
-
return 'right';
|
|
57
|
-
}
|
|
58
|
-
else if (classList.contains(`v-rte--horizontal-alignment-justify`)) {
|
|
59
|
-
return 'justify';
|
|
60
|
-
}
|
|
61
|
-
const style = node.style;
|
|
62
|
-
switch (style.textAlign) {
|
|
63
|
-
case 'center':
|
|
64
|
-
return 'center';
|
|
65
|
-
case 'right':
|
|
66
|
-
return 'right';
|
|
67
|
-
case 'justify':
|
|
68
|
-
return 'justify';
|
|
69
|
-
case 'left':
|
|
70
|
-
return 'left';
|
|
71
|
-
default:
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
60
|
+
return [nodeAnnotation_abstract.BlockAnnotationTypeEnum.ALIGNMENT, new HorizontalAlignmentAnnotation(textAlign)];
|
|
74
61
|
}
|
|
75
62
|
/**
|
|
76
63
|
* Generate the JSON item of the annotation
|
|
@@ -103,10 +90,10 @@ class HorizontalAlignmentAnnotation extends blockAnnotation_abstract.BlockAnnota
|
|
|
103
90
|
/**
|
|
104
91
|
* Annotation for block indentation
|
|
105
92
|
*/
|
|
106
|
-
class IndentAnnotation extends
|
|
93
|
+
class IndentAnnotation extends nodeAnnotation_abstract.BlockAnnotation {
|
|
107
94
|
constructor(indent) {
|
|
108
95
|
super();
|
|
109
|
-
this.type =
|
|
96
|
+
this.type = nodeAnnotation_abstract.BlockAnnotationTypeEnum.INDENT;
|
|
110
97
|
this.indent = Math.max(0, indent);
|
|
111
98
|
}
|
|
112
99
|
/**
|
|
@@ -116,49 +103,7 @@ class IndentAnnotation extends blockAnnotation_abstract.BlockAnnotation {
|
|
|
116
103
|
* @returns {[BlockAnnotationTypeEnum.INDENT, IndentAnnotation]} Map item for the annotation
|
|
117
104
|
*/
|
|
118
105
|
static from(indent) {
|
|
119
|
-
return [
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Generate the map item for the annotation by html element
|
|
123
|
-
*
|
|
124
|
-
* @param {HTMLElement} node - An html element.
|
|
125
|
-
* @returns {[BlockAnnotationTypeEnum.INDENT, IndentAnnotation]} Map item for the annotation
|
|
126
|
-
*/
|
|
127
|
-
static fromHTML(node) {
|
|
128
|
-
const marginLeft = this.getMarginLeft(node);
|
|
129
|
-
return marginLeft && marginLeft >= 0 ? this.from(Math.floor(marginLeft / 16)) : null;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Retrieves the left margin value of an HTML element.
|
|
133
|
-
*
|
|
134
|
-
* @param {HTMLElement} node - An html element.
|
|
135
|
-
* @returns {number} margin left.
|
|
136
|
-
*/
|
|
137
|
-
static getMarginLeft(node) {
|
|
138
|
-
const style = node.style;
|
|
139
|
-
let marginLeft;
|
|
140
|
-
if (style.marginLeft) {
|
|
141
|
-
marginLeft = style.marginLeft;
|
|
142
|
-
}
|
|
143
|
-
else if (style.margin) {
|
|
144
|
-
const margins = style.margin.split(' ');
|
|
145
|
-
switch (margins.length) {
|
|
146
|
-
case 4:
|
|
147
|
-
marginLeft = margins[3];
|
|
148
|
-
break;
|
|
149
|
-
case 2:
|
|
150
|
-
case 3:
|
|
151
|
-
marginLeft = margins[1];
|
|
152
|
-
break;
|
|
153
|
-
default:
|
|
154
|
-
marginLeft = margins[0];
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
return Number(marginLeft.replace('px', ''));
|
|
106
|
+
return [nodeAnnotation_abstract.BlockAnnotationTypeEnum.INDENT, new IndentAnnotation(indent)];
|
|
162
107
|
}
|
|
163
108
|
/**
|
|
164
109
|
* Generate the JSON item of the annotation
|
|
@@ -227,10 +172,10 @@ class BlockBaseOperator {
|
|
|
227
172
|
}
|
|
228
173
|
|
|
229
174
|
/** Append blocks or nodes to a block */
|
|
230
|
-
class AppendChildNodesAction extends
|
|
175
|
+
class AppendChildNodesAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
231
176
|
constructor(childNodes) {
|
|
232
177
|
super();
|
|
233
|
-
this.type =
|
|
178
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES;
|
|
234
179
|
this.entityToBeAppended = childNodes;
|
|
235
180
|
}
|
|
236
181
|
}
|
|
@@ -241,116 +186,47 @@ class AppendChildNodesAction extends node_abstract.ModifyContentAction {
|
|
|
241
186
|
* @example needRemovedNode.parentBlock.apply(new RemoveChildAction(needRemovedNode))
|
|
242
187
|
* @example needRemovedBlock.parent.apply(new RemoveChildAction(needRemovedBlock))
|
|
243
188
|
*/
|
|
244
|
-
class RemoveChildAction extends
|
|
189
|
+
class RemoveChildAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
245
190
|
constructor(childNode) {
|
|
246
191
|
super();
|
|
247
|
-
this.type =
|
|
192
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD;
|
|
248
193
|
this.entityToBeRemoved = childNode;
|
|
249
194
|
}
|
|
250
195
|
}
|
|
251
196
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
static getTextStyle(node) {
|
|
286
|
-
if (node.nodeType !== Node.TEXT_NODE && node.hasAttribute('data-type')) {
|
|
287
|
-
return node.getAttribute('data-type');
|
|
288
|
-
}
|
|
289
|
-
switch (node.style.fontSize) {
|
|
290
|
-
case '36px':
|
|
291
|
-
return 'title';
|
|
292
|
-
case '28px':
|
|
293
|
-
return 'subtitle';
|
|
294
|
-
case '22px':
|
|
295
|
-
return 'heading-1';
|
|
296
|
-
case '20px':
|
|
297
|
-
return 'heading-2';
|
|
298
|
-
case '18px':
|
|
299
|
-
return 'heading-3';
|
|
300
|
-
}
|
|
301
|
-
switch (node.nodeName) {
|
|
302
|
-
case 'H1':
|
|
303
|
-
return 'heading-1';
|
|
304
|
-
case 'H2':
|
|
305
|
-
return 'heading-2';
|
|
306
|
-
case 'H3':
|
|
307
|
-
return 'heading-3';
|
|
308
|
-
default:
|
|
309
|
-
return 'paragraph';
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Generate the JSON representation of the annotation
|
|
314
|
-
*
|
|
315
|
-
* @returns {Nullable<Record<string, unknown>>} JSON representation of the annotation
|
|
316
|
-
*/
|
|
317
|
-
toJSON() {
|
|
318
|
-
return { textStyle: this.textStyle };
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Render the styles by block type
|
|
322
|
-
*
|
|
323
|
-
* @returns {AnnotationStyle} the styles to apply
|
|
324
|
-
*/
|
|
325
|
-
render() {
|
|
326
|
-
const paragraphStyle = {
|
|
327
|
-
fontFamily: 'Inter',
|
|
328
|
-
fontSize: '16px',
|
|
329
|
-
lineHeight: '22px',
|
|
330
|
-
fontWeight: '500',
|
|
331
|
-
};
|
|
332
|
-
switch (this.textStyle) {
|
|
333
|
-
case 'paragraph': {
|
|
334
|
-
return paragraphStyle;
|
|
335
|
-
}
|
|
336
|
-
case 'title': {
|
|
337
|
-
return { fontFamily: 'Inter', fontSize: '36px', lineHeight: '40px', fontWeight: '500' };
|
|
338
|
-
}
|
|
339
|
-
case 'subtitle': {
|
|
340
|
-
return { fontFamily: 'Inter', fontSize: '28px', lineHeight: '32px', fontWeight: '500' };
|
|
341
|
-
}
|
|
342
|
-
case 'heading-1': {
|
|
343
|
-
return { fontFamily: 'Inter', fontSize: '22px', lineHeight: '24px', fontWeight: '500' };
|
|
344
|
-
}
|
|
345
|
-
case 'heading-2': {
|
|
346
|
-
return { fontFamily: 'Inter', fontSize: '20px', lineHeight: '24px', fontWeight: '500' };
|
|
347
|
-
}
|
|
348
|
-
case 'heading-3': {
|
|
349
|
-
return { fontFamily: 'Inter', fontSize: '18px', lineHeight: '22px', fontWeight: '500' };
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
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';
|
|
354
230
|
|
|
355
231
|
/**
|
|
356
232
|
* Abstract class for block
|
|
@@ -381,23 +257,6 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
381
257
|
return IndentAnnotation.from(value);
|
|
382
258
|
}
|
|
383
259
|
}
|
|
384
|
-
/**
|
|
385
|
-
* Create annotations for block element.
|
|
386
|
-
*
|
|
387
|
-
* @param {string} type - Annotations type.
|
|
388
|
-
* @param {HTMLElement} node - current node.
|
|
389
|
-
* @returns {Nullable<[BlockAnnotationTypeEnum, BlockAnnotation]>} - result.
|
|
390
|
-
*/
|
|
391
|
-
static createAnnotationEntityFromHTML(type, node) {
|
|
392
|
-
switch (type) {
|
|
393
|
-
case 'ALIGNMENT':
|
|
394
|
-
return HorizontalAlignmentAnnotation.fromHTML(node);
|
|
395
|
-
case 'TEXT_STYLE':
|
|
396
|
-
return TextStyleAnnotation.fromHTML(node);
|
|
397
|
-
case 'INDENT':
|
|
398
|
-
return IndentAnnotation.fromHTML(node);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
260
|
/**
|
|
402
261
|
* Class to JSON object
|
|
403
262
|
*
|
|
@@ -405,7 +264,7 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
405
264
|
*/
|
|
406
265
|
toJSON() {
|
|
407
266
|
const annotations = Array.from(this.annotationMap.values())
|
|
408
|
-
.filter((annotation) => annotation instanceof
|
|
267
|
+
.filter((annotation) => annotation instanceof nodeAnnotation_abstract.BlockAnnotation)
|
|
409
268
|
.reduce((record, annotation) => {
|
|
410
269
|
return Object.assign(Object.assign({}, record), annotation.toJSON());
|
|
411
270
|
}, {});
|
|
@@ -428,9 +287,9 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
428
287
|
apply(action) {
|
|
429
288
|
this.doApply(action);
|
|
430
289
|
if (action.isFlushable) {
|
|
431
|
-
const domNode =
|
|
290
|
+
const domNode = nodeAnnotation_abstract.stateEntityRenderingRegistry.getDOMByEntity(this);
|
|
432
291
|
if (domNode) {
|
|
433
|
-
const nodeSubject =
|
|
292
|
+
const nodeSubject = domNodeSubjectFactory.domNodeSubjectFactory.getSubjectFromParentNodeByEventId(domNode, vegaInternalEventId.VegaInternalRichTextEditorFlushChanges);
|
|
434
293
|
if (nodeSubject) {
|
|
435
294
|
changeManager.ChangeManager.notify(nodeSubject, {});
|
|
436
295
|
}
|
|
@@ -443,7 +302,7 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
443
302
|
* @param {AnnotationAction|ModifyContentAction} action - Annotation action
|
|
444
303
|
*/
|
|
445
304
|
doApply(action) {
|
|
446
|
-
if (action instanceof
|
|
305
|
+
if (action instanceof nodeAnnotation_abstract.ModifyContentAction) {
|
|
447
306
|
this.doModifyActionApply(action);
|
|
448
307
|
}
|
|
449
308
|
else {
|
|
@@ -460,29 +319,6 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
460
319
|
this.annotationMap.set(annotation.type, annotation);
|
|
461
320
|
typeof this.doAnnotationActionApply === 'function' && this.doAnnotationActionApply(action);
|
|
462
321
|
}
|
|
463
|
-
/**
|
|
464
|
-
* Get styles from annotations
|
|
465
|
-
*
|
|
466
|
-
* @returns {AnnotationStyle} - Annotation style
|
|
467
|
-
*/
|
|
468
|
-
getStyles() {
|
|
469
|
-
return Array.from(this.annotationMap.values())
|
|
470
|
-
.filter((annotation) => annotation instanceof blockAnnotation_abstract.BlockAnnotation)
|
|
471
|
-
.map((annotation) => annotation.render())
|
|
472
|
-
.filter(typeGuard.isNonNullable)
|
|
473
|
-
.reduce((current, obj) => (Object.assign(Object.assign({}, current), obj)), {});
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Get classes from annotations
|
|
477
|
-
*
|
|
478
|
-
* @returns {AnnotationStyle} - Annotation style
|
|
479
|
-
*/
|
|
480
|
-
getClasses() {
|
|
481
|
-
return Array.from(this.annotationMap.values())
|
|
482
|
-
.map((annotation) => { var _a; return (_a = annotation.renderClass) === null || _a === void 0 ? void 0 : _a.call(annotation); })
|
|
483
|
-
.filter(typeGuard.isNonNullable)
|
|
484
|
-
.reduce((pre, cur) => [pre, cur].join(' '), '');
|
|
485
|
-
}
|
|
486
322
|
/**
|
|
487
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.
|
|
488
324
|
*
|
|
@@ -503,7 +339,7 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
503
339
|
if (this.type === secondBlock.type || (this.type !== 'image' && secondBlock.type !== 'image')) {
|
|
504
340
|
let shouldMergeNodes = secondBlock['nodes'];
|
|
505
341
|
if (this.type !== 'image') {
|
|
506
|
-
shouldMergeNodes = secondBlock['nodes'].filter((node) => node['text'] && node['text'] !==
|
|
342
|
+
shouldMergeNodes = secondBlock['nodes'].filter((node) => node['text'] && node['text'] !== ZERO_WIDTH_SPACE);
|
|
507
343
|
}
|
|
508
344
|
this.apply(new AppendChildNodesAction(shouldMergeNodes));
|
|
509
345
|
secondBlock.parent.apply(new RemoveChildAction(secondBlock));
|
|
@@ -696,10 +532,10 @@ class RTEBlock extends BlockBaseOperator {
|
|
|
696
532
|
/**
|
|
697
533
|
* Annotation for image
|
|
698
534
|
*/
|
|
699
|
-
class ImageAnnotation extends
|
|
535
|
+
class ImageAnnotation extends nodeAnnotation_abstract.NodeAnnotation {
|
|
700
536
|
constructor(size = 'md', alt) {
|
|
701
537
|
super();
|
|
702
|
-
this.type =
|
|
538
|
+
this.type = nodeAnnotation_abstract.NodeAnnotationTypeEnum.IMAGE;
|
|
703
539
|
this.size = size;
|
|
704
540
|
this.alt = alt;
|
|
705
541
|
}
|
|
@@ -711,17 +547,7 @@ class ImageAnnotation extends node_abstract.NodeAnnotation {
|
|
|
711
547
|
* @returns {[NodeAnnotationTypeEnum.IMAGE, ImageAnnotation]} Map item for the annotation
|
|
712
548
|
*/
|
|
713
549
|
static from(size, alt) {
|
|
714
|
-
return [
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Generate the map item for the annotation
|
|
718
|
-
*
|
|
719
|
-
* @param {VegaRichTextImageEditorSizeType} size - size.
|
|
720
|
-
* @param {string} alt - alt.
|
|
721
|
-
* @returns {[NodeAnnotationTypeEnum.IMAGE, ImageAnnotation]} Map item for the annotation
|
|
722
|
-
*/
|
|
723
|
-
static fromHTML(size, alt) {
|
|
724
|
-
return this.from(size || 'md', alt);
|
|
550
|
+
return [nodeAnnotation_abstract.NodeAnnotationTypeEnum.IMAGE, new ImageAnnotation(size, alt)];
|
|
725
551
|
}
|
|
726
552
|
/**
|
|
727
553
|
* Generate the JSON representation of the annotation
|
|
@@ -759,57 +585,41 @@ class ImageAnnotation extends node_abstract.NodeAnnotation {
|
|
|
759
585
|
}
|
|
760
586
|
|
|
761
587
|
/**
|
|
762
|
-
*
|
|
588
|
+
* Image node
|
|
763
589
|
*/
|
|
764
|
-
class
|
|
765
|
-
constructor(size, alt) {
|
|
766
|
-
super();
|
|
767
|
-
this.isFlushable = true;
|
|
768
|
-
this.size = size;
|
|
769
|
-
this.alt = alt;
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Converts the action to an annotation
|
|
773
|
-
*
|
|
774
|
-
* @returns {ImageAnnotation} The annotation
|
|
775
|
-
*/
|
|
776
|
-
toAnnotation() {
|
|
777
|
-
return new ImageAnnotation(this.size, this.alt);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
class RTEImageNode extends node_abstract.RTENode {
|
|
590
|
+
class RTEImageNode extends nodeAnnotation_abstract.RTENode {
|
|
782
591
|
constructor(id, url, parentBlock, annotationMap) {
|
|
783
592
|
super(id, annotationMap);
|
|
784
|
-
this.type =
|
|
593
|
+
this.type = nodeAnnotation_abstract.NodeTypeEnum.IMAGE;
|
|
785
594
|
this.url = url;
|
|
786
595
|
this.parentBlock = parentBlock;
|
|
787
596
|
}
|
|
788
|
-
|
|
789
|
-
|
|
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);
|
|
790
606
|
let annotations;
|
|
791
|
-
if (!
|
|
607
|
+
if (!node.annotations || Object.keys(node.annotations).length === 0) {
|
|
792
608
|
annotations = { size: 'md' };
|
|
793
609
|
}
|
|
794
610
|
else {
|
|
795
|
-
annotations =
|
|
611
|
+
annotations = node.annotations;
|
|
796
612
|
}
|
|
797
613
|
imageNode.annotationMap = new Map(Object.keys(annotations)
|
|
798
614
|
.map(() => ImageAnnotation.from(annotations.size, annotations.alt))
|
|
799
615
|
.filter(typeGuard.isNonNullable));
|
|
800
616
|
return imageNode;
|
|
801
617
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
: node.querySelector('img').src;
|
|
806
|
-
const size = node.size;
|
|
807
|
-
const imageNode = new RTEImageNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), src, parentBlock);
|
|
808
|
-
imageNode.annotationMap = new Map([ImageAnnotation.fromHTML(size, node.alt)]);
|
|
809
|
-
return imageNode;
|
|
810
|
-
}
|
|
618
|
+
/**
|
|
619
|
+
* @inheritDoc
|
|
620
|
+
*/
|
|
811
621
|
toJSON() {
|
|
812
|
-
const imageAnnotation = this.annotationMap.get(
|
|
622
|
+
const imageAnnotation = this.annotationMap.get(nodeAnnotation_abstract.NodeAnnotationTypeEnum.IMAGE);
|
|
813
623
|
const annotations = {};
|
|
814
624
|
if (imageAnnotation === null || imageAnnotation === void 0 ? void 0 : imageAnnotation.size) {
|
|
815
625
|
annotations.size = imageAnnotation.size;
|
|
@@ -819,55 +629,20 @@ class RTEImageNode extends node_abstract.RTENode {
|
|
|
819
629
|
}
|
|
820
630
|
return Object.assign(Object.assign({ id: this.id }, (Object.keys(annotations).length > 0 ? { annotations } : {})), { type: 'image', url: this.url });
|
|
821
631
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
const alt = imageAnnotation === null || imageAnnotation === void 0 ? void 0 : imageAnnotation.alt;
|
|
826
|
-
const handleChange = ({ detail, }) => {
|
|
827
|
-
switch (detail.action) {
|
|
828
|
-
case 'edit': {
|
|
829
|
-
const size = detail.payload.size;
|
|
830
|
-
const alt = detail.payload.alt;
|
|
831
|
-
this.apply(new ImageAnnotationAction(size, alt));
|
|
832
|
-
break;
|
|
833
|
-
}
|
|
834
|
-
/*
|
|
835
|
-
* The below method is e2e-test covered in
|
|
836
|
-
* @see{module:vega-rich-text-editor-image-click-delete-button}
|
|
837
|
-
*/
|
|
838
|
-
/* istanbul ignore next */
|
|
839
|
-
case 'delete': {
|
|
840
|
-
const event = new InputEvent('beforeinput', {
|
|
841
|
-
inputType: 'deleteContentBackward',
|
|
842
|
-
bubbles: true,
|
|
843
|
-
});
|
|
844
|
-
setTimeout(() => {
|
|
845
|
-
node_abstract.stateEntityRenderingRegistry.getDOMByEntity(this).dispatchEvent(event);
|
|
846
|
-
}, 50);
|
|
847
|
-
break;
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
return editable ? (globalSlimmerRegistry.h("vega-rich-text-image-editor", { style: this.getStyles(), size: size, alt: alt, ref: (ref) => {
|
|
852
|
-
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, domNodeSubjectObserverFactory.VegaChange, handleChange);
|
|
853
|
-
} }, this.renderImage(editable, alt))) : (this.renderImage(editable, alt));
|
|
854
|
-
}
|
|
632
|
+
/**
|
|
633
|
+
* @inheritDoc
|
|
634
|
+
*/
|
|
855
635
|
doAnnotationActionApply(action) {
|
|
856
636
|
const annotation = action.toAnnotation();
|
|
857
637
|
this.annotationMap.set(annotation.type, annotation);
|
|
858
638
|
}
|
|
859
639
|
// placeholder method
|
|
860
640
|
/* istanbul ignore next */
|
|
641
|
+
/**
|
|
642
|
+
* @inheritDoc
|
|
643
|
+
*/
|
|
861
644
|
doModifyActionApply(action) {
|
|
862
645
|
}
|
|
863
|
-
registerRef(ref) {
|
|
864
|
-
if (ref) {
|
|
865
|
-
node_abstract.stateEntityRenderingRegistry.register(ref, this);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
renderImage(editable, alt) {
|
|
869
|
-
return (globalSlimmerRegistry.h("img", { style: editable ? { width: '100%' } : this.getStyles(), alt: alt, src: this.url, ref: this.registerRef.bind(this) }));
|
|
870
|
-
}
|
|
871
646
|
}
|
|
872
647
|
|
|
873
648
|
/**
|
|
@@ -875,10 +650,10 @@ class RTEImageNode extends node_abstract.RTENode {
|
|
|
875
650
|
*
|
|
876
651
|
* @example block.apply(new ReplaceChildNodesAction(newNodes))
|
|
877
652
|
*/
|
|
878
|
-
class ReplaceChildNodesAction extends
|
|
653
|
+
class ReplaceChildNodesAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
879
654
|
constructor(newChildNodes) {
|
|
880
655
|
super();
|
|
881
|
-
this.type =
|
|
656
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES;
|
|
882
657
|
this.newChildNodes = newChildNodes;
|
|
883
658
|
}
|
|
884
659
|
}
|
|
@@ -888,10 +663,10 @@ class ReplaceChildNodesAction extends node_abstract.ModifyContentAction {
|
|
|
888
663
|
*
|
|
889
664
|
* @example currentBlock.parent.apply(new InsertBlocksAfterAction(currentBlock, newBlock, ...))
|
|
890
665
|
*/
|
|
891
|
-
class InsertBlocksAfterAction extends
|
|
666
|
+
class InsertBlocksAfterAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
892
667
|
constructor(referBlock, ...blocksToBeInserted) {
|
|
893
668
|
super();
|
|
894
|
-
this.type =
|
|
669
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_AFTER;
|
|
895
670
|
this.referBlock = referBlock;
|
|
896
671
|
this.blocksToBeInserted = blocksToBeInserted;
|
|
897
672
|
}
|
|
@@ -903,19 +678,905 @@ class InsertBlocksAfterAction extends node_abstract.ModifyContentAction {
|
|
|
903
678
|
*
|
|
904
679
|
* @example block.apply(new SplitBlockWithNodeAction(node, offset))
|
|
905
680
|
*/
|
|
906
|
-
class SplitBlockWithNodeAction extends
|
|
681
|
+
class SplitBlockWithNodeAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
907
682
|
constructor(splitPointNode, startOffsetOfNode) {
|
|
908
683
|
super();
|
|
909
|
-
this.type =
|
|
684
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE;
|
|
910
685
|
this.splitPointNode = splitPointNode;
|
|
911
686
|
this.startOffsetOfNode = startOffsetOfNode;
|
|
912
687
|
}
|
|
913
688
|
}
|
|
914
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];
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Text style annotation
|
|
1517
|
+
*/
|
|
1518
|
+
class TextStyleAnnotation extends nodeAnnotation_abstract.BlockAnnotation {
|
|
1519
|
+
constructor(textStyle) {
|
|
1520
|
+
super();
|
|
1521
|
+
this.type = nodeAnnotation_abstract.BlockAnnotationTypeEnum.TEXT_STYLE;
|
|
1522
|
+
this.textStyle = textStyle;
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Generate the map item for the annotations
|
|
1526
|
+
*
|
|
1527
|
+
* @param {VegaRTETextStyleType} textStyle - the text style type
|
|
1528
|
+
* @returns {[BlockAnnotationTypeEnum.TEXT_STYLE, TextStyleAnnotation]} Map item for the annotation
|
|
1529
|
+
*/
|
|
1530
|
+
static from(textStyle) {
|
|
1531
|
+
return [nodeAnnotation_abstract.BlockAnnotationTypeEnum.TEXT_STYLE, new TextStyleAnnotation(textStyle)];
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Generate the JSON representation of the annotation
|
|
1535
|
+
*
|
|
1536
|
+
* @returns {Nullable<Record<string, unknown>>} JSON representation of the annotation
|
|
1537
|
+
*/
|
|
1538
|
+
toJSON() {
|
|
1539
|
+
return { textStyle: this.textStyle };
|
|
1540
|
+
}
|
|
1541
|
+
/**
|
|
1542
|
+
* Render the styles by block type
|
|
1543
|
+
*
|
|
1544
|
+
* @returns {AnnotationStyle} the styles to apply
|
|
1545
|
+
*/
|
|
1546
|
+
render() {
|
|
1547
|
+
const paragraphStyle = {
|
|
1548
|
+
fontFamily: 'Inter',
|
|
1549
|
+
fontSize: '16px',
|
|
1550
|
+
lineHeight: '22px',
|
|
1551
|
+
fontWeight: '500',
|
|
1552
|
+
};
|
|
1553
|
+
switch (this.textStyle) {
|
|
1554
|
+
case 'paragraph': {
|
|
1555
|
+
return paragraphStyle;
|
|
1556
|
+
}
|
|
1557
|
+
case 'title': {
|
|
1558
|
+
return { fontFamily: 'Inter', fontSize: '36px', lineHeight: '40px', fontWeight: '500' };
|
|
1559
|
+
}
|
|
1560
|
+
case 'subtitle': {
|
|
1561
|
+
return { fontFamily: 'Inter', fontSize: '28px', lineHeight: '32px', fontWeight: '500' };
|
|
1562
|
+
}
|
|
1563
|
+
case 'heading-1': {
|
|
1564
|
+
return { fontFamily: 'Inter', fontSize: '22px', lineHeight: '24px', fontWeight: '500' };
|
|
1565
|
+
}
|
|
1566
|
+
case 'heading-2': {
|
|
1567
|
+
return { fontFamily: 'Inter', fontSize: '20px', lineHeight: '24px', fontWeight: '500' };
|
|
1568
|
+
}
|
|
1569
|
+
case 'heading-3': {
|
|
1570
|
+
return { fontFamily: 'Inter', fontSize: '18px', lineHeight: '22px', fontWeight: '500' };
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
915
1576
|
/**
|
|
916
1577
|
* Action to change the text style of a block
|
|
917
1578
|
*/
|
|
918
|
-
class TextStyleAnnotationAction extends
|
|
1579
|
+
class TextStyleAnnotationAction extends AnnotationAction {
|
|
919
1580
|
constructor(textStyle, bold) {
|
|
920
1581
|
super();
|
|
921
1582
|
this.isFlushable = true;
|
|
@@ -935,7 +1596,7 @@ class TextStyleAnnotationAction extends textNode.AnnotationAction {
|
|
|
935
1596
|
/**
|
|
936
1597
|
* Action to toggle bold annotation
|
|
937
1598
|
*/
|
|
938
|
-
class BoldAnnotationAction extends
|
|
1599
|
+
class BoldAnnotationAction extends TextSplittableAction {
|
|
939
1600
|
constructor(bold) {
|
|
940
1601
|
super();
|
|
941
1602
|
this.isFlushable = true;
|
|
@@ -947,7 +1608,7 @@ class BoldAnnotationAction extends textNode.TextSplittableAction {
|
|
|
947
1608
|
* @returns {BoldAnnotation} the annotation
|
|
948
1609
|
*/
|
|
949
1610
|
toAnnotation() {
|
|
950
|
-
return new
|
|
1611
|
+
return new BoldAnnotation(this.bold);
|
|
951
1612
|
}
|
|
952
1613
|
}
|
|
953
1614
|
|
|
@@ -956,10 +1617,10 @@ class BoldAnnotationAction extends textNode.TextSplittableAction {
|
|
|
956
1617
|
*
|
|
957
1618
|
* @example firstBlock.apply(new MergeTwoBlocksNodesAction(secondBlock))
|
|
958
1619
|
*/
|
|
959
|
-
class MergeTwoBlocksNodesAction extends
|
|
1620
|
+
class MergeTwoBlocksNodesAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
960
1621
|
constructor(blockNeedToBeMerged) {
|
|
961
1622
|
super();
|
|
962
|
-
this.type =
|
|
1623
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES;
|
|
963
1624
|
this.blockNeedToBeMerged = blockNeedToBeMerged;
|
|
964
1625
|
}
|
|
965
1626
|
}
|
|
@@ -969,10 +1630,10 @@ class MergeTwoBlocksNodesAction extends node_abstract.ModifyContentAction {
|
|
|
969
1630
|
*
|
|
970
1631
|
* @example currentBlock.parent.apply(new InsertBlocksBeforeAction(currentBlock, newBlock, ...))
|
|
971
1632
|
*/
|
|
972
|
-
class InsertBlocksBeforeAction extends
|
|
1633
|
+
class InsertBlocksBeforeAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
973
1634
|
constructor(referBlock, ...blocksToBeInserted) {
|
|
974
1635
|
super();
|
|
975
|
-
this.type =
|
|
1636
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_BEFORE;
|
|
976
1637
|
this.referBlock = referBlock;
|
|
977
1638
|
this.blocksToBeInserted = blocksToBeInserted;
|
|
978
1639
|
}
|
|
@@ -987,16 +1648,22 @@ class RTETextBlock extends RTEBlock {
|
|
|
987
1648
|
this.nodes = [];
|
|
988
1649
|
this.type = type;
|
|
989
1650
|
if (RTETextBlock.isAcceptableTextStyle(type)) {
|
|
990
|
-
|
|
1651
|
+
this.annotationMap = new Map([TextStyleAnnotation.from(type)]);
|
|
991
1652
|
}
|
|
992
1653
|
else {
|
|
993
|
-
|
|
1654
|
+
this.annotationMap = new Map([TextStyleAnnotation.from('paragraph')]);
|
|
994
1655
|
}
|
|
995
1656
|
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Converts a VegaRTETextBlock into an RTETextBlock.
|
|
1659
|
+
*
|
|
1660
|
+
* @param {VegaRTETextBlock} block - The block object
|
|
1661
|
+
* @returns {RTETextBlock} A RTETextBlock class
|
|
1662
|
+
*/
|
|
996
1663
|
static from(block) {
|
|
997
1664
|
const textBlock = new RTETextBlock(block.id, block.type);
|
|
998
1665
|
const { annotations } = block;
|
|
999
|
-
textBlock.nodes = block.nodes.map((richText) =>
|
|
1666
|
+
textBlock.nodes = block.nodes.map((richText) => RTETextNode.from(richText, textBlock));
|
|
1000
1667
|
if (annotations) {
|
|
1001
1668
|
Object.entries(annotations).forEach(([type, value]) => {
|
|
1002
1669
|
const item = this.createAnnotationEntity(type, value);
|
|
@@ -1007,17 +1674,6 @@ class RTETextBlock extends RTEBlock {
|
|
|
1007
1674
|
}
|
|
1008
1675
|
return textBlock;
|
|
1009
1676
|
}
|
|
1010
|
-
static fromHTML(node, blockType) {
|
|
1011
|
-
const textBlock = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), blockType);
|
|
1012
|
-
textBlock.nodes = Array.from(node.childNodes).map((item) => textNode.RTETextNode.fromHTML(item, textBlock));
|
|
1013
|
-
Object.keys(blockAnnotation_abstract.BlockAnnotationTypeEnum).forEach((type) => {
|
|
1014
|
-
const item = this.createAnnotationEntityFromHTML(type, node);
|
|
1015
|
-
if (typeGuard.isNonNullable(item)) {
|
|
1016
|
-
textBlock.annotationMap.set(...item);
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
return textBlock;
|
|
1020
|
-
}
|
|
1021
1677
|
/**
|
|
1022
1678
|
* The function `createAnnotationEntity` creates a block annotation entity based on the provided type
|
|
1023
1679
|
* and value.
|
|
@@ -1038,15 +1694,26 @@ class RTETextBlock extends RTEBlock {
|
|
|
1038
1694
|
return super.createAnnotationEntity(type, value);
|
|
1039
1695
|
}
|
|
1040
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
|
+
*/
|
|
1041
1703
|
static isAcceptableTextStyle(type) {
|
|
1042
1704
|
return ['title', 'subtitle', 'paragraph', 'heading-1', 'heading-2', 'heading-3'].includes(type);
|
|
1043
1705
|
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Merges RTETextNode nodes based on certain conditions.
|
|
1708
|
+
*
|
|
1709
|
+
* @param {AnnotationAction} action - AnnotationAction
|
|
1710
|
+
*/
|
|
1044
1711
|
mergeNodes(action) {
|
|
1045
1712
|
this.nodes = this.nodes.reduce((prev, cur) => {
|
|
1046
1713
|
const lastNode = prev.at(-1);
|
|
1047
|
-
if (action instanceof
|
|
1048
|
-
const lastNodeLinkAnnotation = lastNode === null || lastNode === void 0 ? void 0 : lastNode.getAnnotationByType(
|
|
1049
|
-
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);
|
|
1050
1717
|
if (lastNodeLinkAnnotation &&
|
|
1051
1718
|
curNodeLinkAnnotation &&
|
|
1052
1719
|
lastNodeLinkAnnotation.toEqual(curNodeLinkAnnotation)) {
|
|
@@ -1057,38 +1724,39 @@ class RTETextBlock extends RTEBlock {
|
|
|
1057
1724
|
return [...prev, cur];
|
|
1058
1725
|
}, []);
|
|
1059
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* @inheritDoc
|
|
1729
|
+
*/
|
|
1060
1730
|
toJSON() {
|
|
1061
1731
|
return Object.assign(Object.assign({}, super.toJSON()), { type: this.type, nodes: this.nodes.map((node) => node.toJSON()) });
|
|
1062
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
|
+
*/
|
|
1063
1739
|
cloneWithNodes(nodes) {
|
|
1064
1740
|
const block = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), this.type);
|
|
1065
1741
|
block.nodes = [];
|
|
1066
1742
|
block.apply(new AppendChildNodesAction(nodes));
|
|
1067
1743
|
return block;
|
|
1068
1744
|
}
|
|
1745
|
+
/**
|
|
1746
|
+
* @inheritDoc
|
|
1747
|
+
*/
|
|
1069
1748
|
isNotEmpty() {
|
|
1070
1749
|
return this.nodes.length > 0 && this.nodes.some((node) => !node.isEmpty());
|
|
1071
1750
|
}
|
|
1751
|
+
/**
|
|
1752
|
+
* @inheritDoc
|
|
1753
|
+
*/
|
|
1072
1754
|
getLastNode() {
|
|
1073
1755
|
return this.nodes[this.nodes.length - 1];
|
|
1074
1756
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
this.renderNodes(renderContext),
|
|
1079
|
-
children));
|
|
1080
|
-
}
|
|
1081
|
-
registerRef(ref) {
|
|
1082
|
-
if (ref) {
|
|
1083
|
-
node_abstract.stateEntityRenderingRegistry.register(ref, this);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
renderNodes(renderConfig = {}) {
|
|
1087
|
-
const linkGroupAnnotation = this.getAnnotationByType(node_abstract.InternalAnnotationTypeEnum.LINK_GROUP);
|
|
1088
|
-
return linkGroupAnnotation
|
|
1089
|
-
? linkGroupAnnotation.renderNodes(this.nodes, renderConfig)
|
|
1090
|
-
: this.nodes.map((node) => node.render());
|
|
1091
|
-
}
|
|
1757
|
+
/**
|
|
1758
|
+
* @inheritDoc
|
|
1759
|
+
*/
|
|
1092
1760
|
doAnnotationActionApply(action) {
|
|
1093
1761
|
if (action instanceof TextStyleAnnotationAction) {
|
|
1094
1762
|
if (this.type !== 'list-item') {
|
|
@@ -1103,17 +1771,17 @@ class RTETextBlock extends RTEBlock {
|
|
|
1103
1771
|
}
|
|
1104
1772
|
else {
|
|
1105
1773
|
this.nodes.forEach((node) => {
|
|
1106
|
-
node.apply(new
|
|
1774
|
+
node.apply(new DeleteNodeAnnotationAction(nodeAnnotation_abstract.NodeAnnotationTypeEnum.BOLD));
|
|
1107
1775
|
});
|
|
1108
1776
|
}
|
|
1109
1777
|
return;
|
|
1110
1778
|
}
|
|
1111
|
-
if (action instanceof
|
|
1112
|
-
const linkGroupAnnotation = this.getAnnotationByType(
|
|
1779
|
+
if (action instanceof LinkGroupAnnotationAction) {
|
|
1780
|
+
const linkGroupAnnotation = this.getAnnotationByType(nodeAnnotation_abstract.InternalAnnotationTypeEnum.LINK_GROUP);
|
|
1113
1781
|
if (linkGroupAnnotation) {
|
|
1114
1782
|
const linkGroup = linkGroupAnnotation.linkGroups.get(action.groupKey);
|
|
1115
1783
|
linkGroupAnnotation.linkGroups.set(action.groupKey, [...linkGroup, ...action.nodes]);
|
|
1116
|
-
this.annotationMap.set(
|
|
1784
|
+
this.annotationMap.set(nodeAnnotation_abstract.InternalAnnotationTypeEnum.LINK_GROUP, linkGroupAnnotation);
|
|
1117
1785
|
}
|
|
1118
1786
|
return;
|
|
1119
1787
|
}
|
|
@@ -1125,44 +1793,44 @@ class RTETextBlock extends RTEBlock {
|
|
|
1125
1793
|
*/
|
|
1126
1794
|
doModifyActionApply(action) {
|
|
1127
1795
|
switch (action.type) {
|
|
1128
|
-
case
|
|
1796
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1129
1797
|
this.removeChildNode(action);
|
|
1130
1798
|
break;
|
|
1131
|
-
case
|
|
1799
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1132
1800
|
this.appendChildNodes(action.entityToBeAppended);
|
|
1133
1801
|
break;
|
|
1134
|
-
case
|
|
1802
|
+
case nodeAnnotation_abstract.ModifyContentActionType.CLEAR_CHILD_NODES:
|
|
1135
1803
|
this.nodes = [];
|
|
1136
1804
|
break;
|
|
1137
|
-
case
|
|
1805
|
+
case nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
|
|
1138
1806
|
action.newBlock = this.splitTextNodeBlock(action.splitPointNode, action.startOffsetOfNode);
|
|
1139
1807
|
break;
|
|
1140
|
-
case
|
|
1808
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES:
|
|
1141
1809
|
this.nodes = [];
|
|
1142
1810
|
this.appendChildNodes(action.newChildNodes);
|
|
1143
1811
|
break;
|
|
1144
|
-
case
|
|
1812
|
+
case nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
|
|
1145
1813
|
this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
|
|
1146
1814
|
break;
|
|
1147
|
-
case
|
|
1815
|
+
case nodeAnnotation_abstract.ModifyContentActionType.BREAK_SINGLE_BLOCK:
|
|
1148
1816
|
action.newBlock = this.breakSingleTextBlock(action.startContainerNode, action.startOffset);
|
|
1149
1817
|
break;
|
|
1150
|
-
case
|
|
1818
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
|
|
1151
1819
|
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1152
1820
|
break;
|
|
1153
|
-
case
|
|
1821
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
|
|
1154
1822
|
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
|
|
1155
1823
|
break;
|
|
1156
|
-
case
|
|
1824
|
+
case nodeAnnotation_abstract.ModifyContentActionType.TRANSFORM_LIST_BLOCK:
|
|
1157
1825
|
this.convertParagraphToList(action);
|
|
1158
1826
|
break;
|
|
1159
|
-
case
|
|
1827
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_BLOCK_CONTENT:
|
|
1160
1828
|
this.deleteNodeContent(action);
|
|
1161
1829
|
break;
|
|
1162
|
-
case
|
|
1830
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1163
1831
|
this.insertImage(action);
|
|
1164
1832
|
break;
|
|
1165
|
-
case
|
|
1833
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_BEFORE:
|
|
1166
1834
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1167
1835
|
...action.nodesToBeInserted,
|
|
1168
1836
|
action.referNode,
|
|
@@ -1170,6 +1838,13 @@ class RTETextBlock extends RTEBlock {
|
|
|
1170
1838
|
break;
|
|
1171
1839
|
}
|
|
1172
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
|
+
*/
|
|
1173
1848
|
splitTextNodeBlock(splitNode, startOffsetOfNode) {
|
|
1174
1849
|
if (splitNode) {
|
|
1175
1850
|
const beforeText = splitNode.text.slice(0, startOffsetOfNode);
|
|
@@ -1191,16 +1866,37 @@ class RTETextBlock extends RTEBlock {
|
|
|
1191
1866
|
}
|
|
1192
1867
|
}
|
|
1193
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
|
+
*/
|
|
1194
1876
|
isCaretPositionAtStart(node, startOffset) {
|
|
1195
1877
|
return node === this.nodes[0] && startOffset === 0;
|
|
1196
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
|
+
*/
|
|
1197
1886
|
isCaretPositionAtEnd(node, startOffset) {
|
|
1198
1887
|
const lastNode = this.nodes[this.nodes.length - 1];
|
|
1199
1888
|
return node === lastNode && (node.isEmpty() || startOffset === lastNode.text.length);
|
|
1200
1889
|
}
|
|
1890
|
+
/**
|
|
1891
|
+
* lineBreakSingleBlock
|
|
1892
|
+
*
|
|
1893
|
+
* @param {RTETextNode} splitNode -
|
|
1894
|
+
* @param {number} startOffsetOfNode -
|
|
1895
|
+
* @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
|
|
1896
|
+
*/
|
|
1201
1897
|
lineBreakSingleBlock(splitNode, startOffsetOfNode) {
|
|
1202
1898
|
if (splitNode) {
|
|
1203
|
-
const lineBreakNode = new
|
|
1899
|
+
const lineBreakNode = new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', this);
|
|
1204
1900
|
const beforeText = splitNode.text.slice(0, startOffsetOfNode);
|
|
1205
1901
|
const afterText = splitNode.text.slice(startOffsetOfNode);
|
|
1206
1902
|
const nodesSplitIndex = this.nodes.indexOf(splitNode);
|
|
@@ -1218,20 +1914,31 @@ class RTETextBlock extends RTEBlock {
|
|
|
1218
1914
|
return lineBreakNode;
|
|
1219
1915
|
}
|
|
1220
1916
|
}
|
|
1917
|
+
/**
|
|
1918
|
+
* lineBreakMultipleBlocks
|
|
1919
|
+
*
|
|
1920
|
+
* @param {RTEBlock[]} selectedBlocks -
|
|
1921
|
+
* @returns {Nullable<RTETextNode>} Nullable<RTETextNode>
|
|
1922
|
+
*/
|
|
1221
1923
|
lineBreakMultipleBlocks(selectedBlocks) {
|
|
1222
1924
|
const beforeNodes = this['nodes'];
|
|
1223
|
-
const lineBreakNode = new
|
|
1925
|
+
const lineBreakNode = new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', this);
|
|
1224
1926
|
const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
|
|
1225
1927
|
this.mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes);
|
|
1226
1928
|
return lineBreakNode;
|
|
1227
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* deleteNodeContent
|
|
1932
|
+
*
|
|
1933
|
+
* @param {DeleteBlockContentAction} action - ModifyContentAction
|
|
1934
|
+
*/
|
|
1228
1935
|
deleteNodeContent(action) {
|
|
1229
1936
|
const startContainerNode = action.startContainerNode;
|
|
1230
1937
|
const startOffset = action.startOffset;
|
|
1231
1938
|
if (startOffset !== 0 && !startContainerNode.isEmpty()) {
|
|
1232
1939
|
const newText = startContainerNode.text.slice(0, startOffset - 1) +
|
|
1233
1940
|
startContainerNode.text.slice(startOffset);
|
|
1234
|
-
startContainerNode.apply(new
|
|
1941
|
+
startContainerNode.apply(new UpdateTextAction(newText));
|
|
1235
1942
|
if (newText) {
|
|
1236
1943
|
action.previousNode = startContainerNode;
|
|
1237
1944
|
return;
|
|
@@ -1266,6 +1973,7 @@ class RTETextBlock extends RTEBlock {
|
|
|
1266
1973
|
}
|
|
1267
1974
|
/**
|
|
1268
1975
|
* Remove line break
|
|
1976
|
+
*
|
|
1269
1977
|
* @example caret at the first line
|
|
1270
1978
|
* \n
|
|
1271
1979
|
* test
|
|
@@ -1275,11 +1983,12 @@ class RTETextBlock extends RTEBlock {
|
|
|
1275
1983
|
}
|
|
1276
1984
|
/**
|
|
1277
1985
|
* Remove line break
|
|
1986
|
+
*
|
|
1278
1987
|
* @example caret at the begin of second line
|
|
1279
1988
|
* \n
|
|
1280
1989
|
* test
|
|
1281
1990
|
*/
|
|
1282
|
-
if (previousNode instanceof
|
|
1991
|
+
if (previousNode instanceof RTETextNode && previousNode.isEmpty()) {
|
|
1283
1992
|
const shouldRemoveNode = previousNode;
|
|
1284
1993
|
previousNode = this.getPreviousNode(previousNode);
|
|
1285
1994
|
shouldRemoveNode.parentBlock.apply(new RemoveChildAction(shouldRemoveNode));
|
|
@@ -1300,35 +2009,37 @@ class RTETextBlock extends RTEBlock {
|
|
|
1300
2009
|
}
|
|
1301
2010
|
}
|
|
1302
2011
|
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Remove the child node
|
|
2014
|
+
*
|
|
2015
|
+
* @param {RemoveChildAction} action - Modify action
|
|
2016
|
+
*/
|
|
1303
2017
|
removeChildNode(action) {
|
|
1304
2018
|
this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
|
|
1305
2019
|
if (this.nodes.length === 0) {
|
|
1306
2020
|
this.parent.apply(new RemoveChildAction(this));
|
|
1307
2021
|
}
|
|
1308
2022
|
}
|
|
2023
|
+
/**
|
|
2024
|
+
* mergeLineBreakNodes
|
|
2025
|
+
*
|
|
2026
|
+
* @param {RTENode[]} beforeNodes -
|
|
2027
|
+
* @param {RTETextNode} lineBreakNode -
|
|
2028
|
+
* @param {RTENode[]} afterNodes -
|
|
2029
|
+
*/
|
|
1309
2030
|
mergeLineBreakNodes(beforeNodes, lineBreakNode, afterNodes) {
|
|
1310
2031
|
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
1311
|
-
afterNodes.push(new
|
|
2032
|
+
afterNodes.push(new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', this, beforeNodes[beforeNodes.length - 1] && beforeNodes[beforeNodes.length - 1].annotationMap));
|
|
1312
2033
|
}
|
|
1313
2034
|
this.apply(new ReplaceChildNodesAction([...beforeNodes, lineBreakNode, ...afterNodes]));
|
|
1314
2035
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
case 'heading-2':
|
|
1323
|
-
return `h2`;
|
|
1324
|
-
case 'heading-3':
|
|
1325
|
-
return `h3`;
|
|
1326
|
-
case 'paragraph':
|
|
1327
|
-
return 'p';
|
|
1328
|
-
case 'list-item':
|
|
1329
|
-
return 'li';
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
2036
|
+
/**
|
|
2037
|
+
* breakSingleTextBlock
|
|
2038
|
+
*
|
|
2039
|
+
* @param {RTETextNode} splitNode -
|
|
2040
|
+
* @param {number} startOffsetOfNode -
|
|
2041
|
+
* @returns {Nullable<RTEBlock>} Nullable<RTEBlock>
|
|
2042
|
+
*/
|
|
1332
2043
|
breakSingleTextBlock(splitNode, startOffsetOfNode) {
|
|
1333
2044
|
const newParagraph = this.copyInlineStyleToNewParagraph(splitNode);
|
|
1334
2045
|
if (this.isCaretPositionAtEnd(splitNode, startOffsetOfNode)) {
|
|
@@ -1344,6 +2055,11 @@ class RTETextBlock extends RTEBlock {
|
|
|
1344
2055
|
}
|
|
1345
2056
|
return newParagraph;
|
|
1346
2057
|
}
|
|
2058
|
+
/**
|
|
2059
|
+
* convertParagraphToList
|
|
2060
|
+
*
|
|
2061
|
+
* @param {TransformListAction} action - ModifyContentAction
|
|
2062
|
+
*/
|
|
1347
2063
|
convertParagraphToList(action) {
|
|
1348
2064
|
const bulletList = this.parent.createList(action.listType);
|
|
1349
2065
|
const listItems = action.selectedBlocks.map((node) => this.parent.toListItem(node));
|
|
@@ -1353,6 +2069,11 @@ class RTETextBlock extends RTEBlock {
|
|
|
1353
2069
|
node.parent.apply(new RemoveChildAction(node));
|
|
1354
2070
|
});
|
|
1355
2071
|
}
|
|
2072
|
+
/**
|
|
2073
|
+
* insertImage
|
|
2074
|
+
*
|
|
2075
|
+
* @param {InsertImageToBlockAction} action - ModifyContentAction
|
|
2076
|
+
*/
|
|
1356
2077
|
insertImage(action) {
|
|
1357
2078
|
const splitNode = action.splitPointNode;
|
|
1358
2079
|
const startOffsetOfNode = action.startOffsetOfNode;
|
|
@@ -1369,10 +2090,16 @@ class RTETextBlock extends RTEBlock {
|
|
|
1369
2090
|
this.parent.apply(new InsertBlocksAfterAction(this, newImageBlock));
|
|
1370
2091
|
}
|
|
1371
2092
|
}
|
|
2093
|
+
/**
|
|
2094
|
+
* copyInlineStyleToNewParagraph
|
|
2095
|
+
*
|
|
2096
|
+
* @param {RTETextNode} needCopedNode -
|
|
2097
|
+
* @returns {RTETextBlock} RTETextBlock
|
|
2098
|
+
*/
|
|
1372
2099
|
copyInlineStyleToNewParagraph(needCopedNode) {
|
|
1373
2100
|
const textNode = needCopedNode.cloneWithText('');
|
|
1374
2101
|
// The link annotation don't need inherited
|
|
1375
|
-
textNode.annotationMap.delete(
|
|
2102
|
+
textNode.annotationMap.delete(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
1376
2103
|
const newParagraph = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
1377
2104
|
newParagraph.apply(new AppendChildNodesAction([textNode]));
|
|
1378
2105
|
return newParagraph;
|
|
@@ -1388,6 +2115,12 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1388
2115
|
this.type = 'image';
|
|
1389
2116
|
this.nodes = [];
|
|
1390
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
|
+
*/
|
|
1391
2124
|
static from(block) {
|
|
1392
2125
|
const imageBlock = new RTEImageBlock(block.id);
|
|
1393
2126
|
const { annotations } = block;
|
|
@@ -1402,80 +2135,72 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1402
2135
|
}
|
|
1403
2136
|
return imageBlock;
|
|
1404
2137
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
imageBlock.nodes = nodes.map((item) => RTEImageNode.fromHTML(item, imageBlock));
|
|
1409
|
-
Object.keys(blockAnnotation_abstract.BlockAnnotationTypeEnum).forEach((type) => {
|
|
1410
|
-
const item = this.createAnnotationEntityFromHTML(type, node);
|
|
1411
|
-
if (typeGuard.isNonNullable(item)) {
|
|
1412
|
-
imageBlock.annotationMap.set(...item);
|
|
1413
|
-
}
|
|
1414
|
-
});
|
|
1415
|
-
return imageBlock;
|
|
1416
|
-
}
|
|
2138
|
+
/**
|
|
2139
|
+
* @inheritDoc
|
|
2140
|
+
*/
|
|
1417
2141
|
toJSON() {
|
|
1418
2142
|
return Object.assign(Object.assign({}, super.toJSON()), { type: 'image', nodes: this.nodes.map((node) => node.toJSON()) });
|
|
1419
2143
|
}
|
|
2144
|
+
/**
|
|
2145
|
+
* @inheritDoc
|
|
2146
|
+
*/
|
|
1420
2147
|
isNotEmpty() {
|
|
1421
2148
|
return this.nodes.length > 0 && this.nodes.some((node) => node.url.length > 0);
|
|
1422
2149
|
}
|
|
2150
|
+
/**
|
|
2151
|
+
* @inheritDoc
|
|
2152
|
+
*/
|
|
1423
2153
|
getLastNode() {
|
|
1424
2154
|
return this.nodes[this.nodes.length - 1];
|
|
1425
2155
|
}
|
|
1426
|
-
render(renderContext) {
|
|
1427
|
-
return (globalSlimmerRegistry.h("div", { style: Object.assign({}, this.getStyles()), ref: this.registerRef.bind(this), class: super.getClasses() }, this.nodes.map((node) => {
|
|
1428
|
-
return node.render(renderContext);
|
|
1429
|
-
})));
|
|
1430
|
-
}
|
|
1431
2156
|
/**
|
|
1432
|
-
* Apply modify action to block
|
|
2157
|
+
* Apply a modify action to block
|
|
1433
2158
|
*
|
|
1434
2159
|
* @param {ModifyContentAction} action - Modify action
|
|
1435
2160
|
*/
|
|
1436
2161
|
doModifyActionApply(action) {
|
|
1437
2162
|
switch (action.type) {
|
|
1438
|
-
case
|
|
2163
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1439
2164
|
this.removeChildNode(action);
|
|
1440
2165
|
break;
|
|
1441
|
-
case
|
|
2166
|
+
case nodeAnnotation_abstract.ModifyContentActionType.CLEAR_CHILD_NODES:
|
|
1442
2167
|
this.nodes = [];
|
|
1443
2168
|
break;
|
|
1444
|
-
case
|
|
2169
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1445
2170
|
this.appendChildNodes(action.entityToBeAppended);
|
|
1446
2171
|
break;
|
|
1447
|
-
case
|
|
2172
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES:
|
|
1448
2173
|
this.nodes = [];
|
|
1449
2174
|
this.appendChildNodes(action.newChildNodes);
|
|
1450
2175
|
break;
|
|
1451
|
-
case
|
|
2176
|
+
case nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
|
|
1452
2177
|
action.newBlock = this.splitImageNodes(action.splitPointNode, action.startOffsetOfNode);
|
|
1453
2178
|
break;
|
|
1454
|
-
case
|
|
2179
|
+
case nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
|
|
1455
2180
|
this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
|
|
1456
2181
|
break;
|
|
1457
|
-
case
|
|
2182
|
+
case nodeAnnotation_abstract.ModifyContentActionType.BREAK_SINGLE_BLOCK:
|
|
1458
2183
|
action.newBlock = this.breakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1459
2184
|
break;
|
|
1460
|
-
case
|
|
2185
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
|
|
1461
2186
|
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1462
2187
|
break;
|
|
1463
|
-
case
|
|
2188
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
|
|
1464
2189
|
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
|
|
1465
2190
|
break;
|
|
1466
|
-
case
|
|
2191
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_BLOCK_CONTENT:
|
|
1467
2192
|
this.deleteNodeContent(action);
|
|
1468
2193
|
break;
|
|
1469
|
-
case
|
|
2194
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1470
2195
|
this.insertImage(action);
|
|
1471
2196
|
break;
|
|
1472
|
-
case
|
|
2197
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_AFTER:
|
|
1473
2198
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1474
2199
|
action.referNode,
|
|
1475
2200
|
...action.nodesToBeInserted,
|
|
1476
2201
|
]);
|
|
1477
2202
|
break;
|
|
1478
|
-
case
|
|
2203
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_BEFORE:
|
|
1479
2204
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1480
2205
|
...action.nodesToBeInserted,
|
|
1481
2206
|
action.referNode,
|
|
@@ -1483,11 +2208,11 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1483
2208
|
break;
|
|
1484
2209
|
}
|
|
1485
2210
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
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
|
+
*/
|
|
1491
2216
|
removeChildNode(action) {
|
|
1492
2217
|
this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
|
|
1493
2218
|
if (this.nodes.length === 0) {
|
|
@@ -1500,6 +2225,7 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1500
2225
|
*
|
|
1501
2226
|
* @param {RTEImageNode} imageNode The split point image node
|
|
1502
2227
|
* @param {number} imageOffset The cursor point 0 | 1
|
|
2228
|
+
* @returns {Nullable<RTEBlock>} The new block after split
|
|
1503
2229
|
*/
|
|
1504
2230
|
splitImageNodes(imageNode, imageOffset) {
|
|
1505
2231
|
const nodesSplitIndex = this.nodes.indexOf(imageNode);
|
|
@@ -1512,12 +2238,25 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1512
2238
|
return newBlock;
|
|
1513
2239
|
}
|
|
1514
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
|
+
*/
|
|
1515
2247
|
cloneWithNodes(nodes) {
|
|
1516
2248
|
const block = new RTEImageBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1517
2249
|
block.nodes = [];
|
|
1518
2250
|
block.apply(new AppendChildNodesAction(nodes));
|
|
1519
2251
|
return block;
|
|
1520
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
|
+
*/
|
|
1521
2260
|
breakSingleBlock(splitNode, startOffsetOfNode) {
|
|
1522
2261
|
const newParagraph = RTETextBlock.from({
|
|
1523
2262
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
@@ -1537,19 +2276,46 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1537
2276
|
}
|
|
1538
2277
|
return newParagraph;
|
|
1539
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
|
+
*/
|
|
1540
2286
|
lineBreakSingleBlock(splitNode, startOffset) {
|
|
1541
2287
|
const newParagraph = this.breakSingleBlock(splitNode, startOffset);
|
|
1542
2288
|
if (newParagraph) {
|
|
1543
2289
|
return newParagraph['nodes'][0];
|
|
1544
2290
|
}
|
|
1545
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
|
+
*/
|
|
1546
2299
|
isCaretPositionAtStart(node, startOffset) {
|
|
1547
2300
|
return node === this.nodes[0] && startOffset === 0;
|
|
1548
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
|
+
*/
|
|
1549
2309
|
isCaretPositionAtEnd(node, startOffset) {
|
|
1550
2310
|
const lastNode = this.nodes[this.nodes.length - 1];
|
|
1551
2311
|
return node === lastNode && startOffset === 1;
|
|
1552
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
|
+
*/
|
|
1553
2319
|
lineBreakMultipleBlocks(selectedBlocks) {
|
|
1554
2320
|
const newParagraph = RTETextBlock.from({
|
|
1555
2321
|
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
@@ -1559,11 +2325,16 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1559
2325
|
this.parent.apply(new InsertBlocksAfterAction(this, newParagraph));
|
|
1560
2326
|
const afterNodes = this.concatBlocksNodes(selectedBlocks.slice(1));
|
|
1561
2327
|
if (afterNodes.length === 0 || (afterNodes[0] && afterNodes[0].text === '')) {
|
|
1562
|
-
afterNodes.push(new
|
|
2328
|
+
afterNodes.push(new RTETextNode(createPublicApiRuntimeMetricsSlimmer.generateUUID(), '\n', newParagraph));
|
|
1563
2329
|
}
|
|
1564
2330
|
newParagraph.apply(new AppendChildNodesAction(afterNodes));
|
|
1565
2331
|
return newParagraph['nodes'][0];
|
|
1566
2332
|
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Deletes content from a block node based on specific conditions.
|
|
2335
|
+
*
|
|
2336
|
+
* @param {DeleteBlockContentAction} action - Delete block content action
|
|
2337
|
+
*/
|
|
1567
2338
|
deleteNodeContent(action) {
|
|
1568
2339
|
const startContainerNode = action
|
|
1569
2340
|
.startContainerNode, startOffset = action.startOffset;
|
|
@@ -1624,15 +2395,24 @@ class RTEImageBlock extends RTEBlock {
|
|
|
1624
2395
|
}
|
|
1625
2396
|
}
|
|
1626
2397
|
|
|
2398
|
+
/**
|
|
2399
|
+
* List item block
|
|
2400
|
+
*/
|
|
1627
2401
|
class RTEListItemBlock extends RTETextBlock {
|
|
1628
2402
|
constructor(id, children) {
|
|
1629
2403
|
super(id, 'list-item');
|
|
1630
2404
|
this.children = [];
|
|
1631
2405
|
this.children = children;
|
|
1632
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
|
+
*/
|
|
1633
2413
|
static from(block) {
|
|
1634
2414
|
const listItemBlock = new RTEListItemBlock(block.id);
|
|
1635
|
-
listItemBlock.nodes = block.nodes.map((richText) =>
|
|
2415
|
+
listItemBlock.nodes = block.nodes.map((richText) => RTETextNode.from(richText, listItemBlock));
|
|
1636
2416
|
if (block.children) {
|
|
1637
2417
|
listItemBlock.children = block.children.map((child) => {
|
|
1638
2418
|
const listBlock = RTEListBlock.from(child);
|
|
@@ -1651,42 +2431,25 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1651
2431
|
}
|
|
1652
2432
|
return listItemBlock;
|
|
1653
2433
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
.map((item) => {
|
|
1658
|
-
if (!['UL', 'OL'].includes(item.nodeName)) {
|
|
1659
|
-
return textNode.RTETextNode.fromHTML(item, listItem);
|
|
1660
|
-
}
|
|
1661
|
-
})
|
|
1662
|
-
.filter(Boolean);
|
|
1663
|
-
listItem.children = Array.from(node.childNodes)
|
|
1664
|
-
.map((item) => {
|
|
1665
|
-
if (['UL', 'OL'].includes(item.nodeName)) {
|
|
1666
|
-
const listBlock = RTEListBlock.fromHTML(item);
|
|
1667
|
-
listBlock && (listBlock.parent = listItem);
|
|
1668
|
-
return listBlock;
|
|
1669
|
-
}
|
|
1670
|
-
})
|
|
1671
|
-
.filter(Boolean);
|
|
1672
|
-
Object.keys(blockAnnotation_abstract.BlockAnnotationTypeEnum).forEach((type) => {
|
|
1673
|
-
const item = this.createAnnotationEntityFromHTML(type, node);
|
|
1674
|
-
if (typeGuard.isNonNullable(item)) {
|
|
1675
|
-
listItem.annotationMap.set(...item);
|
|
1676
|
-
}
|
|
1677
|
-
});
|
|
1678
|
-
return listItem;
|
|
1679
|
-
}
|
|
2434
|
+
/**
|
|
2435
|
+
* @inheritDoc
|
|
2436
|
+
*/
|
|
1680
2437
|
toJSON() {
|
|
1681
2438
|
var _a;
|
|
1682
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()) });
|
|
1683
2440
|
}
|
|
2441
|
+
/**
|
|
2442
|
+
* @inheritDoc
|
|
2443
|
+
*/
|
|
1684
2444
|
cloneWithNodes(nodes) {
|
|
1685
2445
|
const block = new RTEListItemBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1686
2446
|
block.nodes = [];
|
|
1687
2447
|
block.apply(new AppendChildNodesAction(nodes));
|
|
1688
2448
|
return block;
|
|
1689
2449
|
}
|
|
2450
|
+
/**
|
|
2451
|
+
* @inheritDoc
|
|
2452
|
+
*/
|
|
1690
2453
|
isNotEmpty() {
|
|
1691
2454
|
if (this.children) {
|
|
1692
2455
|
return super.isNotEmpty() || this.children.some((block) => block.isNotEmpty());
|
|
@@ -1695,6 +2458,9 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1695
2458
|
return super.isNotEmpty();
|
|
1696
2459
|
}
|
|
1697
2460
|
}
|
|
2461
|
+
/**
|
|
2462
|
+
* @inheritDoc
|
|
2463
|
+
*/
|
|
1698
2464
|
getLastNode() {
|
|
1699
2465
|
if (this.children && this.children.length > 0) {
|
|
1700
2466
|
const childListBlock = this.children[this.children.length - 1];
|
|
@@ -1702,9 +2468,6 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1702
2468
|
}
|
|
1703
2469
|
return super.getLastNode();
|
|
1704
2470
|
}
|
|
1705
|
-
render(renderContext) {
|
|
1706
|
-
return super.render(renderContext, this.renderChildren(renderContext));
|
|
1707
|
-
}
|
|
1708
2471
|
/**
|
|
1709
2472
|
* Apply a modify action to block
|
|
1710
2473
|
*
|
|
@@ -1712,47 +2475,47 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1712
2475
|
*/
|
|
1713
2476
|
doModifyActionApply(action) {
|
|
1714
2477
|
switch (action.type) {
|
|
1715
|
-
case
|
|
2478
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1716
2479
|
this.removeListChildNode(action);
|
|
1717
2480
|
break;
|
|
1718
|
-
case
|
|
2481
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_NEST_LIST:
|
|
1719
2482
|
this.removeNestList(action);
|
|
1720
2483
|
break;
|
|
1721
|
-
case
|
|
2484
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1722
2485
|
this.appendChildNodes(action.entityToBeAppended);
|
|
1723
2486
|
break;
|
|
1724
|
-
case
|
|
2487
|
+
case nodeAnnotation_abstract.ModifyContentActionType.CLEAR_CHILD_NODES:
|
|
1725
2488
|
this.nodes = [];
|
|
1726
2489
|
break;
|
|
1727
|
-
case
|
|
2490
|
+
case nodeAnnotation_abstract.ModifyContentActionType.SPLIT_BLOCK_WITH_NODE:
|
|
1728
2491
|
this.splitListItemBlock(action);
|
|
1729
2492
|
break;
|
|
1730
|
-
case
|
|
2493
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_CHILD_NODES:
|
|
1731
2494
|
this.nodes = [];
|
|
1732
2495
|
this.appendChildNodes(action.newChildNodes);
|
|
1733
2496
|
break;
|
|
1734
|
-
case
|
|
2497
|
+
case nodeAnnotation_abstract.ModifyContentActionType.REPLACE_NEST_LIST:
|
|
1735
2498
|
this.replaceNestList(action.newList);
|
|
1736
2499
|
break;
|
|
1737
|
-
case
|
|
2500
|
+
case nodeAnnotation_abstract.ModifyContentActionType.MERGE_TWO_BLOCKS_NODES:
|
|
1738
2501
|
this.mergeTwoBlocksNodes(action.blockNeedToBeMerged);
|
|
1739
2502
|
break;
|
|
1740
|
-
case
|
|
2503
|
+
case nodeAnnotation_abstract.ModifyContentActionType.BREAK_SINGLE_BLOCK:
|
|
1741
2504
|
action.newBlock = this.breakSingleListItemBlock(action.startContainerNode, action.startOffset);
|
|
1742
2505
|
break;
|
|
1743
|
-
case
|
|
2506
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_SINGLE_BLOCK:
|
|
1744
2507
|
action.lineBreakNode = this.lineBreakSingleBlock(action.startContainerNode, action.startOffset);
|
|
1745
2508
|
break;
|
|
1746
|
-
case
|
|
2509
|
+
case nodeAnnotation_abstract.ModifyContentActionType.LINE_BREAK_MULTIPLE_BLOCKS:
|
|
1747
2510
|
action.lineBreakNode = this.lineBreakMultipleBlocks(action.selectedBlocks);
|
|
1748
2511
|
break;
|
|
1749
|
-
case
|
|
2512
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_BLOCK_CONTENT:
|
|
1750
2513
|
this.deleteListNodeContent(action);
|
|
1751
2514
|
break;
|
|
1752
|
-
case
|
|
2515
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1753
2516
|
this.parent.apply(action);
|
|
1754
2517
|
break;
|
|
1755
|
-
case
|
|
2518
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_NODES_BEFORE:
|
|
1756
2519
|
this.replaceNodeWithNodes(action.referNode, [
|
|
1757
2520
|
...action.nodesToBeInserted,
|
|
1758
2521
|
action.referNode,
|
|
@@ -1760,16 +2523,22 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1760
2523
|
break;
|
|
1761
2524
|
}
|
|
1762
2525
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
2526
|
+
/**
|
|
2527
|
+
* Remove the list child node
|
|
2528
|
+
*
|
|
2529
|
+
* @param {RemoveChildAction} action - Modify action
|
|
2530
|
+
*/
|
|
1767
2531
|
removeListChildNode(action) {
|
|
1768
2532
|
this.nodes = this.nodes.filter((node) => node !== action.entityToBeRemoved);
|
|
1769
2533
|
if (this.nodes.length === 0 && (!this.children || !this.children.length)) {
|
|
1770
2534
|
this.parent.apply(new RemoveChildAction(this));
|
|
1771
2535
|
}
|
|
1772
2536
|
}
|
|
2537
|
+
/**
|
|
2538
|
+
* Remove the nest list
|
|
2539
|
+
*
|
|
2540
|
+
* @param {RemoveNestListAction} action - Modify action
|
|
2541
|
+
*/
|
|
1773
2542
|
removeNestList(action) {
|
|
1774
2543
|
if (this.children) {
|
|
1775
2544
|
if (this.children.length > 1) {
|
|
@@ -1780,15 +2549,34 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1780
2549
|
}
|
|
1781
2550
|
}
|
|
1782
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
|
+
*/
|
|
1783
2557
|
replaceNestList(newList) {
|
|
1784
2558
|
newList.forEach((listBlock) => {
|
|
1785
2559
|
listBlock.parent = this;
|
|
1786
2560
|
});
|
|
1787
2561
|
this.children = newList;
|
|
1788
2562
|
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Split list item block
|
|
2565
|
+
*
|
|
2566
|
+
* @param {SplitBlockWithNodeAction} action - Modify action
|
|
2567
|
+
*/
|
|
1789
2568
|
splitListItemBlock(action) {
|
|
1790
2569
|
action.newBlock = this.splitTextNodeBlock(action.splitPointNode, action.startOffsetOfNode);
|
|
1791
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
|
+
*/
|
|
1792
2580
|
breakSingleListItemBlock(splitNode, startOffsetOfNode) {
|
|
1793
2581
|
const newListItem = new RTEListItemBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
1794
2582
|
const newBreakNode = this.copyInlineStyleToNewNode(splitNode);
|
|
@@ -1806,6 +2594,12 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1806
2594
|
}
|
|
1807
2595
|
return newListItem;
|
|
1808
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
|
+
*/
|
|
1809
2603
|
breakListItemAtEnd(newListItem) {
|
|
1810
2604
|
const lastItem = this.parent.blocks[this.parent.blocks.length - 1];
|
|
1811
2605
|
const currentItemIsEmpty = this.nodes.length === 1 && this.nodes[0].isEmpty();
|
|
@@ -1832,6 +2626,11 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1832
2626
|
}
|
|
1833
2627
|
return newListItem;
|
|
1834
2628
|
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Delete list node content
|
|
2631
|
+
*
|
|
2632
|
+
* @param {DeleteBlockContentAction} action - Modify action
|
|
2633
|
+
*/
|
|
1835
2634
|
deleteListNodeContent(action) {
|
|
1836
2635
|
const startContainerNode = action.startContainerNode;
|
|
1837
2636
|
const listBlock = startContainerNode.parentBlock.parent;
|
|
@@ -1840,10 +2639,16 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1840
2639
|
listBlock.parent.apply(new RemoveChildAction(listBlock));
|
|
1841
2640
|
}
|
|
1842
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
|
+
*/
|
|
1843
2648
|
copyInlineStyleToNewNode(needCopedNode) {
|
|
1844
2649
|
const textNode = needCopedNode.cloneWithText('');
|
|
1845
|
-
// The link annotation
|
|
1846
|
-
textNode.annotationMap.delete(
|
|
2650
|
+
// The link annotation doesn't need to inherit
|
|
2651
|
+
textNode.annotationMap.delete(nodeAnnotation_abstract.NodeAnnotationTypeEnum.LINK);
|
|
1847
2652
|
return textNode;
|
|
1848
2653
|
}
|
|
1849
2654
|
}
|
|
@@ -1853,14 +2658,17 @@ class RTEListItemBlock extends RTETextBlock {
|
|
|
1853
2658
|
*
|
|
1854
2659
|
* @example needRemovedNestList.parent.apply(new RemoveNestListAction(needRemovedNestList))
|
|
1855
2660
|
*/
|
|
1856
|
-
class RemoveNestListAction extends
|
|
2661
|
+
class RemoveNestListAction extends nodeAnnotation_abstract.ModifyContentAction {
|
|
1857
2662
|
constructor(childList) {
|
|
1858
2663
|
super();
|
|
1859
|
-
this.type =
|
|
2664
|
+
this.type = nodeAnnotation_abstract.ModifyContentActionType.DELETE_NEST_LIST;
|
|
1860
2665
|
this.nestListBlockToBeRemoved = childList;
|
|
1861
2666
|
}
|
|
1862
2667
|
}
|
|
1863
2668
|
|
|
2669
|
+
/**
|
|
2670
|
+
* List block
|
|
2671
|
+
*/
|
|
1864
2672
|
class RTEListBlock extends RTEBlock {
|
|
1865
2673
|
constructor(id, type) {
|
|
1866
2674
|
super(id);
|
|
@@ -1868,6 +2676,12 @@ class RTEListBlock extends RTEBlock {
|
|
|
1868
2676
|
this.blocks = [];
|
|
1869
2677
|
this.type = type;
|
|
1870
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
|
+
*/
|
|
1871
2685
|
static from(block) {
|
|
1872
2686
|
const listBlock = new RTEListBlock(block.id, block.type);
|
|
1873
2687
|
listBlock.blocks = block.blocks.map((item) => {
|
|
@@ -1877,37 +2691,25 @@ class RTEListBlock extends RTEBlock {
|
|
|
1877
2691
|
});
|
|
1878
2692
|
return listBlock;
|
|
1879
2693
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
.map((item) => {
|
|
1884
|
-
const listItemBlock = RTEListItemBlock.fromHTML(item);
|
|
1885
|
-
listItemBlock && (listItemBlock.parent = listBlock);
|
|
1886
|
-
return listItemBlock;
|
|
1887
|
-
})
|
|
1888
|
-
.filter(Boolean);
|
|
1889
|
-
Object.keys(blockAnnotation_abstract.BlockAnnotationTypeEnum).forEach((type) => {
|
|
1890
|
-
const item = this.createAnnotationEntityFromHTML(type, node);
|
|
1891
|
-
if (typeGuard.isNonNullable(item)) {
|
|
1892
|
-
listBlock.annotationMap.set(...item);
|
|
1893
|
-
}
|
|
1894
|
-
});
|
|
1895
|
-
return listBlock;
|
|
1896
|
-
}
|
|
2694
|
+
/**
|
|
2695
|
+
* @inheritDoc
|
|
2696
|
+
*/
|
|
1897
2697
|
toJSON() {
|
|
1898
2698
|
return Object.assign(Object.assign({}, super.toJSON()), { id: this.id, type: this.type, blocks: this.blocks.map((block) => block.toJSON()) });
|
|
1899
2699
|
}
|
|
2700
|
+
/**
|
|
2701
|
+
* @inheritDoc
|
|
2702
|
+
*/
|
|
1900
2703
|
isNotEmpty() {
|
|
1901
2704
|
return (this.blocks.length > 0 &&
|
|
1902
2705
|
this.blocks.some((listItemBlock) => listItemBlock.isNotEmpty()));
|
|
1903
2706
|
}
|
|
2707
|
+
/**
|
|
2708
|
+
* @inheritDoc
|
|
2709
|
+
*/
|
|
1904
2710
|
getLastNode() {
|
|
1905
2711
|
return this.blocks[this.blocks.length - 1].getLastNode();
|
|
1906
2712
|
}
|
|
1907
|
-
render(renderContext) {
|
|
1908
|
-
const BlockTag = this.type === 'number-list' ? 'ol' : 'ul';
|
|
1909
|
-
return (globalSlimmerRegistry.h(BlockTag, { ref: this.registerRef.bind(this) }, this.blocks.map((block) => block.render(renderContext))));
|
|
1910
|
-
}
|
|
1911
2713
|
/**
|
|
1912
2714
|
* Apply a modify action to block
|
|
1913
2715
|
*
|
|
@@ -1915,46 +2717,52 @@ class RTEListBlock extends RTEBlock {
|
|
|
1915
2717
|
*/
|
|
1916
2718
|
doModifyActionApply(action) {
|
|
1917
2719
|
switch (action.type) {
|
|
1918
|
-
case
|
|
2720
|
+
case nodeAnnotation_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
1919
2721
|
this.removeListItemBlock(action.entityToBeRemoved);
|
|
1920
2722
|
break;
|
|
1921
|
-
case
|
|
2723
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_AFTER:
|
|
1922
2724
|
this.replaceBlockWithBlocks(action.referBlock, [
|
|
1923
2725
|
action.referBlock,
|
|
1924
2726
|
...action.blocksToBeInserted,
|
|
1925
2727
|
]);
|
|
1926
2728
|
break;
|
|
1927
|
-
case
|
|
2729
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_BLOCKS_BEFORE:
|
|
1928
2730
|
this.replaceBlockWithBlocks(action.referBlock, [
|
|
1929
2731
|
...action.blocksToBeInserted,
|
|
1930
2732
|
action.referBlock,
|
|
1931
2733
|
]);
|
|
1932
2734
|
break;
|
|
1933
|
-
case
|
|
2735
|
+
case nodeAnnotation_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
1934
2736
|
this.appendChildBlocks(action.entityToBeAppended);
|
|
1935
2737
|
break;
|
|
1936
|
-
case
|
|
2738
|
+
case nodeAnnotation_abstract.ModifyContentActionType.TRANSFORM_LIST_BLOCK:
|
|
1937
2739
|
this.convertToList(action);
|
|
1938
2740
|
break;
|
|
1939
|
-
case
|
|
2741
|
+
case nodeAnnotation_abstract.ModifyContentActionType.TRANSFORM_PARAGRAPH_BLOCK:
|
|
1940
2742
|
this.convertToParagraph(action);
|
|
1941
2743
|
break;
|
|
1942
|
-
case
|
|
2744
|
+
case nodeAnnotation_abstract.ModifyContentActionType.INSERT_IMAGE_TO_BLOCK:
|
|
1943
2745
|
this.insertImage(action);
|
|
1944
2746
|
break;
|
|
1945
2747
|
}
|
|
1946
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
|
+
*/
|
|
1947
2755
|
toParagraph(block) {
|
|
1948
2756
|
const textBlock = new RTETextBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), 'paragraph');
|
|
1949
2757
|
textBlock.apply(new AppendChildNodesAction(block['nodes']));
|
|
1950
2758
|
textBlock['annotationMap'] = block['annotationMap'];
|
|
1951
2759
|
return textBlock;
|
|
1952
2760
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
2761
|
+
/**
|
|
2762
|
+
* Covert block to List
|
|
2763
|
+
*
|
|
2764
|
+
* @param {TransformListAction} action - Modify action
|
|
2765
|
+
*/
|
|
1958
2766
|
convertToList(action) {
|
|
1959
2767
|
const selectedBlocks = action.selectedBlocks;
|
|
1960
2768
|
const bulletList = this.parent.createList(action.listType);
|
|
@@ -1964,7 +2772,7 @@ class RTEListBlock extends RTEBlock {
|
|
|
1964
2772
|
bulletList.apply(new AppendChildNodesAction(this.blocks));
|
|
1965
2773
|
this.parent.apply(new InsertBlocksAfterAction(this, bulletList));
|
|
1966
2774
|
this.parent.apply(new RemoveChildAction(this));
|
|
1967
|
-
selectedBlocks.forEach((block) => block.nodes.map((node) => node.apply(new
|
|
2775
|
+
selectedBlocks.forEach((block) => block.nodes.map((node) => node.apply(new SyncUpSelectionAction())));
|
|
1968
2776
|
}
|
|
1969
2777
|
else {
|
|
1970
2778
|
const listItems = action.selectedBlocks.map((block) => this.parent.toListItem(block));
|
|
@@ -1978,12 +2786,17 @@ class RTEListBlock extends RTEBlock {
|
|
|
1978
2786
|
}
|
|
1979
2787
|
}
|
|
1980
2788
|
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Covert block to paragraph
|
|
2791
|
+
*
|
|
2792
|
+
* @param {TransformListAction} action - Modify action
|
|
2793
|
+
*/
|
|
1981
2794
|
convertToParagraph(action) {
|
|
1982
2795
|
let isSelectedFirstBlock = false;
|
|
1983
2796
|
let isSelectedLastBlock = false;
|
|
1984
2797
|
const selectedBlocks = action.selectedBlocks;
|
|
1985
2798
|
const currentParagraph = selectedBlocks.map((block) => {
|
|
1986
|
-
block.nodes.map((node) => node.apply(new
|
|
2799
|
+
block.nodes.map((node) => node.apply(new SyncUpSelectionAction()));
|
|
1987
2800
|
if (block === this.blocks[0])
|
|
1988
2801
|
isSelectedFirstBlock = true;
|
|
1989
2802
|
if (block === this.blocks[this.blocks.length - 1])
|
|
@@ -2013,6 +2826,11 @@ class RTEListBlock extends RTEBlock {
|
|
|
2013
2826
|
this.parent.apply(new RemoveChildAction(this));
|
|
2014
2827
|
}
|
|
2015
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
|
+
*/
|
|
2016
2834
|
insertImage(action) {
|
|
2017
2835
|
const imageBlock = action.imageBlockToBeInserted;
|
|
2018
2836
|
if (this.parent['type'] !== 'list-item') {
|
|
@@ -2022,10 +2840,15 @@ class RTEListBlock extends RTEBlock {
|
|
|
2022
2840
|
this.parent.apply(action);
|
|
2023
2841
|
}
|
|
2024
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
|
+
*/
|
|
2025
2848
|
removeListItemBlock(blockToBeRemoved) {
|
|
2026
2849
|
super.removeChildBlock(blockToBeRemoved);
|
|
2027
2850
|
if (this.blocks.length === 0 && this.parent) {
|
|
2028
|
-
// 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
|
|
2029
2852
|
if (this.parent instanceof RTEListItemBlock) {
|
|
2030
2853
|
this.parent.apply(new RemoveNestListAction(this));
|
|
2031
2854
|
}
|
|
@@ -2036,149 +2859,40 @@ class RTEListBlock extends RTEBlock {
|
|
|
2036
2859
|
}
|
|
2037
2860
|
}
|
|
2038
2861
|
|
|
2039
|
-
|
|
2040
|
-
* Class representing the content state of the rich text editor.
|
|
2041
|
-
*/
|
|
2042
|
-
class VegaRTEContent extends BlockBaseOperator {
|
|
2043
|
-
constructor(blocks) {
|
|
2044
|
-
super();
|
|
2045
|
-
blocks.forEach((block) => {
|
|
2046
|
-
block.parent = this;
|
|
2047
|
-
});
|
|
2048
|
-
this.blocks = blocks;
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* Converts a JSON array of blocks to a class array of RTEContentBlock.
|
|
2052
|
-
*
|
|
2053
|
-
* @param {VegaRTEContentBlock[]} value The JSON array of blocks to convert.
|
|
2054
|
-
* @returns {RTEContentBlock[]} The converted array of RTEContentBlock.
|
|
2055
|
-
*/
|
|
2056
|
-
static fromJSON(value) {
|
|
2057
|
-
const blocks = value.map((block) => {
|
|
2058
|
-
switch (block.type) {
|
|
2059
|
-
case 'paragraph':
|
|
2060
|
-
case 'title':
|
|
2061
|
-
case 'subtitle':
|
|
2062
|
-
case 'heading-1':
|
|
2063
|
-
case 'heading-2':
|
|
2064
|
-
case 'heading-3': {
|
|
2065
|
-
return RTETextBlock.from(block);
|
|
2066
|
-
}
|
|
2067
|
-
case 'image':
|
|
2068
|
-
return RTEImageBlock.from(block);
|
|
2069
|
-
case 'bullet-list':
|
|
2070
|
-
case 'number-list':
|
|
2071
|
-
return RTEListBlock.from(block);
|
|
2072
|
-
default: {
|
|
2073
|
-
throw new Error(`[Vega] Unknown block type: ${block.type}`);
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
});
|
|
2077
|
-
return new VegaRTEContent(blocks);
|
|
2078
|
-
}
|
|
2079
|
-
/**
|
|
2080
|
-
* Create an empty content state
|
|
2081
|
-
*
|
|
2082
|
-
* @returns {VegaRTEContent} An empty content state
|
|
2083
|
-
*/
|
|
2084
|
-
static createEmptyContent() {
|
|
2085
|
-
return VegaRTEContent.fromJSON([
|
|
2086
|
-
{
|
|
2087
|
-
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
2088
|
-
type: 'paragraph',
|
|
2089
|
-
nodes: [
|
|
2090
|
-
{
|
|
2091
|
-
id: createPublicApiRuntimeMetricsSlimmer.generateUUID(),
|
|
2092
|
-
type: 'text',
|
|
2093
|
-
text: '',
|
|
2094
|
-
},
|
|
2095
|
-
],
|
|
2096
|
-
},
|
|
2097
|
-
]);
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* Clones the content state.
|
|
2101
|
-
*
|
|
2102
|
-
* @returns {VegaRTEContent} The cloned content state.
|
|
2103
|
-
*/
|
|
2104
|
-
clone() {
|
|
2105
|
-
return new VegaRTEContent([...this.blocks]);
|
|
2106
|
-
}
|
|
2107
|
-
/**
|
|
2108
|
-
* Converts the content state to a JSON array of blocks.
|
|
2109
|
-
*
|
|
2110
|
-
* @returns {VegaRTEContentBlock[]} The JSON array of blocks.
|
|
2111
|
-
*/
|
|
2112
|
-
toJSON() {
|
|
2113
|
-
return this.blocks.map((block) => block.toJSON());
|
|
2114
|
-
}
|
|
2115
|
-
/**
|
|
2116
|
-
* Internal method to add the block item, remove the block item
|
|
2117
|
-
*
|
|
2118
|
-
* @param {ModifyContentAction} action - Modify content action
|
|
2119
|
-
*/
|
|
2120
|
-
apply(action) {
|
|
2121
|
-
switch (action.type) {
|
|
2122
|
-
case node_abstract.ModifyContentActionType.DELETE_CHILD:
|
|
2123
|
-
this.removeChildBlock(action.entityToBeRemoved);
|
|
2124
|
-
break;
|
|
2125
|
-
case node_abstract.ModifyContentActionType.APPEND_CHILD_NODES:
|
|
2126
|
-
this.appendChildBlocks(action.entityToBeAppended);
|
|
2127
|
-
break;
|
|
2128
|
-
case node_abstract.ModifyContentActionType.INSERT_BLOCKS_AFTER:
|
|
2129
|
-
this.replaceBlockWithBlocks(action.referBlock, [
|
|
2130
|
-
action.referBlock,
|
|
2131
|
-
...action.blocksToBeInserted,
|
|
2132
|
-
]);
|
|
2133
|
-
break;
|
|
2134
|
-
case node_abstract.ModifyContentActionType.INSERT_BLOCKS_BEFORE:
|
|
2135
|
-
this.replaceBlockWithBlocks(action.referBlock, [
|
|
2136
|
-
...action.blocksToBeInserted,
|
|
2137
|
-
action.referBlock,
|
|
2138
|
-
]);
|
|
2139
|
-
break;
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
/**
|
|
2143
|
-
* Convert text to list.
|
|
2144
|
-
*
|
|
2145
|
-
* @param {RTETextBlock} block - block
|
|
2146
|
-
* @returns {RTEListItemBlock} list item block dto.
|
|
2147
|
-
*/
|
|
2148
|
-
toListItem(block) {
|
|
2149
|
-
block.nodes.map((node) => node.apply(new textNode.SyncUpSelectionAction()));
|
|
2150
|
-
const listItemBlock = new RTEListItemBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID());
|
|
2151
|
-
listItemBlock.apply(new AppendChildNodesAction(block['nodes']));
|
|
2152
|
-
listItemBlock['annotationMap'] = block['annotationMap'];
|
|
2153
|
-
return listItemBlock;
|
|
2154
|
-
}
|
|
2155
|
-
/**
|
|
2156
|
-
* create list.
|
|
2157
|
-
*
|
|
2158
|
-
* @param {ListType} type - type
|
|
2159
|
-
* @returns {RTEListBlock} list block dto.
|
|
2160
|
-
*/
|
|
2161
|
-
createList(type) {
|
|
2162
|
-
return new RTEListBlock(createPublicApiRuntimeMetricsSlimmer.generateUUID(), type);
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2862
|
+
exports.AnnotationAction = AnnotationAction;
|
|
2166
2863
|
exports.AppendChildNodesAction = AppendChildNodesAction;
|
|
2864
|
+
exports.BlockBaseOperator = BlockBaseOperator;
|
|
2865
|
+
exports.BoldAnnotation = BoldAnnotation;
|
|
2167
2866
|
exports.BoldAnnotationAction = BoldAnnotationAction;
|
|
2867
|
+
exports.ClearFormattingAnnotationAction = ClearFormattingAnnotationAction;
|
|
2868
|
+
exports.CodeAnnotationAction = CodeAnnotationAction;
|
|
2168
2869
|
exports.HorizontalAlignmentAnnotation = HorizontalAlignmentAnnotation;
|
|
2169
|
-
exports.
|
|
2870
|
+
exports.ImageAnnotation = ImageAnnotation;
|
|
2170
2871
|
exports.IndentAnnotation = IndentAnnotation;
|
|
2171
2872
|
exports.InsertBlocksAfterAction = InsertBlocksAfterAction;
|
|
2172
2873
|
exports.InsertBlocksBeforeAction = InsertBlocksBeforeAction;
|
|
2874
|
+
exports.ItalicAnnotation = ItalicAnnotation;
|
|
2875
|
+
exports.LinkAnnotationAction = LinkAnnotationAction;
|
|
2173
2876
|
exports.MergeTwoBlocksNodesAction = MergeTwoBlocksNodesAction;
|
|
2174
2877
|
exports.RTEImageBlock = RTEImageBlock;
|
|
2175
2878
|
exports.RTEImageNode = RTEImageNode;
|
|
2176
2879
|
exports.RTEListBlock = RTEListBlock;
|
|
2177
2880
|
exports.RTEListItemBlock = RTEListItemBlock;
|
|
2178
2881
|
exports.RTETextBlock = RTETextBlock;
|
|
2882
|
+
exports.RTETextNode = RTETextNode;
|
|
2883
|
+
exports.RTE_TEXT_COLORS = RTE_TEXT_COLORS;
|
|
2179
2884
|
exports.RemoveChildAction = RemoveChildAction;
|
|
2180
2885
|
exports.ReplaceChildNodesAction = ReplaceChildNodesAction;
|
|
2886
|
+
exports.SelectionRangeAnnotation = SelectionRangeAnnotation;
|
|
2181
2887
|
exports.SplitBlockWithNodeAction = SplitBlockWithNodeAction;
|
|
2888
|
+
exports.StrikethroughAnnotation = StrikethroughAnnotation;
|
|
2889
|
+
exports.SyncUpSelectionAction = SyncUpSelectionAction;
|
|
2890
|
+
exports.TextColorAnnotation = TextColorAnnotation;
|
|
2891
|
+
exports.TextSplittableAction = TextSplittableAction;
|
|
2182
2892
|
exports.TextStyleAnnotation = TextStyleAnnotation;
|
|
2183
2893
|
exports.TextStyleAnnotationAction = TextStyleAnnotationAction;
|
|
2184
|
-
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;
|