@wordpress/block-editor 13.4.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 +11 -0
- package/README.md +11 -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-list/use-block-props/use-block-refs.js +24 -32
- package/build/components/block-list/use-block-props/use-block-refs.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-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/zoom-out-mode-inserters.js +15 -16
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +0 -1
- 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/dimensions-tool/scale-tool.js +1 -0
- package/build/components/dimensions-tool/scale-tool.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 +55 -51
- package/build/components/global-styles/background-panel.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 +0 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +58 -39
- 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 +30 -26
- 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 +1 -1
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +56 -20
- 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/inserter/category-tabs/index.js +29 -2
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/menu.js +2 -2
- package/build/components/inserter/menu.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/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/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 +4 -6
- 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/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/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/line-height.js +0 -1
- package/build/hooks/line-height.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 +4 -0
- 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/private-apis.js +0 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +9 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -4
- 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/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-list/use-block-props/use-block-refs.js +24 -34
- package/build-module/components/block-list/use-block-props/use-block-refs.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-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/zoom-out-mode-inserters.js +16 -17
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +0 -1
- 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/dimensions-tool/scale-tool.js +1 -0
- package/build-module/components/dimensions-tool/scale-tool.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 +55 -51
- package/build-module/components/global-styles/background-panel.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 +0 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +57 -38
- 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 +30 -26
- 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 +1 -1
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +56 -20
- 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/inserter/category-tabs/index.js +30 -3
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -2
- package/build-module/components/inserter/menu.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/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/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 +4 -6
- 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/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/index.js +2 -1
- package/build-module/hooks/index.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/spacing-visualizer.js +1 -1
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +3 -0
- 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/private-apis.js +1 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +9 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +4 -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 +5 -12
- package/build-style/content.css +5 -12
- 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 +88 -46
- package/build-style/style.css +88 -46
- package/package.json +31 -31
- package/src/autocompleters/style.scss +4 -0
- package/src/components/block-breadcrumb/index.js +4 -2
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-draggable/index.js +3 -3
- package/src/components/block-list/use-block-props/use-block-refs.js +27 -43
- package/src/components/block-mover/index.js +5 -2
- 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-tools/block-selection-button.js +1 -2
- package/src/components/block-tools/index.js +5 -6
- package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/src/components/block-tools/zoom-out-mode-inserters.js +14 -18
- package/src/components/block-tools/zoom-out-toolbar.js +0 -1
- 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/dimensions-tool/scale-tool.js +1 -0
- 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 +69 -61
- package/src/components/global-styles/image-settings-panel.js +1 -0
- package/src/components/global-styles/style.scss +0 -10
- package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
- package/src/components/global-styles/test/use-global-styles-output.js +49 -4
- 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 +0 -1
- package/src/components/global-styles/use-global-styles-output.js +67 -48
- package/src/components/global-styles/utils.js +112 -0
- package/src/components/grid/grid-item-movers.js +46 -44
- package/src/components/grid/grid-item-resizer.js +11 -17
- package/src/components/grid/grid-visualizer.js +1 -1
- package/src/components/grid/style.scss +60 -10
- package/src/components/grid/use-grid-layout-sync.js +68 -14
- package/src/components/iframe/content.scss +2 -2
- package/src/components/iframe/index.js +3 -7
- package/src/components/inserter/category-tabs/index.js +35 -2
- package/src/components/inserter/menu.js +2 -2
- package/src/components/inserter/style.scss +16 -11
- package/src/components/inspector-controls/README.md +5 -0
- 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/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/skip-to-selected-block/index.js +5 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -6
- 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/link-editor.js +0 -1
- 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/index.js +2 -1
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/spacing-visualizer.js +1 -1
- package/src/hooks/use-bindings-attributes.js +4 -0
- 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/private-apis.js +1 -2
- package/src/store/actions.js +13 -5
- package/src/store/selectors.js +4 -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-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/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
|
@@ -318,8 +318,12 @@ function BackgroundImageControls( {
|
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
const sizeValue =
|
|
322
|
-
|
|
321
|
+
const sizeValue =
|
|
322
|
+
style?.background?.backgroundSize ||
|
|
323
|
+
inheritedValue?.background?.backgroundSize;
|
|
324
|
+
const positionValue =
|
|
325
|
+
style?.background?.backgroundPosition ||
|
|
326
|
+
inheritedValue?.background?.backgroundPosition;
|
|
323
327
|
|
|
324
328
|
onChange(
|
|
325
329
|
setImmutably( style, [ 'background' ], {
|
|
@@ -334,6 +338,7 @@ function BackgroundImageControls( {
|
|
|
334
338
|
! positionValue && ( 'auto' === sizeValue || ! sizeValue )
|
|
335
339
|
? '50% 0'
|
|
336
340
|
: positionValue,
|
|
341
|
+
backgroundSize: sizeValue,
|
|
337
342
|
} )
|
|
338
343
|
);
|
|
339
344
|
};
|
|
@@ -448,6 +453,9 @@ function BackgroundSizeControls( {
|
|
|
448
453
|
const imageValue =
|
|
449
454
|
style?.background?.backgroundImage?.url ||
|
|
450
455
|
inheritedValue?.background?.backgroundImage?.url;
|
|
456
|
+
const isUploadedImage =
|
|
457
|
+
style?.background?.backgroundImage?.id ||
|
|
458
|
+
inheritedValue?.background?.backgroundImage?.id;
|
|
451
459
|
const positionValue =
|
|
452
460
|
style?.background?.backgroundPosition ||
|
|
453
461
|
inheritedValue?.background?.backgroundPosition;
|
|
@@ -456,19 +464,15 @@ function BackgroundSizeControls( {
|
|
|
456
464
|
inheritedValue?.background?.backgroundAttachment;
|
|
457
465
|
|
|
458
466
|
/*
|
|
459
|
-
*
|
|
460
|
-
* default
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* empty value being treated as `auto`.
|
|
467
|
+
* Set default values for uploaded images.
|
|
468
|
+
* The default values are passed by the consumer.
|
|
469
|
+
* Block-level controls may have different defaults to root-level controls.
|
|
470
|
+
* A falsy value is treated by default as `auto` (Tile).
|
|
464
471
|
*/
|
|
465
472
|
const currentValueForToggle =
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
sizeValue
|
|
469
|
-
sizeValue === ''
|
|
470
|
-
? 'auto'
|
|
471
|
-
: sizeValue || defaultValues?.backgroundSize;
|
|
473
|
+
! sizeValue && isUploadedImage
|
|
474
|
+
? defaultValues?.backgroundSize
|
|
475
|
+
: sizeValue || 'auto';
|
|
472
476
|
|
|
473
477
|
/*
|
|
474
478
|
* If the current value is `cover` and the repeat value is `undefined`, then
|
|
@@ -569,6 +573,7 @@ function BackgroundSizeControls( {
|
|
|
569
573
|
onChange={ updateBackgroundPosition }
|
|
570
574
|
/>
|
|
571
575
|
<ToggleControl
|
|
576
|
+
__nextHasNoMarginBottom
|
|
572
577
|
label={ __( 'Fixed background' ) }
|
|
573
578
|
checked={ attachmentValue === 'fixed' }
|
|
574
579
|
onChange={ toggleScrollWithPage }
|
|
@@ -577,6 +582,7 @@ function BackgroundSizeControls( {
|
|
|
577
582
|
) }
|
|
578
583
|
/>
|
|
579
584
|
<ToggleGroupControl
|
|
585
|
+
__nextHasNoMarginBottom
|
|
580
586
|
size="__unstable-large"
|
|
581
587
|
label={ __( 'Size' ) }
|
|
582
588
|
value={ currentValueForToggle }
|
|
@@ -626,6 +632,7 @@ function BackgroundSizeControls( {
|
|
|
626
632
|
}
|
|
627
633
|
/>
|
|
628
634
|
<ToggleControl
|
|
635
|
+
__nextHasNoMarginBottom
|
|
629
636
|
label={ __( 'Repeat' ) }
|
|
630
637
|
checked={ repeatCheckedValue }
|
|
631
638
|
onChange={ toggleIsRepeated }
|
|
@@ -717,55 +724,56 @@ export default function BackgroundPanel( {
|
|
|
717
724
|
}
|
|
718
725
|
) }
|
|
719
726
|
>
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
<
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
themeFileURIs
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
727
|
+
<ToolsPanelItem
|
|
728
|
+
hasValue={ () => hasImageValue }
|
|
729
|
+
label={ __( 'Image' ) }
|
|
730
|
+
onDeselect={ resetBackground }
|
|
731
|
+
isShownByDefault={ defaultControls.backgroundImage }
|
|
732
|
+
panelId={ panelId }
|
|
733
|
+
>
|
|
734
|
+
{ shouldShowBackgroundImageControls ? (
|
|
735
|
+
<BackgroundControlsPanel
|
|
736
|
+
label={ title }
|
|
737
|
+
filename={ title }
|
|
738
|
+
url={ getResolvedThemeFilePath(
|
|
739
|
+
url,
|
|
740
|
+
themeFileURIs
|
|
741
|
+
) }
|
|
742
|
+
onToggle={ setIsDropDownOpen }
|
|
743
|
+
hasImageValue={ hasImageValue }
|
|
744
|
+
>
|
|
745
|
+
<VStack spacing={ 3 } className="single-column">
|
|
746
|
+
<BackgroundImageControls
|
|
747
|
+
onChange={ onChange }
|
|
748
|
+
style={ value }
|
|
749
|
+
inheritedValue={ inheritedValue }
|
|
750
|
+
themeFileURIs={ themeFileURIs }
|
|
751
|
+
displayInPanel
|
|
752
|
+
onRemoveImage={ () => {
|
|
753
|
+
setIsDropDownOpen( false );
|
|
754
|
+
resetBackground();
|
|
755
|
+
} }
|
|
756
|
+
/>
|
|
757
|
+
<BackgroundSizeControls
|
|
758
|
+
onChange={ onChange }
|
|
759
|
+
panelId={ panelId }
|
|
760
|
+
style={ value }
|
|
761
|
+
defaultValues={ defaultValues }
|
|
762
|
+
inheritedValue={ inheritedValue }
|
|
763
|
+
themeFileURIs={ themeFileURIs }
|
|
764
|
+
/>
|
|
765
|
+
</VStack>
|
|
766
|
+
</BackgroundControlsPanel>
|
|
767
|
+
) : (
|
|
768
|
+
<BackgroundImageControls
|
|
769
|
+
onChange={ onChange }
|
|
770
|
+
style={ value }
|
|
771
|
+
inheritedValue={ inheritedValue }
|
|
772
|
+
themeFileURIs={ themeFileURIs }
|
|
773
|
+
/>
|
|
774
|
+
) }
|
|
775
|
+
</ToolsPanelItem>
|
|
758
776
|
</div>
|
|
759
|
-
|
|
760
|
-
{ /* Dummy ToolsPanel items, so we can control what's in the dropdown popover */ }
|
|
761
|
-
<ToolsPanelItem
|
|
762
|
-
hasValue={ () => hasImageValue }
|
|
763
|
-
label={ __( 'Image' ) }
|
|
764
|
-
onDeselect={ resetBackground }
|
|
765
|
-
isShownByDefault={ defaultControls.backgroundImage }
|
|
766
|
-
panelId={ panelId }
|
|
767
|
-
className="block-editor-global-styles-background-panel__hidden-tools-panel-item"
|
|
768
|
-
/>
|
|
769
777
|
</Wrapper>
|
|
770
778
|
);
|
|
771
779
|
}
|
|
@@ -193,10 +193,6 @@
|
|
|
193
193
|
.block-editor-global-styles-background-panel__dropdown-content-wrapper {
|
|
194
194
|
min-width: 260px;
|
|
195
195
|
overflow-x: hidden;
|
|
196
|
-
.components-base-control__help,
|
|
197
|
-
.components-toggle-control {
|
|
198
|
-
margin-bottom: 0;
|
|
199
|
-
}
|
|
200
196
|
|
|
201
197
|
.components-focal-point-picker-wrapper {
|
|
202
198
|
background-color: $gray-100;
|
|
@@ -215,12 +211,6 @@
|
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
|
|
218
|
-
.block-editor-global-styles-background-panel__hidden-tools-panel-item {
|
|
219
|
-
height: 0;
|
|
220
|
-
width: 0;
|
|
221
|
-
position: absolute;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
214
|
// Push control panel into the background when the media modal is open.
|
|
225
215
|
.modal-open .block-editor-global-styles-background-panel__popover {
|
|
226
216
|
z-index: z-index(".block-editor-global-styles-background-panel__popover");
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
setThemeFileUris,
|
|
6
|
-
getResolvedThemeFilePath,
|
|
7
|
-
} from '../theme-file-uri-utils';
|
|
4
|
+
import { getResolvedThemeFilePath } from '../theme-file-uri-utils';
|
|
8
5
|
|
|
9
6
|
const themeFileURIs = [
|
|
10
7
|
{
|
|
@@ -19,28 +16,6 @@ const themeFileURIs = [
|
|
|
19
16
|
},
|
|
20
17
|
];
|
|
21
18
|
|
|
22
|
-
describe( 'setThemeFileUris()', () => {
|
|
23
|
-
const themeJson = {
|
|
24
|
-
styles: {
|
|
25
|
-
background: {
|
|
26
|
-
backgroundImage: {
|
|
27
|
-
url: 'file:./assets/image.jpg',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
it( 'should replace relative paths with resolved URIs if found in themeFileURIs', () => {
|
|
34
|
-
const newThemeJson = setThemeFileUris( themeJson, themeFileURIs );
|
|
35
|
-
expect(
|
|
36
|
-
newThemeJson.styles.background.backgroundImage.url ===
|
|
37
|
-
'https://wordpress.org/assets/image.jpg'
|
|
38
|
-
).toBe( true );
|
|
39
|
-
// Object reference should be the same as the function is mutating the object.
|
|
40
|
-
expect( newThemeJson ).toEqual( themeJson );
|
|
41
|
-
} );
|
|
42
|
-
} );
|
|
43
|
-
|
|
44
19
|
describe( 'getResolvedThemeFilePath()', () => {
|
|
45
20
|
it.each( [
|
|
46
21
|
[
|
|
@@ -1028,14 +1028,59 @@ describe( 'global styles renderer', () => {
|
|
|
1028
1028
|
'letter-spacing: 2px',
|
|
1029
1029
|
] );
|
|
1030
1030
|
} );
|
|
1031
|
+
it( 'should set default values for block background styles', () => {
|
|
1032
|
+
const backgroundStyles = {
|
|
1033
|
+
background: {
|
|
1034
|
+
backgroundImage: {
|
|
1035
|
+
url: 'https://wordpress.org/assets/image.jpg',
|
|
1036
|
+
id: 123,
|
|
1037
|
+
},
|
|
1038
|
+
},
|
|
1039
|
+
};
|
|
1040
|
+
expect(
|
|
1041
|
+
getStylesDeclarations( backgroundStyles, '.wp-block-group' )
|
|
1042
|
+
).toEqual( [
|
|
1043
|
+
"background-image: url( 'https://wordpress.org/assets/image.jpg' )",
|
|
1044
|
+
'background-size: cover',
|
|
1045
|
+
] );
|
|
1046
|
+
// Test with root-level styles.
|
|
1047
|
+
expect(
|
|
1048
|
+
getStylesDeclarations( backgroundStyles, ROOT_BLOCK_SELECTOR )
|
|
1049
|
+
).toEqual( [
|
|
1050
|
+
"background-image: url( 'https://wordpress.org/assets/image.jpg' )",
|
|
1051
|
+
] );
|
|
1052
|
+
expect(
|
|
1053
|
+
getStylesDeclarations(
|
|
1054
|
+
{
|
|
1055
|
+
background: {
|
|
1056
|
+
...backgroundStyles.background,
|
|
1057
|
+
backgroundSize: 'contain',
|
|
1058
|
+
},
|
|
1059
|
+
},
|
|
1060
|
+
'.wp-block-group'
|
|
1061
|
+
)
|
|
1062
|
+
).toEqual( [
|
|
1063
|
+
"background-image: url( 'https://wordpress.org/assets/image.jpg' )",
|
|
1064
|
+
'background-position: center',
|
|
1065
|
+
'background-size: contain',
|
|
1066
|
+
] );
|
|
1067
|
+
} );
|
|
1031
1068
|
} );
|
|
1032
1069
|
|
|
1033
1070
|
describe( 'processCSSNesting', () => {
|
|
1071
|
+
it( 'should return empty string when supplied css is empty', () => {
|
|
1072
|
+
expect( processCSSNesting( '', '.foo' ) ).toEqual( '' );
|
|
1073
|
+
} );
|
|
1034
1074
|
it( 'should return processed CSS without any nested selectors', () => {
|
|
1035
1075
|
expect(
|
|
1036
1076
|
processCSSNesting( 'color: red; margin: auto;', '.foo' )
|
|
1037
1077
|
).toEqual( ':root :where(.foo){color: red; margin: auto;}' );
|
|
1038
1078
|
} );
|
|
1079
|
+
it( 'should return processed CSS when there are no root selectors', () => {
|
|
1080
|
+
expect(
|
|
1081
|
+
processCSSNesting( '&::before{color: red;}', '.foo' )
|
|
1082
|
+
).toEqual( ':root :where(.foo)::before{color: red;}' );
|
|
1083
|
+
} );
|
|
1039
1084
|
it( 'should return processed CSS with nested selectors', () => {
|
|
1040
1085
|
expect(
|
|
1041
1086
|
processCSSNesting(
|
|
@@ -1049,21 +1094,21 @@ describe( 'global styles renderer', () => {
|
|
|
1049
1094
|
it( 'should return processed CSS with pseudo elements', () => {
|
|
1050
1095
|
expect(
|
|
1051
1096
|
processCSSNesting(
|
|
1052
|
-
'color: red; margin: auto; &::before{color: blue;} & ::before{color: green;} &.one::before{color: yellow;} & .two::before{color: purple;}',
|
|
1097
|
+
'color: red; margin: auto; &::before{color: blue;} & ::before{color: green;} &.one::before{color: yellow;} & .two::before{color: purple;} & > ::before{color: darkseagreen;}',
|
|
1053
1098
|
'.foo'
|
|
1054
1099
|
)
|
|
1055
1100
|
).toEqual(
|
|
1056
|
-
':root :where(.foo){color: red; margin: auto;}:root :where(.foo::before
|
|
1101
|
+
':root :where(.foo){color: red; margin: auto;}:root :where(.foo)::before{color: blue;}:root :where(.foo) ::before{color: green;}:root :where(.foo.one)::before{color: yellow;}:root :where(.foo .two)::before{color: purple;}:root :where(.foo) > ::before{color: darkseagreen;}'
|
|
1057
1102
|
);
|
|
1058
1103
|
} );
|
|
1059
1104
|
it( 'should return processed CSS with multiple root selectors', () => {
|
|
1060
1105
|
expect(
|
|
1061
1106
|
processCSSNesting(
|
|
1062
|
-
'color: red; margin: auto; &.one{color: blue;} & .two{color: green;} &::before{color: yellow;} & ::before{color: purple;} &.three::before{color: orange;} & .four::before{color: skyblue;}',
|
|
1107
|
+
'color: red; margin: auto; &.one{color: blue;} & .two{color: green;} &::before{color: yellow;} & ::before{color: purple;} &.three::before{color: orange;} & .four::before{color: skyblue;} & > ::before{color: darkseagreen;}',
|
|
1063
1108
|
'.foo, .bar'
|
|
1064
1109
|
)
|
|
1065
1110
|
).toEqual(
|
|
1066
|
-
':root :where(.foo, .bar){color: red; margin: auto;}:root :where(.foo.one, .bar.one){color: blue;}:root :where(.foo .two, .bar .two){color: green;}:root :where(.foo
|
|
1111
|
+
':root :where(.foo, .bar){color: red; margin: auto;}:root :where(.foo.one, .bar.one){color: blue;}:root :where(.foo .two, .bar .two){color: green;}:root :where(.foo, .bar)::before{color: yellow;}:root :where(.foo, .bar) ::before{color: purple;}:root :where(.foo.three, .bar.three)::before{color: orange;}:root :where(.foo .four, .bar .four)::before{color: skyblue;}:root :where(.foo, .bar) > ::before{color: darkseagreen;}'
|
|
1067
1112
|
);
|
|
1068
1113
|
} );
|
|
1069
1114
|
} );
|
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
getPresetVariableFromValue,
|
|
8
8
|
getValueFromVariable,
|
|
9
9
|
scopeFeatureSelectors,
|
|
10
|
+
getResolvedThemeFilePath,
|
|
11
|
+
getResolvedRefValue,
|
|
12
|
+
getResolvedValue,
|
|
10
13
|
} from '../utils';
|
|
11
14
|
|
|
12
15
|
describe( 'editor utils', () => {
|
|
@@ -52,6 +55,41 @@ describe( 'editor utils', () => {
|
|
|
52
55
|
},
|
|
53
56
|
},
|
|
54
57
|
},
|
|
58
|
+
styles: {
|
|
59
|
+
background: {
|
|
60
|
+
backgroundImage: {
|
|
61
|
+
url: 'file:./assets/image.jpg',
|
|
62
|
+
},
|
|
63
|
+
backgroundAttachment: 'fixed',
|
|
64
|
+
backgroundPosition: 'top left',
|
|
65
|
+
},
|
|
66
|
+
blocks: {
|
|
67
|
+
'core/group': {
|
|
68
|
+
background: {
|
|
69
|
+
backgroundImage: {
|
|
70
|
+
ref: 'styles.background.backgroundImage',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
dimensions: {
|
|
74
|
+
minHeight: '100px',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
_links: {
|
|
80
|
+
'wp:theme-file': [
|
|
81
|
+
{
|
|
82
|
+
name: 'file:./assets/image.jpg',
|
|
83
|
+
href: 'https://wordpress.org/assets/image.jpg',
|
|
84
|
+
target: 'styles.background.backgroundImage.url',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'file:./assets/other/image.jpg',
|
|
88
|
+
href: 'https://wordpress.org/assets/other/image.jpg',
|
|
89
|
+
target: "styles.blocks.['core/group'].background.backgroundImage.url",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
55
93
|
isGlobalStylesUserThemeJSON: true,
|
|
56
94
|
};
|
|
57
95
|
|
|
@@ -366,4 +404,86 @@ describe( 'editor utils', () => {
|
|
|
366
404
|
} );
|
|
367
405
|
} );
|
|
368
406
|
} );
|
|
407
|
+
|
|
408
|
+
describe( 'getResolvedThemeFilePath()', () => {
|
|
409
|
+
it.each( [
|
|
410
|
+
[
|
|
411
|
+
'file:./assets/image.jpg',
|
|
412
|
+
'https://wordpress.org/assets/image.jpg',
|
|
413
|
+
'Should return absolute URL if found in themeFileURIs',
|
|
414
|
+
],
|
|
415
|
+
[
|
|
416
|
+
'file:./misc/image.jpg',
|
|
417
|
+
'file:./misc/image.jpg',
|
|
418
|
+
'Should return value if not found in themeFileURIs',
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
'https://wordpress.org/assets/image.jpg',
|
|
422
|
+
'https://wordpress.org/assets/image.jpg',
|
|
423
|
+
'Should not match absolute URLs',
|
|
424
|
+
],
|
|
425
|
+
] )(
|
|
426
|
+
'Given file %s and return value %s: %s',
|
|
427
|
+
( file, returnedValue ) => {
|
|
428
|
+
expect(
|
|
429
|
+
getResolvedThemeFilePath(
|
|
430
|
+
file,
|
|
431
|
+
themeJson._links[ 'wp:theme-file' ]
|
|
432
|
+
) === returnedValue
|
|
433
|
+
).toBe( true );
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
} );
|
|
437
|
+
|
|
438
|
+
describe( 'getResolvedRefValue()', () => {
|
|
439
|
+
it.each( [
|
|
440
|
+
[ 'blue', 'blue', null ],
|
|
441
|
+
[ 0, 0, themeJson ],
|
|
442
|
+
[
|
|
443
|
+
{ ref: 'styles.background.backgroundImage' },
|
|
444
|
+
{ url: 'file:./assets/image.jpg' },
|
|
445
|
+
themeJson,
|
|
446
|
+
],
|
|
447
|
+
[
|
|
448
|
+
{
|
|
449
|
+
ref: 'styles.blocks.core/group.background.backgroundImage',
|
|
450
|
+
},
|
|
451
|
+
undefined,
|
|
452
|
+
themeJson,
|
|
453
|
+
],
|
|
454
|
+
] )(
|
|
455
|
+
'Given ruleValue %s return expected value of %s',
|
|
456
|
+
( ruleValue, returnedValue, tree ) => {
|
|
457
|
+
expect( getResolvedRefValue( ruleValue, tree ) ).toEqual(
|
|
458
|
+
returnedValue
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
} );
|
|
463
|
+
|
|
464
|
+
describe( 'getResolvedValue()', () => {
|
|
465
|
+
it.each( [
|
|
466
|
+
[ 'blue', 'blue', null ],
|
|
467
|
+
[ 0, 0, themeJson ],
|
|
468
|
+
[
|
|
469
|
+
{ ref: 'styles.background.backgroundImage' },
|
|
470
|
+
{ url: 'https://wordpress.org/assets/image.jpg' },
|
|
471
|
+
themeJson,
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
{
|
|
475
|
+
ref: 'styles.blocks.core/group.background.backgroundImage',
|
|
476
|
+
},
|
|
477
|
+
undefined,
|
|
478
|
+
themeJson,
|
|
479
|
+
],
|
|
480
|
+
] )(
|
|
481
|
+
'Given ruleValue %s return expected value of %s',
|
|
482
|
+
( ruleValue, returnedValue, tree ) => {
|
|
483
|
+
expect( getResolvedValue( ruleValue, tree ) ).toEqual(
|
|
484
|
+
returnedValue
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
} );
|
|
369
489
|
} );
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { getValueFromObjectPath } from '../../utils/object';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Looks up a theme file URI based on a relative path.
|
|
8
3
|
*
|
|
@@ -21,57 +16,3 @@ export function getResolvedThemeFilePath( file, themeFileURIs = [] ) {
|
|
|
21
16
|
|
|
22
17
|
return uri?.href;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Mutates an object by settings a value at the provided path.
|
|
27
|
-
*
|
|
28
|
-
* @param {Object} object Object to set a value in.
|
|
29
|
-
* @param {number|string|Array} path Path in the object to modify.
|
|
30
|
-
* @param {*} value New value to set.
|
|
31
|
-
* @return {Object} Object with the new value set.
|
|
32
|
-
*/
|
|
33
|
-
function setMutably( object, path, value ) {
|
|
34
|
-
path = path.split( '.' );
|
|
35
|
-
const finalValueKey = path.pop();
|
|
36
|
-
let prev = object;
|
|
37
|
-
|
|
38
|
-
for ( const key of path ) {
|
|
39
|
-
const current = prev[ key ];
|
|
40
|
-
prev = current;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
prev[ finalValueKey ] = value;
|
|
44
|
-
|
|
45
|
-
return object;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Resolves any relative paths if a corresponding theme file URI is available.
|
|
50
|
-
* Note: this function mutates the object and is specifically to be used in
|
|
51
|
-
* an async styles build context in useGlobalStylesOutput
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} themeJson Theme.json/Global styles tree.
|
|
54
|
-
* @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
|
|
55
|
-
* @return {Object} Returns mutated object.
|
|
56
|
-
*/
|
|
57
|
-
export function setThemeFileUris( themeJson, themeFileURIs ) {
|
|
58
|
-
if ( ! themeJson?.styles || ! themeFileURIs ) {
|
|
59
|
-
return themeJson;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
themeFileURIs.forEach( ( { name, href, target } ) => {
|
|
63
|
-
const value = getValueFromObjectPath( themeJson, target );
|
|
64
|
-
if ( value === name ) {
|
|
65
|
-
/*
|
|
66
|
-
* The object must not be updated immutably here because the
|
|
67
|
-
* themeJson is a reference to the global styles tree used as a dependency in the
|
|
68
|
-
* useGlobalStylesOutputWithConfig() hook. If we don't mutate the object,
|
|
69
|
-
* the hook will detect the change and re-render the component, resulting
|
|
70
|
-
* in a maximum depth exceeded error.
|
|
71
|
-
*/
|
|
72
|
-
themeJson = setMutably( themeJson, target, href );
|
|
73
|
-
}
|
|
74
|
-
} );
|
|
75
|
-
|
|
76
|
-
return themeJson;
|
|
77
|
-
}
|