@wordpress/edit-site 5.12.11 → 5.12.13
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/block-editor/constants.js +1 -1
- package/build/components/block-editor/constants.js.map +1 -1
- package/build/components/editor/index.js +2 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +8 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +31 -25
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +1 -1
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/layout/index.js +6 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/grid.js +2 -1
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +17 -3
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +20 -3
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/index.js +1 -2
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +11 -19
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +15 -13
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +8 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +2 -0
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +0 -9
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +30 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/store/private-actions.js +2 -1
- package/build/store/private-actions.js.map +1 -1
- package/build-module/components/block-editor/constants.js +1 -1
- package/build-module/components/block-editor/constants.js.map +1 -1
- package/build-module/components/editor/index.js +2 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +9 -3
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +27 -21
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +3 -3
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/layout/index.js +6 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +3 -2
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +17 -3
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +19 -3
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/index.js +1 -2
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +12 -20
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +13 -13
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +7 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -0
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +0 -7
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +29 -0
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/store/private-actions.js +2 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +25 -25
- package/build-style/style.css +25 -25
- package/package.json +20 -20
- package/src/components/block-editor/constants.js +5 -1
- package/src/components/editor/index.js +2 -3
- package/src/components/global-styles/screen-revisions/index.js +76 -58
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +63 -48
- package/src/components/header-edit-mode/document-actions/index.js +4 -3
- package/src/components/header-edit-mode/document-actions/style.scss +25 -25
- package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
- package/src/components/layout/index.js +6 -0
- package/src/components/page-patterns/grid.js +8 -3
- package/src/components/page-patterns/patterns-list.js +15 -2
- package/src/components/page-patterns/style.scss +3 -0
- package/src/components/page-patterns/use-patterns.js +19 -3
- package/src/components/page-template-parts/index.js +0 -1
- package/src/components/resizable-frame/index.js +10 -25
- package/src/components/sidebar-navigation-screen/index.js +13 -15
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
- package/src/components/sidebar-navigation-screen-pages/index.js +9 -4
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -8
- package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
- package/src/hooks/commands/use-edit-mode-commands.js +34 -3
- package/src/store/private-actions.js +5 -1
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
__experimentalUseNavigator as useNavigator,
|
|
8
8
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
9
9
|
Spinner,
|
|
10
|
+
__experimentalSpacer as Spacer,
|
|
10
11
|
} from '@wordpress/components';
|
|
11
12
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
13
|
import { useContext, useState, useEffect } from '@wordpress/element';
|
|
@@ -87,6 +88,7 @@ function ScreenRevisions() {
|
|
|
87
88
|
const isLoadButtonEnabled =
|
|
88
89
|
!! globalStylesRevision?.id &&
|
|
89
90
|
! areGlobalStyleConfigsEqual( globalStylesRevision, userConfig );
|
|
91
|
+
const shouldShowRevisions = ! isLoading && revisions.length;
|
|
90
92
|
|
|
91
93
|
return (
|
|
92
94
|
<>
|
|
@@ -99,68 +101,84 @@ function ScreenRevisions() {
|
|
|
99
101
|
{ isLoading && (
|
|
100
102
|
<Spinner className="edit-site-global-styles-screen-revisions__loading" />
|
|
101
103
|
) }
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
{ shouldShowRevisions ? (
|
|
105
|
+
<>
|
|
106
|
+
<Revisions
|
|
107
|
+
blocks={ blocks }
|
|
108
|
+
userConfig={ globalStylesRevision }
|
|
109
|
+
onClose={ onCloseRevisions }
|
|
110
|
+
/>
|
|
111
|
+
<div className="edit-site-global-styles-screen-revisions">
|
|
112
|
+
<RevisionsButtons
|
|
113
|
+
onChange={ selectRevision }
|
|
114
|
+
selectedRevisionId={ selectedRevisionId }
|
|
115
|
+
userRevisions={ revisions }
|
|
116
|
+
/>
|
|
117
|
+
{ isLoadButtonEnabled && (
|
|
118
|
+
<SidebarFixedBottom>
|
|
119
|
+
<Button
|
|
120
|
+
variant="primary"
|
|
121
|
+
className="edit-site-global-styles-screen-revisions__button"
|
|
122
|
+
disabled={
|
|
123
|
+
! globalStylesRevision?.id ||
|
|
124
|
+
globalStylesRevision?.id === 'unsaved'
|
|
125
|
+
}
|
|
126
|
+
onClick={ () => {
|
|
127
|
+
if ( hasUnsavedChanges ) {
|
|
128
|
+
setIsLoadingRevisionWithUnsavedChanges(
|
|
129
|
+
true
|
|
130
|
+
);
|
|
131
|
+
} else {
|
|
132
|
+
restoreRevision(
|
|
133
|
+
globalStylesRevision
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
} }
|
|
137
|
+
>
|
|
138
|
+
{ __( 'Apply' ) }
|
|
139
|
+
</Button>
|
|
140
|
+
</SidebarFixedBottom>
|
|
141
|
+
) }
|
|
142
|
+
</div>
|
|
143
|
+
{ isLoadingRevisionWithUnsavedChanges && (
|
|
144
|
+
<ConfirmDialog
|
|
145
|
+
title={ __(
|
|
146
|
+
'Loading this revision will discard all unsaved changes.'
|
|
147
|
+
) }
|
|
148
|
+
isOpen={ isLoadingRevisionWithUnsavedChanges }
|
|
149
|
+
confirmButtonText={ __(
|
|
150
|
+
' Discard unsaved changes'
|
|
151
|
+
) }
|
|
152
|
+
onConfirm={ () =>
|
|
153
|
+
restoreRevision( globalStylesRevision )
|
|
154
|
+
}
|
|
155
|
+
onCancel={ () =>
|
|
156
|
+
setIsLoadingRevisionWithUnsavedChanges( false )
|
|
123
157
|
}
|
|
124
|
-
onClick={ () => {
|
|
125
|
-
if ( hasUnsavedChanges ) {
|
|
126
|
-
setIsLoadingRevisionWithUnsavedChanges(
|
|
127
|
-
true
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
restoreRevision( globalStylesRevision );
|
|
131
|
-
}
|
|
132
|
-
} }
|
|
133
158
|
>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
159
|
+
<>
|
|
160
|
+
<h2>
|
|
161
|
+
{ __(
|
|
162
|
+
'Loading this revision will discard all unsaved changes.'
|
|
163
|
+
) }
|
|
164
|
+
</h2>
|
|
165
|
+
<p>
|
|
166
|
+
{ __(
|
|
167
|
+
'Do you want to replace your unsaved changes in the editor?'
|
|
168
|
+
) }
|
|
169
|
+
</p>
|
|
170
|
+
</>
|
|
171
|
+
</ConfirmDialog>
|
|
143
172
|
) }
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
173
|
+
</>
|
|
174
|
+
) : (
|
|
175
|
+
<Spacer marginX={ 4 } data-testid="global-styles-no-revisions">
|
|
176
|
+
{
|
|
177
|
+
// Adding an existing translation here in case these changes are shipped to WordPress 6.3.
|
|
178
|
+
// Later we could update to something better, e.g., "There are currently no style revisions.".
|
|
179
|
+
__( 'No results found.' )
|
|
149
180
|
}
|
|
150
|
-
>
|
|
151
|
-
<>
|
|
152
|
-
<h2>
|
|
153
|
-
{ __(
|
|
154
|
-
'Loading this revision will discard all unsaved changes.'
|
|
155
|
-
) }
|
|
156
|
-
</h2>
|
|
157
|
-
<p>
|
|
158
|
-
{ __(
|
|
159
|
-
'Do you want to replace your unsaved changes in the editor?'
|
|
160
|
-
) }
|
|
161
|
-
</p>
|
|
162
|
-
</>
|
|
163
|
-
</ConfirmDialog>
|
|
181
|
+
</Spacer>
|
|
164
182
|
) }
|
|
165
183
|
</>
|
|
166
184
|
);
|
|
@@ -49,6 +49,7 @@ describe( 'useGlobalStylesRevisions', () => {
|
|
|
49
49
|
styles: {},
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
|
+
isLoadingGlobalStylesRevisions: false,
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
it( 'returns loaded revisions with no unsaved changes', () => {
|
|
@@ -117,11 +118,23 @@ describe( 'useGlobalStylesRevisions', () => {
|
|
|
117
118
|
const { result } = renderHook( () => useGlobalStylesRevisions() );
|
|
118
119
|
const { revisions, isLoading, hasUnsavedChanges } = result.current;
|
|
119
120
|
|
|
120
|
-
expect( isLoading ).toBe(
|
|
121
|
+
expect( isLoading ).toBe( false );
|
|
121
122
|
expect( hasUnsavedChanges ).toBe( false );
|
|
122
123
|
expect( revisions ).toEqual( [] );
|
|
123
124
|
} );
|
|
124
125
|
|
|
126
|
+
it( 'returns loading status when resolving global revisions', () => {
|
|
127
|
+
useSelect.mockImplementation( () => ( {
|
|
128
|
+
...selectValue,
|
|
129
|
+
isLoadingGlobalStylesRevisions: true,
|
|
130
|
+
} ) );
|
|
131
|
+
|
|
132
|
+
const { result } = renderHook( () => useGlobalStylesRevisions() );
|
|
133
|
+
const { isLoading } = result.current;
|
|
134
|
+
|
|
135
|
+
expect( isLoading ).toBe( true );
|
|
136
|
+
} );
|
|
137
|
+
|
|
125
138
|
it( 'returns empty revisions when authors are not yet available', () => {
|
|
126
139
|
useSelect.mockImplementation( () => ( {
|
|
127
140
|
...selectValue,
|
|
@@ -21,34 +21,40 @@ const EMPTY_ARRAY = [];
|
|
|
21
21
|
const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
|
|
22
22
|
export default function useGlobalStylesRevisions() {
|
|
23
23
|
const { user: userConfig } = useContext( GlobalStylesContext );
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const {
|
|
25
|
+
authors,
|
|
26
|
+
currentUser,
|
|
27
|
+
isDirty,
|
|
28
|
+
revisions,
|
|
29
|
+
isLoadingGlobalStylesRevisions,
|
|
30
|
+
} = useSelect( ( select ) => {
|
|
31
|
+
const {
|
|
32
|
+
__experimentalGetDirtyEntityRecords,
|
|
33
|
+
getCurrentUser,
|
|
34
|
+
getUsers,
|
|
35
|
+
getCurrentThemeGlobalStylesRevisions,
|
|
36
|
+
isResolving,
|
|
37
|
+
} = select( coreStore );
|
|
38
|
+
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
39
|
+
const _currentUser = getCurrentUser();
|
|
40
|
+
const _isDirty = dirtyEntityRecords.length > 0;
|
|
41
|
+
const globalStylesRevisions =
|
|
42
|
+
getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
|
|
43
|
+
const _authors = getUsers( SITE_EDITOR_AUTHORS_QUERY ) || EMPTY_ARRAY;
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
return {
|
|
46
|
+
authors: _authors,
|
|
47
|
+
currentUser: _currentUser,
|
|
48
|
+
isDirty: _isDirty,
|
|
49
|
+
revisions: globalStylesRevisions,
|
|
50
|
+
isLoadingGlobalStylesRevisions: isResolving(
|
|
51
|
+
'getCurrentThemeGlobalStylesRevisions'
|
|
52
|
+
),
|
|
53
|
+
};
|
|
54
|
+
}, [] );
|
|
49
55
|
return useMemo( () => {
|
|
50
56
|
let _modifiedRevisions = [];
|
|
51
|
-
if ( ! authors.length ||
|
|
57
|
+
if ( ! authors.length || isLoadingGlobalStylesRevisions ) {
|
|
52
58
|
return {
|
|
53
59
|
revisions: _modifiedRevisions,
|
|
54
60
|
hasUnsavedChanges: isDirty,
|
|
@@ -66,30 +72,32 @@ export default function useGlobalStylesRevisions() {
|
|
|
66
72
|
};
|
|
67
73
|
} );
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
_modifiedRevisions[ 0 ].
|
|
72
|
-
|
|
75
|
+
if ( _modifiedRevisions.length ) {
|
|
76
|
+
// Flags the most current saved revision.
|
|
77
|
+
if ( _modifiedRevisions[ 0 ].id !== 'unsaved' ) {
|
|
78
|
+
_modifiedRevisions[ 0 ].isLatest = true;
|
|
79
|
+
}
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
// Adds an item for unsaved changes.
|
|
82
|
+
if (
|
|
83
|
+
isDirty &&
|
|
84
|
+
userConfig &&
|
|
85
|
+
Object.keys( userConfig ).length > 0 &&
|
|
86
|
+
currentUser
|
|
87
|
+
) {
|
|
88
|
+
const unsavedRevision = {
|
|
89
|
+
id: 'unsaved',
|
|
90
|
+
styles: userConfig?.styles,
|
|
91
|
+
settings: userConfig?.settings,
|
|
92
|
+
author: {
|
|
93
|
+
name: currentUser?.name,
|
|
94
|
+
avatar_urls: currentUser?.avatar_urls,
|
|
95
|
+
},
|
|
96
|
+
modified: new Date(),
|
|
97
|
+
};
|
|
91
98
|
|
|
92
|
-
|
|
99
|
+
_modifiedRevisions.unshift( unsavedRevision );
|
|
100
|
+
}
|
|
93
101
|
}
|
|
94
102
|
|
|
95
103
|
return {
|
|
@@ -97,5 +105,12 @@ export default function useGlobalStylesRevisions() {
|
|
|
97
105
|
hasUnsavedChanges: isDirty,
|
|
98
106
|
isLoading: false,
|
|
99
107
|
};
|
|
100
|
-
}, [
|
|
108
|
+
}, [
|
|
109
|
+
isDirty,
|
|
110
|
+
revisions,
|
|
111
|
+
currentUser,
|
|
112
|
+
authors,
|
|
113
|
+
userConfig,
|
|
114
|
+
isLoadingGlobalStylesRevisions,
|
|
115
|
+
] );
|
|
101
116
|
}
|
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { sprintf, __ } from '@wordpress/i18n';
|
|
9
|
+
import { sprintf, __, isRTL } from '@wordpress/i18n';
|
|
10
10
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
11
|
import {
|
|
12
12
|
Button,
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
import { BlockIcon } from '@wordpress/block-editor';
|
|
18
18
|
import { store as commandsStore } from '@wordpress/commands';
|
|
19
19
|
import {
|
|
20
|
-
chevronLeftSmall
|
|
20
|
+
chevronLeftSmall,
|
|
21
|
+
chevronRightSmall,
|
|
21
22
|
page as pageIcon,
|
|
22
23
|
navigation as navigationIcon,
|
|
23
24
|
symbol,
|
|
@@ -153,7 +154,7 @@ function BaseDocumentActions( { className, icon, children, onBack } ) {
|
|
|
153
154
|
{ onBack && (
|
|
154
155
|
<Button
|
|
155
156
|
className="edit-site-document-actions__back"
|
|
156
|
-
icon={
|
|
157
|
+
icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
|
|
157
158
|
onClick={ ( event ) => {
|
|
158
159
|
event.stopPropagation();
|
|
159
160
|
onBack();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
.edit-site-document-actions {
|
|
2
|
-
display:
|
|
3
|
-
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: $grid-unit;
|
|
4
5
|
height: $button-size;
|
|
6
|
+
justify-content: space-between;
|
|
5
7
|
// Flex items will, by default, refuse to shrink below a minimum
|
|
6
8
|
// intrinsic width. In order to shrink this flexbox item, and
|
|
7
9
|
// subsequently truncate child text, we set an explicit min-width.
|
|
@@ -10,11 +12,12 @@
|
|
|
10
12
|
background: $gray-100;
|
|
11
13
|
border-radius: 4px;
|
|
12
14
|
width: min(100%, 450px);
|
|
13
|
-
overflow: hidden;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
.components-button {
|
|
17
|
+
&:hover {
|
|
18
|
+
color: var(--wp-block-synced-color);
|
|
19
|
+
background: $gray-200;
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
@include break-medium() {
|
|
@@ -27,21 +30,23 @@
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
.edit-site-document-actions__command {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
grid-row: 1;
|
|
33
|
+
flex-grow: 1;
|
|
34
|
+
color: var(--wp-block-synced-color);
|
|
35
|
+
overflow: hidden;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
|
|
37
38
|
.edit-site-document-actions__title {
|
|
38
39
|
flex-grow: 1;
|
|
39
40
|
color: var(--wp-block-synced-color);
|
|
40
41
|
overflow: hidden;
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
color: var(--wp-block-synced-color);
|
|
45
|
+
}
|
|
42
46
|
|
|
43
47
|
.block-editor-block-icon {
|
|
44
48
|
min-width: $grid-unit-30;
|
|
49
|
+
flex-shrink: 0;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
h1 {
|
|
@@ -70,26 +75,21 @@
|
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
.edit-site-document-actions__shortcut,
|
|
74
|
-
.edit-site-document-actions__back {
|
|
75
|
-
color: $gray-800;
|
|
76
|
-
|
|
77
|
-
.edit-site-document-actions:hover & {
|
|
78
|
-
color: $gray-900;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
78
|
.edit-site-document-actions__shortcut {
|
|
83
|
-
|
|
79
|
+
color: $gray-800;
|
|
84
80
|
}
|
|
85
81
|
|
|
86
|
-
.edit-site-document-actions__back {
|
|
82
|
+
.edit-site-document-actions__back.components-button.has-icon.has-text {
|
|
87
83
|
min-width: $button-size;
|
|
88
84
|
flex-shrink: 0;
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
color: $gray-700;
|
|
86
|
+
gap: 0;
|
|
91
87
|
z-index: 1;
|
|
92
88
|
|
|
89
|
+
&:hover {
|
|
90
|
+
color: currentColor;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
93
|
.edit-site-document-actions.is-animated & {
|
|
94
94
|
animation: edit-site-document-actions__slide-in-left 0.3s;
|
|
95
95
|
@include reduce-motion("animation");
|
|
@@ -33,10 +33,8 @@ function KeyboardShortcutsEditMode() {
|
|
|
33
33
|
);
|
|
34
34
|
const { redo, undo } = useDispatch( coreStore );
|
|
35
35
|
const {
|
|
36
|
-
isFeatureActive,
|
|
37
36
|
setIsListViewOpened,
|
|
38
37
|
switchEditorMode,
|
|
39
|
-
toggleFeature,
|
|
40
38
|
setIsInserterOpened,
|
|
41
39
|
closeGeneralSidebar,
|
|
42
40
|
} = useDispatch( editSiteStore );
|
|
@@ -47,7 +45,8 @@ function KeyboardShortcutsEditMode() {
|
|
|
47
45
|
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
|
|
48
46
|
useSelect( blockEditorStore );
|
|
49
47
|
|
|
50
|
-
const {
|
|
48
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
49
|
+
const { set: setPreference, toggle } = useDispatch( preferencesStore );
|
|
51
50
|
const { createInfoNotice } = useDispatch( noticesStore );
|
|
52
51
|
|
|
53
52
|
const toggleDistractionFree = () => {
|
|
@@ -135,9 +134,9 @@ function KeyboardShortcutsEditMode() {
|
|
|
135
134
|
|
|
136
135
|
useShortcut( 'core/edit-site/toggle-distraction-free', () => {
|
|
137
136
|
toggleDistractionFree();
|
|
138
|
-
|
|
137
|
+
toggle( 'core/edit-site', 'distractionFree' );
|
|
139
138
|
createInfoNotice(
|
|
140
|
-
|
|
139
|
+
getPreference( 'core/edit-site', 'distractionFree' )
|
|
141
140
|
? __( 'Distraction free mode turned on.' )
|
|
142
141
|
: __( 'Distraction free mode turned off.' ),
|
|
143
142
|
{
|
|
@@ -340,6 +340,12 @@ export default function Layout() {
|
|
|
340
340
|
! isEditorLoading
|
|
341
341
|
}
|
|
342
342
|
isFullWidth={ isEditing }
|
|
343
|
+
defaultSize={ {
|
|
344
|
+
width:
|
|
345
|
+
canvasSize.width -
|
|
346
|
+
24 /* $canvas-padding */,
|
|
347
|
+
height: canvasSize.height,
|
|
348
|
+
} }
|
|
343
349
|
isOversized={
|
|
344
350
|
isResizableFrameOversized
|
|
345
351
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
__experimentalText as Text,
|
|
7
7
|
Button,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
|
-
import { useRef,
|
|
9
|
+
import { useRef, useMemo } from '@wordpress/element';
|
|
10
10
|
import { __, _x, _n, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { useAsyncList } from '@wordpress/compose';
|
|
12
12
|
|
|
@@ -82,8 +82,13 @@ function Pagination( { currentPage, numPages, changePage, totalItems } ) {
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export default function Grid( {
|
|
86
|
-
|
|
85
|
+
export default function Grid( {
|
|
86
|
+
categoryId,
|
|
87
|
+
items,
|
|
88
|
+
currentPage,
|
|
89
|
+
setCurrentPage,
|
|
90
|
+
...props
|
|
91
|
+
} ) {
|
|
87
92
|
const gridRef = useRef();
|
|
88
93
|
const totalItems = items.length;
|
|
89
94
|
const pageIndex = currentPage - 1;
|
|
@@ -48,6 +48,7 @@ const SYNC_DESCRIPTIONS = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export default function PatternsList( { categoryId, type } ) {
|
|
51
|
+
const [ currentPage, setCurrentPage ] = useState( 1 );
|
|
51
52
|
const location = useLocation();
|
|
52
53
|
const history = useHistory();
|
|
53
54
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
@@ -73,6 +74,16 @@ export default function PatternsList( { categoryId, type } ) {
|
|
|
73
74
|
}
|
|
74
75
|
);
|
|
75
76
|
|
|
77
|
+
const updateSearchFilter = ( value ) => {
|
|
78
|
+
setCurrentPage( 1 );
|
|
79
|
+
setFilterValue( value );
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const updateSyncFilter = ( value ) => {
|
|
83
|
+
setCurrentPage( 1 );
|
|
84
|
+
setSyncFilter( value );
|
|
85
|
+
};
|
|
86
|
+
|
|
76
87
|
const id = useId();
|
|
77
88
|
const titleId = `${ id }-title`;
|
|
78
89
|
const descriptionId = `${ id }-description`;
|
|
@@ -109,7 +120,7 @@ export default function PatternsList( { categoryId, type } ) {
|
|
|
109
120
|
<FlexBlock className="edit-site-patterns__search-block">
|
|
110
121
|
<SearchControl
|
|
111
122
|
className="edit-site-patterns__search"
|
|
112
|
-
onChange={ ( value ) =>
|
|
123
|
+
onChange={ ( value ) => updateSearchFilter( value ) }
|
|
113
124
|
placeholder={ __( 'Search patterns' ) }
|
|
114
125
|
label={ __( 'Search patterns' ) }
|
|
115
126
|
value={ filterValue }
|
|
@@ -123,7 +134,7 @@ export default function PatternsList( { categoryId, type } ) {
|
|
|
123
134
|
label={ __( 'Filter by sync status' ) }
|
|
124
135
|
value={ syncFilter }
|
|
125
136
|
isBlock
|
|
126
|
-
onChange={ ( value ) =>
|
|
137
|
+
onChange={ ( value ) => updateSyncFilter( value ) }
|
|
127
138
|
__nextHasNoMarginBottom
|
|
128
139
|
>
|
|
129
140
|
{ Object.entries( SYNC_FILTERS ).map(
|
|
@@ -157,6 +168,8 @@ export default function PatternsList( { categoryId, type } ) {
|
|
|
157
168
|
items={ patterns }
|
|
158
169
|
aria-labelledby={ titleId }
|
|
159
170
|
aria-describedby={ descriptionId }
|
|
171
|
+
currentPage={ currentPage }
|
|
172
|
+
setCurrentPage={ setCurrentPage }
|
|
160
173
|
/>
|
|
161
174
|
) }
|
|
162
175
|
{ ! isResolving && ! hasPatterns && <NoPatterns /> }
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { parse } from '@wordpress/blocks';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
7
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -39,14 +40,12 @@ const templatePartToPattern = ( templatePart ) => ( {
|
|
|
39
40
|
templatePart,
|
|
40
41
|
} );
|
|
41
42
|
|
|
42
|
-
const templatePartHasCategory = ( item, category ) =>
|
|
43
|
-
item.templatePart.area === category;
|
|
44
|
-
|
|
45
43
|
const selectTemplatePartsAsPatterns = (
|
|
46
44
|
select,
|
|
47
45
|
{ categoryId, search = '' } = {}
|
|
48
46
|
) => {
|
|
49
47
|
const { getEntityRecords, getIsResolving } = select( coreStore );
|
|
48
|
+
const { __experimentalGetDefaultTemplatePartAreas } = select( editorStore );
|
|
50
49
|
const query = { per_page: -1 };
|
|
51
50
|
const rawTemplateParts =
|
|
52
51
|
getEntityRecords( 'postType', TEMPLATE_PARTS, query ) ??
|
|
@@ -55,6 +54,23 @@ const selectTemplatePartsAsPatterns = (
|
|
|
55
54
|
templatePartToPattern( templatePart )
|
|
56
55
|
);
|
|
57
56
|
|
|
57
|
+
// In the case where a custom template part area has been removed we need
|
|
58
|
+
// the current list of areas to cross check against so orphaned template
|
|
59
|
+
// parts can be treated as uncategorized.
|
|
60
|
+
const knownAreas = __experimentalGetDefaultTemplatePartAreas() || [];
|
|
61
|
+
const templatePartAreas = knownAreas.map( ( area ) => area.area );
|
|
62
|
+
|
|
63
|
+
const templatePartHasCategory = ( item, category ) => {
|
|
64
|
+
if ( category !== 'uncategorized' ) {
|
|
65
|
+
return item.templatePart.area === category;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
item.templatePart.area === category ||
|
|
70
|
+
! templatePartAreas.includes( item.templatePart.area )
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
58
74
|
const isResolving = getIsResolving( 'getEntityRecords', [
|
|
59
75
|
'postType',
|
|
60
76
|
'wp_template_part',
|