@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.block-editor-tabbed-sidebar {
|
|
2
|
+
height: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
flex-grow: 1;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
|
|
8
|
+
@include break-medium() {
|
|
9
|
+
width: 350px;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.block-editor-tabbed-sidebar__tablist-and-close-button {
|
|
14
|
+
border-bottom: $border-width solid $gray-300;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
padding-right: $grid-unit-15;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
.block-editor-tabbed-sidebar__close-button {
|
|
22
|
+
background: $white;
|
|
23
|
+
/* stylelint-disable-next-line property-disallowed-list -- This should be removed when https://github.com/WordPress/gutenberg/issues/59013 is fixed. */
|
|
24
|
+
order: 1;
|
|
25
|
+
align-self: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.block-editor-tabbed-sidebar__tablist {
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
margin-bottom: -$border-width;
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.block-editor-tabbed-sidebar__tab {
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
margin-bottom: -$border-width;
|
|
38
|
+
|
|
39
|
+
&[id$="reusable"] {
|
|
40
|
+
flex-grow: inherit;
|
|
41
|
+
// These are to align the `reusable` icon with the search icon.
|
|
42
|
+
padding-left: $grid-unit-20;
|
|
43
|
+
padding-right: $grid-unit-20;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.block-editor-tabbed-sidebar__tabpanel {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
overflow-y: auto;
|
|
52
|
+
scrollbar-gutter: auto;
|
|
53
|
+
}
|
package/src/hooks/background.js
CHANGED
|
@@ -16,6 +16,10 @@ import {
|
|
|
16
16
|
useHasBackgroundPanel,
|
|
17
17
|
hasBackgroundImageValue,
|
|
18
18
|
} from '../components/global-styles/background-panel';
|
|
19
|
+
import {
|
|
20
|
+
globalStylesDataKey,
|
|
21
|
+
globalStylesLinksDataKey,
|
|
22
|
+
} from '../store/private-keys';
|
|
19
23
|
|
|
20
24
|
export const BACKGROUND_SUPPORT_KEY = 'background';
|
|
21
25
|
|
|
@@ -134,10 +138,25 @@ export function BackgroundImagePanel( {
|
|
|
134
138
|
setAttributes,
|
|
135
139
|
settings,
|
|
136
140
|
} ) {
|
|
137
|
-
const style = useSelect(
|
|
138
|
-
( select ) =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
const { style, inheritedValue, _links } = useSelect(
|
|
142
|
+
( select ) => {
|
|
143
|
+
const { getBlockAttributes, getSettings } =
|
|
144
|
+
select( blockEditorStore );
|
|
145
|
+
const _settings = getSettings();
|
|
146
|
+
return {
|
|
147
|
+
style: getBlockAttributes( clientId )?.style,
|
|
148
|
+
_links: _settings[ globalStylesLinksDataKey ],
|
|
149
|
+
/*
|
|
150
|
+
* @TODO 1. Pass inherited value down to all block style controls,
|
|
151
|
+
* See: packages/block-editor/src/hooks/style.js
|
|
152
|
+
* @TODO 2. Add support for block style variations,
|
|
153
|
+
* See implementation: packages/block-editor/src/hooks/block-style-variation.js
|
|
154
|
+
*/
|
|
155
|
+
inheritedValue:
|
|
156
|
+
_settings[ globalStylesDataKey ]?.blocks?.[ name ],
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
[ clientId, name ]
|
|
141
160
|
);
|
|
142
161
|
|
|
143
162
|
if (
|
|
@@ -147,11 +166,6 @@ export function BackgroundImagePanel( {
|
|
|
147
166
|
return null;
|
|
148
167
|
}
|
|
149
168
|
|
|
150
|
-
const defaultControls = getBlockSupport( name, [
|
|
151
|
-
BACKGROUND_SUPPORT_KEY,
|
|
152
|
-
'__experimentalDefaultControls',
|
|
153
|
-
] );
|
|
154
|
-
|
|
155
169
|
const onChange = ( newStyle ) => {
|
|
156
170
|
setAttributes( {
|
|
157
171
|
style: cleanEmptyObject( newStyle ),
|
|
@@ -170,13 +184,14 @@ export function BackgroundImagePanel( {
|
|
|
170
184
|
|
|
171
185
|
return (
|
|
172
186
|
<StylesBackgroundPanel
|
|
187
|
+
inheritedValue={ inheritedValue }
|
|
173
188
|
as={ BackgroundInspectorControl }
|
|
174
189
|
panelId={ clientId }
|
|
175
|
-
defaultControls={ defaultControls }
|
|
176
190
|
defaultValues={ BACKGROUND_DEFAULT_VALUES }
|
|
177
191
|
settings={ updatedSettings }
|
|
178
192
|
onChange={ onChange }
|
|
179
193
|
value={ style }
|
|
194
|
+
themeFileURIs={ _links?.[ 'wp:theme-file' ] }
|
|
180
195
|
/>
|
|
181
196
|
);
|
|
182
197
|
}
|
package/src/hooks/block-hooks.js
CHANGED
|
@@ -43,25 +43,12 @@ function BlockHooksControlPure( {
|
|
|
43
43
|
[ blockTypes, name, ignoredHookedBlocks ]
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
const { blockIndex, rootClientId, innerBlocksLength } = useSelect(
|
|
47
|
-
( select ) => {
|
|
48
|
-
const { getBlocks, getBlockIndex, getBlockRootClientId } =
|
|
49
|
-
select( blockEditorStore );
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
blockIndex: getBlockIndex( clientId ),
|
|
53
|
-
innerBlocksLength: getBlocks( clientId )?.length,
|
|
54
|
-
rootClientId: getBlockRootClientId( clientId ),
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
[ clientId ]
|
|
58
|
-
);
|
|
59
|
-
|
|
60
46
|
const hookedBlockClientIds = useSelect(
|
|
61
47
|
( select ) => {
|
|
62
|
-
const { getBlocks, getGlobalBlockCount } =
|
|
48
|
+
const { getBlocks, getBlockRootClientId, getGlobalBlockCount } =
|
|
63
49
|
select( blockEditorStore );
|
|
64
50
|
|
|
51
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
65
52
|
const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(
|
|
66
53
|
( clientIds, block ) => {
|
|
67
54
|
// If the block doesn't exist anywhere in the block tree,
|
|
@@ -127,9 +114,11 @@ function BlockHooksControlPure( {
|
|
|
127
114
|
|
|
128
115
|
return EMPTY_OBJECT;
|
|
129
116
|
},
|
|
130
|
-
[ hookedBlocksForCurrentBlock, name, clientId
|
|
117
|
+
[ hookedBlocksForCurrentBlock, name, clientId ]
|
|
131
118
|
);
|
|
132
119
|
|
|
120
|
+
const { getBlockIndex, getBlockCount, getBlockRootClientId } =
|
|
121
|
+
useSelect( blockEditorStore );
|
|
133
122
|
const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
|
|
134
123
|
|
|
135
124
|
if ( ! hookedBlocksForCurrentBlock.length ) {
|
|
@@ -150,6 +139,10 @@ function BlockHooksControlPure( {
|
|
|
150
139
|
);
|
|
151
140
|
|
|
152
141
|
const insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {
|
|
142
|
+
const blockIndex = getBlockIndex( clientId );
|
|
143
|
+
const innerBlocksLength = getBlockCount( clientId );
|
|
144
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
145
|
+
|
|
153
146
|
switch ( relativePosition ) {
|
|
154
147
|
case 'before':
|
|
155
148
|
case 'after':
|
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
getBlockSelectors,
|
|
15
15
|
} from '../components/global-styles';
|
|
16
16
|
import { useStyleOverride } from './utils';
|
|
17
|
+
import { getValueFromObjectPath } from '../utils/object';
|
|
17
18
|
import { store as blockEditorStore } from '../store';
|
|
18
19
|
import { globalStylesDataKey } from '../store/private-keys';
|
|
20
|
+
import { unlock } from '../lock-unlock';
|
|
19
21
|
|
|
20
22
|
const VARIATION_PREFIX = 'is-style-';
|
|
21
23
|
|
|
@@ -59,6 +61,197 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
|
|
|
59
61
|
return null;
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
// A helper component to apply a style override using the useStyleOverride hook.
|
|
65
|
+
function OverrideStyles( { override } ) {
|
|
66
|
+
useStyleOverride( override );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This component is used to generate new block style variation overrides
|
|
71
|
+
* based on an incoming theme config. If a matching style is found in the config,
|
|
72
|
+
* a new override is created and returned. The overrides can be used in conjunction with
|
|
73
|
+
* useStyleOverride to apply the new styles to the editor. Its use is
|
|
74
|
+
* subject to change.
|
|
75
|
+
*
|
|
76
|
+
* @param {Object} props Props.
|
|
77
|
+
* @param {Object} props.config A global styles object, containing settings and styles.
|
|
78
|
+
* @return {JSX.Element|undefined} An array of new block variation overrides.
|
|
79
|
+
*/
|
|
80
|
+
export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
|
|
81
|
+
const { getBlockStyles, overrides } = useSelect(
|
|
82
|
+
( select ) => ( {
|
|
83
|
+
getBlockStyles: select( blocksStore ).getBlockStyles,
|
|
84
|
+
overrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),
|
|
85
|
+
} ),
|
|
86
|
+
[]
|
|
87
|
+
);
|
|
88
|
+
const { getBlockName } = useSelect( blockEditorStore );
|
|
89
|
+
|
|
90
|
+
const overridesWithConfig = useMemo( () => {
|
|
91
|
+
if ( ! overrides?.length ) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const newOverrides = [];
|
|
95
|
+
const overriddenClientIds = [];
|
|
96
|
+
for ( const [ , override ] of overrides ) {
|
|
97
|
+
if (
|
|
98
|
+
override?.variation &&
|
|
99
|
+
override?.clientId &&
|
|
100
|
+
/*
|
|
101
|
+
* Because this component overwrites existing style overrides,
|
|
102
|
+
* filter out any overrides that are already present in the store.
|
|
103
|
+
*/
|
|
104
|
+
! overriddenClientIds.includes( override.clientId )
|
|
105
|
+
) {
|
|
106
|
+
const blockName = getBlockName( override.clientId );
|
|
107
|
+
const configStyles =
|
|
108
|
+
config?.styles?.blocks?.[ blockName ]?.variations?.[
|
|
109
|
+
override.variation
|
|
110
|
+
];
|
|
111
|
+
if ( configStyles ) {
|
|
112
|
+
const variationConfig = {
|
|
113
|
+
settings: config?.settings,
|
|
114
|
+
// The variation style data is all that is needed to generate
|
|
115
|
+
// the styles for the current application to a block. The variation
|
|
116
|
+
// name is updated to match the instance specific class name.
|
|
117
|
+
styles: {
|
|
118
|
+
blocks: {
|
|
119
|
+
[ blockName ]: {
|
|
120
|
+
variations: {
|
|
121
|
+
[ `${ override.variation }-${ override.clientId }` ]:
|
|
122
|
+
configStyles,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
const blockSelectors = getBlockSelectors(
|
|
129
|
+
getBlockTypes(),
|
|
130
|
+
getBlockStyles,
|
|
131
|
+
override.clientId
|
|
132
|
+
);
|
|
133
|
+
const hasBlockGapSupport = false;
|
|
134
|
+
const hasFallbackGapSupport = true;
|
|
135
|
+
const disableLayoutStyles = true;
|
|
136
|
+
const disableRootPadding = true;
|
|
137
|
+
const variationStyles = toStyles(
|
|
138
|
+
variationConfig,
|
|
139
|
+
blockSelectors,
|
|
140
|
+
hasBlockGapSupport,
|
|
141
|
+
hasFallbackGapSupport,
|
|
142
|
+
disableLayoutStyles,
|
|
143
|
+
disableRootPadding,
|
|
144
|
+
{
|
|
145
|
+
blockGap: false,
|
|
146
|
+
blockStyles: true,
|
|
147
|
+
layoutStyles: false,
|
|
148
|
+
marginReset: false,
|
|
149
|
+
presets: false,
|
|
150
|
+
rootPadding: false,
|
|
151
|
+
variationStyles: true,
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
newOverrides.push( {
|
|
155
|
+
id: `${ override.variation }-${ override.clientId }`,
|
|
156
|
+
css: variationStyles,
|
|
157
|
+
__unstableType: 'variation',
|
|
158
|
+
variation: override.variation,
|
|
159
|
+
// The clientId will be stored with the override and used to ensure
|
|
160
|
+
// the order of overrides matches the order of blocks so that the
|
|
161
|
+
// correct CSS cascade is maintained.
|
|
162
|
+
clientId: override.clientId,
|
|
163
|
+
} );
|
|
164
|
+
overriddenClientIds.push( override.clientId );
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return newOverrides;
|
|
169
|
+
}, [ config, overrides, getBlockStyles, getBlockName ] );
|
|
170
|
+
|
|
171
|
+
if ( ! overridesWithConfig || ! overridesWithConfig.length ) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
{ overridesWithConfig.map( ( override ) => (
|
|
178
|
+
<OverrideStyles key={ override.id } override={ override } />
|
|
179
|
+
) ) }
|
|
180
|
+
</>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves any variation styles data and resolves any referenced values.
|
|
186
|
+
*
|
|
187
|
+
* @param {Object} globalStyles A complete global styles object, containing settings and styles.
|
|
188
|
+
* @param {string} name The name of the desired block type.
|
|
189
|
+
* @param {variation} variation The of the block style variation to retrieve data for.
|
|
190
|
+
*
|
|
191
|
+
* @return {Object|undefined} The global styles data for the specified variation.
|
|
192
|
+
*/
|
|
193
|
+
export function getVariationStylesWithRefValues(
|
|
194
|
+
globalStyles,
|
|
195
|
+
name,
|
|
196
|
+
variation
|
|
197
|
+
) {
|
|
198
|
+
if ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Helper to recursively look for `ref` values to resolve.
|
|
203
|
+
const replaceRefs = ( variationStyles ) => {
|
|
204
|
+
Object.keys( variationStyles ).forEach( ( key ) => {
|
|
205
|
+
const value = variationStyles[ key ];
|
|
206
|
+
|
|
207
|
+
// Only process objects.
|
|
208
|
+
if ( typeof value === 'object' && value !== null ) {
|
|
209
|
+
// Process `ref` value if present.
|
|
210
|
+
if ( value.ref !== undefined ) {
|
|
211
|
+
if (
|
|
212
|
+
typeof value.ref !== 'string' ||
|
|
213
|
+
value.ref.trim() === ''
|
|
214
|
+
) {
|
|
215
|
+
// Remove invalid ref.
|
|
216
|
+
delete variationStyles[ key ];
|
|
217
|
+
} else {
|
|
218
|
+
// Resolve `ref` value.
|
|
219
|
+
const refValue = getValueFromObjectPath(
|
|
220
|
+
globalStyles,
|
|
221
|
+
value.ref
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
if ( refValue ) {
|
|
225
|
+
variationStyles[ key ] = refValue;
|
|
226
|
+
} else {
|
|
227
|
+
delete variationStyles[ key ];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// Recursively resolve `ref` values in nested objects.
|
|
232
|
+
replaceRefs( value );
|
|
233
|
+
|
|
234
|
+
// After recursion, if value is empty due to explicitly
|
|
235
|
+
// `undefined` ref value, remove it.
|
|
236
|
+
if ( Object.keys( value ).length === 0 ) {
|
|
237
|
+
delete variationStyles[ key ];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
} );
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// Deep clone variation node to avoid mutating it within global styles and losing refs.
|
|
245
|
+
const styles = JSON.parse(
|
|
246
|
+
JSON.stringify(
|
|
247
|
+
globalStyles.styles.blocks[ name ].variations[ variation ]
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
replaceRefs( styles );
|
|
251
|
+
|
|
252
|
+
return styles;
|
|
253
|
+
}
|
|
254
|
+
|
|
62
255
|
function useBlockStyleVariation( name, variation, clientId ) {
|
|
63
256
|
// Prefer global styles data in GlobalStylesContext, which are available
|
|
64
257
|
// if in the site editor. Otherwise fall back to whatever is in the
|
|
@@ -73,9 +266,14 @@ function useBlockStyleVariation( name, variation, clientId ) {
|
|
|
73
266
|
}, [] );
|
|
74
267
|
|
|
75
268
|
return useMemo( () => {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
269
|
+
const variationStyles = getVariationStylesWithRefValues(
|
|
270
|
+
{
|
|
271
|
+
settings: mergedConfig?.settings ?? globalSettings,
|
|
272
|
+
styles: mergedConfig?.styles ?? globalStyles,
|
|
273
|
+
},
|
|
274
|
+
name,
|
|
275
|
+
variation
|
|
276
|
+
);
|
|
79
277
|
|
|
80
278
|
return {
|
|
81
279
|
settings: mergedConfig?.settings ?? globalSettings,
|
|
@@ -157,6 +355,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
157
355
|
id: `variation-${ clientId }`,
|
|
158
356
|
css: variationStyles,
|
|
159
357
|
__unstableType: 'variation',
|
|
358
|
+
variation,
|
|
160
359
|
// The clientId will be stored with the override and used to ensure
|
|
161
360
|
// the order of overrides matches the order of blocks so that the
|
|
162
361
|
// correct CSS cascade is maintained.
|
package/src/hooks/duotone.js
CHANGED
|
@@ -295,26 +295,30 @@ function useDuotoneStyles( {
|
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
// Safari does not always update the duotone filter when the duotone
|
|
299
|
-
// are changed. When using Safari, force the block element to be
|
|
300
|
-
// the browser to ensure any changes are reflected
|
|
301
|
-
// that used on the site frontend in
|
|
298
|
+
// Safari does not always update the duotone filter when the duotone
|
|
299
|
+
// colors are changed. When using Safari, force the block element to be
|
|
300
|
+
// repainted by the browser to ensure any changes are reflected
|
|
301
|
+
// visually. This logic matches that used on the site frontend in
|
|
302
|
+
// `block-supports/duotone.php`.
|
|
302
303
|
if ( blockElement && isSafari ) {
|
|
303
304
|
const display = blockElement.style.display;
|
|
304
|
-
// Switch to `inline-block` to force a repaint. In the editor,
|
|
305
|
-
// is used instead of `none` to ensure that scroll
|
|
306
|
-
// as `none` results in the editor
|
|
305
|
+
// Switch to `inline-block` to force a repaint. In the editor,
|
|
306
|
+
// `inline-block` is used instead of `none` to ensure that scroll
|
|
307
|
+
// position is not affected, as `none` results in the editor
|
|
308
|
+
// scrolling to the top of the block.
|
|
307
309
|
blockElement.style.display = 'inline-block';
|
|
308
|
-
// Simply accessing el.offsetHeight flushes layout and style
|
|
309
|
-
//
|
|
310
|
+
// Simply accessing el.offsetHeight flushes layout and style changes
|
|
311
|
+
// in WebKit without having to wait for setTimeout.
|
|
310
312
|
// eslint-disable-next-line no-unused-expressions
|
|
311
313
|
blockElement.offsetHeight;
|
|
312
314
|
blockElement.style.display = display;
|
|
313
315
|
}
|
|
314
|
-
|
|
316
|
+
// `colors` must be a dependency so this effect runs when the colors
|
|
317
|
+
// change in Safari.
|
|
318
|
+
}, [ isValidFilter, blockElement, colors ] );
|
|
315
319
|
}
|
|
316
320
|
|
|
317
|
-
function useBlockProps( { name, style } ) {
|
|
321
|
+
function useBlockProps( { clientId, name, style } ) {
|
|
318
322
|
const id = useInstanceId( useBlockProps );
|
|
319
323
|
const selector = useMemo( () => {
|
|
320
324
|
const blockType = getBlockType( name );
|
|
@@ -362,7 +366,7 @@ function useBlockProps( { name, style } ) {
|
|
|
362
366
|
const shouldRender = selector && attribute;
|
|
363
367
|
|
|
364
368
|
useDuotoneStyles( {
|
|
365
|
-
clientId
|
|
369
|
+
clientId,
|
|
366
370
|
id: filterClass,
|
|
367
371
|
selector,
|
|
368
372
|
attribute,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
5
|
+
import { addFilter } from '@wordpress/hooks';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { GridVisualizer, useGridLayoutSync } from '../components/grid';
|
|
12
|
+
import { store as blockEditorStore } from '../store';
|
|
13
|
+
|
|
14
|
+
function GridLayoutSync( props ) {
|
|
15
|
+
useGridLayoutSync( props );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function GridTools( { clientId, layout } ) {
|
|
19
|
+
const { isSelected, isDragging } = useSelect( ( select ) => {
|
|
20
|
+
const { isBlockSelected, isDraggingBlocks } =
|
|
21
|
+
select( blockEditorStore );
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
isSelected: isBlockSelected( clientId ),
|
|
25
|
+
isDragging: isDraggingBlocks(),
|
|
26
|
+
};
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
if ( ! isSelected && ! isDragging ) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<GridVisualizer clientId={ clientId } parentLayout={ layout } />
|
|
36
|
+
<GridLayoutSync clientId={ clientId } />
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const addGridVisualizerToBlockEdit = createHigherOrderComponent(
|
|
42
|
+
( BlockEdit ) => ( props ) => {
|
|
43
|
+
if ( props.attributes.layout?.type !== 'grid' ) {
|
|
44
|
+
return <BlockEdit { ...props } />;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<GridTools
|
|
50
|
+
clientId={ props.clientId }
|
|
51
|
+
layout={ props.attributes.layout }
|
|
52
|
+
/>
|
|
53
|
+
<BlockEdit { ...props } />
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
'addGridVisualizerToBlockEdit'
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
addFilter(
|
|
61
|
+
'editor.BlockEdit',
|
|
62
|
+
'core/editor/grid-visualizer',
|
|
63
|
+
addGridVisualizerToBlockEdit
|
|
64
|
+
);
|
package/src/hooks/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import blockHooks from './block-hooks';
|
|
|
33
33
|
import blockBindingsPanel from './block-bindings';
|
|
34
34
|
import './block-renaming';
|
|
35
35
|
import './use-bindings-attributes';
|
|
36
|
+
import './grid-visualizer';
|
|
36
37
|
|
|
37
38
|
createBlockEditFilter(
|
|
38
39
|
[
|
|
@@ -87,4 +88,6 @@ export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
|
87
88
|
export { getTypographyClassesAndStyles } from './use-typography-props';
|
|
88
89
|
export { getGapCSSValue } from './gap';
|
|
89
90
|
export { useCachedTruthy } from './use-cached-truthy';
|
|
91
|
+
export { setBackgroundStyleDefaults } from './background';
|
|
90
92
|
export { useZoomOut } from './use-zoom-out';
|
|
93
|
+
export { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';
|
|
@@ -35,6 +35,23 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
35
35
|
const id = useInstanceId( useBlockPropsChildLayoutStyles );
|
|
36
36
|
const selector = `.wp-container-content-${ id }`;
|
|
37
37
|
|
|
38
|
+
// Check that the grid layout attributes are of the correct type, so that we don't accidentally
|
|
39
|
+
// write code that stores a string attribute instead of a number.
|
|
40
|
+
if ( process.env.NODE_ENV === 'development' ) {
|
|
41
|
+
if ( columnStart && typeof columnStart !== 'number' ) {
|
|
42
|
+
throw new Error( 'columnStart must be a number' );
|
|
43
|
+
}
|
|
44
|
+
if ( rowStart && typeof rowStart !== 'number' ) {
|
|
45
|
+
throw new Error( 'rowStart must be a number' );
|
|
46
|
+
}
|
|
47
|
+
if ( columnSpan && typeof columnSpan !== 'number' ) {
|
|
48
|
+
throw new Error( 'columnSpan must be a number' );
|
|
49
|
+
}
|
|
50
|
+
if ( rowSpan && typeof rowSpan !== 'number' ) {
|
|
51
|
+
throw new Error( 'rowSpan must be a number' );
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
38
55
|
let css = '';
|
|
39
56
|
if ( shouldRenderChildLayoutStyles ) {
|
|
40
57
|
if ( selfStretch === 'fixed' && flexSize ) {
|
|
@@ -59,6 +76,19 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
59
76
|
grid-column: span ${ columnSpan };
|
|
60
77
|
}`;
|
|
61
78
|
}
|
|
79
|
+
if ( rowStart && rowSpan ) {
|
|
80
|
+
css += `${ selector } {
|
|
81
|
+
grid-row: ${ rowStart } / span ${ rowSpan };
|
|
82
|
+
}`;
|
|
83
|
+
} else if ( rowStart ) {
|
|
84
|
+
css += `${ selector } {
|
|
85
|
+
grid-row: ${ rowStart };
|
|
86
|
+
}`;
|
|
87
|
+
} else if ( rowSpan ) {
|
|
88
|
+
css += `${ selector } {
|
|
89
|
+
grid-row: span ${ rowSpan };
|
|
90
|
+
}`;
|
|
91
|
+
}
|
|
62
92
|
/**
|
|
63
93
|
* If minimumColumnWidth is set on the parent, or if no
|
|
64
94
|
* columnCount is set, the grid is responsive so a
|
|
@@ -68,16 +98,6 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
68
98
|
( columnSpan || columnStart ) &&
|
|
69
99
|
( minimumColumnWidth || ! columnCount )
|
|
70
100
|
) {
|
|
71
|
-
// Check if columnSpan and columnStart are numbers so Math.max doesn't break.
|
|
72
|
-
const columnSpanNumber = columnSpan ? parseInt( columnSpan ) : null;
|
|
73
|
-
const columnStartNumber = columnStart
|
|
74
|
-
? parseInt( columnStart )
|
|
75
|
-
: null;
|
|
76
|
-
const highestNumber = Math.max(
|
|
77
|
-
columnSpanNumber,
|
|
78
|
-
columnStartNumber
|
|
79
|
-
);
|
|
80
|
-
|
|
81
101
|
let parentColumnValue = parseFloat( minimumColumnWidth );
|
|
82
102
|
/**
|
|
83
103
|
* 12rem is the default minimumColumnWidth value.
|
|
@@ -99,32 +119,29 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
99
119
|
parentColumnUnit = 'rem';
|
|
100
120
|
}
|
|
101
121
|
|
|
122
|
+
const highestNumber = Math.max( columnSpan, columnStart );
|
|
102
123
|
const defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5;
|
|
103
124
|
const containerQueryValue =
|
|
104
125
|
highestNumber * parentColumnValue +
|
|
105
126
|
( highestNumber - 1 ) * defaultGapValue;
|
|
127
|
+
// For blocks that only span one column, we want to remove any rowStart values as
|
|
128
|
+
// the container reduces in size, so that blocks are still arranged in markup order.
|
|
129
|
+
const minimumContainerQueryValue =
|
|
130
|
+
parentColumnValue * 2 + defaultGapValue - 1;
|
|
106
131
|
// If a span is set we want to preserve it as long as possible, otherwise we just reset the value.
|
|
107
|
-
const gridColumnValue =
|
|
132
|
+
const gridColumnValue =
|
|
133
|
+
columnSpan && columnSpan > 1 ? '1/-1' : 'auto';
|
|
108
134
|
|
|
109
|
-
css += `@container (max-width: ${
|
|
135
|
+
css += `@container (max-width: ${ Math.max(
|
|
136
|
+
containerQueryValue,
|
|
137
|
+
minimumContainerQueryValue
|
|
138
|
+
) }${ parentColumnUnit }) {
|
|
110
139
|
${ selector } {
|
|
111
140
|
grid-column: ${ gridColumnValue };
|
|
141
|
+
grid-row: auto;
|
|
112
142
|
}
|
|
113
143
|
}`;
|
|
114
144
|
}
|
|
115
|
-
if ( rowStart && rowSpan ) {
|
|
116
|
-
css += `${ selector } {
|
|
117
|
-
grid-row: ${ rowStart } / span ${ rowSpan };
|
|
118
|
-
}`;
|
|
119
|
-
} else if ( rowStart ) {
|
|
120
|
-
css += `${ selector } {
|
|
121
|
-
grid-row: ${ rowStart };
|
|
122
|
-
}`;
|
|
123
|
-
} else if ( rowSpan ) {
|
|
124
|
-
css += `${ selector } {
|
|
125
|
-
grid-row: span ${ rowSpan };
|
|
126
|
-
}`;
|
|
127
|
-
}
|
|
128
145
|
}
|
|
129
146
|
|
|
130
147
|
useStyleOverride( { css } );
|
|
@@ -143,7 +160,7 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
|
|
|
143
160
|
const {
|
|
144
161
|
type: parentLayoutType = 'default',
|
|
145
162
|
allowSizingOnChildren = false,
|
|
146
|
-
|
|
163
|
+
isManualPlacement,
|
|
147
164
|
} = parentLayout;
|
|
148
165
|
|
|
149
166
|
const rootClientId = useSelect(
|
|
@@ -160,8 +177,6 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
|
|
|
160
177
|
return null;
|
|
161
178
|
}
|
|
162
179
|
|
|
163
|
-
const isManualGrid = !! columnCount;
|
|
164
|
-
|
|
165
180
|
function updateLayout( layout ) {
|
|
166
181
|
setAttributes( {
|
|
167
182
|
style: {
|
|
@@ -190,15 +205,16 @@ function ChildLayoutControlsPure( { clientId, style, setAttributes } ) {
|
|
|
190
205
|
parentLayout={ parentLayout }
|
|
191
206
|
/>
|
|
192
207
|
) }
|
|
193
|
-
{
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
{ isManualPlacement &&
|
|
209
|
+
window.__experimentalEnableGridInteractivity && (
|
|
210
|
+
<GridItemMovers
|
|
211
|
+
layout={ style?.layout }
|
|
212
|
+
parentLayout={ parentLayout }
|
|
213
|
+
onChange={ updateLayout }
|
|
214
|
+
gridClientId={ rootClientId }
|
|
215
|
+
blockClientId={ clientId }
|
|
216
|
+
/>
|
|
217
|
+
) }
|
|
202
218
|
</>
|
|
203
219
|
);
|
|
204
220
|
}
|