@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
|
@@ -8,15 +8,16 @@ import { get, isEmpty, kebabCase, set } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, __EXPERIMENTAL_ELEMENTS as ELEMENTS, getBlockTypes, store as blocksStore } from '@wordpress/blocks';
|
|
11
|
+
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, __EXPERIMENTAL_ELEMENTS as ELEMENTS, getBlockSupport, getBlockTypes, store as blocksStore } from '@wordpress/blocks';
|
|
12
12
|
import { useSelect } from '@wordpress/data';
|
|
13
|
-
import { useContext, useMemo } from '@wordpress/element';
|
|
13
|
+
import { renderToString, useContext, useMemo } from '@wordpress/element';
|
|
14
14
|
import { getCSSRules } from '@wordpress/style-engine';
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { PRESET_METADATA, ROOT_BLOCK_SELECTOR, scopeSelector } from './utils';
|
|
20
|
+
import { getBlockCSSSelector } from './get-block-css-selector';
|
|
20
21
|
import { getTypographyFontSizeValue } from './typography-utils';
|
|
21
22
|
import { GlobalStylesContext } from './context';
|
|
22
23
|
import { useGlobalSetting } from './hooks';
|
|
@@ -134,10 +135,10 @@ function getPresetsSvgFilters() {
|
|
|
134
135
|
return PRESET_METADATA.filter( // Duotone are the only type of filters for now.
|
|
135
136
|
metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
|
|
136
137
|
const presetByOrigin = get(blockPresets, metadata.path, {});
|
|
137
|
-
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => createElement(PresetDuotoneFilter, {
|
|
138
|
+
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => renderToString(createElement(PresetDuotoneFilter, {
|
|
138
139
|
preset: preset,
|
|
139
140
|
key: preset.slug
|
|
140
|
-
})));
|
|
141
|
+
})))).join('');
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
144
|
|
|
@@ -178,6 +179,76 @@ function concatFeatureVariationSelectorString(featureSelector, styleVariationSel
|
|
|
178
179
|
});
|
|
179
180
|
return combinedSelectors.join(', ');
|
|
180
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Generate style declarations for a block's custom feature and subfeature
|
|
184
|
+
* selectors.
|
|
185
|
+
*
|
|
186
|
+
* NOTE: The passed `styles` object will be mutated by this function.
|
|
187
|
+
*
|
|
188
|
+
* @param {Object} selectors Custom selectors object for a block.
|
|
189
|
+
* @param {Object} styles A block's styles object.
|
|
190
|
+
*
|
|
191
|
+
* @return {Object} Style declarations.
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
const getFeatureDeclarations = (selectors, styles) => {
|
|
196
|
+
const declarations = {};
|
|
197
|
+
Object.entries(selectors).forEach(_ref5 => {
|
|
198
|
+
let [feature, selector] = _ref5;
|
|
199
|
+
|
|
200
|
+
// We're only processing features/subfeatures that have styles.
|
|
201
|
+
if (feature === 'root' || !(styles !== null && styles !== void 0 && styles[feature])) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const isShorthand = typeof selector === 'string'; // If we have a selector object instead of shorthand process it.
|
|
206
|
+
|
|
207
|
+
if (!isShorthand) {
|
|
208
|
+
Object.entries(selector).forEach(_ref6 => {
|
|
209
|
+
let [subfeature, subfeatureSelector] = _ref6;
|
|
210
|
+
|
|
211
|
+
// Don't process root feature selector yet or any
|
|
212
|
+
// subfeature that doesn't have a style.
|
|
213
|
+
if (subfeature === 'root' || !(styles !== null && styles !== void 0 && styles[feature][subfeature])) {
|
|
214
|
+
return;
|
|
215
|
+
} // Create a temporary styles object and build
|
|
216
|
+
// declarations for subfeature.
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
const subfeatureStyles = {
|
|
220
|
+
[feature]: {
|
|
221
|
+
[subfeature]: styles[feature][subfeature]
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const newDeclarations = getStylesDeclarations(subfeatureStyles); // Merge new declarations in with any others that
|
|
225
|
+
// share the same selector.
|
|
226
|
+
|
|
227
|
+
declarations[subfeatureSelector] = [...(declarations[subfeatureSelector] || []), ...newDeclarations]; // Remove the subfeature's style now it will be
|
|
228
|
+
// included under its own selector not the block's.
|
|
229
|
+
|
|
230
|
+
delete styles[feature][subfeature];
|
|
231
|
+
});
|
|
232
|
+
} // Now subfeatures have been processed and removed, we can
|
|
233
|
+
// process root, or shorthand, feature selectors.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
if (isShorthand || selector.root) {
|
|
237
|
+
const featureSelector = isShorthand ? selector : selector.root; // Create temporary style object and build declarations for feature.
|
|
238
|
+
|
|
239
|
+
const featureStyles = {
|
|
240
|
+
[feature]: styles[feature]
|
|
241
|
+
};
|
|
242
|
+
const newDeclarations = getStylesDeclarations(featureStyles); // Merge new declarations with any others that share the selector.
|
|
243
|
+
|
|
244
|
+
declarations[featureSelector] = [...(declarations[featureSelector] || []), ...newDeclarations]; // Remove the feature from the block's styles now as it will be
|
|
245
|
+
// included under its own selector not the block's.
|
|
246
|
+
|
|
247
|
+
delete styles[feature];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return declarations;
|
|
251
|
+
};
|
|
181
252
|
/**
|
|
182
253
|
* Transform given style tree into a set of style declarations.
|
|
183
254
|
*
|
|
@@ -199,13 +270,13 @@ export function getStylesDeclarations() {
|
|
|
199
270
|
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
200
271
|
let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
201
272
|
const isRoot = ROOT_BLOCK_SELECTOR === selector;
|
|
202
|
-
const output = Object.entries(STYLE_PROPERTY).reduce((declarations,
|
|
273
|
+
const output = Object.entries(STYLE_PROPERTY).reduce((declarations, _ref7) => {
|
|
203
274
|
let [key, {
|
|
204
275
|
value,
|
|
205
276
|
properties,
|
|
206
277
|
useEngine,
|
|
207
278
|
rootOnly
|
|
208
|
-
}] =
|
|
279
|
+
}] = _ref7;
|
|
209
280
|
|
|
210
281
|
if (rootOnly && !isRoot) {
|
|
211
282
|
return declarations;
|
|
@@ -304,7 +375,7 @@ export function getStylesDeclarations() {
|
|
|
304
375
|
* @return {string} Generated CSS rules for the layout styles.
|
|
305
376
|
*/
|
|
306
377
|
|
|
307
|
-
export function getLayoutStyles(
|
|
378
|
+
export function getLayoutStyles(_ref8) {
|
|
308
379
|
var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
|
|
309
380
|
|
|
310
381
|
let {
|
|
@@ -314,7 +385,7 @@ export function getLayoutStyles(_ref6) {
|
|
|
314
385
|
hasBlockGapSupport,
|
|
315
386
|
hasFallbackGapSupport,
|
|
316
387
|
fallbackGapValue
|
|
317
|
-
} =
|
|
388
|
+
} = _ref8;
|
|
318
389
|
let ruleset = '';
|
|
319
390
|
let gapValue = hasBlockGapSupport ? getGapCSSValue(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap) : ''; // Ensure a fallback gap value for the root layout definitions,
|
|
320
391
|
// and use a fallback value if one is provided for the current block.
|
|
@@ -328,12 +399,12 @@ export function getLayoutStyles(_ref6) {
|
|
|
328
399
|
}
|
|
329
400
|
|
|
330
401
|
if (gapValue && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
|
|
331
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
402
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
|
|
332
403
|
let {
|
|
333
404
|
className,
|
|
334
405
|
name,
|
|
335
406
|
spacingStyles
|
|
336
|
-
} =
|
|
407
|
+
} = _ref9;
|
|
337
408
|
|
|
338
409
|
// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
|
|
339
410
|
if (!hasBlockGapSupport && 'flex' !== name) {
|
|
@@ -345,8 +416,8 @@ export function getLayoutStyles(_ref6) {
|
|
|
345
416
|
const declarations = [];
|
|
346
417
|
|
|
347
418
|
if (spacingStyle.rules) {
|
|
348
|
-
Object.entries(spacingStyle.rules).forEach(
|
|
349
|
-
let [cssProperty, cssValue] =
|
|
419
|
+
Object.entries(spacingStyle.rules).forEach(_ref10 => {
|
|
420
|
+
let [cssProperty, cssValue] = _ref10;
|
|
350
421
|
declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
|
|
351
422
|
});
|
|
352
423
|
}
|
|
@@ -358,7 +429,7 @@ export function getLayoutStyles(_ref6) {
|
|
|
358
429
|
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
359
430
|
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})` : `:where(${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})`;
|
|
360
431
|
} else {
|
|
361
|
-
combinedSelector = selector === ROOT_BLOCK_SELECTOR ?
|
|
432
|
+
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(${selector} .${className})${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}-${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
|
|
362
433
|
}
|
|
363
434
|
|
|
364
435
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
@@ -375,12 +446,12 @@ export function getLayoutStyles(_ref6) {
|
|
|
375
446
|
|
|
376
447
|
if (selector === ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings3 = tree.settings) !== null && _tree$settings3 !== void 0 && (_tree$settings3$layou = _tree$settings3.layout) !== null && _tree$settings3$layou !== void 0 && _tree$settings3$layou.definitions) {
|
|
377
448
|
const validDisplayModes = ['block', 'flex', 'grid'];
|
|
378
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
449
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref11 => {
|
|
379
450
|
let {
|
|
380
451
|
className,
|
|
381
452
|
displayMode,
|
|
382
453
|
baseStyles
|
|
383
|
-
} =
|
|
454
|
+
} = _ref11;
|
|
384
455
|
|
|
385
456
|
if (displayMode && validDisplayModes.includes(displayMode)) {
|
|
386
457
|
ruleset += `${selector} .${className} { display:${displayMode}; }`;
|
|
@@ -391,8 +462,8 @@ export function getLayoutStyles(_ref6) {
|
|
|
391
462
|
const declarations = [];
|
|
392
463
|
|
|
393
464
|
if (baseStyle.rules) {
|
|
394
|
-
Object.entries(baseStyle.rules).forEach(
|
|
395
|
-
let [cssProperty, cssValue] =
|
|
465
|
+
Object.entries(baseStyle.rules).forEach(_ref12 => {
|
|
466
|
+
let [cssProperty, cssValue] = _ref12;
|
|
396
467
|
declarations.push(`${cssProperty}: ${cssValue}`);
|
|
397
468
|
});
|
|
398
469
|
}
|
|
@@ -417,8 +488,8 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
417
488
|
return nodes;
|
|
418
489
|
}
|
|
419
490
|
|
|
420
|
-
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(
|
|
421
|
-
let [key] =
|
|
491
|
+
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref13 => {
|
|
492
|
+
let [key] = _ref13;
|
|
422
493
|
return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
|
|
423
494
|
})); // Top-level.
|
|
424
495
|
|
|
@@ -432,10 +503,10 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
432
503
|
});
|
|
433
504
|
}
|
|
434
505
|
|
|
435
|
-
Object.entries(ELEMENTS).forEach(
|
|
506
|
+
Object.entries(ELEMENTS).forEach(_ref14 => {
|
|
436
507
|
var _tree$styles, _tree$styles$elements;
|
|
437
508
|
|
|
438
|
-
let [name, selector] =
|
|
509
|
+
let [name, selector] = _ref14;
|
|
439
510
|
|
|
440
511
|
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && (_tree$styles$elements = _tree$styles.elements) !== null && _tree$styles$elements !== void 0 && _tree$styles$elements[name])) {
|
|
441
512
|
var _tree$styles2, _tree$styles2$element;
|
|
@@ -447,10 +518,10 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
447
518
|
}
|
|
448
519
|
}); // Iterate over blocks: they can have styles & elements.
|
|
449
520
|
|
|
450
|
-
Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(
|
|
521
|
+
Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(_ref15 => {
|
|
451
522
|
var _blockSelectors$block, _node$elements;
|
|
452
523
|
|
|
453
|
-
let [blockName, node] =
|
|
524
|
+
let [blockName, node] = _ref15;
|
|
454
525
|
const blockStyles = pickStyleKeys(node);
|
|
455
526
|
|
|
456
527
|
if (node !== null && node !== void 0 && node.variations) {
|
|
@@ -475,8 +546,8 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
475
546
|
});
|
|
476
547
|
}
|
|
477
548
|
|
|
478
|
-
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(
|
|
479
|
-
let [elementName, value] =
|
|
549
|
+
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref16 => {
|
|
550
|
+
let [elementName, value] = _ref16;
|
|
480
551
|
|
|
481
552
|
if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(ELEMENTS !== null && ELEMENTS !== void 0 && ELEMENTS[elementName])) {
|
|
482
553
|
var _blockSelectors$block3;
|
|
@@ -504,10 +575,10 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
504
575
|
|
|
505
576
|
const pickPresets = treeToPickFrom => {
|
|
506
577
|
const presets = {};
|
|
507
|
-
PRESET_METADATA.forEach(
|
|
578
|
+
PRESET_METADATA.forEach(_ref17 => {
|
|
508
579
|
let {
|
|
509
580
|
path
|
|
510
|
-
} =
|
|
581
|
+
} = _ref17;
|
|
511
582
|
const value = get(treeToPickFrom, path, false);
|
|
512
583
|
|
|
513
584
|
if (value !== false) {
|
|
@@ -530,8 +601,8 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
530
601
|
} // Blocks.
|
|
531
602
|
|
|
532
603
|
|
|
533
|
-
Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(
|
|
534
|
-
let [blockName, node] =
|
|
604
|
+
Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref18 => {
|
|
605
|
+
let [blockName, node] = _ref18;
|
|
535
606
|
const blockPresets = pickPresets(node);
|
|
536
607
|
const blockCustom = node.custom;
|
|
537
608
|
|
|
@@ -550,12 +621,12 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
550
621
|
export const toCustomProperties = (tree, blockSelectors) => {
|
|
551
622
|
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
552
623
|
let ruleset = '';
|
|
553
|
-
settings.forEach(
|
|
624
|
+
settings.forEach(_ref19 => {
|
|
554
625
|
let {
|
|
555
626
|
presets,
|
|
556
627
|
custom,
|
|
557
628
|
selector
|
|
558
|
-
} =
|
|
629
|
+
} = _ref19;
|
|
559
630
|
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
560
631
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
561
632
|
|
|
@@ -614,7 +685,7 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
614
685
|
}
|
|
615
686
|
|
|
616
687
|
ruleset += '}';
|
|
617
|
-
nodesWithStyles.forEach(
|
|
688
|
+
nodesWithStyles.forEach(_ref20 => {
|
|
618
689
|
let {
|
|
619
690
|
selector,
|
|
620
691
|
duotoneSelector,
|
|
@@ -623,54 +694,43 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
623
694
|
hasLayoutSupport,
|
|
624
695
|
featureSelectors,
|
|
625
696
|
styleVariationSelectors
|
|
626
|
-
} =
|
|
697
|
+
} = _ref20;
|
|
627
698
|
|
|
628
699
|
// Process styles for block support features with custom feature level
|
|
629
700
|
// CSS selectors set.
|
|
630
701
|
if (featureSelectors) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
639
|
-
delete styles[featureName];
|
|
640
|
-
|
|
641
|
-
if (!!featureDeclarations.length) {
|
|
642
|
-
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
643
|
-
}
|
|
702
|
+
const featureDeclarations = getFeatureDeclarations(featureSelectors, styles);
|
|
703
|
+
Object.entries(featureDeclarations).forEach(_ref21 => {
|
|
704
|
+
let [cssSelector, declarations] = _ref21;
|
|
705
|
+
|
|
706
|
+
if (!!declarations.length) {
|
|
707
|
+
const rules = declarations.join(';');
|
|
708
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
644
709
|
}
|
|
645
710
|
});
|
|
646
711
|
}
|
|
647
712
|
|
|
648
713
|
if (styleVariationSelectors) {
|
|
649
|
-
Object.entries(styleVariationSelectors).forEach(
|
|
714
|
+
Object.entries(styleVariationSelectors).forEach(_ref22 => {
|
|
650
715
|
var _styles$variations;
|
|
651
716
|
|
|
652
|
-
let [styleVariationName, styleVariationSelector] =
|
|
717
|
+
let [styleVariationName, styleVariationSelector] = _ref22;
|
|
653
718
|
|
|
654
719
|
if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
|
|
655
720
|
var _styles$variations3;
|
|
656
721
|
|
|
657
722
|
// If the block uses any custom selectors for block support, add those first.
|
|
658
723
|
if (featureSelectors) {
|
|
659
|
-
|
|
660
|
-
var _styles$variations2, _styles$variations2$s;
|
|
661
|
-
|
|
662
|
-
let [featureName, featureSelector] = _ref21;
|
|
724
|
+
var _styles$variations2;
|
|
663
725
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
};
|
|
668
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
669
|
-
delete styles.variations[styleVariationName][featureName];
|
|
726
|
+
const featureDeclarations = getFeatureDeclarations(featureSelectors, styles === null || styles === void 0 ? void 0 : (_styles$variations2 = styles.variations) === null || _styles$variations2 === void 0 ? void 0 : _styles$variations2[styleVariationName]);
|
|
727
|
+
Object.entries(featureDeclarations).forEach(_ref23 => {
|
|
728
|
+
let [baseSelector, declarations] = _ref23;
|
|
670
729
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
730
|
+
if (!!declarations.length) {
|
|
731
|
+
const cssSelector = concatFeatureVariationSelectorString(baseSelector, styleVariationSelector);
|
|
732
|
+
const rules = declarations.join(';');
|
|
733
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
674
734
|
}
|
|
675
735
|
});
|
|
676
736
|
} // Otherwise add regular selectors.
|
|
@@ -690,14 +750,14 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
690
750
|
if (styles !== null && styles !== void 0 && styles.filter) {
|
|
691
751
|
duotoneStyles.filter = styles.filter;
|
|
692
752
|
delete styles.filter;
|
|
693
|
-
} // Process duotone styles
|
|
753
|
+
} // Process duotone styles.
|
|
694
754
|
|
|
695
755
|
|
|
696
756
|
if (duotoneSelector) {
|
|
697
757
|
const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
|
|
698
758
|
|
|
699
759
|
if (duotoneDeclarations.length > 0) {
|
|
700
|
-
ruleset = ruleset + `${
|
|
760
|
+
ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
|
|
701
761
|
}
|
|
702
762
|
} // Process blockGap and layout styles.
|
|
703
763
|
|
|
@@ -721,14 +781,14 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
721
781
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
722
782
|
|
|
723
783
|
|
|
724
|
-
const pseudoSelectorStyles = Object.entries(styles).filter(
|
|
725
|
-
let [key] =
|
|
784
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref24 => {
|
|
785
|
+
let [key] = _ref24;
|
|
726
786
|
return key.startsWith(':');
|
|
727
787
|
});
|
|
728
788
|
|
|
729
789
|
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
730
|
-
pseudoSelectorStyles.forEach(
|
|
731
|
-
let [pseudoKey, pseudoStyle] =
|
|
790
|
+
pseudoSelectorStyles.forEach(_ref25 => {
|
|
791
|
+
let [pseudoKey, pseudoStyle] = _ref25;
|
|
732
792
|
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
733
793
|
|
|
734
794
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
@@ -760,15 +820,16 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
760
820
|
|
|
761
821
|
// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
|
|
762
822
|
const gapValue = getGapCSSValue(tree === null || tree === void 0 ? void 0 : (_tree$styles4 = tree.styles) === null || _tree$styles4 === void 0 ? void 0 : (_tree$styles4$spacing = _tree$styles4.spacing) === null || _tree$styles4$spacing === void 0 ? void 0 : _tree$styles4$spacing.blockGap) || '0.5em';
|
|
763
|
-
ruleset = ruleset +
|
|
764
|
-
ruleset = ruleset +
|
|
823
|
+
ruleset = ruleset + `:where(.wp-site-blocks) > * { margin-block-start: ${gapValue}; margin-block-end: 0; }`;
|
|
824
|
+
ruleset = ruleset + ':where(.wp-site-blocks) > :first-child:first-child { margin-block-start: 0; }';
|
|
825
|
+
ruleset = ruleset + ':where(.wp-site-blocks) > :last-child:last-child { margin-block-end: 0; }';
|
|
765
826
|
}
|
|
766
827
|
|
|
767
|
-
nodesWithSettings.forEach(
|
|
828
|
+
nodesWithSettings.forEach(_ref26 => {
|
|
768
829
|
let {
|
|
769
830
|
selector,
|
|
770
831
|
presets
|
|
771
|
-
} =
|
|
832
|
+
} = _ref26;
|
|
772
833
|
|
|
773
834
|
if (ROOT_BLOCK_SELECTOR === selector) {
|
|
774
835
|
// Do not add extra specificity for top-level classes.
|
|
@@ -785,23 +846,50 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
785
846
|
};
|
|
786
847
|
export function toSvgFilters(tree, blockSelectors) {
|
|
787
848
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
788
|
-
return nodesWithSettings.flatMap(
|
|
849
|
+
return nodesWithSettings.flatMap(_ref27 => {
|
|
789
850
|
let {
|
|
790
851
|
presets
|
|
791
|
-
} =
|
|
852
|
+
} = _ref27;
|
|
792
853
|
return getPresetsSvgFilters(presets);
|
|
793
854
|
});
|
|
794
855
|
}
|
|
856
|
+
|
|
857
|
+
const getSelectorsConfig = (blockType, rootSelector) => {
|
|
858
|
+
if (!isEmpty(blockType === null || blockType === void 0 ? void 0 : blockType.selectors)) {
|
|
859
|
+
return blockType.selectors;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
const config = {
|
|
863
|
+
root: rootSelector
|
|
864
|
+
};
|
|
865
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref28 => {
|
|
866
|
+
let [featureKey, featureName] = _ref28;
|
|
867
|
+
const featureSelector = getBlockCSSSelector(blockType, featureKey);
|
|
868
|
+
|
|
869
|
+
if (featureSelector) {
|
|
870
|
+
config[featureName] = featureSelector;
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
return config;
|
|
874
|
+
};
|
|
875
|
+
|
|
795
876
|
export const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
796
877
|
const result = {};
|
|
797
878
|
blockTypes.forEach(blockType => {
|
|
798
|
-
var _blockType$supports
|
|
879
|
+
var _blockType$supports, _blockType$supports2, _blockType$supports2$, _blockType$supports2$2;
|
|
799
880
|
|
|
800
881
|
const name = blockType.name;
|
|
801
|
-
const selector = (
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
882
|
+
const selector = getBlockCSSSelector(blockType);
|
|
883
|
+
let duotoneSelector = getBlockCSSSelector(blockType, 'filter.duotone'); // Keep backwards compatibility for support.color.__experimentalDuotone.
|
|
884
|
+
|
|
885
|
+
if (!duotoneSelector) {
|
|
886
|
+
const rootSelector = getBlockCSSSelector(blockType);
|
|
887
|
+
const duotoneSupport = getBlockSupport(blockType, 'color.__experimentalDuotone', false);
|
|
888
|
+
duotoneSelector = duotoneSupport && scopeSelector(rootSelector, duotoneSupport);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && _blockType$supports.__experimentalLayout);
|
|
892
|
+
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.spacing) === null || _blockType$supports2$ === void 0 ? void 0 : (_blockType$supports2$2 = _blockType$supports2$.blockGap) === null || _blockType$supports2$2 === void 0 ? void 0 : _blockType$supports2$2.__experimentalDefault;
|
|
805
893
|
const blockStyleVariations = getBlockStyles(name);
|
|
806
894
|
const styleVariationSelectors = {};
|
|
807
895
|
|
|
@@ -813,17 +901,7 @@ export const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
|
813
901
|
} // For each block support feature add any custom selectors.
|
|
814
902
|
|
|
815
903
|
|
|
816
|
-
const featureSelectors =
|
|
817
|
-
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
|
|
818
|
-
var _blockType$supports5, _blockType$supports5$;
|
|
819
|
-
|
|
820
|
-
let [featureKey, featureName] = _ref26;
|
|
821
|
-
const featureSelector = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports5 = blockType.supports) === null || _blockType$supports5 === void 0 ? void 0 : (_blockType$supports5$ = _blockType$supports5[featureKey]) === null || _blockType$supports5$ === void 0 ? void 0 : _blockType$supports5$.__experimentalSelector;
|
|
822
|
-
|
|
823
|
-
if (featureSelector) {
|
|
824
|
-
featureSelectors[featureName] = scopeSelector(selector, featureSelector);
|
|
825
|
-
}
|
|
826
|
-
});
|
|
904
|
+
const featureSelectors = getSelectorsConfig(blockType, selector);
|
|
827
905
|
result[name] = {
|
|
828
906
|
duotoneSelector,
|
|
829
907
|
fallbackGapValue,
|
|
@@ -907,8 +985,8 @@ export function useGlobalStylesOutput() {
|
|
|
907
985
|
const blockSelectors = getBlockSelectors(getBlockTypes(), getBlockStyles);
|
|
908
986
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
909
987
|
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
910
|
-
const
|
|
911
|
-
const
|
|
988
|
+
const svgs = toSvgFilters(mergedConfig, blockSelectors);
|
|
989
|
+
const styles = [{
|
|
912
990
|
css: customProperties,
|
|
913
991
|
isGlobalStyles: true
|
|
914
992
|
}, {
|
|
@@ -918,6 +996,10 @@ export function useGlobalStylesOutput() {
|
|
|
918
996
|
{
|
|
919
997
|
css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
|
|
920
998
|
isGlobalStyles: true
|
|
999
|
+
}, {
|
|
1000
|
+
assets: svgs,
|
|
1001
|
+
__unstableType: 'svg',
|
|
1002
|
+
isGlobalStyles: true
|
|
921
1003
|
}]; // Loop through the blocks to check if there are custom CSS values.
|
|
922
1004
|
// If there are, get the block selector and push the selector together with
|
|
923
1005
|
// the CSS value to the 'stylesheets' array.
|
|
@@ -929,13 +1011,13 @@ export function useGlobalStylesOutput() {
|
|
|
929
1011
|
var _mergedConfig$styles$3;
|
|
930
1012
|
|
|
931
1013
|
const selector = blockSelectors[blockType.name].selector;
|
|
932
|
-
|
|
1014
|
+
styles.push({
|
|
933
1015
|
css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
|
|
934
1016
|
isGlobalStyles: true
|
|
935
1017
|
});
|
|
936
1018
|
}
|
|
937
1019
|
});
|
|
938
|
-
return [
|
|
1020
|
+
return [styles, mergedConfig.settings];
|
|
939
1021
|
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
940
1022
|
}
|
|
941
1023
|
//# sourceMappingURL=use-global-styles-output.js.map
|