@wordpress/edit-site 6.3.0 → 6.4.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 +2 -0
- package/build/components/add-new-pattern/index.js +8 -2
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/index.js +3 -1
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +1 -82
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +14 -5
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +42 -23
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +4 -4
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +58 -10
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js +44 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size.js +213 -0
- package/build/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js +50 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes.js +163 -0
- package/build/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js +67 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/screen-block.js +10 -8
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +3 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/size-control/index.js +85 -0
- package/build/components/global-styles/size-control/index.js.map +1 -0
- package/build/components/global-styles/style-variations-container.js +3 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +8 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +1 -1
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/layout/index.js +6 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +14 -6
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-patterns/header.js +1 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +23 -11
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +41 -34
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/post-edit/index.js +105 -0
- package/build/components/post-edit/index.js.map +1 -0
- package/build/components/post-fields/index.js +314 -0
- package/build/components/post-fields/index.js.map +1 -0
- package/build/components/post-list/index.js +281 -0
- package/build/components/post-list/index.js.map +1 -0
- package/build/components/posts-app/router.js +3 -3
- package/build/components/posts-app/router.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +22 -10
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +40 -1
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/content.js +64 -0
- package/build/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +34 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-filtered-template-parts.js +64 -0
- package/build/utils/get-filtered-template-parts.js.map +1 -0
- package/build-module/components/add-new-pattern/index.js +8 -2
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/index.js +3 -1
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +1 -82
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +14 -5
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +44 -25
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +4 -4
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +61 -13
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js +37 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size.js +207 -0
- package/build-module/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js +43 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js +157 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js +61 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +10 -8
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/size-control/index.js +79 -0
- package/build-module/components/global-styles/size-control/index.js.map +1 -0
- package/build-module/components/global-styles/style-variations-container.js +3 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +8 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +1 -1
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +1 -2
- package/build-module/components/global-styles/variations/variations-typography.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/layout/router.js +14 -6
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-patterns/header.js +1 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +23 -11
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +43 -37
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +98 -0
- package/build-module/components/post-edit/index.js.map +1 -0
- package/build-module/components/post-fields/index.js +306 -0
- package/build-module/components/post-fields/index.js.map +1 -0
- package/build-module/components/post-list/index.js +275 -0
- package/build-module/components/post-list/index.js.map +1 -0
- package/build-module/components/posts-app/router.js +3 -3
- package/build-module/components/posts-app/router.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +21 -9
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +42 -3
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js +57 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/index.js +5 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +35 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-filtered-template-parts.js +57 -0
- package/build-module/utils/get-filtered-template-parts.js.map +1 -0
- package/build-style/posts-rtl.css +581 -503
- package/build-style/posts.css +581 -503
- package/build-style/style-rtl.css +621 -519
- package/build-style/style.css +621 -519
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +8 -2
- package/src/components/add-new-template/index.js +4 -1
- package/src/components/add-new-template/style.scss +4 -6
- package/src/components/block-editor/use-site-editor-settings.js +15 -111
- package/src/components/global-styles/block-preview-panel.js +22 -9
- package/src/components/global-styles/font-families.js +66 -31
- package/src/components/global-styles/font-library-modal/index.js +4 -2
- package/src/components/global-styles/font-library-modal/installed-fonts.js +92 -11
- package/src/components/global-styles/font-library-modal/style.scss +9 -0
- package/src/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +43 -0
- package/src/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +37 -0
- package/src/components/global-styles/font-sizes/font-size-preview.js +43 -0
- package/src/components/global-styles/font-sizes/font-size.js +250 -0
- package/src/components/global-styles/font-sizes/font-sizes-count.js +40 -0
- package/src/components/global-styles/font-sizes/font-sizes.js +263 -0
- package/src/components/global-styles/font-sizes/rename-font-size-dialog.js +70 -0
- package/src/components/global-styles/screen-block.js +12 -14
- package/src/components/global-styles/screen-style-variations.js +2 -2
- package/src/components/global-styles/screen-typography.js +3 -2
- package/src/components/global-styles/size-control/index.js +86 -0
- package/src/components/global-styles/style-variations-container.js +4 -0
- package/src/components/global-styles/style.scss +13 -3
- package/src/components/global-styles/ui.js +10 -0
- package/src/components/global-styles/variations/variations-color.js +1 -1
- package/src/components/global-styles/variations/variations-typography.js +1 -2
- package/src/components/layout/index.js +11 -0
- package/src/components/layout/router.js +13 -5
- package/src/components/layout/style.scss +26 -8
- package/src/components/page-patterns/header.js +1 -1
- package/src/components/page-patterns/index.js +15 -8
- package/src/components/page-templates/index.js +51 -46
- package/src/components/page-templates/style.scss +5 -3
- package/src/components/post-edit/index.js +96 -0
- package/src/components/post-edit/style.scss +9 -0
- package/src/components/post-fields/index.js +345 -0
- package/src/components/post-list/index.js +326 -0
- package/src/components/{posts-app → post-list}/style.scss +12 -9
- package/src/components/posts-app/router.js +3 -3
- package/src/components/sidebar-dataviews/default-views.js +21 -9
- package/src/components/sidebar-dataviews/index.js +36 -1
- package/src/components/sidebar-navigation-screen-global-styles/content.js +55 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -55
- package/src/hooks/push-changes-to-global-styles/index.js +1 -1
- package/src/index.js +7 -1
- package/src/posts.scss +1 -1
- package/src/store/selectors.js +53 -14
- package/src/store/test/selectors.js +1 -26
- package/src/style.scss +2 -1
- package/src/utils/get-filtered-template-parts.js +61 -0
- package/src/utils/test/get-filtered-template-parts.js +127 -0
- package/build/components/global-styles/screen-background.js +0 -36
- package/build/components/global-styles/screen-background.js.map +0 -1
- package/build/components/posts-app/posts-list.js +0 -568
- package/build/components/posts-app/posts-list.js.map +0 -1
- package/build-module/components/global-styles/screen-background.js +0 -30
- package/build-module/components/global-styles/screen-background.js.map +0 -1
- package/build-module/components/posts-app/posts-list.js +0 -560
- package/build-module/components/posts-app/posts-list.js.map +0 -1
- package/src/components/global-styles/screen-background.js +0 -29
- package/src/components/posts-app/posts-list.js +0 -651
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
.
|
|
1
|
+
.edit-site-post-list__featured-image {
|
|
2
2
|
height: 100%;
|
|
3
3
|
object-fit: cover;
|
|
4
4
|
width: 100%;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.
|
|
7
|
+
.edit-site-post-list__featured-image-wrapper {
|
|
8
8
|
height: 100%;
|
|
9
9
|
width: 100%;
|
|
10
10
|
border-radius: $grid-unit-05;
|
|
11
11
|
|
|
12
|
-
&.is-layout-table:not(:has(.
|
|
13
|
-
&.is-layout-table .
|
|
12
|
+
&.is-layout-table:not(:has(.edit-site-post-list__featured-image-button)),
|
|
13
|
+
&.is-layout-table .edit-site-post-list__featured-image-button {
|
|
14
14
|
width: $grid-unit-40;
|
|
15
15
|
height: $grid-unit-40;
|
|
16
16
|
display: block;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.
|
|
36
|
+
.edit-site-post-list__featured-image-button {
|
|
37
37
|
box-shadow: none;
|
|
38
38
|
border: none;
|
|
39
39
|
padding: 0;
|
|
@@ -53,18 +53,18 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.dataviews-view-grid__card.is-selected {
|
|
56
|
-
.
|
|
56
|
+
.edit-site-post-list__featured-image-button::after {
|
|
57
57
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
58
58
|
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
.
|
|
62
|
+
.edit-site-post-list__title span {
|
|
63
63
|
text-overflow: ellipsis;
|
|
64
64
|
overflow: hidden;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.
|
|
67
|
+
.edit-site-post-list__title-badge {
|
|
68
68
|
background: $gray-100;
|
|
69
69
|
color: $gray-700;
|
|
70
70
|
padding: 0 $grid-unit-05;
|
|
@@ -72,11 +72,14 @@
|
|
|
72
72
|
font-size: 12px;
|
|
73
73
|
font-weight: 400;
|
|
74
74
|
flex-shrink: 0;
|
|
75
|
+
line-height: $grid-unit-05 * 5;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
.
|
|
78
|
+
.edit-site-post-list__status-icon {
|
|
78
79
|
height: $grid-unit-30;
|
|
80
|
+
width: $grid-unit-30;
|
|
79
81
|
svg {
|
|
80
82
|
fill: currentColor;
|
|
83
|
+
margin-left: -$grid-unit-05;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -13,7 +13,7 @@ import Editor from '../editor';
|
|
|
13
13
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
14
14
|
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
|
|
15
15
|
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
16
|
-
import
|
|
16
|
+
import PostList from '../post-list';
|
|
17
17
|
|
|
18
18
|
const { useLocation } = unlock( routerPrivateApis );
|
|
19
19
|
|
|
@@ -40,7 +40,7 @@ export default function useLayoutAreas() {
|
|
|
40
40
|
content={ <DataViewsSidebarContent /> }
|
|
41
41
|
/>
|
|
42
42
|
),
|
|
43
|
-
content: <
|
|
43
|
+
content: <PostList postType={ postType } />,
|
|
44
44
|
preview: ( isListLayout || canvas === 'edit' ) && (
|
|
45
45
|
<Editor isPostsList />
|
|
46
46
|
),
|
|
@@ -48,7 +48,7 @@ export default function useLayoutAreas() {
|
|
|
48
48
|
canvas === 'edit' ? (
|
|
49
49
|
<Editor isPostsList />
|
|
50
50
|
) : (
|
|
51
|
-
<
|
|
51
|
+
<PostList postType={ postType } />
|
|
52
52
|
),
|
|
53
53
|
},
|
|
54
54
|
widths: {
|
|
@@ -26,17 +26,31 @@ import {
|
|
|
26
26
|
OPERATOR_IS_ANY,
|
|
27
27
|
} from '../../utils/constants';
|
|
28
28
|
|
|
29
|
-
export const
|
|
29
|
+
export const defaultLayouts = {
|
|
30
30
|
[ LAYOUT_TABLE ]: {
|
|
31
|
-
|
|
31
|
+
layout: {
|
|
32
|
+
primaryField: 'title',
|
|
33
|
+
styles: {
|
|
34
|
+
'featured-image': {
|
|
35
|
+
width: '1%',
|
|
36
|
+
},
|
|
37
|
+
title: {
|
|
38
|
+
maxWidth: 300,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
32
42
|
},
|
|
33
43
|
[ LAYOUT_GRID ]: {
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
layout: {
|
|
45
|
+
mediaField: 'featured-image',
|
|
46
|
+
primaryField: 'title',
|
|
47
|
+
},
|
|
36
48
|
},
|
|
37
49
|
[ LAYOUT_LIST ]: {
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
layout: {
|
|
51
|
+
primaryField: 'title',
|
|
52
|
+
mediaField: 'featured-image',
|
|
53
|
+
},
|
|
40
54
|
},
|
|
41
55
|
};
|
|
42
56
|
|
|
@@ -51,9 +65,7 @@ const DEFAULT_POST_BASE = {
|
|
|
51
65
|
direction: 'desc',
|
|
52
66
|
},
|
|
53
67
|
fields: [ 'title', 'author', 'status' ],
|
|
54
|
-
layout:
|
|
55
|
-
...DEFAULT_CONFIG_PER_VIEW_TYPE[ LAYOUT_LIST ],
|
|
56
|
-
},
|
|
68
|
+
layout: defaultLayouts[ LAYOUT_LIST ].layout,
|
|
57
69
|
};
|
|
58
70
|
|
|
59
71
|
export function useDefaultViews( { postType } ) {
|
|
@@ -3,20 +3,55 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
5
5
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
6
|
+
import { useRef, useEffect } from '@wordpress/element';
|
|
7
|
+
import { usePrevious } from '@wordpress/compose';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
9
11
|
*/
|
|
10
12
|
import { useDefaultViews } from './default-views';
|
|
11
13
|
import { unlock } from '../../lock-unlock';
|
|
12
|
-
const { useLocation } = unlock( routerPrivateApis );
|
|
13
14
|
import DataViewItem from './dataview-item';
|
|
14
15
|
import CustomDataViewsList from './custom-dataviews-list';
|
|
15
16
|
|
|
17
|
+
const { useLocation, useHistory } = unlock( routerPrivateApis );
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Hook to switch to table layout when switching to the trash view.
|
|
21
|
+
* When going out of the trash view, it switches back to the previous layout if
|
|
22
|
+
* there was an automatic switch to table layout.
|
|
23
|
+
*/
|
|
24
|
+
function useSwitchToTableOnTrash() {
|
|
25
|
+
const {
|
|
26
|
+
params: { activeView, layout, ...restParams },
|
|
27
|
+
} = useLocation();
|
|
28
|
+
const history = useHistory();
|
|
29
|
+
const viewToSwitchOutOfTrash = useRef( undefined );
|
|
30
|
+
const previousActiveView = usePrevious( activeView );
|
|
31
|
+
useEffect( () => {
|
|
32
|
+
if ( activeView === 'trash' && previousActiveView !== 'trash' ) {
|
|
33
|
+
viewToSwitchOutOfTrash.current = layout || 'list';
|
|
34
|
+
history.push( { ...restParams, layout: 'table', activeView } );
|
|
35
|
+
} else if (
|
|
36
|
+
previousActiveView === 'trash' &&
|
|
37
|
+
activeView !== 'trash' &&
|
|
38
|
+
viewToSwitchOutOfTrash.current
|
|
39
|
+
) {
|
|
40
|
+
history.push( {
|
|
41
|
+
...restParams,
|
|
42
|
+
layout: viewToSwitchOutOfTrash.current,
|
|
43
|
+
activeView,
|
|
44
|
+
} );
|
|
45
|
+
viewToSwitchOutOfTrash.current = undefined;
|
|
46
|
+
}
|
|
47
|
+
}, [ previousActiveView, activeView, layout, history, restParams ] );
|
|
48
|
+
}
|
|
49
|
+
|
|
16
50
|
export default function DataViewsSidebarContent() {
|
|
17
51
|
const {
|
|
18
52
|
params: { postType, activeView = 'all', isCustom = 'false' },
|
|
19
53
|
} = useLocation();
|
|
54
|
+
useSwitchToTableOnTrash();
|
|
20
55
|
const DEFAULT_VIEWS = useDefaultViews( { postType } );
|
|
21
56
|
if ( ! postType ) {
|
|
22
57
|
return null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
|
+
import { BlockEditorProvider } from '@wordpress/block-editor';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import StyleVariationsContainer from '../global-styles/style-variations-container';
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
15
|
+
import ColorVariations from '../global-styles/variations/variations-color';
|
|
16
|
+
import TypographyVariations from '../global-styles/variations/variations-typography';
|
|
17
|
+
|
|
18
|
+
const noop = () => {};
|
|
19
|
+
|
|
20
|
+
export default function SidebarNavigationScreenGlobalStylesContent() {
|
|
21
|
+
const { storedSettings } = useSelect( ( select ) => {
|
|
22
|
+
const { getSettings } = unlock( select( editSiteStore ) );
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
storedSettings: getSettings(),
|
|
26
|
+
};
|
|
27
|
+
}, [] );
|
|
28
|
+
|
|
29
|
+
const gap = 3;
|
|
30
|
+
|
|
31
|
+
// Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
|
|
32
|
+
// loaded. This is necessary because the Iframe component waits until
|
|
33
|
+
// the block editor store's `__internalIsInitialized` is true before
|
|
34
|
+
// rendering the iframe. Without this, the iframe previews will not render
|
|
35
|
+
// in mobile viewport sizes, where the editor canvas is hidden.
|
|
36
|
+
return (
|
|
37
|
+
<BlockEditorProvider
|
|
38
|
+
settings={ storedSettings }
|
|
39
|
+
onChange={ noop }
|
|
40
|
+
onInput={ noop }
|
|
41
|
+
>
|
|
42
|
+
<VStack
|
|
43
|
+
spacing={ 10 }
|
|
44
|
+
className="edit-site-global-styles-variation-container"
|
|
45
|
+
>
|
|
46
|
+
<StyleVariationsContainer gap={ gap } />
|
|
47
|
+
<ColorVariations title={ __( 'Palettes' ) } gap={ gap } />
|
|
48
|
+
<TypographyVariations
|
|
49
|
+
title={ __( 'Typography' ) }
|
|
50
|
+
gap={ gap }
|
|
51
|
+
/>
|
|
52
|
+
</VStack>
|
|
53
|
+
</BlockEditorProvider>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -5,9 +5,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
5
5
|
import { edit, seen } from '@wordpress/icons';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
-
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
9
8
|
import { useViewportMatch } from '@wordpress/compose';
|
|
10
|
-
import { BlockEditorProvider } from '@wordpress/block-editor';
|
|
11
9
|
import { useCallback } from '@wordpress/element';
|
|
12
10
|
import { store as editorStore } from '@wordpress/editor';
|
|
13
11
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -16,7 +14,6 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
16
14
|
* Internal dependencies
|
|
17
15
|
*/
|
|
18
16
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
19
|
-
import StyleVariationsContainer from '../global-styles/style-variations-container';
|
|
20
17
|
import { unlock } from '../../lock-unlock';
|
|
21
18
|
import { store as editSiteStore } from '../../store';
|
|
22
19
|
import SidebarButton from '../sidebar-button';
|
|
@@ -24,11 +21,7 @@ import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
|
24
21
|
import StyleBook from '../style-book';
|
|
25
22
|
import useGlobalStylesRevisions from '../global-styles/screen-revisions/use-global-styles-revisions';
|
|
26
23
|
import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';
|
|
27
|
-
import
|
|
28
|
-
import TypographyVariations from '../global-styles/variations/variations-typography';
|
|
29
|
-
import { useCurrentMergeThemeStyleVariationsWithUserConfig } from '../../hooks/use-theme-style-variations/use-theme-style-variations-by-property';
|
|
30
|
-
|
|
31
|
-
const noop = () => {};
|
|
24
|
+
import SidebarNavigationScreenGlobalStylesContent from './content';
|
|
32
25
|
|
|
33
26
|
export function SidebarNavigationItemGlobalStyles( props ) {
|
|
34
27
|
const { openGeneralSidebar } = useDispatch( editSiteStore );
|
|
@@ -63,53 +56,6 @@ export function SidebarNavigationItemGlobalStyles( props ) {
|
|
|
63
56
|
);
|
|
64
57
|
}
|
|
65
58
|
|
|
66
|
-
function SidebarNavigationScreenGlobalStylesContent() {
|
|
67
|
-
const { storedSettings } = useSelect( ( select ) => {
|
|
68
|
-
const { getSettings } = unlock( select( editSiteStore ) );
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
storedSettings: getSettings(),
|
|
72
|
-
};
|
|
73
|
-
}, [] );
|
|
74
|
-
|
|
75
|
-
const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig( [
|
|
76
|
-
'color',
|
|
77
|
-
] );
|
|
78
|
-
const typographyVariations =
|
|
79
|
-
useCurrentMergeThemeStyleVariationsWithUserConfig( [ 'typography' ] );
|
|
80
|
-
|
|
81
|
-
const gap = 3;
|
|
82
|
-
|
|
83
|
-
// Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
|
|
84
|
-
// loaded. This is necessary because the Iframe component waits until
|
|
85
|
-
// the block editor store's `__internalIsInitialized` is true before
|
|
86
|
-
// rendering the iframe. Without this, the iframe previews will not render
|
|
87
|
-
// in mobile viewport sizes, where the editor canvas is hidden.
|
|
88
|
-
return (
|
|
89
|
-
<BlockEditorProvider
|
|
90
|
-
settings={ storedSettings }
|
|
91
|
-
onChange={ noop }
|
|
92
|
-
onInput={ noop }
|
|
93
|
-
>
|
|
94
|
-
<VStack
|
|
95
|
-
spacing={ 10 }
|
|
96
|
-
className="edit-site-global-styles-variation-container"
|
|
97
|
-
>
|
|
98
|
-
<StyleVariationsContainer gap={ gap } />
|
|
99
|
-
{ colorVariations?.length && (
|
|
100
|
-
<ColorVariations title={ __( 'Palettes' ) } gap={ gap } />
|
|
101
|
-
) }
|
|
102
|
-
{ typographyVariations?.length && (
|
|
103
|
-
<TypographyVariations
|
|
104
|
-
title={ __( 'Typography' ) }
|
|
105
|
-
gap={ gap }
|
|
106
|
-
/>
|
|
107
|
-
) }
|
|
108
|
-
</VStack>
|
|
109
|
-
</BlockEditorProvider>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
59
|
export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
|
|
114
60
|
const { revisions, isLoading: isLoadingRevisions } =
|
|
115
61
|
useGlobalStylesRevisions();
|
|
@@ -375,7 +375,7 @@ function PushChangesToGlobalStyles( props ) {
|
|
|
375
375
|
const withPushChangesToGlobalStyles = createHigherOrderComponent(
|
|
376
376
|
( BlockEdit ) => ( props ) => (
|
|
377
377
|
<>
|
|
378
|
-
<BlockEdit { ...props } />
|
|
378
|
+
<BlockEdit key="edit" { ...props } />
|
|
379
379
|
{ props.isSelected && <PushChangesToGlobalStyles { ...props } /> }
|
|
380
380
|
</>
|
|
381
381
|
)
|
package/src/index.js
CHANGED
|
@@ -28,7 +28,11 @@ import { store as editSiteStore } from './store';
|
|
|
28
28
|
import { unlock } from './lock-unlock';
|
|
29
29
|
import App from './components/app';
|
|
30
30
|
|
|
31
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
registerDefaultActions,
|
|
33
|
+
registerCoreBlockBindingsSources,
|
|
34
|
+
bootstrapBlockBindingsSourcesFromServer,
|
|
35
|
+
} = unlock( editorPrivateApis );
|
|
32
36
|
|
|
33
37
|
/**
|
|
34
38
|
* Initializes the site editor screen.
|
|
@@ -45,6 +49,8 @@ export function initializeEditor( id, settings ) {
|
|
|
45
49
|
( { name } ) => name !== 'core/freeform'
|
|
46
50
|
);
|
|
47
51
|
registerCoreBlocks( coreBlocks );
|
|
52
|
+
bootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );
|
|
53
|
+
registerCoreBlockBindingsSources();
|
|
48
54
|
dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );
|
|
49
55
|
registerLegacyWidgetBlock( { inserter: false } );
|
|
50
56
|
registerWidgetGroupBlock( { inserter: false } );
|
package/src/posts.scss
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
@import "./components/site-hub/style.scss";
|
|
8
8
|
@import "./components/site-icon/style.scss";
|
|
9
9
|
@import "./components/editor-canvas-container/style.scss";
|
|
10
|
-
@import "./components/
|
|
10
|
+
@import "./components/post-list/style.scss";
|
|
11
11
|
@import "./components/resizable-frame/style.scss";
|
|
12
12
|
|
|
13
13
|
@include wordpress-admin-schemes();
|
package/src/store/selectors.js
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
5
|
-
import { createRegistrySelector } from '@wordpress/data';
|
|
5
|
+
import { createRegistrySelector, createSelector } from '@wordpress/data';
|
|
6
6
|
import deprecated from '@wordpress/deprecated';
|
|
7
7
|
import { Platform } from '@wordpress/element';
|
|
8
8
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
9
|
import { store as editorStore } from '@wordpress/editor';
|
|
10
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
14
15
|
import { unlock } from '../lock-unlock';
|
|
16
|
+
import { TEMPLATE_PART_POST_TYPE } from '../utils/constants';
|
|
17
|
+
import getFilteredTemplatePartBlocks from '../utils/get-filtered-template-parts';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* @typedef {'template'|'template_type'} TemplateType Template type.
|
|
@@ -71,7 +74,17 @@ export const __experimentalGetPreviewDeviceType = createRegistrySelector(
|
|
|
71
74
|
* @return {Object} Whether the current user can create media or not.
|
|
72
75
|
*/
|
|
73
76
|
export const getCanUserCreateMedia = createRegistrySelector(
|
|
74
|
-
( select ) => () =>
|
|
77
|
+
( select ) => () => {
|
|
78
|
+
deprecated(
|
|
79
|
+
`wp.data.select( 'core/edit-site' ).getCanUserCreateMedia()`,
|
|
80
|
+
{
|
|
81
|
+
since: '6.7',
|
|
82
|
+
alternative: `wp.data.select( 'core' ).canUser( 'create', { kind: 'root', type: 'media' } )`,
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return select( coreDataStore ).canUser( 'create', 'media' );
|
|
87
|
+
}
|
|
75
88
|
);
|
|
76
89
|
|
|
77
90
|
/**
|
|
@@ -82,13 +95,11 @@ export const getCanUserCreateMedia = createRegistrySelector(
|
|
|
82
95
|
* @return {Array} The available reusable blocks.
|
|
83
96
|
*/
|
|
84
97
|
export const getReusableBlocks = createRegistrySelector( ( select ) => () => {
|
|
85
|
-
deprecated(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
);
|
|
98
|
+
deprecated( `select( 'core/edit-site' ).getReusableBlocks()`, {
|
|
99
|
+
since: '6.5',
|
|
100
|
+
version: '6.8',
|
|
101
|
+
alternative: `select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )`,
|
|
102
|
+
} );
|
|
92
103
|
const isWeb = Platform.OS === 'web';
|
|
93
104
|
return isWeb
|
|
94
105
|
? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {
|
|
@@ -232,18 +243,46 @@ export function isSaveViewOpened( state ) {
|
|
|
232
243
|
return state.saveViewPanel;
|
|
233
244
|
}
|
|
234
245
|
|
|
246
|
+
function getBlocksAndTemplateParts( select ) {
|
|
247
|
+
const templateParts = select( coreDataStore ).getEntityRecords(
|
|
248
|
+
'postType',
|
|
249
|
+
TEMPLATE_PART_POST_TYPE,
|
|
250
|
+
{ per_page: -1 }
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
const { getBlocksByName, getBlocksByClientId } = select( blockEditorStore );
|
|
254
|
+
|
|
255
|
+
const clientIds = getBlocksByName( 'core/template-part' );
|
|
256
|
+
const blocks = getBlocksByClientId( clientIds );
|
|
257
|
+
return [ blocks, templateParts ];
|
|
258
|
+
}
|
|
259
|
+
|
|
235
260
|
/**
|
|
236
261
|
* Returns the template parts and their blocks for the current edited template.
|
|
237
262
|
*
|
|
263
|
+
* @deprecated
|
|
238
264
|
* @param {Object} state Global application state.
|
|
239
265
|
* @return {Array} Template parts and their blocks in an array.
|
|
240
266
|
*/
|
|
241
267
|
export const getCurrentTemplateTemplateParts = createRegistrySelector(
|
|
242
|
-
( select ) =>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
268
|
+
( select ) =>
|
|
269
|
+
createSelector(
|
|
270
|
+
() => {
|
|
271
|
+
deprecated(
|
|
272
|
+
`select( 'core/edit-site' ).getCurrentTemplateTemplateParts()`,
|
|
273
|
+
{
|
|
274
|
+
since: '6.7',
|
|
275
|
+
version: '6.9',
|
|
276
|
+
alternative: `select( 'core/block-editor' ).getBlocksByName( 'core/template-part' )`,
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
return getFilteredTemplatePartBlocks(
|
|
281
|
+
...getBlocksAndTemplateParts( select )
|
|
282
|
+
);
|
|
283
|
+
},
|
|
284
|
+
() => getBlocksAndTemplateParts( select )
|
|
285
|
+
)
|
|
247
286
|
);
|
|
248
287
|
|
|
249
288
|
/**
|
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { store as coreDataStore } from '@wordpress/core-data';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
10
|
-
getCanUserCreateMedia,
|
|
11
|
-
getEditedPostType,
|
|
12
|
-
getEditedPostId,
|
|
13
|
-
isPage,
|
|
14
|
-
} from '../selectors';
|
|
4
|
+
import { getEditedPostType, getEditedPostId, isPage } from '../selectors';
|
|
15
5
|
|
|
16
6
|
describe( 'selectors', () => {
|
|
17
|
-
const canUser = jest.fn( () => true );
|
|
18
|
-
getCanUserCreateMedia.registry = {
|
|
19
|
-
select: jest.fn( () => ( { canUser } ) ),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
describe( 'getCanUserCreateMedia', () => {
|
|
23
|
-
it( "selects `canUser( 'create', 'media' )` from the core store", () => {
|
|
24
|
-
expect( getCanUserCreateMedia() ).toBe( true );
|
|
25
|
-
expect(
|
|
26
|
-
getCanUserCreateMedia.registry.select
|
|
27
|
-
).toHaveBeenCalledWith( coreDataStore );
|
|
28
|
-
expect( canUser ).toHaveBeenCalledWith( 'create', 'media' );
|
|
29
|
-
} );
|
|
30
|
-
} );
|
|
31
|
-
|
|
32
7
|
describe( 'getEditedPostId', () => {
|
|
33
8
|
it( 'returns the template ID', () => {
|
|
34
9
|
const state = { editedPost: { id: 10 } };
|
package/src/style.scss
CHANGED
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
@import "./components/site-icon/style.scss";
|
|
29
29
|
@import "./components/style-book/style.scss";
|
|
30
30
|
@import "./components/editor-canvas-container/style.scss";
|
|
31
|
-
@import "./components/
|
|
31
|
+
@import "./components/post-edit/style.scss";
|
|
32
|
+
@import "./components/post-list/style.scss";
|
|
32
33
|
@import "./components/resizable-frame/style.scss";
|
|
33
34
|
@import "./hooks/push-changes-to-global-styles/style.scss";
|
|
34
35
|
@import "./components/global-styles/font-library-modal/style.scss";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { isTemplatePart } from '@wordpress/blocks';
|
|
5
|
+
|
|
6
|
+
const EMPTY_ARRAY = [];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get a flattened and filtered list of template parts and the matching block for that template part.
|
|
10
|
+
*
|
|
11
|
+
* Takes a list of blocks defined within a template, and a list of template parts, and returns a
|
|
12
|
+
* flattened list of template parts and the matching block for that template part.
|
|
13
|
+
*
|
|
14
|
+
* @param {Array} blocks Blocks to flatten.
|
|
15
|
+
* @param {?Array} templateParts Available template parts.
|
|
16
|
+
* @return {Array} An array of template parts and their blocks.
|
|
17
|
+
*/
|
|
18
|
+
export default function getFilteredTemplatePartBlocks(
|
|
19
|
+
blocks = EMPTY_ARRAY,
|
|
20
|
+
templateParts
|
|
21
|
+
) {
|
|
22
|
+
const templatePartsById = templateParts
|
|
23
|
+
? // Key template parts by their ID.
|
|
24
|
+
templateParts.reduce(
|
|
25
|
+
( newTemplateParts, part ) => ( {
|
|
26
|
+
...newTemplateParts,
|
|
27
|
+
[ part.id ]: part,
|
|
28
|
+
} ),
|
|
29
|
+
{}
|
|
30
|
+
)
|
|
31
|
+
: {};
|
|
32
|
+
|
|
33
|
+
const result = [];
|
|
34
|
+
|
|
35
|
+
// Iterate over all blocks, recursing into inner blocks.
|
|
36
|
+
// Output will be based on a depth-first traversal.
|
|
37
|
+
const stack = [ ...blocks ];
|
|
38
|
+
while ( stack.length ) {
|
|
39
|
+
const { innerBlocks, ...block } = stack.shift();
|
|
40
|
+
// Place inner blocks at the beginning of the stack to preserve order.
|
|
41
|
+
stack.unshift( ...innerBlocks );
|
|
42
|
+
|
|
43
|
+
if ( isTemplatePart( block ) ) {
|
|
44
|
+
const {
|
|
45
|
+
attributes: { theme, slug },
|
|
46
|
+
} = block;
|
|
47
|
+
const templatePartId = `${ theme }//${ slug }`;
|
|
48
|
+
const templatePart = templatePartsById[ templatePartId ];
|
|
49
|
+
|
|
50
|
+
// Only add to output if the found template part block is in the list of available template parts.
|
|
51
|
+
if ( templatePart ) {
|
|
52
|
+
result.push( {
|
|
53
|
+
templatePart,
|
|
54
|
+
block,
|
|
55
|
+
} );
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return result;
|
|
61
|
+
}
|