@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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useWindowDimensions } from 'react-native';
|
|
5
|
+
import {
|
|
6
|
+
useSharedValue,
|
|
7
|
+
useAnimatedRef,
|
|
8
|
+
scrollTo,
|
|
9
|
+
useAnimatedReaction,
|
|
10
|
+
withTiming,
|
|
11
|
+
withRepeat,
|
|
12
|
+
cancelAnimation,
|
|
13
|
+
Easing,
|
|
14
|
+
} from 'react-native-reanimated';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { useBlockListContext } from '../block-list/block-list-context';
|
|
20
|
+
|
|
21
|
+
const SCROLL_INACTIVE_DISTANCE_PX = 50;
|
|
22
|
+
const SCROLL_INTERVAL_MS = 1000;
|
|
23
|
+
const VELOCITY_MULTIPLIER = 5000;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* React hook that scrolls the scroll container when a block is being dragged.
|
|
27
|
+
*
|
|
28
|
+
* @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
|
|
29
|
+
* functions to be called in `onDragStart`, `onDragOver`
|
|
30
|
+
* and `onDragEnd` events respectively. Additionally,
|
|
31
|
+
* `scrollHandler` function is returned which should be
|
|
32
|
+
* called in the `onScroll` event of the block list.
|
|
33
|
+
*/
|
|
34
|
+
export default function useScrollWhenDragging() {
|
|
35
|
+
const { scrollRef } = useBlockListContext();
|
|
36
|
+
const animatedScrollRef = useAnimatedRef();
|
|
37
|
+
animatedScrollRef( scrollRef );
|
|
38
|
+
|
|
39
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
40
|
+
|
|
41
|
+
const velocityY = useSharedValue( 0 );
|
|
42
|
+
const offsetY = useSharedValue( 0 );
|
|
43
|
+
const dragStartY = useSharedValue( 0 );
|
|
44
|
+
const animationTimer = useSharedValue( 0 );
|
|
45
|
+
const isAnimationTimerActive = useSharedValue( false );
|
|
46
|
+
const isScrollActive = useSharedValue( false );
|
|
47
|
+
|
|
48
|
+
const scroll = {
|
|
49
|
+
offsetY: useSharedValue( 0 ),
|
|
50
|
+
maxOffsetY: useSharedValue( 0 ),
|
|
51
|
+
};
|
|
52
|
+
const scrollHandler = ( event ) => {
|
|
53
|
+
'worklet';
|
|
54
|
+
const { contentSize, contentOffset, layoutMeasurement } = event;
|
|
55
|
+
scroll.offsetY.value = contentOffset.y;
|
|
56
|
+
scroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const stopScrolling = () => {
|
|
60
|
+
'worklet';
|
|
61
|
+
cancelAnimation( animationTimer );
|
|
62
|
+
|
|
63
|
+
isAnimationTimerActive.value = false;
|
|
64
|
+
isScrollActive.value = false;
|
|
65
|
+
velocityY.value = 0;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const startScrolling = ( y ) => {
|
|
69
|
+
'worklet';
|
|
70
|
+
stopScrolling();
|
|
71
|
+
offsetY.value = scroll.offsetY.value;
|
|
72
|
+
dragStartY.value = y;
|
|
73
|
+
|
|
74
|
+
animationTimer.value = 0;
|
|
75
|
+
animationTimer.value = withRepeat(
|
|
76
|
+
withTiming( 1, {
|
|
77
|
+
duration: SCROLL_INTERVAL_MS,
|
|
78
|
+
easing: Easing.linear,
|
|
79
|
+
} ),
|
|
80
|
+
-1,
|
|
81
|
+
true
|
|
82
|
+
);
|
|
83
|
+
isAnimationTimerActive.value = true;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const scrollOnDragOver = ( y ) => {
|
|
87
|
+
'worklet';
|
|
88
|
+
const dragDistance = Math.max(
|
|
89
|
+
Math.abs( y - dragStartY.value ) - SCROLL_INACTIVE_DISTANCE_PX,
|
|
90
|
+
0
|
|
91
|
+
);
|
|
92
|
+
const distancePercentage = dragDistance / windowHeight;
|
|
93
|
+
|
|
94
|
+
if ( ! isScrollActive.value ) {
|
|
95
|
+
isScrollActive.value = dragDistance > 0;
|
|
96
|
+
} else if ( y > dragStartY.value ) {
|
|
97
|
+
// User is dragging downwards.
|
|
98
|
+
velocityY.value = VELOCITY_MULTIPLIER * distancePercentage;
|
|
99
|
+
} else if ( y < dragStartY.value ) {
|
|
100
|
+
// User is dragging upwards.
|
|
101
|
+
velocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;
|
|
102
|
+
} else {
|
|
103
|
+
velocityY.value = 0;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
useAnimatedReaction(
|
|
108
|
+
() => animationTimer.value,
|
|
109
|
+
( value, previous ) => {
|
|
110
|
+
if ( velocityY.value === 0 ) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const delta = Math.abs( value - previous );
|
|
115
|
+
let newOffset = offsetY.value + delta * velocityY.value;
|
|
116
|
+
|
|
117
|
+
if ( scroll.maxOffsetY.value !== 0 ) {
|
|
118
|
+
newOffset = Math.max(
|
|
119
|
+
0,
|
|
120
|
+
Math.min( scroll.maxOffsetY.value, newOffset )
|
|
121
|
+
);
|
|
122
|
+
} else {
|
|
123
|
+
// Scroll values are empty until receiving the first scroll event.
|
|
124
|
+
// In that case, the max offset is unknown and we can't clamp the
|
|
125
|
+
// new offset value.
|
|
126
|
+
newOffset = Math.max( 0, newOffset );
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
offsetY.value = newOffset;
|
|
130
|
+
scrollTo( animatedScrollRef, 0, offsetY.value, false );
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return [ startScrolling, scrollOnDragOver, stopScrolling, scrollHandler ];
|
|
135
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { orderBy } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createContext, useContext } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_BLOCK_LIST_CONTEXT = {
|
|
12
|
+
scrollRef: null,
|
|
13
|
+
blocksLayouts: { current: {} },
|
|
14
|
+
findBlockLayoutByClientId,
|
|
15
|
+
getBlockLayoutsOrderedByYCoord,
|
|
16
|
+
findBlockLayoutByPosition,
|
|
17
|
+
updateBlocksLayouts,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const Context = createContext( DEFAULT_BLOCK_LIST_CONTEXT );
|
|
21
|
+
const { Provider, Consumer } = Context;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Finds a block's layout data by position.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} data Blocks layouts object.
|
|
27
|
+
* @param {Object} position Position to use for finding the block.
|
|
28
|
+
* @param {number} position.x X coordinate.
|
|
29
|
+
* @param {number} position.y Y coordinate.
|
|
30
|
+
*
|
|
31
|
+
* @return {Object|undefined} Found block layout data that matches the provided position. If none is found, `undefined` will be returned.
|
|
32
|
+
*/
|
|
33
|
+
function findBlockLayoutByPosition( data, position ) {
|
|
34
|
+
// Only enabled for root level blocks
|
|
35
|
+
return Object.values( data ).find( ( block ) => {
|
|
36
|
+
return (
|
|
37
|
+
position.x >= block.x &&
|
|
38
|
+
position.x <= block.x + block.width &&
|
|
39
|
+
position.y >= block.y &&
|
|
40
|
+
position.y <= block.y + block.height
|
|
41
|
+
);
|
|
42
|
+
} );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Finds a block's layout data by its client Id.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} data Blocks layouts object.
|
|
49
|
+
* @param {string} clientId Block's clientId.
|
|
50
|
+
*
|
|
51
|
+
* @return {Object} Found block layout data.
|
|
52
|
+
*/
|
|
53
|
+
function findBlockLayoutByClientId( data, clientId ) {
|
|
54
|
+
return Object.entries( data ).reduce( ( acc, entry ) => {
|
|
55
|
+
const item = entry[ 1 ];
|
|
56
|
+
if ( acc ) {
|
|
57
|
+
return acc;
|
|
58
|
+
}
|
|
59
|
+
if ( item?.clientId === clientId ) {
|
|
60
|
+
return item;
|
|
61
|
+
}
|
|
62
|
+
if ( item?.innerBlocks && Object.keys( item.innerBlocks ).length > 0 ) {
|
|
63
|
+
return findBlockLayoutByClientId( item.innerBlocks, clientId );
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}, null );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Deletes the layout data of a block by its client Id.
|
|
71
|
+
*
|
|
72
|
+
* @param {Object} data Blocks layouts object.
|
|
73
|
+
* @param {string} clientId Block's clientsId.
|
|
74
|
+
*
|
|
75
|
+
* @return {Object} Updated data object.
|
|
76
|
+
*/
|
|
77
|
+
export function deleteBlockLayoutByClientId( data, clientId ) {
|
|
78
|
+
return Object.keys( data ).reduce( ( acc, key ) => {
|
|
79
|
+
if ( key !== clientId ) {
|
|
80
|
+
acc[ key ] = data[ key ];
|
|
81
|
+
}
|
|
82
|
+
if (
|
|
83
|
+
data[ key ]?.innerBlocks &&
|
|
84
|
+
Object.keys( data[ key ].innerBlocks ).length > 0
|
|
85
|
+
) {
|
|
86
|
+
if ( acc[ key ] ) {
|
|
87
|
+
acc[ key ].innerBlocks = deleteBlockLayoutByClientId(
|
|
88
|
+
data[ key ].innerBlocks,
|
|
89
|
+
clientId
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return acc;
|
|
94
|
+
}, {} );
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Orders the block's layout data by its Y coordinate.
|
|
99
|
+
*
|
|
100
|
+
* @param {Object} data Blocks layouts object.
|
|
101
|
+
*
|
|
102
|
+
* @return {Object} Blocks layouts object ordered by its Y coordinate.
|
|
103
|
+
*/
|
|
104
|
+
function getBlockLayoutsOrderedByYCoord( data ) {
|
|
105
|
+
// Only enabled for root level blocks.
|
|
106
|
+
// Using lodash orderBy due to hermes not having
|
|
107
|
+
// stable support for native .sort(). It will be
|
|
108
|
+
// supported in the React Native version 0.68.0.
|
|
109
|
+
return orderBy( data, [ 'y', 'asc' ] );
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Updates or deletes a block's layout data in the blocksLayouts object,
|
|
114
|
+
* in case of deletion, the layout data is not required.
|
|
115
|
+
*
|
|
116
|
+
* @param {Object} blocksLayouts Blocks layouts object.
|
|
117
|
+
* @param {Object} blockData Block's layout data to add or remove to/from the blockLayouts object.
|
|
118
|
+
* @param {string} blockData.clientId Block's clientId.
|
|
119
|
+
* @param {?string} blockData.rootClientId Optional. Block's rootClientId.
|
|
120
|
+
* @param {?boolean} blockData.shouldRemove Optional. Flag to remove it from the blocksLayout list.
|
|
121
|
+
* @param {number} blockData.width Block's width.
|
|
122
|
+
* @param {number} blockData.height Block's height.
|
|
123
|
+
* @param {number} blockData.x Block's x coordinate (relative to the parent).
|
|
124
|
+
* @param {number} blockData.y Block's y coordinate (relative to the parent).
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
function updateBlocksLayouts( blocksLayouts, blockData ) {
|
|
128
|
+
const { clientId, rootClientId, shouldRemove, ...layoutProps } = blockData;
|
|
129
|
+
|
|
130
|
+
if ( clientId && shouldRemove ) {
|
|
131
|
+
blocksLayouts.current = deleteBlockLayoutByClientId(
|
|
132
|
+
blocksLayouts.current,
|
|
133
|
+
clientId
|
|
134
|
+
);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if ( clientId && ! rootClientId ) {
|
|
139
|
+
blocksLayouts.current[ clientId ] = {
|
|
140
|
+
clientId,
|
|
141
|
+
rootClientId,
|
|
142
|
+
...layoutProps,
|
|
143
|
+
innerBlocks: {
|
|
144
|
+
...blocksLayouts.current[ clientId ]?.innerBlocks,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
} else if ( clientId && rootClientId ) {
|
|
148
|
+
const block = findBlockLayoutByClientId(
|
|
149
|
+
blocksLayouts.current,
|
|
150
|
+
rootClientId
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
if ( block ) {
|
|
154
|
+
block.innerBlocks[ clientId ] = {
|
|
155
|
+
clientId,
|
|
156
|
+
rootClientId,
|
|
157
|
+
...layoutProps,
|
|
158
|
+
innerBlocks: {
|
|
159
|
+
...block.innerBlocks[ clientId ]?.innerBlocks,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { Provider as BlockListProvider, Consumer as BlockListConsumer };
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Hook that returns the block list context.
|
|
170
|
+
*
|
|
171
|
+
* @return {Object} Block list context
|
|
172
|
+
*/
|
|
173
|
+
export const useBlockListContext = () => {
|
|
174
|
+
return useContext( Context );
|
|
175
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useCallback } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { useBlockListContext } from './block-list-context';
|
|
15
|
+
|
|
16
|
+
function BlockListItemCell( { children, clientId, rootClientId, onLayout } ) {
|
|
17
|
+
const { blocksLayouts, updateBlocksLayouts } = useBlockListContext();
|
|
18
|
+
|
|
19
|
+
useEffect( () => {
|
|
20
|
+
return () => {
|
|
21
|
+
updateBlocksLayouts( blocksLayouts, {
|
|
22
|
+
clientId,
|
|
23
|
+
shouldRemove: true,
|
|
24
|
+
} );
|
|
25
|
+
};
|
|
26
|
+
}, [] );
|
|
27
|
+
|
|
28
|
+
const onCellLayout = useCallback(
|
|
29
|
+
( event ) => {
|
|
30
|
+
const {
|
|
31
|
+
nativeEvent: { layout },
|
|
32
|
+
} = event;
|
|
33
|
+
updateBlocksLayouts( blocksLayouts, {
|
|
34
|
+
clientId,
|
|
35
|
+
rootClientId,
|
|
36
|
+
...layout,
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
if ( onLayout ) {
|
|
40
|
+
onLayout( event );
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[ clientId, rootClientId, updateBlocksLayouts, onLayout ]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return <View onLayout={ onCellLayout }>{ children }</View>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default BlockListItemCell;
|
|
@@ -121,6 +121,7 @@ export class BlockListItem extends Component {
|
|
|
121
121
|
blockWidth,
|
|
122
122
|
...restProps
|
|
123
123
|
} = this.props;
|
|
124
|
+
|
|
124
125
|
const readableContentViewStyle =
|
|
125
126
|
contentResizeMode === 'stretch' && stretchStyle;
|
|
126
127
|
const { isContainerRelated } = alignmentHelpers;
|
|
@@ -162,25 +163,20 @@ export class BlockListItem extends Component {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
render() {
|
|
165
|
-
const {
|
|
166
|
-
gridProperties,
|
|
167
|
-
clientId,
|
|
168
|
-
parentWidth,
|
|
169
|
-
items,
|
|
170
|
-
blockWidth,
|
|
171
|
-
} = this.props;
|
|
166
|
+
const { parentWidth, blockWidth, isGridItem } = this.props;
|
|
172
167
|
|
|
173
168
|
if ( ! blockWidth ) {
|
|
174
169
|
return null;
|
|
175
170
|
}
|
|
176
171
|
|
|
177
|
-
if (
|
|
172
|
+
if ( isGridItem ) {
|
|
173
|
+
const { numOfColumns, tileCount, tileIndex } = this.props;
|
|
178
174
|
return (
|
|
179
175
|
<Grid
|
|
180
|
-
numOfColumns={ gridProperties.numColumns }
|
|
181
|
-
tileCount={ items.length }
|
|
182
|
-
index={ items.indexOf( clientId ) }
|
|
183
176
|
maxWidth={ parentWidth }
|
|
177
|
+
numOfColumns={ numOfColumns }
|
|
178
|
+
tileCount={ tileCount }
|
|
179
|
+
index={ tileIndex }
|
|
184
180
|
>
|
|
185
181
|
{ this.renderContent() }
|
|
186
182
|
</Grid>
|
|
@@ -31,6 +31,7 @@ import BlockEdit from '../block-edit';
|
|
|
31
31
|
import BlockInvalidWarning from './block-invalid-warning';
|
|
32
32
|
import BlockMobileToolbar from '../block-mobile-toolbar';
|
|
33
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
|
+
import BlockDraggable from '../block-draggable';
|
|
34
35
|
|
|
35
36
|
const emptyArray = [];
|
|
36
37
|
function BlockForType( {
|
|
@@ -189,6 +190,8 @@ class BlockListBlock extends Component {
|
|
|
189
190
|
marginHorizontal,
|
|
190
191
|
isInnerBlockSelected,
|
|
191
192
|
name,
|
|
193
|
+
draggingEnabled,
|
|
194
|
+
draggingClientId,
|
|
192
195
|
} = this.props;
|
|
193
196
|
|
|
194
197
|
if ( ! attributes || ! blockType ) {
|
|
@@ -256,14 +259,23 @@ class BlockListBlock extends Component {
|
|
|
256
259
|
] }
|
|
257
260
|
/>
|
|
258
261
|
) }
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
<BlockDraggable
|
|
263
|
+
clientId={ clientId }
|
|
264
|
+
draggingClientId={ draggingClientId }
|
|
265
|
+
enabled={ draggingEnabled }
|
|
266
|
+
testID="draggable-trigger-content"
|
|
267
|
+
>
|
|
268
|
+
{ () =>
|
|
269
|
+
isValid ? (
|
|
270
|
+
this.getBlockForType()
|
|
271
|
+
) : (
|
|
272
|
+
<BlockInvalidWarning
|
|
273
|
+
blockTitle={ title }
|
|
274
|
+
icon={ icon }
|
|
275
|
+
/>
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
</BlockDraggable>
|
|
267
279
|
<View
|
|
268
280
|
style={ styles.neutralToolbar }
|
|
269
281
|
ref={ this.anchorNodeRef }
|
|
@@ -278,6 +290,7 @@ class BlockListBlock extends Component {
|
|
|
278
290
|
blockWidth={ blockWidth }
|
|
279
291
|
anchorNodeRef={ this.anchorNodeRef.current }
|
|
280
292
|
isFullWidth={ isFullWidthToolbar }
|
|
293
|
+
draggingClientId={ draggingClientId }
|
|
281
294
|
/>
|
|
282
295
|
) }
|
|
283
296
|
</View>
|
|
@@ -308,6 +321,7 @@ export default compose( [
|
|
|
308
321
|
withSelect( ( select, { clientId } ) => {
|
|
309
322
|
const {
|
|
310
323
|
getBlockIndex,
|
|
324
|
+
getBlockCount,
|
|
311
325
|
getSettings,
|
|
312
326
|
isBlockSelected,
|
|
313
327
|
getBlock,
|
|
@@ -315,6 +329,7 @@ export default compose( [
|
|
|
315
329
|
getLowestCommonAncestorWithSelectedBlock,
|
|
316
330
|
getBlockParents,
|
|
317
331
|
hasSelectedInnerBlock,
|
|
332
|
+
getBlockHierarchyRootClientId,
|
|
318
333
|
} = select( blockEditorStore );
|
|
319
334
|
|
|
320
335
|
const order = getBlockIndex( clientId );
|
|
@@ -359,6 +374,18 @@ export default compose( [
|
|
|
359
374
|
const baseGlobalStyles = getSettings()
|
|
360
375
|
?.__experimentalGlobalStylesBaseStyles;
|
|
361
376
|
|
|
377
|
+
const hasInnerBlocks = getBlockCount( clientId ) > 0;
|
|
378
|
+
// For blocks with inner blocks, we only enable the dragging in the nested
|
|
379
|
+
// blocks if any of them are selected. This way we prevent the long-press
|
|
380
|
+
// gesture from being disabled for elements within the block UI.
|
|
381
|
+
const draggingEnabled =
|
|
382
|
+
! hasInnerBlocks ||
|
|
383
|
+
isSelected ||
|
|
384
|
+
! hasSelectedInnerBlock( clientId, true );
|
|
385
|
+
// Dragging nested blocks is not supported yet. For this reason, the block to be dragged
|
|
386
|
+
// will be the top in the hierarchy.
|
|
387
|
+
const draggingClientId = getBlockHierarchyRootClientId( clientId );
|
|
388
|
+
|
|
362
389
|
return {
|
|
363
390
|
icon,
|
|
364
391
|
name: name || 'core/missing',
|
|
@@ -366,6 +393,8 @@ export default compose( [
|
|
|
366
393
|
title,
|
|
367
394
|
attributes,
|
|
368
395
|
blockType,
|
|
396
|
+
draggingClientId,
|
|
397
|
+
draggingEnabled,
|
|
369
398
|
isSelected,
|
|
370
399
|
isInnerBlockSelected,
|
|
371
400
|
isValid,
|
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
9
|
+
import { AsyncModeProvider, useSelect, useDispatch } from '@wordpress/data';
|
|
10
10
|
import { useViewportMatch, useMergeRefs } from '@wordpress/compose';
|
|
11
11
|
import { createContext, useState, useMemo } from '@wordpress/element';
|
|
12
12
|
|
|
@@ -48,6 +48,23 @@ function Root( { className, ...settings } ) {
|
|
|
48
48
|
},
|
|
49
49
|
[]
|
|
50
50
|
);
|
|
51
|
+
const { setBlockVisibility } = useDispatch( blockEditorStore );
|
|
52
|
+
const intersectionObserver = useMemo( () => {
|
|
53
|
+
const { IntersectionObserver: Observer } = window;
|
|
54
|
+
|
|
55
|
+
if ( ! Observer ) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return new Observer( ( entries ) => {
|
|
60
|
+
const updates = {};
|
|
61
|
+
for ( const entry of entries ) {
|
|
62
|
+
const clientId = entry.target.getAttribute( 'data-block' );
|
|
63
|
+
updates[ clientId ] = entry.isIntersecting;
|
|
64
|
+
}
|
|
65
|
+
setBlockVisibility( updates );
|
|
66
|
+
} );
|
|
67
|
+
}, [] );
|
|
51
68
|
const innerBlocksProps = useInnerBlocksProps(
|
|
52
69
|
{
|
|
53
70
|
ref: useMergeRefs( [
|
|
@@ -65,7 +82,9 @@ function Root( { className, ...settings } ) {
|
|
|
65
82
|
);
|
|
66
83
|
return (
|
|
67
84
|
<elementContext.Provider value={ element }>
|
|
68
|
-
<
|
|
85
|
+
<IntersectionObserver.Provider value={ intersectionObserver }>
|
|
86
|
+
<div { ...innerBlocksProps } />
|
|
87
|
+
</IntersectionObserver.Provider>
|
|
69
88
|
</elementContext.Provider>
|
|
70
89
|
);
|
|
71
90
|
}
|
|
@@ -90,34 +109,17 @@ function Items( {
|
|
|
90
109
|
__experimentalAppenderTagName,
|
|
91
110
|
__experimentalLayout: layout = defaultLayout,
|
|
92
111
|
} ) {
|
|
93
|
-
const
|
|
94
|
-
const intersectionObserver = useMemo( () => {
|
|
95
|
-
const { IntersectionObserver: Observer } = window;
|
|
96
|
-
|
|
97
|
-
if ( ! Observer ) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return new Observer( ( entries ) => {
|
|
102
|
-
setIntersectingBlocks( ( oldIntersectingBlocks ) => {
|
|
103
|
-
const newIntersectingBlocks = new Set( oldIntersectingBlocks );
|
|
104
|
-
for ( const entry of entries ) {
|
|
105
|
-
const clientId = entry.target.getAttribute( 'data-block' );
|
|
106
|
-
const action = entry.isIntersecting ? 'add' : 'delete';
|
|
107
|
-
newIntersectingBlocks[ action ]( clientId );
|
|
108
|
-
}
|
|
109
|
-
return newIntersectingBlocks;
|
|
110
|
-
} );
|
|
111
|
-
} );
|
|
112
|
-
}, [ setIntersectingBlocks ] );
|
|
113
|
-
const { order, selectedBlocks } = useSelect(
|
|
112
|
+
const { order, selectedBlocks, visibleBlocks } = useSelect(
|
|
114
113
|
( select ) => {
|
|
115
|
-
const {
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const {
|
|
115
|
+
getBlockOrder,
|
|
116
|
+
getSelectedBlockClientIds,
|
|
117
|
+
__unstableGetVisibleBlocks,
|
|
118
|
+
} = select( blockEditorStore );
|
|
118
119
|
return {
|
|
119
120
|
order: getBlockOrder( rootClientId ),
|
|
120
121
|
selectedBlocks: getSelectedBlockClientIds(),
|
|
122
|
+
visibleBlocks: __unstableGetVisibleBlocks(),
|
|
121
123
|
};
|
|
122
124
|
},
|
|
123
125
|
[ rootClientId ]
|
|
@@ -125,24 +127,22 @@ function Items( {
|
|
|
125
127
|
|
|
126
128
|
return (
|
|
127
129
|
<LayoutProvider value={ layout }>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
) ) }
|
|
145
|
-
</IntersectionObserver.Provider>
|
|
130
|
+
{ order.map( ( clientId ) => (
|
|
131
|
+
<AsyncModeProvider
|
|
132
|
+
key={ clientId }
|
|
133
|
+
value={
|
|
134
|
+
// Only provide data asynchronously if the block is
|
|
135
|
+
// not visible and not selected.
|
|
136
|
+
! visibleBlocks.has( clientId ) &&
|
|
137
|
+
! selectedBlocks.includes( clientId )
|
|
138
|
+
}
|
|
139
|
+
>
|
|
140
|
+
<BlockListBlock
|
|
141
|
+
rootClientId={ rootClientId }
|
|
142
|
+
clientId={ clientId }
|
|
143
|
+
/>
|
|
144
|
+
</AsyncModeProvider>
|
|
145
|
+
) ) }
|
|
146
146
|
{ order.length < 1 && placeholder }
|
|
147
147
|
<BlockListAppender
|
|
148
148
|
tagName={ __experimentalAppenderTagName }
|