@wordpress/edit-site 5.7.0 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/add-new-template/new-template.js +2 -1
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +7 -7
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +6 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +117 -0
- package/build/components/editor-canvas-container/index.js.map +1 -0
- package/build/components/global-styles/border-panel.js +81 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +6 -8
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +11 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +53 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +50 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/global-styles-provider.js +4 -15
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/preview.js +1 -1
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +14 -8
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-effects.js +15 -7
- package/build/components/global-styles/screen-effects.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +2 -2
- package/build/components/global-styles/screen-filters.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -118
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +149 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -0
- package/build/components/global-styles/ui.js +52 -15
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/index.js +11 -7
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -137
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +17 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/table.js +3 -3
- package/build/components/list/table.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -0
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/index.js +4 -0
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +28 -13
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -6
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +5 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/site-hub/index.js +40 -17
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +8 -7
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/start-template-options/index.js +9 -8
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/style-book/index.js +9 -41
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/template-details/index.js +3 -1
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/hooks/commands/index.js +19 -0
- package/build/hooks/commands/index.js.map +1 -0
- package/build/hooks/commands/use-navigation-commands.js +126 -0
- package/build/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build/hooks/commands/use-wp-admin-commands.js +97 -0
- package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/store/private-actions.js +19 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +13 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +23 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +3 -2
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +6 -6
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +6 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +100 -0
- package/build-module/components/editor-canvas-container/index.js.map +1 -0
- package/build-module/components/global-styles/border-panel.js +81 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +6 -6
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +11 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +43 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +40 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/global-styles-provider.js +5 -16
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/preview.js +1 -1
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +13 -8
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-effects.js +13 -4
- package/build-module/components/global-styles/screen-effects.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +2 -2
- package/build-module/components/global-styles/screen-filters.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +11 -114
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +130 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -0
- package/build-module/components/global-styles/ui.js +49 -16
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +10 -7
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -135
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +14 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/table.js +3 -3
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -0
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -0
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +28 -15
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +9 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/site-hub/index.js +40 -18
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +8 -7
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +9 -8
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/style-book/index.js +10 -41
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -1
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/hooks/commands/index.js +10 -0
- package/build-module/hooks/commands/index.js.map +1 -0
- package/build-module/hooks/commands/use-navigation-commands.js +109 -0
- package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js +81 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/private-actions.js +15 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +11 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +23 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +133 -107
- package/build-style/style.css +133 -107
- package/package.json +34 -32
- package/src/components/add-new-template/new-template.js +3 -0
- package/src/components/block-editor/index.js +8 -8
- package/src/components/editor/index.js +11 -3
- package/src/components/editor-canvas-container/index.js +115 -0
- package/src/components/editor-canvas-container/style.scss +19 -0
- package/src/components/global-styles/border-panel.js +73 -1
- package/src/components/global-styles/context-menu.js +6 -6
- package/src/components/global-styles/dimensions-panel.js +11 -0
- package/src/components/global-styles/effects-panel.js +40 -0
- package/src/components/global-styles/filters-panel.js +39 -0
- package/src/components/global-styles/global-styles-provider.js +4 -18
- package/src/components/global-styles/preview.js +1 -1
- package/src/components/global-styles/screen-block-list.js +9 -5
- package/src/components/global-styles/screen-css.js +1 -1
- package/src/components/global-styles/screen-effects.js +12 -5
- package/src/components/global-styles/screen-filters.js +2 -2
- package/src/components/global-styles/screen-style-variations.js +10 -129
- package/src/components/global-styles/style-variations-container.js +136 -0
- package/src/components/global-styles/style.scss +0 -39
- package/src/components/global-styles/ui.js +54 -8
- package/src/components/header-edit-mode/index.js +14 -5
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -155
- package/src/components/layout/index.js +13 -16
- package/src/components/layout/style.scss +31 -4
- package/src/components/list/table.js +16 -2
- package/src/components/preferences-modal/index.js +7 -0
- package/src/components/secondary-sidebar/style.scss +23 -5
- package/src/components/sidebar/index.js +4 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +36 -17
- package/src/components/sidebar-navigation-screen/index.js +10 -5
- package/src/components/sidebar-navigation-screen/style.scss +20 -5
- package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/src/components/sidebar-navigation-screen-main/index.js +9 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
- package/src/components/site-hub/index.js +51 -23
- package/src/components/site-icon/index.js +6 -11
- package/src/components/site-icon/style.scss +8 -3
- package/src/components/start-template-options/index.js +13 -12
- package/src/components/start-template-options/style.scss +18 -43
- package/src/components/style-book/index.js +7 -51
- package/src/components/style-book/style.scss +0 -18
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -3
- package/src/components/template-details/index.js +1 -0
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/hooks/commands/index.js +10 -0
- package/src/hooks/commands/use-navigation-commands.js +112 -0
- package/src/hooks/commands/use-wp-admin-commands.js +79 -0
- package/src/hooks/template-part-edit.js +1 -0
- package/src/index.js +1 -0
- package/src/store/private-actions.js +14 -0
- package/src/store/private-selectors.js +11 -0
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +2 -1
- package/src/style.scss +1 -0
- package/build/components/global-styles/duotone-panel.js +0 -78
- package/build/components/global-styles/duotone-panel.js.map +0 -1
- package/build/components/global-styles/filter-utils.js +0 -17
- package/build/components/global-styles/filter-utils.js.map +0 -1
- package/build/components/global-styles/shadow-panel.js +0 -197
- package/build/components/global-styles/shadow-panel.js.map +0 -1
- package/build-module/components/global-styles/duotone-panel.js +0 -67
- package/build-module/components/global-styles/duotone-panel.js.map +0 -1
- package/build-module/components/global-styles/filter-utils.js +0 -9
- package/build-module/components/global-styles/filter-utils.js.map +0 -1
- package/build-module/components/global-styles/shadow-panel.js +0 -178
- package/build-module/components/global-styles/shadow-panel.js.map +0 -1
- package/src/components/global-styles/duotone-panel.js +0 -82
- package/src/components/global-styles/filter-utils.js +0 -9
- package/src/components/global-styles/shadow-panel.js +0 -178
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Children, cloneElement, useState, useMemo } from '@wordpress/element';
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
privateApis as componentsPrivateApis,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import { ESCAPE } from '@wordpress/keycodes';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
|
+
import { closeSmall } from '@wordpress/icons';
|
|
13
|
+
import { useFocusOnMount, useFocusReturn } from '@wordpress/compose';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { unlock } from '../../private-apis';
|
|
19
|
+
import { store as editSiteStore } from '../../store';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns a translated string for the title of the editor canvas container.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} view Editor canvas container view.
|
|
25
|
+
*
|
|
26
|
+
* @return {string} Translated string corresponding to value of view. Default is ''.
|
|
27
|
+
*/
|
|
28
|
+
export function getEditorCanvasContainerTitle( view ) {
|
|
29
|
+
switch ( view ) {
|
|
30
|
+
case 'style-book':
|
|
31
|
+
return __( 'Style Book' );
|
|
32
|
+
default:
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Creates a private slot fill.
|
|
38
|
+
const { createPrivateSlotFill } = unlock( componentsPrivateApis );
|
|
39
|
+
const SLOT_FILL_NAME = 'EditSiteEditorCanvasContainerSlot';
|
|
40
|
+
const { Slot: EditorCanvasContainerSlot, Fill: EditorCanvasContainerFill } =
|
|
41
|
+
createPrivateSlotFill( SLOT_FILL_NAME );
|
|
42
|
+
|
|
43
|
+
function EditorCanvasContainer( {
|
|
44
|
+
children,
|
|
45
|
+
closeButtonLabel,
|
|
46
|
+
onClose = () => {},
|
|
47
|
+
} ) {
|
|
48
|
+
const editorCanvasContainerView = useSelect(
|
|
49
|
+
( select ) =>
|
|
50
|
+
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
|
|
51
|
+
[]
|
|
52
|
+
);
|
|
53
|
+
const [ isClosed, setIsClosed ] = useState( false );
|
|
54
|
+
const { setEditorCanvasContainerView } = unlock(
|
|
55
|
+
useDispatch( editSiteStore )
|
|
56
|
+
);
|
|
57
|
+
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
58
|
+
const sectionFocusReturnRef = useFocusReturn();
|
|
59
|
+
const title = useMemo(
|
|
60
|
+
() => getEditorCanvasContainerTitle( editorCanvasContainerView ),
|
|
61
|
+
[ editorCanvasContainerView ]
|
|
62
|
+
);
|
|
63
|
+
function onCloseContainer() {
|
|
64
|
+
onClose();
|
|
65
|
+
setEditorCanvasContainerView( undefined );
|
|
66
|
+
setIsClosed( true );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function closeOnEscape( event ) {
|
|
70
|
+
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
onCloseContainer();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const childrenWithProps = Array.isArray( children )
|
|
77
|
+
? Children.map( children, ( child, index ) =>
|
|
78
|
+
index === 0
|
|
79
|
+
? cloneElement( child, {
|
|
80
|
+
ref: sectionFocusReturnRef,
|
|
81
|
+
} )
|
|
82
|
+
: child
|
|
83
|
+
)
|
|
84
|
+
: cloneElement( children, {
|
|
85
|
+
ref: sectionFocusReturnRef,
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
if ( isClosed ) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<EditorCanvasContainerFill>
|
|
94
|
+
{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
|
|
95
|
+
<section
|
|
96
|
+
className="edit-site-editor-canvas-container"
|
|
97
|
+
ref={ focusOnMountRef }
|
|
98
|
+
onKeyDown={ closeOnEscape }
|
|
99
|
+
aria-label={ title }
|
|
100
|
+
>
|
|
101
|
+
<Button
|
|
102
|
+
className="edit-site-editor-canvas-container__close-button"
|
|
103
|
+
icon={ closeSmall }
|
|
104
|
+
label={ closeButtonLabel || __( 'Close' ) }
|
|
105
|
+
onClick={ onCloseContainer }
|
|
106
|
+
showTooltip={ false }
|
|
107
|
+
/>
|
|
108
|
+
{ childrenWithProps }
|
|
109
|
+
</section>
|
|
110
|
+
</EditorCanvasContainerFill>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
EditorCanvasContainer.Slot = EditorCanvasContainerSlot;
|
|
115
|
+
export default EditorCanvasContainer;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.edit-site-editor-canvas-container {
|
|
2
|
+
background: $white; // Fallback color, overridden by JavaScript.
|
|
3
|
+
border-radius: $radius-block-ui;
|
|
4
|
+
bottom: 0;
|
|
5
|
+
left: 0;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
position: absolute;
|
|
8
|
+
right: 0;
|
|
9
|
+
top: 0;
|
|
10
|
+
transition: all 0.3s; // Match .block-editor-iframe__body transition.
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.edit-site-editor-canvas-container__close-button {
|
|
14
|
+
position: absolute;
|
|
15
|
+
right: $grid-unit-10;
|
|
16
|
+
top: math.div($grid-unit-60 - $button-size, 2); // ( tab height - button size ) / 2
|
|
17
|
+
z-index: 1;
|
|
18
|
+
background: $white;
|
|
19
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
+
import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -15,6 +16,41 @@ const {
|
|
|
15
16
|
BorderPanel: StylesBorderPanel,
|
|
16
17
|
} = unlock( blockEditorPrivateApis );
|
|
17
18
|
|
|
19
|
+
function applyFallbackStyle( border ) {
|
|
20
|
+
if ( ! border ) {
|
|
21
|
+
return border;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const hasColorOrWidth = border.color || border.width;
|
|
25
|
+
|
|
26
|
+
if ( ! border.style && hasColorOrWidth ) {
|
|
27
|
+
return { ...border, style: 'solid' };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if ( border.style && ! hasColorOrWidth ) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return border;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function applyAllFallbackStyles( border ) {
|
|
38
|
+
if ( ! border ) {
|
|
39
|
+
return border;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ( hasSplitBorders( border ) ) {
|
|
43
|
+
return {
|
|
44
|
+
top: applyFallbackStyle( border.top ),
|
|
45
|
+
right: applyFallbackStyle( border.right ),
|
|
46
|
+
bottom: applyFallbackStyle( border.bottom ),
|
|
47
|
+
left: applyFallbackStyle( border.left ),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return applyFallbackStyle( border );
|
|
52
|
+
}
|
|
53
|
+
|
|
18
54
|
export default function BorderPanel( { name, variation = '' } ) {
|
|
19
55
|
let prefixParts = [];
|
|
20
56
|
if ( variation ) {
|
|
@@ -29,11 +65,47 @@ export default function BorderPanel( { name, variation = '' } ) {
|
|
|
29
65
|
const [ rawSettings ] = useGlobalSetting( '', name );
|
|
30
66
|
const settings = useSettingsForBlockElement( rawSettings, name );
|
|
31
67
|
|
|
68
|
+
const onChange = ( newStyle ) => {
|
|
69
|
+
if ( ! newStyle?.border ) {
|
|
70
|
+
setStyle( newStyle );
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// As Global Styles can't conditionally generate styles based on if
|
|
75
|
+
// other style properties have been set, we need to force split
|
|
76
|
+
// border definitions for user set global border styles. Border
|
|
77
|
+
// radius is derived from the same property i.e. `border.radius` if
|
|
78
|
+
// it is a string that is used. The longhand border radii styles are
|
|
79
|
+
// only generated if that property is an object.
|
|
80
|
+
//
|
|
81
|
+
// For borders (color, style, and width) those are all properties on
|
|
82
|
+
// the `border` style property. This means if the theme.json defined
|
|
83
|
+
// split borders and the user condenses them into a flat border or
|
|
84
|
+
// vice-versa we'd get both sets of styles which would conflict.
|
|
85
|
+
const { radius, ...newBorder } = newStyle.border;
|
|
86
|
+
const border = applyAllFallbackStyles( newBorder );
|
|
87
|
+
const updatedBorder = ! hasSplitBorders( border )
|
|
88
|
+
? {
|
|
89
|
+
top: border,
|
|
90
|
+
right: border,
|
|
91
|
+
bottom: border,
|
|
92
|
+
left: border,
|
|
93
|
+
}
|
|
94
|
+
: {
|
|
95
|
+
color: null,
|
|
96
|
+
style: null,
|
|
97
|
+
width: null,
|
|
98
|
+
...border,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
setStyle( { ...newStyle, border: { ...updatedBorder, radius } } );
|
|
102
|
+
};
|
|
103
|
+
|
|
32
104
|
return (
|
|
33
105
|
<StylesBorderPanel
|
|
34
106
|
inheritedValue={ inheritedStyle }
|
|
35
107
|
value={ style }
|
|
36
|
-
onChange={
|
|
108
|
+
onChange={ onChange }
|
|
37
109
|
settings={ settings }
|
|
38
110
|
/>
|
|
39
111
|
);
|
|
@@ -27,12 +27,10 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
27
27
|
/**
|
|
28
28
|
* Internal dependencies
|
|
29
29
|
*/
|
|
30
|
-
import { useHasFilterPanel } from './filter-utils';
|
|
31
30
|
import { useHasVariationsPanel } from './variations-panel';
|
|
32
31
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
33
32
|
import { IconWithCurrentColor } from './icon-with-current-color';
|
|
34
33
|
import { ScreenVariations } from './screen-variations';
|
|
35
|
-
import { useHasShadowControl } from './shadow-panel';
|
|
36
34
|
import { unlock } from '../../private-apis';
|
|
37
35
|
|
|
38
36
|
const {
|
|
@@ -40,6 +38,8 @@ const {
|
|
|
40
38
|
useHasTypographyPanel,
|
|
41
39
|
useHasBorderPanel,
|
|
42
40
|
useHasColorPanel,
|
|
41
|
+
useHasEffectsPanel,
|
|
42
|
+
useHasFiltersPanel,
|
|
43
43
|
useGlobalSetting,
|
|
44
44
|
useSettingsForBlockElement,
|
|
45
45
|
} = unlock( blockEditorPrivateApis );
|
|
@@ -50,8 +50,8 @@ function ContextMenu( { name, parentMenu = '' } ) {
|
|
|
50
50
|
const hasTypographyPanel = useHasTypographyPanel( settings );
|
|
51
51
|
const hasColorPanel = useHasColorPanel( settings );
|
|
52
52
|
const hasBorderPanel = useHasBorderPanel( settings );
|
|
53
|
-
const hasEffectsPanel =
|
|
54
|
-
const hasFilterPanel =
|
|
53
|
+
const hasEffectsPanel = useHasEffectsPanel( settings );
|
|
54
|
+
const hasFilterPanel = useHasFiltersPanel( settings );
|
|
55
55
|
const hasDimensionsPanel = useHasDimensionsPanel( settings );
|
|
56
56
|
const hasLayoutPanel = hasDimensionsPanel;
|
|
57
57
|
const hasVariationsPanel = useHasVariationsPanel( name, parentMenu );
|
|
@@ -109,9 +109,9 @@ function ContextMenu( { name, parentMenu = '' } ) {
|
|
|
109
109
|
<NavigationButtonAsItem
|
|
110
110
|
icon={ shadow }
|
|
111
111
|
path={ parentMenu + '/effects' }
|
|
112
|
-
aria-label={ __( '
|
|
112
|
+
aria-label={ __( 'Effects' ) }
|
|
113
113
|
>
|
|
114
|
-
{ __( '
|
|
114
|
+
{ __( 'Effects' ) }
|
|
115
115
|
</NavigationButtonAsItem>
|
|
116
116
|
) }
|
|
117
117
|
{ hasFilterPanel && (
|
|
@@ -16,6 +16,16 @@ const {
|
|
|
16
16
|
DimensionsPanel: StylesDimensionsPanel,
|
|
17
17
|
} = unlock( blockEditorPrivateApis );
|
|
18
18
|
|
|
19
|
+
const DEFAULT_CONTROLS = {
|
|
20
|
+
contentSize: true,
|
|
21
|
+
wideSize: true,
|
|
22
|
+
padding: true,
|
|
23
|
+
margin: true,
|
|
24
|
+
blockGap: true,
|
|
25
|
+
minHeight: true,
|
|
26
|
+
childLayout: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
19
29
|
export default function DimensionsPanel( { name, variation = '' } ) {
|
|
20
30
|
let prefixParts = [];
|
|
21
31
|
if ( variation ) {
|
|
@@ -66,6 +76,7 @@ export default function DimensionsPanel( { name, variation = '' } ) {
|
|
|
66
76
|
onChange={ onChange }
|
|
67
77
|
settings={ settings }
|
|
68
78
|
includeLayoutControls
|
|
79
|
+
defaultControls={ DEFAULT_CONTROLS }
|
|
69
80
|
/>
|
|
70
81
|
);
|
|
71
82
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { unlock } from '../../private-apis';
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
useGlobalSetting,
|
|
13
|
+
useGlobalStyle,
|
|
14
|
+
EffectsPanel: StylesEffectsPanel,
|
|
15
|
+
useSettingsForBlockElement,
|
|
16
|
+
} = unlock( blockEditorPrivateApis );
|
|
17
|
+
|
|
18
|
+
export default function EffectsPanel( { name, variation = '' } ) {
|
|
19
|
+
let prefixParts = [];
|
|
20
|
+
if ( variation ) {
|
|
21
|
+
prefixParts = [ 'variations', variation ].concat( prefixParts );
|
|
22
|
+
}
|
|
23
|
+
const prefix = prefixParts.join( '.' );
|
|
24
|
+
|
|
25
|
+
const [ style ] = useGlobalStyle( prefix, name, 'user', false );
|
|
26
|
+
const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
|
|
27
|
+
shouldDecodeEncode: false,
|
|
28
|
+
} );
|
|
29
|
+
const [ rawSettings ] = useGlobalSetting( '', name );
|
|
30
|
+
const settings = useSettingsForBlockElement( rawSettings, name );
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<StylesEffectsPanel
|
|
34
|
+
inheritedValue={ inheritedStyle }
|
|
35
|
+
value={ style }
|
|
36
|
+
onChange={ setStyle }
|
|
37
|
+
settings={ settings }
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { unlock } from '../../private-apis';
|
|
10
|
+
const {
|
|
11
|
+
useGlobalStyle,
|
|
12
|
+
useGlobalSetting,
|
|
13
|
+
useSettingsForBlockElement,
|
|
14
|
+
FiltersPanel: StylesFiltersPanel,
|
|
15
|
+
} = unlock( blockEditorPrivateApis );
|
|
16
|
+
|
|
17
|
+
export default function FiltersPanel( { name } ) {
|
|
18
|
+
const [ style ] = useGlobalStyle( '', name, 'user', false );
|
|
19
|
+
const [ inheritedStyle, setStyle ] = useGlobalStyle( '', name, 'all', {
|
|
20
|
+
shouldDecodeEncode: false,
|
|
21
|
+
} );
|
|
22
|
+
const [ rawSettings ] = useGlobalSetting( '', name );
|
|
23
|
+
const settings = useSettingsForBlockElement( rawSettings, name );
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<StylesFiltersPanel
|
|
27
|
+
inheritedValue={ inheritedStyle }
|
|
28
|
+
value={ style }
|
|
29
|
+
onChange={ setStyle }
|
|
30
|
+
settings={ {
|
|
31
|
+
...settings,
|
|
32
|
+
color: {
|
|
33
|
+
...settings.color,
|
|
34
|
+
customDuotone: false, //TO FIX: Custom duotone only works on the block level right now
|
|
35
|
+
},
|
|
36
|
+
} }
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { mergeWith
|
|
4
|
+
import { mergeWith } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -17,7 +17,9 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
17
17
|
import CanvasSpinner from '../canvas-spinner';
|
|
18
18
|
import { unlock } from '../../private-apis';
|
|
19
19
|
|
|
20
|
-
const { GlobalStylesContext } = unlock(
|
|
20
|
+
const { GlobalStylesContext, cleanEmptyObject } = unlock(
|
|
21
|
+
blockEditorPrivateApis
|
|
22
|
+
);
|
|
21
23
|
|
|
22
24
|
function mergeTreesCustomizer( _, srcValue ) {
|
|
23
25
|
// We only pass as arrays the presets,
|
|
@@ -32,22 +34,6 @@ export function mergeBaseAndUserConfigs( base, user ) {
|
|
|
32
34
|
return mergeWith( {}, base, user, mergeTreesCustomizer );
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
const cleanEmptyObject = ( object ) => {
|
|
36
|
-
if (
|
|
37
|
-
object === null ||
|
|
38
|
-
typeof object !== 'object' ||
|
|
39
|
-
Array.isArray( object )
|
|
40
|
-
) {
|
|
41
|
-
return object;
|
|
42
|
-
}
|
|
43
|
-
const cleanedNestedObjects = Object.fromEntries(
|
|
44
|
-
Object.entries( mapValues( object, cleanEmptyObject ) ).filter(
|
|
45
|
-
( [ , value ] ) => Boolean( value )
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
37
|
function useGlobalStylesUserConfig() {
|
|
52
38
|
const { globalStylesId, isReady, settings, styles } = useSelect(
|
|
53
39
|
( select ) => {
|
|
@@ -130,7 +130,7 @@ const StylesPreview = ( { label, isFocused, withHoverView } ) => {
|
|
|
130
130
|
height: normalizedHeight * ratio,
|
|
131
131
|
width: '100%',
|
|
132
132
|
background: gradientValue ?? backgroundColor,
|
|
133
|
-
cursor: 'pointer',
|
|
133
|
+
cursor: withHoverView ? 'pointer' : undefined,
|
|
134
134
|
} }
|
|
135
135
|
initial="start"
|
|
136
136
|
animate={
|
|
@@ -57,21 +57,25 @@ function useSortedBlockTypes() {
|
|
|
57
57
|
return [ ...coreItems, ...nonCoreItems ];
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function
|
|
61
|
-
const [ rawSettings ] = useGlobalSetting( '',
|
|
62
|
-
const settings = useSettingsForBlockElement( rawSettings,
|
|
60
|
+
export function useBlockHasGlobalStyles( blockName ) {
|
|
61
|
+
const [ rawSettings ] = useGlobalSetting( '', blockName );
|
|
62
|
+
const settings = useSettingsForBlockElement( rawSettings, blockName );
|
|
63
63
|
const hasTypographyPanel = useHasTypographyPanel( settings );
|
|
64
64
|
const hasColorPanel = useHasColorPanel( settings );
|
|
65
65
|
const hasBorderPanel = useHasBorderPanel( settings );
|
|
66
66
|
const hasDimensionsPanel = useHasDimensionsPanel( settings );
|
|
67
67
|
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
68
|
-
const hasVariationsPanel = useHasVariationsPanel(
|
|
69
|
-
const
|
|
68
|
+
const hasVariationsPanel = useHasVariationsPanel( blockName );
|
|
69
|
+
const hasGlobalStyles =
|
|
70
70
|
hasTypographyPanel ||
|
|
71
71
|
hasColorPanel ||
|
|
72
72
|
hasLayoutPanel ||
|
|
73
73
|
hasVariationsPanel;
|
|
74
|
+
return hasGlobalStyles;
|
|
75
|
+
}
|
|
74
76
|
|
|
77
|
+
function BlockMenuItem( { block } ) {
|
|
78
|
+
const hasBlockMenuItem = useBlockHasGlobalStyles( block.name );
|
|
75
79
|
if ( ! hasBlockMenuItem ) {
|
|
76
80
|
return null;
|
|
77
81
|
}
|
|
@@ -38,7 +38,7 @@ function ScreenCSS( { name } ) {
|
|
|
38
38
|
<>
|
|
39
39
|
{ description }
|
|
40
40
|
<ExternalLink
|
|
41
|
-
href="https://wordpress.org/
|
|
41
|
+
href="https://wordpress.org/documentation/article/css/"
|
|
42
42
|
className="edit-site-global-styles-screen-css-help-link"
|
|
43
43
|
>
|
|
44
44
|
{ __( 'Learn more about CSS' ) }
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -9,17 +10,23 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
10
|
import ScreenHeader from './header';
|
|
10
11
|
import BlockPreviewPanel from './block-preview-panel';
|
|
11
12
|
import { getVariationClassName } from './utils';
|
|
12
|
-
import
|
|
13
|
+
import { unlock } from '../../private-apis';
|
|
14
|
+
import EffectsPanel from './effects-panel';
|
|
15
|
+
|
|
16
|
+
const { useGlobalSetting, useSettingsForBlockElement, useHasEffectsPanel } =
|
|
17
|
+
unlock( blockEditorPrivateApis );
|
|
13
18
|
|
|
14
19
|
function ScreenEffects( { name, variation = '' } ) {
|
|
20
|
+
const [ rawSettings ] = useGlobalSetting( '', name );
|
|
21
|
+
const settings = useSettingsForBlockElement( rawSettings, name );
|
|
15
22
|
const variationClassName = getVariationClassName( variation );
|
|
16
|
-
const
|
|
23
|
+
const hasEffectsPanel = useHasEffectsPanel( settings );
|
|
17
24
|
return (
|
|
18
25
|
<>
|
|
19
|
-
<ScreenHeader title={ __( '
|
|
26
|
+
<ScreenHeader title={ __( 'Effects' ) } />
|
|
20
27
|
<BlockPreviewPanel name={ name } variation={ variationClassName } />
|
|
21
|
-
{
|
|
22
|
-
<
|
|
28
|
+
{ hasEffectsPanel && (
|
|
29
|
+
<EffectsPanel name={ name } variation={ variation } />
|
|
23
30
|
) }
|
|
24
31
|
</>
|
|
25
32
|
);
|
|
@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import FiltersPanel from './filters-panel';
|
|
10
10
|
import BlockPreviewPanel from './block-preview-panel';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -19,7 +19,7 @@ function ScreenFilters( { name } ) {
|
|
|
19
19
|
<>
|
|
20
20
|
<ScreenHeader title={ __( 'Filters' ) } />
|
|
21
21
|
<BlockPreviewPanel name={ name } />
|
|
22
|
-
<
|
|
22
|
+
<FiltersPanel name={ name } />
|
|
23
23
|
</>
|
|
24
24
|
);
|
|
25
25
|
}
|