@wordpress/block-editor 8.6.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +5 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -6
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-content-overlay/index.js +4 -82
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +65 -0
- package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build/components/block-draggable/index.native.js +488 -0
- package/build/components/block-draggable/index.native.js.map +1 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build/components/block-list/block-list-context.native.js +195 -0
- package/build/components/block-list/block-list-context.native.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +67 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build/components/block-list/block-list-item.native.js +12 -9
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block.native.js +27 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +34 -32
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +75 -23
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -4
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +10 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/index.native.js +17 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +19 -8
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +20 -16
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -0
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -29
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +16 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +10 -3
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +122 -41
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +22 -5
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/iframe/index.js +51 -50
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +3 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/index.js +14 -23
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.js +21 -7
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +2 -2
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -5
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/link-control/constants.js +11 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-results.js +4 -3
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +4 -4
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +0 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +10 -4
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +62 -7
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +55 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -0
- package/build/components/rich-text/format-toolbar-container.js +0 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +5 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +167 -0
- package/build/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.native.js +95 -0
- package/build/components/use-on-block-drop/index.native.js.map +1 -0
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +1 -3
- package/build/components/writing-flow/use-click-selection.js.map +1 -1
- package/build/components/writing-flow/use-input.js +15 -0
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +49 -8
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/elements/index.js +9 -0
- package/build/elements/index.js.map +1 -0
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -7
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +14 -7
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +8 -88
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +16 -6
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/style.js +14 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +6 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +14 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +17 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +43 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-alignment-matrix-control/index.js +1 -6
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +3 -78
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build-module/components/block-draggable/index.native.js +453 -0
- package/build-module/components/block-draggable/index.native.js.map +1 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build-module/components/block-list/block-list-context.native.js +179 -0
- package/build-module/components/block-list/block-list-context.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item.native.js +12 -9
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +26 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +35 -33
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +72 -23
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -5
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +18 -5
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +19 -8
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +21 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +1 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -0
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +2 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +13 -2
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +11 -4
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +124 -43
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/iframe/index.js +52 -51
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/index.js +2 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.js +21 -7
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +2 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -5
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/link-control/constants.js +5 -0
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -4
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +5 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +0 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +8 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +63 -8
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +42 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar-container.js +0 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +5 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +148 -0
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.native.js +83 -0
- package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +1 -3
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +15 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +49 -8
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/elements/index.js +2 -0
- package/build-module/elements/index.js.map +1 -0
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -7
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +11 -6
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +8 -88
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +19 -9
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/style.js +15 -14
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +6 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +12 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +17 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +37 -12
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +100 -225
- package/build-style/style.css +100 -225
- package/package.json +30 -30
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-content-overlay/index.js +8 -95
- package/src/components/block-content-overlay/style.scss +2 -12
- package/src/components/block-draggable/draggable-chip.native.js +49 -0
- package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
- package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
- package/src/components/block-draggable/index.native.js +462 -0
- package/src/components/block-draggable/style.native.scss +19 -0
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
- package/src/components/block-draggable/test/helpers.native.js +183 -0
- package/src/components/block-draggable/test/index.native.js +496 -0
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
- package/src/components/block-list/block-list-context.native.js +175 -0
- package/src/components/block-list/block-list-item-cell.native.js +49 -0
- package/src/components/block-list/block-list-item.native.js +7 -11
- package/src/components/block-list/block.native.js +37 -8
- package/src/components/block-list/index.js +44 -44
- package/src/components/block-list/index.native.js +54 -13
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/test/block-list-context.native.js +253 -0
- package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
- package/src/components/block-list/use-block-props/index.js +10 -5
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-mobile-toolbar/index.native.js +9 -1
- package/src/components/block-mover/index.native.js +22 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/inbetween.js +21 -8
- package/src/components/block-popover/index.js +18 -15
- package/src/components/block-popover/style.scss +4 -0
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-switcher/style.scss +2 -39
- package/src/components/block-tools/block-selection-button.js +1 -0
- package/src/components/block-tools/selected-block-popover.js +1 -36
- package/src/components/block-tools/style.scss +1 -12
- package/src/components/block-variation-transforms/index.js +6 -2
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +3 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/colors-gradients/dropdown.js +130 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
- package/src/components/colors-gradients/style.scss +52 -50
- package/src/components/convert-to-group-buttons/toolbar.js +30 -13
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/iframe/index.js +62 -54
- package/src/components/image-editor/use-save-image.js +2 -1
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +2 -3
- package/src/components/inserter/index.js +20 -0
- package/src/components/inserter/index.native.js +2 -2
- package/src/components/inserter/quick-inserter.js +3 -11
- package/src/components/inserter/style.native.scss +1 -0
- package/src/components/inserter/style.scss +2 -1
- package/src/components/link-control/constants.js +11 -0
- package/src/components/link-control/search-results.js +4 -5
- package/src/components/link-control/use-search-handler.js +11 -5
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/drop-indicator.js +0 -1
- package/src/components/list-view/index.js +11 -41
- package/src/components/list-view/style.scss +2 -1
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/media-upload/index.native.js +6 -2
- package/src/components/media-upload/test/index.native.js +31 -6
- package/src/components/navigable-toolbar/index.js +12 -2
- package/src/components/plain-text/index.native.js +64 -8
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/publish-date-time-picker/README.md +52 -0
- package/src/components/publish-date-time-picker/index.js +50 -0
- package/src/components/publish-date-time-picker/style.scss +20 -0
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +3 -1
- package/src/components/rich-text/index.native.js +4 -0
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/url-input/index.js +9 -4
- package/src/components/use-block-drop-zone/index.native.js +173 -0
- package/src/components/use-on-block-drop/index.native.js +119 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/components/writing-flow/use-click-selection.js +1 -4
- package/src/components/writing-flow/use-input.js +12 -0
- package/src/components/writing-flow/use-selection-observer.js +55 -10
- package/src/elements/index.js +1 -0
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +2 -11
- package/src/hooks/border.scss +0 -48
- package/src/hooks/color-panel.js +13 -9
- package/src/hooks/color.js +5 -74
- package/src/hooks/color.scss +5 -58
- package/src/hooks/dimensions.js +55 -41
- package/src/hooks/index.js +1 -0
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/style.js +25 -39
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/typography.js +2 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +11 -3
- package/src/store/actions.js +12 -0
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +14 -1
- package/src/store/selectors.js +42 -12
- package/src/store/test/reducer.js +5 -0
- package/src/store/test/selectors.js +17 -0
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/colors/color-panel.js +0 -82
- package/build/components/colors/color-panel.js.map +0 -1
- package/build/components/colors/color-panel.native.js +0 -11
- package/build/components/colors/color-panel.native.js.map +0 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/colors/color-panel.js +0 -70
- package/build-module/components/colors/color-panel.js.map +0 -1
- package/build-module/components/colors/color-panel.native.js +0 -4
- package/build-module/components/colors/color-panel.native.js.map +0 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/colors/color-panel.js +0 -91
- package/src/components/colors/color-panel.native.js +0 -3
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
act,
|
|
6
|
+
fireEvent,
|
|
7
|
+
initializeEditor,
|
|
8
|
+
waitForStoreResolvers,
|
|
9
|
+
within,
|
|
10
|
+
advanceAnimationByFrame,
|
|
11
|
+
} from 'test/helpers';
|
|
12
|
+
import { fireGestureHandler } from 'react-native-gesture-handler/jest-utils';
|
|
13
|
+
import { State } from 'react-native-gesture-handler';
|
|
14
|
+
|
|
15
|
+
// Touch event type constants have been extracted from original source code, as they are not exported in the package.
|
|
16
|
+
// Reference: https://github.com/software-mansion/react-native-gesture-handler/blob/90895e5f38616a6be256fceec6c6a391cd9ad7c7/src/TouchEventType.ts
|
|
17
|
+
export const TouchEventType = {
|
|
18
|
+
UNDETERMINED: 0,
|
|
19
|
+
TOUCHES_DOWN: 1,
|
|
20
|
+
TOUCHES_MOVE: 2,
|
|
21
|
+
TOUCHES_UP: 3,
|
|
22
|
+
TOUCHES_CANCELLED: 4,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const DEFAULT_TOUCH_EVENTS = [
|
|
26
|
+
{
|
|
27
|
+
id: 1,
|
|
28
|
+
eventType: TouchEventType.TOUCHES_DOWN,
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {Object} WPBlockWithLayout
|
|
36
|
+
* @property {string} name Name of the block (e.g. Paragraph).
|
|
37
|
+
* @property {string} html HTML content.
|
|
38
|
+
* @property {Object} layout Layout data.
|
|
39
|
+
* @property {Object} layout.x X position.
|
|
40
|
+
* @property {Object} layout.y Y position.
|
|
41
|
+
* @property {Object} layout.width Width.
|
|
42
|
+
* @property {Object} layout.height Height.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Initialize the editor with an array of blocks that include their HTML and layout.
|
|
47
|
+
*
|
|
48
|
+
* @param {WPBlockWithLayout[]} blocks Initial blocks.
|
|
49
|
+
*
|
|
50
|
+
* @return {import('@testing-library/react-native').RenderAPI} The Testing Library screen.
|
|
51
|
+
*/
|
|
52
|
+
export const initializeWithBlocksLayouts = async ( blocks ) => {
|
|
53
|
+
const initialHtml = blocks.map( ( block ) => block.html ).join( '\n' );
|
|
54
|
+
|
|
55
|
+
const screen = await initializeEditor( { initialHtml } );
|
|
56
|
+
const { getByA11yLabel } = screen;
|
|
57
|
+
|
|
58
|
+
const waitPromises = [];
|
|
59
|
+
blocks.forEach( ( block, index ) => {
|
|
60
|
+
const a11yLabel = new RegExp(
|
|
61
|
+
`${ block.name } Block\\. Row ${ index + 1 }`
|
|
62
|
+
);
|
|
63
|
+
const element = getByA11yLabel( a11yLabel );
|
|
64
|
+
// "onLayout" event will populate the blocks layouts data.
|
|
65
|
+
fireEvent( element, 'layout', {
|
|
66
|
+
nativeEvent: { layout: block.layout },
|
|
67
|
+
} );
|
|
68
|
+
if ( block.nestedBlocks ) {
|
|
69
|
+
// Nested blocks are rendered via the FlatList of the inner block list.
|
|
70
|
+
// In order to render the items of a FlatList, it's required to trigger the
|
|
71
|
+
// "onLayout" event. Additionally, the call is wrapped over "waitForStoreResolvers"
|
|
72
|
+
// because the nested blocks might make API requests (e.g. the Gallery block).
|
|
73
|
+
waitPromises.push(
|
|
74
|
+
waitForStoreResolvers( () =>
|
|
75
|
+
fireEvent(
|
|
76
|
+
within( element ).getByTestId( 'block-list-wrapper' ),
|
|
77
|
+
'layout',
|
|
78
|
+
{
|
|
79
|
+
nativeEvent: {
|
|
80
|
+
layout: {
|
|
81
|
+
width: block.layout.width,
|
|
82
|
+
height: block.layout.height,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
block.nestedBlocks.forEach( ( nestedBlock, nestedIndex ) => {
|
|
91
|
+
const nestedA11yLabel = new RegExp(
|
|
92
|
+
`${ nestedBlock.name } Block\\. Row ${ nestedIndex + 1 }`
|
|
93
|
+
);
|
|
94
|
+
fireEvent(
|
|
95
|
+
within( element ).getByA11yLabel( nestedA11yLabel ),
|
|
96
|
+
'layout',
|
|
97
|
+
{
|
|
98
|
+
nativeEvent: { layout: nestedBlock.layout },
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
} );
|
|
102
|
+
}
|
|
103
|
+
} );
|
|
104
|
+
await Promise.all( waitPromises );
|
|
105
|
+
|
|
106
|
+
return screen;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fires long-press gesture event on a block.
|
|
111
|
+
*
|
|
112
|
+
* @param {import('react-test-renderer').ReactTestInstance} block Block test instance.
|
|
113
|
+
* @param {string} testID Id for querying the draggable trigger element.
|
|
114
|
+
* @param {Object} [options] Configuration options for the gesture event.
|
|
115
|
+
* @param {boolean} [options.failed] Determines if the gesture should fail.
|
|
116
|
+
* @param {number} [options.triggerIndex] In case there are multiple draggable triggers, this specifies the index to use.
|
|
117
|
+
*/
|
|
118
|
+
export const fireLongPress = (
|
|
119
|
+
block,
|
|
120
|
+
testID,
|
|
121
|
+
{ failed = false, triggerIndex } = {}
|
|
122
|
+
) => {
|
|
123
|
+
const draggableTrigger =
|
|
124
|
+
typeof triggerIndex !== 'undefined'
|
|
125
|
+
? within( block ).getAllByTestId( testID )[ triggerIndex ]
|
|
126
|
+
: within( block ).getByTestId( testID );
|
|
127
|
+
if ( failed ) {
|
|
128
|
+
fireGestureHandler( draggableTrigger, [ { state: State.FAILED } ] );
|
|
129
|
+
} else {
|
|
130
|
+
fireGestureHandler( draggableTrigger, [
|
|
131
|
+
{ oldState: State.BEGAN, state: State.ACTIVE },
|
|
132
|
+
{ state: State.ACTIVE },
|
|
133
|
+
{ state: State.END },
|
|
134
|
+
] );
|
|
135
|
+
}
|
|
136
|
+
// Advance timers one frame to ensure that shared values
|
|
137
|
+
// are updated and trigger animation reactions.
|
|
138
|
+
act( () => advanceAnimationByFrame( 1 ) );
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Fires pan gesture event on a BlockDraggable component.
|
|
143
|
+
*
|
|
144
|
+
* @param {import('react-test-renderer').ReactTestInstance} blockDraggable BlockDraggable test instance.
|
|
145
|
+
* @param {Object} [touchEvents] Array of touch events to dispatch on the pan gesture.
|
|
146
|
+
*/
|
|
147
|
+
export const firePanGesture = (
|
|
148
|
+
blockDraggable,
|
|
149
|
+
touchEvents = DEFAULT_TOUCH_EVENTS
|
|
150
|
+
) => {
|
|
151
|
+
const gestureTouchEvents = touchEvents.map(
|
|
152
|
+
( { eventType, ...touchEvent } ) => ( {
|
|
153
|
+
allTouches: [ touchEvent ],
|
|
154
|
+
eventType,
|
|
155
|
+
} )
|
|
156
|
+
);
|
|
157
|
+
fireGestureHandler( blockDraggable, [
|
|
158
|
+
// TOUCHES_DOWN event is only received on ACTIVE state, so we have to fire it manually.
|
|
159
|
+
{ oldState: State.BEGAN, state: State.ACTIVE },
|
|
160
|
+
...gestureTouchEvents,
|
|
161
|
+
{ state: State.END },
|
|
162
|
+
] );
|
|
163
|
+
// Advance timers one frame to ensure that shared values
|
|
164
|
+
// are updated and trigger animation reactions.
|
|
165
|
+
act( () => advanceAnimationByFrame( 1 ) );
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Gets the draggable chip element.
|
|
170
|
+
*
|
|
171
|
+
* @param {import('@testing-library/react-native').RenderAPI} screen The Testing Library screen.
|
|
172
|
+
*
|
|
173
|
+
* @return {import('react-test-renderer').ReactTestInstance} Draggable chip test instance.
|
|
174
|
+
*/
|
|
175
|
+
export const getDraggableChip = ( { getByTestId } ) => {
|
|
176
|
+
let draggableChip;
|
|
177
|
+
try {
|
|
178
|
+
draggableChip = getByTestId( 'draggable-chip' );
|
|
179
|
+
} catch ( e ) {
|
|
180
|
+
// NOOP.
|
|
181
|
+
}
|
|
182
|
+
return draggableChip;
|
|
183
|
+
};
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
fireEvent,
|
|
6
|
+
getEditorHtml,
|
|
7
|
+
within,
|
|
8
|
+
waitForStoreResolvers,
|
|
9
|
+
withReanimatedTimer,
|
|
10
|
+
} from 'test/helpers';
|
|
11
|
+
import { getByGestureTestId } from 'react-native-gesture-handler/jest-utils';
|
|
12
|
+
import TextInputState from 'react-native/Libraries/Components/TextInput/TextInputState';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
18
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
19
|
+
import '@wordpress/jest-console';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import {
|
|
25
|
+
initializeWithBlocksLayouts,
|
|
26
|
+
fireLongPress,
|
|
27
|
+
firePanGesture,
|
|
28
|
+
TouchEventType,
|
|
29
|
+
getDraggableChip,
|
|
30
|
+
} from './helpers';
|
|
31
|
+
|
|
32
|
+
// Mock throttle to allow updating the dragging position on every "onDragOver" event.
|
|
33
|
+
jest.mock( 'lodash', () => ( {
|
|
34
|
+
...jest.requireActual( 'lodash' ),
|
|
35
|
+
throttle: ( fn ) => {
|
|
36
|
+
fn.cancel = jest.fn();
|
|
37
|
+
return fn;
|
|
38
|
+
},
|
|
39
|
+
} ) );
|
|
40
|
+
|
|
41
|
+
beforeAll( () => {
|
|
42
|
+
// Register all core blocks
|
|
43
|
+
registerCoreBlocks();
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
afterAll( () => {
|
|
47
|
+
// Clean up registered blocks
|
|
48
|
+
getBlockTypes().forEach( ( block ) => {
|
|
49
|
+
unregisterBlockType( block.name );
|
|
50
|
+
} );
|
|
51
|
+
} );
|
|
52
|
+
|
|
53
|
+
const TOUCH_EVENT_ID = 1;
|
|
54
|
+
const BLOCKS = [
|
|
55
|
+
{
|
|
56
|
+
name: 'Paragraph',
|
|
57
|
+
html: `
|
|
58
|
+
<!-- wp:paragraph -->
|
|
59
|
+
<p>This is a paragraph.</p>
|
|
60
|
+
<!-- /wp:paragraph -->`,
|
|
61
|
+
layout: { x: 0, y: 0, width: 100, height: 100 },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Image',
|
|
65
|
+
html: `
|
|
66
|
+
<!-- wp:image {"sizeSlug":"large"} -->
|
|
67
|
+
<figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
|
|
68
|
+
<!-- /wp:image -->`,
|
|
69
|
+
layout: { x: 0, y: 100, width: 100, height: 100 },
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Spacer',
|
|
73
|
+
html: `
|
|
74
|
+
<!-- wp:spacer -->
|
|
75
|
+
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
|
76
|
+
<!-- /wp:spacer -->`,
|
|
77
|
+
layout: { x: 0, y: 200, width: 100, height: 100 },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'Gallery',
|
|
81
|
+
html: `
|
|
82
|
+
<!-- wp:gallery {"linkTo":"none"} -->
|
|
83
|
+
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
|
|
84
|
+
<figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
|
|
85
|
+
<!-- /wp:image -->
|
|
86
|
+
|
|
87
|
+
<!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
|
|
88
|
+
<figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
|
|
89
|
+
<!-- /wp:image --></figure>
|
|
90
|
+
<!-- /wp:gallery -->`,
|
|
91
|
+
layout: { x: 0, y: 300, width: 100, height: 100 },
|
|
92
|
+
nestedBlocks: [
|
|
93
|
+
{ name: 'Image', layout: { x: 0, y: 300, width: 50, height: 50 } },
|
|
94
|
+
{ name: 'Image', layout: { x: 50, y: 300, width: 50, height: 50 } },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
describe( 'BlockDraggable', () => {
|
|
100
|
+
describe( 'drag mode', () => {
|
|
101
|
+
describe( 'Text block', () => {
|
|
102
|
+
it( 'enables drag mode when unselected', async () =>
|
|
103
|
+
withReanimatedTimer( async () => {
|
|
104
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
105
|
+
const { getByA11yLabel } = screen;
|
|
106
|
+
|
|
107
|
+
// Start dragging from block's content
|
|
108
|
+
fireLongPress(
|
|
109
|
+
getByA11yLabel( /Paragraph Block\. Row 1/ ),
|
|
110
|
+
'draggable-trigger-content'
|
|
111
|
+
);
|
|
112
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
113
|
+
|
|
114
|
+
// "firePanGesture" finishes the dragging gesture
|
|
115
|
+
firePanGesture(
|
|
116
|
+
getByGestureTestId( 'block-draggable-wrapper' )
|
|
117
|
+
);
|
|
118
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
119
|
+
} ) );
|
|
120
|
+
|
|
121
|
+
it( 'enables drag mode when selected', async () =>
|
|
122
|
+
withReanimatedTimer( async () => {
|
|
123
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
124
|
+
const { getByA11yLabel } = screen;
|
|
125
|
+
const blockDraggableWrapper = getByGestureTestId(
|
|
126
|
+
'block-draggable-wrapper'
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const paragraphBlock = getByA11yLabel(
|
|
130
|
+
/Paragraph Block\. Row 1/
|
|
131
|
+
);
|
|
132
|
+
fireEvent.press( paragraphBlock );
|
|
133
|
+
|
|
134
|
+
// Start dragging from block's content
|
|
135
|
+
fireLongPress(
|
|
136
|
+
paragraphBlock,
|
|
137
|
+
'draggable-trigger-content'
|
|
138
|
+
);
|
|
139
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
140
|
+
// "firePanGesture" finishes the dragging gesture
|
|
141
|
+
firePanGesture( blockDraggableWrapper );
|
|
142
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
143
|
+
|
|
144
|
+
// Start dragging from block's mobile toolbar
|
|
145
|
+
fireLongPress(
|
|
146
|
+
paragraphBlock,
|
|
147
|
+
'draggable-trigger-mobile-toolbar'
|
|
148
|
+
);
|
|
149
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
150
|
+
// "firePanGesture" finishes the dragging gesture
|
|
151
|
+
firePanGesture( blockDraggableWrapper );
|
|
152
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
153
|
+
} ) );
|
|
154
|
+
|
|
155
|
+
it( 'does not enable drag mode when selected and editing text', async () =>
|
|
156
|
+
withReanimatedTimer( async () => {
|
|
157
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
158
|
+
const { getByA11yLabel } = screen;
|
|
159
|
+
|
|
160
|
+
const paragraphBlock = getByA11yLabel(
|
|
161
|
+
/Paragraph Block\. Row 1/
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
// Select Paragraph block and start editing text
|
|
165
|
+
fireEvent.press( paragraphBlock );
|
|
166
|
+
fireEvent(
|
|
167
|
+
within( paragraphBlock ).getByPlaceholderText(
|
|
168
|
+
'Start writing…'
|
|
169
|
+
),
|
|
170
|
+
'focus'
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// Start dragging from block's content
|
|
174
|
+
fireLongPress(
|
|
175
|
+
paragraphBlock,
|
|
176
|
+
'draggable-trigger-content',
|
|
177
|
+
{ failed: true }
|
|
178
|
+
);
|
|
179
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
180
|
+
// Check that no text input has been unfocused to confirm
|
|
181
|
+
// that editing text is still enabled.
|
|
182
|
+
expect(
|
|
183
|
+
TextInputState.blurTextInput
|
|
184
|
+
).not.toHaveBeenCalled();
|
|
185
|
+
} ) );
|
|
186
|
+
|
|
187
|
+
it( 'finishes editing text and enables drag mode when long-pressing over a different block', async () =>
|
|
188
|
+
withReanimatedTimer( async () => {
|
|
189
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
190
|
+
const { getByA11yLabel } = screen;
|
|
191
|
+
|
|
192
|
+
const paragraphBlock = getByA11yLabel(
|
|
193
|
+
/Paragraph Block\. Row 1/
|
|
194
|
+
);
|
|
195
|
+
const spacerBlock = getByA11yLabel(
|
|
196
|
+
/Spacer Block\. Row 3/
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Select Paragraph block and start editing text
|
|
200
|
+
fireEvent.press( paragraphBlock );
|
|
201
|
+
fireEvent(
|
|
202
|
+
within( paragraphBlock ).getByPlaceholderText(
|
|
203
|
+
'Start writing…'
|
|
204
|
+
),
|
|
205
|
+
'focus'
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
// Start dragging from a different block's content
|
|
209
|
+
fireLongPress( spacerBlock, 'draggable-trigger-content' );
|
|
210
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
211
|
+
// Check that any text input has been unfocused to confirm
|
|
212
|
+
// that editing text finished.
|
|
213
|
+
expect( TextInputState.blurTextInput ).toHaveBeenCalled();
|
|
214
|
+
} ) );
|
|
215
|
+
} );
|
|
216
|
+
|
|
217
|
+
describe( 'Media block', () => {
|
|
218
|
+
it( 'enables drag mode when unselected', async () =>
|
|
219
|
+
withReanimatedTimer( async () => {
|
|
220
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
221
|
+
const { getAllByA11yLabel } = screen;
|
|
222
|
+
|
|
223
|
+
// We select the first Image block as the Gallery block
|
|
224
|
+
// also contains Image blocks.
|
|
225
|
+
const imageBlock = getAllByA11yLabel(
|
|
226
|
+
/Image Block\. Row 2/
|
|
227
|
+
)[ 0 ];
|
|
228
|
+
// Start dragging from block's content
|
|
229
|
+
fireLongPress( imageBlock, 'draggable-trigger-content' );
|
|
230
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
231
|
+
|
|
232
|
+
// "firePanGesture" finishes the dragging gesture
|
|
233
|
+
firePanGesture(
|
|
234
|
+
getByGestureTestId( 'block-draggable-wrapper' )
|
|
235
|
+
);
|
|
236
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
237
|
+
} ) );
|
|
238
|
+
|
|
239
|
+
it( 'enables drag mode when selected', async () =>
|
|
240
|
+
withReanimatedTimer( async () => {
|
|
241
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
242
|
+
const { getAllByA11yLabel } = screen;
|
|
243
|
+
const blockDraggableWrapper = getByGestureTestId(
|
|
244
|
+
'block-draggable-wrapper'
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
// We select the first Image block as the Gallery block
|
|
248
|
+
// also contains Image blocks.
|
|
249
|
+
const imageBlock = getAllByA11yLabel(
|
|
250
|
+
/Image Block\. Row 2/
|
|
251
|
+
)[ 0 ];
|
|
252
|
+
fireEvent.press( imageBlock );
|
|
253
|
+
|
|
254
|
+
// Start dragging from block's content
|
|
255
|
+
fireLongPress( imageBlock, 'draggable-trigger-content' );
|
|
256
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
257
|
+
// "firePanGesture" finishes the dragging gesture
|
|
258
|
+
firePanGesture( blockDraggableWrapper );
|
|
259
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
260
|
+
|
|
261
|
+
// Start dragging from block's mobile toolbar
|
|
262
|
+
fireLongPress(
|
|
263
|
+
imageBlock,
|
|
264
|
+
'draggable-trigger-mobile-toolbar'
|
|
265
|
+
);
|
|
266
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
267
|
+
// "firePanGesture" finishes the dragging gesture
|
|
268
|
+
firePanGesture( blockDraggableWrapper );
|
|
269
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
270
|
+
} ) );
|
|
271
|
+
} );
|
|
272
|
+
|
|
273
|
+
describe( 'Nested block', () => {
|
|
274
|
+
it( 'enables drag mode when unselected', async () =>
|
|
275
|
+
withReanimatedTimer( async () => {
|
|
276
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
277
|
+
const { getByA11yLabel } = screen;
|
|
278
|
+
|
|
279
|
+
// Start dragging from block's content, specifically the first
|
|
280
|
+
// trigger index, which corresponds to the Gallery block content.
|
|
281
|
+
fireLongPress(
|
|
282
|
+
getByA11yLabel( /Gallery Block\. Row 4/ ),
|
|
283
|
+
'draggable-trigger-content',
|
|
284
|
+
{ triggerIndex: 0 }
|
|
285
|
+
);
|
|
286
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
287
|
+
|
|
288
|
+
// "firePanGesture" finishes the dragging gesture
|
|
289
|
+
firePanGesture(
|
|
290
|
+
getByGestureTestId( 'block-draggable-wrapper' )
|
|
291
|
+
);
|
|
292
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
293
|
+
} ) );
|
|
294
|
+
|
|
295
|
+
it( 'enables drag mode when selected', async () =>
|
|
296
|
+
withReanimatedTimer( async () => {
|
|
297
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
298
|
+
const { getByA11yLabel } = screen;
|
|
299
|
+
const blockDraggableWrapper = getByGestureTestId(
|
|
300
|
+
'block-draggable-wrapper'
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
const galleryBlock = getByA11yLabel(
|
|
304
|
+
/Gallery Block\. Row 4/
|
|
305
|
+
);
|
|
306
|
+
await waitForStoreResolvers( () =>
|
|
307
|
+
fireEvent.press( galleryBlock )
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
// Start dragging from block's content, specifically the first
|
|
311
|
+
// trigger index, which corresponds to the Gallery block content.
|
|
312
|
+
fireLongPress( galleryBlock, 'draggable-trigger-content', {
|
|
313
|
+
triggerIndex: 0,
|
|
314
|
+
} );
|
|
315
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
316
|
+
// "firePanGesture" finishes the dragging gesture
|
|
317
|
+
firePanGesture( blockDraggableWrapper );
|
|
318
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
319
|
+
|
|
320
|
+
// Start dragging from block's mobile toolbar
|
|
321
|
+
fireLongPress(
|
|
322
|
+
galleryBlock,
|
|
323
|
+
'draggable-trigger-mobile-toolbar'
|
|
324
|
+
);
|
|
325
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
326
|
+
// "firePanGesture" finishes the dragging gesture
|
|
327
|
+
firePanGesture( blockDraggableWrapper );
|
|
328
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
329
|
+
} ) );
|
|
330
|
+
|
|
331
|
+
it( 'enables drag mode when nested block is selected', async () =>
|
|
332
|
+
withReanimatedTimer( async () => {
|
|
333
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
334
|
+
const { getByA11yLabel } = screen;
|
|
335
|
+
const blockDraggableWrapper = getByGestureTestId(
|
|
336
|
+
'block-draggable-wrapper'
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const galleryBlock = getByA11yLabel(
|
|
340
|
+
/Gallery Block\. Row 4/
|
|
341
|
+
);
|
|
342
|
+
const galleryItem = within( galleryBlock ).getByA11yLabel(
|
|
343
|
+
/Image Block\. Row 2/
|
|
344
|
+
);
|
|
345
|
+
fireEvent.press( galleryBlock );
|
|
346
|
+
fireEvent.press( galleryItem );
|
|
347
|
+
|
|
348
|
+
// Start dragging from nested block's content
|
|
349
|
+
fireLongPress( galleryItem, 'draggable-trigger-content' );
|
|
350
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
351
|
+
// "firePanGesture" finishes the dragging gesture
|
|
352
|
+
firePanGesture( blockDraggableWrapper );
|
|
353
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
354
|
+
|
|
355
|
+
// After dropping the block, the gallery item gets automatically selected.
|
|
356
|
+
// Hence, we have to select the gallery item again.
|
|
357
|
+
fireEvent.press( galleryItem );
|
|
358
|
+
|
|
359
|
+
// Start dragging from nested block's mobile toolbar
|
|
360
|
+
fireLongPress(
|
|
361
|
+
galleryItem,
|
|
362
|
+
'draggable-trigger-mobile-toolbar'
|
|
363
|
+
);
|
|
364
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
365
|
+
// "firePanGesture" finishes the dragging gesture
|
|
366
|
+
firePanGesture( blockDraggableWrapper );
|
|
367
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
368
|
+
} ) );
|
|
369
|
+
} );
|
|
370
|
+
|
|
371
|
+
describe( 'Other block', () => {
|
|
372
|
+
it( 'enables drag mode when unselected', async () =>
|
|
373
|
+
withReanimatedTimer( async () => {
|
|
374
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
375
|
+
const { getByA11yLabel } = screen;
|
|
376
|
+
|
|
377
|
+
// Start dragging from block's content
|
|
378
|
+
fireLongPress(
|
|
379
|
+
getByA11yLabel( /Spacer Block\. Row 3/ ),
|
|
380
|
+
'draggable-trigger-content'
|
|
381
|
+
);
|
|
382
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
383
|
+
|
|
384
|
+
// "firePanGesture" finishes the dragging gesture
|
|
385
|
+
firePanGesture(
|
|
386
|
+
getByGestureTestId( 'block-draggable-wrapper' )
|
|
387
|
+
);
|
|
388
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
389
|
+
} ) );
|
|
390
|
+
|
|
391
|
+
it( 'enables drag mode when selected', async () =>
|
|
392
|
+
withReanimatedTimer( async () => {
|
|
393
|
+
const screen = await initializeWithBlocksLayouts( BLOCKS );
|
|
394
|
+
const { getByA11yLabel } = screen;
|
|
395
|
+
const blockDraggableWrapper = getByGestureTestId(
|
|
396
|
+
'block-draggable-wrapper'
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
const spacerBlock = getByA11yLabel(
|
|
400
|
+
/Spacer Block\. Row 3/
|
|
401
|
+
);
|
|
402
|
+
await waitForStoreResolvers( () =>
|
|
403
|
+
fireEvent.press( spacerBlock )
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
// Start dragging from block's content
|
|
407
|
+
fireLongPress( spacerBlock, 'draggable-trigger-content' );
|
|
408
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
409
|
+
// "firePanGesture" finishes the dragging gesture
|
|
410
|
+
firePanGesture( blockDraggableWrapper );
|
|
411
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
412
|
+
|
|
413
|
+
// Start dragging from block's mobile toolbar
|
|
414
|
+
fireLongPress(
|
|
415
|
+
spacerBlock,
|
|
416
|
+
'draggable-trigger-mobile-toolbar'
|
|
417
|
+
);
|
|
418
|
+
expect( getDraggableChip( screen ) ).toBeVisible();
|
|
419
|
+
// "firePanGesture" finishes the dragging gesture
|
|
420
|
+
firePanGesture( blockDraggableWrapper );
|
|
421
|
+
expect( getDraggableChip( screen ) ).not.toBeDefined();
|
|
422
|
+
} ) );
|
|
423
|
+
} );
|
|
424
|
+
} );
|
|
425
|
+
|
|
426
|
+
it( 'moves blocks', async () =>
|
|
427
|
+
withReanimatedTimer( async () => {
|
|
428
|
+
const { getByA11yLabel } = await initializeWithBlocksLayouts(
|
|
429
|
+
BLOCKS
|
|
430
|
+
);
|
|
431
|
+
const blockDraggableWrapper = getByGestureTestId(
|
|
432
|
+
'block-draggable-wrapper'
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
expect( getEditorHtml() ).toMatchSnapshot( 'Initial order' );
|
|
436
|
+
|
|
437
|
+
// Move Paragraph block from first to second position
|
|
438
|
+
fireLongPress(
|
|
439
|
+
getByA11yLabel( /Paragraph Block\. Row 1/ ),
|
|
440
|
+
'draggable-trigger-content'
|
|
441
|
+
);
|
|
442
|
+
firePanGesture( blockDraggableWrapper, [
|
|
443
|
+
{
|
|
444
|
+
id: TOUCH_EVENT_ID,
|
|
445
|
+
eventType: TouchEventType.TOUCHES_DOWN,
|
|
446
|
+
x: 0,
|
|
447
|
+
y: 0,
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
id: TOUCH_EVENT_ID,
|
|
451
|
+
eventType: TouchEventType.TOUCHES_MOVE,
|
|
452
|
+
x: 0,
|
|
453
|
+
// Dropping position is in the second half of the second block's height.
|
|
454
|
+
y: 180,
|
|
455
|
+
},
|
|
456
|
+
] );
|
|
457
|
+
// Draggable Pan gesture uses the Gesture state manager to manually
|
|
458
|
+
// activate the gesture. Since this not available in tests, the library
|
|
459
|
+
// displays a warning message.
|
|
460
|
+
expect( console ).toHaveWarnedWith(
|
|
461
|
+
'[react-native-gesture-handler] You have to use react-native-reanimated in order to control the state of the gesture.'
|
|
462
|
+
);
|
|
463
|
+
expect( getEditorHtml() ).toMatchSnapshot(
|
|
464
|
+
'Paragraph block moved from first to second position'
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
// Move Spacer block from third to first position
|
|
468
|
+
fireLongPress(
|
|
469
|
+
getByA11yLabel( /Spacer Block\. Row 3/ ),
|
|
470
|
+
'draggable-trigger-content'
|
|
471
|
+
);
|
|
472
|
+
firePanGesture( blockDraggableWrapper, [
|
|
473
|
+
{
|
|
474
|
+
id: TOUCH_EVENT_ID,
|
|
475
|
+
eventType: TouchEventType.TOUCHES_DOWN,
|
|
476
|
+
x: 0,
|
|
477
|
+
y: 250,
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: TOUCH_EVENT_ID,
|
|
481
|
+
eventType: TouchEventType.TOUCHES_MOVE,
|
|
482
|
+
x: 0,
|
|
483
|
+
y: 0,
|
|
484
|
+
},
|
|
485
|
+
] );
|
|
486
|
+
// Draggable Pan gesture uses the Gesture state manager to manually
|
|
487
|
+
// activate the gesture. Since this not available in tests, the library
|
|
488
|
+
// displays a warning message.
|
|
489
|
+
expect( console ).toHaveWarnedWith(
|
|
490
|
+
'[react-native-gesture-handler] You have to use react-native-reanimated in order to control the state of the gesture.'
|
|
491
|
+
);
|
|
492
|
+
expect( getEditorHtml() ).toMatchSnapshot(
|
|
493
|
+
'Spacer block moved from third to first position'
|
|
494
|
+
);
|
|
495
|
+
} ) );
|
|
496
|
+
} );
|