@wordpress/edit-site 5.12.7 → 5.12.8
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/editor-canvas.js +1 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +7 -3
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js +163 -0
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +83 -59
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/grid.js +21 -13
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/header.js +69 -0
- package/build/components/page-patterns/header.js.map +1 -0
- package/build/components/page-patterns/index.js +3 -1
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +67 -27
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +109 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build/components/page-patterns/use-patterns.js +99 -118
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +1 -1
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +1 -34
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +2 -2
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build/components/site-hub/index.js +1 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/template-actions/index.js +3 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +9 -6
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/utils/use-activate-theme.js +1 -1
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +6 -3
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js +147 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +84 -65
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +22 -15
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/header.js +54 -0
- package/build-module/components/page-patterns/header.js.map +1 -0
- package/build-module/components/page-patterns/index.js +3 -1
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +70 -31
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +97 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -0
- package/build-module/components/page-patterns/use-patterns.js +100 -119
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +1 -32
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js +9 -5
- package/build-module/components/sidebar-navigation-screen-patterns/use-my-patterns.js.map +1 -1
- package/build-module/components/site-hub/index.js +1 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/template-actions/index.js +2 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +8 -6
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/utils/use-activate-theme.js +1 -1
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +103 -45
- package/build-style/style.css +103 -45
- package/package.json +14 -14
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/create-pattern-modal/index.js +5 -2
- package/src/components/header-edit-mode/document-actions/style.scss +4 -0
- package/src/components/page-patterns/duplicate-menu-item.js +196 -0
- package/src/components/page-patterns/grid-item.js +187 -137
- package/src/components/page-patterns/grid.js +35 -22
- package/src/components/page-patterns/header.js +69 -0
- package/src/components/page-patterns/index.js +6 -1
- package/src/components/page-patterns/patterns-list.js +89 -47
- package/src/components/page-patterns/rename-menu-item.js +115 -0
- package/src/components/page-patterns/style.scss +86 -26
- package/src/components/page-patterns/use-patterns.js +96 -167
- package/src/components/sidebar-navigation-screen/index.js +1 -1
- package/src/components/sidebar-navigation-screen-page/status-label.js +1 -35
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -6
- package/src/components/sidebar-navigation-screen-patterns/style.scss +0 -3
- package/src/components/sidebar-navigation-screen-patterns/use-my-patterns.js +7 -6
- package/src/components/site-hub/index.js +1 -1
- package/src/components/template-actions/index.js +2 -1
- package/src/components/template-actions/rename-menu-item.js +8 -6
- package/src/hooks/push-changes-to-global-styles/index.js +8 -1
- package/src/style.scss +10 -12
- package/src/utils/use-activate-theme.js +1 -1
|
@@ -4,7 +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 {
|
|
7
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
SYNC_TYPES,
|
|
16
16
|
TEMPLATE_PARTS,
|
|
17
17
|
USER_PATTERNS,
|
|
18
|
-
USER_PATTERN_CATEGORY,
|
|
19
18
|
filterOutDuplicatesByName,
|
|
20
19
|
} from './utils';
|
|
21
20
|
import { unlock } from '../../lock-unlock';
|
|
@@ -31,9 +30,11 @@ const templatePartToPattern = ( templatePart ) => ( {
|
|
|
31
30
|
blocks: parse( templatePart.content.raw ),
|
|
32
31
|
categories: [ templatePart.area ],
|
|
33
32
|
description: templatePart.description || '',
|
|
33
|
+
isCustom: templatePart.source === 'custom',
|
|
34
34
|
keywords: templatePart.keywords || [],
|
|
35
|
+
id: createTemplatePartId( templatePart.theme, templatePart.slug ),
|
|
35
36
|
name: createTemplatePartId( templatePart.theme, templatePart.slug ),
|
|
36
|
-
title: templatePart.title.rendered,
|
|
37
|
+
title: decodeEntities( templatePart.title.rendered ),
|
|
37
38
|
type: templatePart.type,
|
|
38
39
|
templatePart,
|
|
39
40
|
} );
|
|
@@ -41,106 +42,64 @@ const templatePartToPattern = ( templatePart ) => ( {
|
|
|
41
42
|
const templatePartHasCategory = ( item, category ) =>
|
|
42
43
|
item.templatePart.area === category;
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
filterValue = ''
|
|
45
|
+
const selectTemplatePartsAsPatterns = (
|
|
46
|
+
select,
|
|
47
|
+
{ categoryId, search = '' } = {}
|
|
48
48
|
) => {
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { getEntityRecords, isResolving: _isResolving } =
|
|
59
|
-
select( coreStore );
|
|
60
|
-
const query = { per_page: -1 };
|
|
61
|
-
const rawTemplateParts = getEntityRecords(
|
|
62
|
-
'postType',
|
|
63
|
-
postType,
|
|
64
|
-
query
|
|
65
|
-
);
|
|
66
|
-
const partsAsPatterns = rawTemplateParts?.map( ( templatePart ) =>
|
|
67
|
-
templatePartToPattern( templatePart )
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
templateParts: partsAsPatterns,
|
|
72
|
-
isResolving: _isResolving( 'getEntityRecords', [
|
|
73
|
-
'postType',
|
|
74
|
-
'wp_template_part',
|
|
75
|
-
query,
|
|
76
|
-
] ),
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
[ postType ]
|
|
49
|
+
const { getEntityRecords, getIsResolving } = select( coreStore );
|
|
50
|
+
const query = { per_page: -1 };
|
|
51
|
+
const rawTemplateParts =
|
|
52
|
+
getEntityRecords( 'postType', TEMPLATE_PARTS, query ) ??
|
|
53
|
+
EMPTY_PATTERN_LIST;
|
|
54
|
+
const templateParts = rawTemplateParts.map( ( templatePart ) =>
|
|
55
|
+
templatePartToPattern( templatePart )
|
|
80
56
|
);
|
|
81
57
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
58
|
+
const isResolving = getIsResolving( 'getEntityRecords', [
|
|
59
|
+
'postType',
|
|
60
|
+
'wp_template_part',
|
|
61
|
+
query,
|
|
62
|
+
] );
|
|
86
63
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, [ templateParts, filterValue, categoryId ] );
|
|
64
|
+
const patterns = searchItems( templateParts, search, {
|
|
65
|
+
categoryId,
|
|
66
|
+
hasCategory: templatePartHasCategory,
|
|
67
|
+
} );
|
|
92
68
|
|
|
93
|
-
return {
|
|
69
|
+
return { patterns, isResolving };
|
|
94
70
|
};
|
|
95
71
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
72
|
+
const selectThemePatterns = ( select, { categoryId, search = '' } = {} ) => {
|
|
73
|
+
const { getSettings } = unlock( select( editSiteStore ) );
|
|
74
|
+
const settings = getSettings();
|
|
75
|
+
const blockPatterns =
|
|
76
|
+
settings.__experimentalAdditionalBlockPatterns ??
|
|
77
|
+
settings.__experimentalBlockPatterns;
|
|
78
|
+
|
|
79
|
+
const restBlockPatterns = select( coreStore ).getBlockPatterns();
|
|
80
|
+
|
|
81
|
+
let patterns = [
|
|
82
|
+
...( blockPatterns || [] ),
|
|
83
|
+
...( restBlockPatterns || [] ),
|
|
84
|
+
]
|
|
85
|
+
.filter(
|
|
86
|
+
( pattern ) => ! CORE_PATTERN_SOURCES.includes( pattern.source )
|
|
87
|
+
)
|
|
88
|
+
.filter( filterOutDuplicatesByName )
|
|
89
|
+
.map( ( pattern ) => ( {
|
|
90
|
+
...pattern,
|
|
91
|
+
keywords: pattern.keywords || [],
|
|
92
|
+
type: 'pattern',
|
|
93
|
+
blocks: parse( pattern.content ),
|
|
94
|
+
} ) );
|
|
95
|
+
|
|
96
|
+
patterns = searchItems( patterns, search, {
|
|
97
|
+
categoryId,
|
|
98
|
+
hasCategory: ( item, currentCategory ) =>
|
|
99
|
+
item.categories?.includes( currentCategory ),
|
|
108
100
|
} );
|
|
109
101
|
|
|
110
|
-
|
|
111
|
-
select( coreStore ).getBlockPatterns()
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const patterns = useMemo(
|
|
115
|
-
() =>
|
|
116
|
-
[ ...( blockPatterns || [] ), ...( restBlockPatterns || [] ) ]
|
|
117
|
-
.filter(
|
|
118
|
-
( pattern ) =>
|
|
119
|
-
! CORE_PATTERN_SOURCES.includes( pattern.source )
|
|
120
|
-
)
|
|
121
|
-
.filter( filterOutDuplicatesByName )
|
|
122
|
-
.map( ( pattern ) => ( {
|
|
123
|
-
...pattern,
|
|
124
|
-
keywords: pattern.keywords || [],
|
|
125
|
-
type: 'pattern',
|
|
126
|
-
blocks: parse( pattern.content ),
|
|
127
|
-
} ) ),
|
|
128
|
-
[ blockPatterns, restBlockPatterns ]
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
const filteredPatterns = useMemo( () => {
|
|
132
|
-
if ( postType !== PATTERNS ) {
|
|
133
|
-
return EMPTY_PATTERN_LIST;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return searchItems( patterns, filterValue, {
|
|
137
|
-
categoryId,
|
|
138
|
-
hasCategory: ( item, currentCategory ) =>
|
|
139
|
-
item.categories?.includes( currentCategory ),
|
|
140
|
-
} );
|
|
141
|
-
}, [ patterns, filterValue, categoryId, postType ] );
|
|
142
|
-
|
|
143
|
-
return filteredPatterns;
|
|
102
|
+
return { patterns, isResolving: false };
|
|
144
103
|
};
|
|
145
104
|
|
|
146
105
|
const reusableBlockToPattern = ( reusableBlock ) => ( {
|
|
@@ -154,88 +113,58 @@ const reusableBlockToPattern = ( reusableBlock ) => ( {
|
|
|
154
113
|
reusableBlock,
|
|
155
114
|
} );
|
|
156
115
|
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
categoryType = PATTERNS,
|
|
160
|
-
filterValue = ''
|
|
161
|
-
) => {
|
|
162
|
-
const postType = categoryType === PATTERNS ? USER_PATTERNS : categoryType;
|
|
163
|
-
const unfilteredPatterns = useSelect(
|
|
164
|
-
( select ) => {
|
|
165
|
-
if (
|
|
166
|
-
postType !== USER_PATTERNS ||
|
|
167
|
-
categoryId !== USER_PATTERN_CATEGORY
|
|
168
|
-
) {
|
|
169
|
-
return EMPTY_PATTERN_LIST;
|
|
170
|
-
}
|
|
116
|
+
const selectUserPatterns = ( select, { search = '', syncStatus } = {} ) => {
|
|
117
|
+
const { getEntityRecords, getIsResolving } = select( coreStore );
|
|
171
118
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
per_page: -1,
|
|
175
|
-
} );
|
|
119
|
+
const query = { per_page: -1 };
|
|
120
|
+
const records = getEntityRecords( 'postType', USER_PATTERNS, query );
|
|
176
121
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
122
|
+
let patterns = records
|
|
123
|
+
? records.map( ( record ) => reusableBlockToPattern( record ) )
|
|
124
|
+
: EMPTY_PATTERN_LIST;
|
|
125
|
+
const isResolving = getIsResolving( 'getEntityRecords', [
|
|
126
|
+
'postType',
|
|
127
|
+
USER_PATTERNS,
|
|
128
|
+
query,
|
|
129
|
+
] );
|
|
180
130
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
);
|
|
131
|
+
if ( syncStatus ) {
|
|
132
|
+
patterns = patterns.filter(
|
|
133
|
+
( pattern ) => pattern.syncStatus === syncStatus
|
|
134
|
+
);
|
|
135
|
+
}
|
|
187
136
|
|
|
188
|
-
|
|
189
|
-
if
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return searchItems( unfilteredPatterns, filterValue, {
|
|
194
|
-
// We exit user pattern retrieval early if we aren't in the
|
|
195
|
-
// catch-all category for user created patterns, so it has
|
|
196
|
-
// to be in the category.
|
|
197
|
-
hasCategory: () => true,
|
|
198
|
-
} );
|
|
199
|
-
}, [ unfilteredPatterns, filterValue ] );
|
|
200
|
-
|
|
201
|
-
const patterns = { syncedPatterns: [], unsyncedPatterns: [] };
|
|
202
|
-
|
|
203
|
-
filteredPatterns.forEach( ( pattern ) => {
|
|
204
|
-
if ( pattern.syncStatus === SYNC_TYPES.full ) {
|
|
205
|
-
patterns.syncedPatterns.push( pattern );
|
|
206
|
-
} else {
|
|
207
|
-
patterns.unsyncedPatterns.push( pattern );
|
|
208
|
-
}
|
|
137
|
+
patterns = searchItems( patterns, search, {
|
|
138
|
+
// We exit user pattern retrieval early if we aren't in the
|
|
139
|
+
// catch-all category for user created patterns, so it has
|
|
140
|
+
// to be in the category.
|
|
141
|
+
hasCategory: () => true,
|
|
209
142
|
} );
|
|
210
143
|
|
|
211
|
-
return patterns;
|
|
144
|
+
return { patterns, isResolving };
|
|
212
145
|
};
|
|
213
146
|
|
|
214
|
-
export const usePatterns = (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
147
|
+
export const usePatterns = (
|
|
148
|
+
categoryType,
|
|
149
|
+
categoryId,
|
|
150
|
+
{ search = '', syncStatus }
|
|
151
|
+
) => {
|
|
152
|
+
return useSelect(
|
|
153
|
+
( select ) => {
|
|
154
|
+
if ( categoryType === TEMPLATE_PARTS ) {
|
|
155
|
+
return selectTemplatePartsAsPatterns( select, {
|
|
156
|
+
categoryId,
|
|
157
|
+
search,
|
|
158
|
+
} );
|
|
159
|
+
} else if ( categoryType === PATTERNS ) {
|
|
160
|
+
return selectThemePatterns( select, { categoryId, search } );
|
|
161
|
+
} else if ( categoryType === USER_PATTERNS ) {
|
|
162
|
+
return selectUserPatterns( select, { search, syncStatus } );
|
|
163
|
+
}
|
|
164
|
+
return { patterns: EMPTY_PATTERN_LIST, isResolving: false };
|
|
165
|
+
},
|
|
166
|
+
[ categoryId, categoryType, search, syncStatus ]
|
|
231
167
|
);
|
|
232
|
-
|
|
233
|
-
const patterns = {
|
|
234
|
-
syncedPatterns: [ ...templateParts, ...syncedPatterns ],
|
|
235
|
-
unsyncedPatterns: [ ...blockPatterns, ...unsyncedPatterns ],
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
return [ patterns, isResolving ];
|
|
239
168
|
};
|
|
240
169
|
|
|
241
170
|
export default usePatterns;
|
|
@@ -9,42 +9,10 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { dateI18n, getDate, humanTimeDiff } from '@wordpress/date';
|
|
11
11
|
import { createInterpolateElement } from '@wordpress/element';
|
|
12
|
-
import { Path, SVG } from '@wordpress/primitives';
|
|
13
|
-
|
|
14
|
-
const publishedIcon = (
|
|
15
|
-
<SVG fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
|
|
16
|
-
<Path
|
|
17
|
-
fillRule="evenodd"
|
|
18
|
-
clipRule="evenodd"
|
|
19
|
-
d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16Zm-1.067-5.6 4.2-5.667.8.6-4.8 6.467-3-2.267.6-.8 2.2 1.667Z"
|
|
20
|
-
/>
|
|
21
|
-
</SVG>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const draftIcon = (
|
|
25
|
-
<SVG fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
|
|
26
|
-
<Path
|
|
27
|
-
fillRule="evenodd"
|
|
28
|
-
clipRule="evenodd"
|
|
29
|
-
d="M14.5 8a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0ZM16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-8 4a4 4 0 0 0 0-8v8Z"
|
|
30
|
-
/>
|
|
31
|
-
</SVG>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const pendingIcon = (
|
|
35
|
-
<SVG fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
|
|
36
|
-
<Path
|
|
37
|
-
fillRule="evenodd"
|
|
38
|
-
clipRule="evenodd"
|
|
39
|
-
d="M14.5 8a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0ZM16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0ZM8 4a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z"
|
|
40
|
-
/>
|
|
41
|
-
</SVG>
|
|
42
|
-
);
|
|
43
12
|
|
|
44
13
|
export default function StatusLabel( { status, date, short } ) {
|
|
45
14
|
const relateToNow = humanTimeDiff( date );
|
|
46
15
|
let statusLabel = status;
|
|
47
|
-
let statusIcon = pendingIcon;
|
|
48
16
|
switch ( status ) {
|
|
49
17
|
case 'publish':
|
|
50
18
|
statusLabel = date
|
|
@@ -57,7 +25,6 @@ export default function StatusLabel( { status, date, short } ) {
|
|
|
57
25
|
{ time: <time dateTime={ date } /> }
|
|
58
26
|
)
|
|
59
27
|
: __( 'Published' );
|
|
60
|
-
statusIcon = publishedIcon;
|
|
61
28
|
break;
|
|
62
29
|
case 'future':
|
|
63
30
|
const formattedDate = dateI18n(
|
|
@@ -77,7 +44,6 @@ export default function StatusLabel( { status, date, short } ) {
|
|
|
77
44
|
break;
|
|
78
45
|
case 'draft':
|
|
79
46
|
statusLabel = __( 'Draft' );
|
|
80
|
-
statusIcon = draftIcon;
|
|
81
47
|
break;
|
|
82
48
|
case 'pending':
|
|
83
49
|
statusLabel = __( 'Pending' );
|
|
@@ -99,7 +65,7 @@ export default function StatusLabel( { status, date, short } ) {
|
|
|
99
65
|
}
|
|
100
66
|
) }
|
|
101
67
|
>
|
|
102
|
-
{
|
|
68
|
+
{ statusLabel }
|
|
103
69
|
</div>
|
|
104
70
|
);
|
|
105
71
|
}
|
|
@@ -35,7 +35,6 @@ function TemplatePartGroup( { areas, currentArea, currentType } ) {
|
|
|
35
35
|
<>
|
|
36
36
|
<div className="edit-site-sidebar-navigation-screen-patterns__group-header">
|
|
37
37
|
<Heading level={ 2 }>{ __( 'Template parts' ) }</Heading>
|
|
38
|
-
<p>{ __( 'Synced patterns for use in template building.' ) }</p>
|
|
39
38
|
</div>
|
|
40
39
|
<ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
|
|
41
40
|
{ Object.entries( areas ).map(
|
|
@@ -64,11 +63,6 @@ function ThemePatternsGroup( { categories, currentCategory, currentType } ) {
|
|
|
64
63
|
<>
|
|
65
64
|
<div className="edit-site-sidebar-navigation-screen-patterns__group-header">
|
|
66
65
|
<Heading level={ 2 }>{ __( 'Theme patterns' ) }</Heading>
|
|
67
|
-
<p>
|
|
68
|
-
{ __(
|
|
69
|
-
'For insertion into documents where they can then be customized.'
|
|
70
|
-
) }
|
|
71
|
-
</p>
|
|
72
66
|
</div>
|
|
73
67
|
<ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
|
|
74
68
|
{ categories.map( ( category ) => (
|
|
@@ -6,18 +6,19 @@ import { useSelect } from '@wordpress/data';
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
export default function useMyPatterns() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const myPatternsCount = useSelect(
|
|
10
|
+
( select ) =>
|
|
11
|
+
select( coreStore ).getEntityRecords( 'postType', 'wp_block', {
|
|
12
|
+
per_page: -1,
|
|
13
|
+
} )?.length ?? 0
|
|
13
14
|
);
|
|
14
15
|
|
|
15
16
|
return {
|
|
16
17
|
myPatterns: {
|
|
17
|
-
count:
|
|
18
|
+
count: myPatternsCount,
|
|
18
19
|
name: 'my-patterns',
|
|
19
20
|
label: __( 'My patterns' ),
|
|
20
21
|
},
|
|
21
|
-
hasPatterns:
|
|
22
|
+
hasPatterns: myPatternsCount > 0,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
@@ -57,7 +57,7 @@ const SiteHub = forwardRef( ( props, ref ) => {
|
|
|
57
57
|
const siteIconButtonProps = isBackToDashboardButton
|
|
58
58
|
? {
|
|
59
59
|
href: dashboardLink,
|
|
60
|
-
label: __( 'Go
|
|
60
|
+
label: __( 'Go to the Dashboard' ),
|
|
61
61
|
}
|
|
62
62
|
: {
|
|
63
63
|
href: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { moreVertical } from '@wordpress/icons';
|
|
15
15
|
import { store as noticesStore } from '@wordpress/notices';
|
|
16
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Internal dependencies
|
|
@@ -58,7 +59,7 @@ export default function TemplateActions( {
|
|
|
58
59
|
sprintf(
|
|
59
60
|
/* translators: The template/part's name. */
|
|
60
61
|
__( '"%s" reverted.' ),
|
|
61
|
-
template.title.rendered
|
|
62
|
+
decodeEntities( template.title.rendered )
|
|
62
63
|
),
|
|
63
64
|
{
|
|
64
65
|
type: 'snackbar',
|
|
@@ -14,9 +14,11 @@ import {
|
|
|
14
14
|
} from '@wordpress/components';
|
|
15
15
|
import { store as coreStore } from '@wordpress/core-data';
|
|
16
16
|
import { store as noticesStore } from '@wordpress/notices';
|
|
17
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
17
18
|
|
|
18
19
|
export default function RenameMenuItem( { template, onClose } ) {
|
|
19
|
-
const
|
|
20
|
+
const title = decodeEntities( template.title.rendered );
|
|
21
|
+
const [ editedTitle, setEditedTitle ] = useState( title );
|
|
20
22
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
21
23
|
|
|
22
24
|
const { editEntityRecord, saveEditedEntityRecord } =
|
|
@@ -33,11 +35,11 @@ export default function RenameMenuItem( { template, onClose } ) {
|
|
|
33
35
|
|
|
34
36
|
try {
|
|
35
37
|
await editEntityRecord( 'postType', template.type, template.id, {
|
|
36
|
-
title,
|
|
38
|
+
title: editedTitle,
|
|
37
39
|
} );
|
|
38
40
|
|
|
39
41
|
// Update state before saving rerenders the list.
|
|
40
|
-
|
|
42
|
+
setEditedTitle( '' );
|
|
41
43
|
setIsModalOpen( false );
|
|
42
44
|
onClose();
|
|
43
45
|
|
|
@@ -67,7 +69,7 @@ export default function RenameMenuItem( { template, onClose } ) {
|
|
|
67
69
|
<MenuItem
|
|
68
70
|
onClick={ () => {
|
|
69
71
|
setIsModalOpen( true );
|
|
70
|
-
|
|
72
|
+
setEditedTitle( title );
|
|
71
73
|
} }
|
|
72
74
|
>
|
|
73
75
|
{ __( 'Rename' ) }
|
|
@@ -85,8 +87,8 @@ export default function RenameMenuItem( { template, onClose } ) {
|
|
|
85
87
|
<TextControl
|
|
86
88
|
__nextHasNoMarginBottom
|
|
87
89
|
label={ __( 'Name' ) }
|
|
88
|
-
value={
|
|
89
|
-
onChange={
|
|
90
|
+
value={ editedTitle }
|
|
91
|
+
onChange={ setEditedTitle }
|
|
90
92
|
required
|
|
91
93
|
/>
|
|
92
94
|
|
|
@@ -18,6 +18,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
18
18
|
import {
|
|
19
19
|
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
|
|
20
20
|
getBlockType,
|
|
21
|
+
hasBlockSupport,
|
|
21
22
|
} from '@wordpress/blocks';
|
|
22
23
|
import { useContext, useMemo, useCallback } from '@wordpress/element';
|
|
23
24
|
import { useDispatch } from '@wordpress/data';
|
|
@@ -93,6 +94,8 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
|
93
94
|
'typography.fontFamily': 'fontFamily',
|
|
94
95
|
};
|
|
95
96
|
|
|
97
|
+
const SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];
|
|
98
|
+
|
|
96
99
|
function useChangesToPush( name, attributes ) {
|
|
97
100
|
const supports = useSupportedStyles( name );
|
|
98
101
|
|
|
@@ -212,10 +215,14 @@ function PushChangesToGlobalStylesControl( {
|
|
|
212
215
|
const withPushChangesToGlobalStyles = createHigherOrderComponent(
|
|
213
216
|
( BlockEdit ) => ( props ) => {
|
|
214
217
|
const blockEditingMode = useBlockEditingMode();
|
|
218
|
+
const supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>
|
|
219
|
+
hasBlockSupport( props.name, feature )
|
|
220
|
+
);
|
|
221
|
+
|
|
215
222
|
return (
|
|
216
223
|
<>
|
|
217
224
|
<BlockEdit { ...props } />
|
|
218
|
-
{ blockEditingMode === 'default' && (
|
|
225
|
+
{ blockEditingMode === 'default' && supportsStyles && (
|
|
219
226
|
<InspectorAdvancedControls>
|
|
220
227
|
<PushChangesToGlobalStylesControl { ...props } />
|
|
221
228
|
</InspectorAdvancedControls>
|
package/src/style.scss
CHANGED
|
@@ -47,27 +47,20 @@
|
|
|
47
47
|
@import "./components/resizable-frame/style.scss";
|
|
48
48
|
@import "./hooks/push-changes-to-global-styles/style.scss";
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
body.js #wpadminbar {
|
|
51
51
|
display: none;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
body.js #wpbody {
|
|
55
55
|
padding-top: 0;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
html.wp-toolbar {
|
|
61
|
-
background: $white;
|
|
62
|
-
padding-top: 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
body.appearance_page_gutenberg-template-parts,
|
|
66
|
-
body.site-editor-php {
|
|
58
|
+
body.js.appearance_page_gutenberg-template-parts,
|
|
59
|
+
body.js.site-editor-php {
|
|
67
60
|
@include wp-admin-reset(".edit-site");
|
|
68
61
|
}
|
|
69
62
|
|
|
70
|
-
body.site-editor-php {
|
|
63
|
+
body.js.site-editor-php {
|
|
71
64
|
background: $gray-900;
|
|
72
65
|
}
|
|
73
66
|
|
|
@@ -91,6 +84,11 @@ body.site-editor-php {
|
|
|
91
84
|
top: 0;
|
|
92
85
|
}
|
|
93
86
|
|
|
87
|
+
.no-js & {
|
|
88
|
+
min-height: 0;
|
|
89
|
+
position: static;
|
|
90
|
+
}
|
|
91
|
+
|
|
94
92
|
.interface-interface-skeleton {
|
|
95
93
|
top: 0;
|
|
96
94
|
}
|
|
@@ -29,7 +29,7 @@ export function useActivateTheme() {
|
|
|
29
29
|
'themes.php?action=activate&stylesheet=' +
|
|
30
30
|
currentlyPreviewingTheme() +
|
|
31
31
|
'&_wpnonce=' +
|
|
32
|
-
window.
|
|
32
|
+
window.WP_BLOCK_THEME_ACTIVATE_NONCE;
|
|
33
33
|
await window.fetch( activationURL );
|
|
34
34
|
const { wp_theme_preview: themePreview, ...params } =
|
|
35
35
|
location.params;
|