@wordpress/edit-post 7.34.0 → 7.35.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 +8 -2
- package/build/components/header/fullscreen-mode-close/index.js +2 -2
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/index.js +7 -96
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/manage-patterns-menu-item.js +1 -1
- package/build/components/header/more-menu/manage-patterns-menu-item.js.map +1 -1
- package/build/components/layout/index.js +56 -24
- package/build/components/layout/index.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js +2 -2
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/visual-editor/index.js +11 -5
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/visual-editor/use-padding-appender.js +6 -1
- package/build/components/visual-editor/use-padding-appender.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +2 -2
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/index.js +8 -97
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/manage-patterns-menu-item.js +1 -1
- package/build-module/components/header/more-menu/manage-patterns-menu-item.js.map +1 -1
- package/build-module/components/layout/index.js +57 -25
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js +2 -2
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +11 -5
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/use-padding-appender.js +6 -1
- package/build-module/components/visual-editor/use-padding-appender.js.map +1 -1
- package/build-style/style-rtl.css +8 -268
- package/build-style/style.css +8 -268
- package/package.json +32 -32
- package/src/components/header/fullscreen-mode-close/index.js +2 -2
- package/src/components/header/index.js +9 -112
- package/src/components/header/more-menu/manage-patterns-menu-item.js +1 -1
- package/src/components/header/style.scss +4 -241
- package/src/components/layout/index.js +72 -19
- package/src/components/meta-boxes/meta-boxes-area/index.js +4 -8
- package/src/components/visual-editor/index.js +11 -4
- package/src/components/visual-editor/use-padding-appender.js +7 -1
- package/src/style.scss +1 -5
- package/build/components/sidebar/post-format/index.js +0 -21
- package/build/components/sidebar/post-format/index.js.map +0 -1
- package/build/components/sidebar/post-pending-status/index.js +0 -26
- package/build/components/sidebar/post-pending-status/index.js.map +0 -1
- package/build/components/sidebar/post-slug/index.js +0 -21
- package/build/components/sidebar/post-slug/index.js.map +0 -1
- package/build/components/sidebar/post-status/index.js +0 -92
- package/build/components/sidebar/post-status/index.js.map +0 -1
- package/build/components/sidebar/post-sticky/index.js +0 -26
- package/build/components/sidebar/post-sticky/index.js.map +0 -1
- package/build/components/sidebar/post-trash/index.js +0 -16
- package/build/components/sidebar/post-trash/index.js.map +0 -1
- package/build/components/sidebar/post-visibility/index.js +0 -78
- package/build/components/sidebar/post-visibility/index.js.map +0 -1
- package/build/components/sidebar/settings-header/index.js +0 -53
- package/build/components/sidebar/settings-header/index.js.map +0 -1
- package/build/components/sidebar/settings-sidebar/index.js +0 -193
- package/build/components/sidebar/settings-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar/post-format/index.js +0 -13
- package/build-module/components/sidebar/post-format/index.js.map +0 -1
- package/build-module/components/sidebar/post-pending-status/index.js +0 -18
- package/build-module/components/sidebar/post-pending-status/index.js.map +0 -1
- package/build-module/components/sidebar/post-slug/index.js +0 -13
- package/build-module/components/sidebar/post-slug/index.js.map +0 -1
- package/build-module/components/sidebar/post-status/index.js +0 -84
- package/build-module/components/sidebar/post-status/index.js.map +0 -1
- package/build-module/components/sidebar/post-sticky/index.js +0 -18
- package/build-module/components/sidebar/post-sticky/index.js.map +0 -1
- package/build-module/components/sidebar/post-trash/index.js +0 -9
- package/build-module/components/sidebar/post-trash/index.js.map +0 -1
- package/build-module/components/sidebar/post-visibility/index.js +0 -70
- package/build-module/components/sidebar/post-visibility/index.js.map +0 -1
- package/build-module/components/sidebar/settings-header/index.js +0 -46
- package/build-module/components/sidebar/settings-header/index.js.map +0 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +0 -185
- package/build-module/components/sidebar/settings-sidebar/index.js.map +0 -1
- package/src/components/sidebar/post-format/index.js +0 -20
- package/src/components/sidebar/post-format/style.scss +0 -5
- package/src/components/sidebar/post-pending-status/index.js +0 -27
- package/src/components/sidebar/post-slug/index.js +0 -17
- package/src/components/sidebar/post-slug/style.scss +0 -5
- package/src/components/sidebar/post-status/index.js +0 -128
- package/src/components/sidebar/post-sticky/index.js +0 -27
- package/src/components/sidebar/post-trash/index.js +0 -12
- package/src/components/sidebar/post-visibility/index.js +0 -88
- package/src/components/sidebar/post-visibility/style.scss +0 -5
- package/src/components/sidebar/settings-header/index.js +0 -49
- package/src/components/sidebar/settings-sidebar/index.js +0 -247
- package/src/components/sidebar/style.scss +0 -18
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
__experimentalHStack as HStack,
|
|
7
|
-
__experimentalVStack as VStack,
|
|
8
|
-
PanelBody,
|
|
9
|
-
} from '@wordpress/components';
|
|
10
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
-
import {
|
|
12
|
-
PluginPostStatusInfo,
|
|
13
|
-
PostAuthorPanel,
|
|
14
|
-
PostSchedulePanel,
|
|
15
|
-
PostSyncStatus,
|
|
16
|
-
PostURLPanel,
|
|
17
|
-
PostTemplatePanel,
|
|
18
|
-
PostFeaturedImagePanel,
|
|
19
|
-
store as editorStore,
|
|
20
|
-
privateApis as editorPrivateApis,
|
|
21
|
-
} from '@wordpress/editor';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
|
-
import PostTrash from '../post-trash';
|
|
27
|
-
import PostSticky from '../post-sticky';
|
|
28
|
-
import PostSlug from '../post-slug';
|
|
29
|
-
import PostFormat from '../post-format';
|
|
30
|
-
import { unlock } from '../../../lock-unlock';
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
PostStatus: PostStatusPanel,
|
|
34
|
-
PrivatePostExcerptPanel,
|
|
35
|
-
PostContentInformation,
|
|
36
|
-
PostLastEditedPanel,
|
|
37
|
-
} = unlock( editorPrivateApis );
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Module Constants
|
|
41
|
-
*/
|
|
42
|
-
const PANEL_NAME = 'post-status';
|
|
43
|
-
|
|
44
|
-
export default function PostStatus() {
|
|
45
|
-
const { isOpened, isRemoved, showPostContentPanels } = useSelect(
|
|
46
|
-
( select ) => {
|
|
47
|
-
// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
|
|
48
|
-
// not use isEditorPanelEnabled since this panel should not be disabled through the UI.
|
|
49
|
-
const {
|
|
50
|
-
isEditorPanelRemoved,
|
|
51
|
-
isEditorPanelOpened,
|
|
52
|
-
getCurrentPostType,
|
|
53
|
-
} = select( editorStore );
|
|
54
|
-
const postType = getCurrentPostType();
|
|
55
|
-
return {
|
|
56
|
-
isRemoved: isEditorPanelRemoved( PANEL_NAME ),
|
|
57
|
-
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
58
|
-
// Post excerpt panel is rendered in different place depending on the post type.
|
|
59
|
-
// So we cannot make this check inside the PostExcerpt component based on the current edited entity.
|
|
60
|
-
showPostContentPanels: ! [
|
|
61
|
-
'wp_template',
|
|
62
|
-
'wp_template_part',
|
|
63
|
-
'wp_block',
|
|
64
|
-
].includes( postType ),
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
[]
|
|
68
|
-
);
|
|
69
|
-
const { toggleEditorPanelOpened } = useDispatch( editorStore );
|
|
70
|
-
|
|
71
|
-
if ( isRemoved ) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<PanelBody
|
|
77
|
-
className="edit-post-post-status"
|
|
78
|
-
title={ __( 'Summary' ) }
|
|
79
|
-
opened={ isOpened }
|
|
80
|
-
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
81
|
-
>
|
|
82
|
-
<PluginPostStatusInfo.Slot>
|
|
83
|
-
{ ( fills ) => (
|
|
84
|
-
<>
|
|
85
|
-
{ showPostContentPanels && (
|
|
86
|
-
<VStack
|
|
87
|
-
spacing={ 3 }
|
|
88
|
-
// TODO: this needs to be consolidated with the panel in site editor, when we unify them.
|
|
89
|
-
style={ { marginBlockEnd: '24px' } }
|
|
90
|
-
>
|
|
91
|
-
<PostFeaturedImagePanel
|
|
92
|
-
withPanelBody={ false }
|
|
93
|
-
/>
|
|
94
|
-
<PrivatePostExcerptPanel />
|
|
95
|
-
<VStack spacing={ 1 }>
|
|
96
|
-
<PostContentInformation />
|
|
97
|
-
<PostLastEditedPanel />
|
|
98
|
-
</VStack>
|
|
99
|
-
</VStack>
|
|
100
|
-
) }
|
|
101
|
-
<VStack
|
|
102
|
-
spacing={ 1 }
|
|
103
|
-
style={ { marginBlockEnd: '12px' } }
|
|
104
|
-
>
|
|
105
|
-
<PostStatusPanel />
|
|
106
|
-
<PostSchedulePanel />
|
|
107
|
-
<PostTemplatePanel />
|
|
108
|
-
<PostURLPanel />
|
|
109
|
-
<PostSyncStatus />
|
|
110
|
-
</VStack>
|
|
111
|
-
<PostSticky />
|
|
112
|
-
<PostFormat />
|
|
113
|
-
<PostSlug />
|
|
114
|
-
<PostAuthorPanel />
|
|
115
|
-
{ fills }
|
|
116
|
-
<HStack
|
|
117
|
-
style={ {
|
|
118
|
-
marginTop: '16px',
|
|
119
|
-
} }
|
|
120
|
-
>
|
|
121
|
-
<PostTrash />
|
|
122
|
-
</HStack>
|
|
123
|
-
</>
|
|
124
|
-
) }
|
|
125
|
-
</PluginPostStatusInfo.Slot>
|
|
126
|
-
</PanelBody>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
PostSticky as PostStickyForm,
|
|
6
|
-
PostStickyCheck,
|
|
7
|
-
privateApis as editorPrivateApis,
|
|
8
|
-
} from '@wordpress/editor';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { unlock } from '../../../lock-unlock';
|
|
14
|
-
|
|
15
|
-
const { PostPanelRow } = unlock( editorPrivateApis );
|
|
16
|
-
|
|
17
|
-
export function PostSticky() {
|
|
18
|
-
return (
|
|
19
|
-
<PostStickyCheck>
|
|
20
|
-
<PostPanelRow>
|
|
21
|
-
<PostStickyForm />
|
|
22
|
-
</PostPanelRow>
|
|
23
|
-
</PostStickyCheck>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default PostSticky;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import { Dropdown, Button } from '@wordpress/components';
|
|
6
|
-
import {
|
|
7
|
-
PostVisibility as PostVisibilityForm,
|
|
8
|
-
PostVisibilityLabel,
|
|
9
|
-
PostVisibilityCheck,
|
|
10
|
-
usePostVisibilityLabel,
|
|
11
|
-
privateApis as editorPrivateApis,
|
|
12
|
-
} from '@wordpress/editor';
|
|
13
|
-
import { useMemo, useState } from '@wordpress/element';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { unlock } from '../../../lock-unlock';
|
|
19
|
-
|
|
20
|
-
const { PostPanelRow } = unlock( editorPrivateApis );
|
|
21
|
-
|
|
22
|
-
export function PostVisibility() {
|
|
23
|
-
// Use internal state instead of a ref to make sure that the component
|
|
24
|
-
// re-renders when the popover's anchor updates.
|
|
25
|
-
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
26
|
-
// Memoize popoverProps to avoid returning a new object every time.
|
|
27
|
-
const popoverProps = useMemo(
|
|
28
|
-
() => ( {
|
|
29
|
-
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
30
|
-
// move around when the label changes.
|
|
31
|
-
anchor: popoverAnchor,
|
|
32
|
-
placement: 'bottom-end',
|
|
33
|
-
} ),
|
|
34
|
-
[ popoverAnchor ]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<PostVisibilityCheck
|
|
39
|
-
render={ ( { canEdit } ) => (
|
|
40
|
-
<PostPanelRow
|
|
41
|
-
label={ __( 'Visibility' ) }
|
|
42
|
-
ref={ setPopoverAnchor }
|
|
43
|
-
>
|
|
44
|
-
{ ! canEdit && (
|
|
45
|
-
<span>
|
|
46
|
-
<PostVisibilityLabel />
|
|
47
|
-
</span>
|
|
48
|
-
) }
|
|
49
|
-
{ canEdit && (
|
|
50
|
-
<Dropdown
|
|
51
|
-
contentClassName="edit-post-post-visibility__dialog"
|
|
52
|
-
popoverProps={ popoverProps }
|
|
53
|
-
focusOnMount
|
|
54
|
-
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
55
|
-
<PostVisibilityToggle
|
|
56
|
-
isOpen={ isOpen }
|
|
57
|
-
onClick={ onToggle }
|
|
58
|
-
/>
|
|
59
|
-
) }
|
|
60
|
-
renderContent={ ( { onClose } ) => (
|
|
61
|
-
<PostVisibilityForm onClose={ onClose } />
|
|
62
|
-
) }
|
|
63
|
-
/>
|
|
64
|
-
) }
|
|
65
|
-
</PostPanelRow>
|
|
66
|
-
) }
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function PostVisibilityToggle( { isOpen, onClick } ) {
|
|
72
|
-
const label = usePostVisibilityLabel();
|
|
73
|
-
return (
|
|
74
|
-
<Button
|
|
75
|
-
__next40pxDefaultSize
|
|
76
|
-
className="edit-post-post-visibility__toggle"
|
|
77
|
-
variant="tertiary"
|
|
78
|
-
aria-expanded={ isOpen }
|
|
79
|
-
// translators: %s: Current post visibility.
|
|
80
|
-
aria-label={ sprintf( __( 'Select visibility: %s' ), label ) }
|
|
81
|
-
onClick={ onClick }
|
|
82
|
-
>
|
|
83
|
-
{ label }
|
|
84
|
-
</Button>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default PostVisibility;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
|
-
import { __, _x } from '@wordpress/i18n';
|
|
6
|
-
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import { forwardRef } from '@wordpress/element';
|
|
8
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { unlock } from '../../../lock-unlock';
|
|
14
|
-
import { sidebars } from '../settings-sidebar';
|
|
15
|
-
|
|
16
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
17
|
-
|
|
18
|
-
const SettingsHeader = ( _, ref ) => {
|
|
19
|
-
const { documentLabel } = useSelect( ( select ) => {
|
|
20
|
-
const { getPostTypeLabel } = select( editorStore );
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
// translators: Default label for the Document sidebar tab, not selected.
|
|
24
|
-
documentLabel: getPostTypeLabel() || _x( 'Document', 'noun' ),
|
|
25
|
-
};
|
|
26
|
-
}, [] );
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Tabs.TabList ref={ ref }>
|
|
30
|
-
<Tabs.Tab
|
|
31
|
-
tabId={ sidebars.document }
|
|
32
|
-
// Used for focus management in the SettingsSidebar component.
|
|
33
|
-
data-tab-id={ sidebars.document }
|
|
34
|
-
>
|
|
35
|
-
{ documentLabel }
|
|
36
|
-
</Tabs.Tab>
|
|
37
|
-
<Tabs.Tab
|
|
38
|
-
tabId={ sidebars.block }
|
|
39
|
-
// Used for focus management in the SettingsSidebar component.
|
|
40
|
-
data-tab-id={ sidebars.block }
|
|
41
|
-
>
|
|
42
|
-
{ /* translators: Text label for the Block Settings Sidebar tab. */ }
|
|
43
|
-
{ __( 'Block' ) }
|
|
44
|
-
</Tabs.Tab>
|
|
45
|
-
</Tabs.TabList>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default forwardRef( SettingsHeader );
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
BlockInspector,
|
|
6
|
-
store as blockEditorStore,
|
|
7
|
-
} from '@wordpress/block-editor';
|
|
8
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
-
import {
|
|
10
|
-
Platform,
|
|
11
|
-
useCallback,
|
|
12
|
-
useContext,
|
|
13
|
-
useEffect,
|
|
14
|
-
useRef,
|
|
15
|
-
} from '@wordpress/element';
|
|
16
|
-
import { isRTL, __, sprintf } from '@wordpress/i18n';
|
|
17
|
-
import { drawerLeft, drawerRight } from '@wordpress/icons';
|
|
18
|
-
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
19
|
-
import {
|
|
20
|
-
store as editorStore,
|
|
21
|
-
PageAttributesPanel,
|
|
22
|
-
PluginDocumentSettingPanel,
|
|
23
|
-
PluginSidebar,
|
|
24
|
-
PostDiscussionPanel,
|
|
25
|
-
PostLastRevisionPanel,
|
|
26
|
-
PostTaxonomiesPanel,
|
|
27
|
-
privateApis as editorPrivateApis,
|
|
28
|
-
} from '@wordpress/editor';
|
|
29
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
30
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Internal dependencies
|
|
34
|
-
*/
|
|
35
|
-
import SettingsHeader from '../settings-header';
|
|
36
|
-
import PostStatus from '../post-status';
|
|
37
|
-
import MetaBoxes from '../../meta-boxes';
|
|
38
|
-
import { store as editPostStore } from '../../../store';
|
|
39
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
40
|
-
import { unlock } from '../../../lock-unlock';
|
|
41
|
-
|
|
42
|
-
const { PostCardPanel, PostActions, interfaceStore } =
|
|
43
|
-
unlock( editorPrivateApis );
|
|
44
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
45
|
-
const { PatternOverridesPanel, useAutoSwitchEditorSidebars } =
|
|
46
|
-
unlock( editorPrivateApis );
|
|
47
|
-
|
|
48
|
-
const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {
|
|
49
|
-
web: true,
|
|
50
|
-
native: false,
|
|
51
|
-
} );
|
|
52
|
-
export const sidebars = {
|
|
53
|
-
document: 'edit-post/document',
|
|
54
|
-
block: 'edit-post/block',
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const SidebarContent = ( { tabName, keyboardShortcut, isEditingTemplate } ) => {
|
|
58
|
-
const tabListRef = useRef( null );
|
|
59
|
-
// Because `PluginSidebar` renders a `ComplementaryArea`, we
|
|
60
|
-
// need to forward the `Tabs` context so it can be passed through the
|
|
61
|
-
// underlying slot/fill.
|
|
62
|
-
const tabsContextValue = useContext( Tabs.Context );
|
|
63
|
-
|
|
64
|
-
// This effect addresses a race condition caused by tabbing from the last
|
|
65
|
-
// block in the editor into the settings sidebar. Without this effect, the
|
|
66
|
-
// selected tab and browser focus can become separated in an unexpected way
|
|
67
|
-
// (e.g the "block" tab is focused, but the "post" tab is selected).
|
|
68
|
-
useEffect( () => {
|
|
69
|
-
const tabsElements = Array.from(
|
|
70
|
-
tabListRef.current?.querySelectorAll( '[role="tab"]' ) || []
|
|
71
|
-
);
|
|
72
|
-
const selectedTabElement = tabsElements.find(
|
|
73
|
-
// We are purposefully using a custom `data-tab-id` attribute here
|
|
74
|
-
// because we don't want rely on any assumptions about `Tabs`
|
|
75
|
-
// component internals.
|
|
76
|
-
( element ) => element.getAttribute( 'data-tab-id' ) === tabName
|
|
77
|
-
);
|
|
78
|
-
const activeElement = selectedTabElement?.ownerDocument.activeElement;
|
|
79
|
-
const tabsHasFocus = tabsElements.some( ( element ) => {
|
|
80
|
-
return activeElement && activeElement.id === element.id;
|
|
81
|
-
} );
|
|
82
|
-
if (
|
|
83
|
-
tabsHasFocus &&
|
|
84
|
-
selectedTabElement &&
|
|
85
|
-
selectedTabElement.id !== activeElement?.id
|
|
86
|
-
) {
|
|
87
|
-
selectedTabElement?.focus();
|
|
88
|
-
}
|
|
89
|
-
}, [ tabName ] );
|
|
90
|
-
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
91
|
-
|
|
92
|
-
const onActionPerformed = useCallback(
|
|
93
|
-
( actionId, items ) => {
|
|
94
|
-
switch ( actionId ) {
|
|
95
|
-
case 'move-to-trash':
|
|
96
|
-
{
|
|
97
|
-
const postType = items[ 0 ].type;
|
|
98
|
-
document.location.href = addQueryArgs( 'edit.php', {
|
|
99
|
-
post_type: postType,
|
|
100
|
-
} );
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
case 'duplicate-post':
|
|
104
|
-
{
|
|
105
|
-
const newItem = items[ 0 ];
|
|
106
|
-
const title =
|
|
107
|
-
typeof newItem.title === 'string'
|
|
108
|
-
? newItem.title
|
|
109
|
-
: newItem.title?.rendered;
|
|
110
|
-
createSuccessNotice(
|
|
111
|
-
sprintf(
|
|
112
|
-
// translators: %s: Title of the created post e.g: "Post 1".
|
|
113
|
-
__( '"%s" successfully created.' ),
|
|
114
|
-
title
|
|
115
|
-
),
|
|
116
|
-
{
|
|
117
|
-
type: 'snackbar',
|
|
118
|
-
id: 'duplicate-post-action',
|
|
119
|
-
actions: [
|
|
120
|
-
{
|
|
121
|
-
label: __( 'Edit' ),
|
|
122
|
-
onClick: () => {
|
|
123
|
-
const postId = newItem.id;
|
|
124
|
-
document.location.href =
|
|
125
|
-
addQueryArgs( 'post.php', {
|
|
126
|
-
post: postId,
|
|
127
|
-
action: 'edit',
|
|
128
|
-
} );
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
[ createSuccessNotice ]
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<PluginSidebar
|
|
143
|
-
identifier={ tabName }
|
|
144
|
-
header={
|
|
145
|
-
<Tabs.Context.Provider value={ tabsContextValue }>
|
|
146
|
-
<SettingsHeader ref={ tabListRef } />
|
|
147
|
-
</Tabs.Context.Provider>
|
|
148
|
-
}
|
|
149
|
-
closeLabel={ __( 'Close Settings' ) }
|
|
150
|
-
// This classname is added so we can apply a corrective negative
|
|
151
|
-
// margin to the panel.
|
|
152
|
-
// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
|
|
153
|
-
className="edit-post-sidebar__panel"
|
|
154
|
-
headerClassName="edit-post-sidebar__panel-tabs"
|
|
155
|
-
/* translators: button label text should, if possible, be under 16 characters. */
|
|
156
|
-
title={ __( 'Settings' ) }
|
|
157
|
-
toggleShortcut={ keyboardShortcut }
|
|
158
|
-
icon={ isRTL() ? drawerLeft : drawerRight }
|
|
159
|
-
isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
|
|
160
|
-
>
|
|
161
|
-
<Tabs.Context.Provider value={ tabsContextValue }>
|
|
162
|
-
<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>
|
|
163
|
-
<PostCardPanel
|
|
164
|
-
actions={
|
|
165
|
-
<PostActions
|
|
166
|
-
onActionPerformed={ onActionPerformed }
|
|
167
|
-
/>
|
|
168
|
-
}
|
|
169
|
-
/>
|
|
170
|
-
{ ! isEditingTemplate && <PostStatus /> }
|
|
171
|
-
<PluginDocumentSettingPanel.Slot />
|
|
172
|
-
<PostLastRevisionPanel />
|
|
173
|
-
<PostTaxonomiesPanel />
|
|
174
|
-
<PostDiscussionPanel />
|
|
175
|
-
<PageAttributesPanel />
|
|
176
|
-
<PatternOverridesPanel />
|
|
177
|
-
{ ! isEditingTemplate && <MetaBoxes location="side" /> }
|
|
178
|
-
</Tabs.TabPanel>
|
|
179
|
-
<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>
|
|
180
|
-
<BlockInspector />
|
|
181
|
-
</Tabs.TabPanel>
|
|
182
|
-
</Tabs.Context.Provider>
|
|
183
|
-
</PluginSidebar>
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const SettingsSidebar = () => {
|
|
188
|
-
useAutoSwitchEditorSidebars();
|
|
189
|
-
const { tabName, keyboardShortcut, isEditingTemplate } = useSelect(
|
|
190
|
-
( select ) => {
|
|
191
|
-
const shortcut = select(
|
|
192
|
-
keyboardShortcutsStore
|
|
193
|
-
).getShortcutRepresentation( 'core/editor/toggle-sidebar' );
|
|
194
|
-
|
|
195
|
-
const sidebar =
|
|
196
|
-
select( interfaceStore ).getActiveComplementaryArea( 'core' );
|
|
197
|
-
const _isEditorSidebarOpened = [
|
|
198
|
-
sidebars.block,
|
|
199
|
-
sidebars.document,
|
|
200
|
-
].includes( sidebar );
|
|
201
|
-
let _tabName = sidebar;
|
|
202
|
-
if ( ! _isEditorSidebarOpened ) {
|
|
203
|
-
_tabName = !! select(
|
|
204
|
-
blockEditorStore
|
|
205
|
-
).getBlockSelectionStart()
|
|
206
|
-
? sidebars.block
|
|
207
|
-
: sidebars.document;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return {
|
|
211
|
-
tabName: _tabName,
|
|
212
|
-
keyboardShortcut: shortcut,
|
|
213
|
-
isEditingTemplate:
|
|
214
|
-
select( editorStore ).getCurrentPostType() ===
|
|
215
|
-
'wp_template',
|
|
216
|
-
};
|
|
217
|
-
},
|
|
218
|
-
[]
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
const { openGeneralSidebar } = useDispatch( editPostStore );
|
|
222
|
-
|
|
223
|
-
const onTabSelect = useCallback(
|
|
224
|
-
( newSelectedTabId ) => {
|
|
225
|
-
if ( !! newSelectedTabId ) {
|
|
226
|
-
openGeneralSidebar( newSelectedTabId );
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
[ openGeneralSidebar ]
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
return (
|
|
233
|
-
<Tabs
|
|
234
|
-
selectedTabId={ tabName }
|
|
235
|
-
onSelect={ onTabSelect }
|
|
236
|
-
selectOnMove={ false }
|
|
237
|
-
>
|
|
238
|
-
<SidebarContent
|
|
239
|
-
tabName={ tabName }
|
|
240
|
-
keyboardShortcut={ keyboardShortcut }
|
|
241
|
-
isEditingTemplate={ isEditingTemplate }
|
|
242
|
-
/>
|
|
243
|
-
</Tabs>
|
|
244
|
-
);
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
export default SettingsSidebar;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.components-panel__header.edit-post-sidebar__panel-tabs {
|
|
2
|
-
padding-left: 0;
|
|
3
|
-
padding-right: $grid-unit-20;
|
|
4
|
-
|
|
5
|
-
.components-button.has-icon {
|
|
6
|
-
padding: 0;
|
|
7
|
-
min-width: $icon-size;
|
|
8
|
-
height: $icon-size;
|
|
9
|
-
|
|
10
|
-
@include break-medium() {
|
|
11
|
-
display: flex;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.edit-post-sidebar__panel {
|
|
17
|
-
margin-top: -1px;
|
|
18
|
-
}
|