@wordpress/block-editor 10.3.0 → 10.5.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 +13 -0
- package/README.md +0 -1
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-list/block.js +3 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -4
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +21 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +12 -2
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +8 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +10 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +72 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +1 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +5 -4
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +26 -18
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +22 -13
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +7 -6
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +23 -22
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +30 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +62 -31
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-list/block.js +3 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -3
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +21 -11
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +12 -2
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +9 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +10 -4
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +67 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +1 -0
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +6 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +27 -19
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +23 -14
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +7 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +24 -23
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +26 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +59 -31
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -88
- package/build-style/style.css +84 -84
- package/package.json +29 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/style.scss +11 -6
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +1 -0
- package/src/components/block-popover/style.scss +1 -5
- package/src/components/block-preview/index.js +8 -3
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +21 -11
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
- package/src/components/color-palette/test/control.js +1 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +15 -13
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +11 -4
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-list-item/style.scss +2 -0
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
- package/src/components/spacing-sizes-control/style.scss +1 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/border.js +1 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +106 -19
- package/src/hooks/font-size.js +1 -0
- package/src/hooks/layout.js +8 -11
- package/src/hooks/margin.js +23 -17
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +23 -19
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/hooks/utils.js +5 -6
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +44 -39
- package/src/store/actions.js +26 -0
- package/src/store/array.js +1 -6
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +43 -29
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +20 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { ToolbarButton } from '@wordpress/components';
|
|
4
|
+
import { ToolbarButton, MenuItem } from '@wordpress/components';
|
|
5
5
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
6
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
7
|
import { addFilter } from '@wordpress/hooks';
|
|
@@ -12,7 +12,7 @@ import { useEffect, useRef, useCallback } from '@wordpress/element';
|
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { store as blockEditorStore } from '../store';
|
|
15
|
-
import { BlockControls } from '../components';
|
|
15
|
+
import { BlockControls, BlockSettingsMenuControls } from '../components';
|
|
16
16
|
/**
|
|
17
17
|
* External dependencies
|
|
18
18
|
*/
|
|
@@ -107,39 +107,51 @@ export const withBlockControls = createHigherOrderComponent(
|
|
|
107
107
|
return (
|
|
108
108
|
<>
|
|
109
109
|
{ isEditingAsBlocks && ! isContentLocked && (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
<>
|
|
111
|
+
<StopEditingAsBlocksOnOutsideSelect
|
|
112
|
+
clientId={ props.clientId }
|
|
113
|
+
stopEditingAsBlock={ stopEditingAsBlock }
|
|
114
|
+
/>
|
|
115
|
+
<BlockControls group="other">
|
|
116
|
+
<ToolbarButton
|
|
117
|
+
onClick={ () => {
|
|
118
|
+
stopEditingAsBlock();
|
|
119
|
+
} }
|
|
120
|
+
>
|
|
121
|
+
{ __( 'Done' ) }
|
|
122
|
+
</ToolbarButton>
|
|
123
|
+
</BlockControls>
|
|
124
|
+
</>
|
|
125
|
+
) }
|
|
126
|
+
{ ! isEditingAsBlocks && isContentLocked && props.isSelected && (
|
|
127
|
+
<BlockSettingsMenuControls>
|
|
128
|
+
{ ( { onClose } ) => (
|
|
129
|
+
<MenuItem
|
|
130
|
+
onClick={ () => {
|
|
131
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
132
|
+
updateBlockAttributes( props.clientId, {
|
|
133
|
+
templateLock: undefined,
|
|
134
|
+
} );
|
|
135
|
+
updateBlockListSettings( props.clientId, {
|
|
136
|
+
...getBlockListSettings(
|
|
137
|
+
props.clientId
|
|
138
|
+
),
|
|
139
|
+
templateLock: false,
|
|
140
|
+
} );
|
|
141
|
+
focusModeToRevert.current =
|
|
142
|
+
getSettings().focusMode;
|
|
143
|
+
updateSettings( { focusMode: true } );
|
|
144
|
+
__unstableSetTemporarilyEditingAsBlocks(
|
|
145
|
+
props.clientId
|
|
146
|
+
);
|
|
147
|
+
onClose();
|
|
148
|
+
} }
|
|
149
|
+
>
|
|
150
|
+
{ __( 'Modify' ) }
|
|
151
|
+
</MenuItem>
|
|
152
|
+
) }
|
|
153
|
+
</BlockSettingsMenuControls>
|
|
114
154
|
) }
|
|
115
|
-
<BlockControls group="other">
|
|
116
|
-
<ToolbarButton
|
|
117
|
-
onClick={ () => {
|
|
118
|
-
if ( isEditingAsBlocks && ! isContentLocked ) {
|
|
119
|
-
stopEditingAsBlock();
|
|
120
|
-
} else {
|
|
121
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
122
|
-
updateBlockAttributes( props.clientId, {
|
|
123
|
-
templateLock: undefined,
|
|
124
|
-
} );
|
|
125
|
-
updateBlockListSettings( props.clientId, {
|
|
126
|
-
...getBlockListSettings( props.clientId ),
|
|
127
|
-
templateLock: false,
|
|
128
|
-
} );
|
|
129
|
-
focusModeToRevert.current =
|
|
130
|
-
getSettings().focusMode;
|
|
131
|
-
updateSettings( { focusMode: true } );
|
|
132
|
-
__unstableSetTemporarilyEditingAsBlocks(
|
|
133
|
-
props.clientId
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
} }
|
|
137
|
-
>
|
|
138
|
-
{ isEditingAsBlocks && ! isContentLocked
|
|
139
|
-
? __( 'Done' )
|
|
140
|
-
: __( 'Modify' ) }
|
|
141
|
-
</ToolbarButton>
|
|
142
|
-
</BlockControls>
|
|
143
155
|
<BlockEdit
|
|
144
156
|
{ ...props }
|
|
145
157
|
className={ classnames(
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -7,9 +7,10 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
10
|
-
import { Platform } from '@wordpress/element';
|
|
10
|
+
import { Platform, useState } from '@wordpress/element';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
13
|
+
import { useDispatch } from '@wordpress/data';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
@@ -30,6 +31,13 @@ import {
|
|
|
30
31
|
resetMargin,
|
|
31
32
|
useIsMarginDisabled,
|
|
32
33
|
} from './margin';
|
|
34
|
+
import {
|
|
35
|
+
MinHeightEdit,
|
|
36
|
+
hasMinHeightSupport,
|
|
37
|
+
hasMinHeightValue,
|
|
38
|
+
resetMinHeight,
|
|
39
|
+
useIsMinHeightDisabled,
|
|
40
|
+
} from './min-height';
|
|
33
41
|
import {
|
|
34
42
|
PaddingEdit,
|
|
35
43
|
PaddingVisualizer,
|
|
@@ -39,45 +47,75 @@ import {
|
|
|
39
47
|
useIsPaddingDisabled,
|
|
40
48
|
} from './padding';
|
|
41
49
|
import useSetting from '../components/use-setting';
|
|
50
|
+
import { store as blockEditorStore } from '../store';
|
|
42
51
|
|
|
52
|
+
export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
|
|
43
53
|
export const SPACING_SUPPORT_KEY = 'spacing';
|
|
44
54
|
export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
|
|
45
55
|
export const AXIAL_SIDES = [ 'vertical', 'horizontal' ];
|
|
46
56
|
|
|
57
|
+
function useVisualizerMouseOver() {
|
|
58
|
+
const [ isMouseOver, setIsMouseOver ] = useState( false );
|
|
59
|
+
const {
|
|
60
|
+
__experimentalHideBlockInterface: hideBlockInterface,
|
|
61
|
+
__experimentalShowBlockInterface: showBlockInterface,
|
|
62
|
+
} = useDispatch( blockEditorStore );
|
|
63
|
+
const onMouseOver = ( e ) => {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
hideBlockInterface();
|
|
66
|
+
setIsMouseOver( true );
|
|
67
|
+
};
|
|
68
|
+
const onMouseOut = ( e ) => {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
showBlockInterface();
|
|
71
|
+
setIsMouseOver( false );
|
|
72
|
+
};
|
|
73
|
+
return { isMouseOver, onMouseOver, onMouseOut };
|
|
74
|
+
}
|
|
75
|
+
|
|
47
76
|
/**
|
|
48
77
|
* Inspector controls for dimensions support.
|
|
49
78
|
*
|
|
50
79
|
* @param {Object} props Block props.
|
|
51
80
|
*
|
|
52
|
-
* @return {WPElement} Inspector controls for spacing support features.
|
|
81
|
+
* @return {WPElement} Inspector controls for dimensions and spacing support features.
|
|
53
82
|
*/
|
|
54
83
|
export function DimensionsPanel( props ) {
|
|
55
84
|
const isGapDisabled = useIsGapDisabled( props );
|
|
56
85
|
const isPaddingDisabled = useIsPaddingDisabled( props );
|
|
57
86
|
const isMarginDisabled = useIsMarginDisabled( props );
|
|
87
|
+
const isMinHeightDisabled = useIsMinHeightDisabled( props );
|
|
58
88
|
const isDisabled = useIsDimensionsDisabled( props );
|
|
59
89
|
const isSupported = hasDimensionsSupport( props.name );
|
|
60
90
|
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
91
|
+
const paddingMouseOver = useVisualizerMouseOver();
|
|
92
|
+
const marginMouseOver = useVisualizerMouseOver();
|
|
61
93
|
|
|
62
94
|
if ( isDisabled || ! isSupported ) {
|
|
63
95
|
return null;
|
|
64
96
|
}
|
|
65
97
|
|
|
98
|
+
const defaultDimensionsControls = getBlockSupport( props.name, [
|
|
99
|
+
DIMENSIONS_SUPPORT_KEY,
|
|
100
|
+
'__experimentalDefaultControls',
|
|
101
|
+
] );
|
|
102
|
+
|
|
66
103
|
const defaultSpacingControls = getBlockSupport( props.name, [
|
|
67
104
|
SPACING_SUPPORT_KEY,
|
|
68
105
|
'__experimentalDefaultControls',
|
|
69
106
|
] );
|
|
70
107
|
|
|
71
|
-
const createResetAllFilter =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
const createResetAllFilter =
|
|
109
|
+
( attribute, featureSet ) => ( newAttributes ) => ( {
|
|
110
|
+
...newAttributes,
|
|
111
|
+
style: {
|
|
112
|
+
...newAttributes.style,
|
|
113
|
+
[ featureSet ]: {
|
|
114
|
+
...newAttributes.style?.[ featureSet ],
|
|
115
|
+
[ attribute ]: undefined,
|
|
116
|
+
},
|
|
78
117
|
},
|
|
79
|
-
}
|
|
80
|
-
} );
|
|
118
|
+
} );
|
|
81
119
|
|
|
82
120
|
const spacingClassnames = classnames( {
|
|
83
121
|
'tools-panel-item-spacing': spacingSizes && spacingSizes.length > 0,
|
|
@@ -92,11 +130,18 @@ export function DimensionsPanel( props ) {
|
|
|
92
130
|
hasValue={ () => hasPaddingValue( props ) }
|
|
93
131
|
label={ __( 'Padding' ) }
|
|
94
132
|
onDeselect={ () => resetPadding( props ) }
|
|
95
|
-
resetAllFilter={ createResetAllFilter(
|
|
133
|
+
resetAllFilter={ createResetAllFilter(
|
|
134
|
+
'padding',
|
|
135
|
+
'spacing'
|
|
136
|
+
) }
|
|
96
137
|
isShownByDefault={ defaultSpacingControls?.padding }
|
|
97
138
|
panelId={ props.clientId }
|
|
98
139
|
>
|
|
99
|
-
<PaddingEdit
|
|
140
|
+
<PaddingEdit
|
|
141
|
+
onMouseOver={ paddingMouseOver.onMouseOver }
|
|
142
|
+
onMouseOut={ paddingMouseOver.onMouseOut }
|
|
143
|
+
{ ...props }
|
|
144
|
+
/>
|
|
100
145
|
</ToolsPanelItem>
|
|
101
146
|
) }
|
|
102
147
|
{ ! isMarginDisabled && (
|
|
@@ -105,11 +150,18 @@ export function DimensionsPanel( props ) {
|
|
|
105
150
|
hasValue={ () => hasMarginValue( props ) }
|
|
106
151
|
label={ __( 'Margin' ) }
|
|
107
152
|
onDeselect={ () => resetMargin( props ) }
|
|
108
|
-
resetAllFilter={ createResetAllFilter(
|
|
153
|
+
resetAllFilter={ createResetAllFilter(
|
|
154
|
+
'margin',
|
|
155
|
+
'spacing'
|
|
156
|
+
) }
|
|
109
157
|
isShownByDefault={ defaultSpacingControls?.margin }
|
|
110
158
|
panelId={ props.clientId }
|
|
111
159
|
>
|
|
112
|
-
<MarginEdit
|
|
160
|
+
<MarginEdit
|
|
161
|
+
onMouseOver={ marginMouseOver.onMouseOver }
|
|
162
|
+
onMouseOut={ marginMouseOver.onMouseOut }
|
|
163
|
+
{ ...props }
|
|
164
|
+
/>
|
|
113
165
|
</ToolsPanelItem>
|
|
114
166
|
) }
|
|
115
167
|
{ ! isGapDisabled && (
|
|
@@ -118,16 +170,47 @@ export function DimensionsPanel( props ) {
|
|
|
118
170
|
hasValue={ () => hasGapValue( props ) }
|
|
119
171
|
label={ __( 'Block spacing' ) }
|
|
120
172
|
onDeselect={ () => resetGap( props ) }
|
|
121
|
-
resetAllFilter={ createResetAllFilter(
|
|
173
|
+
resetAllFilter={ createResetAllFilter(
|
|
174
|
+
'blockGap',
|
|
175
|
+
'spacing'
|
|
176
|
+
) }
|
|
122
177
|
isShownByDefault={ defaultSpacingControls?.blockGap }
|
|
123
178
|
panelId={ props.clientId }
|
|
124
179
|
>
|
|
125
180
|
<GapEdit { ...props } />
|
|
126
181
|
</ToolsPanelItem>
|
|
127
182
|
) }
|
|
183
|
+
{ ! isMinHeightDisabled && (
|
|
184
|
+
<ToolsPanelItem
|
|
185
|
+
className="single-column"
|
|
186
|
+
hasValue={ () => hasMinHeightValue( props ) }
|
|
187
|
+
label={ __( 'Min. height' ) }
|
|
188
|
+
onDeselect={ () => resetMinHeight( props ) }
|
|
189
|
+
resetAllFilter={ createResetAllFilter(
|
|
190
|
+
'minHeight',
|
|
191
|
+
'dimensions'
|
|
192
|
+
) }
|
|
193
|
+
isShownByDefault={
|
|
194
|
+
defaultDimensionsControls?.minHeight
|
|
195
|
+
}
|
|
196
|
+
panelId={ props.clientId }
|
|
197
|
+
>
|
|
198
|
+
<MinHeightEdit { ...props } />
|
|
199
|
+
</ToolsPanelItem>
|
|
200
|
+
) }
|
|
128
201
|
</InspectorControls>
|
|
129
|
-
{ ! isPaddingDisabled &&
|
|
130
|
-
|
|
202
|
+
{ ! isPaddingDisabled && (
|
|
203
|
+
<PaddingVisualizer
|
|
204
|
+
forceShow={ paddingMouseOver.isMouseOver }
|
|
205
|
+
{ ...props }
|
|
206
|
+
/>
|
|
207
|
+
) }
|
|
208
|
+
{ ! isMarginDisabled && (
|
|
209
|
+
<MarginVisualizer
|
|
210
|
+
forceShow={ marginMouseOver.isMouseOver }
|
|
211
|
+
{ ...props }
|
|
212
|
+
/>
|
|
213
|
+
) }
|
|
131
214
|
</>
|
|
132
215
|
);
|
|
133
216
|
}
|
|
@@ -146,6 +229,7 @@ export function hasDimensionsSupport( blockName ) {
|
|
|
146
229
|
|
|
147
230
|
return (
|
|
148
231
|
hasGapSupport( blockName ) ||
|
|
232
|
+
hasMinHeightSupport( blockName ) ||
|
|
149
233
|
hasPaddingSupport( blockName ) ||
|
|
150
234
|
hasMarginSupport( blockName )
|
|
151
235
|
);
|
|
@@ -160,10 +244,13 @@ export function hasDimensionsSupport( blockName ) {
|
|
|
160
244
|
*/
|
|
161
245
|
const useIsDimensionsDisabled = ( props = {} ) => {
|
|
162
246
|
const gapDisabled = useIsGapDisabled( props );
|
|
247
|
+
const minHeightDisabled = useIsMinHeightDisabled( props );
|
|
163
248
|
const paddingDisabled = useIsPaddingDisabled( props );
|
|
164
249
|
const marginDisabled = useIsMarginDisabled( props );
|
|
165
250
|
|
|
166
|
-
return
|
|
251
|
+
return (
|
|
252
|
+
gapDisabled && minHeightDisabled && paddingDisabled && marginDisabled
|
|
253
|
+
);
|
|
167
254
|
};
|
|
168
255
|
|
|
169
256
|
/**
|
package/src/hooks/font-size.js
CHANGED
package/src/hooks/layout.js
CHANGED
|
@@ -9,11 +9,7 @@ import { kebabCase } from 'lodash';
|
|
|
9
9
|
*/
|
|
10
10
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
11
11
|
import { addFilter } from '@wordpress/hooks';
|
|
12
|
-
import {
|
|
13
|
-
getBlockDefaultClassName,
|
|
14
|
-
getBlockSupport,
|
|
15
|
-
hasBlockSupport,
|
|
16
|
-
} from '@wordpress/blocks';
|
|
12
|
+
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
17
13
|
import { useSelect } from '@wordpress/data';
|
|
18
14
|
import {
|
|
19
15
|
Button,
|
|
@@ -366,9 +362,8 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
366
362
|
const layoutClasses = hasLayoutBlockSupport
|
|
367
363
|
? useLayoutClasses( block )
|
|
368
364
|
: null;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
) }.wp-container-${ id }`;
|
|
365
|
+
// Higher specificity to override defaults from theme.json.
|
|
366
|
+
const selector = `.wp-container-${ id }.wp-container-${ id }`;
|
|
372
367
|
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
373
368
|
const hasBlockGapSupport = blockGapSupport !== null;
|
|
374
369
|
|
|
@@ -390,8 +385,7 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
390
385
|
}
|
|
391
386
|
|
|
392
387
|
// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
|
|
393
|
-
const
|
|
394
|
-
props?.className,
|
|
388
|
+
const layoutClassNames = classnames(
|
|
395
389
|
{
|
|
396
390
|
[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
397
391
|
},
|
|
@@ -413,7 +407,10 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
413
407
|
/>,
|
|
414
408
|
element
|
|
415
409
|
) }
|
|
416
|
-
<BlockListBlock
|
|
410
|
+
<BlockListBlock
|
|
411
|
+
{ ...props }
|
|
412
|
+
__unstableLayoutClassNames={ layoutClassNames }
|
|
413
|
+
/>
|
|
417
414
|
</>
|
|
418
415
|
);
|
|
419
416
|
}
|
package/src/hooks/margin.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
import { cleanEmptyObject } from './utils';
|
|
30
30
|
import BlockPopover from '../components/block-popover';
|
|
31
31
|
import SpacingSizesControl from '../components/spacing-sizes-control';
|
|
32
|
-
import {
|
|
32
|
+
import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Determines if there is margin support.
|
|
@@ -101,6 +101,8 @@ export function MarginEdit( props ) {
|
|
|
101
101
|
name: blockName,
|
|
102
102
|
attributes: { style },
|
|
103
103
|
setAttributes,
|
|
104
|
+
onMouseOver,
|
|
105
|
+
onMouseOut,
|
|
104
106
|
} = props;
|
|
105
107
|
|
|
106
108
|
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
@@ -148,6 +150,8 @@ export function MarginEdit( props ) {
|
|
|
148
150
|
units={ units }
|
|
149
151
|
allowReset={ false }
|
|
150
152
|
splitOnAxis={ splitOnAxis }
|
|
153
|
+
onMouseOver={ onMouseOver }
|
|
154
|
+
onMouseOut={ onMouseOut }
|
|
151
155
|
/>
|
|
152
156
|
) }
|
|
153
157
|
{ spacingSizes?.length > 0 && (
|
|
@@ -159,6 +163,8 @@ export function MarginEdit( props ) {
|
|
|
159
163
|
units={ units }
|
|
160
164
|
allowReset={ false }
|
|
161
165
|
splitOnAxis={ false }
|
|
166
|
+
onMouseOver={ onMouseOver }
|
|
167
|
+
onMouseOut={ onMouseOut }
|
|
162
168
|
/>
|
|
163
169
|
) }
|
|
164
170
|
</>
|
|
@@ -167,22 +173,21 @@ export function MarginEdit( props ) {
|
|
|
167
173
|
} );
|
|
168
174
|
}
|
|
169
175
|
|
|
170
|
-
export function MarginVisualizer( { clientId, attributes } ) {
|
|
176
|
+
export function MarginVisualizer( { clientId, attributes, forceShow } ) {
|
|
171
177
|
const margin = attributes?.style?.spacing?.margin;
|
|
172
|
-
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
173
178
|
|
|
174
179
|
const style = useMemo( () => {
|
|
175
180
|
const marginTop = margin?.top
|
|
176
|
-
?
|
|
181
|
+
? getSpacingPresetCssVar( margin?.top )
|
|
177
182
|
: 0;
|
|
178
183
|
const marginRight = margin?.right
|
|
179
|
-
?
|
|
184
|
+
? getSpacingPresetCssVar( margin?.right )
|
|
180
185
|
: 0;
|
|
181
186
|
const marginBottom = margin?.bottom
|
|
182
|
-
?
|
|
187
|
+
? getSpacingPresetCssVar( margin?.bottom )
|
|
183
188
|
: 0;
|
|
184
189
|
const marginLeft = margin?.left
|
|
185
|
-
?
|
|
190
|
+
? getSpacingPresetCssVar( margin?.left )
|
|
186
191
|
: 0;
|
|
187
192
|
|
|
188
193
|
return {
|
|
@@ -190,10 +195,10 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
190
195
|
borderRightWidth: marginRight,
|
|
191
196
|
borderBottomWidth: marginBottom,
|
|
192
197
|
borderLeftWidth: marginLeft,
|
|
193
|
-
top: marginTop
|
|
194
|
-
right: marginRight
|
|
195
|
-
bottom: marginBottom
|
|
196
|
-
left: marginLeft
|
|
198
|
+
top: marginTop ? `calc(${ marginTop } * -1)` : 0,
|
|
199
|
+
right: marginRight ? `calc(${ marginRight } * -1)` : 0,
|
|
200
|
+
bottom: marginBottom ? `calc(${ marginBottom } * -1)` : 0,
|
|
201
|
+
left: marginLeft ? `calc(${ marginLeft } * -1)` : 0,
|
|
197
202
|
};
|
|
198
203
|
}, [ margin ] );
|
|
199
204
|
|
|
@@ -208,21 +213,22 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
208
213
|
};
|
|
209
214
|
|
|
210
215
|
useEffect( () => {
|
|
211
|
-
if ( ! isShallowEqual( margin, valueRef.current ) ) {
|
|
216
|
+
if ( ! isShallowEqual( margin, valueRef.current ) && ! forceShow ) {
|
|
212
217
|
setIsActive( true );
|
|
213
218
|
valueRef.current = margin;
|
|
214
219
|
|
|
215
|
-
clearTimer();
|
|
216
|
-
|
|
217
220
|
timeoutRef.current = setTimeout( () => {
|
|
218
221
|
setIsActive( false );
|
|
219
222
|
}, 400 );
|
|
220
223
|
}
|
|
221
224
|
|
|
222
|
-
return () =>
|
|
223
|
-
|
|
225
|
+
return () => {
|
|
226
|
+
setIsActive( false );
|
|
227
|
+
clearTimer();
|
|
228
|
+
};
|
|
229
|
+
}, [ margin, forceShow ] );
|
|
224
230
|
|
|
225
|
-
if ( ! isActive ) {
|
|
231
|
+
if ( ! isActive && ! forceShow ) {
|
|
226
232
|
return null;
|
|
227
233
|
}
|
|
228
234
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalUseCustomUnits as useCustomUnits,
|
|
7
|
+
__experimentalUnitControl as UnitControl,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import useSetting from '../components/use-setting';
|
|
15
|
+
import { DIMENSIONS_SUPPORT_KEY } from './dimensions';
|
|
16
|
+
import { cleanEmptyObject } from './utils';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Determines if there is minHeight support.
|
|
20
|
+
*
|
|
21
|
+
* @param {string|Object} blockType Block name or Block Type object.
|
|
22
|
+
* @return {boolean} Whether there is support.
|
|
23
|
+
*/
|
|
24
|
+
export function hasMinHeightSupport( blockType ) {
|
|
25
|
+
const support = getBlockSupport( blockType, DIMENSIONS_SUPPORT_KEY );
|
|
26
|
+
return !! ( true === support || support?.minHeight );
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checks if there is a current value in the minHeight block support attributes.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} props Block props.
|
|
33
|
+
* @return {boolean} Whether or not the block has a minHeight value set.
|
|
34
|
+
*/
|
|
35
|
+
export function hasMinHeightValue( props ) {
|
|
36
|
+
return props.attributes.style?.dimensions?.minHeight !== undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Resets the minHeight block support attributes. This can be used when disabling
|
|
41
|
+
* the padding support controls for a block via a `ToolsPanel`.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} props Block props.
|
|
44
|
+
* @param {Object} props.attributes Block's attributes.
|
|
45
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
46
|
+
*/
|
|
47
|
+
export function resetMinHeight( { attributes = {}, setAttributes } ) {
|
|
48
|
+
const { style } = attributes;
|
|
49
|
+
|
|
50
|
+
setAttributes( {
|
|
51
|
+
style: cleanEmptyObject( {
|
|
52
|
+
...style,
|
|
53
|
+
dimensions: {
|
|
54
|
+
...style?.dimensions,
|
|
55
|
+
minHeight: undefined,
|
|
56
|
+
},
|
|
57
|
+
} ),
|
|
58
|
+
} );
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Custom hook that checks if minHeight controls have been disabled.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} name The name of the block.
|
|
65
|
+
* @return {boolean} Whether minHeight control is disabled.
|
|
66
|
+
*/
|
|
67
|
+
export function useIsMinHeightDisabled( { name: blockName } = {} ) {
|
|
68
|
+
const isDisabled = ! useSetting( 'dimensions.minHeight' );
|
|
69
|
+
return ! hasMinHeightSupport( blockName ) || isDisabled;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Inspector control panel containing the minHeight related configuration.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} props Block props.
|
|
76
|
+
* @return {WPElement} Edit component for height.
|
|
77
|
+
*/
|
|
78
|
+
export function MinHeightEdit( props ) {
|
|
79
|
+
const {
|
|
80
|
+
attributes: { style },
|
|
81
|
+
setAttributes,
|
|
82
|
+
} = props;
|
|
83
|
+
|
|
84
|
+
const units = useCustomUnits( {
|
|
85
|
+
availableUnits: useSetting( 'dimensions.units' ) || [
|
|
86
|
+
'%',
|
|
87
|
+
'px',
|
|
88
|
+
'em',
|
|
89
|
+
'rem',
|
|
90
|
+
'vh',
|
|
91
|
+
'vw',
|
|
92
|
+
],
|
|
93
|
+
} );
|
|
94
|
+
|
|
95
|
+
if ( useIsMinHeightDisabled( props ) ) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const onChange = ( next ) => {
|
|
100
|
+
const newStyle = {
|
|
101
|
+
...style,
|
|
102
|
+
dimensions: {
|
|
103
|
+
...style?.dimensions,
|
|
104
|
+
minHeight: next,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
setAttributes( { style: cleanEmptyObject( newStyle ) } );
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<UnitControl
|
|
113
|
+
label={ __( 'Min. height' ) }
|
|
114
|
+
value={ style?.dimensions?.minHeight }
|
|
115
|
+
units={ units }
|
|
116
|
+
onChange={ onChange }
|
|
117
|
+
min={ 0 }
|
|
118
|
+
size={ '__unstable-large' }
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|