@wordpress/block-editor 13.2.0 → 13.4.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 +4 -0
- package/README.md +0 -5
- package/build/components/alignment-control/ui.js +2 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +1 -1
- package/build/components/block-alignment-control/ui.native.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -3
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +25 -9
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -2
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +2 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +0 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +1 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +5 -7
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +20 -17
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -0
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js +4 -12
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-switcher/index.js +1 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +11 -12
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +20 -17
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +6 -2
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -58
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/index.js +14 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +9 -8
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserter-button.js +45 -0
- package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
- package/build/components/block-tools/zoom-out-mode-inserters.js +29 -28
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +58 -0
- package/build/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build/components/block-tools/zoom-out-toolbar.js +138 -0
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build/components/button-block-appender/index.js +3 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +26 -18
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +7 -4
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/dimensions-tool/index.js +6 -4
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +22 -62
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +185 -116
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +13 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +45 -24
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +121 -0
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +47 -13
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +90 -48
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +2 -2
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +117 -37
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +60 -41
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/index.js +1 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +1 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +20 -3
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +10 -3
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/settings-tab.js +1 -2
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +2 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/utils.js +3 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.js +19 -23
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -3
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +66 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -0
- package/build/components/url-popover/image-url-input-ui.js +3 -3
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/index.js +3 -0
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/background.js +26 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +11 -17
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +169 -4
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +62 -0
- package/build/hooks/grid-visualizer.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +47 -23
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +4 -15
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +96 -55
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +2 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +50 -4
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +92 -51
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +6 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +18 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +0 -3
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/reducer.js +19 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +13 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/format-font-style.js +45 -0
- package/build/utils/format-font-style.js.map +1 -0
- package/build/utils/format-font-weight.js +68 -0
- package/build/utils/format-font-weight.js.map +1 -0
- package/build/utils/get-editor-region.js +34 -0
- package/build/utils/get-editor-region.js.map +1 -0
- package/build/utils/get-font-styles-and-weights.js +167 -0
- package/build/utils/get-font-styles-and-weights.js.map +1 -0
- package/build/utils/pasting.js +5 -13
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +2 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +1 -1
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +1 -1
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +12 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -3
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +26 -9
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +3 -2
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +2 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +0 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +5 -7
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +20 -17
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +2 -0
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +5 -13
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-switcher/index.js +1 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +12 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +20 -17
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +6 -2
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +10 -61
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +9 -8
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +37 -0
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +30 -29
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +49 -0
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build-module/components/button-block-appender/index.js +3 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +27 -19
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -2
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +7 -4
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +6 -4
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +24 -62
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +188 -119
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +13 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +47 -26
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +117 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +47 -13
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +93 -50
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +2 -2
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +118 -38
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +61 -42
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +20 -3
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +10 -3
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -2
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +3 -7
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +2 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/utils.js +3 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +19 -23
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -3
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +60 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -0
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/index.js +3 -0
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/background.js +26 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +11 -17
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +168 -4
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +61 -0
- package/build-module/hooks/grid-visualizer.js.map +1 -0
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +47 -23
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +4 -15
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +96 -56
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +2 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +50 -4
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +92 -51
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +8 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +15 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +0 -3
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/reducer.js +18 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +10 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/format-font-style.js +39 -0
- package/build-module/utils/format-font-style.js.map +1 -0
- package/build-module/utils/format-font-weight.js +62 -0
- package/build-module/utils/format-font-weight.js.map +1 -0
- package/build-module/utils/get-editor-region.js +28 -0
- package/build-module/utils/get-editor-region.js.map +1 -0
- package/build-module/utils/get-font-styles-and-weights.js +160 -0
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
- package/build-module/utils/pasting.js +5 -13
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +7 -6
- package/build-style/content.css +7 -6
- package/build-style/style-rtl.css +356 -181
- package/build-style/style.css +356 -181
- package/build-types/components/block-context/index.d.ts +2 -2
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/components/alignment-control/ui.js +2 -2
- package/src/components/block-alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/ui.native.js +1 -1
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-context/README.md +4 -4
- package/src/components/block-inspector/index.js +8 -4
- package/src/components/block-list/content.scss +2 -16
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
- package/src/components/block-list/use-block-props/use-is-hovered.js +26 -11
- package/src/components/block-list/use-in-between-inserter.js +5 -1
- package/src/components/block-lock/modal.js +10 -2
- package/src/components/block-lock/style.scss +4 -8
- package/src/components/block-lock/toolbar.js +0 -1
- package/src/components/block-mover/button.js +1 -1
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/src/components/block-patterns-paging/index.js +8 -11
- package/src/components/block-patterns-paging/style.scss +0 -5
- package/src/components/block-quick-navigation/index.js +21 -28
- package/src/components/block-removal-warning-modal/index.js +10 -2
- package/src/components/block-rename/modal.js +2 -8
- package/src/components/block-switcher/index.js +1 -1
- package/src/components/block-switcher/pattern-transformations-menu.js +17 -15
- package/src/components/block-switcher/preview-block-popover.js +20 -14
- package/src/components/block-switcher/style.scss +8 -17
- package/src/components/block-switcher/test/index.js +6 -6
- package/src/components/block-toolbar/shuffle.js +9 -1
- package/src/components/block-toolbar/style.scss +1 -11
- package/src/components/block-tools/block-selection-button.js +11 -83
- package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
- package/src/components/block-tools/index.js +21 -1
- package/src/components/block-tools/style.scss +23 -0
- package/src/components/block-tools/use-show-block-tools.js +21 -10
- package/src/components/block-tools/zoom-out-mode-inserter-button.js +47 -0
- package/src/components/block-tools/zoom-out-mode-inserters.js +44 -33
- package/src/components/block-tools/zoom-out-popover.js +50 -0
- package/src/components/block-tools/zoom-out-toolbar.js +140 -0
- package/src/components/button-block-appender/index.js +2 -1
- package/src/components/child-layout-control/index.js +41 -23
- package/src/components/date-format-picker/index.js +2 -2
- package/src/components/date-format-picker/style.scss +0 -9
- package/src/components/default-block-appender/index.js +11 -4
- package/src/components/dimensions-tool/index.js +97 -89
- package/src/components/font-appearance-control/index.js +24 -82
- package/src/components/font-appearance-control/style.scss +3 -5
- package/src/components/global-styles/background-panel.js +266 -167
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/hooks.js +14 -1
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/style.scss +116 -19
- package/src/components/global-styles/test/typography-utils.js +594 -0
- package/src/components/global-styles/test/use-global-styles-output.js +3 -1
- package/src/components/global-styles/typography-panel.js +56 -27
- package/src/components/global-styles/typography-utils.js +159 -0
- package/src/components/global-styles/use-global-styles-output.js +45 -10
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +140 -86
- package/src/components/grid/grid-item-resizer.js +3 -2
- package/src/components/grid/grid-visualizer.js +172 -55
- package/src/components/grid/style.scss +157 -8
- package/src/components/grid/use-grid-layout-sync.js +88 -46
- package/src/components/iframe/content.scss +2 -1
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/index.js +6 -2
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
- package/src/components/inserter/media-tab/media-panel.js +1 -0
- package/src/components/inserter/menu.js +47 -13
- package/src/components/inserter/preview-panel.js +27 -4
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +58 -92
- package/src/components/inserter-draggable-blocks/index.js +11 -3
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
- package/src/components/inspector-controls-tabs/style.scss +0 -21
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/list-view/block-select-button.js +3 -13
- package/src/components/list-view/block.js +10 -3
- package/src/components/list-view/style.scss +2 -1
- package/src/components/list-view/utils.js +13 -2
- package/src/components/media-placeholder/index.js +22 -32
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +9 -2
- package/src/components/tabbed-sidebar/README.md +76 -0
- package/src/components/tabbed-sidebar/index.js +70 -0
- package/src/components/tabbed-sidebar/style.scss +53 -0
- package/src/components/url-popover/image-url-input-ui.js +3 -3
- package/src/components/url-popover/index.js +3 -0
- package/src/components/url-popover/style.scss +1 -0
- package/src/hooks/background.js +25 -10
- package/src/hooks/block-hooks.js +9 -16
- package/src/hooks/block-style-variation.js +202 -3
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/grid-visualizer.js +62 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +64 -39
- package/src/hooks/position.js +3 -20
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +107 -63
- package/src/hooks/utils.js +2 -0
- package/src/layouts/constrained.js +53 -4
- package/src/layouts/grid.js +148 -51
- package/src/private-apis.js +12 -7
- package/src/store/actions.js +15 -0
- package/src/store/defaults.js +0 -2
- package/src/store/defaults.native.js +0 -3
- package/src/store/private-keys.js +1 -0
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +10 -0
- package/src/style.scss +1 -1
- package/src/utils/format-font-style.js +40 -0
- package/src/utils/format-font-weight.js +63 -0
- package/src/utils/get-editor-region.js +31 -0
- package/src/utils/get-font-styles-and-weights.js +191 -0
- package/src/utils/pasting.js +5 -12
- package/src/utils/test/format-font-style.js +34 -0
- package/src/utils/test/format-font-weight.js +66 -0
- package/src/utils/test/get-font-styles-and-weights.js +513 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +0 -71
- package/build/components/inserter/reusable-block-rename-hint.js.map +0 -1
- package/build/components/inspector-controls-tabs/settings-tab-hint.js +0 -53
- package/build/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +0 -64
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +0 -1
- package/build-module/components/inspector-controls-tabs/settings-tab-hint.js +0 -47
- package/build-module/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
- package/src/components/inserter/reusable-block-rename-hint.js +0 -69
- package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
- package/src/hooks/position.scss +0 -18
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.findNearestFontStyle = findNearestFontStyle;
|
|
7
|
+
exports.findNearestFontWeight = findNearestFontWeight;
|
|
8
|
+
exports.findNearestStyleAndWeight = findNearestStyleAndWeight;
|
|
6
9
|
exports.getFluidTypographyOptionsFromSettings = getFluidTypographyOptionsFromSettings;
|
|
10
|
+
exports.getMergedFontFamiliesAndFontFamilyFaces = getMergedFontFamiliesAndFontFamilyFaces;
|
|
7
11
|
exports.getTypographyFontSizeValue = getTypographyFontSizeValue;
|
|
8
12
|
var _fluidUtils = require("../font-sizes/fluid-utils");
|
|
13
|
+
var _getFontStylesAndWeights = require("../../utils/get-font-styles-and-weights");
|
|
9
14
|
/**
|
|
10
15
|
* The fluid utilities must match the backend equivalent.
|
|
11
16
|
* See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
|
|
@@ -106,4 +111,120 @@ function getFluidTypographyOptionsFromSettings(settings) {
|
|
|
106
111
|
fluid: typographySettings?.fluid
|
|
107
112
|
};
|
|
108
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Returns an object of merged font families and the font faces from the selected font family
|
|
117
|
+
* based on the theme.json settings object and the currently selected font family.
|
|
118
|
+
*
|
|
119
|
+
* @param {Object} settings Theme.json settings.
|
|
120
|
+
* @param {string} selectedFontFamily Decoded font family string.
|
|
121
|
+
* @return {Object} Merged font families and font faces from the selected font family.
|
|
122
|
+
*/
|
|
123
|
+
function getMergedFontFamiliesAndFontFamilyFaces(settings, selectedFontFamily) {
|
|
124
|
+
var _fontFamilies$find$fo;
|
|
125
|
+
const fontFamiliesFromSettings = settings?.typography?.fontFamilies;
|
|
126
|
+
const fontFamilies = ['default', 'theme', 'custom'].flatMap(key => {
|
|
127
|
+
var _fontFamiliesFromSett;
|
|
128
|
+
return (_fontFamiliesFromSett = fontFamiliesFromSettings?.[key]) !== null && _fontFamiliesFromSett !== void 0 ? _fontFamiliesFromSett : [];
|
|
129
|
+
});
|
|
130
|
+
const fontFamilyFaces = (_fontFamilies$find$fo = fontFamilies.find(family => family.fontFamily === selectedFontFamily)?.fontFace) !== null && _fontFamilies$find$fo !== void 0 ? _fontFamilies$find$fo : [];
|
|
131
|
+
return {
|
|
132
|
+
fontFamilies,
|
|
133
|
+
fontFamilyFaces
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Returns the nearest font weight value from the available font weight list based on the new font weight.
|
|
139
|
+
* The nearest font weight is the one with the smallest difference from the new font weight.
|
|
140
|
+
*
|
|
141
|
+
* @param {Array} availableFontWeights Array of available font weights.
|
|
142
|
+
* @param {string} newFontWeightValue New font weight value.
|
|
143
|
+
* @return {string} Nearest font weight.
|
|
144
|
+
*/
|
|
145
|
+
function findNearestFontWeight(availableFontWeights, newFontWeightValue) {
|
|
146
|
+
if (!newFontWeightValue || typeof newFontWeightValue !== 'string') {
|
|
147
|
+
return '';
|
|
148
|
+
}
|
|
149
|
+
if (!availableFontWeights || availableFontWeights.length === 0) {
|
|
150
|
+
return newFontWeightValue;
|
|
151
|
+
}
|
|
152
|
+
const nearestFontWeight = availableFontWeights?.reduce((nearest, {
|
|
153
|
+
value: fw
|
|
154
|
+
}) => {
|
|
155
|
+
const currentDiff = Math.abs(parseInt(fw) - parseInt(newFontWeightValue));
|
|
156
|
+
const nearestDiff = Math.abs(parseInt(nearest) - parseInt(newFontWeightValue));
|
|
157
|
+
return currentDiff < nearestDiff ? fw : nearest;
|
|
158
|
+
}, availableFontWeights[0]?.value);
|
|
159
|
+
return nearestFontWeight;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Returns the nearest font style based on the new font style.
|
|
164
|
+
* Defaults to an empty string if the new font style is not valid or available.
|
|
165
|
+
*
|
|
166
|
+
* @param {Array} availableFontStyles Array of available font weights.
|
|
167
|
+
* @param {string} newFontStyleValue New font style value.
|
|
168
|
+
* @return {string} Nearest font style or an empty string.
|
|
169
|
+
*/
|
|
170
|
+
function findNearestFontStyle(availableFontStyles, newFontStyleValue) {
|
|
171
|
+
if (typeof newFontStyleValue !== 'string' || !newFontStyleValue) {
|
|
172
|
+
return '';
|
|
173
|
+
}
|
|
174
|
+
const validStyles = ['normal', 'italic', 'oblique'];
|
|
175
|
+
if (!validStyles.includes(newFontStyleValue)) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
if (!availableFontStyles || availableFontStyles.length === 0 || availableFontStyles.find(style => style.value === newFontStyleValue)) {
|
|
179
|
+
return newFontStyleValue;
|
|
180
|
+
}
|
|
181
|
+
if (newFontStyleValue === 'oblique' && !availableFontStyles.find(style => style.value === 'oblique')) {
|
|
182
|
+
return 'italic';
|
|
183
|
+
}
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Returns the nearest font style and weight based on the available font family faces and the new font style and weight.
|
|
189
|
+
*
|
|
190
|
+
* @param {Array} fontFamilyFaces Array of available font family faces.
|
|
191
|
+
* @param {string} fontStyle New font style. Defaults to previous value.
|
|
192
|
+
* @param {string} fontWeight New font weight. Defaults to previous value.
|
|
193
|
+
* @return {Object} Nearest font style and font weight.
|
|
194
|
+
*/
|
|
195
|
+
function findNearestStyleAndWeight(fontFamilyFaces, fontStyle, fontWeight) {
|
|
196
|
+
let nearestFontStyle = fontStyle;
|
|
197
|
+
let nearestFontWeight = fontWeight;
|
|
198
|
+
const {
|
|
199
|
+
fontStyles,
|
|
200
|
+
fontWeights,
|
|
201
|
+
combinedStyleAndWeightOptions
|
|
202
|
+
} = (0, _getFontStylesAndWeights.getFontStylesAndWeights)(fontFamilyFaces);
|
|
203
|
+
|
|
204
|
+
// Check if the new font style and weight are available in the font family faces.
|
|
205
|
+
const hasFontStyle = fontStyles?.some(({
|
|
206
|
+
value: fs
|
|
207
|
+
}) => fs === fontStyle);
|
|
208
|
+
const hasFontWeight = fontWeights?.some(({
|
|
209
|
+
value: fw
|
|
210
|
+
}) => fw === fontWeight);
|
|
211
|
+
if (!hasFontStyle) {
|
|
212
|
+
/*
|
|
213
|
+
* Default to italic if oblique is not available.
|
|
214
|
+
* Or find the nearest font style based on the nearest font weight.
|
|
215
|
+
*/
|
|
216
|
+
nearestFontStyle = fontStyle ? findNearestFontStyle(fontStyles, fontStyle) : combinedStyleAndWeightOptions?.find(option => option.style.fontWeight === findNearestFontWeight(fontWeights, fontWeight))?.style?.fontStyle;
|
|
217
|
+
}
|
|
218
|
+
if (!hasFontWeight) {
|
|
219
|
+
/*
|
|
220
|
+
* Find the nearest font weight based on available weights.
|
|
221
|
+
* Or find the nearest font weight based on the nearest font style.
|
|
222
|
+
*/
|
|
223
|
+
nearestFontWeight = fontWeight ? findNearestFontWeight(fontWeights, fontWeight) : combinedStyleAndWeightOptions?.find(option => option.style.fontStyle === (nearestFontStyle || fontStyle))?.style?.fontWeight;
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
nearestFontStyle,
|
|
227
|
+
nearestFontWeight
|
|
228
|
+
};
|
|
229
|
+
}
|
|
109
230
|
//# sourceMappingURL=typography-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fluidUtils","require","getTypographyFontSizeValue","preset","settings","size","defaultSize","isFluidTypographyEnabled","typography","fluid","fluidTypographySettings","getFluidTypographyOptionsFromSettings","fluidFontSizeValue","getComputedFluidTypographyValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize","maximumViewportWidth","maxViewportWidth","minimumViewportWidth","minViewportWidth","typographySettings","fluidSettings","Object","keys","length","layoutSettings","layout","defaultMaxViewportWidth","getTypographyValueAndUnit","wideSize"],"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetComputedFluidTypographyValue,\n\tgetTypographyValueAndUnit,\n} from '../font-sizes/fluid-utils';\n\n/**\n * @typedef {Object} FluidPreset\n * @property {string|undefined} max A maximum font size value.\n * @property {?string|undefined} min A minimum font size value.\n */\n\n/**\n * @typedef {Object} Preset\n * @property {?string|?number} size A default font size.\n * @property {string} name A font size name, displayed in the UI.\n * @property {string} slug A font size slug\n * @property {boolean|FluidPreset|undefined} fluid Specifies the minimum and maximum font size value of a fluid font size.\n */\n\n/**\n * @typedef {Object} TypographySettings\n * @property {?string} minViewportWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.\n * @property {?string} maxViewportWidth Maximum size up to which type will have fluidity. Optional if size is specified.\n * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @property {?string} minFontSize The smallest a calculated font size may be. Optional.\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Preset} preset\n * @param {Object} settings\n * @param {boolean|TypographySettings} settings.typography.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.\n * @param {Object?} settings.typography.layout Layout options.\n *\n * @return {string|*} A font-size value or the value of preset.size.\n */\nexport function getTypographyFontSizeValue( preset, settings ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( ! isFluidTypographyEnabled( settings?.typography ) ) {\n\t\treturn defaultSize;\n\t}\n\t/*\n\t * Checks whether a font size has explicitly bypassed fluid calculations.\n\t * Also catches falsy values and 0/'0'.\n\t * Fluid calculations cannot be performed on `0`.\n\t */\n\tif ( ! defaultSize || '0' === defaultSize || false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tlet fluidTypographySettings =\n\t\tgetFluidTypographyOptionsFromSettings( settings );\n\tfluidTypographySettings =\n\t\ttypeof fluidTypographySettings?.fluid === 'object'\n\t\t\t? fluidTypographySettings?.fluid\n\t\t\t: {};\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t\tminimumFontSizeLimit: fluidTypographySettings?.minFontSize,\n\t\tmaximumViewportWidth: fluidTypographySettings?.maxViewportWidth,\n\t\tminimumViewportWidth: fluidTypographySettings?.minViewportWidth,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\nfunction isFluidTypographyEnabled( typographySettings ) {\n\tconst fluidSettings = typographySettings?.fluid;\n\treturn (\n\t\ttrue === fluidSettings ||\n\t\t( fluidSettings &&\n\t\t\ttypeof fluidSettings === 'object' &&\n\t\t\tObject.keys( fluidSettings ).length > 0 )\n\t);\n}\n\n/**\n * Returns fluid typography settings from theme.json setting object.\n *\n * @param {Object} settings Theme.json settings\n * @param {Object} settings.typography Theme.json typography settings\n * @param {Object} settings.layout Theme.json layout settings\n * @return {TypographySettings} Fluid typography settings\n */\nexport function getFluidTypographyOptionsFromSettings( settings ) {\n\tconst typographySettings = settings?.typography;\n\tconst layoutSettings = settings?.layout;\n\tconst defaultMaxViewportWidth = getTypographyValueAndUnit(\n\t\tlayoutSettings?.wideSize\n\t)\n\t\t? layoutSettings?.wideSize\n\t\t: null;\n\treturn isFluidTypographyEnabled( typographySettings ) &&\n\t\tdefaultMaxViewportWidth\n\t\t? {\n\t\t\t\tfluid: {\n\t\t\t\t\tmaxViewportWidth: defaultMaxViewportWidth,\n\t\t\t\t\t...typographySettings.fluid,\n\t\t\t\t},\n\t\t }\n\t\t: {\n\t\t\t\tfluid: typographySettings?.fluid,\n\t\t };\n}\n"],"mappings":";;;;;;;AASA,IAAAA,WAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,0BAA0BA,CAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC9D,MAAM;IAAEC,IAAI,EAAEC;EAAY,CAAC,GAAGH,MAAM;EAEpC,IAAK,CAAEI,wBAAwB,CAAEH,QAAQ,EAAEI,UAAW,CAAC,EAAG;IACzD,O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yB,EACxDH,cAAc,EAAEI,QACjB,CAAC,GACEJ,cAAc,EAAEI,QAAQ,GACxB,IAAI;EACP,OAAO3B,wBAAwB,CAAEkB,kBAAmB,CAAC,IACpDO,uBAAuB,GACrB;IACAvB,KAAK,EAAE;MACNa,gBAAgB,EAAEU,uBAAuB;MACzC,GAAGP,kBAAkB,CAAChB;IACvB;EACA,CAAC,GACD;IACAA,KAAK,EAAEgB,kBAAkB,EAAEhB;EAC3B,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_fluidUtils","require","_getFontStylesAndWeights","getTypographyFontSizeValue","preset","settings","size","defaultSize","isFluidTypographyEnabled","typography","fluid","fluidTypographySettings","getFluidTypographyOptionsFromSettings","fluidFontSizeValue","getComputedFluidTypographyValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize","maximumViewportWidth","maxViewportWidth","minimumViewportWidth","minViewportWidth","typographySettings","fluidSettings","Object","keys","length","layoutSettings","layout","defaultMaxViewportWidth","getTypographyValueAndUnit","wideSize","getMergedFontFamiliesAndFontFamilyFaces","selectedFontFamily","_fontFamilies$find$fo","fontFamiliesFromSettings","fontFamilies","flatMap","key","_fontFamiliesFromSett","fontFamilyFaces","find","family","fontFamily","fontFace","findNearestFontWeight","availableFontWeights","newFontWeightValue","nearestFontWeight","reduce","nearest","value","fw","currentDiff","Math","abs","parseInt","nearestDiff","findNearestFontStyle","availableFontStyles","newFontStyleValue","validStyles","includes","style","findNearestStyleAndWeight","fontStyle","fontWeight","nearestFontStyle","fontStyles","fontWeights","combinedStyleAndWeightOptions","getFontStylesAndWeights","hasFontStyle","some","fs","hasFontWeight","option"],"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetComputedFluidTypographyValue,\n\tgetTypographyValueAndUnit,\n} from '../font-sizes/fluid-utils';\nimport { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';\n\n/**\n * @typedef {Object} FluidPreset\n * @property {string|undefined} max A maximum font size value.\n * @property {?string|undefined} min A minimum font size value.\n */\n\n/**\n * @typedef {Object} Preset\n * @property {?string|?number} size A default font size.\n * @property {string} name A font size name, displayed in the UI.\n * @property {string} slug A font size slug\n * @property {boolean|FluidPreset|undefined} fluid Specifies the minimum and maximum font size value of a fluid font size.\n */\n\n/**\n * @typedef {Object} TypographySettings\n * @property {?string} minViewportWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.\n * @property {?string} maxViewportWidth Maximum size up to which type will have fluidity. Optional if size is specified.\n * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @property {?string} minFontSize The smallest a calculated font size may be. Optional.\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Preset} preset\n * @param {Object} settings\n * @param {boolean|TypographySettings} settings.typography.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.\n * @param {Object?} settings.typography.layout Layout options.\n *\n * @return {string|*} A font-size value or the value of preset.size.\n */\nexport function getTypographyFontSizeValue( preset, settings ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( ! isFluidTypographyEnabled( settings?.typography ) ) {\n\t\treturn defaultSize;\n\t}\n\t/*\n\t * Checks whether a font size has explicitly bypassed fluid calculations.\n\t * Also catches falsy values and 0/'0'.\n\t * Fluid calculations cannot be performed on `0`.\n\t */\n\tif ( ! defaultSize || '0' === defaultSize || false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tlet fluidTypographySettings =\n\t\tgetFluidTypographyOptionsFromSettings( settings );\n\tfluidTypographySettings =\n\t\ttypeof fluidTypographySettings?.fluid === 'object'\n\t\t\t? fluidTypographySettings?.fluid\n\t\t\t: {};\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t\tminimumFontSizeLimit: fluidTypographySettings?.minFontSize,\n\t\tmaximumViewportWidth: fluidTypographySettings?.maxViewportWidth,\n\t\tminimumViewportWidth: fluidTypographySettings?.minViewportWidth,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\nfunction isFluidTypographyEnabled( typographySettings ) {\n\tconst fluidSettings = typographySettings?.fluid;\n\treturn (\n\t\ttrue === fluidSettings ||\n\t\t( fluidSettings &&\n\t\t\ttypeof fluidSettings === 'object' &&\n\t\t\tObject.keys( fluidSettings ).length > 0 )\n\t);\n}\n\n/**\n * Returns fluid typography settings from theme.json setting object.\n *\n * @param {Object} settings Theme.json settings\n * @param {Object} settings.typography Theme.json typography settings\n * @param {Object} settings.layout Theme.json layout settings\n * @return {TypographySettings} Fluid typography settings\n */\nexport function getFluidTypographyOptionsFromSettings( settings ) {\n\tconst typographySettings = settings?.typography;\n\tconst layoutSettings = settings?.layout;\n\tconst defaultMaxViewportWidth = getTypographyValueAndUnit(\n\t\tlayoutSettings?.wideSize\n\t)\n\t\t? layoutSettings?.wideSize\n\t\t: null;\n\treturn isFluidTypographyEnabled( typographySettings ) &&\n\t\tdefaultMaxViewportWidth\n\t\t? {\n\t\t\t\tfluid: {\n\t\t\t\t\tmaxViewportWidth: defaultMaxViewportWidth,\n\t\t\t\t\t...typographySettings.fluid,\n\t\t\t\t},\n\t\t }\n\t\t: {\n\t\t\t\tfluid: typographySettings?.fluid,\n\t\t };\n}\n\n/**\n * Returns an object of merged font families and the font faces from the selected font family\n * based on the theme.json settings object and the currently selected font family.\n *\n * @param {Object} settings Theme.json settings.\n * @param {string} selectedFontFamily Decoded font family string.\n * @return {Object} Merged font families and font faces from the selected font family.\n */\nexport function getMergedFontFamiliesAndFontFamilyFaces(\n\tsettings,\n\tselectedFontFamily\n) {\n\tconst fontFamiliesFromSettings = settings?.typography?.fontFamilies;\n\n\tconst fontFamilies = [ 'default', 'theme', 'custom' ].flatMap(\n\t\t( key ) => fontFamiliesFromSettings?.[ key ] ?? []\n\t);\n\n\tconst fontFamilyFaces =\n\t\tfontFamilies.find(\n\t\t\t( family ) => family.fontFamily === selectedFontFamily\n\t\t)?.fontFace ?? [];\n\n\treturn { fontFamilies, fontFamilyFaces };\n}\n\n/**\n * Returns the nearest font weight value from the available font weight list based on the new font weight.\n * The nearest font weight is the one with the smallest difference from the new font weight.\n *\n * @param {Array} availableFontWeights Array of available font weights.\n * @param {string} newFontWeightValue New font weight value.\n * @return {string} Nearest font weight.\n */\nexport function findNearestFontWeight(\n\tavailableFontWeights,\n\tnewFontWeightValue\n) {\n\tif ( ! newFontWeightValue || typeof newFontWeightValue !== 'string' ) {\n\t\treturn '';\n\t}\n\n\tif ( ! availableFontWeights || availableFontWeights.length === 0 ) {\n\t\treturn newFontWeightValue;\n\t}\n\n\tconst nearestFontWeight = availableFontWeights?.reduce(\n\t\t( nearest, { value: fw } ) => {\n\t\t\tconst currentDiff = Math.abs(\n\t\t\t\tparseInt( fw ) - parseInt( newFontWeightValue )\n\t\t\t);\n\t\t\tconst nearestDiff = Math.abs(\n\t\t\t\tparseInt( nearest ) - parseInt( newFontWeightValue )\n\t\t\t);\n\t\t\treturn currentDiff < nearestDiff ? fw : nearest;\n\t\t},\n\t\tavailableFontWeights[ 0 ]?.value\n\t);\n\n\treturn nearestFontWeight;\n}\n\n/**\n * Returns the nearest font style based on the new font style.\n * Defaults to an empty string if the new font style is not valid or available.\n *\n * @param {Array} availableFontStyles Array of available font weights.\n * @param {string} newFontStyleValue New font style value.\n * @return {string} Nearest font style or an empty string.\n */\nexport function findNearestFontStyle( availableFontStyles, newFontStyleValue ) {\n\tif ( typeof newFontStyleValue !== 'string' || ! newFontStyleValue ) {\n\t\treturn '';\n\t}\n\n\tconst validStyles = [ 'normal', 'italic', 'oblique' ];\n\tif ( ! validStyles.includes( newFontStyleValue ) ) {\n\t\treturn '';\n\t}\n\n\tif (\n\t\t! availableFontStyles ||\n\t\tavailableFontStyles.length === 0 ||\n\t\tavailableFontStyles.find(\n\t\t\t( style ) => style.value === newFontStyleValue\n\t\t)\n\t) {\n\t\treturn newFontStyleValue;\n\t}\n\n\tif (\n\t\tnewFontStyleValue === 'oblique' &&\n\t\t! availableFontStyles.find( ( style ) => style.value === 'oblique' )\n\t) {\n\t\treturn 'italic';\n\t}\n\n\treturn '';\n}\n\n/**\n * Returns the nearest font style and weight based on the available font family faces and the new font style and weight.\n *\n * @param {Array} fontFamilyFaces Array of available font family faces.\n * @param {string} fontStyle New font style. Defaults to previous value.\n * @param {string} fontWeight New font weight. Defaults to previous value.\n * @return {Object} Nearest font style and font weight.\n */\nexport function findNearestStyleAndWeight(\n\tfontFamilyFaces,\n\tfontStyle,\n\tfontWeight\n) {\n\tlet nearestFontStyle = fontStyle;\n\tlet nearestFontWeight = fontWeight;\n\n\tconst { fontStyles, fontWeights, combinedStyleAndWeightOptions } =\n\t\tgetFontStylesAndWeights( fontFamilyFaces );\n\n\t// Check if the new font style and weight are available in the font family faces.\n\tconst hasFontStyle = fontStyles?.some(\n\t\t( { value: fs } ) => fs === fontStyle\n\t);\n\tconst hasFontWeight = fontWeights?.some(\n\t\t( { value: fw } ) => fw === fontWeight\n\t);\n\n\tif ( ! hasFontStyle ) {\n\t\t/*\n\t\t * Default to italic if oblique is not available.\n\t\t * Or find the nearest font style based on the nearest font weight.\n\t\t */\n\t\tnearestFontStyle = fontStyle\n\t\t\t? findNearestFontStyle( fontStyles, fontStyle )\n\t\t\t: combinedStyleAndWeightOptions?.find(\n\t\t\t\t\t( option ) =>\n\t\t\t\t\t\toption.style.fontWeight ===\n\t\t\t\t\t\tfindNearestFontWeight( fontWeights, fontWeight )\n\t\t\t )?.style?.fontStyle;\n\t}\n\n\tif ( ! hasFontWeight ) {\n\t\t/*\n\t\t * Find the nearest font weight based on available weights.\n\t\t * Or find the nearest font weight based on the nearest font style.\n\t\t */\n\t\tnearestFontWeight = fontWeight\n\t\t\t? findNearestFontWeight( fontWeights, fontWeight )\n\t\t\t: combinedStyleAndWeightOptions?.find(\n\t\t\t\t\t( option ) =>\n\t\t\t\t\t\toption.style.fontStyle ===\n\t\t\t\t\t\t( nearestFontStyle || fontStyle )\n\t\t\t )?.style?.fontWeight;\n\t}\n\n\treturn { nearestFontStyle, nearestFontWeight };\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAAA,WAAA,GAAAC,OAAA;AAIA,IAAAC,wBAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,0BAA0BA,CAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC9D,MAAM;IAAEC,IAAI,EAAEC;EAAY,CAAC,GAAGH,MAAM;EAEpC,IAAK,CAAEI,wBAAwB,CAAEH,QAAQ,EAAEI,UAAW,CAAC,EAAG;IACzD,OAAOF,WAAW;EACnB;EACA;AACD;AACA;AACA;AACA;EACC,IAAK,CAAEA,WAAW,IAAI,GAAG,KAAKA,WAAW,IAAI,KAAK,KAAKH,MAAM,EAAEM,KAAK,EAAG;IACtE,OAAOH,WAAW;EACnB;EAEA,IAAII,uBAAuB,GAC1BC,qCAAqC,CAAEP,QAAS,CAAC;EAClDM,uBAAuB,GACtB,OAAOA,uBAAuB,EAAED,KAAK,KAAK,QAAQ,GAC/CC,uBAAuB,EAAED,KAAK,GAC9B,CAAC,CAAC;EAEN,MAAMG,kBAAkB,GAAG,IAAAC,2CAA+B,EAAE;IAC3DC,eAAe,EA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T,SAC7B,CAAC;EACD,MAAMU,aAAa,GAAGN,WAAW,EAAEI,IAAI,CACtC,CAAE;IAAEtB,KAAK,EAAEC;EAAG,CAAC,KAAMA,EAAE,KAAKc,UAC7B,CAAC;EAED,IAAK,CAAEM,YAAY,EAAG;IACrB;AACF;AACA;AACA;IACEL,gBAAgB,GAAGF,SAAS,GACzBP,oBAAoB,CAAEU,UAAU,EAAEH,SAAU,CAAC,GAC7CK,6BAA6B,EAAE7B,IAAI,CACjCmC,MAAM,IACPA,MAAM,CAACb,KAAK,CAACG,UAAU,KACvBrB,qBAAqB,CAAEwB,WAAW,EAAEH,UAAW,CAChD,CAAC,EAAEH,KAAK,EAAEE,SAAS;EACvB;EAEA,IAAK,CAAEU,aAAa,EAAG;IACtB;AACF;AACA;AACA;IACE3B,iBAAiB,GAAGkB,UAAU,GAC3BrB,qBAAqB,CAAEwB,WAAW,EAAEH,UAAW,CAAC,GAChDI,6BAA6B,EAAE7B,IAAI,CACjCmC,MAAM,IACPA,MAAM,CAACb,KAAK,CAACE,SAAS,MACpBE,gBAAgB,IAAIF,SAAS,CAChC,CAAC,EAAEF,KAAK,EAAEG,UAAU;EACxB;EAEA,OAAO;IAAEC,gBAAgB;IAAEnB;EAAkB,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -24,6 +24,7 @@ var _context = require("./context");
|
|
|
24
24
|
var _hooks = require("./hooks");
|
|
25
25
|
var _utils2 = require("../duotone/utils");
|
|
26
26
|
var _gap = require("../../hooks/gap");
|
|
27
|
+
var _background = require("../../hooks/background");
|
|
27
28
|
var _store = require("../../store");
|
|
28
29
|
var _definitions = require("../../layouts/definitions");
|
|
29
30
|
var _object = require("../../utils/object");
|
|
@@ -37,6 +38,12 @@ var _themeFileUriUtils = require("./theme-file-uri-utils");
|
|
|
37
38
|
* Internal dependencies
|
|
38
39
|
*/
|
|
39
40
|
|
|
41
|
+
// Elements that rely on class names in their selectors.
|
|
42
|
+
const ELEMENT_CLASS_NAMES = {
|
|
43
|
+
button: 'wp-element-button',
|
|
44
|
+
caption: 'wp-element-caption'
|
|
45
|
+
};
|
|
46
|
+
|
|
40
47
|
// List of block support features that can have their related styles
|
|
41
48
|
// generated under their own feature level selector rather than the block's.
|
|
42
49
|
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
@@ -292,6 +299,20 @@ function getStylesDeclarations(blockStyles = {}, selector = '', useRootPaddingAl
|
|
|
292
299
|
return declarations;
|
|
293
300
|
}, []);
|
|
294
301
|
|
|
302
|
+
/*
|
|
303
|
+
* Set background defaults.
|
|
304
|
+
* Applies to all background styles except the top-level site background.
|
|
305
|
+
*/
|
|
306
|
+
if (!isRoot && !!blockStyles.background) {
|
|
307
|
+
blockStyles = {
|
|
308
|
+
...blockStyles,
|
|
309
|
+
background: {
|
|
310
|
+
...blockStyles.background,
|
|
311
|
+
...(0, _background.setBackgroundStyleDefaults)(blockStyles.background)
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
295
316
|
// The goal is to move everything to server side generated engine styles
|
|
296
317
|
// This is temporary as we absorb more and more styles into the engine.
|
|
297
318
|
const extraRules = (0, _styleEngine.getCSSRules)(blockStyles);
|
|
@@ -458,14 +479,20 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
458
479
|
if (styles) {
|
|
459
480
|
nodes.push({
|
|
460
481
|
styles,
|
|
461
|
-
selector: _utils.ROOT_BLOCK_SELECTOR
|
|
482
|
+
selector: _utils.ROOT_BLOCK_SELECTOR,
|
|
483
|
+
// Root selector (body) styles should not be wrapped in `:root where()` to keep
|
|
484
|
+
// specificity at (0,0,1) and maintain backwards compatibility.
|
|
485
|
+
skipSelectorWrapper: true
|
|
462
486
|
});
|
|
463
487
|
}
|
|
464
488
|
Object.entries(_blocks.__EXPERIMENTAL_ELEMENTS).forEach(([name, selector]) => {
|
|
465
489
|
if (tree.styles?.elements?.[name]) {
|
|
466
490
|
nodes.push({
|
|
467
491
|
styles: tree.styles?.elements?.[name],
|
|
468
|
-
selector
|
|
492
|
+
selector,
|
|
493
|
+
// Top level elements that don't use a class name should not receive the
|
|
494
|
+
// `:root :where()` wrapper to maintain backwards compatibility.
|
|
495
|
+
skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]
|
|
469
496
|
});
|
|
470
497
|
}
|
|
471
498
|
});
|
|
@@ -482,7 +509,7 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
482
509
|
if (variation?.css) {
|
|
483
510
|
variations[variationName].css = variation.css;
|
|
484
511
|
}
|
|
485
|
-
const variationSelector = blockSelectors[blockName]
|
|
512
|
+
const variationSelector = blockSelectors[blockName]?.styleVariationSelectors?.[variationName];
|
|
486
513
|
|
|
487
514
|
// Process the variation's inner element styles.
|
|
488
515
|
// This comes before the inner block styles so the
|
|
@@ -500,9 +527,9 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
500
527
|
// Process the variations inner block type styles.
|
|
501
528
|
Object.entries((_variation$blocks = variation?.blocks) !== null && _variation$blocks !== void 0 ? _variation$blocks : {}).forEach(([variationBlockName, variationBlockStyles]) => {
|
|
502
529
|
var _variationBlockStyles;
|
|
503
|
-
const variationBlockSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName]
|
|
504
|
-
const variationDuotoneSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName]
|
|
505
|
-
const variationFeatureSelectors = (0, _utils.scopeFeatureSelectors)(variationSelector, blockSelectors[variationBlockName]
|
|
530
|
+
const variationBlockSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName]?.selector);
|
|
531
|
+
const variationDuotoneSelector = (0, _utils.scopeSelector)(variationSelector, blockSelectors[variationBlockName]?.duotoneSelector);
|
|
532
|
+
const variationFeatureSelectors = (0, _utils.scopeFeatureSelectors)(variationSelector, blockSelectors[variationBlockName]?.featureSelectors);
|
|
506
533
|
const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles);
|
|
507
534
|
if (variationBlockStyles?.css) {
|
|
508
535
|
variationBlockStyleNodes.css = variationBlockStyles.css;
|
|
@@ -511,8 +538,8 @@ const getNodesWithStyles = (tree, blockSelectors) => {
|
|
|
511
538
|
selector: variationBlockSelector,
|
|
512
539
|
duotoneSelector: variationDuotoneSelector,
|
|
513
540
|
featureSelectors: variationFeatureSelectors,
|
|
514
|
-
fallbackGapValue: blockSelectors[variationBlockName]
|
|
515
|
-
hasLayoutSupport: blockSelectors[variationBlockName]
|
|
541
|
+
fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue,
|
|
542
|
+
hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport,
|
|
516
543
|
styles: variationBlockStyleNodes
|
|
517
544
|
});
|
|
518
545
|
|
|
@@ -668,8 +695,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
668
695
|
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
|
|
669
696
|
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
|
|
670
697
|
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
|
|
671
|
-
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull
|
|
672
|
-
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull
|
|
698
|
+
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
|
|
699
|
+
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
|
|
673
700
|
`;
|
|
674
701
|
}
|
|
675
702
|
ruleset += '}';
|
|
@@ -682,7 +709,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
682
709
|
fallbackGapValue,
|
|
683
710
|
hasLayoutSupport,
|
|
684
711
|
featureSelectors,
|
|
685
|
-
styleVariationSelectors
|
|
712
|
+
styleVariationSelectors,
|
|
713
|
+
skipSelectorWrapper
|
|
686
714
|
}) => {
|
|
687
715
|
// Process styles for block support features with custom feature level
|
|
688
716
|
// CSS selectors set.
|
|
@@ -723,7 +751,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
723
751
|
// Process the remaining block styles (they use either normal block class or __experimentalSelector).
|
|
724
752
|
const styleDeclarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree, disableRootPadding);
|
|
725
753
|
if (styleDeclarations?.length) {
|
|
726
|
-
|
|
754
|
+
const generalSelector = skipSelectorWrapper ? selector : `:root :where(${selector})`;
|
|
755
|
+
ruleset += `${generalSelector}{${styleDeclarations.join(';')};}`;
|
|
727
756
|
}
|
|
728
757
|
if (styles?.css) {
|
|
729
758
|
ruleset += processCSSNesting(styles.css, `:root :where(${selector})`);
|
|
@@ -773,7 +802,12 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSuppor
|
|
|
773
802
|
// Split and append pseudo selector to create
|
|
774
803
|
// the proper rules to target the elements.
|
|
775
804
|
const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
|
|
776
|
-
|
|
805
|
+
|
|
806
|
+
// As pseudo classes such as :hover, :focus etc. have class-level
|
|
807
|
+
// specificity, they must use the `:root :where()` wrapper. This.
|
|
808
|
+
// caps the specificity at `0-1-0` to allow proper nesting of variations
|
|
809
|
+
// and block type element styles.
|
|
810
|
+
const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(';')};}`;
|
|
777
811
|
ruleset += pseudoRule;
|
|
778
812
|
});
|
|
779
813
|
}
|