@wordpress/block-editor 11.5.0 → 11.7.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 +4 -0
- 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-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.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-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.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 +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- 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 +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +109 -3
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +66 -45
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +180 -99
- 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/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.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/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.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 +5 -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 +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.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/appender.js +28 -3
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +5 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +9 -7
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -1
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- 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/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.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/border.js +90 -240
- 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/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +19 -22
- package/build/hooks/layout.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/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +50 -75
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.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/private-apis.js +7 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +10 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +19 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build/utils/parse-css-unit-to-px.js +15 -9
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- 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-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.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-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.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 +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- 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 +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +104 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +65 -46
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +181 -100
- 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/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.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/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.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 +5 -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 +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.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/appender.js +28 -4
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +5 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +9 -7
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- 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/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.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/border.js +92 -240
- 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/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +19 -22
- package/build-module/hooks/layout.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/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +48 -72
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.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/private-apis.js +5 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +10 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +17 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-module/utils/parse-css-unit-to-px.js +15 -9
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +32 -12
- package/build-style/style.css +32 -12
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +154 -1
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/use-global-styles-output.js +31 -2
- package/src/components/global-styles/typography-panel.js +67 -45
- package/src/components/global-styles/use-global-styles-output.js +176 -93
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +3 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/style.scss +0 -4
- package/src/components/link-control/test/index.js +0 -2
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-block-selection.js +0 -2
- 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/appender.js +31 -5
- package/src/components/off-canvas-editor/branch.js +3 -1
- package/src/components/off-canvas-editor/index.js +7 -7
- package/src/components/off-canvas-editor/link-ui.js +0 -1
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +93 -225
- 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/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/layout.js +19 -16
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +2 -1
- package/src/hooks/utils.js +63 -70
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +10 -8
- package/src/store/selectors.js +20 -3
- package/src/utils/object.js +69 -0
- package/src/utils/parse-css-unit-to-px.js +14 -9
- package/src/utils/test/object.js +107 -0
- package/src/utils/test/parse-css-unit-to-px.js +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
|
@@ -10,13 +10,14 @@ import { get, isEmpty, kebabCase, set } from 'lodash';
|
|
|
10
10
|
|
|
11
11
|
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, __EXPERIMENTAL_ELEMENTS as ELEMENTS, 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';
|
|
@@ -84,13 +85,14 @@ function getPresetsDeclarations() {
|
|
|
84
85
|
/**
|
|
85
86
|
* Transform given preset tree into a set of preset class declarations.
|
|
86
87
|
*
|
|
87
|
-
* @param {string} blockSelector
|
|
88
|
-
* @param {Object}
|
|
88
|
+
* @param {?string} blockSelector
|
|
89
|
+
* @param {Object} blockPresets
|
|
89
90
|
* @return {string} CSS declarations for the preset classes.
|
|
90
91
|
*/
|
|
91
92
|
|
|
92
93
|
|
|
93
|
-
function getPresetsClasses(
|
|
94
|
+
function getPresetsClasses() {
|
|
95
|
+
let blockSelector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*';
|
|
94
96
|
let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
95
97
|
return PRESET_METADATA.reduce((declarations, _ref2) => {
|
|
96
98
|
let {
|
|
@@ -133,10 +135,10 @@ function getPresetsSvgFilters() {
|
|
|
133
135
|
return PRESET_METADATA.filter( // Duotone are the only type of filters for now.
|
|
134
136
|
metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
|
|
135
137
|
const presetByOrigin = get(blockPresets, metadata.path, {});
|
|
136
|
-
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, {
|
|
137
139
|
preset: preset,
|
|
138
140
|
key: preset.slug
|
|
139
|
-
})));
|
|
141
|
+
})))).join('');
|
|
140
142
|
});
|
|
141
143
|
}
|
|
142
144
|
|
|
@@ -177,6 +179,76 @@ function concatFeatureVariationSelectorString(featureSelector, styleVariationSel
|
|
|
177
179
|
});
|
|
178
180
|
return combinedSelectors.join(', ');
|
|
179
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
|
+
};
|
|
180
252
|
/**
|
|
181
253
|
* Transform given style tree into a set of style declarations.
|
|
182
254
|
*
|
|
@@ -198,13 +270,13 @@ export function getStylesDeclarations() {
|
|
|
198
270
|
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
199
271
|
let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
200
272
|
const isRoot = ROOT_BLOCK_SELECTOR === selector;
|
|
201
|
-
const output = Object.entries(STYLE_PROPERTY).reduce((declarations,
|
|
273
|
+
const output = Object.entries(STYLE_PROPERTY).reduce((declarations, _ref7) => {
|
|
202
274
|
let [key, {
|
|
203
275
|
value,
|
|
204
276
|
properties,
|
|
205
277
|
useEngine,
|
|
206
278
|
rootOnly
|
|
207
|
-
}] =
|
|
279
|
+
}] = _ref7;
|
|
208
280
|
|
|
209
281
|
if (rootOnly && !isRoot) {
|
|
210
282
|
return declarations;
|
|
@@ -303,7 +375,7 @@ export function getStylesDeclarations() {
|
|
|
303
375
|
* @return {string} Generated CSS rules for the layout styles.
|
|
304
376
|
*/
|
|
305
377
|
|
|
306
|
-
export function getLayoutStyles(
|
|
378
|
+
export function getLayoutStyles(_ref8) {
|
|
307
379
|
var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
|
|
308
380
|
|
|
309
381
|
let {
|
|
@@ -313,7 +385,7 @@ export function getLayoutStyles(_ref6) {
|
|
|
313
385
|
hasBlockGapSupport,
|
|
314
386
|
hasFallbackGapSupport,
|
|
315
387
|
fallbackGapValue
|
|
316
|
-
} =
|
|
388
|
+
} = _ref8;
|
|
317
389
|
let ruleset = '';
|
|
318
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,
|
|
319
391
|
// and use a fallback value if one is provided for the current block.
|
|
@@ -327,12 +399,12 @@ export function getLayoutStyles(_ref6) {
|
|
|
327
399
|
}
|
|
328
400
|
|
|
329
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) {
|
|
330
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
402
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
|
|
331
403
|
let {
|
|
332
404
|
className,
|
|
333
405
|
name,
|
|
334
406
|
spacingStyles
|
|
335
|
-
} =
|
|
407
|
+
} = _ref9;
|
|
336
408
|
|
|
337
409
|
// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
|
|
338
410
|
if (!hasBlockGapSupport && 'flex' !== name) {
|
|
@@ -344,8 +416,8 @@ export function getLayoutStyles(_ref6) {
|
|
|
344
416
|
const declarations = [];
|
|
345
417
|
|
|
346
418
|
if (spacingStyle.rules) {
|
|
347
|
-
Object.entries(spacingStyle.rules).forEach(
|
|
348
|
-
let [cssProperty, cssValue] =
|
|
419
|
+
Object.entries(spacingStyle.rules).forEach(_ref10 => {
|
|
420
|
+
let [cssProperty, cssValue] = _ref10;
|
|
349
421
|
declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
|
|
350
422
|
});
|
|
351
423
|
}
|
|
@@ -357,7 +429,7 @@ export function getLayoutStyles(_ref6) {
|
|
|
357
429
|
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
358
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) || ''})`;
|
|
359
431
|
} else {
|
|
360
|
-
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}
|
|
432
|
+
combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}-${className}${selector}-${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
|
|
361
433
|
}
|
|
362
434
|
|
|
363
435
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
@@ -374,12 +446,12 @@ export function getLayoutStyles(_ref6) {
|
|
|
374
446
|
|
|
375
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) {
|
|
376
448
|
const validDisplayModes = ['block', 'flex', 'grid'];
|
|
377
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
449
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref11 => {
|
|
378
450
|
let {
|
|
379
451
|
className,
|
|
380
452
|
displayMode,
|
|
381
453
|
baseStyles
|
|
382
|
-
} =
|
|
454
|
+
} = _ref11;
|
|
383
455
|
|
|
384
456
|
if (displayMode && validDisplayModes.includes(displayMode)) {
|
|
385
457
|
ruleset += `${selector} .${className} { display:${displayMode}; }`;
|
|
@@ -390,8 +462,8 @@ export function getLayoutStyles(_ref6) {
|
|
|
390
462
|
const declarations = [];
|
|
391
463
|
|
|
392
464
|
if (baseStyle.rules) {
|
|
393
|
-
Object.entries(baseStyle.rules).forEach(
|
|
394
|
-
let [cssProperty, cssValue] =
|
|
465
|
+
Object.entries(baseStyle.rules).forEach(_ref12 => {
|
|
466
|
+
let [cssProperty, cssValue] = _ref12;
|
|
395
467
|
declarations.push(`${cssProperty}: ${cssValue}`);
|
|
396
468
|
});
|
|
397
469
|
}
|
|
@@ -416,8 +488,8 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
416
488
|
return nodes;
|
|
417
489
|
}
|
|
418
490
|
|
|
419
|
-
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(
|
|
420
|
-
let [key] =
|
|
491
|
+
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref13 => {
|
|
492
|
+
let [key] = _ref13;
|
|
421
493
|
return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
|
|
422
494
|
})); // Top-level.
|
|
423
495
|
|
|
@@ -431,25 +503,25 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
431
503
|
});
|
|
432
504
|
}
|
|
433
505
|
|
|
434
|
-
Object.entries(ELEMENTS).forEach(
|
|
435
|
-
var _tree$styles;
|
|
506
|
+
Object.entries(ELEMENTS).forEach(_ref14 => {
|
|
507
|
+
var _tree$styles, _tree$styles$elements;
|
|
436
508
|
|
|
437
|
-
let [name, selector] =
|
|
509
|
+
let [name, selector] = _ref14;
|
|
438
510
|
|
|
439
|
-
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
440
|
-
var _tree$styles2;
|
|
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])) {
|
|
512
|
+
var _tree$styles2, _tree$styles2$element;
|
|
441
513
|
|
|
442
514
|
nodes.push({
|
|
443
|
-
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
|
|
515
|
+
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : (_tree$styles2$element = _tree$styles2.elements) === null || _tree$styles2$element === void 0 ? void 0 : _tree$styles2$element[name],
|
|
444
516
|
selector
|
|
445
517
|
});
|
|
446
518
|
}
|
|
447
519
|
}); // Iterate over blocks: they can have styles & elements.
|
|
448
520
|
|
|
449
|
-
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 => {
|
|
450
522
|
var _blockSelectors$block, _node$elements;
|
|
451
523
|
|
|
452
|
-
let [blockName, node] =
|
|
524
|
+
let [blockName, node] = _ref15;
|
|
453
525
|
const blockStyles = pickStyleKeys(node);
|
|
454
526
|
|
|
455
527
|
if (node !== null && node !== void 0 && node.variations) {
|
|
@@ -461,24 +533,28 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
461
533
|
}
|
|
462
534
|
|
|
463
535
|
if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
|
|
536
|
+
var _blockSelectors$block2;
|
|
537
|
+
|
|
464
538
|
nodes.push({
|
|
465
539
|
duotoneSelector: blockSelectors[blockName].duotoneSelector,
|
|
466
540
|
fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
|
|
467
541
|
hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
|
|
468
|
-
selector: blockSelectors[blockName].selector,
|
|
542
|
+
selector: (_blockSelectors$block2 = blockSelectors[blockName]) === null || _blockSelectors$block2 === void 0 ? void 0 : _blockSelectors$block2.selector,
|
|
469
543
|
styles: blockStyles,
|
|
470
544
|
featureSelectors: blockSelectors[blockName].featureSelectors,
|
|
471
545
|
styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors
|
|
472
546
|
});
|
|
473
547
|
}
|
|
474
548
|
|
|
475
|
-
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(
|
|
476
|
-
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;
|
|
477
551
|
|
|
478
552
|
if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(ELEMENTS !== null && ELEMENTS !== void 0 && ELEMENTS[elementName])) {
|
|
553
|
+
var _blockSelectors$block3;
|
|
554
|
+
|
|
479
555
|
nodes.push({
|
|
480
556
|
styles: value,
|
|
481
|
-
selector: blockSelectors[blockName].selector.split(',').map(sel => {
|
|
557
|
+
selector: (_blockSelectors$block3 = blockSelectors[blockName]) === null || _blockSelectors$block3 === void 0 ? void 0 : _blockSelectors$block3.selector.split(',').map(sel => {
|
|
482
558
|
const elementSelectors = ELEMENTS[elementName].split(',');
|
|
483
559
|
return elementSelectors.map(elementSelector => sel + ' ' + elementSelector);
|
|
484
560
|
}).join(',')
|
|
@@ -499,10 +575,10 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
499
575
|
|
|
500
576
|
const pickPresets = treeToPickFrom => {
|
|
501
577
|
const presets = {};
|
|
502
|
-
PRESET_METADATA.forEach(
|
|
578
|
+
PRESET_METADATA.forEach(_ref17 => {
|
|
503
579
|
let {
|
|
504
580
|
path
|
|
505
|
-
} =
|
|
581
|
+
} = _ref17;
|
|
506
582
|
const value = get(treeToPickFrom, path, false);
|
|
507
583
|
|
|
508
584
|
if (value !== false) {
|
|
@@ -525,16 +601,18 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
525
601
|
} // Blocks.
|
|
526
602
|
|
|
527
603
|
|
|
528
|
-
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(
|
|
529
|
-
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;
|
|
530
606
|
const blockPresets = pickPresets(node);
|
|
531
607
|
const blockCustom = node.custom;
|
|
532
608
|
|
|
533
609
|
if (!isEmpty(blockPresets) || !!blockCustom) {
|
|
610
|
+
var _blockSelectors$block4;
|
|
611
|
+
|
|
534
612
|
nodes.push({
|
|
535
613
|
presets: blockPresets,
|
|
536
614
|
custom: blockCustom,
|
|
537
|
-
selector: blockSelectors[blockName].selector
|
|
615
|
+
selector: (_blockSelectors$block4 = blockSelectors[blockName]) === null || _blockSelectors$block4 === void 0 ? void 0 : _blockSelectors$block4.selector
|
|
538
616
|
});
|
|
539
617
|
}
|
|
540
618
|
});
|
|
@@ -543,12 +621,12 @@ export const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
543
621
|
export const toCustomProperties = (tree, blockSelectors) => {
|
|
544
622
|
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
545
623
|
let ruleset = '';
|
|
546
|
-
settings.forEach(
|
|
624
|
+
settings.forEach(_ref19 => {
|
|
547
625
|
let {
|
|
548
626
|
presets,
|
|
549
627
|
custom,
|
|
550
628
|
selector
|
|
551
|
-
} =
|
|
629
|
+
} = _ref19;
|
|
552
630
|
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
553
631
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
554
632
|
|
|
@@ -607,7 +685,7 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
607
685
|
}
|
|
608
686
|
|
|
609
687
|
ruleset += '}';
|
|
610
|
-
nodesWithStyles.forEach(
|
|
688
|
+
nodesWithStyles.forEach(_ref20 => {
|
|
611
689
|
let {
|
|
612
690
|
selector,
|
|
613
691
|
duotoneSelector,
|
|
@@ -616,54 +694,43 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
616
694
|
hasLayoutSupport,
|
|
617
695
|
featureSelectors,
|
|
618
696
|
styleVariationSelectors
|
|
619
|
-
} =
|
|
697
|
+
} = _ref20;
|
|
620
698
|
|
|
621
699
|
// Process styles for block support features with custom feature level
|
|
622
700
|
// CSS selectors set.
|
|
623
701
|
if (featureSelectors) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
632
|
-
delete styles[featureName];
|
|
633
|
-
|
|
634
|
-
if (!!featureDeclarations.length) {
|
|
635
|
-
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
636
|
-
}
|
|
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}}`;
|
|
637
709
|
}
|
|
638
710
|
});
|
|
639
711
|
}
|
|
640
712
|
|
|
641
713
|
if (styleVariationSelectors) {
|
|
642
|
-
Object.entries(styleVariationSelectors).forEach(
|
|
714
|
+
Object.entries(styleVariationSelectors).forEach(_ref22 => {
|
|
643
715
|
var _styles$variations;
|
|
644
716
|
|
|
645
|
-
let [styleVariationName, styleVariationSelector] =
|
|
717
|
+
let [styleVariationName, styleVariationSelector] = _ref22;
|
|
646
718
|
|
|
647
719
|
if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
|
|
648
720
|
var _styles$variations3;
|
|
649
721
|
|
|
650
722
|
// If the block uses any custom selectors for block support, add those first.
|
|
651
723
|
if (featureSelectors) {
|
|
652
|
-
|
|
653
|
-
var _styles$variations2, _styles$variations2$s;
|
|
654
|
-
|
|
655
|
-
let [featureName, featureSelector] = _ref21;
|
|
724
|
+
var _styles$variations2;
|
|
656
725
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
};
|
|
661
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
662
|
-
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;
|
|
663
729
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
730
|
+
if (!!declarations.length) {
|
|
731
|
+
const cssSelector = concatFeatureVariationSelectorString(baseSelector, styleVariationSelector);
|
|
732
|
+
const rules = declarations.join(';');
|
|
733
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
667
734
|
}
|
|
668
735
|
});
|
|
669
736
|
} // Otherwise add regular selectors.
|
|
@@ -714,14 +781,14 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
714
781
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
715
782
|
|
|
716
783
|
|
|
717
|
-
const pseudoSelectorStyles = Object.entries(styles).filter(
|
|
718
|
-
let [key] =
|
|
784
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref24 => {
|
|
785
|
+
let [key] = _ref24;
|
|
719
786
|
return key.startsWith(':');
|
|
720
787
|
});
|
|
721
788
|
|
|
722
789
|
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
723
|
-
pseudoSelectorStyles.forEach(
|
|
724
|
-
let [pseudoKey, pseudoStyle] =
|
|
790
|
+
pseudoSelectorStyles.forEach(_ref25 => {
|
|
791
|
+
let [pseudoKey, pseudoStyle] = _ref25;
|
|
725
792
|
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
726
793
|
|
|
727
794
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
@@ -757,11 +824,11 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
757
824
|
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
758
825
|
}
|
|
759
826
|
|
|
760
|
-
nodesWithSettings.forEach(
|
|
827
|
+
nodesWithSettings.forEach(_ref26 => {
|
|
761
828
|
let {
|
|
762
829
|
selector,
|
|
763
830
|
presets
|
|
764
|
-
} =
|
|
831
|
+
} = _ref26;
|
|
765
832
|
|
|
766
833
|
if (ROOT_BLOCK_SELECTOR === selector) {
|
|
767
834
|
// Do not add extra specificity for top-level classes.
|
|
@@ -778,23 +845,43 @@ export const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasF
|
|
|
778
845
|
};
|
|
779
846
|
export function toSvgFilters(tree, blockSelectors) {
|
|
780
847
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
781
|
-
return nodesWithSettings.flatMap(
|
|
848
|
+
return nodesWithSettings.flatMap(_ref27 => {
|
|
782
849
|
let {
|
|
783
850
|
presets
|
|
784
|
-
} =
|
|
851
|
+
} = _ref27;
|
|
785
852
|
return getPresetsSvgFilters(presets);
|
|
786
853
|
});
|
|
787
854
|
}
|
|
855
|
+
|
|
856
|
+
const getSelectorsConfig = (blockType, rootSelector) => {
|
|
857
|
+
if (!isEmpty(blockType === null || blockType === void 0 ? void 0 : blockType.selectors)) {
|
|
858
|
+
return blockType.selectors;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const config = {
|
|
862
|
+
root: rootSelector
|
|
863
|
+
};
|
|
864
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref28 => {
|
|
865
|
+
let [featureKey, featureName] = _ref28;
|
|
866
|
+
const featureSelector = getBlockCSSSelector(blockType, featureKey);
|
|
867
|
+
|
|
868
|
+
if (featureSelector) {
|
|
869
|
+
config[featureName] = featureSelector;
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
return config;
|
|
873
|
+
};
|
|
874
|
+
|
|
788
875
|
export const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
789
876
|
const result = {};
|
|
790
877
|
blockTypes.forEach(blockType => {
|
|
791
|
-
var _blockType$supports
|
|
878
|
+
var _blockType$supports, _blockType$supports2, _blockType$supports2$, _blockType$supports2$2;
|
|
792
879
|
|
|
793
880
|
const name = blockType.name;
|
|
794
|
-
const selector = (
|
|
795
|
-
const duotoneSelector = (
|
|
796
|
-
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$
|
|
797
|
-
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$
|
|
881
|
+
const selector = getBlockCSSSelector(blockType, 'root');
|
|
882
|
+
const duotoneSelector = getBlockCSSSelector(blockType, 'filter.duotone');
|
|
883
|
+
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && _blockType$supports.__experimentalLayout);
|
|
884
|
+
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;
|
|
798
885
|
const blockStyleVariations = getBlockStyles(name);
|
|
799
886
|
const styleVariationSelectors = {};
|
|
800
887
|
|
|
@@ -806,17 +893,7 @@ export const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
|
806
893
|
} // For each block support feature add any custom selectors.
|
|
807
894
|
|
|
808
895
|
|
|
809
|
-
const featureSelectors =
|
|
810
|
-
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
|
|
811
|
-
var _blockType$supports5, _blockType$supports5$;
|
|
812
|
-
|
|
813
|
-
let [featureKey, featureName] = _ref26;
|
|
814
|
-
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;
|
|
815
|
-
|
|
816
|
-
if (featureSelector) {
|
|
817
|
-
featureSelectors[featureName] = scopeSelector(selector, featureSelector);
|
|
818
|
-
}
|
|
819
|
-
});
|
|
896
|
+
const featureSelectors = getSelectorsConfig(blockType, selector);
|
|
820
897
|
result[name] = {
|
|
821
898
|
duotoneSelector,
|
|
822
899
|
fallbackGapValue,
|
|
@@ -838,9 +915,9 @@ export const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
|
838
915
|
*/
|
|
839
916
|
|
|
840
917
|
function updateConfigWithSeparator(config) {
|
|
841
|
-
var _config$styles, _config$styles2, _config$styles2$block, _config$styles3, _config$styles3$block, _config$styles4, _config$styles4$block;
|
|
918
|
+
var _config$styles, _config$styles$blocks, _config$styles2, _config$styles2$block, _config$styles2$block2, _config$styles3, _config$styles3$block, _config$styles3$block2, _config$styles4, _config$styles4$block, _config$styles4$block2;
|
|
842
919
|
|
|
843
|
-
const needsSeparatorStyleUpdate = ((_config$styles = config.styles) === null || _config$styles === void 0 ? void 0 : _config$styles.blocks['core/separator']) && ((_config$styles2 = config.styles) === null || _config$styles2 === void 0 ? void 0 : (_config$styles2$block = _config$styles2.blocks['core/separator'].color) === null || _config$styles2$
|
|
920
|
+
const needsSeparatorStyleUpdate = ((_config$styles = config.styles) === null || _config$styles === void 0 ? void 0 : (_config$styles$blocks = _config$styles.blocks) === null || _config$styles$blocks === void 0 ? void 0 : _config$styles$blocks['core/separator']) && ((_config$styles2 = config.styles) === null || _config$styles2 === void 0 ? void 0 : (_config$styles2$block = _config$styles2.blocks) === null || _config$styles2$block === void 0 ? void 0 : (_config$styles2$block2 = _config$styles2$block['core/separator'].color) === null || _config$styles2$block2 === void 0 ? void 0 : _config$styles2$block2.background) && !((_config$styles3 = config.styles) !== null && _config$styles3 !== void 0 && (_config$styles3$block = _config$styles3.blocks) !== null && _config$styles3$block !== void 0 && (_config$styles3$block2 = _config$styles3$block['core/separator'].color) !== null && _config$styles3$block2 !== void 0 && _config$styles3$block2.text) && !((_config$styles4 = config.styles) !== null && _config$styles4 !== void 0 && (_config$styles4$block = _config$styles4.blocks) !== null && _config$styles4$block !== void 0 && (_config$styles4$block2 = _config$styles4$block['core/separator'].border) !== null && _config$styles4$block2 !== void 0 && _config$styles4$block2.color);
|
|
844
921
|
|
|
845
922
|
if (needsSeparatorStyleUpdate) {
|
|
846
923
|
var _config$styles5;
|
|
@@ -900,8 +977,8 @@ export function useGlobalStylesOutput() {
|
|
|
900
977
|
const blockSelectors = getBlockSelectors(getBlockTypes(), getBlockStyles);
|
|
901
978
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
902
979
|
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
903
|
-
const
|
|
904
|
-
const
|
|
980
|
+
const svgs = toSvgFilters(mergedConfig, blockSelectors);
|
|
981
|
+
const styles = [{
|
|
905
982
|
css: customProperties,
|
|
906
983
|
isGlobalStyles: true
|
|
907
984
|
}, {
|
|
@@ -911,6 +988,10 @@ export function useGlobalStylesOutput() {
|
|
|
911
988
|
{
|
|
912
989
|
css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
|
|
913
990
|
isGlobalStyles: true
|
|
991
|
+
}, {
|
|
992
|
+
assets: svgs,
|
|
993
|
+
__unstableType: 'svg',
|
|
994
|
+
isGlobalStyles: true
|
|
914
995
|
}]; // Loop through the blocks to check if there are custom CSS values.
|
|
915
996
|
// If there are, get the block selector and push the selector together with
|
|
916
997
|
// the CSS value to the 'stylesheets' array.
|
|
@@ -922,13 +1003,13 @@ export function useGlobalStylesOutput() {
|
|
|
922
1003
|
var _mergedConfig$styles$3;
|
|
923
1004
|
|
|
924
1005
|
const selector = blockSelectors[blockType.name].selector;
|
|
925
|
-
|
|
1006
|
+
styles.push({
|
|
926
1007
|
css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
|
|
927
1008
|
isGlobalStyles: true
|
|
928
1009
|
});
|
|
929
1010
|
}
|
|
930
1011
|
});
|
|
931
|
-
return [
|
|
1012
|
+
return [styles, mergedConfig.settings];
|
|
932
1013
|
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
933
1014
|
}
|
|
934
1015
|
//# sourceMappingURL=use-global-styles-output.js.map
|