@wordpress/edit-site 6.11.0 → 6.12.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/app/index.js +0 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build/components/editor/index.js +9 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-editor-title.js +29 -12
- package/build/components/editor/use-editor-title.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +2 -3
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +42 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +6 -8
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/layout/hooks.js +1 -10
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +1 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +3 -7
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/page-templates/fields.js +1 -2
- package/build/components/page-templates/fields.js.map +1 -1
- package/build/components/post-edit/index.js +14 -8
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +3 -197
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +11 -1
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar/index.js +11 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
- package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +14 -72
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +43 -42
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/site-editor-routes/styles-edit.js +6 -1
- package/build/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build/components/site-editor-routes/styles-view.js +8 -2
- package/build/components/site-editor-routes/styles-view.js.map +1 -1
- package/build/components/site-hub/index.js +19 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/constants.js +10 -3
- package/build/components/style-book/constants.js.map +1 -1
- package/build/components/style-book/examples.js +71 -1
- package/build/components/style-book/examples.js.map +1 -1
- package/build/components/style-book/index.js +70 -11
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/welcome-guide/index.js +4 -2
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +1 -9
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -12
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +15 -15
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/posts.js +1 -0
- package/build/posts.js.map +1 -1
- package/build-module/components/app/index.js +0 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build-module/components/editor/index.js +9 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +29 -12
- package/build-module/components/editor/use-editor-title.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +43 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +6 -8
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +1 -9
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +1 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +4 -8
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/page-templates/fields.js +1 -2
- package/build-module/components/page-templates/fields.js.map +1 -1
- package/build-module/components/post-edit/index.js +14 -8
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +7 -202
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +11 -1
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +11 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +15 -73
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-edit.js +6 -1
- package/build-module/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-view.js +8 -2
- package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -6
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/constants.js +10 -3
- package/build-module/components/style-book/constants.js.map +1 -1
- package/build-module/components/style-book/examples.js +71 -1
- package/build-module/components/style-book/examples.js.map +1 -1
- package/build-module/components/style-book/index.js +71 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +4 -2
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +1 -9
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -11
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +15 -15
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +1 -0
- package/build-module/posts.js.map +1 -1
- package/build-style/posts-rtl.css +54 -5
- package/build-style/posts.css +54 -5
- package/build-style/style-rtl.css +109 -28
- package/build-style/style.css +109 -28
- package/package.json +3 -4
- package/src/components/app/index.js +0 -2
- package/src/components/block-editor/use-editor-iframe-props.js +2 -3
- package/src/components/editor/index.js +16 -4
- package/src/components/editor/use-editor-title.js +37 -13
- package/src/components/editor-canvas-container/style.scss +0 -1
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
- package/src/components/global-styles/screen-revisions/style.scss +11 -17
- package/src/components/global-styles/shadows-edit-panel.js +4 -2
- package/src/components/global-styles/ui.js +42 -2
- package/src/components/global-styles-renderer/index.js +4 -10
- package/src/components/layout/hooks.js +1 -7
- package/src/components/layout/index.js +6 -1
- package/src/components/page-patterns/fields.js +6 -12
- package/src/components/page-patterns/style.scss +0 -5
- package/src/components/page-templates/fields.js +2 -3
- package/src/components/post-edit/index.js +38 -30
- package/src/components/post-edit/style.scss +7 -0
- package/src/components/post-fields/index.js +19 -273
- package/src/components/post-list/index.js +9 -3
- package/src/components/post-list/style.scss +29 -3
- package/src/components/sidebar/index.js +23 -7
- package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
- package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
- package/src/components/sidebar-navigation-item/style.scss +2 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +13 -88
- package/src/components/sidebar-navigation-screen-main/index.js +46 -45
- package/src/components/site-editor-routes/styles-edit.js +10 -1
- package/src/components/site-editor-routes/styles-view.js +11 -1
- package/src/components/site-hub/index.js +33 -16
- package/src/components/site-icon/style.scss +16 -0
- package/src/components/style-book/constants.ts +11 -3
- package/src/components/style-book/examples.tsx +105 -1
- package/src/components/style-book/index.js +86 -8
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +54 -64
- package/src/components/welcome-guide/index.js +3 -3
- package/src/components/welcome-guide/page.js +1 -7
- package/src/components/welcome-guide/template.js +1 -8
- package/src/hooks/commands/use-common-commands.js +253 -246
- package/src/index.js +1 -0
- package/src/posts.js +1 -0
- package/src/style.scss +2 -3
- package/build/components/async/index.js +0 -51
- package/build/components/async/index.js.map +0 -1
- package/build/components/use-edited-entity-record/index.js +0 -60
- package/build/components/use-edited-entity-record/index.js.map +0 -1
- package/build/hooks/commands/use-edit-mode-commands.js +0 -179
- package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/build-module/components/async/index.js +0 -44
- package/build-module/components/async/index.js.map +0 -1
- package/build-module/components/use-edited-entity-record/index.js +0 -53
- package/build-module/components/use-edited-entity-record/index.js.map +0 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/src/components/async/index.js +0 -43
- package/src/components/use-edited-entity-record/index.js +0 -58
- package/src/hooks/commands/use-edit-mode-commands.js +0 -168
|
@@ -19,7 +19,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
19
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
20
20
|
import { moreVertical } from '@wordpress/icons';
|
|
21
21
|
import { store as coreStore } from '@wordpress/core-data';
|
|
22
|
-
import { useEffect } from '@wordpress/element';
|
|
22
|
+
import { useEffect, Fragment } from '@wordpress/element';
|
|
23
|
+
import { usePrevious } from '@wordpress/compose';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Internal dependencies
|
|
@@ -201,6 +202,11 @@ function GlobalStylesStyleBook() {
|
|
|
201
202
|
navigator.goTo( '/colors/palette' );
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
205
|
+
if ( blockName === 'typography' ) {
|
|
206
|
+
// Go to typography Global Styles.
|
|
207
|
+
navigator.goTo( '/typography' );
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
204
210
|
|
|
205
211
|
// Now go to the selected block.
|
|
206
212
|
navigator.goTo( '/blocks/' + encodeURIComponent( blockName ) );
|
|
@@ -291,18 +297,52 @@ function GlobalStylesEditorCanvasContainerLink() {
|
|
|
291
297
|
}, [ editorCanvasContainerView, isRevisionsOpen, goTo ] );
|
|
292
298
|
}
|
|
293
299
|
|
|
294
|
-
function
|
|
300
|
+
function useNavigatorSync( parentPath, onPathChange ) {
|
|
301
|
+
const navigator = useNavigator();
|
|
302
|
+
const { path: childPath } = navigator.location;
|
|
303
|
+
const previousParentPath = usePrevious( parentPath );
|
|
304
|
+
const previousChildPath = usePrevious( childPath );
|
|
305
|
+
useEffect( () => {
|
|
306
|
+
if ( parentPath !== childPath ) {
|
|
307
|
+
if ( parentPath !== previousParentPath ) {
|
|
308
|
+
navigator.goTo( parentPath );
|
|
309
|
+
} else if ( childPath !== previousChildPath ) {
|
|
310
|
+
onPathChange( childPath );
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}, [
|
|
314
|
+
onPathChange,
|
|
315
|
+
parentPath,
|
|
316
|
+
previousChildPath,
|
|
317
|
+
previousParentPath,
|
|
318
|
+
childPath,
|
|
319
|
+
navigator,
|
|
320
|
+
] );
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// This component is used to wrap the hook in order to conditionally execute it
|
|
324
|
+
// when the parent component is used on controlled mode.
|
|
325
|
+
function NavigationSync( { path: parentPath, onPathChange, children } ) {
|
|
326
|
+
useNavigatorSync( parentPath, onPathChange );
|
|
327
|
+
return children;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function GlobalStylesUI( { path, onPathChange } ) {
|
|
295
331
|
const blocks = getBlockTypes();
|
|
296
332
|
const editorCanvasContainerView = useSelect(
|
|
297
333
|
( select ) =>
|
|
298
334
|
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
|
|
299
335
|
[]
|
|
300
336
|
);
|
|
337
|
+
|
|
301
338
|
return (
|
|
302
339
|
<Navigator
|
|
303
340
|
className="edit-site-global-styles-sidebar__navigator-provider"
|
|
304
341
|
initialPath="/"
|
|
305
342
|
>
|
|
343
|
+
{ path && onPathChange && (
|
|
344
|
+
<NavigationSync path={ path } onPathChange={ onPathChange } />
|
|
345
|
+
) }
|
|
306
346
|
<GlobalStylesNavigationScreen path="/">
|
|
307
347
|
<ScreenRoot />
|
|
308
348
|
</GlobalStylesNavigationScreen>
|
|
@@ -10,17 +10,11 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
10
10
|
*/
|
|
11
11
|
import { store as editSiteStore } from '../../store';
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
14
13
|
|
|
15
14
|
const { useGlobalStylesOutput } = unlock( blockEditorPrivateApis );
|
|
16
15
|
|
|
17
|
-
function useGlobalStylesRenderer() {
|
|
18
|
-
const
|
|
19
|
-
return select( editSiteStore ).getEditedPostType();
|
|
20
|
-
} );
|
|
21
|
-
const [ styles, settings ] = useGlobalStylesOutput(
|
|
22
|
-
postType !== TEMPLATE_POST_TYPE
|
|
23
|
-
);
|
|
16
|
+
function useGlobalStylesRenderer( disableRootPadding ) {
|
|
17
|
+
const [ styles, settings ] = useGlobalStylesOutput( disableRootPadding );
|
|
24
18
|
const { getSettings } = useSelect( editSiteStore );
|
|
25
19
|
const { updateSettings } = useDispatch( editSiteStore );
|
|
26
20
|
|
|
@@ -41,8 +35,8 @@ function useGlobalStylesRenderer() {
|
|
|
41
35
|
}, [ styles, settings, updateSettings, getSettings ] );
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
export function GlobalStylesRenderer() {
|
|
45
|
-
useGlobalStylesRenderer();
|
|
38
|
+
export function GlobalStylesRenderer( { disableRootPadding } ) {
|
|
39
|
+
useGlobalStylesRenderer( disableRootPadding );
|
|
46
40
|
|
|
47
41
|
return null;
|
|
48
42
|
}
|
|
@@ -5,15 +5,9 @@ import { useEffect, useState } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import useEditedEntityRecord from '../use-edited-entity-record';
|
|
12
|
-
|
|
13
8
|
const MAX_LOADING_TIME = 10000; // 10 seconds
|
|
14
9
|
|
|
15
10
|
export function useIsSiteEditorLoading() {
|
|
16
|
-
const { isLoaded: hasLoadedPost } = useEditedEntityRecord();
|
|
17
11
|
const [ loaded, setLoaded ] = useState( false );
|
|
18
12
|
const inLoadingPause = useSelect(
|
|
19
13
|
( select ) => {
|
|
@@ -64,5 +58,5 @@ export function useIsSiteEditorLoading() {
|
|
|
64
58
|
}
|
|
65
59
|
}, [ inLoadingPause ] );
|
|
66
60
|
|
|
67
|
-
return ! loaded
|
|
61
|
+
return ! loaded;
|
|
68
62
|
}
|
|
@@ -125,7 +125,12 @@ export default function Layout( { route } ) {
|
|
|
125
125
|
isResizableFrameOversized
|
|
126
126
|
}
|
|
127
127
|
/>
|
|
128
|
-
<SidebarContent
|
|
128
|
+
<SidebarContent
|
|
129
|
+
shouldAnimate={
|
|
130
|
+
routeKey !== 'styles-view'
|
|
131
|
+
}
|
|
132
|
+
routeKey={ routeKey }
|
|
133
|
+
>
|
|
129
134
|
{ areas.sidebar }
|
|
130
135
|
</SidebarContent>
|
|
131
136
|
<SaveHub />
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
__experimentalHStack as HStack,
|
|
11
11
|
Button,
|
|
12
12
|
Tooltip,
|
|
13
|
-
|
|
13
|
+
FlexBlock,
|
|
14
14
|
} from '@wordpress/components';
|
|
15
15
|
import { __, _x } from '@wordpress/i18n';
|
|
16
16
|
import { useState, useMemo, useId } from '@wordpress/element';
|
|
@@ -25,7 +25,6 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
28
|
-
import { Async } from '../async';
|
|
29
28
|
import {
|
|
30
29
|
PATTERN_TYPES,
|
|
31
30
|
TEMPLATE_PART_POST_TYPE,
|
|
@@ -45,7 +44,7 @@ function PreviewWrapper( { item, onClick, ariaDescribedBy, children } ) {
|
|
|
45
44
|
className="page-patterns-preview-field__button"
|
|
46
45
|
type="button"
|
|
47
46
|
onClick={ item.type !== PATTERN_TYPES.theme ? onClick : undefined }
|
|
48
|
-
aria-label={ item
|
|
47
|
+
aria-label={ defaultGetTitle( item ) }
|
|
49
48
|
aria-describedby={ ariaDescribedBy }
|
|
50
49
|
aria-disabled={ item.type === PATTERN_TYPES.theme }
|
|
51
50
|
>
|
|
@@ -88,12 +87,12 @@ function PreviewField( { item } ) {
|
|
|
88
87
|
{ isEmpty && isTemplatePart && __( 'Empty template part' ) }
|
|
89
88
|
{ isEmpty && ! isTemplatePart && __( 'Empty pattern' ) }
|
|
90
89
|
{ ! isEmpty && (
|
|
91
|
-
<Async>
|
|
90
|
+
<BlockPreview.Async>
|
|
92
91
|
<BlockPreview
|
|
93
92
|
blocks={ blocks }
|
|
94
93
|
viewportWidth={ item.viewportWidth }
|
|
95
94
|
/>
|
|
96
|
-
</Async>
|
|
95
|
+
</BlockPreview.Async>
|
|
97
96
|
) }
|
|
98
97
|
</PreviewWrapper>
|
|
99
98
|
{ !! description && (
|
|
@@ -123,12 +122,7 @@ function TitleField( { item } ) {
|
|
|
123
122
|
const title = decodeEntities( defaultGetTitle( item ) );
|
|
124
123
|
return (
|
|
125
124
|
<HStack alignment="center" justify="flex-start" spacing={ 2 }>
|
|
126
|
-
<
|
|
127
|
-
as="div"
|
|
128
|
-
gap={ 0 }
|
|
129
|
-
justify="flex-start"
|
|
130
|
-
className="edit-site-patterns__pattern-title"
|
|
131
|
-
>
|
|
125
|
+
<FlexBlock className="edit-site-patterns__pattern-title">
|
|
132
126
|
{ item.type === PATTERN_TYPES.theme ? (
|
|
133
127
|
title
|
|
134
128
|
) : (
|
|
@@ -143,7 +137,7 @@ function TitleField( { item } ) {
|
|
|
143
137
|
{ title }
|
|
144
138
|
</Button>
|
|
145
139
|
) }
|
|
146
|
-
</
|
|
140
|
+
</FlexBlock>
|
|
147
141
|
{ item.type === PATTERN_TYPES.theme && (
|
|
148
142
|
<Tooltip
|
|
149
143
|
placement="top"
|
|
@@ -41,10 +41,6 @@
|
|
|
41
41
|
flex-shrink: 0;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.edit-site-patterns__pattern-lock-icon {
|
|
45
|
-
min-width: min-content;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
.edit-site-patterns__section-header {
|
|
49
45
|
border-bottom: 1px solid #f0f0f0;
|
|
50
46
|
padding: $grid-unit-20 $grid-unit-60;
|
|
@@ -77,7 +73,6 @@
|
|
|
77
73
|
|
|
78
74
|
.edit-site-patterns__pattern-title {
|
|
79
75
|
display: block;
|
|
80
|
-
width: 100%;
|
|
81
76
|
white-space: nowrap;
|
|
82
77
|
overflow: hidden;
|
|
83
78
|
text-overflow: ellipsis;
|
|
@@ -20,7 +20,6 @@ import { EditorProvider } from '@wordpress/editor';
|
|
|
20
20
|
/**
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
|
-
import { Async } from '../async';
|
|
24
23
|
import { default as Link, useLink } from '../routes/link';
|
|
25
24
|
import { useAddedBy } from './hooks';
|
|
26
25
|
|
|
@@ -63,9 +62,9 @@ function PreviewField( { item } ) {
|
|
|
63
62
|
>
|
|
64
63
|
{ isEmpty && __( 'Empty template' ) }
|
|
65
64
|
{ ! isEmpty && (
|
|
66
|
-
<Async>
|
|
65
|
+
<BlockPreview.Async>
|
|
67
66
|
<BlockPreview blocks={ blocks } />
|
|
68
|
-
</Async>
|
|
67
|
+
</BlockPreview.Async>
|
|
69
68
|
) }
|
|
70
69
|
</button>
|
|
71
70
|
</div>
|
|
@@ -23,6 +23,14 @@ import { unlock } from '../../lock-unlock';
|
|
|
23
23
|
|
|
24
24
|
const { PostCardPanel } = unlock( editorPrivateApis );
|
|
25
25
|
|
|
26
|
+
const fieldsWithBulkEditSupport = [
|
|
27
|
+
'title',
|
|
28
|
+
'status',
|
|
29
|
+
'date',
|
|
30
|
+
'author',
|
|
31
|
+
'comment_status',
|
|
32
|
+
];
|
|
33
|
+
|
|
26
34
|
function PostEditForm( { postType, postId } ) {
|
|
27
35
|
const ids = useMemo( () => postId.split( ',' ), [ postId ] );
|
|
28
36
|
const { record } = useSelect(
|
|
@@ -58,27 +66,36 @@ function PostEditForm( { postType, postId } ) {
|
|
|
58
66
|
} ),
|
|
59
67
|
[ _fields ]
|
|
60
68
|
);
|
|
61
|
-
const form = {
|
|
62
|
-
type: 'panel',
|
|
63
|
-
fields: [
|
|
64
|
-
'featured_media',
|
|
65
|
-
'title',
|
|
66
|
-
'author',
|
|
67
|
-
'date',
|
|
68
|
-
'slug',
|
|
69
|
-
'parent',
|
|
70
|
-
'comment_status',
|
|
71
|
-
],
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const fieldsWithBulkEditSupport = [
|
|
75
|
-
'title',
|
|
76
|
-
'status',
|
|
77
|
-
'date',
|
|
78
|
-
'author',
|
|
79
|
-
'comment_status',
|
|
80
|
-
];
|
|
81
69
|
|
|
70
|
+
const form = useMemo(
|
|
71
|
+
() => ( {
|
|
72
|
+
type: 'panel',
|
|
73
|
+
fields: [
|
|
74
|
+
'featured_media',
|
|
75
|
+
'title',
|
|
76
|
+
'status_and_visibility',
|
|
77
|
+
'author',
|
|
78
|
+
'date',
|
|
79
|
+
'slug',
|
|
80
|
+
'parent',
|
|
81
|
+
'comment_status',
|
|
82
|
+
].filter(
|
|
83
|
+
( field ) =>
|
|
84
|
+
ids.length === 1 ||
|
|
85
|
+
fieldsWithBulkEditSupport.includes( field )
|
|
86
|
+
),
|
|
87
|
+
combinedFields: [
|
|
88
|
+
{
|
|
89
|
+
id: 'status_and_visibility',
|
|
90
|
+
label: __( 'Status & Visibility' ),
|
|
91
|
+
children: [ 'status', 'password' ],
|
|
92
|
+
direction: 'vertical',
|
|
93
|
+
render: ( { item } ) => item.status,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
} ),
|
|
97
|
+
[ ids ]
|
|
98
|
+
);
|
|
82
99
|
const onChange = ( edits ) => {
|
|
83
100
|
for ( const id of ids ) {
|
|
84
101
|
if (
|
|
@@ -117,16 +134,7 @@ function PostEditForm( { postType, postId } ) {
|
|
|
117
134
|
<DataForm
|
|
118
135
|
data={ ids.length === 1 ? record : multiEdits }
|
|
119
136
|
fields={ fields }
|
|
120
|
-
form={
|
|
121
|
-
ids.length === 1
|
|
122
|
-
? form
|
|
123
|
-
: {
|
|
124
|
-
...form,
|
|
125
|
-
fields: form.fields.filter( ( field ) =>
|
|
126
|
-
fieldsWithBulkEditSupport.includes( field )
|
|
127
|
-
),
|
|
128
|
-
}
|
|
129
|
-
}
|
|
137
|
+
form={ form }
|
|
130
138
|
onChange={ onChange }
|
|
131
139
|
/>
|
|
132
140
|
</VStack>
|
|
@@ -6,96 +6,23 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { __
|
|
10
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
|
-
import { featuredImageField, slugField, parentField } from '@wordpress/fields';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
12
10
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
notAllowed,
|
|
25
|
-
commentAuthorAvatar as authorIcon,
|
|
26
|
-
} from '@wordpress/icons';
|
|
11
|
+
featuredImageField,
|
|
12
|
+
slugField,
|
|
13
|
+
parentField,
|
|
14
|
+
passwordField,
|
|
15
|
+
statusField,
|
|
16
|
+
commentStatusField,
|
|
17
|
+
titleField,
|
|
18
|
+
dateField,
|
|
19
|
+
} from '@wordpress/fields';
|
|
20
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
21
|
+
import { commentAuthorAvatar as authorIcon } from '@wordpress/icons';
|
|
27
22
|
import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
|
|
28
23
|
import { useSelect } from '@wordpress/data';
|
|
29
24
|
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
|
|
30
25
|
|
|
31
|
-
/**
|
|
32
|
-
* Internal dependencies
|
|
33
|
-
*/
|
|
34
|
-
import {
|
|
35
|
-
LAYOUT_GRID,
|
|
36
|
-
LAYOUT_TABLE,
|
|
37
|
-
OPERATOR_IS_ANY,
|
|
38
|
-
} from '../../utils/constants';
|
|
39
|
-
import { default as Link } from '../routes/link';
|
|
40
|
-
|
|
41
|
-
// See https://github.com/WordPress/gutenberg/issues/55886
|
|
42
|
-
// We do not support custom statutes at the moment.
|
|
43
|
-
const STATUSES = [
|
|
44
|
-
{
|
|
45
|
-
value: 'draft',
|
|
46
|
-
label: __( 'Draft' ),
|
|
47
|
-
icon: drafts,
|
|
48
|
-
description: __( 'Not ready to publish.' ),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
value: 'future',
|
|
52
|
-
label: __( 'Scheduled' ),
|
|
53
|
-
icon: scheduled,
|
|
54
|
-
description: __( 'Publish automatically on a chosen date.' ),
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
value: 'pending',
|
|
58
|
-
label: __( 'Pending Review' ),
|
|
59
|
-
icon: pending,
|
|
60
|
-
description: __( 'Waiting for review before publishing.' ),
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
value: 'private',
|
|
64
|
-
label: __( 'Private' ),
|
|
65
|
-
icon: notAllowed,
|
|
66
|
-
description: __( 'Only visible to site admins and editors.' ),
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
value: 'publish',
|
|
70
|
-
label: __( 'Published' ),
|
|
71
|
-
icon: published,
|
|
72
|
-
description: __( 'Visible to everyone.' ),
|
|
73
|
-
},
|
|
74
|
-
{ value: 'trash', label: __( 'Trash' ), icon: trash },
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
const getFormattedDate = ( dateToDisplay ) =>
|
|
78
|
-
dateI18n(
|
|
79
|
-
getSettings().formats.datetimeAbbreviated,
|
|
80
|
-
getDate( dateToDisplay )
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
function PostStatusField( { item } ) {
|
|
84
|
-
const status = STATUSES.find( ( { value } ) => value === item.status );
|
|
85
|
-
const label = status?.label || item.status;
|
|
86
|
-
const icon = status?.icon;
|
|
87
|
-
return (
|
|
88
|
-
<HStack alignment="left" spacing={ 0 }>
|
|
89
|
-
{ icon && (
|
|
90
|
-
<div className="edit-site-post-list__status-icon">
|
|
91
|
-
<Icon icon={ icon } />
|
|
92
|
-
</div>
|
|
93
|
-
) }
|
|
94
|
-
<span>{ label }</span>
|
|
95
|
-
</HStack>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
26
|
function PostAuthorField( { item } ) {
|
|
100
27
|
const { text, imageUrl } = useSelect(
|
|
101
28
|
( select ) => {
|
|
@@ -134,84 +61,14 @@ function PostAuthorField( { item } ) {
|
|
|
134
61
|
);
|
|
135
62
|
}
|
|
136
63
|
|
|
137
|
-
function usePostFields(
|
|
64
|
+
function usePostFields() {
|
|
138
65
|
const { records: authors, isResolving: isLoadingAuthors } =
|
|
139
66
|
useEntityRecords( 'root', 'user', { per_page: -1 } );
|
|
140
67
|
|
|
141
|
-
const { frontPageId, postsPageId } = useSelect( ( select ) => {
|
|
142
|
-
const { getEntityRecord } = select( coreStore );
|
|
143
|
-
const siteSettings = getEntityRecord( 'root', 'site' );
|
|
144
|
-
return {
|
|
145
|
-
frontPageId: siteSettings?.page_on_front,
|
|
146
|
-
postsPageId: siteSettings?.page_for_posts,
|
|
147
|
-
};
|
|
148
|
-
}, [] );
|
|
149
|
-
|
|
150
68
|
const fields = useMemo(
|
|
151
69
|
() => [
|
|
152
70
|
featuredImageField,
|
|
153
|
-
|
|
154
|
-
label: __( 'Title' ),
|
|
155
|
-
id: 'title',
|
|
156
|
-
type: 'text',
|
|
157
|
-
getValue: ( { item } ) =>
|
|
158
|
-
typeof item.title === 'string'
|
|
159
|
-
? item.title
|
|
160
|
-
: item.title?.raw,
|
|
161
|
-
render: ( { item } ) => {
|
|
162
|
-
const addLink =
|
|
163
|
-
[ LAYOUT_TABLE, LAYOUT_GRID ].includes( viewType ) &&
|
|
164
|
-
item.status !== 'trash';
|
|
165
|
-
const renderedTitle =
|
|
166
|
-
typeof item.title === 'string'
|
|
167
|
-
? item.title
|
|
168
|
-
: item.title?.rendered;
|
|
169
|
-
const title = addLink ? (
|
|
170
|
-
<Link
|
|
171
|
-
params={ {
|
|
172
|
-
postId: item.id,
|
|
173
|
-
postType: item.type,
|
|
174
|
-
canvas: 'edit',
|
|
175
|
-
} }
|
|
176
|
-
>
|
|
177
|
-
{ decodeEntities( renderedTitle ) ||
|
|
178
|
-
__( '(no title)' ) }
|
|
179
|
-
</Link>
|
|
180
|
-
) : (
|
|
181
|
-
<span>
|
|
182
|
-
{ decodeEntities( renderedTitle ) ||
|
|
183
|
-
__( '(no title)' ) }
|
|
184
|
-
</span>
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
let suffix = '';
|
|
188
|
-
if ( item.id === frontPageId ) {
|
|
189
|
-
suffix = (
|
|
190
|
-
<span className="edit-site-post-list__title-badge">
|
|
191
|
-
{ __( 'Homepage' ) }
|
|
192
|
-
</span>
|
|
193
|
-
);
|
|
194
|
-
} else if ( item.id === postsPageId ) {
|
|
195
|
-
suffix = (
|
|
196
|
-
<span className="edit-site-post-list__title-badge">
|
|
197
|
-
{ __( 'Posts Page' ) }
|
|
198
|
-
</span>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return (
|
|
203
|
-
<HStack
|
|
204
|
-
className="edit-site-post-list__title"
|
|
205
|
-
alignment="center"
|
|
206
|
-
justify="flex-start"
|
|
207
|
-
>
|
|
208
|
-
{ title }
|
|
209
|
-
{ suffix }
|
|
210
|
-
</HStack>
|
|
211
|
-
);
|
|
212
|
-
},
|
|
213
|
-
enableHiding: false,
|
|
214
|
-
},
|
|
71
|
+
titleField,
|
|
215
72
|
{
|
|
216
73
|
label: __( 'Author' ),
|
|
217
74
|
id: 'author',
|
|
@@ -231,125 +88,14 @@ function usePostFields( viewType ) {
|
|
|
231
88
|
: nameB.localeCompare( nameA );
|
|
232
89
|
},
|
|
233
90
|
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
id: 'status',
|
|
237
|
-
type: 'text',
|
|
238
|
-
elements: STATUSES,
|
|
239
|
-
render: PostStatusField,
|
|
240
|
-
Edit: 'radio',
|
|
241
|
-
enableSorting: false,
|
|
242
|
-
filterBy: {
|
|
243
|
-
operators: [ OPERATOR_IS_ANY ],
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
label: __( 'Date' ),
|
|
248
|
-
id: 'date',
|
|
249
|
-
type: 'datetime',
|
|
250
|
-
render: ( { item } ) => {
|
|
251
|
-
const isDraftOrPrivate = [ 'draft', 'private' ].includes(
|
|
252
|
-
item.status
|
|
253
|
-
);
|
|
254
|
-
if ( isDraftOrPrivate ) {
|
|
255
|
-
return createInterpolateElement(
|
|
256
|
-
sprintf(
|
|
257
|
-
/* translators: %s: page creation or modification date. */
|
|
258
|
-
__( '<span>Modified: <time>%s</time></span>' ),
|
|
259
|
-
getFormattedDate( item.date )
|
|
260
|
-
),
|
|
261
|
-
{
|
|
262
|
-
span: <span />,
|
|
263
|
-
time: <time />,
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const isScheduled = item.status === 'future';
|
|
269
|
-
if ( isScheduled ) {
|
|
270
|
-
return createInterpolateElement(
|
|
271
|
-
sprintf(
|
|
272
|
-
/* translators: %s: page creation date */
|
|
273
|
-
__( '<span>Scheduled: <time>%s</time></span>' ),
|
|
274
|
-
getFormattedDate( item.date )
|
|
275
|
-
),
|
|
276
|
-
{
|
|
277
|
-
span: <span />,
|
|
278
|
-
time: <time />,
|
|
279
|
-
}
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const isPublished = item.status === 'publish';
|
|
284
|
-
if ( isPublished ) {
|
|
285
|
-
return createInterpolateElement(
|
|
286
|
-
sprintf(
|
|
287
|
-
/* translators: %s: page creation time */
|
|
288
|
-
__( '<span>Published: <time>%s</time></span>' ),
|
|
289
|
-
getFormattedDate( item.date )
|
|
290
|
-
),
|
|
291
|
-
{
|
|
292
|
-
span: <span />,
|
|
293
|
-
time: <time />,
|
|
294
|
-
}
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// Pending posts show the modified date if it's newer.
|
|
299
|
-
const dateToDisplay =
|
|
300
|
-
getDate( item.modified ) > getDate( item.date )
|
|
301
|
-
? item.modified
|
|
302
|
-
: item.date;
|
|
303
|
-
|
|
304
|
-
const isPending = item.status === 'pending';
|
|
305
|
-
if ( isPending ) {
|
|
306
|
-
return createInterpolateElement(
|
|
307
|
-
sprintf(
|
|
308
|
-
/* translators: %s: page creation or modification date. */
|
|
309
|
-
__( '<span>Modified: <time>%s</time></span>' ),
|
|
310
|
-
getFormattedDate( dateToDisplay )
|
|
311
|
-
),
|
|
312
|
-
{
|
|
313
|
-
span: <span />,
|
|
314
|
-
time: <time />,
|
|
315
|
-
}
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Unknow status.
|
|
320
|
-
return <time>{ getFormattedDate( item.date ) }</time>;
|
|
321
|
-
},
|
|
322
|
-
},
|
|
91
|
+
statusField,
|
|
92
|
+
dateField,
|
|
323
93
|
slugField,
|
|
324
94
|
parentField,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
label: __( 'Discussion' ),
|
|
328
|
-
type: 'text',
|
|
329
|
-
Edit: 'radio',
|
|
330
|
-
enableSorting: false,
|
|
331
|
-
filterBy: {
|
|
332
|
-
operators: [],
|
|
333
|
-
},
|
|
334
|
-
elements: [
|
|
335
|
-
{
|
|
336
|
-
value: 'open',
|
|
337
|
-
label: __( 'Open' ),
|
|
338
|
-
description: __(
|
|
339
|
-
'Visitors can add new comments and replies.'
|
|
340
|
-
),
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
value: 'closed',
|
|
344
|
-
label: __( 'Closed' ),
|
|
345
|
-
description: __(
|
|
346
|
-
'Visitors cannot add new comments or replies. Existing comments remain visible.'
|
|
347
|
-
),
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
},
|
|
95
|
+
commentStatusField,
|
|
96
|
+
passwordField,
|
|
351
97
|
],
|
|
352
|
-
[ authors
|
|
98
|
+
[ authors ]
|
|
353
99
|
);
|
|
354
100
|
|
|
355
101
|
return {
|
|
@@ -208,9 +208,7 @@ export default function PostList( { postType } ) {
|
|
|
208
208
|
return found?.filters ?? [];
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
const { isLoading: isLoadingFields, fields: _fields } = usePostFields(
|
|
212
|
-
view.type
|
|
213
|
-
);
|
|
211
|
+
const { isLoading: isLoadingFields, fields: _fields } = usePostFields();
|
|
214
212
|
const fields = useMemo( () => {
|
|
215
213
|
const activeViewFilters = getActiveViewFilters(
|
|
216
214
|
defaultViews,
|
|
@@ -402,6 +400,14 @@ export default function PostList( { postType } ) {
|
|
|
402
400
|
onChangeView={ setView }
|
|
403
401
|
selection={ selection }
|
|
404
402
|
onChangeSelection={ onChangeSelection }
|
|
403
|
+
isItemClickable={ ( item ) => item.status !== 'trash' }
|
|
404
|
+
onClickItem={ ( { id } ) => {
|
|
405
|
+
history.push( {
|
|
406
|
+
postId: id,
|
|
407
|
+
postType,
|
|
408
|
+
canvas: 'edit',
|
|
409
|
+
} );
|
|
410
|
+
} }
|
|
405
411
|
getItemId={ getItemId }
|
|
406
412
|
defaultLayouts={ defaultLayouts }
|
|
407
413
|
header={
|