@wordpress/block-editor 13.2.0 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +0 -1
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-lock/toolbar.js +0 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +1 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +5 -7
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +20 -17
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-rename/modal.js +4 -12
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +1 -0
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -58
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/index.js +14 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -2
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +57 -0
- package/build/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build/components/block-tools/zoom-out-toolbar.js +138 -0
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build/components/button-block-appender/index.js +3 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +26 -18
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +10 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/dimensions-tool/index.js +6 -4
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +26 -61
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +178 -116
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +8 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +50 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +50 -0
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +23 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +11 -14
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +2 -2
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +116 -36
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +29 -22
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/media-placeholder/index.js +19 -23
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +66 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -0
- package/build/components/url-popover/index.js +3 -0
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/background.js +26 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +11 -17
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +169 -4
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +65 -0
- package/build/hooks/grid-visualizer.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +39 -22
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +2 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +16 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +2 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +44 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +90 -51
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/defaults.js +0 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +0 -3
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/utils/format-font-style.js +45 -0
- package/build/utils/format-font-style.js.map +1 -0
- package/build/utils/format-font-weight.js +68 -0
- package/build/utils/format-font-weight.js.map +1 -0
- package/build/utils/get-editor-region.js +34 -0
- package/build/utils/get-editor-region.js.map +1 -0
- package/build/utils/get-font-styles-and-weights.js +167 -0
- package/build/utils/get-font-styles-and-weights.js.map +1 -0
- package/build/utils/pasting.js +5 -13
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +12 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +0 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +5 -7
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +20 -17
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +5 -13
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +1 -0
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +10 -61
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -2
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +48 -0
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build-module/components/button-block-appender/index.js +3 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +27 -19
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +11 -3
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +6 -4
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -63
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +181 -119
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +8 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +52 -14
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +48 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +23 -8
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +11 -14
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +2 -2
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +117 -37
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +29 -22
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +19 -23
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +60 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -0
- package/build-module/components/url-popover/index.js +3 -0
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/background.js +26 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +11 -17
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +168 -4
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +64 -0
- package/build-module/hooks/grid-visualizer.js.map +1 -0
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +39 -22
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +2 -9
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +16 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +2 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +44 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +90 -51
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +8 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/defaults.js +0 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +0 -3
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/utils/format-font-style.js +39 -0
- package/build-module/utils/format-font-style.js.map +1 -0
- package/build-module/utils/format-font-weight.js +62 -0
- package/build-module/utils/format-font-weight.js.map +1 -0
- package/build-module/utils/get-editor-region.js +28 -0
- package/build-module/utils/get-editor-region.js.map +1 -0
- package/build-module/utils/get-font-styles-and-weights.js +160 -0
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
- package/build-module/utils/pasting.js +5 -13
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +207 -96
- package/build-style/style.css +207 -96
- package/package.json +32 -32
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-lock/toolbar.js +0 -1
- package/src/components/block-mover/button.js +1 -1
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/src/components/block-patterns-paging/index.js +8 -11
- package/src/components/block-patterns-paging/style.scss +18 -0
- package/src/components/block-quick-navigation/index.js +21 -28
- package/src/components/block-rename/modal.js +2 -8
- package/src/components/block-switcher/test/index.js +6 -6
- package/src/components/block-toolbar/shuffle.js +1 -0
- package/src/components/block-toolbar/style.scss +1 -11
- package/src/components/block-tools/block-selection-button.js +11 -83
- package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
- package/src/components/block-tools/index.js +21 -1
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-tools/use-show-block-tools.js +14 -6
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/src/components/block-tools/zoom-out-popover.js +49 -0
- package/src/components/block-tools/zoom-out-toolbar.js +140 -0
- package/src/components/button-block-appender/index.js +2 -1
- package/src/components/child-layout-control/index.js +41 -23
- package/src/components/date-format-picker/index.js +10 -1
- package/src/components/date-format-picker/style.scss +0 -9
- package/src/components/dimensions-tool/index.js +97 -89
- package/src/components/font-appearance-control/index.js +29 -83
- package/src/components/font-appearance-control/style.scss +3 -5
- package/src/components/global-styles/background-panel.js +249 -170
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/hooks.js +9 -0
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/style.scss +105 -20
- package/src/components/global-styles/test/typography-utils.js +269 -0
- package/src/components/global-styles/typography-panel.js +49 -12
- package/src/components/global-styles/typography-utils.js +63 -0
- package/src/components/global-styles/use-global-styles-output.js +23 -8
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +11 -27
- package/src/components/grid/grid-item-resizer.js +3 -2
- package/src/components/grid/grid-visualizer.js +171 -54
- package/src/components/grid/style.scss +43 -8
- package/src/components/grid/use-grid-layout-sync.js +31 -28
- package/src/components/iframe/content.scss +1 -0
- package/src/components/inner-blocks/index.js +2 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
- package/src/components/inserter/menu.js +47 -13
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +1 -49
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/media-placeholder/index.js +22 -32
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
- package/src/components/tabbed-sidebar/README.md +76 -0
- package/src/components/tabbed-sidebar/index.js +70 -0
- package/src/components/tabbed-sidebar/style.scss +53 -0
- package/src/components/url-popover/index.js +3 -0
- package/src/hooks/background.js +25 -10
- package/src/hooks/block-hooks.js +9 -16
- package/src/hooks/block-style-variation.js +202 -3
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/grid-visualizer.js +64 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +53 -37
- package/src/hooks/position.js +3 -10
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +18 -4
- package/src/hooks/utils.js +2 -0
- package/src/layouts/constrained.js +43 -2
- package/src/layouts/grid.js +146 -51
- package/src/private-apis.js +12 -1
- package/src/store/defaults.js +0 -2
- package/src/store/defaults.native.js +0 -3
- package/src/store/private-keys.js +1 -0
- package/src/style.scss +1 -1
- package/src/utils/format-font-style.js +40 -0
- package/src/utils/format-font-weight.js +63 -0
- package/src/utils/get-editor-region.js +31 -0
- package/src/utils/get-font-styles-and-weights.js +191 -0
- package/src/utils/pasting.js +5 -12
- package/src/utils/test/format-font-style.js +34 -0
- package/src/utils/test/format-font-weight.js +66 -0
- package/src/utils/test/get-font-styles-and-weights.js +513 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/hooks/position.scss +0 -18
|
@@ -30,12 +30,10 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
|
|
|
30
30
|
useEffect( () => {
|
|
31
31
|
const updates = {};
|
|
32
32
|
|
|
33
|
-
const { columnCount, rowCount
|
|
34
|
-
const isManualGrid = !! columnCount;
|
|
33
|
+
const { columnCount, rowCount, isManualPlacement } = gridLayout;
|
|
35
34
|
|
|
36
|
-
if (
|
|
35
|
+
if ( isManualPlacement ) {
|
|
37
36
|
const rects = [];
|
|
38
|
-
let cellsTaken = 0;
|
|
39
37
|
|
|
40
38
|
// Respect the position of blocks that already have a columnStart and rowStart value.
|
|
41
39
|
for ( const clientId of blockOrder ) {
|
|
@@ -46,7 +44,6 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
|
|
|
46
44
|
columnSpan = 1,
|
|
47
45
|
rowSpan = 1,
|
|
48
46
|
} = attributes.style?.layout || {};
|
|
49
|
-
cellsTaken += columnSpan * rowSpan;
|
|
50
47
|
if ( ! columnStart || ! rowStart ) {
|
|
51
48
|
continue;
|
|
52
49
|
}
|
|
@@ -60,29 +57,21 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
|
|
|
60
57
|
);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
// Ensure there's enough rows to fit all blocks.
|
|
64
|
-
const minimumNeededRows = Math.ceil( cellsTaken / columnCount );
|
|
65
|
-
if ( rowCount < minimumNeededRows ) {
|
|
66
|
-
updates[ gridClientId ] = {
|
|
67
|
-
layout: {
|
|
68
|
-
...gridLayout,
|
|
69
|
-
rowCount: minimumNeededRows,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
60
|
// When in manual mode, ensure that every block has a columnStart and rowStart value.
|
|
75
61
|
for ( const clientId of blockOrder ) {
|
|
76
62
|
const attributes = getBlockAttributes( clientId );
|
|
77
|
-
const {
|
|
78
|
-
|
|
63
|
+
const {
|
|
64
|
+
columnStart,
|
|
65
|
+
rowStart,
|
|
66
|
+
columnSpan = 1,
|
|
67
|
+
rowSpan = 1,
|
|
68
|
+
} = attributes.style?.layout || {};
|
|
79
69
|
if ( columnStart && rowStart ) {
|
|
80
70
|
continue;
|
|
81
71
|
}
|
|
82
72
|
const [ newColumnStart, newRowStart ] = getFirstEmptyCell(
|
|
83
73
|
rects,
|
|
84
74
|
columnCount,
|
|
85
|
-
minimumNeededRows,
|
|
86
75
|
columnSpan,
|
|
87
76
|
rowSpan
|
|
88
77
|
);
|
|
@@ -105,6 +94,17 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
|
|
|
105
94
|
},
|
|
106
95
|
};
|
|
107
96
|
}
|
|
97
|
+
|
|
98
|
+
// Ensure there's enough rows to fit all blocks.
|
|
99
|
+
const bottomMostRow = Math.max( ...rects.map( ( r ) => r.rowEnd ) );
|
|
100
|
+
if ( ! rowCount || rowCount < bottomMostRow ) {
|
|
101
|
+
updates[ gridClientId ] = {
|
|
102
|
+
layout: {
|
|
103
|
+
...gridLayout,
|
|
104
|
+
rowCount: bottomMostRow,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
108
|
} else {
|
|
109
109
|
// When in auto mode, remove all of the columnStart and rowStart values.
|
|
110
110
|
for ( const clientId of blockOrder ) {
|
|
@@ -121,6 +121,16 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
// Remove row styles in auto mode
|
|
126
|
+
if ( rowCount ) {
|
|
127
|
+
updates[ gridClientId ] = {
|
|
128
|
+
layout: {
|
|
129
|
+
...gridLayout,
|
|
130
|
+
rowCount: undefined,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
if ( Object.keys( updates ).length ) {
|
|
@@ -143,14 +153,8 @@ export function useGridLayoutSync( { clientId: gridClientId } ) {
|
|
|
143
153
|
] );
|
|
144
154
|
}
|
|
145
155
|
|
|
146
|
-
function getFirstEmptyCell(
|
|
147
|
-
|
|
148
|
-
columnCount,
|
|
149
|
-
rowCount,
|
|
150
|
-
columnSpan = 1,
|
|
151
|
-
rowSpan = 1
|
|
152
|
-
) {
|
|
153
|
-
for ( let row = 1; row <= rowCount; row++ ) {
|
|
156
|
+
function getFirstEmptyCell( rects, columnCount, columnSpan = 1, rowSpan = 1 ) {
|
|
157
|
+
for ( let row = 1; ; row++ ) {
|
|
154
158
|
for ( let column = 1; column <= columnCount; column++ ) {
|
|
155
159
|
const rect = new GridRect( {
|
|
156
160
|
columnStart: column,
|
|
@@ -163,5 +167,4 @@ function getFirstEmptyCell(
|
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
|
-
return [ 1, 1 ];
|
|
167
170
|
}
|
|
@@ -269,7 +269,8 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
|
|
|
269
269
|
props.ref,
|
|
270
270
|
__unstableDisableDropZone ||
|
|
271
271
|
isDropZoneDisabled ||
|
|
272
|
-
( layout?.
|
|
272
|
+
( layout?.isManualPlacement &&
|
|
273
|
+
window.__experimentalEnableGridInteractivity )
|
|
273
274
|
? null
|
|
274
275
|
: blockDropZoneRef,
|
|
275
276
|
] );
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { PatternCategoryPreviews } from './pattern-category-previews';
|
|
5
|
-
import { useZoomOut } from '../../../hooks/use-zoom-out';
|
|
6
5
|
|
|
7
|
-
function
|
|
6
|
+
export function PatternCategoryPreviewPanel( {
|
|
8
7
|
rootClientId,
|
|
9
8
|
onInsert,
|
|
10
9
|
onHover,
|
|
@@ -24,17 +23,3 @@ function PatternCategoryPreviewPanelInner( {
|
|
|
24
23
|
/>
|
|
25
24
|
);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
function PatternCategoryPreviewPanelWithZoomOut( props ) {
|
|
29
|
-
useZoomOut();
|
|
30
|
-
return <PatternCategoryPreviewPanelInner { ...props } />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function PatternCategoryPreviewPanel( props ) {
|
|
34
|
-
// When the pattern panel is showing, we want to use zoom out mode
|
|
35
|
-
if ( window.__experimentalEnableZoomedOutPatternsTab ) {
|
|
36
|
-
return <PatternCategoryPreviewPanelWithZoomOut { ...props } />;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return <PatternCategoryPreviewPanelInner { ...props } />;
|
|
40
|
-
}
|
|
@@ -30,8 +30,9 @@ import { PatternCategoryPreviewPanel } from './block-patterns-tab/pattern-catego
|
|
|
30
30
|
import { MediaTab, MediaCategoryPanel } from './media-tab';
|
|
31
31
|
import InserterSearchResults from './search-results';
|
|
32
32
|
import useInsertionPoint from './hooks/use-insertion-point';
|
|
33
|
-
import InserterTabs from './tabs';
|
|
34
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
|
+
import TabbedSidebar from '../tabbed-sidebar';
|
|
35
|
+
import { useZoomOut } from '../../hooks/use-zoom-out';
|
|
35
36
|
|
|
36
37
|
const NOOP = () => {};
|
|
37
38
|
function InserterMenu(
|
|
@@ -88,7 +89,7 @@ function InserterMenu(
|
|
|
88
89
|
shouldForceFocusBlock,
|
|
89
90
|
_rootClientId
|
|
90
91
|
);
|
|
91
|
-
onSelect();
|
|
92
|
+
onSelect( blocks );
|
|
92
93
|
|
|
93
94
|
// Check for focus loss due to filtering blocks by selected block type
|
|
94
95
|
window.requestAnimationFrame( () => {
|
|
@@ -145,6 +146,11 @@ function InserterMenu(
|
|
|
145
146
|
|
|
146
147
|
const showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;
|
|
147
148
|
|
|
149
|
+
const showZoomOut =
|
|
150
|
+
showPatternPanel && window.__experimentalEnableZoomedOutPatternsTab;
|
|
151
|
+
|
|
152
|
+
useZoomOut( showZoomOut );
|
|
153
|
+
|
|
148
154
|
const inserterSearch = useMemo( () => {
|
|
149
155
|
if ( selectedTab === 'media' ) {
|
|
150
156
|
return null;
|
|
@@ -315,21 +321,49 @@ function InserterMenu(
|
|
|
315
321
|
ref={ ref }
|
|
316
322
|
>
|
|
317
323
|
<div className="block-editor-inserter__main-area">
|
|
318
|
-
<
|
|
324
|
+
<TabbedSidebar
|
|
319
325
|
ref={ tabsRef }
|
|
320
326
|
onSelect={ handleSetSelectedTab }
|
|
321
327
|
onClose={ onClose }
|
|
322
328
|
selectedTab={ selectedTab }
|
|
323
|
-
|
|
324
|
-
{
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
closeButtonLabel={ __( 'Close block inserter' ) }
|
|
330
|
+
tabs={ [
|
|
331
|
+
{
|
|
332
|
+
name: 'blocks',
|
|
333
|
+
title: __( 'Blocks' ),
|
|
334
|
+
panel: (
|
|
335
|
+
<>
|
|
336
|
+
{ inserterSearch }
|
|
337
|
+
{ selectedTab === 'blocks' &&
|
|
338
|
+
! delayedFilterValue &&
|
|
339
|
+
blocksTab }
|
|
340
|
+
</>
|
|
341
|
+
),
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'patterns',
|
|
345
|
+
title: __( 'Patterns' ),
|
|
346
|
+
panel: (
|
|
347
|
+
<>
|
|
348
|
+
{ inserterSearch }
|
|
349
|
+
{ selectedTab === 'patterns' &&
|
|
350
|
+
! delayedFilterValue &&
|
|
351
|
+
patternsTab }
|
|
352
|
+
</>
|
|
353
|
+
),
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: 'media',
|
|
357
|
+
title: __( 'Media' ),
|
|
358
|
+
panel: (
|
|
359
|
+
<>
|
|
360
|
+
{ inserterSearch }
|
|
361
|
+
{ mediaTab }
|
|
362
|
+
</>
|
|
363
|
+
),
|
|
364
|
+
},
|
|
365
|
+
] }
|
|
366
|
+
/>
|
|
333
367
|
</div>
|
|
334
368
|
{ showInserterHelpPanel && hoveredItem && (
|
|
335
369
|
<Popover
|
|
@@ -85,7 +85,12 @@ export default function QuickInserter( {
|
|
|
85
85
|
// When clicking Browse All select the appropriate block so as
|
|
86
86
|
// the insertion point can work as expected.
|
|
87
87
|
const onBrowseAll = () => {
|
|
88
|
-
setInserterIsOpened( {
|
|
88
|
+
setInserterIsOpened( {
|
|
89
|
+
rootClientId,
|
|
90
|
+
insertionIndex,
|
|
91
|
+
filterValue,
|
|
92
|
+
onSelect,
|
|
93
|
+
} );
|
|
89
94
|
};
|
|
90
95
|
|
|
91
96
|
let maxBlockPatterns = 0;
|
|
@@ -17,19 +17,13 @@ $block-inserter-tabs-height: 44px;
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.block-editor-inserter__main-area {
|
|
20
|
-
position: relative;
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
20
|
height: 100%;
|
|
24
21
|
gap: $grid-unit-20;
|
|
22
|
+
position: relative;
|
|
25
23
|
|
|
26
24
|
&.show-as-tabs {
|
|
27
25
|
gap: 0;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
@include break-medium {
|
|
31
|
-
width: $block-inserter-width;
|
|
32
|
-
}
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
.block-editor-inserter__popover.is-quick {
|
|
@@ -109,48 +103,6 @@ $block-inserter-tabs-height: 44px;
|
|
|
109
103
|
padding: $grid-unit-20 $grid-unit-20 0 $grid-unit-20;
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
.block-editor-inserter__tabs {
|
|
113
|
-
flex-grow: 1;
|
|
114
|
-
display: flex;
|
|
115
|
-
flex-direction: column;
|
|
116
|
-
overflow: hidden;
|
|
117
|
-
|
|
118
|
-
.block-editor-inserter__tablist-and-close-button {
|
|
119
|
-
border-bottom: $border-width solid $gray-300;
|
|
120
|
-
padding-right: $grid-unit-15;
|
|
121
|
-
display: flex;
|
|
122
|
-
justify-content: space-between;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.block-editor-inserter__close-button {
|
|
126
|
-
/* stylelint-disable-next-line property-disallowed-list -- This should be refactored to avoid order if possible */
|
|
127
|
-
order: 1;
|
|
128
|
-
align-self: center;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.block-editor-inserter__tablist {
|
|
132
|
-
width: 100%;
|
|
133
|
-
margin-bottom: -$border-width;
|
|
134
|
-
|
|
135
|
-
button[role="tab"] {
|
|
136
|
-
flex-grow: 1;
|
|
137
|
-
&[id$="reusable"] {
|
|
138
|
-
flex-grow: inherit;
|
|
139
|
-
// These are to align the `reusable` icon with the search icon.
|
|
140
|
-
padding-left: $grid-unit-20;
|
|
141
|
-
padding-right: $grid-unit-20;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.block-editor-inserter__tabpanel {
|
|
147
|
-
display: flex;
|
|
148
|
-
flex-grow: 1;
|
|
149
|
-
flex-direction: column;
|
|
150
|
-
overflow-y: auto;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
106
|
.block-editor-inserter__no-tab-container {
|
|
155
107
|
overflow-y: auto;
|
|
156
108
|
flex-grow: 1;
|
|
@@ -10,7 +10,7 @@ import { useCallback } from '@wordpress/element';
|
|
|
10
10
|
*/
|
|
11
11
|
import { store as blockEditorStore } from '../../store';
|
|
12
12
|
import { cleanEmptyObject } from '../../hooks/utils';
|
|
13
|
-
import {
|
|
13
|
+
import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
|
|
14
14
|
|
|
15
15
|
export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
16
16
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
@@ -20,7 +20,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
20
20
|
getSelectedBlockClientId,
|
|
21
21
|
hasMultiSelection,
|
|
22
22
|
} = useSelect( blockEditorStore );
|
|
23
|
-
|
|
23
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
24
24
|
const panelId = getSelectedBlockClientId();
|
|
25
25
|
const resetAll = useCallback(
|
|
26
26
|
( resetFilters = [] ) => {
|
|
@@ -72,7 +72,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
72
72
|
shouldRenderPlaceholderItems // Required to maintain fills ordering.
|
|
73
73
|
__experimentalFirstVisibleItemClass="first"
|
|
74
74
|
__experimentalLastVisibleItemClass="last"
|
|
75
|
-
dropdownMenuProps={
|
|
75
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
76
76
|
>
|
|
77
77
|
{ children }
|
|
78
78
|
</ToolsPanel>
|
|
@@ -60,28 +60,37 @@ const InsertFromURLPopover = ( {
|
|
|
60
60
|
</URLPopover>
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
const URLSelectionUI = ( {
|
|
64
|
-
isURLInputVisible,
|
|
65
|
-
src,
|
|
66
|
-
onChangeSrc,
|
|
67
|
-
onSubmitSrc,
|
|
68
|
-
openURLInput,
|
|
69
|
-
closeURLInput,
|
|
70
|
-
} ) => {
|
|
63
|
+
const URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {
|
|
71
64
|
// Use internal state instead of a ref to make sure that the component
|
|
72
65
|
// re-renders when the popover's anchor updates.
|
|
73
66
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
67
|
+
const [ isURLInputVisible, setIsURLInputVisible ] = useState( false );
|
|
68
|
+
|
|
69
|
+
const openURLInput = () => {
|
|
70
|
+
setIsURLInputVisible( true );
|
|
71
|
+
};
|
|
72
|
+
const closeURLInput = () => {
|
|
73
|
+
setIsURLInputVisible( false );
|
|
74
|
+
popoverAnchor?.focus();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const onSubmitSrc = ( event ) => {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
if ( src && onSelectURL ) {
|
|
80
|
+
onSelectURL( src );
|
|
81
|
+
closeURLInput();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
74
84
|
|
|
75
85
|
return (
|
|
76
|
-
<div
|
|
77
|
-
className="block-editor-media-placeholder__url-input-container"
|
|
78
|
-
ref={ setPopoverAnchor }
|
|
79
|
-
>
|
|
86
|
+
<div className="block-editor-media-placeholder__url-input-container">
|
|
80
87
|
<Button
|
|
81
88
|
className="block-editor-media-placeholder__button"
|
|
82
89
|
onClick={ openURLInput }
|
|
83
90
|
isPressed={ isURLInputVisible }
|
|
84
91
|
variant="secondary"
|
|
92
|
+
aria-haspopup="dialog"
|
|
93
|
+
ref={ setPopoverAnchor }
|
|
85
94
|
>
|
|
86
95
|
{ __( 'Insert from URL' ) }
|
|
87
96
|
</Button>
|
|
@@ -138,7 +147,6 @@ export function MediaPlaceholder( {
|
|
|
138
147
|
return getSettings().mediaUpload;
|
|
139
148
|
}, [] );
|
|
140
149
|
const [ src, setSrc ] = useState( '' );
|
|
141
|
-
const [ isURLInputVisible, setIsURLInputVisible ] = useState( false );
|
|
142
150
|
|
|
143
151
|
useEffect( () => {
|
|
144
152
|
setSrc( value?.src ?? '' );
|
|
@@ -159,21 +167,6 @@ export function MediaPlaceholder( {
|
|
|
159
167
|
setSrc( event.target.value );
|
|
160
168
|
};
|
|
161
169
|
|
|
162
|
-
const openURLInput = () => {
|
|
163
|
-
setIsURLInputVisible( true );
|
|
164
|
-
};
|
|
165
|
-
const closeURLInput = () => {
|
|
166
|
-
setIsURLInputVisible( false );
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const onSubmitSrc = ( event ) => {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
if ( src && onSelectURL ) {
|
|
172
|
-
onSelectURL( src );
|
|
173
|
-
closeURLInput();
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
170
|
const onFilesUpload = ( files ) => {
|
|
178
171
|
if ( ! handleUpload ) {
|
|
179
172
|
return onSelect( files );
|
|
@@ -404,12 +397,9 @@ export function MediaPlaceholder( {
|
|
|
404
397
|
return (
|
|
405
398
|
onSelectURL && (
|
|
406
399
|
<URLSelectionUI
|
|
407
|
-
isURLInputVisible={ isURLInputVisible }
|
|
408
400
|
src={ src }
|
|
409
401
|
onChangeSrc={ onChangeSrc }
|
|
410
|
-
|
|
411
|
-
openURLInput={ openURLInput }
|
|
412
|
-
closeURLInput={ closeURLInput }
|
|
402
|
+
onSelectURL={ onSelectURL }
|
|
413
403
|
/>
|
|
414
404
|
)
|
|
415
405
|
);
|
|
@@ -210,6 +210,7 @@ export default function NavigableToolbar( {
|
|
|
210
210
|
shouldUseKeyboardFocusShortcut = true,
|
|
211
211
|
__experimentalInitialIndex: initialIndex,
|
|
212
212
|
__experimentalOnIndexChange: onIndexChange,
|
|
213
|
+
orientation = 'horizontal',
|
|
213
214
|
...props
|
|
214
215
|
} ) {
|
|
215
216
|
const toolbarRef = useRef();
|
|
@@ -230,6 +231,7 @@ export default function NavigableToolbar( {
|
|
|
230
231
|
<Toolbar
|
|
231
232
|
label={ props[ 'aria-label' ] }
|
|
232
233
|
ref={ toolbarRef }
|
|
234
|
+
orientation={ orientation }
|
|
233
235
|
{ ...props }
|
|
234
236
|
>
|
|
235
237
|
{ children }
|
|
@@ -239,7 +241,7 @@ export default function NavigableToolbar( {
|
|
|
239
241
|
|
|
240
242
|
return (
|
|
241
243
|
<NavigableMenu
|
|
242
|
-
orientation=
|
|
244
|
+
orientation={ orientation }
|
|
243
245
|
role="toolbar"
|
|
244
246
|
ref={ toolbarRef }
|
|
245
247
|
{ ...props }
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
Button,
|
|
6
|
-
CustomSelectControl,
|
|
7
6
|
Icon,
|
|
8
7
|
RangeControl,
|
|
9
8
|
__experimentalHStack as HStack,
|
|
10
9
|
__experimentalUnitControl as UnitControl,
|
|
11
10
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
12
11
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
12
|
+
privateApis as componentsPrivateApis,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { useSelect } from '@wordpress/data';
|
|
15
15
|
import { useState, useMemo } from '@wordpress/element';
|
|
@@ -31,6 +31,11 @@ import {
|
|
|
31
31
|
getPresetValueFromCustomValue,
|
|
32
32
|
isValueSpacingPreset,
|
|
33
33
|
} from '../utils';
|
|
34
|
+
import { unlock } from '../../../lock-unlock';
|
|
35
|
+
|
|
36
|
+
const { CustomSelectControlV2Legacy: CustomSelectControl } = unlock(
|
|
37
|
+
componentsPrivateApis
|
|
38
|
+
);
|
|
34
39
|
|
|
35
40
|
const CUSTOM_VALUE_SETTINGS = {
|
|
36
41
|
px: { max: 300, steps: 1 },
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Tabbed Panel
|
|
2
|
+
|
|
3
|
+
The `TabbedPanel` component is used to create the secondary panels in the editor.
|
|
4
|
+
|
|
5
|
+
## Development guidelines
|
|
6
|
+
|
|
7
|
+
This acts as a wrapper for the `Tabs` component, but adding conventions that can be shared between all secondary panels, for example:
|
|
8
|
+
|
|
9
|
+
- A close button
|
|
10
|
+
- Tabs that fill the panel
|
|
11
|
+
- Custom scollbars
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
Renders a block alignment toolbar with alignments options.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { TabbedSidebar } from '@wordpress/components';
|
|
19
|
+
|
|
20
|
+
const MyTabbedSidebar = () => (
|
|
21
|
+
<TabbedSidebar
|
|
22
|
+
tabs={ [
|
|
23
|
+
{
|
|
24
|
+
name: 'slug-1',
|
|
25
|
+
title: _x( 'Title 1', 'context' ),
|
|
26
|
+
panel: <PanelContents>,
|
|
27
|
+
panelRef: useRef('an-optional-ref'),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'slug-2',
|
|
31
|
+
title: _x( 'Title 2', 'context' ),
|
|
32
|
+
panel: <PanelContents />,
|
|
33
|
+
},
|
|
34
|
+
] }
|
|
35
|
+
onClose={ onClickCloseButton }
|
|
36
|
+
onSelect={ onSelectTab }
|
|
37
|
+
defaultTabId="slug-1"
|
|
38
|
+
ref={ tabsRef }
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Props
|
|
44
|
+
|
|
45
|
+
### `defaultTabId`
|
|
46
|
+
|
|
47
|
+
- **Type:** `String`
|
|
48
|
+
- **Default:** `undefined`
|
|
49
|
+
|
|
50
|
+
This is passed to the `Tabs` component so it can handle the tab to select by default when it component renders.
|
|
51
|
+
|
|
52
|
+
### `onClose`
|
|
53
|
+
|
|
54
|
+
- **Type:** `Function`
|
|
55
|
+
|
|
56
|
+
The function that is called when the close button is clicked.
|
|
57
|
+
|
|
58
|
+
### `onSelect`
|
|
59
|
+
|
|
60
|
+
- **Type:** `Function`
|
|
61
|
+
|
|
62
|
+
This is passed to the `Tabs` component - it will be called when a tab has been selected. It is passed the selected tab's ID as an argument.
|
|
63
|
+
|
|
64
|
+
### `selectedTab`
|
|
65
|
+
|
|
66
|
+
- **Type:** `String`
|
|
67
|
+
- **Default:** `undefined`
|
|
68
|
+
|
|
69
|
+
This is passed to the `Tabs` component - it will display this tab as selected.
|
|
70
|
+
|
|
71
|
+
### `tabs`
|
|
72
|
+
|
|
73
|
+
- **Type:** `Array`
|
|
74
|
+
- **Default:** `undefined`
|
|
75
|
+
|
|
76
|
+
An array of tabs which will be rendered as `TabList` and `TabPanel` components.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
privateApis as componentsPrivateApis,
|
|
7
|
+
} from '@wordpress/components';
|
|
8
|
+
import { forwardRef } from '@wordpress/element';
|
|
9
|
+
import { closeSmall } from '@wordpress/icons';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { unlock } from '../../lock-unlock';
|
|
15
|
+
|
|
16
|
+
const { Tabs } = unlock( componentsPrivateApis );
|
|
17
|
+
|
|
18
|
+
function TabbedSidebar(
|
|
19
|
+
{ defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel },
|
|
20
|
+
ref
|
|
21
|
+
) {
|
|
22
|
+
return (
|
|
23
|
+
<div className="block-editor-tabbed-sidebar">
|
|
24
|
+
<Tabs
|
|
25
|
+
selectOnMove={ false }
|
|
26
|
+
defaultTabId={ defaultTabId }
|
|
27
|
+
onSelect={ onSelect }
|
|
28
|
+
selectedTabId={ selectedTab }
|
|
29
|
+
>
|
|
30
|
+
<div className="block-editor-tabbed-sidebar__tablist-and-close-button">
|
|
31
|
+
<Button
|
|
32
|
+
className="block-editor-tabbed-sidebar__close-button"
|
|
33
|
+
icon={ closeSmall }
|
|
34
|
+
label={ closeButtonLabel }
|
|
35
|
+
onClick={ () => onClose() }
|
|
36
|
+
size="small"
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
<Tabs.TabList
|
|
40
|
+
className="block-editor-tabbed-sidebar__tablist"
|
|
41
|
+
ref={ ref }
|
|
42
|
+
>
|
|
43
|
+
{ tabs.map( ( tab ) => (
|
|
44
|
+
<Tabs.Tab
|
|
45
|
+
key={ tab.name }
|
|
46
|
+
tabId={ tab.name }
|
|
47
|
+
className="block-editor-tabbed-sidebar__tab"
|
|
48
|
+
>
|
|
49
|
+
{ tab.title }
|
|
50
|
+
</Tabs.Tab>
|
|
51
|
+
) ) }
|
|
52
|
+
</Tabs.TabList>
|
|
53
|
+
</div>
|
|
54
|
+
{ tabs.map( ( tab ) => (
|
|
55
|
+
<Tabs.TabPanel
|
|
56
|
+
key={ tab.name }
|
|
57
|
+
tabId={ tab.name }
|
|
58
|
+
focusable={ false }
|
|
59
|
+
className="block-editor-tabbed-sidebar__tabpanel"
|
|
60
|
+
ref={ tab.panelRef }
|
|
61
|
+
>
|
|
62
|
+
{ tab.panel }
|
|
63
|
+
</Tabs.TabPanel>
|
|
64
|
+
) ) }
|
|
65
|
+
</Tabs>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default forwardRef( TabbedSidebar );
|