@wordpress/edit-site 6.35.2-next.dc3f6d3c1.0 → 6.36.1-next.8b30e05b0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +109 -0
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.js.map +7 -0
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.js +328 -0
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.js.map +7 -0
- package/build/components/add-new-template-legacy/index.js +389 -0
- package/build/components/add-new-template-legacy/index.js.map +7 -0
- package/build/components/add-new-template-legacy/utils.js +620 -0
- package/build/components/add-new-template-legacy/utils.js.map +7 -0
- package/build/components/page-templates/fields.js +3 -1
- package/build/components/page-templates/fields.js.map +2 -2
- package/build/components/page-templates/index-legacy.js +185 -0
- package/build/components/page-templates/index-legacy.js.map +7 -0
- package/build/components/post-list/index.js +10 -0
- package/build/components/post-list/index.js.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.js +101 -0
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.js.map +7 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +3 -3
- package/build/components/site-editor-routes/templates.js +10 -2
- package/build/components/site-editor-routes/templates.js.map +3 -3
- package/build/components/site-hub/index.js +1 -1
- package/build/components/site-hub/index.js.map +2 -2
- package/build/utils/constants.js +6 -0
- package/build/utils/constants.js.map +2 -2
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +93 -0
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.js.map +7 -0
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js +316 -0
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.js.map +7 -0
- package/build-module/components/add-new-template-legacy/index.js +390 -0
- package/build-module/components/add-new-template-legacy/index.js.map +7 -0
- package/build-module/components/add-new-template-legacy/utils.js +589 -0
- package/build-module/components/add-new-template-legacy/utils.js.map +7 -0
- package/build-module/components/page-templates/fields.js +3 -1
- package/build-module/components/page-templates/fields.js.map +2 -2
- package/build-module/components/page-templates/index-legacy.js +154 -0
- package/build-module/components/page-templates/index-legacy.js.map +7 -0
- package/build-module/components/post-list/index.js +12 -0
- package/build-module/components/post-list/index.js.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js +70 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.js.map +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +2 -2
- package/build-module/components/site-editor-routes/templates.js +10 -2
- package/build-module/components/site-editor-routes/templates.js.map +2 -2
- package/build-module/components/site-hub/index.js +1 -1
- package/build-module/components/site-hub/index.js.map +2 -2
- package/build-module/utils/constants.js +4 -0
- package/build-module/utils/constants.js.map +2 -2
- package/build-style/style-rtl.css +263 -27
- package/build-style/style.css +263 -27
- package/package.json +46 -46
- package/src/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +94 -0
- package/src/components/add-new-template-legacy/add-custom-template-modal-content.js +314 -0
- package/src/components/add-new-template-legacy/index.js +454 -0
- package/src/components/add-new-template-legacy/utils.js +760 -0
- package/src/components/page-templates/fields.js +13 -9
- package/src/components/page-templates/index-legacy.js +166 -0
- package/src/components/post-list/index.js +13 -0
- package/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js +79 -0
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +8 -1
- package/src/components/site-editor-routes/templates.js +22 -3
- package/src/components/site-hub/index.js +1 -1
- package/src/utils/constants.js +2 -0
|
@@ -100,15 +100,19 @@ export const previewField = {
|
|
|
100
100
|
export const descriptionField = {
|
|
101
101
|
label: __( 'Description' ),
|
|
102
102
|
id: 'description',
|
|
103
|
-
render:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
render: window?.__experimentalTemplateActivate
|
|
104
|
+
? function RenderDescription( { item } ) {
|
|
105
|
+
const defaultTemplateTypes = useAllDefaultTemplateTypes();
|
|
106
|
+
const defaultTemplateType = defaultTemplateTypes.find(
|
|
107
|
+
( type ) => type.slug === item.slug
|
|
108
|
+
);
|
|
109
|
+
return item.description
|
|
110
|
+
? decodeEntities( item.description )
|
|
111
|
+
: defaultTemplateType?.description;
|
|
112
|
+
}
|
|
113
|
+
: ( { item } ) => {
|
|
114
|
+
return item.description && decodeEntities( item.description );
|
|
115
|
+
},
|
|
112
116
|
enableSorting: false,
|
|
113
117
|
enableGlobalSearch: true,
|
|
114
118
|
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Page } from '@wordpress/admin-ui';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { useState, useMemo, useCallback } from '@wordpress/element';
|
|
7
|
+
import { privateApis as corePrivateApis } from '@wordpress/core-data';
|
|
8
|
+
import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
|
|
9
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
10
|
+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
11
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
12
|
+
import { useEvent } from '@wordpress/compose';
|
|
13
|
+
import { useView } from '@wordpress/views';
|
|
14
|
+
import { Button } from '@wordpress/components';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import AddNewTemplate from '../add-new-template-legacy';
|
|
20
|
+
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
21
|
+
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import { useEditPostAction } from '../dataviews-actions';
|
|
23
|
+
import { authorField, descriptionField, previewField } from './fields';
|
|
24
|
+
import { defaultLayouts, getDefaultView } from './view-utils';
|
|
25
|
+
|
|
26
|
+
const { usePostActions, templateTitleField } = unlock( editorPrivateApis );
|
|
27
|
+
const { useHistory, useLocation } = unlock( routerPrivateApis );
|
|
28
|
+
const { useEntityRecordsWithPermissions } = unlock( corePrivateApis );
|
|
29
|
+
|
|
30
|
+
export default function PageTemplates() {
|
|
31
|
+
const { path, query } = useLocation();
|
|
32
|
+
const { activeView = 'active', postId } = query;
|
|
33
|
+
const [ selection, setSelection ] = useState( [ postId ] );
|
|
34
|
+
|
|
35
|
+
const defaultView = useMemo( () => {
|
|
36
|
+
return getDefaultView( activeView );
|
|
37
|
+
}, [ activeView ] );
|
|
38
|
+
const { view, updateView, isModified, resetToDefault } = useView( {
|
|
39
|
+
kind: 'postType',
|
|
40
|
+
name: TEMPLATE_POST_TYPE,
|
|
41
|
+
slug: activeView,
|
|
42
|
+
defaultView,
|
|
43
|
+
queryParams: {
|
|
44
|
+
page: query.pageNumber,
|
|
45
|
+
search: query.search,
|
|
46
|
+
},
|
|
47
|
+
onChangeQueryParams: ( newQueryParams ) => {
|
|
48
|
+
history.navigate(
|
|
49
|
+
addQueryArgs( path, {
|
|
50
|
+
...query,
|
|
51
|
+
pageNumber: newQueryParams.page,
|
|
52
|
+
search: newQueryParams.search || undefined,
|
|
53
|
+
} )
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
const { records, isResolving: isLoadingData } =
|
|
59
|
+
useEntityRecordsWithPermissions( 'postType', TEMPLATE_POST_TYPE, {
|
|
60
|
+
per_page: -1,
|
|
61
|
+
} );
|
|
62
|
+
const history = useHistory();
|
|
63
|
+
const onChangeSelection = useCallback(
|
|
64
|
+
( items ) => {
|
|
65
|
+
setSelection( items );
|
|
66
|
+
if ( view?.type === 'list' ) {
|
|
67
|
+
history.navigate(
|
|
68
|
+
addQueryArgs( path, {
|
|
69
|
+
postId: items.length === 1 ? items[ 0 ] : undefined,
|
|
70
|
+
} )
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[ history, path, view?.type ]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const authors = useMemo( () => {
|
|
78
|
+
if ( ! records ) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const authorsSet = new Set();
|
|
82
|
+
records.forEach( ( template ) => {
|
|
83
|
+
authorsSet.add( template.author_text );
|
|
84
|
+
} );
|
|
85
|
+
return Array.from( authorsSet ).map( ( author ) => ( {
|
|
86
|
+
value: author,
|
|
87
|
+
label: author,
|
|
88
|
+
} ) );
|
|
89
|
+
}, [ records ] );
|
|
90
|
+
|
|
91
|
+
const fields = useMemo(
|
|
92
|
+
() => [
|
|
93
|
+
previewField,
|
|
94
|
+
templateTitleField,
|
|
95
|
+
descriptionField,
|
|
96
|
+
{
|
|
97
|
+
...authorField,
|
|
98
|
+
elements: authors,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
[ authors ]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const { data, paginationInfo } = useMemo( () => {
|
|
105
|
+
return filterSortAndPaginate( records, view, fields );
|
|
106
|
+
}, [ records, view, fields ] );
|
|
107
|
+
|
|
108
|
+
const postTypeActions = usePostActions( {
|
|
109
|
+
postType: TEMPLATE_POST_TYPE,
|
|
110
|
+
context: 'list',
|
|
111
|
+
} );
|
|
112
|
+
const editAction = useEditPostAction();
|
|
113
|
+
const actions = useMemo(
|
|
114
|
+
() => [ editAction, ...postTypeActions ],
|
|
115
|
+
[ postTypeActions, editAction ]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const onChangeView = useEvent( ( newView ) => {
|
|
119
|
+
if ( newView.type !== view.type ) {
|
|
120
|
+
// Retrigger the routing areas resolution.
|
|
121
|
+
history.invalidate();
|
|
122
|
+
}
|
|
123
|
+
updateView( newView );
|
|
124
|
+
} );
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<Page
|
|
128
|
+
className="edit-site-page-templates"
|
|
129
|
+
title={ __( 'Templates' ) }
|
|
130
|
+
actions={
|
|
131
|
+
<>
|
|
132
|
+
{ isModified && (
|
|
133
|
+
<Button
|
|
134
|
+
__next40pxDefaultSize
|
|
135
|
+
onClick={ () => {
|
|
136
|
+
resetToDefault();
|
|
137
|
+
history.invalidate();
|
|
138
|
+
} }
|
|
139
|
+
>
|
|
140
|
+
{ __( 'Reset view' ) }
|
|
141
|
+
</Button>
|
|
142
|
+
) }
|
|
143
|
+
<AddNewTemplate />
|
|
144
|
+
</>
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
<DataViews
|
|
148
|
+
key={ activeView }
|
|
149
|
+
paginationInfo={ paginationInfo }
|
|
150
|
+
fields={ fields }
|
|
151
|
+
actions={ actions }
|
|
152
|
+
data={ data }
|
|
153
|
+
isLoading={ isLoadingData }
|
|
154
|
+
view={ view }
|
|
155
|
+
onChangeView={ onChangeView }
|
|
156
|
+
onChangeSelection={ onChangeSelection }
|
|
157
|
+
isItemClickable={ () => true }
|
|
158
|
+
onClickItem={ ( { id } ) => {
|
|
159
|
+
history.navigate( `/wp_template/${ id }?canvas=edit` );
|
|
160
|
+
} }
|
|
161
|
+
selection={ selection }
|
|
162
|
+
defaultLayouts={ defaultLayouts }
|
|
163
|
+
/>
|
|
164
|
+
</Page>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
@@ -24,6 +24,8 @@ import { useView } from '@wordpress/views';
|
|
|
24
24
|
import {
|
|
25
25
|
OPERATOR_IS_ANY,
|
|
26
26
|
OPERATOR_IS_NONE,
|
|
27
|
+
OPERATOR_BEFORE,
|
|
28
|
+
OPERATOR_AFTER,
|
|
27
29
|
LAYOUT_LIST,
|
|
28
30
|
} from '../../utils/constants';
|
|
29
31
|
|
|
@@ -123,6 +125,17 @@ export default function PostList( { postType } ) {
|
|
|
123
125
|
) {
|
|
124
126
|
filters.author_exclude = filter.value;
|
|
125
127
|
}
|
|
128
|
+
if ( filter.field === 'date' ) {
|
|
129
|
+
// Skip if no value is set yet
|
|
130
|
+
if ( ! filter.value ) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if ( filter.operator === OPERATOR_BEFORE ) {
|
|
134
|
+
filters.before = filter.value;
|
|
135
|
+
} else if ( filter.operator === OPERATOR_AFTER ) {
|
|
136
|
+
filters.after = filter.value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
126
139
|
} );
|
|
127
140
|
|
|
128
141
|
// We want to provide a different default item for the status filter
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEntityRecords } from '@wordpress/core-data';
|
|
5
|
+
import { useMemo } from '@wordpress/element';
|
|
6
|
+
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
9
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
15
|
+
import { useAddedBy } from '../page-templates/hooks';
|
|
16
|
+
import { layout } from '@wordpress/icons';
|
|
17
|
+
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
|
|
20
|
+
const { useLocation } = unlock( routerPrivateApis );
|
|
21
|
+
|
|
22
|
+
const EMPTY_ARRAY = [];
|
|
23
|
+
|
|
24
|
+
function TemplateDataviewItem( { template, isActive } ) {
|
|
25
|
+
const { text, icon } = useAddedBy( template.type, template.id );
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<SidebarNavigationItem
|
|
29
|
+
to={ addQueryArgs( '/template', { activeView: text } ) }
|
|
30
|
+
icon={ icon }
|
|
31
|
+
aria-current={ isActive }
|
|
32
|
+
>
|
|
33
|
+
{ text }
|
|
34
|
+
</SidebarNavigationItem>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function DataviewsTemplatesSidebarContent() {
|
|
39
|
+
const {
|
|
40
|
+
query: { activeView = 'all' },
|
|
41
|
+
} = useLocation();
|
|
42
|
+
const { records } = useEntityRecords( 'postType', TEMPLATE_POST_TYPE, {
|
|
43
|
+
per_page: -1,
|
|
44
|
+
} );
|
|
45
|
+
const firstItemPerAuthorText = useMemo( () => {
|
|
46
|
+
const firstItemPerAuthor = records?.reduce( ( acc, template ) => {
|
|
47
|
+
const author = template.author_text;
|
|
48
|
+
if ( author && ! acc[ author ] ) {
|
|
49
|
+
acc[ author ] = template;
|
|
50
|
+
}
|
|
51
|
+
return acc;
|
|
52
|
+
}, {} );
|
|
53
|
+
return (
|
|
54
|
+
( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??
|
|
55
|
+
EMPTY_ARRAY
|
|
56
|
+
);
|
|
57
|
+
}, [ records ] );
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<ItemGroup className="edit-site-sidebar-navigation-screen-templates-browse">
|
|
61
|
+
<SidebarNavigationItem
|
|
62
|
+
to="/template"
|
|
63
|
+
icon={ layout }
|
|
64
|
+
aria-current={ activeView === 'all' }
|
|
65
|
+
>
|
|
66
|
+
{ __( 'All templates' ) }
|
|
67
|
+
</SidebarNavigationItem>
|
|
68
|
+
{ firstItemPerAuthorText.map( ( template ) => {
|
|
69
|
+
return (
|
|
70
|
+
<TemplateDataviewItem
|
|
71
|
+
key={ template.author_text }
|
|
72
|
+
template={ template }
|
|
73
|
+
isActive={ activeView === template.author_text }
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
} ) }
|
|
77
|
+
</ItemGroup>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -8,6 +8,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
8
8
|
*/
|
|
9
9
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
10
10
|
import DataviewsTemplatesSidebarContent from './content';
|
|
11
|
+
import DataviewsTemplatesSidebarContentLegacy from './content-legacy';
|
|
11
12
|
|
|
12
13
|
export default function SidebarNavigationScreenTemplatesBrowse( { backPath } ) {
|
|
13
14
|
return (
|
|
@@ -17,7 +18,13 @@ export default function SidebarNavigationScreenTemplatesBrowse( { backPath } ) {
|
|
|
17
18
|
'Create new templates, or reset any customizations made to the templates supplied by your theme.'
|
|
18
19
|
) }
|
|
19
20
|
backPath={ backPath }
|
|
20
|
-
content={
|
|
21
|
+
content={
|
|
22
|
+
window?.__experimentalTemplateActivate ? (
|
|
23
|
+
<DataviewsTemplatesSidebarContent />
|
|
24
|
+
) : (
|
|
25
|
+
<DataviewsTemplatesSidebarContentLegacy />
|
|
26
|
+
)
|
|
27
|
+
}
|
|
21
28
|
/>
|
|
22
29
|
);
|
|
23
30
|
}
|
|
@@ -10,6 +10,7 @@ import Editor from '../editor';
|
|
|
10
10
|
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
|
|
11
11
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
12
12
|
import PageTemplates from '../page-templates';
|
|
13
|
+
import PageTemplatesLegacy from '../page-templates/index-legacy';
|
|
13
14
|
import { getDefaultView } from '../page-templates/view-utils';
|
|
14
15
|
|
|
15
16
|
async function isTemplateListView( query ) {
|
|
@@ -37,7 +38,16 @@ export const templatesRoute = {
|
|
|
37
38
|
},
|
|
38
39
|
content( { siteData } ) {
|
|
39
40
|
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
40
|
-
|
|
41
|
+
if ( ! isBlockTheme ) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
// Use the new template activation system if experiment is enabled,
|
|
45
|
+
// otherwise use the legacy simple template list.
|
|
46
|
+
return window?.__experimentalTemplateActivate ? (
|
|
47
|
+
<PageTemplates />
|
|
48
|
+
) : (
|
|
49
|
+
<PageTemplatesLegacy />
|
|
50
|
+
);
|
|
41
51
|
},
|
|
42
52
|
async preview( { query, siteData } ) {
|
|
43
53
|
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
@@ -49,10 +59,19 @@ export const templatesRoute = {
|
|
|
49
59
|
},
|
|
50
60
|
mobile( { siteData } ) {
|
|
51
61
|
const isBlockTheme = siteData.currentTheme?.is_block_theme;
|
|
52
|
-
|
|
62
|
+
if ( ! isBlockTheme ) {
|
|
63
|
+
return <SidebarNavigationScreenUnsupported />;
|
|
64
|
+
}
|
|
65
|
+
// Check if the template activation experiment is enabled.
|
|
66
|
+
const isTemplateActivateEnabled =
|
|
67
|
+
typeof window !== 'undefined' &&
|
|
68
|
+
window.__experimentalTemplateActivate;
|
|
69
|
+
// Use the new template activation system if experiment is enabled,
|
|
70
|
+
// otherwise use the legacy simple template list.
|
|
71
|
+
return isTemplateActivateEnabled ? (
|
|
53
72
|
<PageTemplates />
|
|
54
73
|
) : (
|
|
55
|
-
<
|
|
74
|
+
<PageTemplatesLegacy />
|
|
56
75
|
);
|
|
57
76
|
},
|
|
58
77
|
},
|
|
@@ -134,7 +134,7 @@ export const SiteHubMobile = memo(
|
|
|
134
134
|
const currentTheme = getCurrentTheme();
|
|
135
135
|
const settings = getSettings();
|
|
136
136
|
const supportsEditorStyles =
|
|
137
|
-
currentTheme
|
|
137
|
+
currentTheme?.theme_supports[ 'editor-styles' ];
|
|
138
138
|
// This is a temp solution until the has_theme_json value is available for the current theme.
|
|
139
139
|
const hasThemeJson = settings.supportsLayout;
|
|
140
140
|
|
package/src/utils/constants.js
CHANGED