@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
|
@@ -23,6 +23,8 @@ var _styleEngine = require("@wordpress/style-engine");
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("./utils");
|
|
25
25
|
|
|
26
|
+
var _getBlockCssSelector = require("./get-block-css-selector");
|
|
27
|
+
|
|
26
28
|
var _typographyUtils = require("./typography-utils");
|
|
27
29
|
|
|
28
30
|
var _context = require("./context");
|
|
@@ -107,13 +109,14 @@ function getPresetsDeclarations() {
|
|
|
107
109
|
/**
|
|
108
110
|
* Transform given preset tree into a set of preset class declarations.
|
|
109
111
|
*
|
|
110
|
-
* @param {string} blockSelector
|
|
111
|
-
* @param {Object}
|
|
112
|
+
* @param {?string} blockSelector
|
|
113
|
+
* @param {Object} blockPresets
|
|
112
114
|
* @return {string} CSS declarations for the preset classes.
|
|
113
115
|
*/
|
|
114
116
|
|
|
115
117
|
|
|
116
|
-
function getPresetsClasses(
|
|
118
|
+
function getPresetsClasses() {
|
|
119
|
+
let blockSelector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*';
|
|
117
120
|
let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
118
121
|
return _utils.PRESET_METADATA.reduce((declarations, _ref2) => {
|
|
119
122
|
let {
|
|
@@ -156,10 +159,10 @@ function getPresetsSvgFilters() {
|
|
|
156
159
|
return _utils.PRESET_METADATA.filter( // Duotone are the only type of filters for now.
|
|
157
160
|
metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
|
|
158
161
|
const presetByOrigin = (0, _lodash.get)(blockPresets, metadata.path, {});
|
|
159
|
-
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0, _element.createElement)(_components.PresetDuotoneFilter, {
|
|
162
|
+
return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0, _element.renderToString)((0, _element.createElement)(_components.PresetDuotoneFilter, {
|
|
160
163
|
preset: preset,
|
|
161
164
|
key: preset.slug
|
|
162
|
-
})));
|
|
165
|
+
})))).join('');
|
|
163
166
|
});
|
|
164
167
|
}
|
|
165
168
|
|
|
@@ -200,6 +203,76 @@ function concatFeatureVariationSelectorString(featureSelector, styleVariationSel
|
|
|
200
203
|
});
|
|
201
204
|
return combinedSelectors.join(', ');
|
|
202
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Generate style declarations for a block's custom feature and subfeature
|
|
208
|
+
* selectors.
|
|
209
|
+
*
|
|
210
|
+
* NOTE: The passed `styles` object will be mutated by this function.
|
|
211
|
+
*
|
|
212
|
+
* @param {Object} selectors Custom selectors object for a block.
|
|
213
|
+
* @param {Object} styles A block's styles object.
|
|
214
|
+
*
|
|
215
|
+
* @return {Object} Style declarations.
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
const getFeatureDeclarations = (selectors, styles) => {
|
|
220
|
+
const declarations = {};
|
|
221
|
+
Object.entries(selectors).forEach(_ref5 => {
|
|
222
|
+
let [feature, selector] = _ref5;
|
|
223
|
+
|
|
224
|
+
// We're only processing features/subfeatures that have styles.
|
|
225
|
+
if (feature === 'root' || !(styles !== null && styles !== void 0 && styles[feature])) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const isShorthand = typeof selector === 'string'; // If we have a selector object instead of shorthand process it.
|
|
230
|
+
|
|
231
|
+
if (!isShorthand) {
|
|
232
|
+
Object.entries(selector).forEach(_ref6 => {
|
|
233
|
+
let [subfeature, subfeatureSelector] = _ref6;
|
|
234
|
+
|
|
235
|
+
// Don't process root feature selector yet or any
|
|
236
|
+
// subfeature that doesn't have a style.
|
|
237
|
+
if (subfeature === 'root' || !(styles !== null && styles !== void 0 && styles[feature][subfeature])) {
|
|
238
|
+
return;
|
|
239
|
+
} // Create a temporary styles object and build
|
|
240
|
+
// declarations for subfeature.
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
const subfeatureStyles = {
|
|
244
|
+
[feature]: {
|
|
245
|
+
[subfeature]: styles[feature][subfeature]
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
const newDeclarations = getStylesDeclarations(subfeatureStyles); // Merge new declarations in with any others that
|
|
249
|
+
// share the same selector.
|
|
250
|
+
|
|
251
|
+
declarations[subfeatureSelector] = [...(declarations[subfeatureSelector] || []), ...newDeclarations]; // Remove the subfeature's style now it will be
|
|
252
|
+
// included under its own selector not the block's.
|
|
253
|
+
|
|
254
|
+
delete styles[feature][subfeature];
|
|
255
|
+
});
|
|
256
|
+
} // Now subfeatures have been processed and removed, we can
|
|
257
|
+
// process root, or shorthand, feature selectors.
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if (isShorthand || selector.root) {
|
|
261
|
+
const featureSelector = isShorthand ? selector : selector.root; // Create temporary style object and build declarations for feature.
|
|
262
|
+
|
|
263
|
+
const featureStyles = {
|
|
264
|
+
[feature]: styles[feature]
|
|
265
|
+
};
|
|
266
|
+
const newDeclarations = getStylesDeclarations(featureStyles); // Merge new declarations with any others that share the selector.
|
|
267
|
+
|
|
268
|
+
declarations[featureSelector] = [...(declarations[featureSelector] || []), ...newDeclarations]; // Remove the feature from the block's styles now as it will be
|
|
269
|
+
// included under its own selector not the block's.
|
|
270
|
+
|
|
271
|
+
delete styles[feature];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return declarations;
|
|
275
|
+
};
|
|
203
276
|
/**
|
|
204
277
|
* Transform given style tree into a set of style declarations.
|
|
205
278
|
*
|
|
@@ -221,13 +294,13 @@ function getStylesDeclarations() {
|
|
|
221
294
|
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
222
295
|
let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
223
296
|
const isRoot = _utils.ROOT_BLOCK_SELECTOR === selector;
|
|
224
|
-
const output = Object.entries(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations,
|
|
297
|
+
const output = Object.entries(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations, _ref7) => {
|
|
225
298
|
let [key, {
|
|
226
299
|
value,
|
|
227
300
|
properties,
|
|
228
301
|
useEngine,
|
|
229
302
|
rootOnly
|
|
230
|
-
}] =
|
|
303
|
+
}] = _ref7;
|
|
231
304
|
|
|
232
305
|
if (rootOnly && !isRoot) {
|
|
233
306
|
return declarations;
|
|
@@ -327,7 +400,7 @@ function getStylesDeclarations() {
|
|
|
327
400
|
*/
|
|
328
401
|
|
|
329
402
|
|
|
330
|
-
function getLayoutStyles(
|
|
403
|
+
function getLayoutStyles(_ref8) {
|
|
331
404
|
var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
|
|
332
405
|
|
|
333
406
|
let {
|
|
@@ -337,7 +410,7 @@ function getLayoutStyles(_ref6) {
|
|
|
337
410
|
hasBlockGapSupport,
|
|
338
411
|
hasFallbackGapSupport,
|
|
339
412
|
fallbackGapValue
|
|
340
|
-
} =
|
|
413
|
+
} = _ref8;
|
|
341
414
|
let ruleset = '';
|
|
342
415
|
let gapValue = hasBlockGapSupport ? (0, _gap.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,
|
|
343
416
|
// and use a fallback value if one is provided for the current block.
|
|
@@ -351,12 +424,12 @@ function getLayoutStyles(_ref6) {
|
|
|
351
424
|
}
|
|
352
425
|
|
|
353
426
|
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) {
|
|
354
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
427
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
|
|
355
428
|
let {
|
|
356
429
|
className,
|
|
357
430
|
name,
|
|
358
431
|
spacingStyles
|
|
359
|
-
} =
|
|
432
|
+
} = _ref9;
|
|
360
433
|
|
|
361
434
|
// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
|
|
362
435
|
if (!hasBlockGapSupport && 'flex' !== name) {
|
|
@@ -368,8 +441,8 @@ function getLayoutStyles(_ref6) {
|
|
|
368
441
|
const declarations = [];
|
|
369
442
|
|
|
370
443
|
if (spacingStyle.rules) {
|
|
371
|
-
Object.entries(spacingStyle.rules).forEach(
|
|
372
|
-
let [cssProperty, cssValue] =
|
|
444
|
+
Object.entries(spacingStyle.rules).forEach(_ref10 => {
|
|
445
|
+
let [cssProperty, cssValue] = _ref10;
|
|
373
446
|
declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
|
|
374
447
|
});
|
|
375
448
|
}
|
|
@@ -381,7 +454,7 @@ function getLayoutStyles(_ref6) {
|
|
|
381
454
|
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
382
455
|
combinedSelector = selector === _utils.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) || ''})`;
|
|
383
456
|
} else {
|
|
384
|
-
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}
|
|
457
|
+
combinedSelector = selector === _utils.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) || ''}`;
|
|
385
458
|
}
|
|
386
459
|
|
|
387
460
|
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
@@ -398,12 +471,12 @@ function getLayoutStyles(_ref6) {
|
|
|
398
471
|
|
|
399
472
|
if (selector === _utils.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) {
|
|
400
473
|
const validDisplayModes = ['block', 'flex', 'grid'];
|
|
401
|
-
Object.values(tree.settings.layout.definitions).forEach(
|
|
474
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref11 => {
|
|
402
475
|
let {
|
|
403
476
|
className,
|
|
404
477
|
displayMode,
|
|
405
478
|
baseStyles
|
|
406
|
-
} =
|
|
479
|
+
} = _ref11;
|
|
407
480
|
|
|
408
481
|
if (displayMode && validDisplayModes.includes(displayMode)) {
|
|
409
482
|
ruleset += `${selector} .${className} { display:${displayMode}; }`;
|
|
@@ -414,8 +487,8 @@ function getLayoutStyles(_ref6) {
|
|
|
414
487
|
const declarations = [];
|
|
415
488
|
|
|
416
489
|
if (baseStyle.rules) {
|
|
417
|
-
Object.entries(baseStyle.rules).forEach(
|
|
418
|
-
let [cssProperty, cssValue] =
|
|
490
|
+
Object.entries(baseStyle.rules).forEach(_ref12 => {
|
|
491
|
+
let [cssProperty, cssValue] = _ref12;
|
|
419
492
|
declarations.push(`${cssProperty}: ${cssValue}`);
|
|
420
493
|
});
|
|
421
494
|
}
|
|
@@ -441,8 +514,8 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
441
514
|
return nodes;
|
|
442
515
|
}
|
|
443
516
|
|
|
444
|
-
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(
|
|
445
|
-
let [key] =
|
|
517
|
+
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref13 => {
|
|
518
|
+
let [key] = _ref13;
|
|
446
519
|
return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
|
|
447
520
|
})); // Top-level.
|
|
448
521
|
|
|
@@ -456,25 +529,25 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
456
529
|
});
|
|
457
530
|
}
|
|
458
531
|
|
|
459
|
-
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(
|
|
460
|
-
var _tree$styles;
|
|
532
|
+
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(_ref14 => {
|
|
533
|
+
var _tree$styles, _tree$styles$elements;
|
|
461
534
|
|
|
462
|
-
let [name, selector] =
|
|
535
|
+
let [name, selector] = _ref14;
|
|
463
536
|
|
|
464
|
-
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
465
|
-
var _tree$styles2;
|
|
537
|
+
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])) {
|
|
538
|
+
var _tree$styles2, _tree$styles2$element;
|
|
466
539
|
|
|
467
540
|
nodes.push({
|
|
468
|
-
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
|
|
541
|
+
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],
|
|
469
542
|
selector
|
|
470
543
|
});
|
|
471
544
|
}
|
|
472
545
|
}); // Iterate over blocks: they can have styles & elements.
|
|
473
546
|
|
|
474
|
-
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(
|
|
547
|
+
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 => {
|
|
475
548
|
var _blockSelectors$block, _node$elements;
|
|
476
549
|
|
|
477
|
-
let [blockName, node] =
|
|
550
|
+
let [blockName, node] = _ref15;
|
|
478
551
|
const blockStyles = pickStyleKeys(node);
|
|
479
552
|
|
|
480
553
|
if (node !== null && node !== void 0 && node.variations) {
|
|
@@ -486,24 +559,28 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
486
559
|
}
|
|
487
560
|
|
|
488
561
|
if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
|
|
562
|
+
var _blockSelectors$block2;
|
|
563
|
+
|
|
489
564
|
nodes.push({
|
|
490
565
|
duotoneSelector: blockSelectors[blockName].duotoneSelector,
|
|
491
566
|
fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
|
|
492
567
|
hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
|
|
493
|
-
selector: blockSelectors[blockName].selector,
|
|
568
|
+
selector: (_blockSelectors$block2 = blockSelectors[blockName]) === null || _blockSelectors$block2 === void 0 ? void 0 : _blockSelectors$block2.selector,
|
|
494
569
|
styles: blockStyles,
|
|
495
570
|
featureSelectors: blockSelectors[blockName].featureSelectors,
|
|
496
571
|
styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors
|
|
497
572
|
});
|
|
498
573
|
}
|
|
499
574
|
|
|
500
|
-
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(
|
|
501
|
-
let [elementName, value] =
|
|
575
|
+
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref16 => {
|
|
576
|
+
let [elementName, value] = _ref16;
|
|
502
577
|
|
|
503
578
|
if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(_blocks.__EXPERIMENTAL_ELEMENTS !== null && _blocks.__EXPERIMENTAL_ELEMENTS !== void 0 && _blocks.__EXPERIMENTAL_ELEMENTS[elementName])) {
|
|
579
|
+
var _blockSelectors$block3;
|
|
580
|
+
|
|
504
581
|
nodes.push({
|
|
505
582
|
styles: value,
|
|
506
|
-
selector: blockSelectors[blockName].selector.split(',').map(sel => {
|
|
583
|
+
selector: (_blockSelectors$block3 = blockSelectors[blockName]) === null || _blockSelectors$block3 === void 0 ? void 0 : _blockSelectors$block3.selector.split(',').map(sel => {
|
|
507
584
|
const elementSelectors = _blocks.__EXPERIMENTAL_ELEMENTS[elementName].split(',');
|
|
508
585
|
|
|
509
586
|
return elementSelectors.map(elementSelector => sel + ' ' + elementSelector);
|
|
@@ -529,10 +606,10 @@ const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
529
606
|
const pickPresets = treeToPickFrom => {
|
|
530
607
|
const presets = {};
|
|
531
608
|
|
|
532
|
-
_utils.PRESET_METADATA.forEach(
|
|
609
|
+
_utils.PRESET_METADATA.forEach(_ref17 => {
|
|
533
610
|
let {
|
|
534
611
|
path
|
|
535
|
-
} =
|
|
612
|
+
} = _ref17;
|
|
536
613
|
const value = (0, _lodash.get)(treeToPickFrom, path, false);
|
|
537
614
|
|
|
538
615
|
if (value !== false) {
|
|
@@ -556,16 +633,18 @@ const getNodesWithSettings = (tree, blockSelectors) => {
|
|
|
556
633
|
} // Blocks.
|
|
557
634
|
|
|
558
635
|
|
|
559
|
-
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(
|
|
560
|
-
let [blockName, node] =
|
|
636
|
+
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 => {
|
|
637
|
+
let [blockName, node] = _ref18;
|
|
561
638
|
const blockPresets = pickPresets(node);
|
|
562
639
|
const blockCustom = node.custom;
|
|
563
640
|
|
|
564
641
|
if (!(0, _lodash.isEmpty)(blockPresets) || !!blockCustom) {
|
|
642
|
+
var _blockSelectors$block4;
|
|
643
|
+
|
|
565
644
|
nodes.push({
|
|
566
645
|
presets: blockPresets,
|
|
567
646
|
custom: blockCustom,
|
|
568
|
-
selector: blockSelectors[blockName].selector
|
|
647
|
+
selector: (_blockSelectors$block4 = blockSelectors[blockName]) === null || _blockSelectors$block4 === void 0 ? void 0 : _blockSelectors$block4.selector
|
|
569
648
|
});
|
|
570
649
|
}
|
|
571
650
|
});
|
|
@@ -577,12 +656,12 @@ exports.getNodesWithSettings = getNodesWithSettings;
|
|
|
577
656
|
const toCustomProperties = (tree, blockSelectors) => {
|
|
578
657
|
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
579
658
|
let ruleset = '';
|
|
580
|
-
settings.forEach(
|
|
659
|
+
settings.forEach(_ref19 => {
|
|
581
660
|
let {
|
|
582
661
|
presets,
|
|
583
662
|
custom,
|
|
584
663
|
selector
|
|
585
|
-
} =
|
|
664
|
+
} = _ref19;
|
|
586
665
|
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
587
666
|
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
588
667
|
|
|
@@ -644,7 +723,7 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
644
723
|
}
|
|
645
724
|
|
|
646
725
|
ruleset += '}';
|
|
647
|
-
nodesWithStyles.forEach(
|
|
726
|
+
nodesWithStyles.forEach(_ref20 => {
|
|
648
727
|
let {
|
|
649
728
|
selector,
|
|
650
729
|
duotoneSelector,
|
|
@@ -653,54 +732,43 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
653
732
|
hasLayoutSupport,
|
|
654
733
|
featureSelectors,
|
|
655
734
|
styleVariationSelectors
|
|
656
|
-
} =
|
|
735
|
+
} = _ref20;
|
|
657
736
|
|
|
658
737
|
// Process styles for block support features with custom feature level
|
|
659
738
|
// CSS selectors set.
|
|
660
739
|
if (featureSelectors) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
669
|
-
delete styles[featureName];
|
|
670
|
-
|
|
671
|
-
if (!!featureDeclarations.length) {
|
|
672
|
-
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
673
|
-
}
|
|
740
|
+
const featureDeclarations = getFeatureDeclarations(featureSelectors, styles);
|
|
741
|
+
Object.entries(featureDeclarations).forEach(_ref21 => {
|
|
742
|
+
let [cssSelector, declarations] = _ref21;
|
|
743
|
+
|
|
744
|
+
if (!!declarations.length) {
|
|
745
|
+
const rules = declarations.join(';');
|
|
746
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
674
747
|
}
|
|
675
748
|
});
|
|
676
749
|
}
|
|
677
750
|
|
|
678
751
|
if (styleVariationSelectors) {
|
|
679
|
-
Object.entries(styleVariationSelectors).forEach(
|
|
752
|
+
Object.entries(styleVariationSelectors).forEach(_ref22 => {
|
|
680
753
|
var _styles$variations;
|
|
681
754
|
|
|
682
|
-
let [styleVariationName, styleVariationSelector] =
|
|
755
|
+
let [styleVariationName, styleVariationSelector] = _ref22;
|
|
683
756
|
|
|
684
757
|
if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
|
|
685
758
|
var _styles$variations3;
|
|
686
759
|
|
|
687
760
|
// If the block uses any custom selectors for block support, add those first.
|
|
688
761
|
if (featureSelectors) {
|
|
689
|
-
|
|
690
|
-
var _styles$variations2, _styles$variations2$s;
|
|
691
|
-
|
|
692
|
-
let [featureName, featureSelector] = _ref21;
|
|
762
|
+
var _styles$variations2;
|
|
693
763
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
};
|
|
698
|
-
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
699
|
-
delete styles.variations[styleVariationName][featureName];
|
|
764
|
+
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]);
|
|
765
|
+
Object.entries(featureDeclarations).forEach(_ref23 => {
|
|
766
|
+
let [baseSelector, declarations] = _ref23;
|
|
700
767
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
768
|
+
if (!!declarations.length) {
|
|
769
|
+
const cssSelector = concatFeatureVariationSelectorString(baseSelector, styleVariationSelector);
|
|
770
|
+
const rules = declarations.join(';');
|
|
771
|
+
ruleset = ruleset + `${cssSelector}{${rules}}`;
|
|
704
772
|
}
|
|
705
773
|
});
|
|
706
774
|
} // Otherwise add regular selectors.
|
|
@@ -751,14 +819,14 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
751
819
|
} // Check for pseudo selector in `styles` and handle separately.
|
|
752
820
|
|
|
753
821
|
|
|
754
|
-
const pseudoSelectorStyles = Object.entries(styles).filter(
|
|
755
|
-
let [key] =
|
|
822
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref24 => {
|
|
823
|
+
let [key] = _ref24;
|
|
756
824
|
return key.startsWith(':');
|
|
757
825
|
});
|
|
758
826
|
|
|
759
827
|
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
760
|
-
pseudoSelectorStyles.forEach(
|
|
761
|
-
let [pseudoKey, pseudoStyle] =
|
|
828
|
+
pseudoSelectorStyles.forEach(_ref25 => {
|
|
829
|
+
let [pseudoKey, pseudoStyle] = _ref25;
|
|
762
830
|
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
763
831
|
|
|
764
832
|
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
@@ -794,11 +862,11 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
|
|
|
794
862
|
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
795
863
|
}
|
|
796
864
|
|
|
797
|
-
nodesWithSettings.forEach(
|
|
865
|
+
nodesWithSettings.forEach(_ref26 => {
|
|
798
866
|
let {
|
|
799
867
|
selector,
|
|
800
868
|
presets
|
|
801
|
-
} =
|
|
869
|
+
} = _ref26;
|
|
802
870
|
|
|
803
871
|
if (_utils.ROOT_BLOCK_SELECTOR === selector) {
|
|
804
872
|
// Do not add extra specificity for top-level classes.
|
|
@@ -818,24 +886,43 @@ exports.toStyles = toStyles;
|
|
|
818
886
|
|
|
819
887
|
function toSvgFilters(tree, blockSelectors) {
|
|
820
888
|
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
821
|
-
return nodesWithSettings.flatMap(
|
|
889
|
+
return nodesWithSettings.flatMap(_ref27 => {
|
|
822
890
|
let {
|
|
823
891
|
presets
|
|
824
|
-
} =
|
|
892
|
+
} = _ref27;
|
|
825
893
|
return getPresetsSvgFilters(presets);
|
|
826
894
|
});
|
|
827
895
|
}
|
|
828
896
|
|
|
897
|
+
const getSelectorsConfig = (blockType, rootSelector) => {
|
|
898
|
+
if (!(0, _lodash.isEmpty)(blockType === null || blockType === void 0 ? void 0 : blockType.selectors)) {
|
|
899
|
+
return blockType.selectors;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const config = {
|
|
903
|
+
root: rootSelector
|
|
904
|
+
};
|
|
905
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref28 => {
|
|
906
|
+
let [featureKey, featureName] = _ref28;
|
|
907
|
+
const featureSelector = (0, _getBlockCssSelector.getBlockCSSSelector)(blockType, featureKey);
|
|
908
|
+
|
|
909
|
+
if (featureSelector) {
|
|
910
|
+
config[featureName] = featureSelector;
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
return config;
|
|
914
|
+
};
|
|
915
|
+
|
|
829
916
|
const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
830
917
|
const result = {};
|
|
831
918
|
blockTypes.forEach(blockType => {
|
|
832
|
-
var _blockType$supports
|
|
919
|
+
var _blockType$supports, _blockType$supports2, _blockType$supports2$, _blockType$supports2$2;
|
|
833
920
|
|
|
834
921
|
const name = blockType.name;
|
|
835
|
-
const selector = (
|
|
836
|
-
const duotoneSelector = (
|
|
837
|
-
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$
|
|
838
|
-
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$
|
|
922
|
+
const selector = (0, _getBlockCssSelector.getBlockCSSSelector)(blockType, 'root');
|
|
923
|
+
const duotoneSelector = (0, _getBlockCssSelector.getBlockCSSSelector)(blockType, 'filter.duotone');
|
|
924
|
+
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && _blockType$supports.__experimentalLayout);
|
|
925
|
+
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;
|
|
839
926
|
const blockStyleVariations = getBlockStyles(name);
|
|
840
927
|
const styleVariationSelectors = {};
|
|
841
928
|
|
|
@@ -847,17 +934,7 @@ const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
|
847
934
|
} // For each block support feature add any custom selectors.
|
|
848
935
|
|
|
849
936
|
|
|
850
|
-
const featureSelectors =
|
|
851
|
-
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
|
|
852
|
-
var _blockType$supports5, _blockType$supports5$;
|
|
853
|
-
|
|
854
|
-
let [featureKey, featureName] = _ref26;
|
|
855
|
-
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;
|
|
856
|
-
|
|
857
|
-
if (featureSelector) {
|
|
858
|
-
featureSelectors[featureName] = (0, _utils.scopeSelector)(selector, featureSelector);
|
|
859
|
-
}
|
|
860
|
-
});
|
|
937
|
+
const featureSelectors = getSelectorsConfig(blockType, selector);
|
|
861
938
|
result[name] = {
|
|
862
939
|
duotoneSelector,
|
|
863
940
|
fallbackGapValue,
|
|
@@ -882,9 +959,9 @@ const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
|
882
959
|
exports.getBlockSelectors = getBlockSelectors;
|
|
883
960
|
|
|
884
961
|
function updateConfigWithSeparator(config) {
|
|
885
|
-
var _config$styles, _config$styles2, _config$styles2$block, _config$styles3, _config$styles3$block, _config$styles4, _config$styles4$block;
|
|
962
|
+
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;
|
|
886
963
|
|
|
887
|
-
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$
|
|
964
|
+
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);
|
|
888
965
|
|
|
889
966
|
if (needsSeparatorStyleUpdate) {
|
|
890
967
|
var _config$styles5;
|
|
@@ -944,8 +1021,8 @@ function useGlobalStylesOutput() {
|
|
|
944
1021
|
const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)(), getBlockStyles);
|
|
945
1022
|
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
946
1023
|
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
947
|
-
const
|
|
948
|
-
const
|
|
1024
|
+
const svgs = toSvgFilters(mergedConfig, blockSelectors);
|
|
1025
|
+
const styles = [{
|
|
949
1026
|
css: customProperties,
|
|
950
1027
|
isGlobalStyles: true
|
|
951
1028
|
}, {
|
|
@@ -955,6 +1032,10 @@ function useGlobalStylesOutput() {
|
|
|
955
1032
|
{
|
|
956
1033
|
css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
|
|
957
1034
|
isGlobalStyles: true
|
|
1035
|
+
}, {
|
|
1036
|
+
assets: svgs,
|
|
1037
|
+
__unstableType: 'svg',
|
|
1038
|
+
isGlobalStyles: true
|
|
958
1039
|
}]; // Loop through the blocks to check if there are custom CSS values.
|
|
959
1040
|
// If there are, get the block selector and push the selector together with
|
|
960
1041
|
// the CSS value to the 'stylesheets' array.
|
|
@@ -966,13 +1047,13 @@ function useGlobalStylesOutput() {
|
|
|
966
1047
|
var _mergedConfig$styles$3;
|
|
967
1048
|
|
|
968
1049
|
const selector = blockSelectors[blockType.name].selector;
|
|
969
|
-
|
|
1050
|
+
styles.push({
|
|
970
1051
|
css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
|
|
971
1052
|
isGlobalStyles: true
|
|
972
1053
|
});
|
|
973
1054
|
}
|
|
974
1055
|
});
|
|
975
|
-
return [
|
|
1056
|
+
return [styles, mergedConfig.settings];
|
|
976
1057
|
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
977
1058
|
}
|
|
978
1059
|
//# sourceMappingURL=use-global-styles-output.js.map
|