@wordpress/edit-site 5.8.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 +2 -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-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 +50 -4
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +6 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -18
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/ui.js +7 -14
- 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/layout/index.js +9 -7
- 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/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/site-hub/index.js +38 -16
- 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/hooks/commands/use-navigation-commands.js +9 -0
- package/build/hooks/commands/use-navigation-commands.js.map +1 -1
- package/build/hooks/commands/use-wp-admin-commands.js +4 -1
- package/build/hooks/commands/use-wp-admin-commands.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-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-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 +51 -4
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +6 -1
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +5 -19
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/ui.js +6 -14
- 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/layout/index.js +8 -7
- 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/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/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/hooks/commands/use-navigation-commands.js +8 -0
- package/build-module/hooks/commands/use-navigation-commands.js.map +1 -1
- package/build-module/hooks/commands/use-wp-admin-commands.js +3 -1
- package/build-module/hooks/commands/use-wp-admin-commands.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-style/style-rtl.css +113 -61
- package/build-style/style.css +113 -61
- package/package.json +34 -34
- package/src/components/add-new-template/new-template.js +3 -0
- package/src/components/block-editor/index.js +8 -8
- 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 +43 -2
- package/src/components/global-styles/filters-panel.js +7 -1
- package/src/components/global-styles/global-styles-provider.js +4 -18
- package/src/components/global-styles/ui.js +10 -6
- package/src/components/header-edit-mode/index.js +14 -5
- package/src/components/layout/index.js +9 -16
- package/src/components/layout/style.scss +31 -4
- package/src/components/list/table.js +16 -2
- package/src/components/secondary-sidebar/style.scss +23 -5
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +36 -17
- package/src/components/site-hub/index.js +50 -22
- 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 +12 -30
- 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/hooks/commands/use-navigation-commands.js +9 -0
- package/src/hooks/commands/use-wp-admin-commands.js +3 -1
- 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/style.scss +1 -0
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import { FlexItem, FlexBlock, Flex, Button } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { styles, seen } from '@wordpress/icons';
|
|
7
|
-
import { useSelect } from '@wordpress/data';
|
|
8
|
-
|
|
9
|
-
import {
|
|
7
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
+
import { useEffect } from '@wordpress/element';
|
|
9
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -15,19 +15,39 @@ import DefaultSidebar from './default-sidebar';
|
|
|
15
15
|
import { GlobalStylesUI } from '../global-styles';
|
|
16
16
|
import { store as editSiteStore } from '../../store';
|
|
17
17
|
import { GlobalStylesMenuSlot } from '../global-styles/ui';
|
|
18
|
+
import { unlock } from '../../private-apis';
|
|
18
19
|
|
|
19
20
|
export default function GlobalStylesSidebar() {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const { shouldClearCanvasContainerView, isStyleBookOpened } = useSelect(
|
|
22
|
+
( select ) => {
|
|
23
|
+
const { getActiveComplementaryArea } = select( interfaceStore );
|
|
24
|
+
const _isVisualEditorMode =
|
|
25
|
+
'visual' === select( editSiteStore ).getEditorMode();
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
isStyleBookOpened:
|
|
29
|
+
'style-book' ===
|
|
30
|
+
unlock(
|
|
31
|
+
select( editSiteStore )
|
|
32
|
+
).getEditorCanvasContainerView(),
|
|
33
|
+
shouldClearCanvasContainerView:
|
|
34
|
+
'edit-site/global-styles' !==
|
|
35
|
+
getActiveComplementaryArea( 'core/edit-site' ) ||
|
|
36
|
+
! _isVisualEditorMode,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
23
39
|
[]
|
|
24
40
|
);
|
|
25
41
|
|
|
42
|
+
const { setEditorCanvasContainerView } = unlock(
|
|
43
|
+
useDispatch( editSiteStore )
|
|
44
|
+
);
|
|
26
45
|
useEffect( () => {
|
|
27
|
-
if (
|
|
28
|
-
|
|
46
|
+
if ( shouldClearCanvasContainerView ) {
|
|
47
|
+
setEditorCanvasContainerView( undefined );
|
|
29
48
|
}
|
|
30
|
-
}, [
|
|
49
|
+
}, [ shouldClearCanvasContainerView ] );
|
|
50
|
+
|
|
31
51
|
return (
|
|
32
52
|
<DefaultSidebar
|
|
33
53
|
className="edit-site-global-styles-sidebar"
|
|
@@ -46,10 +66,12 @@ export default function GlobalStylesSidebar() {
|
|
|
46
66
|
icon={ seen }
|
|
47
67
|
label={ __( 'Style Book' ) }
|
|
48
68
|
isPressed={ isStyleBookOpened }
|
|
49
|
-
disabled={
|
|
50
|
-
onClick={ () =>
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
disabled={ shouldClearCanvasContainerView }
|
|
70
|
+
onClick={ () =>
|
|
71
|
+
setEditorCanvasContainerView(
|
|
72
|
+
isStyleBookOpened ? undefined : 'style-book'
|
|
73
|
+
)
|
|
74
|
+
}
|
|
53
75
|
/>
|
|
54
76
|
</FlexItem>
|
|
55
77
|
<FlexItem>
|
|
@@ -58,10 +80,7 @@ export default function GlobalStylesSidebar() {
|
|
|
58
80
|
</Flex>
|
|
59
81
|
}
|
|
60
82
|
>
|
|
61
|
-
<GlobalStylesUI
|
|
62
|
-
isStyleBookOpened={ isStyleBookOpened }
|
|
63
|
-
onCloseStyleBook={ () => setIsStyleBookOpened( false ) }
|
|
64
|
-
/>
|
|
83
|
+
<GlobalStylesUI />
|
|
65
84
|
</DefaultSidebar>
|
|
66
85
|
);
|
|
67
86
|
}
|
|
@@ -10,14 +10,15 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
10
10
|
import {
|
|
11
11
|
Button,
|
|
12
12
|
__unstableMotion as motion,
|
|
13
|
+
__unstableAnimatePresence as AnimatePresence,
|
|
13
14
|
__experimentalHStack as HStack,
|
|
14
15
|
} from '@wordpress/components';
|
|
15
16
|
import { useReducedMotion } from '@wordpress/compose';
|
|
16
17
|
import { __ } from '@wordpress/i18n';
|
|
17
18
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
18
19
|
import { store as coreStore } from '@wordpress/core-data';
|
|
19
|
-
import { forwardRef } from '@wordpress/element';
|
|
20
20
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
21
|
+
import { forwardRef } from '@wordpress/element';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Internal dependencies
|
|
@@ -29,7 +30,7 @@ import { unlock } from '../../private-apis';
|
|
|
29
30
|
const HUB_ANIMATION_DURATION = 0.3;
|
|
30
31
|
|
|
31
32
|
const SiteHub = forwardRef( ( props, ref ) => {
|
|
32
|
-
const { canvasMode
|
|
33
|
+
const { canvasMode } = useSelect( ( select ) => {
|
|
33
34
|
const { getCanvasMode, getSettings } = unlock(
|
|
34
35
|
select( editSiteStore )
|
|
35
36
|
);
|
|
@@ -41,20 +42,15 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
41
42
|
const disableMotion = useReducedMotion();
|
|
42
43
|
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
43
44
|
const { clearSelectedBlock } = useDispatch( blockEditorStore );
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onClick: () => {
|
|
54
|
-
clearSelectedBlock();
|
|
55
|
-
setCanvasMode( 'view' );
|
|
56
|
-
},
|
|
57
|
-
};
|
|
45
|
+
const siteIconButtonProps = {
|
|
46
|
+
label: __( 'Open Admin Sidebar' ),
|
|
47
|
+
onClick: () => {
|
|
48
|
+
if ( canvasMode === 'edit' ) {
|
|
49
|
+
clearSelectedBlock();
|
|
50
|
+
setCanvasMode( 'view' );
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
58
54
|
const siteTitle = useSelect(
|
|
59
55
|
( select ) =>
|
|
60
56
|
select( coreStore ).getEntityRecord( 'root', 'site' )?.title,
|
|
@@ -66,7 +62,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
66
62
|
ref={ ref }
|
|
67
63
|
{ ...props }
|
|
68
64
|
className={ classnames( 'edit-site-site-hub', props.className ) }
|
|
69
|
-
|
|
65
|
+
initial={ false }
|
|
70
66
|
transition={ {
|
|
71
67
|
type: 'tween',
|
|
72
68
|
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
@@ -91,15 +87,47 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
91
87
|
{ ...siteIconButtonProps }
|
|
92
88
|
className="edit-site-layout__view-mode-toggle"
|
|
93
89
|
>
|
|
94
|
-
<
|
|
90
|
+
<motion.div
|
|
91
|
+
initial={ false }
|
|
92
|
+
animate={ {
|
|
93
|
+
scale: canvasMode === 'view' ? 0.5 : 1,
|
|
94
|
+
} }
|
|
95
|
+
whileHover={ {
|
|
96
|
+
scale: canvasMode === 'view' ? 0.5 : 0.96,
|
|
97
|
+
} }
|
|
98
|
+
transition={ {
|
|
99
|
+
type: 'tween',
|
|
100
|
+
duration: disableMotion
|
|
101
|
+
? 0
|
|
102
|
+
: HUB_ANIMATION_DURATION,
|
|
103
|
+
ease: 'easeOut',
|
|
104
|
+
} }
|
|
105
|
+
>
|
|
106
|
+
<SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
|
|
107
|
+
</motion.div>
|
|
95
108
|
</Button>
|
|
96
109
|
</motion.div>
|
|
97
110
|
|
|
98
|
-
|
|
99
|
-
<div
|
|
111
|
+
<AnimatePresence>
|
|
112
|
+
<motion.div
|
|
113
|
+
layout={ canvasMode === 'edit' }
|
|
114
|
+
animate={ {
|
|
115
|
+
opacity: canvasMode === 'view' ? 1 : 0,
|
|
116
|
+
} }
|
|
117
|
+
exit={ {
|
|
118
|
+
opacity: 0,
|
|
119
|
+
} }
|
|
120
|
+
className="edit-site-site-hub__site-title"
|
|
121
|
+
transition={ {
|
|
122
|
+
type: 'tween',
|
|
123
|
+
duration: disableMotion ? 0 : 0.2,
|
|
124
|
+
ease: 'easeOut',
|
|
125
|
+
delay: canvasMode === 'view' ? 0.1 : 0,
|
|
126
|
+
} }
|
|
127
|
+
>
|
|
100
128
|
{ decodeEntities( siteTitle ) }
|
|
101
|
-
</div>
|
|
102
|
-
|
|
129
|
+
</motion.div>
|
|
130
|
+
</AnimatePresence>
|
|
103
131
|
</HStack>
|
|
104
132
|
</motion.div>
|
|
105
133
|
);
|
|
@@ -14,22 +14,17 @@ import { store as coreDataStore } from '@wordpress/core-data';
|
|
|
14
14
|
|
|
15
15
|
function SiteIcon( { className } ) {
|
|
16
16
|
const { isRequestingSite, siteIconUrl } = useSelect( ( select ) => {
|
|
17
|
-
const { getEntityRecord
|
|
18
|
-
const siteData =
|
|
19
|
-
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
17
|
+
const { getEntityRecord } = select( coreDataStore );
|
|
18
|
+
const siteData = getEntityRecord( 'root', '__unstableBase', undefined );
|
|
20
19
|
|
|
21
20
|
return {
|
|
22
|
-
isRequestingSite:
|
|
23
|
-
|
|
24
|
-
'__unstableBase',
|
|
25
|
-
undefined,
|
|
26
|
-
] ),
|
|
27
|
-
siteIconUrl: siteData.site_icon_url,
|
|
21
|
+
isRequestingSite: ! siteData,
|
|
22
|
+
siteIconUrl: siteData?.site_icon_url,
|
|
28
23
|
};
|
|
29
24
|
}, [] );
|
|
30
25
|
|
|
31
26
|
if ( isRequestingSite && ! siteIconUrl ) {
|
|
32
|
-
return
|
|
27
|
+
return <div className="edit-site-site-icon__image" />;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
const icon = siteIconUrl ? (
|
|
@@ -41,7 +36,7 @@ function SiteIcon( { className } ) {
|
|
|
41
36
|
) : (
|
|
42
37
|
<Icon
|
|
43
38
|
className="edit-site-site-icon__icon"
|
|
44
|
-
size="
|
|
39
|
+
size="48px"
|
|
45
40
|
icon={ wordpress }
|
|
46
41
|
/>
|
|
47
42
|
);
|
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
.edit-site-site-icon__image {
|
|
6
|
-
width:
|
|
7
|
-
height:
|
|
8
|
-
border-radius: $radius-block-ui;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: auto;
|
|
8
|
+
border-radius: $radius-block-ui * 2;
|
|
9
9
|
object-fit: cover;
|
|
10
|
+
background: #333;
|
|
11
|
+
|
|
12
|
+
.edit-site-layout.is-full-canvas.is-edit-mode & {
|
|
13
|
+
border-radius: 0;
|
|
14
|
+
}
|
|
10
15
|
}
|
|
@@ -32,7 +32,7 @@ function useFallbackTemplateContent( slug, isCustom = false ) {
|
|
|
32
32
|
ignore_empty: true,
|
|
33
33
|
} ),
|
|
34
34
|
} ).then( ( { content } ) => setTemplateContent( content.raw ) );
|
|
35
|
-
}, [ slug ] );
|
|
35
|
+
}, [ isCustom, slug ] );
|
|
36
36
|
return templateContent;
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -121,6 +121,7 @@ function StartModal( { slug, isCustom, onClose, postType } ) {
|
|
|
121
121
|
closeLabel={ __( 'Cancel' ) }
|
|
122
122
|
focusOnMount="firstElement"
|
|
123
123
|
onRequestClose={ onClose }
|
|
124
|
+
isFullScreen={ true }
|
|
124
125
|
>
|
|
125
126
|
<div className="edit-site-start-template-options__modal-content">
|
|
126
127
|
<PatternSelection
|
|
@@ -146,28 +147,28 @@ export default function StartTemplateOptions() {
|
|
|
146
147
|
const [ modalState, setModalState ] = useState(
|
|
147
148
|
START_TEMPLATE_MODAL_STATES.INITIAL
|
|
148
149
|
);
|
|
149
|
-
const {
|
|
150
|
+
const { shouldOpenModal, slug, isCustom, postType } = useSelect(
|
|
150
151
|
( select ) => {
|
|
151
152
|
const { getEditedPostType, getEditedPostId } =
|
|
152
153
|
select( editSiteStore );
|
|
153
154
|
const _postType = getEditedPostType();
|
|
154
155
|
const postId = getEditedPostId();
|
|
155
|
-
const {
|
|
156
|
-
|
|
157
|
-
getEditedEntityRecord,
|
|
158
|
-
} = select( coreStore );
|
|
156
|
+
const { getEditedEntityRecord, hasEditsForEntityRecord } =
|
|
157
|
+
select( coreStore );
|
|
159
158
|
const templateRecord = getEditedEntityRecord(
|
|
160
159
|
'postType',
|
|
161
160
|
_postType,
|
|
162
161
|
postId
|
|
163
162
|
);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
const hasEdits = hasEditsForEntityRecord(
|
|
164
|
+
'postType',
|
|
165
|
+
_postType,
|
|
166
|
+
postId
|
|
167
|
+
);
|
|
167
168
|
|
|
168
169
|
return {
|
|
169
|
-
|
|
170
|
-
!
|
|
170
|
+
shouldOpenModal:
|
|
171
|
+
! hasEdits &&
|
|
171
172
|
'' === templateRecord.content &&
|
|
172
173
|
'wp_template' === _postType &&
|
|
173
174
|
! select( preferencesStore ).get(
|
|
@@ -184,7 +185,7 @@ export default function StartTemplateOptions() {
|
|
|
184
185
|
|
|
185
186
|
if (
|
|
186
187
|
( modalState === START_TEMPLATE_MODAL_STATES.INITIAL &&
|
|
187
|
-
!
|
|
188
|
+
! shouldOpenModal ) ||
|
|
188
189
|
modalState === START_TEMPLATE_MODAL_STATES.CLOSED
|
|
189
190
|
) {
|
|
190
191
|
return null;
|
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
.edit-site-start-template-options__modal.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
.edit-site-start-template-options__modal-content .block-editor-block-patterns-list {
|
|
2
|
+
column-count: 2;
|
|
3
|
+
column-gap: $grid-unit-30;
|
|
4
|
+
|
|
5
|
+
// Small top padding required to avoid cutting off the visible outline when hovering items
|
|
6
|
+
padding-top: $border-width-focus;
|
|
7
|
+
|
|
8
8
|
@include break-medium() {
|
|
9
|
-
|
|
9
|
+
column-count: 3;
|
|
10
10
|
}
|
|
11
|
-
@include break-large() {
|
|
12
|
-
height: fit-content;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
margin-top: $grid-unit-05;
|
|
20
|
-
gap: $grid-unit-30;
|
|
21
|
-
grid-template-columns: repeat(auto-fit, minmax(min(100%/2, max(240px, 100%/10)), 1fr));
|
|
12
|
+
@include break-wide() {
|
|
13
|
+
column-count: 4;
|
|
14
|
+
}
|
|
22
15
|
|
|
23
16
|
.block-editor-block-patterns-list__list-item {
|
|
24
17
|
break-inside: avoid-column;
|
|
25
|
-
margin-bottom: 0;
|
|
26
|
-
width: 100%;
|
|
27
|
-
aspect-ratio: 3/4;
|
|
28
|
-
|
|
29
|
-
.block-editor-block-preview__container {
|
|
30
|
-
height: 100%;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.block-editor-block-preview__content {
|
|
34
|
-
width: 100%;
|
|
35
|
-
position: absolute;
|
|
36
|
-
}
|
|
37
18
|
|
|
38
19
|
.block-editor-block-patterns-list__item-title {
|
|
39
20
|
display: none;
|
|
@@ -54,6 +35,7 @@
|
|
|
54
35
|
position: absolute;
|
|
55
36
|
padding: 0;
|
|
56
37
|
background: #f0f0f0;
|
|
38
|
+
min-height: $grid-unit-50 * 4;
|
|
57
39
|
&::after {
|
|
58
40
|
width: 100%;
|
|
59
41
|
top: 50%;
|
|
@@ -7,14 +7,11 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
-
Button,
|
|
11
10
|
__unstableComposite as Composite,
|
|
12
11
|
__unstableUseCompositeState as useCompositeState,
|
|
13
12
|
__unstableCompositeItem as CompositeItem,
|
|
14
13
|
Disabled,
|
|
15
14
|
TabPanel,
|
|
16
|
-
createSlotFill,
|
|
17
|
-
__experimentalUseSlotFills as useSlotFills,
|
|
18
15
|
} from '@wordpress/components';
|
|
19
16
|
import { __, sprintf } from '@wordpress/i18n';
|
|
20
17
|
import {
|
|
@@ -31,29 +28,19 @@ import {
|
|
|
31
28
|
__unstableIframe as Iframe,
|
|
32
29
|
} from '@wordpress/block-editor';
|
|
33
30
|
import { useSelect } from '@wordpress/data';
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
useResizeObserver,
|
|
37
|
-
useFocusOnMount,
|
|
38
|
-
useFocusReturn,
|
|
39
|
-
useMergeRefs,
|
|
40
|
-
} from '@wordpress/compose';
|
|
31
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
41
32
|
import { useMemo, memo } from '@wordpress/element';
|
|
42
|
-
import { ESCAPE } from '@wordpress/keycodes';
|
|
43
33
|
|
|
44
34
|
/**
|
|
45
35
|
* Internal dependencies
|
|
46
36
|
*/
|
|
47
37
|
import { unlock } from '../../private-apis';
|
|
38
|
+
import EditorCanvasContainer from '../editor-canvas-container';
|
|
48
39
|
|
|
49
40
|
const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
|
|
50
41
|
blockEditorPrivateApis
|
|
51
42
|
);
|
|
52
43
|
|
|
53
|
-
const SLOT_FILL_NAME = 'EditSiteStyleBook';
|
|
54
|
-
const { Slot: StyleBookSlot, Fill: StyleBookFill } =
|
|
55
|
-
createSlotFill( SLOT_FILL_NAME );
|
|
56
|
-
|
|
57
44
|
// The content area of the Style Book is rendered within an iframe so that global styles
|
|
58
45
|
// are applied to elements within the entire content area. To support elements that are
|
|
59
46
|
// not part of the block previews, such as headings and layout for the block previews,
|
|
@@ -174,11 +161,8 @@ function getExamples() {
|
|
|
174
161
|
return [ headingsExample, ...otherExamples ];
|
|
175
162
|
}
|
|
176
163
|
|
|
177
|
-
function StyleBook( { isSelected, onSelect
|
|
164
|
+
function StyleBook( { isSelected, onSelect } ) {
|
|
178
165
|
const [ resizeObserver, sizes ] = useResizeObserver();
|
|
179
|
-
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
180
|
-
const sectionFocusReturnRef = useFocusReturn();
|
|
181
|
-
|
|
182
166
|
const [ textColor ] = useGlobalStyle( 'color.text' );
|
|
183
167
|
const [ backgroundColor ] = useGlobalStyle( 'color.background' );
|
|
184
168
|
const examples = useMemo( getExamples, [] );
|
|
@@ -207,17 +191,9 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
207
191
|
[ originalSettings ]
|
|
208
192
|
);
|
|
209
193
|
|
|
210
|
-
function closeOnEscape( event ) {
|
|
211
|
-
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
212
|
-
event.preventDefault();
|
|
213
|
-
onClose();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
194
|
return (
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
<section
|
|
195
|
+
<EditorCanvasContainer closeButtonLabel={ __( 'Close Style Book' ) }>
|
|
196
|
+
<div
|
|
221
197
|
className={ classnames( 'edit-site-style-book', {
|
|
222
198
|
'is-wide': sizes.width > 600,
|
|
223
199
|
} ) }
|
|
@@ -225,21 +201,8 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
225
201
|
color: textColor,
|
|
226
202
|
background: backgroundColor,
|
|
227
203
|
} }
|
|
228
|
-
aria-label={ __( 'Style Book' ) }
|
|
229
|
-
onKeyDown={ closeOnEscape }
|
|
230
|
-
ref={ useMergeRefs( [
|
|
231
|
-
sectionFocusReturnRef,
|
|
232
|
-
focusOnMountRef,
|
|
233
|
-
] ) }
|
|
234
204
|
>
|
|
235
205
|
{ resizeObserver }
|
|
236
|
-
<Button
|
|
237
|
-
className="edit-site-style-book__close-button"
|
|
238
|
-
icon={ closeSmall }
|
|
239
|
-
label={ __( 'Close Style Book' ) }
|
|
240
|
-
onClick={ onClose }
|
|
241
|
-
showTooltip={ false }
|
|
242
|
-
/>
|
|
243
206
|
<TabPanel
|
|
244
207
|
className="edit-site-style-book__tab-panel"
|
|
245
208
|
tabs={ tabs }
|
|
@@ -282,8 +245,8 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
282
245
|
</Iframe>
|
|
283
246
|
) }
|
|
284
247
|
</TabPanel>
|
|
285
|
-
</
|
|
286
|
-
</
|
|
248
|
+
</div>
|
|
249
|
+
</EditorCanvasContainer>
|
|
287
250
|
);
|
|
288
251
|
}
|
|
289
252
|
|
|
@@ -365,11 +328,4 @@ const Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {
|
|
|
365
328
|
);
|
|
366
329
|
};
|
|
367
330
|
|
|
368
|
-
function useHasStyleBook() {
|
|
369
|
-
const fills = useSlotFills( SLOT_FILL_NAME );
|
|
370
|
-
return !! fills?.length;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
StyleBook.Slot = StyleBookSlot;
|
|
374
331
|
export default StyleBook;
|
|
375
|
-
export { useHasStyleBook };
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
.edit-site-style-book {
|
|
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-style-book__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
|
-
}
|
|
18
|
-
|
|
19
1
|
.edit-site-style-book__tab-panel {
|
|
20
2
|
.components-tab-panel__tabs {
|
|
21
3
|
background: $white;
|
|
@@ -14,16 +14,17 @@ import { store as editSiteStore } from '../../store';
|
|
|
14
14
|
export default function useInitEditedEntityFromURL() {
|
|
15
15
|
const { params: { postId, postType } = {} } = useLocation();
|
|
16
16
|
const { isRequestingSite, homepageId, url } = useSelect( ( select ) => {
|
|
17
|
-
const { getSite } = select( coreDataStore );
|
|
17
|
+
const { getSite, getUnstableBase } = select( coreDataStore );
|
|
18
18
|
const siteData = getSite();
|
|
19
|
+
const base = getUnstableBase();
|
|
19
20
|
|
|
20
21
|
return {
|
|
21
|
-
isRequestingSite: !
|
|
22
|
+
isRequestingSite: ! base,
|
|
22
23
|
homepageId:
|
|
23
24
|
siteData?.show_on_front === 'page'
|
|
24
25
|
? siteData.page_on_front
|
|
25
26
|
: null,
|
|
26
|
-
url:
|
|
27
|
+
url: base?.home,
|
|
27
28
|
};
|
|
28
29
|
}, [] );
|
|
29
30
|
|
|
@@ -102,6 +102,7 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
102
102
|
<Button
|
|
103
103
|
className="edit-site-template-details__show-all-button"
|
|
104
104
|
{ ...browseAllLinkProps }
|
|
105
|
+
onClick={ () => onClose() }
|
|
105
106
|
>
|
|
106
107
|
{ template?.type === 'wp_template'
|
|
107
108
|
? __( 'Manage all templates' )
|
|
@@ -6,6 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
import { useMemo } from '@wordpress/element';
|
|
7
7
|
import { useSelect } from '@wordpress/data';
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
+
import { post, page, layout, symbolFilled } from '@wordpress/icons';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -16,6 +17,13 @@ import { useHistory } from '../../components/routes';
|
|
|
16
17
|
|
|
17
18
|
const { useCommandLoader } = unlock( privateApis );
|
|
18
19
|
|
|
20
|
+
const icons = {
|
|
21
|
+
post,
|
|
22
|
+
page,
|
|
23
|
+
wp_template: layout,
|
|
24
|
+
wp_template_part: symbolFilled,
|
|
25
|
+
};
|
|
26
|
+
|
|
19
27
|
const getNavigationCommandLoaderPerPostType = ( postType ) =>
|
|
20
28
|
function useNavigationCommandLoader( { search } ) {
|
|
21
29
|
const supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(
|
|
@@ -51,6 +59,7 @@ const getNavigationCommandLoaderPerPostType = ( postType ) =>
|
|
|
51
59
|
label: record.title?.rendered
|
|
52
60
|
? record.title?.rendered
|
|
53
61
|
: __( '(no title)' ),
|
|
62
|
+
icon: icons[ postType ],
|
|
54
63
|
callback: ( { close } ) => {
|
|
55
64
|
history.push( {
|
|
56
65
|
postType,
|
|
@@ -6,6 +6,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import { addQueryArgs } from '@wordpress/url';
|
|
8
8
|
import { useMemo } from '@wordpress/element';
|
|
9
|
+
import { plus } from '@wordpress/icons';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -43,8 +44,9 @@ const getWPAdminAddCommandLoader = ( postType ) =>
|
|
|
43
44
|
const commands = useMemo(
|
|
44
45
|
() => [
|
|
45
46
|
{
|
|
46
|
-
name: 'core/wp-admin/add-' + postType,
|
|
47
|
+
name: 'core/wp-admin/add-' + postType + '-' + search,
|
|
47
48
|
label,
|
|
49
|
+
icon: plus,
|
|
48
50
|
callback: () => {
|
|
49
51
|
document.location.href = addQueryArgs( newPostLink, {
|
|
50
52
|
post_type: postType,
|
|
@@ -27,3 +27,17 @@ export const setCanvasMode =
|
|
|
27
27
|
dispatch.setIsListViewOpened( true );
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Action that switches the editor canvas container view.
|
|
33
|
+
*
|
|
34
|
+
* @param {?string} view Editor canvas container view.
|
|
35
|
+
*/
|
|
36
|
+
export const setEditorCanvasContainerView =
|
|
37
|
+
( view ) =>
|
|
38
|
+
( { dispatch } ) => {
|
|
39
|
+
dispatch( {
|
|
40
|
+
type: 'SET_EDITOR_CANVAS_CONTAINER_VIEW',
|
|
41
|
+
view,
|
|
42
|
+
} );
|
|
43
|
+
};
|
|
@@ -8,3 +8,14 @@
|
|
|
8
8
|
export function getCanvasMode( state ) {
|
|
9
9
|
return state.canvasMode;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns the editor canvas container view.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} state Global application state.
|
|
16
|
+
*
|
|
17
|
+
* @return {string} Editor canvas container view.
|
|
18
|
+
*/
|
|
19
|
+
export function getEditorCanvasContainerView( state ) {
|
|
20
|
+
return state.editorCanvasContainerView;
|
|
21
|
+
}
|
package/src/store/reducer.js
CHANGED
|
@@ -140,6 +140,23 @@ function canvasMode( state = 'init', action ) {
|
|
|
140
140
|
return state;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Reducer used to track the site editor canvas container view.
|
|
145
|
+
* Default is `undefined`, denoting the default, visual block editor.
|
|
146
|
+
* This could be, for example, `'style-book'` (the style book).
|
|
147
|
+
*
|
|
148
|
+
* @param {string|undefined} state Current state.
|
|
149
|
+
* @param {Object} action Dispatched action.
|
|
150
|
+
*/
|
|
151
|
+
function editorCanvasContainerView( state = undefined, action ) {
|
|
152
|
+
switch ( action.type ) {
|
|
153
|
+
case 'SET_EDITOR_CANVAS_CONTAINER_VIEW':
|
|
154
|
+
return action.view;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return state;
|
|
158
|
+
}
|
|
159
|
+
|
|
143
160
|
export default combineReducers( {
|
|
144
161
|
deviceType,
|
|
145
162
|
settings,
|
|
@@ -148,4 +165,5 @@ export default combineReducers( {
|
|
|
148
165
|
listViewPanel,
|
|
149
166
|
saveViewPanel,
|
|
150
167
|
canvasMode,
|
|
168
|
+
editorCanvasContainerView,
|
|
151
169
|
} );
|
package/src/style.scss
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
@import "./components/sidebar-navigation-screen-navigation-menus/style.scss";
|
|
32
32
|
@import "./components/site-icon/style.scss";
|
|
33
33
|
@import "./components/style-book/style.scss";
|
|
34
|
+
@import "./components/editor-canvas-container/style.scss";
|
|
34
35
|
@import "./hooks/push-changes-to-global-styles/style.scss";
|
|
35
36
|
|
|
36
37
|
html #wpadminbar {
|