@wordpress/block-editor 8.5.7 → 9.1.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 +5 -74
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +64 -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 +484 -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 +29 -6
- package/build/components/block-list/block.native.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-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +9 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.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 +191 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +85 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +216 -0
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- 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 +149 -44
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/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 +5 -23
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +31 -9
- package/build/components/inserter/index.native.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/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- 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 +1 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- 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-display-information/index.js +3 -1
- package/build/components/use-block-display-information/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/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +463 -44
- 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/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- 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/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- 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 +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- 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 +4 -70
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +50 -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 +449 -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 +28 -6
- package/build-module/components/block-list/block.native.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-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +8 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.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 +173 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +72 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- 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-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +199 -0
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- 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 +151 -46
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/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 +1 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +32 -11
- package/build-module/components/inserter/index.native.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/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- 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 +1 -5
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- 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-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/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/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +453 -44
- 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/dimensions.js +5 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- 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/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- 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 +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +148 -410
- package/build-style/style.css +148 -410
- package/package.json +28 -28
- 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 +9 -79
- package/src/components/block-content-overlay/style.scss +2 -11
- 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 +458 -0
- package/src/components/block-draggable/style.native.scss +19 -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 +38 -8
- 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-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- package/src/components/block-mobile-toolbar/index.native.js +8 -1
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/index.native.js +22 -6
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +6 -0
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +188 -0
- package/src/components/block-popover/index.js +75 -0
- package/src/components/block-popover/style.scss +28 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +2 -43
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -151
- package/src/components/block-tools/style.scss +12 -135
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +7 -3
- 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 +156 -62
- package/src/components/colors-gradients/style.scss +51 -23
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/gradients/README.md +29 -0
- 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 +1 -3
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- 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/navigable-toolbar/README.md +16 -0
- package/src/components/navigable-toolbar/index.js +12 -2
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +1 -3
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/url-input/index.js +9 -4
- package/src/components/use-block-display-information/index.js +2 -0
- 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/hooks/anchor.js +1 -1
- package/src/hooks/border.js +429 -72
- package/src/hooks/color-panel.js +13 -9
- package/src/hooks/color.scss +0 -62
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- 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/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js +0 -327
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -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-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js +0 -306
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.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-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -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( {
|
|
@@ -47,6 +48,7 @@ function BlockForType( {
|
|
|
47
48
|
onDeleteBlock,
|
|
48
49
|
onReplace,
|
|
49
50
|
parentWidth,
|
|
51
|
+
parentBlockAlignment,
|
|
50
52
|
wrapperProps,
|
|
51
53
|
blockWidth,
|
|
52
54
|
baseGlobalStyles,
|
|
@@ -95,6 +97,7 @@ function BlockForType( {
|
|
|
95
97
|
contentStyle={ contentStyle }
|
|
96
98
|
onDeleteBlock={ onDeleteBlock }
|
|
97
99
|
blockWidth={ blockWidth }
|
|
100
|
+
parentBlockAlignment={ parentBlockAlignment }
|
|
98
101
|
/>
|
|
99
102
|
<View onLayout={ getBlockWidth } />
|
|
100
103
|
</GlobalStylesContext.Provider>
|
|
@@ -187,6 +190,8 @@ class BlockListBlock extends Component {
|
|
|
187
190
|
marginHorizontal,
|
|
188
191
|
isInnerBlockSelected,
|
|
189
192
|
name,
|
|
193
|
+
draggingEnabled,
|
|
194
|
+
draggingClientId,
|
|
190
195
|
} = this.props;
|
|
191
196
|
|
|
192
197
|
if ( ! attributes || ! blockType ) {
|
|
@@ -254,14 +259,22 @@ class BlockListBlock extends Component {
|
|
|
254
259
|
] }
|
|
255
260
|
/>
|
|
256
261
|
) }
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
<BlockDraggable
|
|
263
|
+
clientId={ clientId }
|
|
264
|
+
draggingClientId={ draggingClientId }
|
|
265
|
+
enabled={ draggingEnabled }
|
|
266
|
+
>
|
|
267
|
+
{ () =>
|
|
268
|
+
isValid ? (
|
|
269
|
+
this.getBlockForType()
|
|
270
|
+
) : (
|
|
271
|
+
<BlockInvalidWarning
|
|
272
|
+
blockTitle={ title }
|
|
273
|
+
icon={ icon }
|
|
274
|
+
/>
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
</BlockDraggable>
|
|
265
278
|
<View
|
|
266
279
|
style={ styles.neutralToolbar }
|
|
267
280
|
ref={ this.anchorNodeRef }
|
|
@@ -276,6 +289,7 @@ class BlockListBlock extends Component {
|
|
|
276
289
|
blockWidth={ blockWidth }
|
|
277
290
|
anchorNodeRef={ this.anchorNodeRef.current }
|
|
278
291
|
isFullWidth={ isFullWidthToolbar }
|
|
292
|
+
draggingClientId={ draggingClientId }
|
|
279
293
|
/>
|
|
280
294
|
) }
|
|
281
295
|
</View>
|
|
@@ -306,6 +320,7 @@ export default compose( [
|
|
|
306
320
|
withSelect( ( select, { clientId } ) => {
|
|
307
321
|
const {
|
|
308
322
|
getBlockIndex,
|
|
323
|
+
getBlockCount,
|
|
309
324
|
getSettings,
|
|
310
325
|
isBlockSelected,
|
|
311
326
|
getBlock,
|
|
@@ -313,6 +328,7 @@ export default compose( [
|
|
|
313
328
|
getLowestCommonAncestorWithSelectedBlock,
|
|
314
329
|
getBlockParents,
|
|
315
330
|
hasSelectedInnerBlock,
|
|
331
|
+
getBlockHierarchyRootClientId,
|
|
316
332
|
} = select( blockEditorStore );
|
|
317
333
|
|
|
318
334
|
const order = getBlockIndex( clientId );
|
|
@@ -357,6 +373,18 @@ export default compose( [
|
|
|
357
373
|
const baseGlobalStyles = getSettings()
|
|
358
374
|
?.__experimentalGlobalStylesBaseStyles;
|
|
359
375
|
|
|
376
|
+
const hasInnerBlocks = getBlockCount( clientId ) > 0;
|
|
377
|
+
// For blocks with inner blocks, we only enable the dragging in the nested
|
|
378
|
+
// blocks if any of them are selected. This way we prevent the long-press
|
|
379
|
+
// gesture from being disabled for elements within the block UI.
|
|
380
|
+
const draggingEnabled =
|
|
381
|
+
! hasInnerBlocks ||
|
|
382
|
+
isSelected ||
|
|
383
|
+
! hasSelectedInnerBlock( clientId, true );
|
|
384
|
+
// Dragging nested blocks is not supported yet. For this reason, the block to be dragged
|
|
385
|
+
// will be the top in the hierarchy.
|
|
386
|
+
const draggingClientId = getBlockHierarchyRootClientId( clientId );
|
|
387
|
+
|
|
360
388
|
return {
|
|
361
389
|
icon,
|
|
362
390
|
name: name || 'core/missing',
|
|
@@ -364,6 +392,8 @@ export default compose( [
|
|
|
364
392
|
title,
|
|
365
393
|
attributes,
|
|
366
394
|
blockType,
|
|
395
|
+
draggingClientId,
|
|
396
|
+
draggingEnabled,
|
|
367
397
|
isSelected,
|
|
368
398
|
isInnerBlockSelected,
|
|
369
399
|
isValid,
|
|
@@ -25,10 +25,15 @@ import { __ } from '@wordpress/i18n';
|
|
|
25
25
|
import styles from './style.scss';
|
|
26
26
|
import BlockListAppender from '../block-list-appender';
|
|
27
27
|
import BlockListItem from './block-list-item';
|
|
28
|
+
import BlockListItemCell from './block-list-item-cell';
|
|
29
|
+
import {
|
|
30
|
+
BlockListProvider,
|
|
31
|
+
BlockListConsumer,
|
|
32
|
+
DEFAULT_BLOCK_LIST_CONTEXT,
|
|
33
|
+
} from './block-list-context';
|
|
34
|
+
import { BlockDraggableWrapper } from '../block-draggable';
|
|
28
35
|
import { store as blockEditorStore } from '../../store';
|
|
29
36
|
|
|
30
|
-
const BlockListContext = createContext();
|
|
31
|
-
|
|
32
37
|
export const OnCaretVerticalPositionChange = createContext();
|
|
33
38
|
|
|
34
39
|
const stylesMemo = {};
|
|
@@ -78,6 +83,9 @@ export class BlockList extends Component {
|
|
|
78
83
|
);
|
|
79
84
|
this.renderEmptyList = this.renderEmptyList.bind( this );
|
|
80
85
|
this.getExtraData = this.getExtraData.bind( this );
|
|
86
|
+
this.getCellRendererComponent = this.getCellRendererComponent.bind(
|
|
87
|
+
this
|
|
88
|
+
);
|
|
81
89
|
|
|
82
90
|
this.onLayout = this.onLayout.bind( this );
|
|
83
91
|
|
|
@@ -154,6 +162,18 @@ export class BlockList extends Component {
|
|
|
154
162
|
return this.extraData;
|
|
155
163
|
}
|
|
156
164
|
|
|
165
|
+
getCellRendererComponent( { children, item, onLayout } ) {
|
|
166
|
+
const { rootClientId } = this.props;
|
|
167
|
+
return (
|
|
168
|
+
<BlockListItemCell
|
|
169
|
+
children={ children }
|
|
170
|
+
clientId={ item }
|
|
171
|
+
onLayout={ onLayout }
|
|
172
|
+
rootClientId={ rootClientId }
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
157
177
|
onLayout( { nativeEvent } ) {
|
|
158
178
|
const { layout } = nativeEvent;
|
|
159
179
|
const { blockWidth } = this.state;
|
|
@@ -170,20 +190,27 @@ export class BlockList extends Component {
|
|
|
170
190
|
}
|
|
171
191
|
|
|
172
192
|
render() {
|
|
173
|
-
const { isRootList } = this.props;
|
|
193
|
+
const { isRootList, isRTL } = this.props;
|
|
174
194
|
// Use of Context to propagate the main scroll ref to its children e.g InnerBlocks.
|
|
175
195
|
const blockList = isRootList ? (
|
|
176
|
-
<
|
|
177
|
-
{
|
|
178
|
-
|
|
196
|
+
<BlockListProvider
|
|
197
|
+
value={ {
|
|
198
|
+
...DEFAULT_BLOCK_LIST_CONTEXT,
|
|
199
|
+
scrollRef: this.scrollViewRef,
|
|
200
|
+
} }
|
|
201
|
+
>
|
|
202
|
+
<BlockDraggableWrapper isRTL={ isRTL }>
|
|
203
|
+
{ ( { onScroll } ) => this.renderList( { onScroll } ) }
|
|
204
|
+
</BlockDraggableWrapper>
|
|
205
|
+
</BlockListProvider>
|
|
179
206
|
) : (
|
|
180
|
-
<
|
|
181
|
-
{ (
|
|
207
|
+
<BlockListConsumer>
|
|
208
|
+
{ ( { scrollRef } ) =>
|
|
182
209
|
this.renderList( {
|
|
183
|
-
parentScrollRef:
|
|
210
|
+
parentScrollRef: scrollRef,
|
|
184
211
|
} )
|
|
185
212
|
}
|
|
186
|
-
</
|
|
213
|
+
</BlockListConsumer>
|
|
187
214
|
);
|
|
188
215
|
|
|
189
216
|
return (
|
|
@@ -212,7 +239,7 @@ export class BlockList extends Component {
|
|
|
212
239
|
contentResizeMode,
|
|
213
240
|
blockWidth,
|
|
214
241
|
} = this.props;
|
|
215
|
-
const { parentScrollRef } = extraProps;
|
|
242
|
+
const { parentScrollRef, onScroll } = extraProps;
|
|
216
243
|
|
|
217
244
|
const {
|
|
218
245
|
blockToolbar,
|
|
@@ -279,6 +306,7 @@ export class BlockList extends Component {
|
|
|
279
306
|
data={ blockClientIds }
|
|
280
307
|
keyExtractor={ identity }
|
|
281
308
|
renderItem={ this.renderItem }
|
|
309
|
+
CellRendererComponent={ this.getCellRendererComponent }
|
|
282
310
|
shouldPreventAutomaticScroll={
|
|
283
311
|
this.shouldFlatListPreventAutomaticScroll
|
|
284
312
|
}
|
|
@@ -286,6 +314,7 @@ export class BlockList extends Component {
|
|
|
286
314
|
ListHeaderComponent={ header }
|
|
287
315
|
ListEmptyComponent={ ! isReadOnly && this.renderEmptyList }
|
|
288
316
|
ListFooterComponent={ this.renderBlockListFooter }
|
|
317
|
+
onScroll={ onScroll }
|
|
289
318
|
/>
|
|
290
319
|
{ this.shouldShowInnerBlockAppender() && (
|
|
291
320
|
<View
|
|
@@ -321,6 +350,15 @@ export class BlockList extends Component {
|
|
|
321
350
|
gridProperties,
|
|
322
351
|
} = this.props;
|
|
323
352
|
const { blockWidth } = this.state;
|
|
353
|
+
|
|
354
|
+
// Extracting the grid item properties here to avoid
|
|
355
|
+
// re-renders in the blockListItem component.
|
|
356
|
+
const isGridItem = !! gridProperties;
|
|
357
|
+
const gridItemProps = gridProperties && {
|
|
358
|
+
numOfColumns: gridProperties.numColumns,
|
|
359
|
+
tileCount: blockClientIds.length,
|
|
360
|
+
tileIndex: blockClientIds.indexOf( clientId ),
|
|
361
|
+
};
|
|
324
362
|
return (
|
|
325
363
|
<BlockListItem
|
|
326
364
|
isStackedHorizontally={ isStackedHorizontally }
|
|
@@ -337,8 +375,8 @@ export class BlockList extends Component {
|
|
|
337
375
|
this.shouldShowInnerBlockAppender
|
|
338
376
|
}
|
|
339
377
|
blockWidth={ blockWidth }
|
|
340
|
-
|
|
341
|
-
|
|
378
|
+
isGridItem={ isGridItem }
|
|
379
|
+
{ ...gridItemProps }
|
|
342
380
|
/>
|
|
343
381
|
);
|
|
344
382
|
}
|
|
@@ -401,6 +439,8 @@ export default compose( [
|
|
|
401
439
|
|
|
402
440
|
const isFloatingToolbarVisible =
|
|
403
441
|
!! selectedBlockClientId && hasRootInnerBlocks;
|
|
442
|
+
const isRTL = getSettings().isRTL;
|
|
443
|
+
|
|
404
444
|
return {
|
|
405
445
|
blockClientIds,
|
|
406
446
|
blockCount,
|
|
@@ -411,6 +451,7 @@ export default compose( [
|
|
|
411
451
|
isFloatingToolbarVisible,
|
|
412
452
|
isStackedHorizontally,
|
|
413
453
|
maxWidth,
|
|
454
|
+
isRTL,
|
|
414
455
|
};
|
|
415
456
|
}
|
|
416
457
|
),
|
|
@@ -262,12 +262,17 @@
|
|
|
262
262
|
right: $border-width;
|
|
263
263
|
bottom: $border-width;
|
|
264
264
|
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
|
|
265
|
-
|
|
265
|
+
// Border is outset, so subtract the width to achieve correct radius.
|
|
266
|
+
border-radius: $radius-block-ui - $border-width;
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
&.is-selected {
|
|
270
|
-
cursor:
|
|
271
|
+
cursor: default;
|
|
272
|
+
|
|
273
|
+
&.rich-text {
|
|
274
|
+
cursor: unset;
|
|
275
|
+
}
|
|
271
276
|
|
|
272
277
|
&::after {
|
|
273
278
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); // Selected not focussed.
|
|
@@ -303,22 +308,6 @@
|
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
// Active entity spotlight.
|
|
307
|
-
// Disable if focus mode is active.
|
|
308
|
-
.is-root-container:not(.is-focus-mode) .block-editor-block-list__block.has-active-entity {
|
|
309
|
-
opacity: 0.5;
|
|
310
|
-
transition: opacity 0.1s linear;
|
|
311
|
-
@include reduce-motion("transition");
|
|
312
|
-
|
|
313
|
-
&.is-active-entity,
|
|
314
|
-
&.has-child-selected,
|
|
315
|
-
&:not(.has-child-selected) .block-editor-block-list__block,
|
|
316
|
-
&.is-active-entity .block-editor-block-list__block,
|
|
317
|
-
.is-active-entity .block-editor-block-list__block {
|
|
318
|
-
opacity: 1;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
311
|
.wp-block[data-align="left"] > *,
|
|
323
312
|
.wp-block[data-align="right"] > *,
|
|
324
313
|
.wp-block.alignleft,
|