@wordpress/block-editor 11.2.0 → 11.3.1
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 +5 -0
- package/README.md +28 -4
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/autocomplete/index.js +2 -7
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +7 -2
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +2 -2
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-card/index.js +2 -4
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-edit/index.js +8 -0
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +15 -14
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +5 -0
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +0 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mover/mover-description.js +2 -2
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +3 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +1 -1
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
- package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
- package/build/components/block-patterns-list/index.js +31 -3
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -11
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +32 -8
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-selection-clearer/index.js +1 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +7 -33
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +12 -6
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +2 -8
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/utils.js +1 -1
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +55 -47
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/icons.js +15 -1
- package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +9 -4
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/color-style-selector/index.js +3 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -4
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-family/index.js +1 -7
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +1 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +1 -1
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/global-styles/context.js +22 -0
- package/build/components/global-styles/context.js.map +1 -0
- package/build/components/global-styles/hooks.js +142 -0
- package/build/components/global-styles/hooks.js.map +1 -0
- package/build/components/global-styles/index.js +42 -0
- package/build/components/global-styles/index.js.map +1 -0
- package/build/components/global-styles/typography-utils.js +92 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +974 -0
- package/build/components/global-styles/use-global-styles-output.js.map +1 -0
- package/build/components/global-styles/utils.js +340 -0
- package/build/components/global-styles/utils.js.map +1 -0
- package/build/components/height-control/index.js +13 -1
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +5 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/image-editor/context.js +1 -2
- package/build/components/image-editor/context.js.map +1 -1
- package/build/components/image-editor/cropper.js +3 -1
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +13 -9
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +11 -35
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/image-size-control/index.js +1 -7
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +8 -24
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +22 -32
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +8 -23
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-block-context.js +53 -0
- package/build/components/inner-blocks/use-block-context.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +9 -2
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +2 -2
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +1 -7
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +5 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +142 -56
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +74 -21
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +11 -13
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +6 -3
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/media-tab/utils.js +26 -15
- package/build/components/inserter/media-tab/utils.js.map +1 -1
- package/build/components/inserter/menu.js +4 -0
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +5 -3
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/search-results.js +2 -7
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -9
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +15 -2
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +14 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +4 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/index.js +2 -2
- package/build/components/inspector-controls/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +14 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +14 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +2 -2
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/justify-content-control/ui.js +8 -1
- package/build/components/justify-content-control/ui.js.map +1 -1
- package/build/components/link-control/index.js +45 -17
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block.js +1 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -1
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +50 -3
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +3 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/block-select-button.js +10 -4
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +6 -27
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +25 -10
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +27 -20
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +2 -2
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
- package/build/components/provider/index.js +21 -9
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +5 -6
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/rich-text/use-before-input-rules.js +11 -3
- package/build/components/rich-text/use-before-input-rules.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -1
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -8
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/tool-selector/index.js +3 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +7 -8
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-display-information/index.js +1 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/experiments.js +45 -0
- package/build/experiments.js.map +1 -0
- package/build/experiments.native.js +40 -0
- package/build/experiments.native.js.map +1 -0
- package/build/hooks/anchor.js +2 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/child-layout.js +5 -1
- package/build/hooks/child-layout.js.map +1 -1
- package/build/hooks/color-panel.js +1 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +3 -3
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/custom-class-name.js +2 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/dimensions.js +7 -5
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/margin.js +1 -0
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -0
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +39 -17
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-color-props.js +3 -3
- package/build/hooks/use-color-props.js.map +1 -1
- package/build/hooks/utils.js +69 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +10 -1
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js +3 -0
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +59 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +0 -18
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +3 -30
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +11 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +78 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/private-selectors.js +32 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +60 -48
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-variation-transforms.js +1 -1
- package/build/utils/block-variation-transforms.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/transform-styles/index.js +1 -7
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -6
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +7 -2
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +2 -2
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-card/index.js +2 -4
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +7 -0
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +15 -14
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +5 -0
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +0 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +2 -2
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +3 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -1
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
- package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +32 -3
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -11
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +31 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js +1 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -30
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -6
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +2 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +1 -1
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +55 -48
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
- package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +3 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -5
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -6
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +1 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +1 -1
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/global-styles/context.js +12 -0
- package/build-module/components/global-styles/context.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +121 -0
- package/build-module/components/global-styles/hooks.js.map +1 -0
- package/build-module/components/global-styles/index.js +4 -0
- package/build-module/components/global-styles/index.js.map +1 -0
- package/build-module/components/global-styles/typography-utils.js +84 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +930 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
- package/build-module/components/global-styles/utils.js +321 -0
- package/build-module/components/global-styles/utils.js.map +1 -0
- package/build-module/components/height-control/index.js +14 -1
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -4
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/image-editor/context.js +1 -2
- package/build-module/components/image-editor/context.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +3 -1
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +13 -3
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +12 -37
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +1 -6
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +2 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +21 -32
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +9 -22
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-block-context.js +43 -0
- package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +9 -2
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +5 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +145 -56
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +74 -24
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +14 -14
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +7 -4
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/media-tab/utils.js +27 -15
- package/build-module/components/inserter/media-tab/utils.js.map +1 -1
- package/build-module/components/inserter/menu.js +4 -0
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +5 -3
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -6
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -9
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +14 -2
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +13 -1
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +4 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/index.js +2 -2
- package/build-module/components/inspector-controls/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +13 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +13 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +2 -2
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/justify-content-control/ui.js +9 -2
- package/build-module/components/justify-content-control/ui.js.map +1 -1
- package/build-module/components/link-control/index.js +45 -16
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block.js +1 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -1
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +47 -4
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +2 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +6 -25
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +23 -11
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +27 -19
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +2 -2
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/provider/index.js +16 -9
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +4 -4
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-before-input-rules.js +10 -2
- package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -1
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -7
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/tool-selector/index.js +3 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +8 -8
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +1 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/experiments.js +25 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/experiments.native.js +23 -0
- package/build-module/experiments.native.js.map +1 -0
- package/build-module/hooks/anchor.js +2 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/child-layout.js +5 -1
- package/build-module/hooks/child-layout.js.map +1 -1
- package/build-module/hooks/color-panel.js +1 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +3 -3
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +2 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/dimensions.js +6 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/margin.js +1 -0
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -0
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +36 -16
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-color-props.js +3 -3
- package/build-module/hooks/use-color-props.js.map +1 -1
- package/build-module/hooks/utils.js +70 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +3 -0
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +60 -10
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +0 -18
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +2 -26
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +8 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +66 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/private-selectors.js +23 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +48 -37
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-variation-transforms.js +1 -1
- package/build-module/utils/block-variation-transforms.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +1 -6
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +283 -3
- package/build-style/content.css +283 -3
- package/build-style/style-rtl.css +105 -221
- package/build-style/style.css +105 -221
- package/package.json +30 -29
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/alignment-control/test/index.js +5 -15
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/autocomplete/index.js +3 -6
- package/src/components/block-actions/index.js +9 -0
- package/src/components/block-alignment-control/test/index.js +3 -11
- package/src/components/block-alignment-matrix-control/index.js +1 -2
- package/src/components/block-card/index.js +1 -4
- package/src/components/block-content-overlay/content.scss +4 -4
- package/src/components/block-edit/index.js +15 -1
- package/src/components/block-icon/content.scss +31 -0
- package/src/components/block-inspector/index.js +13 -17
- package/src/components/block-list/use-in-between-inserter.js +5 -0
- package/src/components/block-lock/modal.js +0 -1
- package/src/components/block-mover/mover-description.js +2 -2
- package/src/components/block-mover/stories/index.js +3 -3
- package/src/components/block-navigation/dropdown.js +1 -1
- package/src/components/block-pattern-setup/index.js +1 -4
- package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
- package/src/components/block-patterns-list/index.js +29 -3
- package/src/components/block-preview/README.md +9 -9
- package/src/components/block-preview/auto.js +9 -11
- package/src/components/block-preview/content.scss +23 -0
- package/src/components/block-preview/index.js +40 -10
- package/src/components/block-preview/style.scss +0 -23
- package/src/components/block-selection-clearer/index.js +1 -1
- package/src/components/block-selection-clearer/test/index.js +6 -6
- package/src/components/block-settings/container.native.js +7 -26
- package/src/components/block-settings-menu/block-settings-dropdown.js +13 -5
- package/src/components/block-settings-menu-controls/index.js +2 -10
- package/src/components/block-switcher/test/index.js +43 -44
- package/src/components/block-switcher/utils.js +1 -1
- package/src/components/block-tools/selected-block-popover.js +77 -80
- package/src/components/block-tools/style.scss +0 -1
- package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
- package/src/components/block-vertical-alignment-control/icons.js +12 -0
- package/src/components/block-vertical-alignment-control/test/index.js +3 -11
- package/src/components/block-vertical-alignment-control/ui.js +16 -6
- package/src/components/color-style-selector/index.js +1 -1
- package/src/components/colors/test/with-colors.js +2 -8
- package/src/components/date-format-picker/index.js +23 -24
- package/src/components/date-format-picker/style.scss +0 -6
- package/src/components/default-block-appender/content.scss +18 -0
- package/src/components/default-block-appender/test/index.js +2 -8
- package/src/components/font-family/index.js +1 -6
- package/src/components/font-sizes/fluid-utils.js +1 -1
- package/src/components/font-sizes/utils.js +1 -1
- package/src/components/global-styles/README.md +77 -0
- package/src/components/global-styles/context.js +15 -0
- package/src/components/global-styles/hooks.js +145 -0
- package/src/components/global-styles/index.js +7 -0
- package/src/components/global-styles/test/typography-utils.js +393 -0
- package/src/components/global-styles/test/use-global-styles-output.js +814 -0
- package/src/components/global-styles/test/utils.js +206 -0
- package/src/components/global-styles/typography-utils.js +87 -0
- package/src/components/global-styles/use-global-styles-output.js +1088 -0
- package/src/components/global-styles/utils.js +373 -0
- package/src/components/height-control/README.md +55 -0
- package/src/components/height-control/index.js +13 -1
- package/src/components/iframe/index.js +8 -2
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/image-editor/context.js +5 -9
- package/src/components/image-editor/cropper.js +3 -1
- package/src/components/image-editor/index.js +13 -4
- package/src/components/image-editor/use-transform-image.js +14 -55
- package/src/components/image-size-control/index.js +1 -6
- package/src/components/index.js +2 -6
- package/src/components/inner-blocks/index.js +29 -33
- package/src/components/inner-blocks/index.native.js +27 -47
- package/src/components/inner-blocks/use-block-context.js +47 -0
- package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
- package/src/components/inserter/block-patterns-tab.js +9 -1
- package/src/components/inserter/block-types-tab.js +3 -4
- package/src/components/inserter/hooks/use-patterns-state.js +1 -6
- package/src/components/inserter/index.js +3 -4
- package/src/components/inserter/media-tab/hooks.js +167 -65
- package/src/components/inserter/media-tab/media-list.js +94 -26
- package/src/components/inserter/media-tab/media-panel.js +9 -20
- package/src/components/inserter/media-tab/media-tab.js +12 -4
- package/src/components/inserter/media-tab/utils.js +20 -10
- package/src/components/inserter/menu.js +8 -0
- package/src/components/inserter/preview-panel.js +4 -2
- package/src/components/inserter/search-results.js +2 -6
- package/src/components/inserter/stories/index.js +9 -9
- package/src/components/inserter/style.scss +58 -11
- package/src/components/inserter-list-item/index.js +0 -7
- package/src/components/inspector-controls/README.md +3 -7
- package/src/components/inspector-controls/fill.js +15 -1
- package/src/components/inspector-controls/fill.native.js +14 -1
- package/src/components/inspector-controls/groups.js +3 -0
- package/src/components/inspector-controls/index.js +2 -6
- package/src/components/inspector-controls/slot.js +14 -1
- package/src/components/inspector-controls/slot.native.js +14 -1
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +2 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +21 -10
- package/src/components/justify-content-control/ui.js +9 -0
- package/src/components/link-control/index.js +59 -23
- package/src/components/link-control/style.scss +7 -24
- package/src/components/link-control/test/index.js +134 -5
- package/src/components/list-view/block.js +1 -1
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-replace-flow/test/index.js +4 -12
- package/src/components/media-upload/index.native.js +2 -2
- package/src/components/off-canvas-editor/README.md +2 -2
- package/src/components/off-canvas-editor/appender.js +93 -37
- package/src/components/off-canvas-editor/block-contents.js +2 -1
- package/src/components/off-canvas-editor/block-select-button.js +12 -1
- package/src/components/off-canvas-editor/block.js +3 -42
- package/src/components/off-canvas-editor/branch.js +32 -5
- package/src/components/off-canvas-editor/index.js +20 -20
- package/src/components/off-canvas-editor/link-ui.js +2 -2
- package/src/components/off-canvas-editor/style.scss +5 -1
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
- package/src/components/provider/index.js +33 -14
- package/src/components/provider/index.native.js +4 -3
- package/src/components/provider/test/experimental-provider.js +94 -0
- package/src/components/provider/test/use-block-sync.js +10 -0
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/rich-text/use-before-input-rules.js +10 -2
- package/src/components/rich-text/utils.js +1 -1
- package/src/components/spacing-sizes-control/utils.js +2 -7
- package/src/components/tool-selector/index.js +1 -1
- package/src/components/url-input/test/button.js +24 -24
- package/src/components/url-popover/image-url-input-ui.js +7 -8
- package/src/components/url-popover/style.scss +0 -10
- package/src/components/use-block-display-information/index.js +1 -1
- package/src/components/warning/{style.scss → content.scss} +0 -0
- package/src/components/warning/test/index.js +1 -5
- package/src/content.scss +7 -0
- package/src/experiments.js +27 -0
- package/src/experiments.native.js +25 -0
- package/src/hooks/anchor.js +2 -1
- package/src/hooks/border.js +1 -1
- package/src/hooks/child-layout.js +6 -1
- package/src/hooks/color-panel.js +1 -1
- package/src/hooks/color.js +3 -3
- package/src/hooks/custom-class-name.js +2 -1
- package/src/hooks/dimensions.js +6 -6
- package/src/hooks/layout.scss +4 -0
- package/src/hooks/margin.js +1 -0
- package/src/hooks/padding.js +1 -0
- package/src/hooks/position.js +56 -36
- package/src/hooks/test/align.native.js +1 -1
- package/src/hooks/test/utils.js +104 -0
- package/src/hooks/typography.js +1 -1
- package/src/hooks/use-color-props.js +3 -3
- package/src/hooks/utils.js +68 -2
- package/src/index.js +1 -0
- package/src/layouts/constrained.js +3 -0
- package/src/layouts/flex.js +66 -14
- package/src/layouts/flow.js +0 -9
- package/src/store/actions.js +2 -26
- package/src/store/defaults.js +7 -2
- package/src/store/index.js +8 -2
- package/src/store/private-actions.js +65 -0
- package/src/store/private-selectors.js +20 -0
- package/src/store/reducer.js +1 -1
- package/src/store/selectors.js +103 -62
- package/src/store/test/actions.js +0 -18
- package/src/store/test/private-actions.js +22 -0
- package/src/store/test/private-selectors.js +52 -0
- package/src/store/test/selectors.js +52 -54
- package/src/style.scss +3 -5
- package/src/utils/block-variation-transforms.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +3 -1
- package/src/utils/test/parse-css-unit-to-px.js +16 -24
- package/src/utils/transform-styles/index.js +1 -6
- package/build/components/inner-blocks/get-block-context.js +0 -45
- package/build/components/inner-blocks/get-block-context.js.map +0 -1
- package/build/components/off-canvas-editor/block-edit-button.js +0 -50
- package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
- package/build-module/components/inner-blocks/get-block-context.js +0 -37
- package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
- package/src/components/inner-blocks/get-block-context.js +0 -39
- package/src/components/off-canvas-editor/block-edit-button.js +0 -27
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBlockSelectors = void 0;
|
|
7
|
+
exports.getLayoutStyles = getLayoutStyles;
|
|
8
|
+
exports.getNodesWithStyles = exports.getNodesWithSettings = void 0;
|
|
9
|
+
exports.getStylesDeclarations = getStylesDeclarations;
|
|
10
|
+
exports.toStyles = exports.toCustomProperties = void 0;
|
|
11
|
+
exports.toSvgFilters = toSvgFilters;
|
|
12
|
+
exports.useGlobalStylesOutput = useGlobalStylesOutput;
|
|
13
|
+
|
|
14
|
+
var _element = require("@wordpress/element");
|
|
15
|
+
|
|
16
|
+
var _lodash = require("lodash");
|
|
17
|
+
|
|
18
|
+
var _blocks = require("@wordpress/blocks");
|
|
19
|
+
|
|
20
|
+
var _data = require("@wordpress/data");
|
|
21
|
+
|
|
22
|
+
var _styleEngine = require("@wordpress/style-engine");
|
|
23
|
+
|
|
24
|
+
var _utils = require("./utils");
|
|
25
|
+
|
|
26
|
+
var _typographyUtils = require("./typography-utils");
|
|
27
|
+
|
|
28
|
+
var _context = require("./context");
|
|
29
|
+
|
|
30
|
+
var _hooks = require("./hooks");
|
|
31
|
+
|
|
32
|
+
var _components = require("../duotone/components");
|
|
33
|
+
|
|
34
|
+
var _gap = require("../../hooks/gap");
|
|
35
|
+
|
|
36
|
+
var _store = require("../../store");
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* External dependencies
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* WordPress dependencies
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Internal dependencies
|
|
48
|
+
*/
|
|
49
|
+
// List of block support features that can have their related styles
|
|
50
|
+
// generated under their own feature level selector rather than the block's.
|
|
51
|
+
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
52
|
+
__experimentalBorder: 'border',
|
|
53
|
+
color: 'color',
|
|
54
|
+
spacing: 'spacing',
|
|
55
|
+
typography: 'typography'
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function compileStyleValue(uncompiledValue) {
|
|
59
|
+
var _uncompiledValue$star;
|
|
60
|
+
|
|
61
|
+
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
62
|
+
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
63
|
+
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
64
|
+
|
|
65
|
+
if (uncompiledValue !== null && uncompiledValue !== void 0 && (_uncompiledValue$star = uncompiledValue.startsWith) !== null && _uncompiledValue$star !== void 0 && _uncompiledValue$star.call(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
|
|
66
|
+
const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
|
|
67
|
+
return `var(--wp--${variable})`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return uncompiledValue;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Transform given preset tree into a set of style declarations.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} blockPresets
|
|
76
|
+
* @param {Object} mergedSettings Merged theme.json settings.
|
|
77
|
+
*
|
|
78
|
+
* @return {Array<Object>} An array of style declarations.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
function getPresetsDeclarations() {
|
|
83
|
+
let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
84
|
+
let mergedSettings = arguments.length > 1 ? arguments[1] : undefined;
|
|
85
|
+
return _utils.PRESET_METADATA.reduce((declarations, _ref) => {
|
|
86
|
+
let {
|
|
87
|
+
path,
|
|
88
|
+
valueKey,
|
|
89
|
+
valueFunc,
|
|
90
|
+
cssVarInfix
|
|
91
|
+
} = _ref;
|
|
92
|
+
const presetByOrigin = (0, _lodash.get)(blockPresets, path, []);
|
|
93
|
+
['default', 'theme', 'custom'].forEach(origin => {
|
|
94
|
+
if (presetByOrigin[origin]) {
|
|
95
|
+
presetByOrigin[origin].forEach(value => {
|
|
96
|
+
if (valueKey && !valueFunc) {
|
|
97
|
+
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${value[valueKey]}`);
|
|
98
|
+
} else if (valueFunc && typeof valueFunc === 'function') {
|
|
99
|
+
declarations.push(`--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(value.slug)}: ${valueFunc(value, mergedSettings)}`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return declarations;
|
|
105
|
+
}, []);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Transform given preset tree into a set of preset class declarations.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} blockSelector
|
|
111
|
+
* @param {Object} blockPresets
|
|
112
|
+
* @return {string} CSS declarations for the preset classes.
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
function getPresetsClasses(blockSelector) {
|
|
117
|
+
let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
118
|
+
return _utils.PRESET_METADATA.reduce((declarations, _ref2) => {
|
|
119
|
+
let {
|
|
120
|
+
path,
|
|
121
|
+
cssVarInfix,
|
|
122
|
+
classes
|
|
123
|
+
} = _ref2;
|
|
124
|
+
|
|
125
|
+
if (!classes) {
|
|
126
|
+
return declarations;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const presetByOrigin = (0, _lodash.get)(blockPresets, path, []);
|
|
130
|
+
['default', 'theme', 'custom'].forEach(origin => {
|
|
131
|
+
if (presetByOrigin[origin]) {
|
|
132
|
+
presetByOrigin[origin].forEach(_ref3 => {
|
|
133
|
+
let {
|
|
134
|
+
slug
|
|
135
|
+
} = _ref3;
|
|
136
|
+
classes.forEach(_ref4 => {
|
|
137
|
+
let {
|
|
138
|
+
classSuffix,
|
|
139
|
+
propertyName
|
|
140
|
+
} = _ref4;
|
|
141
|
+
const classSelectorToUse = `.has-${(0, _lodash.kebabCase)(slug)}-${classSuffix}`;
|
|
142
|
+
const selectorToUse = blockSelector.split(',') // Selector can be "h1, h2, h3"
|
|
143
|
+
.map(selector => `${selector}${classSelectorToUse}`).join(',');
|
|
144
|
+
const value = `var(--wp--preset--${cssVarInfix}--${(0, _lodash.kebabCase)(slug)})`;
|
|
145
|
+
declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return declarations;
|
|
151
|
+
}, '');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getPresetsSvgFilters() {
|
|
155
|
+
let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
156
|
+
return _utils.PRESET_METADATA.filter( // Duotone are the only type of filters for now.
|
|
157
|
+
metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
|
|
158
|
+
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, {
|
|
160
|
+
preset: preset,
|
|
161
|
+
key: preset.slug
|
|
162
|
+
})));
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function flattenTree() {
|
|
167
|
+
let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
168
|
+
let prefix = arguments.length > 1 ? arguments[1] : undefined;
|
|
169
|
+
let token = arguments.length > 2 ? arguments[2] : undefined;
|
|
170
|
+
let result = [];
|
|
171
|
+
Object.keys(input).forEach(key => {
|
|
172
|
+
const newKey = prefix + (0, _lodash.kebabCase)(key.replace('/', '-'));
|
|
173
|
+
const newLeaf = input[key];
|
|
174
|
+
|
|
175
|
+
if (newLeaf instanceof Object) {
|
|
176
|
+
const newPrefix = newKey + token;
|
|
177
|
+
result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
|
|
178
|
+
} else {
|
|
179
|
+
result.push(`${newKey}: ${newLeaf}`);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Gets variation selector string from feature selector.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} featureSelector The feature selector.
|
|
188
|
+
*
|
|
189
|
+
* @param {string} styleVariationSelector The style variation selector.
|
|
190
|
+
* @return {string} Combined selector string.
|
|
191
|
+
*
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) {
|
|
196
|
+
const featureSelectors = featureSelector.split(',');
|
|
197
|
+
const combinedSelectors = [];
|
|
198
|
+
featureSelectors.forEach(selector => {
|
|
199
|
+
combinedSelectors.push(`${styleVariationSelector.trim()}${selector.trim()}`);
|
|
200
|
+
});
|
|
201
|
+
return combinedSelectors.join(', ');
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Transform given style tree into a set of style declarations.
|
|
205
|
+
*
|
|
206
|
+
* @param {Object} blockStyles Block styles.
|
|
207
|
+
*
|
|
208
|
+
* @param {string} selector The selector these declarations should attach to.
|
|
209
|
+
*
|
|
210
|
+
* @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
|
|
211
|
+
*
|
|
212
|
+
* @param {Object} tree A theme.json tree containing layout definitions.
|
|
213
|
+
*
|
|
214
|
+
* @return {Array} An array of style declarations.
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
function getStylesDeclarations() {
|
|
219
|
+
let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
220
|
+
let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
221
|
+
let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
|
|
222
|
+
let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
223
|
+
const isRoot = _utils.ROOT_BLOCK_SELECTOR === selector;
|
|
224
|
+
const output = Object.entries(_blocks.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations, _ref5) => {
|
|
225
|
+
let [key, {
|
|
226
|
+
value,
|
|
227
|
+
properties,
|
|
228
|
+
useEngine,
|
|
229
|
+
rootOnly
|
|
230
|
+
}] = _ref5;
|
|
231
|
+
|
|
232
|
+
if (rootOnly && !isRoot) {
|
|
233
|
+
return declarations;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const pathToValue = value;
|
|
237
|
+
|
|
238
|
+
if (pathToValue[0] === 'elements' || useEngine) {
|
|
239
|
+
return declarations;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const styleValue = (0, _lodash.get)(blockStyles, pathToValue); // Root-level padding styles don't currently support strings with CSS shorthand values.
|
|
243
|
+
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
|
|
244
|
+
|
|
245
|
+
if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
|
|
246
|
+
return declarations;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (!!properties && typeof styleValue !== 'string') {
|
|
250
|
+
Object.entries(properties).forEach(entry => {
|
|
251
|
+
const [name, prop] = entry;
|
|
252
|
+
|
|
253
|
+
if (!(0, _lodash.get)(styleValue, [prop], false)) {
|
|
254
|
+
// Do not create a declaration
|
|
255
|
+
// for sub-properties that don't have any value.
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const cssProperty = name.startsWith('--') ? name : (0, _lodash.kebabCase)(name);
|
|
260
|
+
declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(styleValue, [prop]))}`);
|
|
261
|
+
});
|
|
262
|
+
} else if ((0, _lodash.get)(blockStyles, pathToValue, false)) {
|
|
263
|
+
const cssProperty = key.startsWith('--') ? key : (0, _lodash.kebabCase)(key);
|
|
264
|
+
declarations.push(`${cssProperty}: ${compileStyleValue((0, _lodash.get)(blockStyles, pathToValue))}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return declarations;
|
|
268
|
+
}, []); // The goal is to move everything to server side generated engine styles
|
|
269
|
+
// This is temporary as we absorb more and more styles into the engine.
|
|
270
|
+
|
|
271
|
+
const extraRules = (0, _styleEngine.getCSSRules)(blockStyles);
|
|
272
|
+
extraRules.forEach(rule => {
|
|
273
|
+
var _ruleValue;
|
|
274
|
+
|
|
275
|
+
// Don't output padding properties if padding variables are set.
|
|
276
|
+
if (isRoot && useRootPaddingAlign && rule.key.startsWith('padding')) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const cssProperty = rule.key.startsWith('--') ? rule.key : (0, _lodash.kebabCase)(rule.key);
|
|
281
|
+
let ruleValue = rule.value;
|
|
282
|
+
|
|
283
|
+
if (typeof ruleValue !== 'string' && (_ruleValue = ruleValue) !== null && _ruleValue !== void 0 && _ruleValue.ref) {
|
|
284
|
+
var _ruleValue2;
|
|
285
|
+
|
|
286
|
+
const refPath = ruleValue.ref.split('.');
|
|
287
|
+
ruleValue = (0, _lodash.get)(tree, refPath); // Presence of another ref indicates a reference to another dynamic value.
|
|
288
|
+
// Pointing to another dynamic value is not supported.
|
|
289
|
+
|
|
290
|
+
if (!ruleValue || !!((_ruleValue2 = ruleValue) !== null && _ruleValue2 !== void 0 && _ruleValue2.ref)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
} // Calculate fluid typography rules where available.
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
if (cssProperty === 'font-size') {
|
|
297
|
+
var _tree$settings;
|
|
298
|
+
|
|
299
|
+
/*
|
|
300
|
+
* getTypographyFontSizeValue() will check
|
|
301
|
+
* if fluid typography has been activated and also
|
|
302
|
+
* whether the incoming value can be converted to a fluid value.
|
|
303
|
+
* Values that already have a "clamp()" function will not pass the test,
|
|
304
|
+
* and therefore the original $value will be returned.
|
|
305
|
+
*/
|
|
306
|
+
ruleValue = (0, _typographyUtils.getTypographyFontSizeValue)({
|
|
307
|
+
size: ruleValue
|
|
308
|
+
}, tree === null || tree === void 0 ? void 0 : (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.typography);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
output.push(`${cssProperty}: ${ruleValue}`);
|
|
312
|
+
});
|
|
313
|
+
return output;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Get generated CSS for layout styles by looking up layout definitions provided
|
|
317
|
+
* in theme.json, and outputting common layout styles, and specific blockGap values.
|
|
318
|
+
*
|
|
319
|
+
* @param {Object} props
|
|
320
|
+
* @param {Object} props.tree A theme.json tree containing layout definitions.
|
|
321
|
+
* @param {Object} props.style A style object containing spacing values.
|
|
322
|
+
* @param {string} props.selector Selector used to group together layout styling rules.
|
|
323
|
+
* @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.
|
|
324
|
+
* @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.
|
|
325
|
+
* @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.
|
|
326
|
+
* @return {string} Generated CSS rules for the layout styles.
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
function getLayoutStyles(_ref6) {
|
|
331
|
+
var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
|
|
332
|
+
|
|
333
|
+
let {
|
|
334
|
+
tree,
|
|
335
|
+
style,
|
|
336
|
+
selector,
|
|
337
|
+
hasBlockGapSupport,
|
|
338
|
+
hasFallbackGapSupport,
|
|
339
|
+
fallbackGapValue
|
|
340
|
+
} = _ref6;
|
|
341
|
+
let ruleset = '';
|
|
342
|
+
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
|
+
// and use a fallback value if one is provided for the current block.
|
|
344
|
+
|
|
345
|
+
if (hasFallbackGapSupport) {
|
|
346
|
+
if (selector === _utils.ROOT_BLOCK_SELECTOR) {
|
|
347
|
+
gapValue = !gapValue ? '0.5em' : gapValue;
|
|
348
|
+
} else if (!hasBlockGapSupport && fallbackGapValue) {
|
|
349
|
+
gapValue = fallbackGapValue;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
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(_ref7 => {
|
|
355
|
+
let {
|
|
356
|
+
className,
|
|
357
|
+
name,
|
|
358
|
+
spacingStyles
|
|
359
|
+
} = _ref7;
|
|
360
|
+
|
|
361
|
+
// Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
|
|
362
|
+
if (!hasBlockGapSupport && 'flex' !== name) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (spacingStyles !== null && spacingStyles !== void 0 && spacingStyles.length) {
|
|
367
|
+
spacingStyles.forEach(spacingStyle => {
|
|
368
|
+
const declarations = [];
|
|
369
|
+
|
|
370
|
+
if (spacingStyle.rules) {
|
|
371
|
+
Object.entries(spacingStyle.rules).forEach(_ref8 => {
|
|
372
|
+
let [cssProperty, cssValue] = _ref8;
|
|
373
|
+
declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (declarations.length) {
|
|
378
|
+
let combinedSelector = '';
|
|
379
|
+
|
|
380
|
+
if (!hasBlockGapSupport) {
|
|
381
|
+
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
|
|
382
|
+
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
|
+
} else {
|
|
384
|
+
combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}); // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
|
|
392
|
+
|
|
393
|
+
if (selector === _utils.ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
|
|
394
|
+
ruleset += `${selector} { --wp--style--block-gap: ${gapValue}; }`;
|
|
395
|
+
}
|
|
396
|
+
} // Output base styles
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
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
|
+
const validDisplayModes = ['block', 'flex', 'grid'];
|
|
401
|
+
Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
|
|
402
|
+
let {
|
|
403
|
+
className,
|
|
404
|
+
displayMode,
|
|
405
|
+
baseStyles
|
|
406
|
+
} = _ref9;
|
|
407
|
+
|
|
408
|
+
if (displayMode && validDisplayModes.includes(displayMode)) {
|
|
409
|
+
ruleset += `${selector} .${className} { display:${displayMode}; }`;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (baseStyles !== null && baseStyles !== void 0 && baseStyles.length) {
|
|
413
|
+
baseStyles.forEach(baseStyle => {
|
|
414
|
+
const declarations = [];
|
|
415
|
+
|
|
416
|
+
if (baseStyle.rules) {
|
|
417
|
+
Object.entries(baseStyle.rules).forEach(_ref10 => {
|
|
418
|
+
let [cssProperty, cssValue] = _ref10;
|
|
419
|
+
declarations.push(`${cssProperty}: ${cssValue}`);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (declarations.length) {
|
|
424
|
+
const combinedSelector = `${selector} .${className}${(baseStyle === null || baseStyle === void 0 ? void 0 : baseStyle.selector) || ''}`;
|
|
425
|
+
ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return ruleset;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const getNodesWithStyles = (tree, blockSelectors) => {
|
|
436
|
+
var _tree$styles$blocks, _tree$styles3;
|
|
437
|
+
|
|
438
|
+
const nodes = [];
|
|
439
|
+
|
|
440
|
+
if (!(tree !== null && tree !== void 0 && tree.styles)) {
|
|
441
|
+
return nodes;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const pickStyleKeys = treeToPickFrom => Object.fromEntries(Object.entries(treeToPickFrom !== null && treeToPickFrom !== void 0 ? treeToPickFrom : {}).filter(_ref11 => {
|
|
445
|
+
let [key] = _ref11;
|
|
446
|
+
return ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key);
|
|
447
|
+
})); // Top-level.
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
const styles = pickStyleKeys(tree.styles);
|
|
451
|
+
|
|
452
|
+
if (!!styles) {
|
|
453
|
+
nodes.push({
|
|
454
|
+
styles,
|
|
455
|
+
selector: _utils.ROOT_BLOCK_SELECTOR
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(_ref12 => {
|
|
460
|
+
var _tree$styles;
|
|
461
|
+
|
|
462
|
+
let [name, selector] = _ref12;
|
|
463
|
+
|
|
464
|
+
if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
|
|
465
|
+
var _tree$styles2;
|
|
466
|
+
|
|
467
|
+
nodes.push({
|
|
468
|
+
styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
|
|
469
|
+
selector
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}); // Iterate over blocks: they can have styles & elements.
|
|
473
|
+
|
|
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(_ref13 => {
|
|
475
|
+
var _blockSelectors$block, _node$elements;
|
|
476
|
+
|
|
477
|
+
let [blockName, node] = _ref13;
|
|
478
|
+
const blockStyles = pickStyleKeys(node);
|
|
479
|
+
|
|
480
|
+
if (node !== null && node !== void 0 && node.variations) {
|
|
481
|
+
const variations = {};
|
|
482
|
+
Object.keys(node.variations).forEach(variation => {
|
|
483
|
+
variations[variation] = pickStyleKeys(node.variations[variation]);
|
|
484
|
+
});
|
|
485
|
+
blockStyles.variations = variations;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
|
|
489
|
+
nodes.push({
|
|
490
|
+
duotoneSelector: blockSelectors[blockName].duotoneSelector,
|
|
491
|
+
fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
|
|
492
|
+
hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
|
|
493
|
+
selector: blockSelectors[blockName].selector,
|
|
494
|
+
styles: blockStyles,
|
|
495
|
+
featureSelectors: blockSelectors[blockName].featureSelectors,
|
|
496
|
+
styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref14 => {
|
|
501
|
+
let [elementName, value] = _ref14;
|
|
502
|
+
|
|
503
|
+
if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(_blocks.__EXPERIMENTAL_ELEMENTS !== null && _blocks.__EXPERIMENTAL_ELEMENTS !== void 0 && _blocks.__EXPERIMENTAL_ELEMENTS[elementName])) {
|
|
504
|
+
nodes.push({
|
|
505
|
+
styles: value,
|
|
506
|
+
selector: blockSelectors[blockName].selector.split(',').map(sel => {
|
|
507
|
+
const elementSelectors = _blocks.__EXPERIMENTAL_ELEMENTS[elementName].split(',');
|
|
508
|
+
|
|
509
|
+
return elementSelectors.map(elementSelector => sel + ' ' + elementSelector);
|
|
510
|
+
}).join(',')
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
return nodes;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
exports.getNodesWithStyles = getNodesWithStyles;
|
|
519
|
+
|
|
520
|
+
const getNodesWithSettings = (tree, blockSelectors) => {
|
|
521
|
+
var _tree$settings4, _tree$settings$blocks, _tree$settings5;
|
|
522
|
+
|
|
523
|
+
const nodes = [];
|
|
524
|
+
|
|
525
|
+
if (!(tree !== null && tree !== void 0 && tree.settings)) {
|
|
526
|
+
return nodes;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const pickPresets = treeToPickFrom => {
|
|
530
|
+
const presets = {};
|
|
531
|
+
|
|
532
|
+
_utils.PRESET_METADATA.forEach(_ref15 => {
|
|
533
|
+
let {
|
|
534
|
+
path
|
|
535
|
+
} = _ref15;
|
|
536
|
+
const value = (0, _lodash.get)(treeToPickFrom, path, false);
|
|
537
|
+
|
|
538
|
+
if (value !== false) {
|
|
539
|
+
(0, _lodash.set)(presets, path, value);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
return presets;
|
|
544
|
+
}; // Top-level.
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
const presets = pickPresets(tree.settings);
|
|
548
|
+
const custom = (_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.custom;
|
|
549
|
+
|
|
550
|
+
if (!(0, _lodash.isEmpty)(presets) || !!custom) {
|
|
551
|
+
nodes.push({
|
|
552
|
+
presets,
|
|
553
|
+
custom,
|
|
554
|
+
selector: _utils.ROOT_BLOCK_SELECTOR
|
|
555
|
+
});
|
|
556
|
+
} // Blocks.
|
|
557
|
+
|
|
558
|
+
|
|
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(_ref16 => {
|
|
560
|
+
let [blockName, node] = _ref16;
|
|
561
|
+
const blockPresets = pickPresets(node);
|
|
562
|
+
const blockCustom = node.custom;
|
|
563
|
+
|
|
564
|
+
if (!(0, _lodash.isEmpty)(blockPresets) || !!blockCustom) {
|
|
565
|
+
nodes.push({
|
|
566
|
+
presets: blockPresets,
|
|
567
|
+
custom: blockCustom,
|
|
568
|
+
selector: blockSelectors[blockName].selector
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
return nodes;
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
exports.getNodesWithSettings = getNodesWithSettings;
|
|
576
|
+
|
|
577
|
+
const toCustomProperties = (tree, blockSelectors) => {
|
|
578
|
+
const settings = getNodesWithSettings(tree, blockSelectors);
|
|
579
|
+
let ruleset = '';
|
|
580
|
+
settings.forEach(_ref17 => {
|
|
581
|
+
let {
|
|
582
|
+
presets,
|
|
583
|
+
custom,
|
|
584
|
+
selector
|
|
585
|
+
} = _ref17;
|
|
586
|
+
const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
|
|
587
|
+
const customProps = flattenTree(custom, '--wp--custom--', '--');
|
|
588
|
+
|
|
589
|
+
if (customProps.length > 0) {
|
|
590
|
+
declarations.push(...customProps);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (declarations.length > 0) {
|
|
594
|
+
ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
return ruleset;
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
exports.toCustomProperties = toCustomProperties;
|
|
601
|
+
|
|
602
|
+
const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
|
|
603
|
+
var _tree$settings6, _tree$settings7;
|
|
604
|
+
|
|
605
|
+
let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
606
|
+
const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
|
|
607
|
+
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
608
|
+
const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings6 = tree.settings) === null || _tree$settings6 === void 0 ? void 0 : _tree$settings6.useRootPaddingAwareAlignments;
|
|
609
|
+
const {
|
|
610
|
+
contentSize,
|
|
611
|
+
wideSize
|
|
612
|
+
} = (tree === null || tree === void 0 ? void 0 : (_tree$settings7 = tree.settings) === null || _tree$settings7 === void 0 ? void 0 : _tree$settings7.layout) || {};
|
|
613
|
+
/*
|
|
614
|
+
* Reset default browser margin on the root body element.
|
|
615
|
+
* This is set on the root selector **before** generating the ruleset
|
|
616
|
+
* from the `theme.json`. This is to ensure that if the `theme.json` declares
|
|
617
|
+
* `margin` in its `spacing` declaration for the `body` element then these
|
|
618
|
+
* user-generated values take precedence in the CSS cascade.
|
|
619
|
+
* @link https://github.com/WordPress/gutenberg/issues/36147.
|
|
620
|
+
*/
|
|
621
|
+
|
|
622
|
+
let ruleset = 'body {margin: 0;';
|
|
623
|
+
|
|
624
|
+
if (contentSize) {
|
|
625
|
+
ruleset += ` --wp--style--global--content-size: ${contentSize};`;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (wideSize) {
|
|
629
|
+
ruleset += ` --wp--style--global--wide-size: ${wideSize};`;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (useRootPaddingAlign) {
|
|
633
|
+
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
|
|
634
|
+
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
635
|
+
.has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
|
|
636
|
+
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
|
|
637
|
+
.has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
|
|
638
|
+
.has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
639
|
+
.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
ruleset += '}';
|
|
643
|
+
nodesWithStyles.forEach(_ref18 => {
|
|
644
|
+
let {
|
|
645
|
+
selector,
|
|
646
|
+
duotoneSelector,
|
|
647
|
+
styles,
|
|
648
|
+
fallbackGapValue,
|
|
649
|
+
hasLayoutSupport,
|
|
650
|
+
featureSelectors,
|
|
651
|
+
styleVariationSelectors
|
|
652
|
+
} = _ref18;
|
|
653
|
+
|
|
654
|
+
// Process styles for block support features with custom feature level
|
|
655
|
+
// CSS selectors set.
|
|
656
|
+
if (featureSelectors) {
|
|
657
|
+
Object.entries(featureSelectors).forEach(_ref19 => {
|
|
658
|
+
let [featureName, featureSelector] = _ref19;
|
|
659
|
+
|
|
660
|
+
if (styles !== null && styles !== void 0 && styles[featureName]) {
|
|
661
|
+
const featureStyles = {
|
|
662
|
+
[featureName]: styles[featureName]
|
|
663
|
+
};
|
|
664
|
+
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
665
|
+
delete styles[featureName];
|
|
666
|
+
|
|
667
|
+
if (!!featureDeclarations.length) {
|
|
668
|
+
ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (styleVariationSelectors) {
|
|
675
|
+
Object.entries(styleVariationSelectors).forEach(_ref20 => {
|
|
676
|
+
var _styles$variations;
|
|
677
|
+
|
|
678
|
+
let [styleVariationName, styleVariationSelector] = _ref20;
|
|
679
|
+
|
|
680
|
+
if (styles !== null && styles !== void 0 && (_styles$variations = styles.variations) !== null && _styles$variations !== void 0 && _styles$variations[styleVariationName]) {
|
|
681
|
+
var _styles$variations3;
|
|
682
|
+
|
|
683
|
+
// If the block uses any custom selectors for block support, add those first.
|
|
684
|
+
if (featureSelectors) {
|
|
685
|
+
Object.entries(featureSelectors).forEach(_ref21 => {
|
|
686
|
+
var _styles$variations2, _styles$variations2$s;
|
|
687
|
+
|
|
688
|
+
let [featureName, featureSelector] = _ref21;
|
|
689
|
+
|
|
690
|
+
if (styles !== null && styles !== void 0 && (_styles$variations2 = styles.variations) !== null && _styles$variations2 !== void 0 && (_styles$variations2$s = _styles$variations2[styleVariationName]) !== null && _styles$variations2$s !== void 0 && _styles$variations2$s[featureName]) {
|
|
691
|
+
const featureStyles = {
|
|
692
|
+
[featureName]: styles.variations[styleVariationName][featureName]
|
|
693
|
+
};
|
|
694
|
+
const featureDeclarations = getStylesDeclarations(featureStyles);
|
|
695
|
+
delete styles.variations[styleVariationName][featureName];
|
|
696
|
+
|
|
697
|
+
if (!!featureDeclarations.length) {
|
|
698
|
+
ruleset = ruleset + `${concatFeatureVariationSelectorString(featureSelector, styleVariationSelector)}{${featureDeclarations.join(';')} }`;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
} // Otherwise add regular selectors.
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
const styleVariationDeclarations = getStylesDeclarations(styles === null || styles === void 0 ? void 0 : (_styles$variations3 = styles.variations) === null || _styles$variations3 === void 0 ? void 0 : _styles$variations3[styleVariationName], styleVariationSelector, useRootPaddingAlign, tree);
|
|
706
|
+
|
|
707
|
+
if (!!styleVariationDeclarations.length) {
|
|
708
|
+
ruleset = ruleset + `${styleVariationSelector}{${styleVariationDeclarations.join(';')}}`;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const duotoneStyles = {};
|
|
715
|
+
|
|
716
|
+
if (styles !== null && styles !== void 0 && styles.filter) {
|
|
717
|
+
duotoneStyles.filter = styles.filter;
|
|
718
|
+
delete styles.filter;
|
|
719
|
+
} // Process duotone styles (they use color.__experimentalDuotone selector).
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
if (duotoneSelector) {
|
|
723
|
+
const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
|
|
724
|
+
|
|
725
|
+
if (duotoneDeclarations.length > 0) {
|
|
726
|
+
ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
|
|
727
|
+
}
|
|
728
|
+
} // Process blockGap and layout styles.
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
if (!disableLayoutStyles && (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
|
|
732
|
+
ruleset += getLayoutStyles({
|
|
733
|
+
tree,
|
|
734
|
+
style: styles,
|
|
735
|
+
selector,
|
|
736
|
+
hasBlockGapSupport,
|
|
737
|
+
hasFallbackGapSupport,
|
|
738
|
+
fallbackGapValue
|
|
739
|
+
});
|
|
740
|
+
} // Process the remaining block styles (they use either normal block class or __experimentalSelector).
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
const declarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree);
|
|
744
|
+
|
|
745
|
+
if (declarations !== null && declarations !== void 0 && declarations.length) {
|
|
746
|
+
ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
|
|
747
|
+
} // Check for pseudo selector in `styles` and handle separately.
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
const pseudoSelectorStyles = Object.entries(styles).filter(_ref22 => {
|
|
751
|
+
let [key] = _ref22;
|
|
752
|
+
return key.startsWith(':');
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
|
|
756
|
+
pseudoSelectorStyles.forEach(_ref23 => {
|
|
757
|
+
let [pseudoKey, pseudoStyle] = _ref23;
|
|
758
|
+
const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
|
|
759
|
+
|
|
760
|
+
if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
|
|
761
|
+
return;
|
|
762
|
+
} // `selector` maybe provided in a form
|
|
763
|
+
// where block level selectors have sub element
|
|
764
|
+
// selectors appended to them as a comma separated
|
|
765
|
+
// string.
|
|
766
|
+
// e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;
|
|
767
|
+
// Split and append pseudo selector to create
|
|
768
|
+
// the proper rules to target the elements.
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
|
|
772
|
+
|
|
773
|
+
const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
|
|
774
|
+
ruleset = ruleset + pseudoRule;
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
/* Add alignment / layout styles */
|
|
779
|
+
|
|
780
|
+
ruleset = ruleset + '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
|
|
781
|
+
ruleset = ruleset + '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
|
|
782
|
+
ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
|
|
783
|
+
|
|
784
|
+
if (hasBlockGapSupport) {
|
|
785
|
+
var _tree$styles4, _tree$styles4$spacing;
|
|
786
|
+
|
|
787
|
+
// Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
|
|
788
|
+
const gapValue = (0, _gap.getGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$styles4 = tree.styles) === null || _tree$styles4 === void 0 ? void 0 : (_tree$styles4$spacing = _tree$styles4.spacing) === null || _tree$styles4$spacing === void 0 ? void 0 : _tree$styles4$spacing.blockGap) || '0.5em';
|
|
789
|
+
ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
|
|
790
|
+
ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
nodesWithSettings.forEach(_ref24 => {
|
|
794
|
+
let {
|
|
795
|
+
selector,
|
|
796
|
+
presets
|
|
797
|
+
} = _ref24;
|
|
798
|
+
|
|
799
|
+
if (_utils.ROOT_BLOCK_SELECTOR === selector) {
|
|
800
|
+
// Do not add extra specificity for top-level classes.
|
|
801
|
+
selector = '';
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
const classes = getPresetsClasses(selector, presets);
|
|
805
|
+
|
|
806
|
+
if (!(0, _lodash.isEmpty)(classes)) {
|
|
807
|
+
ruleset = ruleset + classes;
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
return ruleset;
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
exports.toStyles = toStyles;
|
|
814
|
+
|
|
815
|
+
function toSvgFilters(tree, blockSelectors) {
|
|
816
|
+
const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
|
|
817
|
+
return nodesWithSettings.flatMap(_ref25 => {
|
|
818
|
+
let {
|
|
819
|
+
presets
|
|
820
|
+
} = _ref25;
|
|
821
|
+
return getPresetsSvgFilters(presets);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
const getBlockSelectors = (blockTypes, getBlockStyles) => {
|
|
826
|
+
const result = {};
|
|
827
|
+
blockTypes.forEach(blockType => {
|
|
828
|
+
var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports4, _blockType$supports4$, _blockType$supports4$2;
|
|
829
|
+
|
|
830
|
+
const name = blockType.name;
|
|
831
|
+
const selector = (_blockType$supports$_ = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports = blockType.supports) === null || _blockType$supports === void 0 ? void 0 : _blockType$supports.__experimentalSelector) !== null && _blockType$supports$_ !== void 0 ? _blockType$supports$_ : '.wp-block-' + name.replace('core/', '').replace('/', '-');
|
|
832
|
+
const duotoneSelector = (_blockType$supports$c = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.color) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalDuotone) !== null && _blockType$supports$c !== void 0 ? _blockType$supports$c : null;
|
|
833
|
+
const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
|
|
834
|
+
const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports4 = blockType.supports) === null || _blockType$supports4 === void 0 ? void 0 : (_blockType$supports4$ = _blockType$supports4.spacing) === null || _blockType$supports4$ === void 0 ? void 0 : (_blockType$supports4$2 = _blockType$supports4$.blockGap) === null || _blockType$supports4$2 === void 0 ? void 0 : _blockType$supports4$2.__experimentalDefault;
|
|
835
|
+
const blockStyleVariations = getBlockStyles(name);
|
|
836
|
+
const styleVariationSelectors = {};
|
|
837
|
+
|
|
838
|
+
if (blockStyleVariations !== null && blockStyleVariations !== void 0 && blockStyleVariations.length) {
|
|
839
|
+
blockStyleVariations.forEach(variation => {
|
|
840
|
+
const styleVariationSelector = `.is-style-${variation.name}${selector}`;
|
|
841
|
+
styleVariationSelectors[variation.name] = styleVariationSelector;
|
|
842
|
+
});
|
|
843
|
+
} // For each block support feature add any custom selectors.
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
const featureSelectors = {};
|
|
847
|
+
Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref26 => {
|
|
848
|
+
var _blockType$supports5, _blockType$supports5$;
|
|
849
|
+
|
|
850
|
+
let [featureKey, featureName] = _ref26;
|
|
851
|
+
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;
|
|
852
|
+
|
|
853
|
+
if (featureSelector) {
|
|
854
|
+
featureSelectors[featureName] = (0, _utils.scopeSelector)(selector, featureSelector);
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
result[name] = {
|
|
858
|
+
duotoneSelector,
|
|
859
|
+
fallbackGapValue,
|
|
860
|
+
featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : undefined,
|
|
861
|
+
hasLayoutSupport,
|
|
862
|
+
name,
|
|
863
|
+
selector,
|
|
864
|
+
styleVariationSelectors: Object.keys(styleVariationSelectors).length ? styleVariationSelectors : undefined
|
|
865
|
+
};
|
|
866
|
+
});
|
|
867
|
+
return result;
|
|
868
|
+
};
|
|
869
|
+
/**
|
|
870
|
+
* If there is a separator block whose color is defined in theme.json via background,
|
|
871
|
+
* update the separator color to the same value by using border color.
|
|
872
|
+
*
|
|
873
|
+
* @param {Object} config Theme.json configuration file object.
|
|
874
|
+
* @return {Object} configTheme.json configuration file object updated.
|
|
875
|
+
*/
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
exports.getBlockSelectors = getBlockSelectors;
|
|
879
|
+
|
|
880
|
+
function updateConfigWithSeparator(config) {
|
|
881
|
+
var _config$styles, _config$styles2, _config$styles2$block, _config$styles3, _config$styles3$block, _config$styles4, _config$styles4$block;
|
|
882
|
+
|
|
883
|
+
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$block === void 0 ? void 0 : _config$styles2$block.background) && !((_config$styles3 = config.styles) !== null && _config$styles3 !== void 0 && (_config$styles3$block = _config$styles3.blocks['core/separator'].color) !== null && _config$styles3$block !== void 0 && _config$styles3$block.text) && !((_config$styles4 = config.styles) !== null && _config$styles4 !== void 0 && (_config$styles4$block = _config$styles4.blocks['core/separator'].border) !== null && _config$styles4$block !== void 0 && _config$styles4$block.color);
|
|
884
|
+
|
|
885
|
+
if (needsSeparatorStyleUpdate) {
|
|
886
|
+
var _config$styles5;
|
|
887
|
+
|
|
888
|
+
return { ...config,
|
|
889
|
+
styles: { ...config.styles,
|
|
890
|
+
blocks: { ...config.styles.blocks,
|
|
891
|
+
'core/separator': { ...config.styles.blocks['core/separator'],
|
|
892
|
+
color: { ...config.styles.blocks['core/separator'].color,
|
|
893
|
+
text: (_config$styles5 = config.styles) === null || _config$styles5 === void 0 ? void 0 : _config$styles5.blocks['core/separator'].color.background
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return config;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const processCSSNesting = (css, blockSelector) => {
|
|
905
|
+
let processedCSS = ''; // Split CSS nested rules.
|
|
906
|
+
|
|
907
|
+
const parts = css.split('&');
|
|
908
|
+
parts.forEach(part => {
|
|
909
|
+
processedCSS += !part.includes('{') ? blockSelector + '{' + part + '}' // If the part doesn't contain braces, it applies to the root level.
|
|
910
|
+
: blockSelector + part; // Prepend the selector, which effectively replaces the "&" character.
|
|
911
|
+
});
|
|
912
|
+
return processedCSS;
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
function useGlobalStylesOutput() {
|
|
916
|
+
let {
|
|
917
|
+
merged: mergedConfig
|
|
918
|
+
} = (0, _element.useContext)(_context.GlobalStylesContext);
|
|
919
|
+
const [blockGap] = (0, _hooks.useGlobalSetting)('spacing.blockGap');
|
|
920
|
+
const hasBlockGapSupport = blockGap !== null;
|
|
921
|
+
const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
|
|
922
|
+
|
|
923
|
+
const disableLayoutStyles = (0, _data.useSelect)(select => {
|
|
924
|
+
const {
|
|
925
|
+
getSettings
|
|
926
|
+
} = select(_store.store);
|
|
927
|
+
return !!getSettings().disableLayoutStyles;
|
|
928
|
+
});
|
|
929
|
+
const getBlockStyles = (0, _data.useSelect)(select => {
|
|
930
|
+
return select(_blocks.store).getBlockStyles;
|
|
931
|
+
}, []);
|
|
932
|
+
return (0, _element.useMemo)(() => {
|
|
933
|
+
var _mergedConfig, _mergedConfig2, _mergedConfig$styles$;
|
|
934
|
+
|
|
935
|
+
if (!((_mergedConfig = mergedConfig) !== null && _mergedConfig !== void 0 && _mergedConfig.styles) || !((_mergedConfig2 = mergedConfig) !== null && _mergedConfig2 !== void 0 && _mergedConfig2.settings)) {
|
|
936
|
+
return [];
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
mergedConfig = updateConfigWithSeparator(mergedConfig);
|
|
940
|
+
const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)(), getBlockStyles);
|
|
941
|
+
const customProperties = toCustomProperties(mergedConfig, blockSelectors);
|
|
942
|
+
const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
|
|
943
|
+
const filters = toSvgFilters(mergedConfig, blockSelectors);
|
|
944
|
+
const stylesheets = [{
|
|
945
|
+
css: customProperties,
|
|
946
|
+
isGlobalStyles: true
|
|
947
|
+
}, {
|
|
948
|
+
css: globalStyles,
|
|
949
|
+
isGlobalStyles: true
|
|
950
|
+
}, // Load custom CSS in own stylesheet so that any invalid CSS entered in the input won't break all the global styles in the editor.
|
|
951
|
+
{
|
|
952
|
+
css: (_mergedConfig$styles$ = mergedConfig.styles.css) !== null && _mergedConfig$styles$ !== void 0 ? _mergedConfig$styles$ : '',
|
|
953
|
+
isGlobalStyles: true
|
|
954
|
+
}]; // Loop through the blocks to check if there are custom CSS values.
|
|
955
|
+
// If there are, get the block selector and push the selector together with
|
|
956
|
+
// the CSS value to the 'stylesheets' array.
|
|
957
|
+
|
|
958
|
+
(0, _blocks.getBlockTypes)().forEach(blockType => {
|
|
959
|
+
var _mergedConfig$styles$2;
|
|
960
|
+
|
|
961
|
+
if ((_mergedConfig$styles$2 = mergedConfig.styles.blocks[blockType.name]) !== null && _mergedConfig$styles$2 !== void 0 && _mergedConfig$styles$2.css) {
|
|
962
|
+
var _mergedConfig$styles$3;
|
|
963
|
+
|
|
964
|
+
const selector = blockSelectors[blockType.name].selector;
|
|
965
|
+
stylesheets.push({
|
|
966
|
+
css: processCSSNesting((_mergedConfig$styles$3 = mergedConfig.styles.blocks[blockType.name]) === null || _mergedConfig$styles$3 === void 0 ? void 0 : _mergedConfig$styles$3.css, selector),
|
|
967
|
+
isGlobalStyles: true
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
return [stylesheets, mergedConfig.settings, filters];
|
|
972
|
+
}, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
|
|
973
|
+
}
|
|
974
|
+
//# sourceMappingURL=use-global-styles-output.js.map
|