@wordpress/edit-site 6.0.3 → 6.0.4
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-page/index.js +7 -1
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +30 -16
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/page-pages/index.js +38 -6
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +8 -2
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +10 -3
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -4
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/components/add-new-page/index.js +8 -2
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +30 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +38 -6
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +8 -2
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +10 -3
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +5 -5
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-style/style-rtl.css +13 -12
- package/build-style/style.css +13 -12
- package/package.json +17 -17
- package/src/components/add-new-page/index.js +14 -1
- package/src/components/add-new-pattern/index.js +37 -23
- package/src/components/block-editor/style.scss +0 -11
- package/src/components/page-pages/index.js +45 -11
- package/src/components/page-patterns/index.js +8 -2
- package/src/components/page-templates/index.js +9 -2
- package/src/components/sidebar-dataviews/default-views.js +13 -5
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
- package/src/style.scss +13 -0
|
@@ -36,21 +36,29 @@ export default function AddNewPattern() {
|
|
|
36
36
|
const [ showPatternModal, setShowPatternModal ] = useState( false );
|
|
37
37
|
const [ showTemplatePartModal, setShowTemplatePartModal ] =
|
|
38
38
|
useState( false );
|
|
39
|
+
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
39
40
|
const { createPatternFromFile } = unlock( useDispatch( patternsStore ) );
|
|
40
41
|
const { createSuccessNotice, createErrorNotice } =
|
|
41
42
|
useDispatch( noticesStore );
|
|
42
43
|
const patternUploadInputRef = useRef();
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const {
|
|
45
|
+
isBlockBasedTheme,
|
|
46
|
+
addNewPatternLabel,
|
|
47
|
+
addNewTemplatePartLabel,
|
|
48
|
+
canCreatePattern,
|
|
49
|
+
canCreateTemplatePart,
|
|
50
|
+
} = useSelect( ( select ) => {
|
|
51
|
+
const { getCurrentTheme, getPostType, canUser } = select( coreStore );
|
|
52
|
+
return {
|
|
53
|
+
isBlockBasedTheme: getCurrentTheme()?.is_block_theme,
|
|
54
|
+
addNewPatternLabel: getPostType( PATTERN_TYPES.user )?.labels
|
|
55
|
+
?.add_new_item,
|
|
56
|
+
addNewTemplatePartLabel: getPostType( TEMPLATE_PART_POST_TYPE )
|
|
57
|
+
?.labels?.add_new_item,
|
|
58
|
+
canCreatePattern: canUser( 'create', 'blocks' ),
|
|
59
|
+
canCreateTemplatePart: canUser( 'create', 'template-parts' ),
|
|
60
|
+
};
|
|
61
|
+
}, [] );
|
|
54
62
|
|
|
55
63
|
function handleCreatePattern( { pattern } ) {
|
|
56
64
|
setShowPatternModal( false );
|
|
@@ -78,15 +86,16 @@ export default function AddNewPattern() {
|
|
|
78
86
|
setShowTemplatePartModal( false );
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
const controls = [
|
|
82
|
-
|
|
89
|
+
const controls = [];
|
|
90
|
+
if ( canCreatePattern ) {
|
|
91
|
+
controls.push( {
|
|
83
92
|
icon: symbol,
|
|
84
93
|
onClick: () => setShowPatternModal( true ),
|
|
85
94
|
title: addNewPatternLabel,
|
|
86
|
-
}
|
|
87
|
-
|
|
95
|
+
} );
|
|
96
|
+
}
|
|
88
97
|
|
|
89
|
-
if ( isBlockBasedTheme ) {
|
|
98
|
+
if ( isBlockBasedTheme && canCreateTemplatePart ) {
|
|
90
99
|
controls.push( {
|
|
91
100
|
icon: symbolFilled,
|
|
92
101
|
onClick: () => setShowTemplatePartModal( true ),
|
|
@@ -94,15 +103,20 @@ export default function AddNewPattern() {
|
|
|
94
103
|
} );
|
|
95
104
|
}
|
|
96
105
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
if ( canCreatePattern ) {
|
|
107
|
+
controls.push( {
|
|
108
|
+
icon: upload,
|
|
109
|
+
onClick: () => {
|
|
110
|
+
patternUploadInputRef.current.click();
|
|
111
|
+
},
|
|
112
|
+
title: __( 'Import pattern from JSON' ),
|
|
113
|
+
} );
|
|
114
|
+
}
|
|
104
115
|
|
|
105
116
|
const { categoryMap, findOrCreateTerm } = useAddPatternCategory();
|
|
117
|
+
if ( controls.length === 0 ) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
106
120
|
return (
|
|
107
121
|
<>
|
|
108
122
|
{ addNewPatternLabel && (
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
/* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */
|
|
2
|
-
::view-transition-old(frame),
|
|
3
|
-
::view-transition-new(frame) {
|
|
4
|
-
animation-duration: 0;
|
|
5
|
-
}
|
|
6
|
-
/* stylelint-enable */
|
|
7
|
-
|
|
8
1
|
.edit-site-visual-editor__editor-canvas {
|
|
9
|
-
/* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */
|
|
10
|
-
view-transition-name: frame;
|
|
11
|
-
/* stylelint-enable */
|
|
12
|
-
|
|
13
2
|
&.is-focused {
|
|
14
3
|
outline: calc(2 * var(--wp-admin-border-width-focus)) solid var(--wp-admin-theme-color);
|
|
15
4
|
outline-offset: calc(-2 * var(--wp-admin-border-width-focus));
|
|
@@ -39,6 +39,7 @@ import AddNewPageModal from '../add-new-page';
|
|
|
39
39
|
import Media from '../media';
|
|
40
40
|
import { unlock } from '../../lock-unlock';
|
|
41
41
|
import { useEditPostAction } from '../dataviews-actions';
|
|
42
|
+
import { usePrevious } from '@wordpress/compose';
|
|
42
43
|
|
|
43
44
|
const { usePostActions } = unlock( editorPrivateApis );
|
|
44
45
|
const { useLocation, useHistory } = unlock( routerPrivateApis );
|
|
@@ -201,10 +202,18 @@ function FeaturedImage( { item, viewType } ) {
|
|
|
201
202
|
);
|
|
202
203
|
}
|
|
203
204
|
|
|
205
|
+
function getItemId( item ) {
|
|
206
|
+
return item.id.toString();
|
|
207
|
+
}
|
|
208
|
+
|
|
204
209
|
export default function PagePages() {
|
|
205
210
|
const postType = 'page';
|
|
206
211
|
const [ view, setView ] = useView( postType );
|
|
207
212
|
const history = useHistory();
|
|
213
|
+
const {
|
|
214
|
+
params: { postId },
|
|
215
|
+
} = useLocation();
|
|
216
|
+
const [ selection, setSelection ] = useState( [ postId ] );
|
|
208
217
|
|
|
209
218
|
const onSelectionChange = useCallback(
|
|
210
219
|
( items ) => {
|
|
@@ -266,6 +275,20 @@ export default function PagePages() {
|
|
|
266
275
|
totalPages,
|
|
267
276
|
} = useEntityRecords( 'postType', postType, queryArgs );
|
|
268
277
|
|
|
278
|
+
const ids = pages?.map( ( page ) => getItemId( page ) ) ?? [];
|
|
279
|
+
const prevIds = usePrevious( ids ) ?? [];
|
|
280
|
+
const deletedIds = prevIds.filter( ( id ) => ! ids.includes( id ) );
|
|
281
|
+
const postIdWasDeleted = deletedIds.includes( postId );
|
|
282
|
+
|
|
283
|
+
useEffect( () => {
|
|
284
|
+
if ( postIdWasDeleted ) {
|
|
285
|
+
history.push( {
|
|
286
|
+
...history.getLocationWithParams().params,
|
|
287
|
+
postId: undefined,
|
|
288
|
+
} );
|
|
289
|
+
}
|
|
290
|
+
}, [ postIdWasDeleted, history ] );
|
|
291
|
+
|
|
269
292
|
const { records: authors, isResolving: isLoadingAuthors } =
|
|
270
293
|
useEntityRecords( 'root', 'user', { per_page: -1 } );
|
|
271
294
|
|
|
@@ -277,15 +300,19 @@ export default function PagePages() {
|
|
|
277
300
|
[ totalItems, totalPages ]
|
|
278
301
|
);
|
|
279
302
|
|
|
280
|
-
const { frontPageId, postsPageId, addNewLabel } = useSelect(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
303
|
+
const { frontPageId, postsPageId, addNewLabel, canCreatePage } = useSelect(
|
|
304
|
+
( select ) => {
|
|
305
|
+
const { getEntityRecord, getPostType, canUser } =
|
|
306
|
+
select( coreStore );
|
|
307
|
+
const siteSettings = getEntityRecord( 'root', 'site' );
|
|
308
|
+
return {
|
|
309
|
+
frontPageId: siteSettings?.page_on_front,
|
|
310
|
+
postsPageId: siteSettings?.page_for_posts,
|
|
311
|
+
addNewLabel: getPostType( 'page' )?.labels?.add_new_item,
|
|
312
|
+
canCreatePage: canUser( 'create', 'pages' ),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
);
|
|
289
316
|
|
|
290
317
|
const fields = useMemo(
|
|
291
318
|
() => [
|
|
@@ -456,7 +483,10 @@ export default function PagePages() {
|
|
|
456
483
|
[ authors, view.type, frontPageId, postsPageId ]
|
|
457
484
|
);
|
|
458
485
|
|
|
459
|
-
const postTypeActions = usePostActions(
|
|
486
|
+
const postTypeActions = usePostActions( {
|
|
487
|
+
postType: 'page',
|
|
488
|
+
context: 'list',
|
|
489
|
+
} );
|
|
460
490
|
const editAction = useEditPostAction();
|
|
461
491
|
const actions = useMemo(
|
|
462
492
|
() => [ editAction, ...postTypeActions ],
|
|
@@ -496,7 +526,8 @@ export default function PagePages() {
|
|
|
496
526
|
<Page
|
|
497
527
|
title={ __( 'Pages' ) }
|
|
498
528
|
actions={
|
|
499
|
-
addNewLabel &&
|
|
529
|
+
addNewLabel &&
|
|
530
|
+
canCreatePage && (
|
|
500
531
|
<>
|
|
501
532
|
<Button
|
|
502
533
|
variant="primary"
|
|
@@ -523,7 +554,10 @@ export default function PagePages() {
|
|
|
523
554
|
isLoading={ isLoadingPages || isLoadingAuthors }
|
|
524
555
|
view={ view }
|
|
525
556
|
onChangeView={ onChangeView }
|
|
557
|
+
selection={ selection }
|
|
558
|
+
setSelection={ setSelection }
|
|
526
559
|
onSelectionChange={ onSelectionChange }
|
|
560
|
+
getItemId={ getItemId }
|
|
527
561
|
/>
|
|
528
562
|
</Page>
|
|
529
563
|
);
|
|
@@ -354,8 +354,14 @@ export default function DataviewsPatterns() {
|
|
|
354
354
|
return filterSortAndPaginate( patterns, viewWithoutFilters, fields );
|
|
355
355
|
}, [ patterns, view, fields, type ] );
|
|
356
356
|
|
|
357
|
-
const templatePartActions = usePostActions(
|
|
358
|
-
|
|
357
|
+
const templatePartActions = usePostActions( {
|
|
358
|
+
postType: TEMPLATE_PART_POST_TYPE,
|
|
359
|
+
context: 'list',
|
|
360
|
+
} );
|
|
361
|
+
const patternActions = usePostActions( {
|
|
362
|
+
postType: PATTERN_TYPES.user,
|
|
363
|
+
context: 'list',
|
|
364
|
+
} );
|
|
359
365
|
const editAction = useEditPostAction();
|
|
360
366
|
|
|
361
367
|
const actions = useMemo( () => {
|
|
@@ -186,7 +186,9 @@ function Preview( { item, viewType } ) {
|
|
|
186
186
|
|
|
187
187
|
export default function PageTemplates() {
|
|
188
188
|
const { params } = useLocation();
|
|
189
|
-
const { activeView = 'all', layout } = params;
|
|
189
|
+
const { activeView = 'all', layout, postId } = params;
|
|
190
|
+
const [ selection, setSelection ] = useState( [ postId ] );
|
|
191
|
+
|
|
190
192
|
const defaultView = useMemo( () => {
|
|
191
193
|
const usedType = layout ?? DEFAULT_VIEW.type;
|
|
192
194
|
return {
|
|
@@ -323,7 +325,10 @@ export default function PageTemplates() {
|
|
|
323
325
|
return filterSortAndPaginate( records, view, fields );
|
|
324
326
|
}, [ records, view, fields ] );
|
|
325
327
|
|
|
326
|
-
const postTypeActions = usePostActions(
|
|
328
|
+
const postTypeActions = usePostActions( {
|
|
329
|
+
postType: TEMPLATE_POST_TYPE,
|
|
330
|
+
context: 'list',
|
|
331
|
+
} );
|
|
327
332
|
const editAction = useEditPostAction();
|
|
328
333
|
const actions = useMemo(
|
|
329
334
|
() => [ editAction, ...postTypeActions ],
|
|
@@ -366,6 +371,8 @@ export default function PageTemplates() {
|
|
|
366
371
|
view={ view }
|
|
367
372
|
onChangeView={ onChangeView }
|
|
368
373
|
onSelectionChange={ onSelectionChange }
|
|
374
|
+
selection={ selection }
|
|
375
|
+
setSelection={ setSelection }
|
|
369
376
|
/>
|
|
370
377
|
</Page>
|
|
371
378
|
);
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
trash,
|
|
7
|
+
pages,
|
|
8
|
+
drafts,
|
|
9
|
+
published,
|
|
10
|
+
scheduled,
|
|
11
|
+
pending,
|
|
12
|
+
notAllowed,
|
|
13
|
+
} from '@wordpress/icons';
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
16
|
* Internal dependencies
|
|
@@ -57,7 +65,7 @@ export const DEFAULT_VIEWS = {
|
|
|
57
65
|
{
|
|
58
66
|
title: __( 'Published' ),
|
|
59
67
|
slug: 'published',
|
|
60
|
-
icon:
|
|
68
|
+
icon: published,
|
|
61
69
|
view: {
|
|
62
70
|
...DEFAULT_PAGE_BASE,
|
|
63
71
|
filters: [
|
|
@@ -72,7 +80,7 @@ export const DEFAULT_VIEWS = {
|
|
|
72
80
|
{
|
|
73
81
|
title: __( 'Scheduled' ),
|
|
74
82
|
slug: 'future',
|
|
75
|
-
icon:
|
|
83
|
+
icon: scheduled,
|
|
76
84
|
view: {
|
|
77
85
|
...DEFAULT_PAGE_BASE,
|
|
78
86
|
filters: [
|
|
@@ -102,7 +110,7 @@ export const DEFAULT_VIEWS = {
|
|
|
102
110
|
{
|
|
103
111
|
title: __( 'Pending' ),
|
|
104
112
|
slug: 'pending',
|
|
105
|
-
icon:
|
|
113
|
+
icon: pending,
|
|
106
114
|
view: {
|
|
107
115
|
...DEFAULT_PAGE_BASE,
|
|
108
116
|
filters: [
|
|
@@ -117,7 +125,7 @@ export const DEFAULT_VIEWS = {
|
|
|
117
125
|
{
|
|
118
126
|
title: __( 'Private' ),
|
|
119
127
|
slug: 'private',
|
|
120
|
-
icon:
|
|
128
|
+
icon: notAllowed,
|
|
121
129
|
view: {
|
|
122
130
|
...DEFAULT_PAGE_BASE,
|
|
123
131
|
filters: [
|