@wordpress/block-editor 12.19.5 → 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 +4 -0
- package/build/components/block-canvas/index.js +2 -0
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.js +14 -17
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-inspector/index.js +0 -3
- 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/index.js +9 -9
- package/build/components/block-list/index.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-parent-selector-menu-item.js +54 -0
- package/build/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +9 -37
- 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 +7 -5
- 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 +37 -5
- 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/date-format-picker/index.js +0 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +1 -2
- package/build/components/font-appearance-control/index.js.map +1 -1
- 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/dimensions-panel.js +30 -19
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.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 +0 -4
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/search-input.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/observe-typing/index.js +5 -10
- package/build/components/observe-typing/index.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/format-toolbar-container.js +1 -31
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +1 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +7 -14
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +5 -8
- package/build/components/url-input/index.js.map +1 -1
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.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 +89 -1
- 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/position.js +0 -1
- package/build/hooks/position.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-typography-props.js +1 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/layouts/grid.js +111 -14
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +2 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +4 -36
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +29 -45
- package/build/store/private-actions.js.map +1 -1
- package/build/store/reducer.js +2 -4
- 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-canvas/index.js +2 -0
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +14 -17
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -4
- 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/index.js +9 -9
- package/build-module/components/block-list/index.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-parent-selector-menu-item.js +46 -0
- package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -40
- 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 +7 -6
- 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 +38 -6
- 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/date-format-picker/index.js +0 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +1 -2
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- 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/dimensions-panel.js +30 -19
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.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 +0 -4
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/search-input.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/observe-typing/index.js +5 -10
- package/build-module/components/observe-typing/index.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/format-toolbar-container.js +1 -31
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +8 -14
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +5 -8
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.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 +89 -1
- 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/position.js +0 -1
- package/build-module/hooks/position.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-typography-props.js +2 -3
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/layouts/grid.js +113 -16
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +2 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +4 -36
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +29 -45
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/reducer.js +2 -4
- 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 +7 -2
- package/build-style/content.css +7 -2
- package/build-style/style-rtl.css +55 -25
- package/build-style/style.css +55 -25
- package/package.json +31 -32
- package/src/components/block-canvas/index.js +2 -0
- package/src/components/block-draggable/test/index.native.js +2 -2
- package/src/components/block-heading-level-dropdown/index.js +17 -25
- package/src/components/block-inspector/index.js +0 -11
- 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/index.js +55 -55
- package/src/components/block-list/test/block-outline.native.js +255 -0
- 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-parent-selector-menu-item.js +50 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +9 -50
- package/src/components/block-styles/style.scss +0 -4
- 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 +5 -11
- 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 +85 -44
- 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/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +5 -2
- package/src/components/font-appearance-control/index.js +0 -1
- package/src/components/global-styles/border-panel.js +2 -2
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +36 -24
- package/src/components/global-styles/image-settings-panel.js +1 -1
- package/src/components/global-styles/test/typography-utils.js +231 -81
- package/src/components/global-styles/test/use-global-styles-output.js +3 -2
- 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 +0 -7
- package/src/components/line-height-control/test/index.js +1 -1
- package/src/components/link-control/search-input.js +1 -1
- 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/observe-typing/index.js +7 -10
- 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/format-toolbar-container.js +1 -48
- package/src/components/rich-text/index.js +1 -2
- package/src/components/skip-to-selected-block/index.js +10 -13
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -5
- package/src/components/url-input/index.js +6 -15
- package/src/hooks/anchor.scss +1 -1
- package/src/hooks/background.js +1 -1
- package/src/hooks/block-hooks.js +1 -1
- 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 +91 -1
- package/src/hooks/layout.js +12 -1
- package/src/hooks/line-height.js +1 -1
- package/src/hooks/position.js +0 -1
- package/src/hooks/spacing-visualizer.js +126 -0
- package/src/hooks/{padding.scss → spacing.scss} +1 -1
- package/src/hooks/use-typography-props.js +2 -8
- package/src/layouts/grid.js +137 -53
- package/src/layouts/test/grid.js +16 -2
- package/src/private-apis.js +2 -2
- package/src/store/actions.js +4 -42
- package/src/store/private-actions.js +34 -69
- package/src/store/reducer.js +2 -8
- package/src/store/selectors.js +41 -46
- package/src/store/test/actions.js +0 -105
- package/src/style.scss +2 -2
- package/src/utils/calculate-scale.js +20 -0
- package/build/components/default-style-picker/index.js +0 -70
- package/build/components/default-style-picker/index.js.map +0 -1
- 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/components/default-style-picker/index.js +0 -63
- package/build-module/components/default-style-picker/index.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/components/block-settings-menu/style.scss +0 -3
- package/src/components/default-style-picker/index.js +0 -70
- 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
|
@@ -9,13 +9,17 @@ import { useSelect } from '@wordpress/data';
|
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockEditorStore } from '../store';
|
|
11
11
|
import { useStyleOverride } from './utils';
|
|
12
|
+
import { useLayout } from '../components/block-list/layout';
|
|
13
|
+
import { GridVisualizer, GridItemResizer } from '../components/grid-visualizer';
|
|
12
14
|
|
|
13
15
|
function useBlockPropsChildLayoutStyles( { style } ) {
|
|
14
16
|
const shouldRenderChildLayoutStyles = useSelect( ( select ) => {
|
|
15
17
|
return ! select( blockEditorStore ).getSettings().disableLayoutStyles;
|
|
16
18
|
} );
|
|
17
19
|
const layout = style?.layout ?? {};
|
|
18
|
-
const { selfStretch, flexSize } = layout;
|
|
20
|
+
const { selfStretch, flexSize, columnSpan, rowSpan } = layout;
|
|
21
|
+
const parentLayout = useLayout() || {};
|
|
22
|
+
const { columnCount, minimumColumnWidth } = parentLayout;
|
|
19
23
|
const id = useInstanceId( useBlockPropsChildLayoutStyles );
|
|
20
24
|
const selector = `.wp-container-content-${ id }`;
|
|
21
25
|
|
|
@@ -30,6 +34,55 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
30
34
|
css = `${ selector } {
|
|
31
35
|
flex-grow: 1;
|
|
32
36
|
}`;
|
|
37
|
+
} else if ( columnSpan ) {
|
|
38
|
+
css = `${ selector } {
|
|
39
|
+
grid-column: span ${ columnSpan };
|
|
40
|
+
}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* If minimumColumnWidth is set on the parent, or if no
|
|
44
|
+
* columnCount is set, the grid is responsive so a
|
|
45
|
+
* container query is needed for the span to resize.
|
|
46
|
+
*/
|
|
47
|
+
if ( columnSpan && ( minimumColumnWidth || ! columnCount ) ) {
|
|
48
|
+
// Calculate the container query value.
|
|
49
|
+
const columnSpanNumber = parseInt( columnSpan );
|
|
50
|
+
let parentColumnValue = parseFloat( minimumColumnWidth );
|
|
51
|
+
/**
|
|
52
|
+
* 12rem is the default minimumColumnWidth value.
|
|
53
|
+
* If parentColumnValue is not a number, default to 12.
|
|
54
|
+
*/
|
|
55
|
+
if ( isNaN( parentColumnValue ) ) {
|
|
56
|
+
parentColumnValue = 12;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let parentColumnUnit = minimumColumnWidth?.replace(
|
|
60
|
+
parentColumnValue,
|
|
61
|
+
''
|
|
62
|
+
);
|
|
63
|
+
/**
|
|
64
|
+
* Check that parent column unit is either 'px', 'rem' or 'em'.
|
|
65
|
+
* If not, default to 'rem'.
|
|
66
|
+
*/
|
|
67
|
+
if ( ! [ 'px', 'rem', 'em' ].includes( parentColumnUnit ) ) {
|
|
68
|
+
parentColumnUnit = 'rem';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5;
|
|
72
|
+
const containerQueryValue =
|
|
73
|
+
columnSpanNumber * parentColumnValue +
|
|
74
|
+
( columnSpanNumber - 1 ) * defaultGapValue;
|
|
75
|
+
|
|
76
|
+
css += `@container (max-width: ${ containerQueryValue }${ parentColumnUnit }) {
|
|
77
|
+
${ selector } {
|
|
78
|
+
grid-column: 1 / -1;
|
|
79
|
+
}
|
|
80
|
+
}`;
|
|
81
|
+
}
|
|
82
|
+
if ( rowSpan ) {
|
|
83
|
+
css += `${ selector } {
|
|
84
|
+
grid-row: span ${ rowSpan };
|
|
85
|
+
}`;
|
|
33
86
|
}
|
|
34
87
|
}
|
|
35
88
|
|
|
@@ -44,8 +97,45 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
44
97
|
return { className: `wp-container-content-${ id }` };
|
|
45
98
|
}
|
|
46
99
|
|
|
100
|
+
function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
|
|
101
|
+
const parentLayout = useLayout() || {};
|
|
102
|
+
const rootClientId = useSelect(
|
|
103
|
+
( select ) => {
|
|
104
|
+
return select( blockEditorStore ).getBlockRootClientId( clientId );
|
|
105
|
+
},
|
|
106
|
+
[ clientId ]
|
|
107
|
+
);
|
|
108
|
+
if ( parentLayout.type !== 'grid' ) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
if ( ! window.__experimentalEnableGridInteractivity ) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return (
|
|
115
|
+
<>
|
|
116
|
+
<GridVisualizer clientId={ rootClientId } />
|
|
117
|
+
<GridItemResizer
|
|
118
|
+
clientId={ clientId }
|
|
119
|
+
onChange={ ( { columnSpan, rowSpan } ) => {
|
|
120
|
+
setAttributes( {
|
|
121
|
+
style: {
|
|
122
|
+
...style,
|
|
123
|
+
layout: {
|
|
124
|
+
...style?.layout,
|
|
125
|
+
columnSpan,
|
|
126
|
+
rowSpan,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
} );
|
|
130
|
+
} }
|
|
131
|
+
/>
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
47
136
|
export default {
|
|
48
137
|
useBlockProps: useBlockPropsChildLayoutStyles,
|
|
138
|
+
edit: ChildLayoutControlsPure,
|
|
49
139
|
attributeKeys: [ 'style' ],
|
|
50
140
|
hasSupport() {
|
|
51
141
|
return true;
|
package/src/hooks/layout.js
CHANGED
|
@@ -135,7 +135,12 @@ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) {
|
|
|
135
135
|
return css;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
function LayoutPanelPure( {
|
|
138
|
+
function LayoutPanelPure( {
|
|
139
|
+
layout,
|
|
140
|
+
setAttributes,
|
|
141
|
+
name: blockName,
|
|
142
|
+
clientId,
|
|
143
|
+
} ) {
|
|
139
144
|
const settings = useBlockSettings( blockName );
|
|
140
145
|
// Block settings come from theme.json under settings.[blockName].
|
|
141
146
|
const { layout: layoutSettings } = settings;
|
|
@@ -266,6 +271,8 @@ function LayoutPanelPure( { layout, setAttributes, name: blockName } ) {
|
|
|
266
271
|
layout={ usedLayout }
|
|
267
272
|
onChange={ onChangeLayout }
|
|
268
273
|
layoutBlockSupport={ blockSupportAndThemeSettings }
|
|
274
|
+
name={ blockName }
|
|
275
|
+
clientId={ clientId }
|
|
269
276
|
/>
|
|
270
277
|
) }
|
|
271
278
|
{ constrainedType && displayControlsForLegacyLayouts && (
|
|
@@ -273,6 +280,8 @@ function LayoutPanelPure( { layout, setAttributes, name: blockName } ) {
|
|
|
273
280
|
layout={ usedLayout }
|
|
274
281
|
onChange={ onChangeLayout }
|
|
275
282
|
layoutBlockSupport={ blockSupportAndThemeSettings }
|
|
283
|
+
name={ blockName }
|
|
284
|
+
clientId={ clientId }
|
|
276
285
|
/>
|
|
277
286
|
) }
|
|
278
287
|
</PanelBody>
|
|
@@ -282,6 +291,8 @@ function LayoutPanelPure( { layout, setAttributes, name: blockName } ) {
|
|
|
282
291
|
layout={ usedLayout }
|
|
283
292
|
onChange={ onChangeLayout }
|
|
284
293
|
layoutBlockSupport={ layoutBlockSupport }
|
|
294
|
+
name={ blockName }
|
|
295
|
+
clientId={ clientId }
|
|
285
296
|
/>
|
|
286
297
|
) }
|
|
287
298
|
</>
|
package/src/hooks/line-height.js
CHANGED
|
@@ -39,7 +39,7 @@ export function LineHeightEdit( props ) {
|
|
|
39
39
|
return (
|
|
40
40
|
<LineHeightControl
|
|
41
41
|
__unstableInputWidth="100%"
|
|
42
|
-
__nextHasNoMarginBottom
|
|
42
|
+
__nextHasNoMarginBottom
|
|
43
43
|
value={ style?.typography?.lineHeight }
|
|
44
44
|
onChange={ onChange }
|
|
45
45
|
size="__unstable-large"
|
package/src/hooks/position.js
CHANGED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useEffect,
|
|
9
|
+
useReducer,
|
|
10
|
+
} from '@wordpress/element';
|
|
11
|
+
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import BlockPopoverCover from '../components/block-popover/cover';
|
|
17
|
+
import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
18
|
+
|
|
19
|
+
function SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {
|
|
20
|
+
const blockElement = useBlockElement( clientId );
|
|
21
|
+
const [ style, updateStyle ] = useReducer( () =>
|
|
22
|
+
computeStyle( blockElement )
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
useLayoutEffect( () => {
|
|
26
|
+
if ( ! blockElement ) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// It's not sufficient to read the computed spacing value when value.spacing changes as
|
|
30
|
+
// useEffect may run before the browser recomputes CSS. We therefore combine
|
|
31
|
+
// useLayoutEffect and two rAF calls to ensure that we read the spacing after the current
|
|
32
|
+
// paint but before the next paint.
|
|
33
|
+
// See https://github.com/WordPress/gutenberg/pull/59227.
|
|
34
|
+
window.requestAnimationFrame( () =>
|
|
35
|
+
window.requestAnimationFrame( updateStyle )
|
|
36
|
+
);
|
|
37
|
+
}, [ blockElement, value ] );
|
|
38
|
+
|
|
39
|
+
const previousValue = useRef( value );
|
|
40
|
+
const [ isActive, setIsActive ] = useState( false );
|
|
41
|
+
|
|
42
|
+
useEffect( () => {
|
|
43
|
+
if ( isShallowEqual( value, previousValue.current ) || forceShow ) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setIsActive( true );
|
|
48
|
+
previousValue.current = value;
|
|
49
|
+
|
|
50
|
+
const timeout = setTimeout( () => {
|
|
51
|
+
setIsActive( false );
|
|
52
|
+
}, 400 );
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
setIsActive( false );
|
|
56
|
+
clearTimeout( timeout );
|
|
57
|
+
};
|
|
58
|
+
}, [ value, forceShow ] );
|
|
59
|
+
|
|
60
|
+
if ( ! isActive && ! forceShow ) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<BlockPopoverCover
|
|
66
|
+
clientId={ clientId }
|
|
67
|
+
__unstablePopoverSlot="block-toolbar"
|
|
68
|
+
>
|
|
69
|
+
<div className="block-editor__spacing-visualizer" style={ style } />
|
|
70
|
+
</BlockPopoverCover>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getComputedCSS( element, property ) {
|
|
75
|
+
return element.ownerDocument.defaultView
|
|
76
|
+
.getComputedStyle( element )
|
|
77
|
+
.getPropertyValue( property );
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function MarginVisualizer( { clientId, value, forceShow } ) {
|
|
81
|
+
return (
|
|
82
|
+
<SpacingVisualizer
|
|
83
|
+
clientId={ clientId }
|
|
84
|
+
value={ value?.spacing?.margin }
|
|
85
|
+
computeStyle={ ( blockElement ) => {
|
|
86
|
+
const top = getComputedCSS( blockElement, 'margin-top' );
|
|
87
|
+
const right = getComputedCSS( blockElement, 'margin-right' );
|
|
88
|
+
const bottom = getComputedCSS( blockElement, 'margin-bottom' );
|
|
89
|
+
const left = getComputedCSS( blockElement, 'margin-left' );
|
|
90
|
+
return {
|
|
91
|
+
borderTopWidth: top,
|
|
92
|
+
borderRightWidth: right,
|
|
93
|
+
borderBottomWidth: bottom,
|
|
94
|
+
borderLeftWidth: left,
|
|
95
|
+
top: top ? `-${ top }` : 0,
|
|
96
|
+
right: right ? `-${ right }` : 0,
|
|
97
|
+
bottom: bottom ? `-${ bottom }` : 0,
|
|
98
|
+
left: left ? `-${ left }` : 0,
|
|
99
|
+
};
|
|
100
|
+
} }
|
|
101
|
+
forceShow={ forceShow }
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function PaddingVisualizer( { clientId, value, forceShow } ) {
|
|
107
|
+
return (
|
|
108
|
+
<SpacingVisualizer
|
|
109
|
+
clientId={ clientId }
|
|
110
|
+
value={ value?.spacing?.padding }
|
|
111
|
+
computeStyle={ ( blockElement ) => ( {
|
|
112
|
+
borderTopWidth: getComputedCSS( blockElement, 'padding-top' ),
|
|
113
|
+
borderRightWidth: getComputedCSS(
|
|
114
|
+
blockElement,
|
|
115
|
+
'padding-right'
|
|
116
|
+
),
|
|
117
|
+
borderBottomWidth: getComputedCSS(
|
|
118
|
+
blockElement,
|
|
119
|
+
'padding-bottom'
|
|
120
|
+
),
|
|
121
|
+
borderLeftWidth: getComputedCSS( blockElement, 'padding-left' ),
|
|
122
|
+
} ) }
|
|
123
|
+
forceShow={ forceShow }
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -13,10 +13,7 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
|
13
13
|
*/
|
|
14
14
|
import { getInlineStyles } from './style';
|
|
15
15
|
import { getFontSizeClass } from '../components/font-sizes';
|
|
16
|
-
import {
|
|
17
|
-
getTypographyFontSizeValue,
|
|
18
|
-
getFluidTypographyOptionsFromSettings,
|
|
19
|
-
} from '../components/global-styles/typography-utils';
|
|
16
|
+
import { getTypographyFontSizeValue } from '../components/global-styles/typography-utils';
|
|
20
17
|
import { unlock } from '../lock-unlock';
|
|
21
18
|
|
|
22
19
|
/*
|
|
@@ -36,14 +33,11 @@ import { unlock } from '../lock-unlock';
|
|
|
36
33
|
export function getTypographyClassesAndStyles( attributes, settings ) {
|
|
37
34
|
const { kebabCase } = unlock( componentsPrivateApis );
|
|
38
35
|
let typographyStyles = attributes?.style?.typography || {};
|
|
39
|
-
const fluidTypographySettings =
|
|
40
|
-
getFluidTypographyOptionsFromSettings( settings );
|
|
41
|
-
|
|
42
36
|
typographyStyles = {
|
|
43
37
|
...typographyStyles,
|
|
44
38
|
fontSize: getTypographyFontSizeValue(
|
|
45
39
|
{ size: attributes?.style?.typography?.fontSize },
|
|
46
|
-
|
|
40
|
+
settings
|
|
47
41
|
),
|
|
48
42
|
};
|
|
49
43
|
|
package/src/layouts/grid.js
CHANGED
|
@@ -8,9 +8,13 @@ import {
|
|
|
8
8
|
Flex,
|
|
9
9
|
FlexItem,
|
|
10
10
|
RangeControl,
|
|
11
|
+
__experimentalNumberControl as NumberControl,
|
|
12
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
13
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
11
14
|
__experimentalUnitControl as UnitControl,
|
|
12
15
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
13
16
|
} from '@wordpress/components';
|
|
17
|
+
import { useState } from '@wordpress/element';
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* Internal dependencies
|
|
@@ -19,6 +23,7 @@ import { appendSelectors, getBlockGapCSS } from './utils';
|
|
|
19
23
|
import { getGapCSSValue } from '../hooks/gap';
|
|
20
24
|
import { shouldSkipSerialization } from '../hooks/utils';
|
|
21
25
|
import { LAYOUT_DEFINITIONS } from './definitions';
|
|
26
|
+
import { GridVisualizer } from '../components/grid-visualizer';
|
|
22
27
|
|
|
23
28
|
const RANGE_CONTROL_MAX_VALUES = {
|
|
24
29
|
px: 600,
|
|
@@ -51,23 +56,44 @@ const RANGE_CONTROL_MAX_VALUES = {
|
|
|
51
56
|
dvmax: 100,
|
|
52
57
|
};
|
|
53
58
|
|
|
59
|
+
const units = [
|
|
60
|
+
{ value: 'px', label: 'px', default: 0 },
|
|
61
|
+
{ value: 'rem', label: 'rem', default: 0 },
|
|
62
|
+
{ value: 'em', label: 'em', default: 0 },
|
|
63
|
+
];
|
|
64
|
+
|
|
54
65
|
export default {
|
|
55
66
|
name: 'grid',
|
|
56
67
|
label: __( 'Grid' ),
|
|
57
68
|
inspectorControls: function GridLayoutInspectorControls( {
|
|
58
69
|
layout = {},
|
|
59
70
|
onChange,
|
|
71
|
+
clientId,
|
|
60
72
|
} ) {
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<GridLayoutTypeControl
|
|
76
|
+
layout={ layout }
|
|
77
|
+
onChange={ onChange }
|
|
78
|
+
/>
|
|
79
|
+
{ layout?.columnCount ? (
|
|
80
|
+
<GridLayoutColumnsControl
|
|
81
|
+
layout={ layout }
|
|
82
|
+
onChange={ onChange }
|
|
83
|
+
/>
|
|
84
|
+
) : (
|
|
85
|
+
<GridLayoutMinimumWidthControl
|
|
86
|
+
layout={ layout }
|
|
87
|
+
onChange={ onChange }
|
|
88
|
+
/>
|
|
89
|
+
) }
|
|
90
|
+
{ window.__experimentalEnableGridInteractivity && (
|
|
91
|
+
<GridVisualizer clientId={ clientId } />
|
|
92
|
+
) }
|
|
93
|
+
</>
|
|
68
94
|
);
|
|
69
95
|
},
|
|
70
|
-
toolBarControls: function
|
|
96
|
+
toolBarControls: function GridLayoutToolbarControls() {
|
|
71
97
|
return null;
|
|
72
98
|
},
|
|
73
99
|
getLayoutStyle: function getLayoutStyle( {
|
|
@@ -97,7 +123,8 @@ export default {
|
|
|
97
123
|
);
|
|
98
124
|
} else if ( minimumColumnWidth ) {
|
|
99
125
|
rules.push(
|
|
100
|
-
`grid-template-columns: repeat(auto-fill, minmax(min(${ minimumColumnWidth }, 100%), 1fr))
|
|
126
|
+
`grid-template-columns: repeat(auto-fill, minmax(min(${ minimumColumnWidth }, 100%), 1fr))`,
|
|
127
|
+
`container-type: inline-size`
|
|
101
128
|
);
|
|
102
129
|
}
|
|
103
130
|
|
|
@@ -152,38 +179,6 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
|
|
|
152
179
|
} else if ( [ 'em', 'rem' ].includes( unit ) && newUnit === 'px' ) {
|
|
153
180
|
// Convert to pixel value assuming a root size of 16px.
|
|
154
181
|
newValue = Math.round( quantity * 16 ) + newUnit;
|
|
155
|
-
} else if (
|
|
156
|
-
[
|
|
157
|
-
'vh',
|
|
158
|
-
'vw',
|
|
159
|
-
'%',
|
|
160
|
-
'svw',
|
|
161
|
-
'lvw',
|
|
162
|
-
'dvw',
|
|
163
|
-
'svh',
|
|
164
|
-
'lvh',
|
|
165
|
-
'dvh',
|
|
166
|
-
'vi',
|
|
167
|
-
'svi',
|
|
168
|
-
'lvi',
|
|
169
|
-
'dvi',
|
|
170
|
-
'vb',
|
|
171
|
-
'svb',
|
|
172
|
-
'lvb',
|
|
173
|
-
'dvb',
|
|
174
|
-
'vmin',
|
|
175
|
-
'svmin',
|
|
176
|
-
'lvmin',
|
|
177
|
-
'dvmin',
|
|
178
|
-
'vmax',
|
|
179
|
-
'svmax',
|
|
180
|
-
'lvmax',
|
|
181
|
-
'dvmax',
|
|
182
|
-
].includes( newUnit ) &&
|
|
183
|
-
quantity > 100
|
|
184
|
-
) {
|
|
185
|
-
// When converting to `%` or viewport-relative units, cap the new value at 100.
|
|
186
|
-
newValue = 100 + newUnit;
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
onChange( {
|
|
@@ -209,7 +204,10 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
|
|
|
209
204
|
} }
|
|
210
205
|
onUnitChange={ handleUnitChange }
|
|
211
206
|
value={ value }
|
|
207
|
+
units={ units }
|
|
212
208
|
min={ 0 }
|
|
209
|
+
label={ __( 'Minimum column width' ) }
|
|
210
|
+
hideLabelFromVision
|
|
213
211
|
/>
|
|
214
212
|
</FlexItem>
|
|
215
213
|
<FlexItem isBlock>
|
|
@@ -219,6 +217,8 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
|
|
|
219
217
|
min={ 0 }
|
|
220
218
|
max={ RANGE_CONTROL_MAX_VALUES[ unit ] || 600 }
|
|
221
219
|
withInputField={ false }
|
|
220
|
+
label={ __( 'Minimum column width' ) }
|
|
221
|
+
hideLabelFromVision
|
|
222
222
|
/>
|
|
223
223
|
</FlexItem>
|
|
224
224
|
</Flex>
|
|
@@ -231,17 +231,101 @@ function GridLayoutColumnsControl( { layout, onChange } ) {
|
|
|
231
231
|
const { columnCount = 3 } = layout;
|
|
232
232
|
|
|
233
233
|
return (
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
234
|
+
<fieldset>
|
|
235
|
+
<BaseControl.VisualLabel as="legend">
|
|
236
|
+
{ __( 'Columns' ) }
|
|
237
|
+
</BaseControl.VisualLabel>
|
|
238
|
+
<Flex gap={ 4 }>
|
|
239
|
+
<FlexItem isBlock>
|
|
240
|
+
<NumberControl
|
|
241
|
+
size={ '__unstable-large' }
|
|
242
|
+
onChange={ ( value ) => {
|
|
243
|
+
/**
|
|
244
|
+
* If the input is cleared, avoid switching
|
|
245
|
+
* back to "Auto" by setting a value of "1".
|
|
246
|
+
*/
|
|
247
|
+
const validValue = value !== '' ? value : '1';
|
|
248
|
+
onChange( {
|
|
249
|
+
...layout,
|
|
250
|
+
columnCount: validValue,
|
|
251
|
+
} );
|
|
252
|
+
} }
|
|
253
|
+
value={ columnCount }
|
|
254
|
+
min={ 1 }
|
|
255
|
+
label={ __( 'Columns' ) }
|
|
256
|
+
hideLabelFromVision
|
|
257
|
+
/>
|
|
258
|
+
</FlexItem>
|
|
259
|
+
<FlexItem isBlock>
|
|
260
|
+
<RangeControl
|
|
261
|
+
value={ parseInt( columnCount, 10 ) } // RangeControl can't deal with strings.
|
|
262
|
+
onChange={ ( value ) =>
|
|
263
|
+
onChange( {
|
|
264
|
+
...layout,
|
|
265
|
+
columnCount: value,
|
|
266
|
+
} )
|
|
267
|
+
}
|
|
268
|
+
min={ 1 }
|
|
269
|
+
max={ 16 }
|
|
270
|
+
withInputField={ false }
|
|
271
|
+
label={ __( 'Columns' ) }
|
|
272
|
+
hideLabelFromVision
|
|
273
|
+
/>
|
|
274
|
+
</FlexItem>
|
|
275
|
+
</Flex>
|
|
276
|
+
</fieldset>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Enables switching between grid types
|
|
281
|
+
function GridLayoutTypeControl( { layout, onChange } ) {
|
|
282
|
+
const { columnCount, minimumColumnWidth } = layout;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* When switching, temporarily save any custom values set on the
|
|
286
|
+
* previous type so we can switch back without loss.
|
|
287
|
+
*/
|
|
288
|
+
const [ tempColumnCount, setTempColumnCount ] = useState(
|
|
289
|
+
columnCount || 3
|
|
290
|
+
);
|
|
291
|
+
const [ tempMinimumColumnWidth, setTempMinimumColumnWidth ] = useState(
|
|
292
|
+
minimumColumnWidth || '12rem'
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const isManual = !! columnCount ? 'manual' : 'auto';
|
|
296
|
+
|
|
297
|
+
const onChangeType = ( value ) => {
|
|
298
|
+
if ( value === 'manual' ) {
|
|
299
|
+
setTempMinimumColumnWidth( minimumColumnWidth || '12rem' );
|
|
300
|
+
} else {
|
|
301
|
+
setTempColumnCount( columnCount || 3 );
|
|
302
|
+
}
|
|
303
|
+
onChange( {
|
|
304
|
+
...layout,
|
|
305
|
+
columnCount: value === 'manual' ? tempColumnCount : null,
|
|
306
|
+
minimumColumnWidth:
|
|
307
|
+
value === 'auto' ? tempMinimumColumnWidth : null,
|
|
308
|
+
} );
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<ToggleGroupControl
|
|
313
|
+
__nextHasNoMarginBottom
|
|
314
|
+
label={ __( 'Type' ) }
|
|
315
|
+
value={ isManual }
|
|
316
|
+
onChange={ onChangeType }
|
|
317
|
+
isBlock
|
|
318
|
+
>
|
|
319
|
+
<ToggleGroupControlOption
|
|
320
|
+
key={ 'auto' }
|
|
321
|
+
value="auto"
|
|
322
|
+
label={ __( 'Auto' ) }
|
|
323
|
+
/>
|
|
324
|
+
<ToggleGroupControlOption
|
|
325
|
+
key={ 'manual' }
|
|
326
|
+
value="manual"
|
|
327
|
+
label={ __( 'Manual' ) }
|
|
328
|
+
/>
|
|
329
|
+
</ToggleGroupControl>
|
|
246
330
|
);
|
|
247
331
|
}
|
package/src/layouts/test/grid.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import grid from '../grid';
|
|
5
5
|
|
|
6
6
|
describe( 'getLayoutStyle', () => {
|
|
7
|
-
it( 'should return
|
|
8
|
-
const expected = `.editor-styles-wrapper .my-container { grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr)); }`;
|
|
7
|
+
it( 'should return only `grid-template-columns` and `container-type` properties if no non-default params are provided', () => {
|
|
8
|
+
const expected = `.editor-styles-wrapper .my-container { grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr)); container-type: inline-size; }`;
|
|
9
9
|
|
|
10
10
|
const result = grid.getLayoutStyle( {
|
|
11
11
|
selector: '.my-container',
|
|
@@ -16,6 +16,20 @@ describe( 'getLayoutStyle', () => {
|
|
|
16
16
|
layoutDefinitions: undefined,
|
|
17
17
|
} );
|
|
18
18
|
|
|
19
|
+
expect( result ).toBe( expected );
|
|
20
|
+
} );
|
|
21
|
+
it( 'should return only `grid-template-columns` if columnCount property is provided', () => {
|
|
22
|
+
const expected = `.editor-styles-wrapper .my-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }`;
|
|
23
|
+
|
|
24
|
+
const result = grid.getLayoutStyle( {
|
|
25
|
+
selector: '.my-container',
|
|
26
|
+
layout: { columnCount: 3 },
|
|
27
|
+
style: {},
|
|
28
|
+
blockName: 'test-block',
|
|
29
|
+
hasBlockGapSupport: false,
|
|
30
|
+
layoutDefinitions: undefined,
|
|
31
|
+
} );
|
|
32
|
+
|
|
19
33
|
expect( result ).toBe( expected );
|
|
20
34
|
} );
|
|
21
35
|
} );
|
package/src/private-apis.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ComposedPrivateInserter as PrivateInserter } from './components/inserte
|
|
|
10
10
|
import { default as PrivateQuickInserter } from './components/inserter/quick-inserter';
|
|
11
11
|
import { PrivateListView } from './components/list-view';
|
|
12
12
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
|
-
import {
|
|
13
|
+
import { useShowBlockTools } from './components/block-tools/use-show-block-tools';
|
|
14
14
|
import { cleanEmptyObject, useStyleOverride } from './hooks/utils';
|
|
15
15
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
16
16
|
import { LayoutStyle } from './components/block-list/layout';
|
|
@@ -45,7 +45,7 @@ lock( privateApis, {
|
|
|
45
45
|
PrivateListView,
|
|
46
46
|
ResizableBoxPopover,
|
|
47
47
|
BlockInfo,
|
|
48
|
-
|
|
48
|
+
useShowBlockTools,
|
|
49
49
|
cleanEmptyObject,
|
|
50
50
|
useStyleOverride,
|
|
51
51
|
BlockQuickNavigation,
|