@wordpress/block-editor 13.3.0 → 14.0.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 +13 -0
- package/README.md +11 -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 +3 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -2
- package/build/components/block-draggable/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 +26 -27
- 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-mover/index.js +1 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/cover.js +1 -1
- package/build/components/block-popover/cover.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -2
- package/build/components/block-popover/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-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 +5 -2
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +7 -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 +35 -36
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +2 -1
- package/build/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +1 -2
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/child-layout-control/index.js +3 -1
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -11
- 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/scale-tool.js +1 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/font-appearance-control/index.js +2 -7
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +12 -0
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +63 -52
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +1 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/theme-file-uri-utils.js +0 -59
- package/build/components/global-styles/theme-file-uri-utils.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +26 -44
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +78 -7
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +82 -44
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +96 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +93 -44
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +14 -15
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +2 -2
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +93 -45
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/iframe/index.js +4 -8
- package/build/components/iframe/index.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 +1 -1
- package/build/components/inner-blocks/index.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/category-tabs/index.js +29 -2
- package/build/components/inserter/category-tabs/index.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 +3 -3
- 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-draggable-blocks/index.js +10 -3
- package/build/components/inserter-draggable-blocks/index.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/line-height-control/index.js +0 -15
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.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-replace-flow/index.js +3 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/resolution-tool/index.js +1 -0
- package/build/components/resolution-tool/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/skip-to-selected-block/index.js +4 -2
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-input/button.js +0 -1
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +1 -11
- package/build/components/url-input/index.js.map +1 -1
- 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/link-editor.js +0 -1
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -4
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +3 -6
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -3
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -1
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/block-bindings.js +248 -36
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-hooks.js +1 -0
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +2 -2
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/contrast-checker.js +6 -6
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +5 -8
- package/build/hooks/grid-visualizer.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +9 -2
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/line-height.js +0 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/position.js +3 -7
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +1 -1
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +85 -50
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +1 -1
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/hooks/utils.js +20 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +2 -0
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +0 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +27 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +19 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +17 -5
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-editor-region.js +1 -1
- package/build/utils/get-editor-region.js.map +1 -1
- package/build/utils/get-px-from-css-unit.js +1 -1
- package/build/utils/get-px-from-css-unit.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 +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +3 -3
- package/build-module/components/block-draggable/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 +27 -30
- 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-mover/index.js +1 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/cover.js +1 -1
- package/build-module/components/block-popover/cover.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/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-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 +5 -2
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +7 -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 +37 -38
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +2 -1
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +1 -2
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +3 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -12
- 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/scale-tool.js +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +3 -6
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +11 -0
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +63 -52
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +1 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/theme-file-uri-utils.js +0 -58
- package/build-module/components/global-styles/theme-file-uri-utils.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +27 -45
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +76 -7
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +81 -43
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +92 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +96 -46
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +14 -15
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +2 -2
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +94 -46
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -8
- package/build-module/components/iframe/index.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 +1 -1
- package/build-module/components/inner-blocks/index.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/category-tabs/index.js +30 -3
- package/build-module/components/inserter/category-tabs/index.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 +3 -3
- 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-draggable-blocks/index.js +10 -3
- package/build-module/components/inserter-draggable-blocks/index.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/line-height-control/index.js +0 -14
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.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-replace-flow/index.js +3 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +1 -0
- package/build-module/components/resolution-tool/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/skip-to-selected-block/index.js +5 -3
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/button.js +0 -1
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -11
- package/build-module/components/url-input/index.js.map +1 -1
- 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/link-editor.js +0 -1
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +30 -4
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -6
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -3
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/block-bindings.js +253 -40
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-hooks.js +1 -0
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +3 -3
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +7 -7
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +5 -8
- package/build-module/hooks/grid-visualizer.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +9 -2
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/position.js +3 -7
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +1 -1
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +84 -51
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +1 -1
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/hooks/utils.js +19 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +2 -0
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +1 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +24 -1
- package/build-module/store/actions.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 +14 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-editor-region.js +1 -1
- package/build-module/utils/get-editor-region.js.map +1 -1
- package/build-module/utils/get-px-from-css-unit.js +1 -1
- package/build-module/utils/get-px-from-css-unit.js.map +1 -1
- package/build-style/content-rtl.css +11 -18
- package/build-style/content.css +11 -18
- package/build-style/default-editor-styles-rtl.css +3 -0
- package/build-style/default-editor-styles.css +3 -0
- package/build-style/style-rtl.css +242 -136
- package/build-style/style.css +242 -136
- 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 +31 -31
- package/src/autocompleters/style.scss +4 -0
- 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 +4 -2
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-context/README.md +4 -4
- package/src/components/block-draggable/index.js +3 -3
- 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 +30 -30
- 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-mover/index.js +5 -2
- package/src/components/block-patterns-paging/style.scss +0 -23
- package/src/components/block-popover/cover.js +1 -1
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-removal-warning-modal/index.js +10 -2
- 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-toolbar/shuffle.js +8 -1
- package/src/components/block-tools/block-selection-button.js +1 -2
- package/src/components/block-tools/index.js +5 -6
- package/src/components/block-tools/style.scss +8 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/src/components/block-tools/use-show-block-tools.js +12 -9
- package/src/components/block-tools/zoom-out-mode-inserter-button.js +47 -0
- package/src/components/block-tools/zoom-out-mode-inserters.js +48 -42
- package/src/components/block-tools/zoom-out-popover.js +1 -0
- package/src/components/block-tools/zoom-out-toolbar.js +1 -2
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
- package/src/components/colors-gradients/test/control.js +3 -2
- package/src/components/date-format-picker/index.js +2 -11
- package/src/components/default-block-appender/index.js +11 -4
- package/src/components/dimensions-tool/scale-tool.js +1 -0
- package/src/components/font-appearance-control/index.js +1 -5
- package/src/components/font-family/README.md +8 -0
- package/src/components/font-family/index.js +16 -0
- package/src/components/font-family/stories/index.story.js +54 -0
- package/src/components/global-styles/background-panel.js +90 -62
- package/src/components/global-styles/hooks.js +5 -1
- package/src/components/global-styles/image-settings-panel.js +1 -0
- package/src/components/global-styles/style.scss +11 -9
- package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
- package/src/components/global-styles/test/typography-utils.js +325 -0
- package/src/components/global-styles/test/use-global-styles-output.js +52 -5
- package/src/components/global-styles/test/utils.js +120 -0
- package/src/components/global-styles/theme-file-uri-utils.js +0 -59
- package/src/components/global-styles/typography-panel.js +36 -45
- package/src/components/global-styles/typography-utils.js +103 -7
- package/src/components/global-styles/use-global-styles-output.js +89 -50
- package/src/components/global-styles/utils.js +112 -0
- package/src/components/grid/grid-item-movers.js +141 -69
- package/src/components/grid/grid-item-resizer.js +11 -17
- package/src/components/grid/grid-visualizer.js +2 -2
- package/src/components/grid/style.scss +164 -0
- package/src/components/grid/use-grid-layout-sync.js +133 -40
- package/src/components/iframe/content.scss +3 -3
- package/src/components/iframe/index.js +3 -7
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/index.js +4 -1
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
- package/src/components/inserter/category-tabs/index.js +35 -2
- package/src/components/inserter/media-tab/media-panel.js +1 -0
- package/src/components/inserter/menu.js +3 -3
- package/src/components/inserter/preview-panel.js +27 -4
- package/src/components/inserter/style.scss +66 -47
- package/src/components/inserter-draggable-blocks/index.js +11 -3
- package/src/components/inspector-controls/README.md +5 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
- package/src/components/inspector-controls-tabs/style.scss +0 -21
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +1 -21
- package/src/components/line-height-control/stories/index.story.js +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-control/search-input.js +0 -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-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +3 -1
- package/src/components/resolution-tool/index.js +1 -0
- package/src/components/responsive-block-control/test/index.js +5 -1
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/skip-to-selected-block/index.js +5 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -7
- package/src/components/tabbed-sidebar/style.scss +1 -19
- package/src/components/url-input/README.md +0 -5
- package/src/components/url-input/button.js +0 -1
- package/src/components/url-input/index.js +1 -15
- package/src/components/url-popover/image-url-input-ui.js +3 -3
- package/src/components/url-popover/link-editor.js +0 -1
- package/src/components/url-popover/style.scss +1 -0
- package/src/components/use-block-drop-zone/index.js +66 -14
- package/src/components/use-on-block-drop/index.js +1 -9
- package/src/components/use-resize-canvas/index.js +1 -3
- package/src/components/use-settings/index.js +2 -1
- package/src/hooks/block-bindings.js +303 -52
- package/src/hooks/block-bindings.scss +13 -2
- package/src/hooks/block-hooks.js +1 -0
- package/src/hooks/block-hooks.scss +1 -0
- package/src/hooks/block-style-variation.js +3 -3
- package/src/hooks/contrast-checker.js +7 -7
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/grid-visualizer.js +5 -7
- package/src/hooks/index.js +2 -1
- package/src/hooks/layout-child.js +12 -3
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/position.js +3 -13
- package/src/hooks/spacing-visualizer.js +1 -1
- package/src/hooks/use-bindings-attributes.js +93 -59
- package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
- package/src/hooks/use-zoom-out.js +1 -1
- package/src/hooks/utils.js +14 -1
- package/src/index.js +1 -0
- package/src/layouts/constrained.js +10 -2
- package/src/layouts/grid.js +2 -0
- package/src/private-apis.js +1 -8
- package/src/store/actions.js +28 -5
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +14 -4
- package/src/style.scss +1 -1
- package/src/utils/get-editor-region.js +1 -1
- package/src/utils/get-px-from-css-unit.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -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/block-patterns-tab/pattern-category-preview-panel.js +0 -23
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.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/block-patterns-tab/pattern-category-preview-panel.js +0 -25
- package/src/components/inserter/reusable-block-rename-hint.js +0 -69
- package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
|
@@ -25,9 +25,8 @@ import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
|
25
25
|
import { setImmutably } from '../../utils/object';
|
|
26
26
|
import {
|
|
27
27
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
28
|
-
|
|
28
|
+
findNearestStyleAndWeight,
|
|
29
29
|
} from './typography-utils';
|
|
30
|
-
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
31
30
|
|
|
32
31
|
const MIN_TEXT_COLUMNS = 1;
|
|
33
32
|
const MAX_TEXT_COLUMNS = 6;
|
|
@@ -236,57 +235,50 @@ export default function TypographyPanel( {
|
|
|
236
235
|
const hasFontWeights = settings?.typography?.fontWeight;
|
|
237
236
|
const fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );
|
|
238
237
|
const fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
238
|
+
const { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight(
|
|
239
|
+
fontFamilyFaces,
|
|
240
|
+
fontStyle,
|
|
241
|
+
fontWeight
|
|
242
|
+
);
|
|
243
|
+
const setFontAppearance = useCallback(
|
|
244
|
+
( { fontStyle: newFontStyle, fontWeight: newFontWeight } ) => {
|
|
245
|
+
// Only update the font style and weight if they have changed.
|
|
246
|
+
if ( newFontStyle !== fontStyle || newFontWeight !== fontWeight ) {
|
|
247
|
+
onChange( {
|
|
248
|
+
...value,
|
|
249
|
+
typography: {
|
|
250
|
+
...value?.typography,
|
|
251
|
+
fontStyle: newFontStyle || undefined,
|
|
252
|
+
fontWeight: newFontWeight || undefined,
|
|
253
|
+
},
|
|
254
|
+
} );
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
[ fontStyle, fontWeight, onChange, value ]
|
|
258
|
+
);
|
|
252
259
|
const hasFontAppearance = () =>
|
|
253
260
|
!! value?.typography?.fontStyle || !! value?.typography?.fontWeight;
|
|
254
|
-
const resetFontAppearance = () => {
|
|
261
|
+
const resetFontAppearance = useCallback( () => {
|
|
255
262
|
setFontAppearance( {} );
|
|
256
|
-
};
|
|
263
|
+
}, [ setFontAppearance ] );
|
|
257
264
|
|
|
258
|
-
// Check if previous font style and weight values are available in the new font family
|
|
265
|
+
// Check if previous font style and weight values are available in the new font family.
|
|
259
266
|
useEffect( () => {
|
|
260
|
-
|
|
261
|
-
getFontStylesAndWeights( fontFamilyFaces );
|
|
262
|
-
const hasFontStyle = fontStyles?.some(
|
|
263
|
-
( { value: fs } ) => fs === fontStyle
|
|
264
|
-
);
|
|
265
|
-
const hasFontWeight = fontWeights?.some(
|
|
266
|
-
( { value: fw } ) => fw === fontWeight
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
// Try to set nearest available font weight
|
|
270
|
-
if ( ! hasFontWeight && fontWeight ) {
|
|
267
|
+
if ( nearestFontStyle && nearestFontWeight ) {
|
|
271
268
|
setFontAppearance( {
|
|
272
|
-
fontStyle,
|
|
273
|
-
fontWeight:
|
|
269
|
+
fontStyle: nearestFontStyle,
|
|
270
|
+
fontWeight: nearestFontWeight,
|
|
274
271
|
} );
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Set the same weight and style values if the font family is a system font or if both are the same
|
|
278
|
-
if ( isSystemFont || ( hasFontStyle && hasFontWeight ) ) {
|
|
279
|
-
setFontAppearance( {
|
|
280
|
-
fontStyle,
|
|
281
|
-
fontWeight,
|
|
282
|
-
} );
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Reset font appearance if the font family does not have the selected font style
|
|
286
|
-
if ( ! hasFontStyle ) {
|
|
272
|
+
} else {
|
|
273
|
+
// Reset font appearance if there are no available styles or weights.
|
|
287
274
|
resetFontAppearance();
|
|
288
275
|
}
|
|
289
|
-
}, [
|
|
276
|
+
}, [
|
|
277
|
+
nearestFontStyle,
|
|
278
|
+
nearestFontWeight,
|
|
279
|
+
resetFontAppearance,
|
|
280
|
+
setFontAppearance,
|
|
281
|
+
] );
|
|
290
282
|
|
|
291
283
|
// Line Height
|
|
292
284
|
const hasLineHeightEnabled = useHasLineHeightControl( settings );
|
|
@@ -482,7 +474,6 @@ export default function TypographyPanel( {
|
|
|
482
474
|
panelId={ panelId }
|
|
483
475
|
>
|
|
484
476
|
<LineHeightControl
|
|
485
|
-
__nextHasNoMarginBottom
|
|
486
477
|
__unstableInputWidth="auto"
|
|
487
478
|
value={ lineHeight }
|
|
488
479
|
onChange={ setLineHeight }
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getComputedFluidTypographyValue,
|
|
12
12
|
getTypographyValueAndUnit,
|
|
13
13
|
} from '../font-sizes/fluid-utils';
|
|
14
|
+
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @typedef {Object} FluidPreset
|
|
@@ -127,9 +128,9 @@ export function getFluidTypographyOptionsFromSettings( settings ) {
|
|
|
127
128
|
* Returns an object of merged font families and the font faces from the selected font family
|
|
128
129
|
* based on the theme.json settings object and the currently selected font family.
|
|
129
130
|
*
|
|
130
|
-
* @param {Object} settings Theme.json settings
|
|
131
|
-
* @param {string} selectedFontFamily Decoded font family string
|
|
132
|
-
* @return {Object} Merged font families and font faces from the selected font family
|
|
131
|
+
* @param {Object} settings Theme.json settings.
|
|
132
|
+
* @param {string} selectedFontFamily Decoded font family string.
|
|
133
|
+
* @return {Object} Merged font families and font faces from the selected font family.
|
|
133
134
|
*/
|
|
134
135
|
export function getMergedFontFamiliesAndFontFamilyFaces(
|
|
135
136
|
settings,
|
|
@@ -153,11 +154,10 @@ export function getMergedFontFamiliesAndFontFamilyFaces(
|
|
|
153
154
|
* Returns the nearest font weight value from the available font weight list based on the new font weight.
|
|
154
155
|
* The nearest font weight is the one with the smallest difference from the new font weight.
|
|
155
156
|
*
|
|
156
|
-
* @param {Array} availableFontWeights Array of available font weights
|
|
157
|
-
* @param {string} newFontWeightValue New font weight value
|
|
158
|
-
* @return {string} Nearest font weight
|
|
157
|
+
* @param {Array} availableFontWeights Array of available font weights.
|
|
158
|
+
* @param {string} newFontWeightValue New font weight value.
|
|
159
|
+
* @return {string} Nearest font weight.
|
|
159
160
|
*/
|
|
160
|
-
|
|
161
161
|
export function findNearestFontWeight(
|
|
162
162
|
availableFontWeights,
|
|
163
163
|
newFontWeightValue
|
|
@@ -185,3 +185,99 @@ export function findNearestFontWeight(
|
|
|
185
185
|
|
|
186
186
|
return nearestFontWeight;
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Returns the nearest font style based on the new font style.
|
|
191
|
+
* Defaults to an empty string if the new font style is not valid or available.
|
|
192
|
+
*
|
|
193
|
+
* @param {Array} availableFontStyles Array of available font weights.
|
|
194
|
+
* @param {string} newFontStyleValue New font style value.
|
|
195
|
+
* @return {string} Nearest font style or an empty string.
|
|
196
|
+
*/
|
|
197
|
+
export function findNearestFontStyle( availableFontStyles, newFontStyleValue ) {
|
|
198
|
+
if ( typeof newFontStyleValue !== 'string' || ! newFontStyleValue ) {
|
|
199
|
+
return '';
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const validStyles = [ 'normal', 'italic', 'oblique' ];
|
|
203
|
+
if ( ! validStyles.includes( newFontStyleValue ) ) {
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
! availableFontStyles ||
|
|
209
|
+
availableFontStyles.length === 0 ||
|
|
210
|
+
availableFontStyles.find(
|
|
211
|
+
( style ) => style.value === newFontStyleValue
|
|
212
|
+
)
|
|
213
|
+
) {
|
|
214
|
+
return newFontStyleValue;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (
|
|
218
|
+
newFontStyleValue === 'oblique' &&
|
|
219
|
+
! availableFontStyles.find( ( style ) => style.value === 'oblique' )
|
|
220
|
+
) {
|
|
221
|
+
return 'italic';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return '';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Returns the nearest font style and weight based on the available font family faces and the new font style and weight.
|
|
229
|
+
*
|
|
230
|
+
* @param {Array} fontFamilyFaces Array of available font family faces.
|
|
231
|
+
* @param {string} fontStyle New font style. Defaults to previous value.
|
|
232
|
+
* @param {string} fontWeight New font weight. Defaults to previous value.
|
|
233
|
+
* @return {Object} Nearest font style and font weight.
|
|
234
|
+
*/
|
|
235
|
+
export function findNearestStyleAndWeight(
|
|
236
|
+
fontFamilyFaces,
|
|
237
|
+
fontStyle,
|
|
238
|
+
fontWeight
|
|
239
|
+
) {
|
|
240
|
+
let nearestFontStyle = fontStyle;
|
|
241
|
+
let nearestFontWeight = fontWeight;
|
|
242
|
+
|
|
243
|
+
const { fontStyles, fontWeights, combinedStyleAndWeightOptions } =
|
|
244
|
+
getFontStylesAndWeights( fontFamilyFaces );
|
|
245
|
+
|
|
246
|
+
// Check if the new font style and weight are available in the font family faces.
|
|
247
|
+
const hasFontStyle = fontStyles?.some(
|
|
248
|
+
( { value: fs } ) => fs === fontStyle
|
|
249
|
+
);
|
|
250
|
+
const hasFontWeight = fontWeights?.some(
|
|
251
|
+
( { value: fw } ) => fw === fontWeight
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
if ( ! hasFontStyle ) {
|
|
255
|
+
/*
|
|
256
|
+
* Default to italic if oblique is not available.
|
|
257
|
+
* Or find the nearest font style based on the nearest font weight.
|
|
258
|
+
*/
|
|
259
|
+
nearestFontStyle = fontStyle
|
|
260
|
+
? findNearestFontStyle( fontStyles, fontStyle )
|
|
261
|
+
: combinedStyleAndWeightOptions?.find(
|
|
262
|
+
( option ) =>
|
|
263
|
+
option.style.fontWeight ===
|
|
264
|
+
findNearestFontWeight( fontWeights, fontWeight )
|
|
265
|
+
)?.style?.fontStyle;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if ( ! hasFontWeight ) {
|
|
269
|
+
/*
|
|
270
|
+
* Find the nearest font weight based on available weights.
|
|
271
|
+
* Or find the nearest font weight based on the nearest font style.
|
|
272
|
+
*/
|
|
273
|
+
nearestFontWeight = fontWeight
|
|
274
|
+
? findNearestFontWeight( fontWeights, fontWeight )
|
|
275
|
+
: combinedStyleAndWeightOptions?.find(
|
|
276
|
+
( option ) =>
|
|
277
|
+
option.style.fontStyle ===
|
|
278
|
+
( nearestFontStyle || fontStyle )
|
|
279
|
+
)?.style?.fontWeight;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return { nearestFontStyle, nearestFontWeight };
|
|
283
|
+
}
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
scopeFeatureSelectors,
|
|
25
25
|
appendToSelector,
|
|
26
26
|
getBlockStyleVariationSelector,
|
|
27
|
+
compileStyleValue,
|
|
28
|
+
getResolvedValue,
|
|
27
29
|
} from './utils';
|
|
28
30
|
import { getBlockCSSSelector } from './get-block-css-selector';
|
|
29
31
|
import { getTypographyFontSizeValue } from './typography-utils';
|
|
@@ -36,7 +38,12 @@ import { store as blockEditorStore } from '../../store';
|
|
|
36
38
|
import { LAYOUT_DEFINITIONS } from '../../layouts/definitions';
|
|
37
39
|
import { getValueFromObjectPath, setImmutably } from '../../utils/object';
|
|
38
40
|
import { unlock } from '../../lock-unlock';
|
|
39
|
-
|
|
41
|
+
|
|
42
|
+
// Elements that rely on class names in their selectors.
|
|
43
|
+
const ELEMENT_CLASS_NAMES = {
|
|
44
|
+
button: 'wp-element-button',
|
|
45
|
+
caption: 'wp-element-caption',
|
|
46
|
+
};
|
|
40
47
|
|
|
41
48
|
// List of block support features that can have their related styles
|
|
42
49
|
// generated under their own feature level selector rather than the block's.
|
|
@@ -48,21 +55,6 @@ const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
|
48
55
|
};
|
|
49
56
|
const { kebabCase } = unlock( componentsPrivateApis );
|
|
50
57
|
|
|
51
|
-
function compileStyleValue( uncompiledValue ) {
|
|
52
|
-
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
53
|
-
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
54
|
-
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
55
|
-
|
|
56
|
-
if ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {
|
|
57
|
-
const variable = uncompiledValue
|
|
58
|
-
.slice( VARIABLE_REFERENCE_PREFIX.length )
|
|
59
|
-
.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
|
|
60
|
-
.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );
|
|
61
|
-
return `var(--wp--${ variable })`;
|
|
62
|
-
}
|
|
63
|
-
return uncompiledValue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
58
|
/**
|
|
67
59
|
* Transform given preset tree into a set of style declarations.
|
|
68
60
|
*
|
|
@@ -389,21 +381,40 @@ export function getStylesDeclarations(
|
|
|
389
381
|
);
|
|
390
382
|
|
|
391
383
|
/*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
384
|
+
* Preprocess background image values.
|
|
385
|
+
*
|
|
386
|
+
* Note: As we absorb more and more styles into the engine, we could simplify this function.
|
|
387
|
+
* A refactor is for the style engine to handle ref resolution (and possibly defaults)
|
|
388
|
+
* via a public util used internally and externally. Theme.json tree and defaults could be passed
|
|
389
|
+
* as options.
|
|
394
390
|
*/
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
391
|
+
if ( !! blockStyles.background ) {
|
|
392
|
+
/*
|
|
393
|
+
* Resolve dynamic values before they are compiled by the style engine,
|
|
394
|
+
* which doesn't (yet) resolve dynamic values.
|
|
395
|
+
*/
|
|
396
|
+
if ( blockStyles.background?.backgroundImage ) {
|
|
397
|
+
blockStyles.background.backgroundImage = getResolvedValue(
|
|
398
|
+
blockStyles.background.backgroundImage,
|
|
399
|
+
tree
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/*
|
|
404
|
+
* Set default values for block background styles.
|
|
405
|
+
* Top-level styles are an exception as they are applied to the body.
|
|
406
|
+
*/
|
|
407
|
+
if ( ! isRoot && !! blockStyles.background?.backgroundImage?.id ) {
|
|
408
|
+
blockStyles = {
|
|
409
|
+
...blockStyles,
|
|
410
|
+
background: {
|
|
411
|
+
...blockStyles.background,
|
|
412
|
+
...setBackgroundStyleDefaults( blockStyles.background ),
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
}
|
|
403
416
|
}
|
|
404
417
|
|
|
405
|
-
// The goal is to move everything to server side generated engine styles
|
|
406
|
-
// This is temporary as we absorb more and more styles into the engine.
|
|
407
418
|
const extraRules = getCSSRules( blockStyles );
|
|
408
419
|
extraRules.forEach( ( rule ) => {
|
|
409
420
|
// Don't output padding properties if padding variables are set or if we're not editing a full template.
|
|
@@ -418,18 +429,7 @@ export function getStylesDeclarations(
|
|
|
418
429
|
? rule.key
|
|
419
430
|
: kebabCase( rule.key );
|
|
420
431
|
|
|
421
|
-
let ruleValue = rule.value;
|
|
422
|
-
if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
|
|
423
|
-
const refPath = ruleValue.ref.split( '.' );
|
|
424
|
-
ruleValue = compileStyleValue(
|
|
425
|
-
getValueFromObjectPath( tree, refPath )
|
|
426
|
-
);
|
|
427
|
-
// Presence of another ref indicates a reference to another dynamic value.
|
|
428
|
-
// Pointing to another dynamic value is not supported.
|
|
429
|
-
if ( ! ruleValue || ruleValue?.ref ) {
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
432
|
+
let ruleValue = getResolvedValue( rule.value, tree, null );
|
|
433
433
|
|
|
434
434
|
// Calculate fluid typography rules where available.
|
|
435
435
|
if ( cssProperty === 'font-size' ) {
|
|
@@ -643,6 +643,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
643
643
|
nodes.push( {
|
|
644
644
|
styles,
|
|
645
645
|
selector: ROOT_BLOCK_SELECTOR,
|
|
646
|
+
// Root selector (body) styles should not be wrapped in `:root where()` to keep
|
|
647
|
+
// specificity at (0,0,1) and maintain backwards compatibility.
|
|
648
|
+
skipSelectorWrapper: true,
|
|
646
649
|
} );
|
|
647
650
|
}
|
|
648
651
|
|
|
@@ -651,6 +654,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
651
654
|
nodes.push( {
|
|
652
655
|
styles: tree.styles?.elements?.[ name ],
|
|
653
656
|
selector,
|
|
657
|
+
// Top level elements that don't use a class name should not receive the
|
|
658
|
+
// `:root :where()` wrapper to maintain backwards compatibility.
|
|
659
|
+
skipSelectorWrapper: ! ELEMENT_CLASS_NAMES[ name ],
|
|
654
660
|
} );
|
|
655
661
|
}
|
|
656
662
|
} );
|
|
@@ -957,6 +963,7 @@ export const toStyles = (
|
|
|
957
963
|
hasLayoutSupport,
|
|
958
964
|
featureSelectors,
|
|
959
965
|
styleVariationSelectors,
|
|
966
|
+
skipSelectorWrapper,
|
|
960
967
|
} ) => {
|
|
961
968
|
// Process styles for block support features with custom feature level
|
|
962
969
|
// CSS selectors set.
|
|
@@ -1015,7 +1022,10 @@ export const toStyles = (
|
|
|
1015
1022
|
disableRootPadding
|
|
1016
1023
|
);
|
|
1017
1024
|
if ( styleDeclarations?.length ) {
|
|
1018
|
-
|
|
1025
|
+
const generalSelector = skipSelectorWrapper
|
|
1026
|
+
? selector
|
|
1027
|
+
: `:root :where(${ selector })`;
|
|
1028
|
+
ruleset += `${ generalSelector }{${ styleDeclarations.join(
|
|
1019
1029
|
';'
|
|
1020
1030
|
) };}`;
|
|
1021
1031
|
}
|
|
@@ -1109,7 +1119,11 @@ export const toStyles = (
|
|
|
1109
1119
|
.map( ( sel ) => sel + pseudoKey )
|
|
1110
1120
|
.join( ',' );
|
|
1111
1121
|
|
|
1112
|
-
|
|
1122
|
+
// As pseudo classes such as :hover, :focus etc. have class-level
|
|
1123
|
+
// specificity, they must use the `:root :where()` wrapper. This.
|
|
1124
|
+
// caps the specificity at `0-1-0` to allow proper nesting of variations
|
|
1125
|
+
// and block type element styles.
|
|
1126
|
+
const pseudoRule = `:root :where(${ _selector }){${ pseudoDeclarations.join(
|
|
1113
1127
|
';'
|
|
1114
1128
|
) };}`;
|
|
1115
1129
|
|
|
@@ -1307,9 +1321,17 @@ function updateConfigWithSeparator( config ) {
|
|
|
1307
1321
|
export function processCSSNesting( css, blockSelector ) {
|
|
1308
1322
|
let processedCSS = '';
|
|
1309
1323
|
|
|
1324
|
+
if ( ! css || css.trim() === '' ) {
|
|
1325
|
+
return processedCSS;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1310
1328
|
// Split CSS nested rules.
|
|
1311
1329
|
const parts = css.split( '&' );
|
|
1312
1330
|
parts.forEach( ( part ) => {
|
|
1331
|
+
if ( ! part || part.trim() === '' ) {
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1313
1335
|
const isRootCss = ! part.includes( '{' );
|
|
1314
1336
|
if ( isRootCss ) {
|
|
1315
1337
|
// If the part doesn't contain braces, it applies to the root level.
|
|
@@ -1322,11 +1344,32 @@ export function processCSSNesting( css, blockSelector ) {
|
|
|
1322
1344
|
}
|
|
1323
1345
|
|
|
1324
1346
|
const [ nestedSelector, cssValue ] = splittedPart;
|
|
1325
|
-
const combinedSelector = nestedSelector.startsWith( ' ' )
|
|
1326
|
-
? scopeSelector( blockSelector, nestedSelector )
|
|
1327
|
-
: appendToSelector( blockSelector, nestedSelector );
|
|
1328
1347
|
|
|
1329
|
-
|
|
1348
|
+
// Handle pseudo elements such as ::before, ::after, etc. Regex will also
|
|
1349
|
+
// capture any leading combinator such as >, +, or ~, as well as spaces.
|
|
1350
|
+
// This allows pseudo elements as descendants e.g. `.parent ::before`.
|
|
1351
|
+
const matches = nestedSelector.match( /([>+~\s]*::[a-zA-Z-]+)/ );
|
|
1352
|
+
const pseudoPart = matches ? matches[ 1 ] : '';
|
|
1353
|
+
const withoutPseudoElement = matches
|
|
1354
|
+
? nestedSelector.replace( pseudoPart, '' ).trim()
|
|
1355
|
+
: nestedSelector.trim();
|
|
1356
|
+
|
|
1357
|
+
let combinedSelector;
|
|
1358
|
+
if ( withoutPseudoElement === '' ) {
|
|
1359
|
+
// Only contained a pseudo element to use the block selector to form
|
|
1360
|
+
// the final `:root :where()` selector.
|
|
1361
|
+
combinedSelector = blockSelector;
|
|
1362
|
+
} else {
|
|
1363
|
+
// If the nested selector is a descendant of the block scope it with the
|
|
1364
|
+
// block selector. Otherwise append it to the block selector.
|
|
1365
|
+
combinedSelector = nestedSelector.startsWith( ' ' )
|
|
1366
|
+
? scopeSelector( blockSelector, withoutPseudoElement )
|
|
1367
|
+
: appendToSelector( blockSelector, withoutPseudoElement );
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// Build final rule, re-adding any pseudo element outside the `:where()`
|
|
1371
|
+
// to maintain valid CSS selector.
|
|
1372
|
+
processedCSS += `:root :where(${ combinedSelector })${ pseudoPart }{${ cssValue.trim() }}`;
|
|
1330
1373
|
}
|
|
1331
1374
|
} );
|
|
1332
1375
|
return processedCSS;
|
|
@@ -1349,10 +1392,6 @@ export function useGlobalStylesOutputWithConfig(
|
|
|
1349
1392
|
disableRootPadding
|
|
1350
1393
|
) {
|
|
1351
1394
|
const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );
|
|
1352
|
-
mergedConfig = setThemeFileUris(
|
|
1353
|
-
mergedConfig,
|
|
1354
|
-
mergedConfig?._links?.[ 'wp:theme-file' ]
|
|
1355
|
-
);
|
|
1356
1395
|
const hasBlockGapSupport = blockGap !== null;
|
|
1357
1396
|
const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
|
|
1358
1397
|
const disableLayoutStyles = useSelect( ( select ) => {
|
|
@@ -525,3 +525,115 @@ export function getBlockStyleVariationSelector( variation, blockSelector ) {
|
|
|
525
525
|
|
|
526
526
|
return result.join( ',' );
|
|
527
527
|
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Converts style preset values `var:` to CSS custom var values.
|
|
531
|
+
* TODO: Export and use the style engine util: getCSSVarFromStyleValue().
|
|
532
|
+
*
|
|
533
|
+
* Example:
|
|
534
|
+
*
|
|
535
|
+
* compileStyleValue( 'var:preset|color|primary' ) // returns 'var(--wp--color-primary)'
|
|
536
|
+
*
|
|
537
|
+
* @param {string} uncompiledValue A block style value.
|
|
538
|
+
* @return {string} The compiled, or original value.
|
|
539
|
+
*/
|
|
540
|
+
export function compileStyleValue( uncompiledValue ) {
|
|
541
|
+
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
542
|
+
if (
|
|
543
|
+
'string' === typeof uncompiledValue &&
|
|
544
|
+
uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX )
|
|
545
|
+
) {
|
|
546
|
+
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
547
|
+
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
548
|
+
const variable = uncompiledValue
|
|
549
|
+
.slice( VARIABLE_REFERENCE_PREFIX.length )
|
|
550
|
+
.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
|
|
551
|
+
.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );
|
|
552
|
+
return `var(--wp--${ variable })`;
|
|
553
|
+
}
|
|
554
|
+
return uncompiledValue;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Looks up a theme file URI based on a relative path.
|
|
559
|
+
*
|
|
560
|
+
* @param {string} file A relative path.
|
|
561
|
+
* @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
|
|
562
|
+
* @return {string} A resolved theme file URI, if one is found in the themeFileURIs collection.
|
|
563
|
+
*/
|
|
564
|
+
export function getResolvedThemeFilePath( file, themeFileURIs ) {
|
|
565
|
+
if ( ! file || ! themeFileURIs || ! Array.isArray( themeFileURIs ) ) {
|
|
566
|
+
return file;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const uri = themeFileURIs.find(
|
|
570
|
+
( themeFileUri ) => themeFileUri?.name === file
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
if ( ! uri?.href ) {
|
|
574
|
+
return file;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return uri?.href;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Resolves ref values in theme JSON.
|
|
582
|
+
*
|
|
583
|
+
* @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.
|
|
584
|
+
* @param {Object} tree A theme.json object.
|
|
585
|
+
* @return {*} The resolved value or incoming ruleValue.
|
|
586
|
+
*/
|
|
587
|
+
export function getResolvedRefValue( ruleValue, tree ) {
|
|
588
|
+
if ( ! ruleValue || ! tree ) {
|
|
589
|
+
return ruleValue;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
|
|
593
|
+
const refPath = ruleValue.ref.split( '.' );
|
|
594
|
+
const resolvedRuleValue = compileStyleValue(
|
|
595
|
+
getValueFromObjectPath( tree, refPath )
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
/*
|
|
599
|
+
* Presence of another ref indicates a reference to another dynamic value.
|
|
600
|
+
* Pointing to another dynamic value is not supported.
|
|
601
|
+
*/
|
|
602
|
+
if ( resolvedRuleValue?.ref ) {
|
|
603
|
+
return undefined;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if ( ! resolvedRuleValue ) {
|
|
607
|
+
return ruleValue;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return resolvedRuleValue;
|
|
611
|
+
}
|
|
612
|
+
return ruleValue;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Resolves ref and relative path values in theme JSON.
|
|
617
|
+
*
|
|
618
|
+
* @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.
|
|
619
|
+
* @param {Object} tree A theme.json object.
|
|
620
|
+
* @return {*} The resolved value or incoming ruleValue.
|
|
621
|
+
*/
|
|
622
|
+
export function getResolvedValue( ruleValue, tree ) {
|
|
623
|
+
if ( ! ruleValue || ! tree ) {
|
|
624
|
+
return ruleValue;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// Resolve ref values.
|
|
628
|
+
const resolvedValue = getResolvedRefValue( ruleValue, tree );
|
|
629
|
+
|
|
630
|
+
// Resolve relative paths.
|
|
631
|
+
if ( resolvedValue?.url ) {
|
|
632
|
+
resolvedValue.url = getResolvedThemeFilePath(
|
|
633
|
+
resolvedValue.url,
|
|
634
|
+
tree?._links?.[ 'wp:theme-file' ]
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
return resolvedValue;
|
|
639
|
+
}
|