@wordpress/edit-site 5.3.5 → 5.3.7
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/build/components/add-new-template/add-custom-template-modal.js +12 -3
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +5 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +2 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +3 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +1 -1
- package/build/components/global-styles/screen-variations.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +6 -4
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build/components/keyboard-shortcuts/global.js +48 -0
- package/build/components/keyboard-shortcuts/global.js.map +1 -0
- package/build/components/keyboard-shortcuts/register.js +153 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -0
- package/build/components/layout/index.js +11 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +41 -42
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +3 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/routes/link.js +4 -1
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-hub/index.js +82 -0
- package/build/components/save-hub/index.js.map +1 -0
- package/build/components/sidebar/index.js +14 -4
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +30 -0
- package/build/components/sidebar-button/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen/index.js +11 -5
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +18 -18
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +139 -11
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-template/index.js +25 -8
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +22 -5
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/style-book/index.js +17 -2
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +29 -29
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +5 -10
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -6
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/index.js +13 -22
- package/build/index.js.map +1 -1
- package/build/utils/history.js +8 -2
- package/build/utils/history.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +5 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +2 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +3 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +1 -1
- package/build-module/components/global-styles/screen-variations.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +6 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/global.js +37 -0
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/register.js +141 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
- package/build-module/components/layout/index.js +9 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +43 -44
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/index.js +2 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +3 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/routes/link.js +5 -2
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-hub/index.js +68 -0
- package/build-module/components/save-hub/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +10 -5
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +18 -0
- package/build-module/components/sidebar-button/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen/index.js +9 -6
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +20 -22
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +131 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js +25 -10
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +19 -5
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/style-book/index.js +17 -3
- 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 +7 -7
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +27 -29
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +5 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +6 -6
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/index.js +16 -23
- package/build-module/index.js.map +1 -1
- package/build-module/utils/history.js +9 -3
- package/build-module/utils/history.js.map +1 -1
- package/build-style/style-rtl.css +100 -94
- package/build-style/style.css +100 -94
- package/package.json +10 -10
- package/src/components/add-new-template/add-custom-template-modal.js +14 -10
- package/src/components/add-new-template/new-template-part.js +4 -3
- package/src/components/add-new-template/style.scss +0 -5
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/block-editor/style.scss +1 -1
- package/src/components/editor/index.js +4 -3
- package/src/components/global-styles/screen-variations.js +0 -1
- package/src/components/global-styles/shadow-panel.js +4 -3
- package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
- package/src/components/keyboard-shortcuts/global.js +35 -0
- package/src/components/keyboard-shortcuts/register.js +157 -0
- package/src/components/layout/index.js +18 -0
- package/src/components/layout/style.scss +1 -3
- package/src/components/list/added-by.js +48 -55
- package/src/components/list/index.js +3 -1
- package/src/components/list/style.scss +5 -13
- package/src/components/list/table.js +4 -1
- package/src/components/routes/link.js +9 -2
- package/src/components/save-hub/index.js +78 -0
- package/src/components/save-hub/style.scss +15 -0
- package/src/components/sidebar/index.js +11 -6
- package/src/components/sidebar/style.scss +4 -3
- package/src/components/sidebar-button/index.js +21 -0
- package/src/components/sidebar-button/style.scss +24 -0
- package/src/components/sidebar-navigation-item/style.scss +0 -20
- package/src/components/sidebar-navigation-screen/index.js +9 -4
- package/src/components/sidebar-navigation-screen/style.scss +16 -10
- package/src/components/sidebar-navigation-screen-main/index.js +3 -0
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +33 -26
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +141 -10
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +55 -4
- package/src/components/sidebar-navigation-screen-template/index.js +27 -13
- package/src/components/sidebar-navigation-screen-templates/index.js +23 -4
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
- package/src/components/style-book/index.js +25 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -9
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +34 -35
- package/src/components/template-details/index.js +4 -8
- package/src/components/use-edited-entity-record/index.js +26 -18
- package/src/index.js +11 -22
- package/src/style.scss +2 -1
- package/src/utils/history.js +13 -9
- package/build/components/navigation-inspector/index.js +0 -190
- package/build/components/navigation-inspector/index.js.map +0 -1
- package/build/components/navigation-inspector/navigation-menu.js +0 -62
- package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/build-module/components/navigation-inspector/index.js +0 -173
- package/build-module/components/navigation-inspector/index.js.map +0 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
- package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/src/components/navigation-inspector/index.js +0 -223
- package/src/components/navigation-inspector/navigation-menu.js +0 -66
- package/src/components/navigation-inspector/style.scss +0 -46
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '@wordpress/components';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
11
12
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
13
|
import { useViewportMatch } from '@wordpress/compose';
|
|
13
14
|
|
|
@@ -18,6 +19,8 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
18
19
|
import { useLink } from '../routes/link';
|
|
19
20
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
20
21
|
import AddNewTemplate from '../add-new-template';
|
|
22
|
+
import { store as editSiteStore } from '../../store';
|
|
23
|
+
import SidebarButton from '../sidebar-button';
|
|
21
24
|
|
|
22
25
|
const config = {
|
|
23
26
|
wp_template: {
|
|
@@ -26,6 +29,9 @@ const config = {
|
|
|
26
29
|
loading: __( 'Loading templates' ),
|
|
27
30
|
notFound: __( 'No templates found' ),
|
|
28
31
|
manage: __( 'Manage all templates' ),
|
|
32
|
+
description: __(
|
|
33
|
+
'Express the layout of your site with templates.'
|
|
34
|
+
),
|
|
29
35
|
},
|
|
30
36
|
},
|
|
31
37
|
wp_template_part: {
|
|
@@ -34,6 +40,9 @@ const config = {
|
|
|
34
40
|
loading: __( 'Loading template parts' ),
|
|
35
41
|
notFound: __( 'No template parts found' ),
|
|
36
42
|
manage: __( 'Manage all template parts' ),
|
|
43
|
+
description: __(
|
|
44
|
+
'Template Parts are small pieces of a layout that can be reused across multiple templates and always appear the same way. Common template parts include the site header, footer, or sidebar.'
|
|
45
|
+
),
|
|
37
46
|
},
|
|
38
47
|
},
|
|
39
48
|
};
|
|
@@ -51,6 +60,11 @@ export default function SidebarNavigationScreenTemplates() {
|
|
|
51
60
|
params: { postType },
|
|
52
61
|
} = useNavigator();
|
|
53
62
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
63
|
+
const isTemplatePartsMode = useSelect( ( select ) => {
|
|
64
|
+
const settings = select( editSiteStore ).getSettings();
|
|
65
|
+
|
|
66
|
+
return !! settings.supportsTemplatePartsMode;
|
|
67
|
+
}, [] );
|
|
54
68
|
|
|
55
69
|
const { records: templates, isResolving: isLoading } = useEntityRecords(
|
|
56
70
|
'postType',
|
|
@@ -59,21 +73,26 @@ export default function SidebarNavigationScreenTemplates() {
|
|
|
59
73
|
per_page: -1,
|
|
60
74
|
}
|
|
61
75
|
);
|
|
76
|
+
const sortedTemplates = templates ? [ ...templates ] : [];
|
|
77
|
+
sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );
|
|
62
78
|
|
|
63
79
|
const browseAllLink = useLink( {
|
|
64
80
|
path: '/' + postType + '/all',
|
|
65
81
|
} );
|
|
66
82
|
|
|
83
|
+
const canCreate = ! isMobileViewport && ! isTemplatePartsMode;
|
|
84
|
+
|
|
67
85
|
return (
|
|
68
86
|
<SidebarNavigationScreen
|
|
87
|
+
isRoot={ isTemplatePartsMode }
|
|
69
88
|
title={ config[ postType ].labels.title }
|
|
89
|
+
description={ config[ postType ].labels.description }
|
|
70
90
|
actions={
|
|
71
|
-
|
|
91
|
+
canCreate && (
|
|
72
92
|
<AddNewTemplate
|
|
73
93
|
templateType={ postType }
|
|
74
94
|
toggleProps={ {
|
|
75
|
-
|
|
76
|
-
'edit-site-sidebar-navigation-screen-templates__add-button',
|
|
95
|
+
as: SidebarButton,
|
|
77
96
|
} }
|
|
78
97
|
/>
|
|
79
98
|
)
|
|
@@ -88,7 +107,7 @@ export default function SidebarNavigationScreenTemplates() {
|
|
|
88
107
|
{ config[ postType ].labels.notFound }
|
|
89
108
|
</Item>
|
|
90
109
|
) }
|
|
91
|
-
{
|
|
110
|
+
{ sortedTemplates.map( ( template ) => (
|
|
92
111
|
<TemplateItem
|
|
93
112
|
postType={ postType }
|
|
94
113
|
postId={ template.id }
|
|
@@ -12,9 +12,15 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
12
12
|
const config = {
|
|
13
13
|
wp_template: {
|
|
14
14
|
title: __( 'All templates' ),
|
|
15
|
+
description: __(
|
|
16
|
+
'Create new templates, or reset any customizations made to the templates supplied by your theme.'
|
|
17
|
+
),
|
|
15
18
|
},
|
|
16
19
|
wp_template_part: {
|
|
17
20
|
title: __( 'All template parts' ),
|
|
21
|
+
description: __(
|
|
22
|
+
'Create new template parts, or reset any customisations made to the template parts supplied by your theme.'
|
|
23
|
+
),
|
|
18
24
|
},
|
|
19
25
|
};
|
|
20
26
|
|
|
@@ -22,5 +28,10 @@ export default function SidebarNavigationScreenTemplatesBrowse() {
|
|
|
22
28
|
const {
|
|
23
29
|
params: { postType },
|
|
24
30
|
} = useNavigator();
|
|
25
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<SidebarNavigationScreen
|
|
33
|
+
title={ config[ postType ].title }
|
|
34
|
+
description={ config[ postType ].description }
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
26
37
|
}
|
|
@@ -24,8 +24,14 @@ import {
|
|
|
24
24
|
privateApis as blockEditorPrivateApis,
|
|
25
25
|
} from '@wordpress/block-editor';
|
|
26
26
|
import { closeSmall } from '@wordpress/icons';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
useResizeObserver,
|
|
29
|
+
useFocusOnMount,
|
|
30
|
+
useFocusReturn,
|
|
31
|
+
useMergeRefs,
|
|
32
|
+
} from '@wordpress/compose';
|
|
28
33
|
import { useMemo, memo } from '@wordpress/element';
|
|
34
|
+
import { ESCAPE } from '@wordpress/keycodes';
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
37
|
* Internal dependencies
|
|
@@ -90,6 +96,9 @@ function getExamples() {
|
|
|
90
96
|
|
|
91
97
|
function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
92
98
|
const [ resizeObserver, sizes ] = useResizeObserver();
|
|
99
|
+
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
100
|
+
const sectionFocusReturnRef = useFocusReturn();
|
|
101
|
+
|
|
93
102
|
const [ textColor ] = useGlobalStyle( 'color.text' );
|
|
94
103
|
const [ backgroundColor ] = useGlobalStyle( 'color.background' );
|
|
95
104
|
const examples = useMemo( getExamples, [] );
|
|
@@ -108,8 +117,17 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
108
117
|
} ) ),
|
|
109
118
|
[ examples ]
|
|
110
119
|
);
|
|
120
|
+
|
|
121
|
+
function closeOnEscape( event ) {
|
|
122
|
+
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
onClose();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
111
128
|
return (
|
|
112
129
|
<StyleBookFill>
|
|
130
|
+
{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
|
|
113
131
|
<section
|
|
114
132
|
className={ classnames( 'edit-site-style-book', {
|
|
115
133
|
'is-wide': sizes.width > 600,
|
|
@@ -119,6 +137,11 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
119
137
|
background: backgroundColor,
|
|
120
138
|
} }
|
|
121
139
|
aria-label={ __( 'Style Book' ) }
|
|
140
|
+
onKeyDown={ closeOnEscape }
|
|
141
|
+
ref={ useMergeRefs( [
|
|
142
|
+
sectionFocusReturnRef,
|
|
143
|
+
focusOnMountRef,
|
|
144
|
+
] ) }
|
|
122
145
|
>
|
|
123
146
|
{ resizeObserver }
|
|
124
147
|
<Button
|
|
@@ -126,6 +149,7 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
126
149
|
icon={ closeSmall }
|
|
127
150
|
label={ __( 'Close Style Book' ) }
|
|
128
151
|
onClick={ onClose }
|
|
152
|
+
showTooltip={ false }
|
|
129
153
|
/>
|
|
130
154
|
<TabPanel
|
|
131
155
|
className="edit-site-style-book__tab-panel"
|
|
@@ -13,7 +13,7 @@ import { store as editSiteStore } from '../../store';
|
|
|
13
13
|
|
|
14
14
|
export default function useInitEditedEntityFromURL() {
|
|
15
15
|
const { params: { postId, postType } = {} } = useLocation();
|
|
16
|
-
const { isRequestingSite, homepageId } = useSelect( ( select ) => {
|
|
16
|
+
const { isRequestingSite, homepageId, url } = useSelect( ( select ) => {
|
|
17
17
|
const { getSite } = select( coreDataStore );
|
|
18
18
|
const siteData = getSite();
|
|
19
19
|
|
|
@@ -23,6 +23,7 @@ export default function useInitEditedEntityFromURL() {
|
|
|
23
23
|
siteData?.show_on_front === 'page'
|
|
24
24
|
? siteData.page_on_front
|
|
25
25
|
: null,
|
|
26
|
+
url: siteData?.url,
|
|
26
27
|
};
|
|
27
28
|
}, [] );
|
|
28
29
|
|
|
@@ -30,13 +31,7 @@ export default function useInitEditedEntityFromURL() {
|
|
|
30
31
|
useDispatch( editSiteStore );
|
|
31
32
|
|
|
32
33
|
useEffect( () => {
|
|
33
|
-
if (
|
|
34
|
-
postType &&
|
|
35
|
-
postId &&
|
|
36
|
-
// This is just a special case to support old WP versions that perform redirects.
|
|
37
|
-
// This code should be removed when we minimum WP version becomes 6.2.
|
|
38
|
-
postId !== 'none'
|
|
39
|
-
) {
|
|
34
|
+
if ( postType && postId ) {
|
|
40
35
|
switch ( postType ) {
|
|
41
36
|
case 'wp_template':
|
|
42
37
|
setTemplate( postId );
|
|
@@ -60,10 +55,11 @@ export default function useInitEditedEntityFromURL() {
|
|
|
60
55
|
} );
|
|
61
56
|
} else if ( ! isRequestingSite ) {
|
|
62
57
|
setPage( {
|
|
63
|
-
path:
|
|
58
|
+
path: url,
|
|
64
59
|
} );
|
|
65
60
|
}
|
|
66
61
|
}, [
|
|
62
|
+
url,
|
|
67
63
|
postId,
|
|
68
64
|
postType,
|
|
69
65
|
homepageId,
|
|
@@ -20,22 +20,52 @@ export default function useSyncCanvasModeWithURL() {
|
|
|
20
20
|
);
|
|
21
21
|
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
22
22
|
const currentCanvasMode = useRef( canvasMode );
|
|
23
|
-
const { canvas: canvasInUrl
|
|
23
|
+
const { canvas: canvasInUrl } = params;
|
|
24
24
|
const currentCanvasInUrl = useRef( canvasInUrl );
|
|
25
|
+
const currentUrlParams = useRef( params );
|
|
26
|
+
useEffect( () => {
|
|
27
|
+
currentUrlParams.current = params;
|
|
28
|
+
}, [ params ] );
|
|
29
|
+
|
|
25
30
|
useEffect( () => {
|
|
26
31
|
currentCanvasMode.current = canvasMode;
|
|
27
|
-
if (
|
|
32
|
+
if ( canvasMode === 'init' ) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
canvasMode === 'edit' &&
|
|
38
|
+
currentCanvasInUrl.current !== canvasMode
|
|
39
|
+
) {
|
|
40
|
+
history.push( {
|
|
41
|
+
...currentUrlParams.current,
|
|
42
|
+
canvas: 'edit',
|
|
43
|
+
} );
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
canvasMode === 'view' &&
|
|
48
|
+
currentCanvasInUrl.current !== undefined
|
|
49
|
+
) {
|
|
28
50
|
history.push( {
|
|
29
|
-
...
|
|
30
|
-
canvas:
|
|
51
|
+
...currentUrlParams.current,
|
|
52
|
+
canvas: undefined,
|
|
31
53
|
} );
|
|
32
54
|
}
|
|
33
|
-
}, [ canvasMode ] );
|
|
55
|
+
}, [ canvasMode, history ] );
|
|
34
56
|
|
|
35
57
|
useEffect( () => {
|
|
36
58
|
currentCanvasInUrl.current = canvasInUrl;
|
|
37
|
-
if (
|
|
38
|
-
|
|
59
|
+
if (
|
|
60
|
+
canvasInUrl === undefined &&
|
|
61
|
+
currentCanvasMode.current !== 'view'
|
|
62
|
+
) {
|
|
63
|
+
setCanvasMode( 'view' );
|
|
64
|
+
} else if (
|
|
65
|
+
canvasInUrl === 'edit' &&
|
|
66
|
+
currentCanvasMode.current !== 'edit'
|
|
67
|
+
) {
|
|
68
|
+
setCanvasMode( 'edit' );
|
|
39
69
|
}
|
|
40
|
-
}, [ canvasInUrl ] );
|
|
70
|
+
}, [ canvasInUrl, setCanvasMode ] );
|
|
41
71
|
}
|
|
@@ -9,6 +9,28 @@ import { useEffect, useRef } from '@wordpress/element';
|
|
|
9
9
|
*/
|
|
10
10
|
import { useLocation, useHistory } from '../routes';
|
|
11
11
|
|
|
12
|
+
export function getPathFromURL( urlParams ) {
|
|
13
|
+
let path = urlParams?.path ?? '/';
|
|
14
|
+
|
|
15
|
+
// Compute the navigator path based on the URL params.
|
|
16
|
+
if ( urlParams?.postType && urlParams?.postId ) {
|
|
17
|
+
switch ( urlParams.postType ) {
|
|
18
|
+
case 'wp_template':
|
|
19
|
+
case 'wp_template_part':
|
|
20
|
+
path = `/${ encodeURIComponent(
|
|
21
|
+
urlParams.postType
|
|
22
|
+
) }/${ encodeURIComponent( urlParams.postId ) }`;
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
path = `/navigation/${ encodeURIComponent(
|
|
26
|
+
urlParams.postType
|
|
27
|
+
) }/${ encodeURIComponent( urlParams.postId ) }`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return path;
|
|
32
|
+
}
|
|
33
|
+
|
|
12
34
|
export default function useSyncPathWithURL() {
|
|
13
35
|
const history = useHistory();
|
|
14
36
|
const { params: urlParams } = useLocation();
|
|
@@ -18,13 +40,17 @@ export default function useSyncPathWithURL() {
|
|
|
18
40
|
goTo,
|
|
19
41
|
} = useNavigator();
|
|
20
42
|
const currentUrlParams = useRef( urlParams );
|
|
21
|
-
const currentPath = useRef();
|
|
43
|
+
const currentPath = useRef( navigatorLocation.path );
|
|
44
|
+
const isMounting = useRef( true );
|
|
22
45
|
|
|
23
46
|
useEffect( () => {
|
|
24
|
-
//
|
|
25
|
-
|
|
47
|
+
// The navigatorParams are only initially filled properly when the
|
|
48
|
+
// navigator screens mount. so we ignore the first synchronisation.
|
|
49
|
+
if ( isMounting.current ) {
|
|
50
|
+
isMounting.current = false;
|
|
26
51
|
return;
|
|
27
52
|
}
|
|
53
|
+
|
|
28
54
|
function updateUrlParams( newUrlParams ) {
|
|
29
55
|
if (
|
|
30
56
|
Object.entries( newUrlParams ).every( ( [ key, value ] ) => {
|
|
@@ -47,51 +73,24 @@ export default function useSyncPathWithURL() {
|
|
|
47
73
|
postId: navigatorParams?.postId,
|
|
48
74
|
path: undefined,
|
|
49
75
|
} );
|
|
50
|
-
} else if ( navigatorParams?.postType && ! navigatorParams?.postId ) {
|
|
51
|
-
updateUrlParams( {
|
|
52
|
-
postType: navigatorParams?.postType,
|
|
53
|
-
path: navigatorLocation.path,
|
|
54
|
-
postId: undefined,
|
|
55
|
-
} );
|
|
56
76
|
} else {
|
|
57
77
|
updateUrlParams( {
|
|
58
78
|
postType: undefined,
|
|
59
79
|
postId: undefined,
|
|
60
|
-
path:
|
|
80
|
+
path:
|
|
81
|
+
navigatorLocation.path === '/'
|
|
82
|
+
? undefined
|
|
83
|
+
: navigatorLocation.path,
|
|
61
84
|
} );
|
|
62
85
|
}
|
|
63
86
|
}, [ navigatorLocation?.path, navigatorParams, history ] );
|
|
64
87
|
|
|
65
88
|
useEffect( () => {
|
|
66
89
|
currentUrlParams.current = urlParams;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Compute the navigator path based on the URL params.
|
|
70
|
-
if (
|
|
71
|
-
urlParams?.postType &&
|
|
72
|
-
urlParams?.postId &&
|
|
73
|
-
// This is just a special case to support old WP versions that perform redirects.
|
|
74
|
-
// This code should be removed when we minimum WP version becomes 6.2.
|
|
75
|
-
urlParams?.postId !== 'none'
|
|
76
|
-
) {
|
|
77
|
-
switch ( urlParams.postType ) {
|
|
78
|
-
case 'wp_template':
|
|
79
|
-
case 'wp_template_part':
|
|
80
|
-
path = `/${ encodeURIComponent(
|
|
81
|
-
urlParams.postType
|
|
82
|
-
) }/${ encodeURIComponent( urlParams.postId ) }`;
|
|
83
|
-
break;
|
|
84
|
-
default:
|
|
85
|
-
path = `/navigation/${ encodeURIComponent(
|
|
86
|
-
urlParams.postType
|
|
87
|
-
) }/${ encodeURIComponent( urlParams.postId ) }`;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
90
|
+
const path = getPathFromURL( urlParams );
|
|
91
91
|
if ( currentPath.current !== path ) {
|
|
92
92
|
currentPath.current = path;
|
|
93
93
|
goTo( path );
|
|
94
94
|
}
|
|
95
|
-
goTo( path );
|
|
96
95
|
}, [ urlParams, goTo ] );
|
|
97
96
|
}
|
|
@@ -18,7 +18,6 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
18
18
|
*/
|
|
19
19
|
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
20
20
|
import { store as editSiteStore } from '../../store';
|
|
21
|
-
import TemplateAreas from './template-areas';
|
|
22
21
|
import EditTemplateTitle from './edit-template-title';
|
|
23
22
|
import { useLink } from '../routes/link';
|
|
24
23
|
import TemplatePartAreaSelector from './template-part-area-selector';
|
|
@@ -31,10 +30,9 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
31
30
|
);
|
|
32
31
|
const { revertTemplate } = useDispatch( editSiteStore );
|
|
33
32
|
|
|
33
|
+
// TODO: We should update this to filter by template part's areas as well.
|
|
34
34
|
const browseAllLinkProps = useLink( {
|
|
35
|
-
|
|
36
|
-
postType: template.type,
|
|
37
|
-
postId: undefined,
|
|
35
|
+
path: '/' + template.type + '/all',
|
|
38
36
|
} );
|
|
39
37
|
|
|
40
38
|
const isTemplatePart = template.type === 'wp_template_part';
|
|
@@ -87,8 +85,6 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
87
85
|
</div>
|
|
88
86
|
) }
|
|
89
87
|
|
|
90
|
-
<TemplateAreas closeTemplateDetailsDropdown={ onClose } />
|
|
91
|
-
|
|
92
88
|
{ isTemplateRevertable( template ) && (
|
|
93
89
|
<MenuGroup className="edit-site-template-details__group edit-site-template-details__revert">
|
|
94
90
|
<MenuItem
|
|
@@ -108,8 +104,8 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
108
104
|
{ ...browseAllLinkProps }
|
|
109
105
|
>
|
|
110
106
|
{ template?.type === 'wp_template'
|
|
111
|
-
? __( '
|
|
112
|
-
: __( '
|
|
107
|
+
? __( 'Manage all templates' )
|
|
108
|
+
: __( 'Manage all template parts' ) }
|
|
113
109
|
</Button>
|
|
114
110
|
</div>
|
|
115
111
|
);
|
|
@@ -11,25 +11,33 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
11
11
|
*/
|
|
12
12
|
import { store as editSiteStore } from '../../store';
|
|
13
13
|
|
|
14
|
-
export default function useEditedEntityRecord() {
|
|
15
|
-
const { record, title, description, isLoaded } = useSelect(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
select(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
export default function useEditedEntityRecord( postType, postId ) {
|
|
15
|
+
const { record, title, description, isLoaded } = useSelect(
|
|
16
|
+
( select ) => {
|
|
17
|
+
const { getEditedPostType, getEditedPostId } =
|
|
18
|
+
select( editSiteStore );
|
|
19
|
+
const { getEditedEntityRecord } = select( coreStore );
|
|
20
|
+
const { __experimentalGetTemplateInfo: getTemplateInfo } =
|
|
21
|
+
select( editorStore );
|
|
22
|
+
const usedPostType = postType ?? getEditedPostType();
|
|
23
|
+
const usedPostId = postId ?? getEditedPostId();
|
|
24
|
+
const _record = getEditedEntityRecord(
|
|
25
|
+
'postType',
|
|
26
|
+
usedPostType,
|
|
27
|
+
usedPostId
|
|
28
|
+
);
|
|
29
|
+
const _isLoaded = !! usedPostId;
|
|
30
|
+
const templateInfo = getTemplateInfo( _record );
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
return {
|
|
33
|
+
record: _record,
|
|
34
|
+
title: templateInfo.title,
|
|
35
|
+
description: templateInfo.description,
|
|
36
|
+
isLoaded: _isLoaded,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
[ postType, postId ]
|
|
40
|
+
);
|
|
33
41
|
|
|
34
42
|
return {
|
|
35
43
|
isLoaded,
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import {
|
|
6
6
|
registerCoreBlocks,
|
|
7
|
+
__experimentalGetCoreBlocks,
|
|
7
8
|
__experimentalRegisterExperimentalCoreBlocks,
|
|
8
9
|
} from '@wordpress/block-library';
|
|
9
10
|
import { dispatch } from '@wordpress/data';
|
|
@@ -16,8 +17,10 @@ import {
|
|
|
16
17
|
import { store as editorStore } from '@wordpress/editor';
|
|
17
18
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
18
19
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
19
|
-
import {
|
|
20
|
-
|
|
20
|
+
import {
|
|
21
|
+
registerLegacyWidgetBlock,
|
|
22
|
+
registerWidgetGroupBlock,
|
|
23
|
+
} from '@wordpress/widgets';
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Internal dependencies
|
|
@@ -41,32 +44,18 @@ export function initializeEditor( id, settings ) {
|
|
|
41
44
|
settings.__experimentalFetchRichUrlData = fetchUrlData;
|
|
42
45
|
|
|
43
46
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
44
|
-
|
|
47
|
+
const coreBlocks = __experimentalGetCoreBlocks().filter(
|
|
48
|
+
( { name } ) => name !== 'core/freeform'
|
|
49
|
+
);
|
|
50
|
+
registerCoreBlocks( coreBlocks );
|
|
51
|
+
dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );
|
|
45
52
|
registerLegacyWidgetBlock( { inserter: false } );
|
|
53
|
+
registerWidgetGroupBlock( { inserter: false } );
|
|
46
54
|
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
47
55
|
__experimentalRegisterExperimentalCoreBlocks( {
|
|
48
56
|
enableFSEBlocks: true,
|
|
49
57
|
} );
|
|
50
58
|
}
|
|
51
|
-
/*
|
|
52
|
-
* Prevent adding the Clasic block in the site editor.
|
|
53
|
-
* Only add the filter when the site editor is initialized, not imported.
|
|
54
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
55
|
-
* so that common filters in the block library are not overwritten.
|
|
56
|
-
*
|
|
57
|
-
* This usage here is inspired by previous usage of the filter in the post editor:
|
|
58
|
-
* https://github.com/WordPress/gutenberg/pull/37157
|
|
59
|
-
*/
|
|
60
|
-
addFilter(
|
|
61
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
62
|
-
'removeClassicBlockFromInserter',
|
|
63
|
-
( canInsert, blockType ) => {
|
|
64
|
-
if ( blockType.name === 'core/freeform' ) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return canInsert;
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
59
|
|
|
71
60
|
// We dispatch actions and update the store synchronously before rendering
|
|
72
61
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
package/src/style.scss
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
@import "./components/header-edit-mode/style.scss";
|
|
9
9
|
@import "./components/header-edit-mode/document-actions/style.scss";
|
|
10
10
|
@import "./components/list/style.scss";
|
|
11
|
-
@import "./components/navigation-inspector/style.scss";
|
|
12
11
|
@import "./components/sidebar-edit-mode/style.scss";
|
|
13
12
|
@import "./components/sidebar-edit-mode/settings-header/style.scss";
|
|
14
13
|
@import "./components/sidebar-edit-mode/template-card/style.scss";
|
|
@@ -19,8 +18,10 @@
|
|
|
19
18
|
@import "./components/welcome-guide/style.scss";
|
|
20
19
|
@import "./components/keyboard-shortcut-help-modal/style.scss";
|
|
21
20
|
@import "./components/layout/style.scss";
|
|
21
|
+
@import "./components/save-hub/style.scss";
|
|
22
22
|
@import "./components/save-panel/style.scss";
|
|
23
23
|
@import "./components/sidebar/style.scss";
|
|
24
|
+
@import "./components/sidebar-button/style.scss";
|
|
24
25
|
@import "./components/sidebar-navigation-item/style.scss";
|
|
25
26
|
@import "./components/sidebar-navigation-screen/style.scss";
|
|
26
27
|
@import "./components/sidebar-navigation-screen-templates/style.scss";
|
package/src/utils/history.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createBrowserHistory } from 'history';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
9
|
+
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
10
10
|
|
|
11
11
|
const history = createBrowserHistory();
|
|
12
12
|
|
|
@@ -14,19 +14,23 @@ const originalHistoryPush = history.push;
|
|
|
14
14
|
const originalHistoryReplace = history.replace;
|
|
15
15
|
|
|
16
16
|
function push( params, state ) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const currentArgs = getQueryArgs( window.location.href );
|
|
18
|
+
const currentUrlWithoutArgs = removeQueryArgs(
|
|
19
|
+
window.location.href,
|
|
20
|
+
...Object.keys( currentArgs )
|
|
21
21
|
);
|
|
22
|
+
const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
|
|
23
|
+
return originalHistoryPush.call( history, newUrl, state );
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
function replace( params, state ) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const currentArgs = getQueryArgs( window.location.href );
|
|
28
|
+
const currentUrlWithoutArgs = removeQueryArgs(
|
|
29
|
+
window.location.href,
|
|
30
|
+
...Object.keys( currentArgs )
|
|
29
31
|
);
|
|
32
|
+
const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
|
|
33
|
+
return originalHistoryReplace.call( history, newUrl, state );
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
history.push = push;
|