@wordpress/block-editor 12.20.0 → 12.21.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 +2 -0
- package/build/components/block-actions/index.js +45 -32
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-bindings-toolbar-indicator/index.js +25 -0
- package/build/components/block-bindings-toolbar-indicator/index.js.map +1 -0
- package/build/components/block-edit/context.js +2 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +8 -3
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +1 -1
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +23 -7
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.native.js +0 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-popover/cover.js +68 -0
- package/build/components/block-popover/cover.js.map +1 -0
- package/build/components/block-popover/drop-zone.js +2 -3
- package/build/components/block-popover/drop-zone.js.map +1 -1
- package/build/components/block-popover/index.js +1 -19
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +12 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +21 -10
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +89 -0
- package/build/components/block-toolbar/shuffle.js.map +1 -0
- package/build/components/block-toolbar/use-has-block-toolbar.js +43 -0
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +2 -5
- package/build/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build/components/block-tools/index.js +9 -26
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +60 -0
- package/build/components/block-tools/use-show-block-tools.js.map +1 -0
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/color-palette/control.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/global-styles/border-panel.js +21 -8
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/index.js +6 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +80 -23
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +7 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +15 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js +77 -0
- package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -0
- package/build/components/grid-visualizer/grid-visualizer.js +81 -0
- package/build/components/grid-visualizer/grid-visualizer.js.map +1 -0
- package/build/components/grid-visualizer/index.js +20 -0
- package/build/components/grid-visualizer/index.js.map +1 -0
- package/build/components/grid-visualizer/utils.js +10 -0
- package/build/components/grid-visualizer/utils.js.map +1 -0
- package/build/components/iframe/index.js +61 -16
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.native.js +7 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +8 -2
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +9 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +2 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +1 -1
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/link-preview.js +4 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-select-button.js +10 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-clipboard-handler.js +2 -1
- package/build/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +3 -5
- package/build/components/resizable-box-popover/index.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -1
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +46 -26
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +3 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-popover/index.js +3 -3
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +2 -1
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/components/writing-flow/utils.js +23 -6
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +34 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/border.js +6 -4
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +3 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +6 -7
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +39 -0
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +11 -4
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +115 -0
- package/build/hooks/spacing-visualizer.js.map +1 -0
- package/build/hooks/use-bindings-attributes.js +171 -48
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-typography-props.js +1 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/layouts/grid.js +6 -2
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +7 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +42 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +29 -55
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -8
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +3 -20
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +27 -15
- package/build/store/selectors.js.map +1 -1
- package/build/utils/calculate-scale.js +17 -0
- package/build/utils/calculate-scale.js.map +1 -0
- package/build-module/components/block-actions/index.js +45 -32
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-bindings-toolbar-indicator/index.js +18 -0
- package/build-module/components/block-bindings-toolbar-indicator/index.js.map +1 -0
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -4
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -5
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +1 -1
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +23 -7
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +0 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -2
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-popover/cover.js +60 -0
- package/build-module/components/block-popover/cover.js.map +1 -0
- package/build-module/components/block-popover/drop-zone.js +2 -3
- package/build-module/components/block-popover/drop-zone.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -19
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -5
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -10
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +21 -11
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +82 -0
- package/build-module/components/block-toolbar/shuffle.js.map +1 -0
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +36 -0
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +2 -5
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build-module/components/block-tools/index.js +9 -26
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +54 -0
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -0
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/color-palette/control.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -1
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +22 -10
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +82 -24
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +7 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +16 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js +69 -0
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid-visualizer/grid-visualizer.js +73 -0
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -0
- package/build-module/components/grid-visualizer/index.js +3 -0
- package/build-module/components/grid-visualizer/index.js.map +1 -0
- package/build-module/components/grid-visualizer/utils.js +4 -0
- package/build-module/components/grid-visualizer/utils.js.map +1 -0
- package/build-module/components/iframe/index.js +61 -16
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +8 -2
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +9 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +2 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +1 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +11 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-clipboard-handler.js +3 -2
- package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +3 -5
- package/build-module/components/resizable-box-popover/index.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -1
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +47 -28
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +3 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-popover/index.js +3 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +3 -2
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +22 -7
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +34 -8
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/border.js +7 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +1 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +7 -8
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +39 -0
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +11 -4
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +106 -0
- package/build-module/hooks/spacing-visualizer.js.map +1 -0
- package/build-module/hooks/use-bindings-attributes.js +172 -49
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +2 -3
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/layouts/grid.js +6 -2
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +7 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +42 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +29 -54
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +3 -20
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +23 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/calculate-scale.js +11 -0
- package/build-module/utils/calculate-scale.js.map +1 -0
- package/build-style/content-rtl.css +8 -2
- package/build-style/content.css +8 -2
- package/build-style/default-editor-styles-rtl.css +1 -0
- package/build-style/default-editor-styles.css +1 -0
- package/build-style/style-rtl.css +113 -22
- package/build-style/style.css +113 -22
- package/package.json +31 -31
- package/src/components/block-actions/index.js +57 -47
- package/src/components/block-bindings-toolbar-indicator/index.js +20 -0
- package/src/components/block-bindings-toolbar-indicator/style.scss +14 -0
- package/src/components/block-draggable/test/index.native.js +2 -2
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +5 -1
- package/src/components/block-inspector/index.js +7 -5
- package/src/components/block-list/block-invalid-warning.native.js +1 -1
- package/src/components/block-list/block-list-item.native.js +1 -1
- package/src/components/block-list/block-outline.native.js +36 -21
- package/src/components/block-list/block-selection-button.native.js +1 -3
- package/src/components/block-list/block.native.js +0 -3
- package/src/components/block-list/content.scss +5 -1
- package/src/components/block-list/test/block-outline.native.js +255 -0
- package/src/components/block-list/use-block-props/index.js +12 -2
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -7
- package/src/components/block-mover/index.native.js +1 -1
- package/src/components/block-popover/cover.js +63 -0
- package/src/components/block-popover/drop-zone.js +3 -4
- package/src/components/block-popover/index.js +1 -28
- package/src/components/block-preview/index.js +3 -1
- package/src/components/block-removal-warning-modal/index.js +5 -19
- package/src/components/block-rename/modal.js +1 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +12 -9
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -1
- package/src/components/block-toolbar/block-toolbar-menu.native.js +2 -2
- package/src/components/block-toolbar/index.js +19 -15
- package/src/components/block-toolbar/shuffle.js +93 -0
- package/src/components/block-toolbar/use-has-block-toolbar.js +49 -0
- package/src/components/block-tools/block-selection-button.js +4 -0
- package/src/components/block-tools/empty-block-inserter.js +3 -6
- package/src/components/block-tools/index.js +13 -36
- package/src/components/block-tools/use-show-block-tools.js +73 -0
- package/src/components/caption/index.native.js +1 -1
- package/src/components/child-layout-control/index.js +1 -1
- package/src/components/color-palette/control.js +1 -1
- package/src/components/colors-gradients/control.js +1 -1
- package/src/components/colors-gradients/test/control.js +2 -2
- package/src/components/contrast-checker/test/index.js +10 -10
- package/src/components/default-block-appender/content.scss +5 -2
- package/src/components/global-styles/border-panel.js +35 -24
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/image-settings-panel.js +1 -1
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/shadow-panel-components.js +92 -23
- package/src/components/global-styles/style.scss +33 -10
- package/src/components/global-styles/test/typography-utils.js +231 -81
- package/src/components/global-styles/typography-utils.js +10 -7
- package/src/components/global-styles/use-global-styles-output.js +14 -16
- package/src/components/global-styles/utils.js +2 -8
- package/src/components/grid-visualizer/grid-item-resizer.js +100 -0
- package/src/components/grid-visualizer/grid-visualizer.js +81 -0
- package/src/components/grid-visualizer/index.js +2 -0
- package/src/components/grid-visualizer/style.scss +33 -0
- package/src/components/grid-visualizer/utils.js +5 -0
- package/src/components/iframe/index.js +78 -31
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +12 -2
- package/src/components/inserter/media-tab/media-preview.js +1 -1
- package/src/components/inserter/menu.js +10 -4
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/mobile-tab-navigation.js +1 -1
- package/src/components/inserter/search-results.js +2 -1
- package/src/components/inserter/style.scss +10 -0
- package/src/components/inserter/tabs.js +2 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -2
- package/src/components/inspector-controls-tabs/index.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/src/components/line-height-control/test/index.js +1 -1
- package/src/components/link-control/link-preview.js +9 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/style.scss +9 -0
- package/src/components/list-view/block-select-button.js +16 -2
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/index.js +1 -1
- package/src/components/list-view/style.scss +8 -0
- package/src/components/list-view/use-clipboard-handler.js +3 -2
- package/src/components/panel-color-settings/index.js +1 -1
- package/src/components/panel-color-settings/test/index.js +3 -3
- package/src/components/provider/index.js +1 -4
- package/src/components/resizable-box-popover/index.js +4 -6
- package/src/components/responsive-block-control/README.md +4 -4
- package/src/components/responsive-block-control/index.js +1 -1
- package/src/components/responsive-block-control/test/index.js +5 -5
- package/src/components/rich-text/index.js +76 -53
- package/src/components/rich-text/use-enter.js +4 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
- package/src/components/url-popover/index.js +5 -5
- package/src/components/url-popover/style.scss +1 -0
- package/src/components/writing-flow/use-clipboard-handler.js +3 -2
- package/src/components/writing-flow/utils.js +31 -16
- package/src/hooks/background.js +1 -1
- package/src/hooks/block-hooks.js +47 -9
- package/src/hooks/block-hooks.scss +6 -0
- package/src/hooks/border.js +16 -4
- package/src/hooks/dimensions.js +1 -2
- package/src/hooks/font-size.js +7 -12
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout-child.js +38 -0
- package/src/hooks/layout.js +12 -1
- package/src/hooks/line-height.js +1 -1
- package/src/hooks/spacing-visualizer.js +126 -0
- package/src/hooks/{padding.scss → spacing.scss} +1 -1
- package/src/hooks/use-bindings-attributes.js +215 -65
- package/src/hooks/use-typography-props.js +2 -8
- package/src/layouts/grid.js +8 -3
- package/src/private-apis.js +6 -2
- package/src/store/actions.js +56 -18
- package/src/store/private-actions.js +34 -79
- package/src/store/private-selectors.js +0 -8
- package/src/store/reducer.js +2 -23
- package/src/store/selectors.js +41 -46
- package/src/store/test/actions.js +0 -4
- package/src/style.scss +3 -1
- package/src/utils/calculate-scale.js +20 -0
- package/build/hooks/margin.js +0 -86
- package/build/hooks/margin.js.map +0 -1
- package/build/hooks/padding.js +0 -78
- package/build/hooks/padding.js.map +0 -1
- package/build/utils/use-can-block-toolbar-be-focused.js +0 -46
- package/build/utils/use-can-block-toolbar-be-focused.js.map +0 -1
- package/build-module/hooks/margin.js +0 -78
- package/build-module/hooks/margin.js.map +0 -1
- package/build-module/hooks/padding.js +0 -70
- package/build-module/hooks/padding.js.map +0 -1
- package/build-module/utils/use-can-block-toolbar-be-focused.js +0 -40
- package/build-module/utils/use-can-block-toolbar-be-focused.js.map +0 -1
- package/src/hooks/margin.js +0 -91
- package/src/hooks/padding.js +0 -82
- package/src/utils/use-can-block-toolbar-be-focused.js +0 -48
|
@@ -19,13 +19,17 @@ import useMovingAnimation from '../../use-moving-animation';
|
|
|
19
19
|
import { PrivateBlockContext } from '../private-block-context';
|
|
20
20
|
import { useFocusFirstElement } from './use-focus-first-element';
|
|
21
21
|
import { useIsHovered } from './use-is-hovered';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
blockBindingsKey,
|
|
24
|
+
useBlockEditContext,
|
|
25
|
+
} from '../../block-edit/context';
|
|
23
26
|
import { useFocusHandler } from './use-focus-handler';
|
|
24
27
|
import { useEventHandlers } from './use-selected-block-event-handlers';
|
|
25
28
|
import { useNavModeExit } from './use-nav-mode-exit';
|
|
26
29
|
import { useBlockRefProvider } from './use-block-refs';
|
|
27
30
|
import { useIntersectionObserver } from './use-intersection-observer';
|
|
28
31
|
import { useFlashEditableBlocks } from '../../use-flash-editable-blocks';
|
|
32
|
+
import { canBindBlock } from '../../../hooks/use-bindings-attributes';
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* This hook is used to lightly mark an element as a block element. The element
|
|
@@ -123,6 +127,12 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
|
|
|
123
127
|
] );
|
|
124
128
|
|
|
125
129
|
const blockEditContext = useBlockEditContext();
|
|
130
|
+
const hasBlockBindings = !! blockEditContext[ blockBindingsKey ];
|
|
131
|
+
const bindingsStyle =
|
|
132
|
+
hasBlockBindings && canBindBlock( name )
|
|
133
|
+
? { '--wp-admin-theme-color': 'var(--wp-bound-block-color)' }
|
|
134
|
+
: {};
|
|
135
|
+
|
|
126
136
|
// Ensures it warns only inside the `edit` implementation for the block.
|
|
127
137
|
if ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {
|
|
128
138
|
warning(
|
|
@@ -168,7 +178,7 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
|
|
|
168
178
|
wrapperProps.className,
|
|
169
179
|
defaultClassName
|
|
170
180
|
),
|
|
171
|
-
style: { ...wrapperProps.style, ...props.style },
|
|
181
|
+
style: { ...wrapperProps.style, ...props.style, ...bindingsStyle },
|
|
172
182
|
};
|
|
173
183
|
}
|
|
174
184
|
|
|
@@ -22,7 +22,7 @@ import { store as blockEditorStore } from '../../../store';
|
|
|
22
22
|
export function useEventHandlers( { clientId, isSelected } ) {
|
|
23
23
|
const { getBlockRootClientId, getBlockIndex } =
|
|
24
24
|
useSelect( blockEditorStore );
|
|
25
|
-
const {
|
|
25
|
+
const { insertAfterBlock, removeBlock } = useDispatch( blockEditorStore );
|
|
26
26
|
|
|
27
27
|
return useRefEffect(
|
|
28
28
|
( node ) => {
|
|
@@ -57,11 +57,7 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
57
57
|
event.preventDefault();
|
|
58
58
|
|
|
59
59
|
if ( keyCode === ENTER ) {
|
|
60
|
-
|
|
61
|
-
{},
|
|
62
|
-
getBlockRootClientId( clientId ),
|
|
63
|
-
getBlockIndex( clientId ) + 1
|
|
64
|
-
);
|
|
60
|
+
insertAfterBlock( clientId );
|
|
65
61
|
} else {
|
|
66
62
|
removeBlock( clientId );
|
|
67
63
|
}
|
|
@@ -90,7 +86,7 @@ export function useEventHandlers( { clientId, isSelected } ) {
|
|
|
90
86
|
isSelected,
|
|
91
87
|
getBlockRootClientId,
|
|
92
88
|
getBlockIndex,
|
|
93
|
-
|
|
89
|
+
insertAfterBlock,
|
|
94
90
|
removeBlock,
|
|
95
91
|
]
|
|
96
92
|
);
|
|
@@ -133,7 +133,7 @@ export const BlockMover = ( {
|
|
|
133
133
|
options={ blockPageMoverOptions }
|
|
134
134
|
onChange={ onPickerSelect }
|
|
135
135
|
title={ __( 'Change block position' ) }
|
|
136
|
-
leftAlign
|
|
136
|
+
leftAlign
|
|
137
137
|
hideCancelButton={ Platform.OS !== 'ios' }
|
|
138
138
|
/>
|
|
139
139
|
</ToolbarGroup>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect, useState, useMemo, forwardRef } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
10
|
+
import BlockPopover from '.';
|
|
11
|
+
|
|
12
|
+
function BlockPopoverCover(
|
|
13
|
+
{ clientId, bottomClientId, children, shift = false, ...props },
|
|
14
|
+
ref
|
|
15
|
+
) {
|
|
16
|
+
bottomClientId ??= clientId;
|
|
17
|
+
|
|
18
|
+
const selectedElement = useBlockElement( clientId );
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<BlockPopover
|
|
22
|
+
ref={ ref }
|
|
23
|
+
clientId={ clientId }
|
|
24
|
+
bottomClientId={ bottomClientId }
|
|
25
|
+
shift={ shift }
|
|
26
|
+
{ ...props }
|
|
27
|
+
>
|
|
28
|
+
{ selectedElement && clientId === bottomClientId ? (
|
|
29
|
+
<CoverContainer selectedElement={ selectedElement }>
|
|
30
|
+
{ children }
|
|
31
|
+
</CoverContainer>
|
|
32
|
+
) : (
|
|
33
|
+
children
|
|
34
|
+
) }
|
|
35
|
+
</BlockPopover>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function CoverContainer( { selectedElement, children } ) {
|
|
40
|
+
const [ width, setWidth ] = useState( selectedElement.offsetWidth );
|
|
41
|
+
const [ height, setHeight ] = useState( selectedElement.offsetHeight );
|
|
42
|
+
|
|
43
|
+
useEffect( () => {
|
|
44
|
+
const observer = new window.ResizeObserver( () => {
|
|
45
|
+
setWidth( selectedElement.offsetWidth );
|
|
46
|
+
setHeight( selectedElement.offsetHeight );
|
|
47
|
+
} );
|
|
48
|
+
observer.observe( selectedElement, { box: 'border-box' } );
|
|
49
|
+
return () => observer.disconnect();
|
|
50
|
+
}, [ selectedElement ] );
|
|
51
|
+
|
|
52
|
+
const style = useMemo( () => {
|
|
53
|
+
return {
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
width,
|
|
56
|
+
height,
|
|
57
|
+
};
|
|
58
|
+
}, [ width, height ] );
|
|
59
|
+
|
|
60
|
+
return <div style={ style }>{ children }</div>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default forwardRef( BlockPopoverCover );
|
|
@@ -9,7 +9,7 @@ import { __unstableMotion as motion } from '@wordpress/components';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { store as blockEditorStore } from '../../store';
|
|
12
|
-
import
|
|
12
|
+
import BlockPopoverCover from './cover';
|
|
13
13
|
|
|
14
14
|
const animateVariants = {
|
|
15
15
|
hide: { opacity: 0, scaleY: 0.75 },
|
|
@@ -38,9 +38,8 @@ function BlockDropZonePopover( {
|
|
|
38
38
|
const reducedMotion = useReducedMotion();
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
|
-
<
|
|
41
|
+
<BlockPopoverCover
|
|
42
42
|
clientId={ clientId }
|
|
43
|
-
__unstableCoverTarget
|
|
44
43
|
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
45
44
|
__unstableContentRef={ __unstableContentRef }
|
|
46
45
|
className="block-editor-block-popover__drop-zone"
|
|
@@ -56,7 +55,7 @@ function BlockDropZonePopover( {
|
|
|
56
55
|
}
|
|
57
56
|
className="block-editor-block-popover__drop-zone-foreground"
|
|
58
57
|
/>
|
|
59
|
-
</
|
|
58
|
+
</BlockPopoverCover>
|
|
60
59
|
);
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -28,8 +28,6 @@ function BlockPopover(
|
|
|
28
28
|
clientId,
|
|
29
29
|
bottomClientId,
|
|
30
30
|
children,
|
|
31
|
-
__unstableRefreshSize,
|
|
32
|
-
__unstableCoverTarget = false,
|
|
33
31
|
__unstablePopoverSlot,
|
|
34
32
|
__unstableContentRef,
|
|
35
33
|
shift = true,
|
|
@@ -75,30 +73,6 @@ function BlockPopover(
|
|
|
75
73
|
};
|
|
76
74
|
}, [ selectedElement ] );
|
|
77
75
|
|
|
78
|
-
const style = useMemo( () => {
|
|
79
|
-
if (
|
|
80
|
-
// popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
81
|
-
// than 0. This check is only there to satisfy the correctness of the
|
|
82
|
-
// exhaustive-deps rule for the `useMemo` hook.
|
|
83
|
-
popoverDimensionsRecomputeCounter < 0 ||
|
|
84
|
-
! selectedElement ||
|
|
85
|
-
lastSelectedElement !== selectedElement
|
|
86
|
-
) {
|
|
87
|
-
return {};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
position: 'absolute',
|
|
92
|
-
width: selectedElement.offsetWidth,
|
|
93
|
-
height: selectedElement.offsetHeight,
|
|
94
|
-
};
|
|
95
|
-
}, [
|
|
96
|
-
selectedElement,
|
|
97
|
-
lastSelectedElement,
|
|
98
|
-
__unstableRefreshSize,
|
|
99
|
-
popoverDimensionsRecomputeCounter,
|
|
100
|
-
] );
|
|
101
|
-
|
|
102
76
|
const popoverAnchor = useMemo( () => {
|
|
103
77
|
if (
|
|
104
78
|
// popoverDimensionsRecomputeCounter is by definition always equal or greater
|
|
@@ -176,8 +150,7 @@ function BlockPopover(
|
|
|
176
150
|
) }
|
|
177
151
|
variant="unstyled"
|
|
178
152
|
>
|
|
179
|
-
{
|
|
180
|
-
{ ! __unstableCoverTarget && children }
|
|
153
|
+
{ children }
|
|
181
154
|
</Popover>
|
|
182
155
|
);
|
|
183
156
|
}
|
|
@@ -20,11 +20,13 @@ import EditorStyles from '../editor-styles';
|
|
|
20
20
|
import { store as blockEditorStore } from '../../store';
|
|
21
21
|
import { BlockListItems } from '../block-list';
|
|
22
22
|
|
|
23
|
+
const EMPTY_ADDITIONAL_STYLES = [];
|
|
24
|
+
|
|
23
25
|
export function BlockPreview( {
|
|
24
26
|
blocks,
|
|
25
27
|
viewportWidth = 1200,
|
|
26
28
|
minHeight,
|
|
27
|
-
additionalStyles =
|
|
29
|
+
additionalStyles = EMPTY_ADDITIONAL_STYLES,
|
|
28
30
|
// Deprecated props:
|
|
29
31
|
__experimentalMinHeight,
|
|
30
32
|
__experimentalPadding,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Button,
|
|
9
9
|
__experimentalHStack as HStack,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
|
-
import { __
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -17,10 +17,9 @@ import { store as blockEditorStore } from '../../store';
|
|
|
17
17
|
import { unlock } from '../../lock-unlock';
|
|
18
18
|
|
|
19
19
|
export function BlockRemovalWarningModal( { rules } ) {
|
|
20
|
-
const { clientIds, selectPrevious,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
20
|
+
const { clientIds, selectPrevious, message } = useSelect( ( select ) =>
|
|
21
|
+
unlock( select( blockEditorStore ) ).getRemovalPromptData()
|
|
22
|
+
);
|
|
24
23
|
|
|
25
24
|
const {
|
|
26
25
|
clearBlockRemovalPrompt,
|
|
@@ -37,23 +36,10 @@ export function BlockRemovalWarningModal( { rules } ) {
|
|
|
37
36
|
};
|
|
38
37
|
}, [ rules, setBlockRemovalRules ] );
|
|
39
38
|
|
|
40
|
-
if ( !
|
|
39
|
+
if ( ! message ) {
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
const message =
|
|
45
|
-
messageType === 'templates'
|
|
46
|
-
? _n(
|
|
47
|
-
'Deleting this block will stop your post or page content from displaying on this template. It is not recommended.',
|
|
48
|
-
'Deleting these blocks will stop your post or page content from displaying on this template. It is not recommended.',
|
|
49
|
-
blockNamesForPrompt.length
|
|
50
|
-
)
|
|
51
|
-
: _n(
|
|
52
|
-
'Deleting this block could break patterns on your site that have content linked to it. Are you sure you want to delete it?',
|
|
53
|
-
'Deleting these blocks could break patterns on your site that have content linked to them. Are you sure you want to delete them?',
|
|
54
|
-
blockNamesForPrompt.length
|
|
55
|
-
);
|
|
56
|
-
|
|
57
43
|
const onConfirmRemoval = () => {
|
|
58
44
|
privateRemoveBlocks( clientIds, selectPrevious, /* force */ true );
|
|
59
45
|
clearBlockRemovalPrompt();
|
|
@@ -91,7 +91,7 @@ export default function BlockRenameModal( {
|
|
|
91
91
|
__next40pxDefaultSize
|
|
92
92
|
value={ editedBlockName }
|
|
93
93
|
label={ __( 'Block name' ) }
|
|
94
|
-
hideLabelFromVision
|
|
94
|
+
hideLabelFromVision
|
|
95
95
|
placeholder={ originalBlockName }
|
|
96
96
|
onChange={ setEditedBlockName }
|
|
97
97
|
onFocus={ autoSelectInputText }
|
|
@@ -33,8 +33,12 @@ const POPOVER_PROPS = {
|
|
|
33
33
|
placement: 'bottom-start',
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
function CopyMenuItem( {
|
|
37
|
-
const
|
|
36
|
+
function CopyMenuItem( { clientIds, onCopy, label } ) {
|
|
37
|
+
const { getBlocksByClientId } = useSelect( blockEditorStore );
|
|
38
|
+
const ref = useCopyToClipboard(
|
|
39
|
+
() => serialize( getBlocksByClientId( clientIds ) ),
|
|
40
|
+
onCopy
|
|
41
|
+
);
|
|
38
42
|
const copyMenuItemLabel = label ? label : __( 'Copy' );
|
|
39
43
|
return <MenuItem ref={ ref }>{ copyMenuItemLabel }</MenuItem>;
|
|
40
44
|
}
|
|
@@ -198,7 +202,7 @@ export function BlockSettingsDropdown( {
|
|
|
198
202
|
{ ( {
|
|
199
203
|
canCopyStyles,
|
|
200
204
|
canDuplicate,
|
|
201
|
-
|
|
205
|
+
canInsertBlock,
|
|
202
206
|
canMove,
|
|
203
207
|
canRemove,
|
|
204
208
|
onDuplicate,
|
|
@@ -208,7 +212,6 @@ export function BlockSettingsDropdown( {
|
|
|
208
212
|
onCopy,
|
|
209
213
|
onPasteStyles,
|
|
210
214
|
onMoveTo,
|
|
211
|
-
blocks,
|
|
212
215
|
} ) => (
|
|
213
216
|
<DropdownMenu
|
|
214
217
|
icon={ moreVertical }
|
|
@@ -245,7 +248,7 @@ export function BlockSettingsDropdown( {
|
|
|
245
248
|
'core/block-editor/insert-after',
|
|
246
249
|
event
|
|
247
250
|
) &&
|
|
248
|
-
|
|
251
|
+
canInsertBlock
|
|
249
252
|
) {
|
|
250
253
|
event.preventDefault();
|
|
251
254
|
setOpenedBlockSettingsMenu( undefined );
|
|
@@ -255,7 +258,7 @@ export function BlockSettingsDropdown( {
|
|
|
255
258
|
'core/block-editor/insert-before',
|
|
256
259
|
event
|
|
257
260
|
) &&
|
|
258
|
-
|
|
261
|
+
canInsertBlock
|
|
259
262
|
) {
|
|
260
263
|
event.preventDefault();
|
|
261
264
|
setOpenedBlockSettingsMenu( undefined );
|
|
@@ -286,7 +289,7 @@ export function BlockSettingsDropdown( {
|
|
|
286
289
|
/>
|
|
287
290
|
) }
|
|
288
291
|
<CopyMenuItem
|
|
289
|
-
|
|
292
|
+
clientIds={ clientIds }
|
|
290
293
|
onCopy={ onCopy }
|
|
291
294
|
/>
|
|
292
295
|
{ canDuplicate && (
|
|
@@ -301,7 +304,7 @@ export function BlockSettingsDropdown( {
|
|
|
301
304
|
{ __( 'Duplicate' ) }
|
|
302
305
|
</MenuItem>
|
|
303
306
|
) }
|
|
304
|
-
{
|
|
307
|
+
{ canInsertBlock && (
|
|
305
308
|
<>
|
|
306
309
|
<MenuItem
|
|
307
310
|
onClick={ pipe(
|
|
@@ -327,7 +330,7 @@ export function BlockSettingsDropdown( {
|
|
|
327
330
|
{ canCopyStyles && (
|
|
328
331
|
<MenuGroup>
|
|
329
332
|
<CopyMenuItem
|
|
330
|
-
|
|
333
|
+
clientIds={ clientIds }
|
|
331
334
|
onCopy={ onCopy }
|
|
332
335
|
label={ __( 'Copy styles' ) }
|
|
333
336
|
/>
|
|
@@ -80,7 +80,7 @@ const BlockTransformationsMenu = ( {
|
|
|
80
80
|
options={ pickerOptions() }
|
|
81
81
|
onChange={ onPickerSelect }
|
|
82
82
|
hideCancelButton={ Platform.OS !== 'ios' }
|
|
83
|
-
leftAlign
|
|
83
|
+
leftAlign
|
|
84
84
|
getAnchor={ getAnchor }
|
|
85
85
|
// translators: %s: block title e.g: "Paragraph".
|
|
86
86
|
title={ sprintf( __( 'Transform %s to' ), blockTitle ) }
|
|
@@ -256,7 +256,7 @@ const BlockActionsMenu = ( {
|
|
|
256
256
|
<ToolbarButton
|
|
257
257
|
title={ __( 'Open Block Actions Menu' ) }
|
|
258
258
|
icon={ moreHorizontalMobile }
|
|
259
|
-
disabled
|
|
259
|
+
disabled
|
|
260
260
|
/>
|
|
261
261
|
</ToolbarGroup>
|
|
262
262
|
);
|
|
@@ -311,7 +311,7 @@ const BlockActionsMenu = ( {
|
|
|
311
311
|
destructiveButtonIndex={ options.length }
|
|
312
312
|
disabledButtonIndices={ disabledButtonIndices }
|
|
313
313
|
hideCancelButton={ Platform.OS !== 'ios' }
|
|
314
|
-
leftAlign
|
|
314
|
+
leftAlign
|
|
315
315
|
getAnchor={ getAnchor }
|
|
316
316
|
// translators: %s: block title e.g: "Paragraph".
|
|
317
317
|
title={ sprintf( __( '%s block options' ), blockTitle ) }
|
|
@@ -34,8 +34,10 @@ import { useShowHoveredOrFocusedGestures } from './utils';
|
|
|
34
34
|
import { store as blockEditorStore } from '../../store';
|
|
35
35
|
import __unstableBlockNameContext from './block-name-context';
|
|
36
36
|
import NavigableToolbar from '../navigable-toolbar';
|
|
37
|
-
import
|
|
38
|
-
|
|
37
|
+
import Shuffle from './shuffle';
|
|
38
|
+
import BlockBindingsIndicator from '../block-bindings-toolbar-indicator';
|
|
39
|
+
import { useHasBlockToolbar } from './use-has-block-toolbar';
|
|
40
|
+
import { canBindBlock } from '../../hooks/use-bindings-attributes';
|
|
39
41
|
/**
|
|
40
42
|
* Renders the block toolbar.
|
|
41
43
|
*
|
|
@@ -60,8 +62,10 @@ export function PrivateBlockToolbar( {
|
|
|
60
62
|
blockClientIds,
|
|
61
63
|
isDefaultEditingMode,
|
|
62
64
|
blockType,
|
|
65
|
+
blockName,
|
|
63
66
|
shouldShowVisualToolbar,
|
|
64
67
|
showParentSelector,
|
|
68
|
+
isUsingBindings,
|
|
65
69
|
} = useSelect( ( select ) => {
|
|
66
70
|
const {
|
|
67
71
|
getBlockName,
|
|
@@ -71,6 +75,7 @@ export function PrivateBlockToolbar( {
|
|
|
71
75
|
isBlockValid,
|
|
72
76
|
getBlockRootClientId,
|
|
73
77
|
getBlockEditingMode,
|
|
78
|
+
getBlockAttributes,
|
|
74
79
|
} = select( blockEditorStore );
|
|
75
80
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
76
81
|
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
@@ -81,20 +86,21 @@ export function PrivateBlockToolbar( {
|
|
|
81
86
|
const parentBlockType = getBlockType( parentBlockName );
|
|
82
87
|
const _isDefaultEditingMode =
|
|
83
88
|
getBlockEditingMode( selectedBlockClientId ) === 'default';
|
|
89
|
+
const _blockName = getBlockName( selectedBlockClientId );
|
|
84
90
|
const isValid = selectedBlockClientIds.every( ( id ) =>
|
|
85
91
|
isBlockValid( id )
|
|
86
92
|
);
|
|
87
93
|
const isVisual = selectedBlockClientIds.every(
|
|
88
94
|
( id ) => getBlockMode( id ) === 'visual'
|
|
89
95
|
);
|
|
96
|
+
const _isUsingBindings = !! getBlockAttributes( selectedBlockClientId )
|
|
97
|
+
?.metadata?.bindings;
|
|
90
98
|
return {
|
|
91
99
|
blockClientId: selectedBlockClientId,
|
|
92
100
|
blockClientIds: selectedBlockClientIds,
|
|
93
101
|
isDefaultEditingMode: _isDefaultEditingMode,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
getBlockType( getBlockName( selectedBlockClientId ) ),
|
|
97
|
-
|
|
102
|
+
blockName: _blockName,
|
|
103
|
+
blockType: selectedBlockClientId && getBlockType( _blockName ),
|
|
98
104
|
shouldShowVisualToolbar: isValid && isVisual,
|
|
99
105
|
rootClientId: blockRootClientId,
|
|
100
106
|
showParentSelector:
|
|
@@ -107,6 +113,7 @@ export function PrivateBlockToolbar( {
|
|
|
107
113
|
) &&
|
|
108
114
|
selectedBlockClientIds.length === 1 &&
|
|
109
115
|
_isDefaultEditingMode,
|
|
116
|
+
isUsingBindings: _isUsingBindings,
|
|
110
117
|
};
|
|
111
118
|
}, [] );
|
|
112
119
|
|
|
@@ -121,15 +128,8 @@ export function PrivateBlockToolbar( {
|
|
|
121
128
|
|
|
122
129
|
const isLargeViewport = ! useViewportMatch( 'medium', '<' );
|
|
123
130
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
hasBlockSupport( blockType, '__experimentalToolbar', true );
|
|
127
|
-
const hasAnyBlockControls = useHasAnyBlockControls();
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
! isToolbarEnabled ||
|
|
131
|
-
( ! isDefaultEditingMode && ! hasAnyBlockControls )
|
|
132
|
-
) {
|
|
131
|
+
const hasBlockToolbar = useHasBlockToolbar();
|
|
132
|
+
if ( ! hasBlockToolbar ) {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -165,6 +165,9 @@ export function PrivateBlockToolbar( {
|
|
|
165
165
|
{ ! isMultiToolbar &&
|
|
166
166
|
isLargeViewport &&
|
|
167
167
|
isDefaultEditingMode && <BlockParentSelector /> }
|
|
168
|
+
{ isUsingBindings && canBindBlock( blockName ) && (
|
|
169
|
+
<BlockBindingsIndicator />
|
|
170
|
+
) }
|
|
168
171
|
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
|
|
169
172
|
isDefaultEditingMode && (
|
|
170
173
|
<div
|
|
@@ -185,6 +188,7 @@ export function PrivateBlockToolbar( {
|
|
|
185
188
|
</ToolbarGroup>
|
|
186
189
|
</div>
|
|
187
190
|
) }
|
|
191
|
+
<Shuffle clientId={ blockClientId } />
|
|
188
192
|
{ shouldShowVisualToolbar && isMultiToolbar && (
|
|
189
193
|
<BlockGroupToolbar />
|
|
190
194
|
) }
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { shuffle } from '@wordpress/icons';
|
|
5
|
+
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useMemo } from '@wordpress/element';
|
|
8
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
|
|
15
|
+
const EMPTY_ARRAY = [];
|
|
16
|
+
|
|
17
|
+
function Container( props ) {
|
|
18
|
+
return (
|
|
19
|
+
<ToolbarGroup>
|
|
20
|
+
<ToolbarButton { ...props } />
|
|
21
|
+
</ToolbarGroup>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function Shuffle( { clientId, as = Container } ) {
|
|
26
|
+
const { categories, patterns } = useSelect(
|
|
27
|
+
( select ) => {
|
|
28
|
+
const {
|
|
29
|
+
getBlockAttributes,
|
|
30
|
+
getBlockRootClientId,
|
|
31
|
+
__experimentalGetAllowedPatterns,
|
|
32
|
+
} = select( blockEditorStore );
|
|
33
|
+
const attributes = getBlockAttributes( clientId );
|
|
34
|
+
const _categories = attributes?.metadata?.categories || EMPTY_ARRAY;
|
|
35
|
+
const rootBlock = getBlockRootClientId( clientId );
|
|
36
|
+
const _patterns = __experimentalGetAllowedPatterns( rootBlock );
|
|
37
|
+
return {
|
|
38
|
+
categories: _categories,
|
|
39
|
+
patterns: _patterns,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
[ clientId ]
|
|
43
|
+
);
|
|
44
|
+
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
45
|
+
const sameCategoryPatternsWithSingleWrapper = useMemo( () => {
|
|
46
|
+
if (
|
|
47
|
+
! categories ||
|
|
48
|
+
categories.length === 0 ||
|
|
49
|
+
! patterns ||
|
|
50
|
+
patterns.length === 0
|
|
51
|
+
) {
|
|
52
|
+
return EMPTY_ARRAY;
|
|
53
|
+
}
|
|
54
|
+
return patterns.filter( ( pattern ) => {
|
|
55
|
+
return (
|
|
56
|
+
// Check if the pattern has only one top level block,
|
|
57
|
+
// otherwise we may shuffle to pattern that will not allow to continue shuffling.
|
|
58
|
+
pattern.blocks.length === 1 &&
|
|
59
|
+
pattern.categories.some( ( category ) => {
|
|
60
|
+
return categories.includes( category );
|
|
61
|
+
} )
|
|
62
|
+
);
|
|
63
|
+
} );
|
|
64
|
+
}, [ categories, patterns ] );
|
|
65
|
+
if ( sameCategoryPatternsWithSingleWrapper.length === 0 ) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const ComponentToUse = as;
|
|
69
|
+
return (
|
|
70
|
+
<ComponentToUse
|
|
71
|
+
label={ __( 'Shuffle' ) }
|
|
72
|
+
icon={ shuffle }
|
|
73
|
+
onClick={ () => {
|
|
74
|
+
const randomPattern =
|
|
75
|
+
sameCategoryPatternsWithSingleWrapper[
|
|
76
|
+
Math.floor(
|
|
77
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
78
|
+
Math.random() *
|
|
79
|
+
sameCategoryPatternsWithSingleWrapper.length
|
|
80
|
+
)
|
|
81
|
+
];
|
|
82
|
+
randomPattern.blocks[ 0 ].attributes = {
|
|
83
|
+
...randomPattern.blocks[ 0 ].attributes,
|
|
84
|
+
metadata: {
|
|
85
|
+
...randomPattern.blocks[ 0 ].attributes.metadata,
|
|
86
|
+
categories,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
replaceBlocks( clientId, randomPattern.blocks );
|
|
90
|
+
} }
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { getBlockType, hasBlockSupport } from '@wordpress/blocks';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
import { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns true if the block toolbar should be shown.
|
|
14
|
+
*
|
|
15
|
+
* @return {boolean} Whether the block toolbar component will be rendered.
|
|
16
|
+
*/
|
|
17
|
+
export function useHasBlockToolbar() {
|
|
18
|
+
const hasAnyBlockControls = useHasAnyBlockControls();
|
|
19
|
+
return useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const {
|
|
22
|
+
getBlockEditingMode,
|
|
23
|
+
getBlockName,
|
|
24
|
+
getSelectedBlockClientIds,
|
|
25
|
+
} = select( blockEditorStore );
|
|
26
|
+
|
|
27
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
28
|
+
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
29
|
+
const isDefaultEditingMode =
|
|
30
|
+
getBlockEditingMode( selectedBlockClientId ) === 'default';
|
|
31
|
+
const blockType =
|
|
32
|
+
selectedBlockClientId &&
|
|
33
|
+
getBlockType( getBlockName( selectedBlockClientId ) );
|
|
34
|
+
const isToolbarEnabled =
|
|
35
|
+
blockType &&
|
|
36
|
+
hasBlockSupport( blockType, '__experimentalToolbar', true );
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
! isToolbarEnabled ||
|
|
40
|
+
( ! isDefaultEditingMode && ! hasAnyBlockControls )
|
|
41
|
+
) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
47
|
+
[ hasAnyBlockControls ]
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -39,6 +39,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
39
39
|
import BlockDraggable from '../block-draggable';
|
|
40
40
|
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
41
41
|
import BlockMover from '../block-mover';
|
|
42
|
+
import Shuffle from '../block-toolbar/shuffle';
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* Block selection button component, displaying the label of the block. If the block
|
|
@@ -271,6 +272,9 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
|
|
|
271
272
|
</BlockDraggable>
|
|
272
273
|
) }
|
|
273
274
|
</FlexItem>
|
|
275
|
+
{ editorMode === 'zoom-out' && (
|
|
276
|
+
<Shuffle clientId={ clientId } as={ Button } />
|
|
277
|
+
) }
|
|
274
278
|
<FlexItem>
|
|
275
279
|
<Button
|
|
276
280
|
ref={ ref }
|