@wordpress/block-editor 11.6.0 → 11.8.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 +6 -0
- package/README.md +46 -55
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.native.js +4 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +11 -21
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -9
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/caption/index.native.js +0 -1
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +15 -29
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +23 -44
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +244 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +151 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/get-block-css-selector.js +118 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +60 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +46 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -35
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +173 -91
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/image-size-control/use-dimension-handler.js +5 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +16 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -2
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +5 -3
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +6 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +56 -14
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +7 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +8 -2
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +6 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +17 -14
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +38 -0
- package/build/components/resizable-box-popover/index.js.map +1 -0
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +7 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +92 -64
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/margin.js +27 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -9
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +0 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +28 -76
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +3 -2
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +7 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.native.js +4 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +11 -19
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +2 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -9
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/caption/index.native.js +0 -1
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +15 -29
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +22 -44
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +228 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +139 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/get-block-css-selector.js +109 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +58 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +5 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +8 -35
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +175 -93
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +5 -2
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +4 -3
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +6 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +50 -13
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +5 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +17 -14
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +26 -0
- package/build-module/components/resizable-box-popover/index.js.map +1 -0
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +7 -10
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +91 -65
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/margin.js +29 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -10
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +0 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +27 -74
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +3 -2
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +5 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-style/style-rtl.css +77 -16
- package/build-style/style.css +77 -16
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-inspector/style.scss +6 -4
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block.native.js +3 -2
- package/src/components/block-list/index.native.js +19 -38
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-popover/inbetween.js +2 -13
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
- package/src/components/caption/index.native.js +0 -1
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/date-format-picker/index.js +1 -1
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/README.md +129 -16
- package/src/components/global-styles/border-panel.js +13 -32
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +43 -55
- package/src/components/global-styles/effects-panel.js +228 -0
- package/src/components/global-styles/filters-panel.js +157 -0
- package/src/components/global-styles/get-block-css-selector.js +118 -0
- package/src/components/global-styles/hooks.js +90 -0
- package/src/components/global-styles/index.js +4 -1
- package/src/components/global-styles/style.scss +42 -0
- package/src/components/global-styles/test/use-global-styles-output.js +34 -5
- package/src/components/global-styles/typography-panel.js +26 -51
- package/src/components/global-styles/use-global-styles-output.js +188 -89
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/image-size-control/use-dimension-handler.js +4 -3
- package/src/components/index.js +4 -1
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inserter/block-patterns-tab.js +3 -1
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/inspector-controls-tabs/utils.js +4 -3
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/list-view/README.md +2 -0
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +6 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +60 -11
- package/src/components/list-view/style.scss +22 -1
- package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
- package/src/components/list-view/use-list-view-client-ids.js +5 -3
- package/src/components/list-view/use-list-view-drop-zone.js +9 -3
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/off-canvas-editor/block-contents.js +4 -0
- package/src/components/off-canvas-editor/index.js +15 -11
- package/src/components/resizable-box-popover/index.js +27 -0
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +2 -5
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
- package/src/components/spacing-sizes-control/style.scss +7 -7
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +1 -2
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +121 -76
- package/src/hooks/margin.js +31 -26
- package/src/hooks/padding.js +24 -18
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +0 -1
- package/src/hooks/utils.js +31 -74
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/layouts/utils.js +2 -2
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +1 -1
- package/src/style.scss +1 -0
- package/src/utils/object.js +69 -0
- package/src/utils/test/object.js +145 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/rich-text/use-native-props.js +0 -11
- package/build/components/rich-text/use-native-props.js.map +0 -1
- package/build/components/rich-text/use-native-props.native.js +0 -24
- package/build/components/rich-text/use-native-props.native.js.map +0 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.js +0 -4
- package/build-module/components/rich-text/use-native-props.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.native.js +0 -15
- package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
- package/src/components/rich-text/use-native-props.js +0 -3
- package/src/components/rich-text/use-native-props.native.js +0 -17
|
@@ -9,17 +9,19 @@ import { get, isEmpty, kebabCase, set } from 'lodash';
|
|
|
9
9
|
import {
|
|
10
10
|
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
|
|
11
11
|
__EXPERIMENTAL_ELEMENTS as ELEMENTS,
|
|
12
|
+
getBlockSupport,
|
|
12
13
|
getBlockTypes,
|
|
13
14
|
store as blocksStore,
|
|
14
15
|
} from '@wordpress/blocks';
|
|
15
16
|
import { useSelect } from '@wordpress/data';
|
|
16
|
-
import { useContext, useMemo } from '@wordpress/element';
|
|
17
|
+
import { renderToString, useContext, useMemo } from '@wordpress/element';
|
|
17
18
|
import { getCSSRules } from '@wordpress/style-engine';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
21
22
|
*/
|
|
22
23
|
import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
|
|
24
|
+
import { getBlockCSSSelector } from './get-block-css-selector';
|
|
23
25
|
import { getTypographyFontSizeValue } from './typography-utils';
|
|
24
26
|
import { GlobalStylesContext } from './context';
|
|
25
27
|
import { useGlobalSetting } from './hooks';
|
|
@@ -144,13 +146,16 @@ function getPresetsSvgFilters( blockPresets = {} ) {
|
|
|
144
146
|
return [ 'default', 'theme' ]
|
|
145
147
|
.filter( ( origin ) => presetByOrigin[ origin ] )
|
|
146
148
|
.flatMap( ( origin ) =>
|
|
147
|
-
presetByOrigin[ origin ].map( ( preset ) =>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
presetByOrigin[ origin ].map( ( preset ) =>
|
|
150
|
+
renderToString(
|
|
151
|
+
<PresetDuotoneFilter
|
|
152
|
+
preset={ preset }
|
|
153
|
+
key={ preset.slug }
|
|
154
|
+
/>
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
.join( '' );
|
|
154
159
|
} );
|
|
155
160
|
}
|
|
156
161
|
|
|
@@ -193,6 +198,89 @@ function concatFeatureVariationSelectorString(
|
|
|
193
198
|
return combinedSelectors.join( ', ' );
|
|
194
199
|
}
|
|
195
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Generate style declarations for a block's custom feature and subfeature
|
|
203
|
+
* selectors.
|
|
204
|
+
*
|
|
205
|
+
* NOTE: The passed `styles` object will be mutated by this function.
|
|
206
|
+
*
|
|
207
|
+
* @param {Object} selectors Custom selectors object for a block.
|
|
208
|
+
* @param {Object} styles A block's styles object.
|
|
209
|
+
*
|
|
210
|
+
* @return {Object} Style declarations.
|
|
211
|
+
*/
|
|
212
|
+
const getFeatureDeclarations = ( selectors, styles ) => {
|
|
213
|
+
const declarations = {};
|
|
214
|
+
|
|
215
|
+
Object.entries( selectors ).forEach( ( [ feature, selector ] ) => {
|
|
216
|
+
// We're only processing features/subfeatures that have styles.
|
|
217
|
+
if ( feature === 'root' || ! styles?.[ feature ] ) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const isShorthand = typeof selector === 'string';
|
|
222
|
+
|
|
223
|
+
// If we have a selector object instead of shorthand process it.
|
|
224
|
+
if ( ! isShorthand ) {
|
|
225
|
+
Object.entries( selector ).forEach(
|
|
226
|
+
( [ subfeature, subfeatureSelector ] ) => {
|
|
227
|
+
// Don't process root feature selector yet or any
|
|
228
|
+
// subfeature that doesn't have a style.
|
|
229
|
+
if (
|
|
230
|
+
subfeature === 'root' ||
|
|
231
|
+
! styles?.[ feature ][ subfeature ]
|
|
232
|
+
) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Create a temporary styles object and build
|
|
237
|
+
// declarations for subfeature.
|
|
238
|
+
const subfeatureStyles = {
|
|
239
|
+
[ feature ]: {
|
|
240
|
+
[ subfeature ]: styles[ feature ][ subfeature ],
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
const newDeclarations =
|
|
244
|
+
getStylesDeclarations( subfeatureStyles );
|
|
245
|
+
|
|
246
|
+
// Merge new declarations in with any others that
|
|
247
|
+
// share the same selector.
|
|
248
|
+
declarations[ subfeatureSelector ] = [
|
|
249
|
+
...( declarations[ subfeatureSelector ] || [] ),
|
|
250
|
+
...newDeclarations,
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
// Remove the subfeature's style now it will be
|
|
254
|
+
// included under its own selector not the block's.
|
|
255
|
+
delete styles[ feature ][ subfeature ];
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Now subfeatures have been processed and removed, we can
|
|
261
|
+
// process root, or shorthand, feature selectors.
|
|
262
|
+
if ( isShorthand || selector.root ) {
|
|
263
|
+
const featureSelector = isShorthand ? selector : selector.root;
|
|
264
|
+
|
|
265
|
+
// Create temporary style object and build declarations for feature.
|
|
266
|
+
const featureStyles = { [ feature ]: styles[ feature ] };
|
|
267
|
+
const newDeclarations = getStylesDeclarations( featureStyles );
|
|
268
|
+
|
|
269
|
+
// Merge new declarations with any others that share the selector.
|
|
270
|
+
declarations[ featureSelector ] = [
|
|
271
|
+
...( declarations[ featureSelector ] || [] ),
|
|
272
|
+
...newDeclarations,
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
// Remove the feature from the block's styles now as it will be
|
|
276
|
+
// included under its own selector not the block's.
|
|
277
|
+
delete styles[ feature ];
|
|
278
|
+
}
|
|
279
|
+
} );
|
|
280
|
+
|
|
281
|
+
return declarations;
|
|
282
|
+
};
|
|
283
|
+
|
|
196
284
|
/**
|
|
197
285
|
* Transform given style tree into a set of style declarations.
|
|
198
286
|
*
|
|
@@ -396,10 +484,10 @@ export function getLayoutStyles( {
|
|
|
396
484
|
} else {
|
|
397
485
|
combinedSelector =
|
|
398
486
|
selector === ROOT_BLOCK_SELECTOR
|
|
399
|
-
?
|
|
487
|
+
? `:where(${ selector } .${ className })${
|
|
400
488
|
spacingStyle?.selector || ''
|
|
401
489
|
}`
|
|
402
|
-
: `${ selector }-${ className }${
|
|
490
|
+
: `${ selector }-${ className }${
|
|
403
491
|
spacingStyle?.selector || ''
|
|
404
492
|
}`;
|
|
405
493
|
}
|
|
@@ -692,23 +780,16 @@ export const toStyles = (
|
|
|
692
780
|
// Process styles for block support features with custom feature level
|
|
693
781
|
// CSS selectors set.
|
|
694
782
|
if ( featureSelectors ) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
if ( !! featureDeclarations.length ) {
|
|
706
|
-
ruleset =
|
|
707
|
-
ruleset +
|
|
708
|
-
`${ featureSelector }{${ featureDeclarations.join(
|
|
709
|
-
';'
|
|
710
|
-
) } }`;
|
|
711
|
-
}
|
|
783
|
+
const featureDeclarations = getFeatureDeclarations(
|
|
784
|
+
featureSelectors,
|
|
785
|
+
styles
|
|
786
|
+
);
|
|
787
|
+
|
|
788
|
+
Object.entries( featureDeclarations ).forEach(
|
|
789
|
+
( [ cssSelector, declarations ] ) => {
|
|
790
|
+
if ( !! declarations.length ) {
|
|
791
|
+
const rules = declarations.join( ';' );
|
|
792
|
+
ruleset = ruleset + `${ cssSelector }{${ rules }}`;
|
|
712
793
|
}
|
|
713
794
|
}
|
|
714
795
|
);
|
|
@@ -720,43 +801,32 @@ export const toStyles = (
|
|
|
720
801
|
if ( styles?.variations?.[ styleVariationName ] ) {
|
|
721
802
|
// If the block uses any custom selectors for block support, add those first.
|
|
722
803
|
if ( featureSelectors ) {
|
|
723
|
-
|
|
724
|
-
(
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
featureStyles
|
|
804
|
+
const featureDeclarations =
|
|
805
|
+
getFeatureDeclarations(
|
|
806
|
+
featureSelectors,
|
|
807
|
+
styles?.variations?.[
|
|
808
|
+
styleVariationName
|
|
809
|
+
]
|
|
810
|
+
);
|
|
811
|
+
|
|
812
|
+
Object.entries( featureDeclarations ).forEach(
|
|
813
|
+
( [ baseSelector, declarations ] ) => {
|
|
814
|
+
if ( !! declarations.length ) {
|
|
815
|
+
const cssSelector =
|
|
816
|
+
concatFeatureVariationSelectorString(
|
|
817
|
+
baseSelector,
|
|
818
|
+
styleVariationSelector
|
|
739
819
|
);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
!! featureDeclarations.length
|
|
746
|
-
) {
|
|
747
|
-
ruleset =
|
|
748
|
-
ruleset +
|
|
749
|
-
`${ concatFeatureVariationSelectorString(
|
|
750
|
-
featureSelector,
|
|
751
|
-
styleVariationSelector
|
|
752
|
-
) }{${ featureDeclarations.join(
|
|
753
|
-
';'
|
|
754
|
-
) } }`;
|
|
755
|
-
}
|
|
820
|
+
const rules =
|
|
821
|
+
declarations.join( ';' );
|
|
822
|
+
ruleset =
|
|
823
|
+
ruleset +
|
|
824
|
+
`${ cssSelector }{${ rules }}`;
|
|
756
825
|
}
|
|
757
826
|
}
|
|
758
827
|
);
|
|
759
828
|
}
|
|
829
|
+
|
|
760
830
|
// Otherwise add regular selectors.
|
|
761
831
|
const styleVariationDeclarations =
|
|
762
832
|
getStylesDeclarations(
|
|
@@ -783,17 +853,16 @@ export const toStyles = (
|
|
|
783
853
|
delete styles.filter;
|
|
784
854
|
}
|
|
785
855
|
|
|
786
|
-
// Process duotone styles
|
|
856
|
+
// Process duotone styles.
|
|
787
857
|
if ( duotoneSelector ) {
|
|
788
858
|
const duotoneDeclarations =
|
|
789
859
|
getStylesDeclarations( duotoneStyles );
|
|
790
860
|
if ( duotoneDeclarations.length > 0 ) {
|
|
791
861
|
ruleset =
|
|
792
862
|
ruleset +
|
|
793
|
-
`${
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
) }{${ duotoneDeclarations.join( ';' ) };}`;
|
|
863
|
+
`${ duotoneSelector }{${ duotoneDeclarations.join(
|
|
864
|
+
';'
|
|
865
|
+
) };}`;
|
|
797
866
|
}
|
|
798
867
|
}
|
|
799
868
|
|
|
@@ -879,10 +948,13 @@ export const toStyles = (
|
|
|
879
948
|
getGapCSSValue( tree?.styles?.spacing?.blockGap ) || '0.5em';
|
|
880
949
|
ruleset =
|
|
881
950
|
ruleset +
|
|
882
|
-
|
|
951
|
+
`:where(.wp-site-blocks) > * { margin-block-start: ${ gapValue }; margin-block-end: 0; }`;
|
|
883
952
|
ruleset =
|
|
884
953
|
ruleset +
|
|
885
|
-
|
|
954
|
+
':where(.wp-site-blocks) > :first-child:first-child { margin-block-start: 0; }';
|
|
955
|
+
ruleset =
|
|
956
|
+
ruleset +
|
|
957
|
+
':where(.wp-site-blocks) > :last-child:last-child { margin-block-end: 0; }';
|
|
886
958
|
}
|
|
887
959
|
|
|
888
960
|
nodesWithSettings.forEach( ( { selector, presets } ) => {
|
|
@@ -907,15 +979,50 @@ export function toSvgFilters( tree, blockSelectors ) {
|
|
|
907
979
|
} );
|
|
908
980
|
}
|
|
909
981
|
|
|
982
|
+
const getSelectorsConfig = ( blockType, rootSelector ) => {
|
|
983
|
+
if ( ! isEmpty( blockType?.selectors ) ) {
|
|
984
|
+
return blockType.selectors;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
const config = { root: rootSelector };
|
|
988
|
+
Object.entries( BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS ).forEach(
|
|
989
|
+
( [ featureKey, featureName ] ) => {
|
|
990
|
+
const featureSelector = getBlockCSSSelector(
|
|
991
|
+
blockType,
|
|
992
|
+
featureKey
|
|
993
|
+
);
|
|
994
|
+
|
|
995
|
+
if ( featureSelector ) {
|
|
996
|
+
config[ featureName ] = featureSelector;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
);
|
|
1000
|
+
|
|
1001
|
+
return config;
|
|
1002
|
+
};
|
|
1003
|
+
|
|
910
1004
|
export const getBlockSelectors = ( blockTypes, getBlockStyles ) => {
|
|
911
1005
|
const result = {};
|
|
912
1006
|
blockTypes.forEach( ( blockType ) => {
|
|
913
1007
|
const name = blockType.name;
|
|
914
|
-
const selector =
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1008
|
+
const selector = getBlockCSSSelector( blockType );
|
|
1009
|
+
let duotoneSelector = getBlockCSSSelector(
|
|
1010
|
+
blockType,
|
|
1011
|
+
'filter.duotone'
|
|
1012
|
+
);
|
|
1013
|
+
|
|
1014
|
+
// Keep backwards compatibility for support.color.__experimentalDuotone.
|
|
1015
|
+
if ( ! duotoneSelector ) {
|
|
1016
|
+
const rootSelector = getBlockCSSSelector( blockType );
|
|
1017
|
+
const duotoneSupport = getBlockSupport(
|
|
1018
|
+
blockType,
|
|
1019
|
+
'color.__experimentalDuotone',
|
|
1020
|
+
false
|
|
1021
|
+
);
|
|
1022
|
+
duotoneSelector =
|
|
1023
|
+
duotoneSupport && scopeSelector( rootSelector, duotoneSupport );
|
|
1024
|
+
}
|
|
1025
|
+
|
|
919
1026
|
const hasLayoutSupport = !! blockType?.supports?.__experimentalLayout;
|
|
920
1027
|
const fallbackGapValue =
|
|
921
1028
|
blockType?.supports?.spacing?.blockGap?.__experimentalDefault;
|
|
@@ -930,20 +1037,7 @@ export const getBlockSelectors = ( blockTypes, getBlockStyles ) => {
|
|
|
930
1037
|
} );
|
|
931
1038
|
}
|
|
932
1039
|
// For each block support feature add any custom selectors.
|
|
933
|
-
const featureSelectors =
|
|
934
|
-
Object.entries( BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS ).forEach(
|
|
935
|
-
( [ featureKey, featureName ] ) => {
|
|
936
|
-
const featureSelector =
|
|
937
|
-
blockType?.supports?.[ featureKey ]?.__experimentalSelector;
|
|
938
|
-
|
|
939
|
-
if ( featureSelector ) {
|
|
940
|
-
featureSelectors[ featureName ] = scopeSelector(
|
|
941
|
-
selector,
|
|
942
|
-
featureSelector
|
|
943
|
-
);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
);
|
|
1040
|
+
const featureSelectors = getSelectorsConfig( blockType, selector );
|
|
947
1041
|
|
|
948
1042
|
result[ name ] = {
|
|
949
1043
|
duotoneSelector,
|
|
@@ -1049,9 +1143,9 @@ export function useGlobalStylesOutput() {
|
|
|
1049
1143
|
hasFallbackGapSupport,
|
|
1050
1144
|
disableLayoutStyles
|
|
1051
1145
|
);
|
|
1146
|
+
const svgs = toSvgFilters( mergedConfig, blockSelectors );
|
|
1052
1147
|
|
|
1053
|
-
const
|
|
1054
|
-
const stylesheets = [
|
|
1148
|
+
const styles = [
|
|
1055
1149
|
{
|
|
1056
1150
|
css: customProperties,
|
|
1057
1151
|
isGlobalStyles: true,
|
|
@@ -1065,6 +1159,11 @@ export function useGlobalStylesOutput() {
|
|
|
1065
1159
|
css: mergedConfig.styles.css ?? '',
|
|
1066
1160
|
isGlobalStyles: true,
|
|
1067
1161
|
},
|
|
1162
|
+
{
|
|
1163
|
+
assets: svgs,
|
|
1164
|
+
__unstableType: 'svg',
|
|
1165
|
+
isGlobalStyles: true,
|
|
1166
|
+
},
|
|
1068
1167
|
];
|
|
1069
1168
|
|
|
1070
1169
|
// Loop through the blocks to check if there are custom CSS values.
|
|
@@ -1073,7 +1172,7 @@ export function useGlobalStylesOutput() {
|
|
|
1073
1172
|
getBlockTypes().forEach( ( blockType ) => {
|
|
1074
1173
|
if ( mergedConfig.styles.blocks[ blockType.name ]?.css ) {
|
|
1075
1174
|
const selector = blockSelectors[ blockType.name ].selector;
|
|
1076
|
-
|
|
1175
|
+
styles.push( {
|
|
1077
1176
|
css: processCSSNesting(
|
|
1078
1177
|
mergedConfig.styles.blocks[ blockType.name ]?.css,
|
|
1079
1178
|
selector
|
|
@@ -1083,7 +1182,7 @@ export function useGlobalStylesOutput() {
|
|
|
1083
1182
|
}
|
|
1084
1183
|
} );
|
|
1085
1184
|
|
|
1086
|
-
return [
|
|
1185
|
+
return [ styles, mergedConfig.settings ];
|
|
1087
1186
|
}, [
|
|
1088
1187
|
hasBlockGapSupport,
|
|
1089
1188
|
hasFallbackGapSupport,
|
|
@@ -16,7 +16,9 @@ export const ROOT_BLOCK_SUPPORTS = [
|
|
|
16
16
|
'backgroundColor',
|
|
17
17
|
'color',
|
|
18
18
|
'linkColor',
|
|
19
|
+
'captionColor',
|
|
19
20
|
'buttonColor',
|
|
21
|
+
'headingColor',
|
|
20
22
|
'fontFamily',
|
|
21
23
|
'fontSize',
|
|
22
24
|
'fontStyle',
|
|
@@ -103,6 +105,7 @@ export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
|
103
105
|
'elements.link.typography.fontSize': 'font-size',
|
|
104
106
|
'elements.button.color.text': 'color',
|
|
105
107
|
'elements.button.color.background': 'color',
|
|
108
|
+
'elements.caption.color.text': 'color',
|
|
106
109
|
'elements.button.typography.fontFamily': 'font-family',
|
|
107
110
|
'elements.button.typography.fontSize': 'font-size',
|
|
108
111
|
'elements.heading.color': 'color',
|
|
@@ -38,17 +38,16 @@ export default function ImageSizeControl( {
|
|
|
38
38
|
{ imageSizeOptions && imageSizeOptions.length > 0 && (
|
|
39
39
|
<SelectControl
|
|
40
40
|
__nextHasNoMarginBottom
|
|
41
|
-
label={ __( '
|
|
41
|
+
label={ __( 'Resolution' ) }
|
|
42
42
|
value={ slug }
|
|
43
43
|
options={ imageSizeOptions }
|
|
44
44
|
onChange={ onChangeImage }
|
|
45
45
|
help={ imageSizeHelp }
|
|
46
|
+
size="__unstable-large"
|
|
46
47
|
/>
|
|
47
48
|
) }
|
|
48
49
|
{ isResizable && (
|
|
49
50
|
<div className="block-editor-image-size-control">
|
|
50
|
-
<p>{ __( 'Image dimensions' ) }</p>
|
|
51
|
-
|
|
52
51
|
<HStack align="baseline" spacing="3">
|
|
53
52
|
<NumberControl
|
|
54
53
|
className="block-editor-image-size-control__width"
|
|
@@ -58,6 +57,7 @@ export default function ImageSizeControl( {
|
|
|
58
57
|
onChange={ ( value ) =>
|
|
59
58
|
updateDimension( 'width', value )
|
|
60
59
|
}
|
|
60
|
+
size="__unstable-large"
|
|
61
61
|
/>
|
|
62
62
|
<NumberControl
|
|
63
63
|
className="block-editor-image-size-control__height"
|
|
@@ -67,6 +67,7 @@ export default function ImageSizeControl( {
|
|
|
67
67
|
onChange={ ( value ) =>
|
|
68
68
|
updateDimension( 'height', value )
|
|
69
69
|
}
|
|
70
|
+
size="__unstable-large"
|
|
70
71
|
/>
|
|
71
72
|
</HStack>
|
|
72
73
|
<HStack>
|
|
@@ -334,7 +334,7 @@ describe( 'ImageSizeControl', () => {
|
|
|
334
334
|
);
|
|
335
335
|
|
|
336
336
|
expect(
|
|
337
|
-
screen.getByRole( 'combobox', { name: '
|
|
337
|
+
screen.getByRole( 'combobox', { name: 'Resolution' } )
|
|
338
338
|
).toHaveValue( 'medium' );
|
|
339
339
|
} );
|
|
340
340
|
|
|
@@ -351,7 +351,7 @@ describe( 'ImageSizeControl', () => {
|
|
|
351
351
|
);
|
|
352
352
|
|
|
353
353
|
await user.selectOptions(
|
|
354
|
-
screen.getByRole( 'combobox', { name: '
|
|
354
|
+
screen.getByRole( 'combobox', { name: 'Resolution' } ),
|
|
355
355
|
'thumbnail'
|
|
356
356
|
);
|
|
357
357
|
|
|
@@ -47,13 +47,14 @@ export default function useDimensionHandler(
|
|
|
47
47
|
}, [ customWidth, customHeight ] );
|
|
48
48
|
|
|
49
49
|
const updateDimension = ( dimension, value ) => {
|
|
50
|
+
const parsedValue = value === '' ? undefined : parseInt( value, 10 );
|
|
50
51
|
if ( dimension === 'width' ) {
|
|
51
|
-
setCurrentWidth(
|
|
52
|
+
setCurrentWidth( parsedValue );
|
|
52
53
|
} else {
|
|
53
|
-
setCurrentHeight(
|
|
54
|
+
setCurrentHeight( parsedValue );
|
|
54
55
|
}
|
|
55
56
|
onChange( {
|
|
56
|
-
[ dimension ]:
|
|
57
|
+
[ dimension ]: parsedValue,
|
|
57
58
|
} );
|
|
58
59
|
};
|
|
59
60
|
|
package/src/components/index.js
CHANGED
|
@@ -92,7 +92,10 @@ export { default as URLPopover } from './url-popover';
|
|
|
92
92
|
export { __experimentalImageURLInputUI } from './url-popover/image-url-input-ui';
|
|
93
93
|
export { default as withColorContext } from './color-palette/with-color-context';
|
|
94
94
|
export { default as __experimentalSpacingSizesControl } from './spacing-sizes-control';
|
|
95
|
-
|
|
95
|
+
export {
|
|
96
|
+
getSpacingPresetCssVar,
|
|
97
|
+
isValueSpacingPreset,
|
|
98
|
+
} from './spacing-sizes-control/utils';
|
|
96
99
|
/*
|
|
97
100
|
* Content Related Components
|
|
98
101
|
*/
|
|
@@ -130,7 +130,7 @@ _Options:_
|
|
|
130
130
|
- `'insert'` — prevents inserting or removing blocks, but allows moving existing ones.
|
|
131
131
|
- `false` — prevents locking from being applied to an `InnerBlocks` area even if a parent block contains locking. ( Boolean )
|
|
132
132
|
|
|
133
|
-
If locking is not set in an `InnerBlocks` area: the locking of the parent `InnerBlocks` area is used. Note that `contentOnly` can't be
|
|
133
|
+
If locking is not set in an `InnerBlocks` area: the locking of the parent `InnerBlocks` area is used. Note that `contentOnly` can't be overridden: it's present, the `templateLock` value of any children is ignored.
|
|
134
134
|
|
|
135
135
|
If the block is a top level block: the locking of the Custom Post Type is used.
|
|
136
136
|
|
|
@@ -28,6 +28,8 @@ import BlockPatternList from '../block-patterns-list';
|
|
|
28
28
|
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
29
29
|
import MobileTabNavigation from './mobile-tab-navigation';
|
|
30
30
|
|
|
31
|
+
const noop = () => {};
|
|
32
|
+
|
|
31
33
|
// Preferred order of pattern categories. Any other categories should
|
|
32
34
|
// be at the bottom without any re-ordering.
|
|
33
35
|
const patternCategoriesOrder = [
|
|
@@ -134,7 +136,7 @@ export function BlockPatternsCategoryDialog( {
|
|
|
134
136
|
export function BlockPatternsCategoryPanel( {
|
|
135
137
|
rootClientId,
|
|
136
138
|
onInsert,
|
|
137
|
-
onHover,
|
|
139
|
+
onHover = noop,
|
|
138
140
|
category,
|
|
139
141
|
showTitlesAsTooltip,
|
|
140
142
|
} ) {
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
PanelBody,
|
|
6
6
|
__experimentalUseSlotFills as useSlotFills,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
|
+
import { useSelect } from '@wordpress/data';
|
|
9
|
+
import { useLayoutEffect, useState } from '@wordpress/element';
|
|
8
10
|
import { __ } from '@wordpress/i18n';
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -12,26 +14,55 @@ import { __ } from '@wordpress/i18n';
|
|
|
12
14
|
*/
|
|
13
15
|
import InspectorControlsGroups from '../inspector-controls/groups';
|
|
14
16
|
import { default as InspectorControls } from '../inspector-controls';
|
|
17
|
+
import { store as blockEditorStore } from '../../store';
|
|
15
18
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
InspectorControlsGroups.position.Slot.__unstableName
|
|
19
|
-
);
|
|
20
|
-
const hasFills = Boolean( fills && fills.length );
|
|
19
|
+
const PositionControlsPanel = () => {
|
|
20
|
+
const [ initialOpen, setInitialOpen ] = useState();
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
// Determine whether the panel should be expanded.
|
|
23
|
+
const { multiSelectedBlocks } = useSelect( ( select ) => {
|
|
24
|
+
const { getBlocksByClientId, getSelectedBlockClientIds } =
|
|
25
|
+
select( blockEditorStore );
|
|
26
|
+
const clientIds = getSelectedBlockClientIds();
|
|
27
|
+
return {
|
|
28
|
+
multiSelectedBlocks: getBlocksByClientId( clientIds ),
|
|
29
|
+
};
|
|
30
|
+
}, [] );
|
|
31
|
+
|
|
32
|
+
useLayoutEffect( () => {
|
|
33
|
+
// If any selected block has a position set, open the panel by default.
|
|
34
|
+
// The first block's value will still be used within the control though.
|
|
35
|
+
if ( initialOpen === undefined ) {
|
|
36
|
+
setInitialOpen(
|
|
37
|
+
multiSelectedBlocks.some(
|
|
38
|
+
( { attributes } ) => !! attributes?.style?.position?.type
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}, [ initialOpen, multiSelectedBlocks, setInitialOpen ] );
|
|
25
43
|
|
|
26
44
|
return (
|
|
27
45
|
<PanelBody
|
|
28
46
|
className="block-editor-block-inspector__position"
|
|
29
47
|
title={ __( 'Position' ) }
|
|
30
|
-
initialOpen={ false }
|
|
48
|
+
initialOpen={ initialOpen ?? false }
|
|
31
49
|
>
|
|
32
50
|
<InspectorControls.Slot group="position" />
|
|
33
51
|
</PanelBody>
|
|
34
52
|
);
|
|
35
53
|
};
|
|
36
54
|
|
|
55
|
+
const PositionControls = () => {
|
|
56
|
+
const fills = useSlotFills(
|
|
57
|
+
InspectorControlsGroups.position.Slot.__unstableName
|
|
58
|
+
);
|
|
59
|
+
const hasFills = Boolean( fills && fills.length );
|
|
60
|
+
|
|
61
|
+
if ( ! hasFills ) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <PositionControlsPanel />;
|
|
66
|
+
};
|
|
67
|
+
|
|
37
68
|
export default PositionControls;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { cog, styles, listView } from '@wordpress/icons';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
export const TAB_SETTINGS = {
|
|
7
8
|
name: 'settings',
|
|
8
|
-
title: 'Settings',
|
|
9
|
+
title: __( 'Settings' ),
|
|
9
10
|
value: 'settings',
|
|
10
11
|
icon: cog,
|
|
11
12
|
className: 'block-editor-block-inspector__tab-item',
|
|
@@ -13,7 +14,7 @@ export const TAB_SETTINGS = {
|
|
|
13
14
|
|
|
14
15
|
export const TAB_STYLES = {
|
|
15
16
|
name: 'styles',
|
|
16
|
-
title: 'Styles',
|
|
17
|
+
title: __( 'Styles' ),
|
|
17
18
|
value: 'styles',
|
|
18
19
|
icon: styles,
|
|
19
20
|
className: 'block-editor-block-inspector__tab-item',
|
|
@@ -21,7 +22,7 @@ export const TAB_STYLES = {
|
|
|
21
22
|
|
|
22
23
|
export const TAB_LIST_VIEW = {
|
|
23
24
|
name: 'list',
|
|
24
|
-
title: 'List View',
|
|
25
|
+
title: __( 'List View' ),
|
|
25
26
|
value: 'list-view',
|
|
26
27
|
icon: listView,
|
|
27
28
|
className: 'block-editor-block-inspector__tab-item',
|
|
@@ -84,6 +84,15 @@ const LineHeightControl = ( {
|
|
|
84
84
|
? undefined
|
|
85
85
|
: { marginBottom: 24 };
|
|
86
86
|
|
|
87
|
+
const handleOnChange = ( nextValue, { event } ) => {
|
|
88
|
+
if ( event.type === 'click' ) {
|
|
89
|
+
onChange( adjustNextValue( nextValue, false ) );
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
onChange( nextValue );
|
|
94
|
+
};
|
|
95
|
+
|
|
87
96
|
return (
|
|
88
97
|
<div
|
|
89
98
|
className="block-editor-line-height-control"
|
|
@@ -93,7 +102,7 @@ const LineHeightControl = ( {
|
|
|
93
102
|
{ ...otherProps }
|
|
94
103
|
__unstableInputWidth={ __unstableInputWidth }
|
|
95
104
|
__unstableStateReducer={ stateReducer }
|
|
96
|
-
onChange={
|
|
105
|
+
onChange={ handleOnChange }
|
|
97
106
|
label={ __( 'Line height' ) }
|
|
98
107
|
placeholder={ BASE_DEFAULT_VALUE }
|
|
99
108
|
step={ STEP }
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The ListView component provides an overview of the hierarchical structure of all blocks in the editor. The blocks are presented vertically one below the other.
|
|
4
4
|
|
|
5
|
+
By providing the `rootClientId` prop you can restrict the blocks that are shown to only children of the block with that client id.
|
|
6
|
+
|
|
5
7
|
Blocks that have child blocks (such as group or column blocks) are presented with the parent at the top and the nested children below.
|
|
6
8
|
|
|
7
9
|
In addition to presenting the structure of the blocks in the editor, the ListView component lets users navigate to each block by clicking on its line in the hierarchy tree. Multiple blocks at the same level of nesting can be selected by holding down the `SHIFT` key and clicking blocks within the list.
|