@wordpress/edit-post 7.27.1 → 7.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/header/index.js +2 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +0 -5
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js +4 -7
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +6 -6
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/sidebar/template-summary/index.js +4 -8
- package/build/components/sidebar/template-summary/index.js.map +1 -1
- package/build/components/visual-editor/index.js +5 -4
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +6 -6
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/editor.js +5 -15
- package/build/editor.js.map +1 -1
- package/build/hooks/use-post-history.js +1 -1
- package/build/hooks/use-post-history.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +2 -2
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +1 -11
- package/build/store/actions.js.map +1 -1
- package/build-module/components/header/index.js +2 -4
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +0 -5
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js +4 -7
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +6 -6
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/template-summary/index.js +4 -8
- package/build-module/components/sidebar/template-summary/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +5 -4
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +6 -6
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/editor.js +5 -15
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/use-post-history.js +1 -1
- package/build-module/hooks/use-post-history.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +2 -2
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +0 -9
- package/build-module/store/actions.js.map +1 -1
- package/package.json +8 -8
- package/src/components/header/index.js +2 -5
- package/src/components/header/mode-switcher/index.js +16 -25
- package/src/components/sidebar/settings-header/index.js +3 -6
- package/src/components/sidebar/settings-sidebar/index.js +7 -7
- package/src/components/sidebar/template-summary/index.js +3 -7
- package/src/components/visual-editor/index.js +4 -2
- package/src/components/welcome-guide/index.js +11 -6
- package/src/editor.js +17 -30
- package/src/hooks/use-post-history.js +1 -1
- package/src/plugins/welcome-guide-menu-item/index.js +3 -3
- package/src/store/actions.js +0 -9
|
@@ -48,7 +48,7 @@ export const sidebars = {
|
|
|
48
48
|
const SidebarContent = ( {
|
|
49
49
|
sidebarName,
|
|
50
50
|
keyboardShortcut,
|
|
51
|
-
|
|
51
|
+
isEditingTemplate,
|
|
52
52
|
} ) => {
|
|
53
53
|
// Because `PluginSidebarEditPost` renders a `ComplementaryArea`, we
|
|
54
54
|
// need to forward the `Tabs` context so it can be passed through the
|
|
@@ -77,7 +77,7 @@ const SidebarContent = ( {
|
|
|
77
77
|
>
|
|
78
78
|
<Tabs.Context.Provider value={ tabsContextValue }>
|
|
79
79
|
<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>
|
|
80
|
-
{ !
|
|
80
|
+
{ ! isEditingTemplate && (
|
|
81
81
|
<>
|
|
82
82
|
<PostStatus />
|
|
83
83
|
<PluginDocumentSettingPanel.Slot />
|
|
@@ -90,7 +90,7 @@ const SidebarContent = ( {
|
|
|
90
90
|
<MetaBoxes location="side" />
|
|
91
91
|
</>
|
|
92
92
|
) }
|
|
93
|
-
{
|
|
93
|
+
{ isEditingTemplate && <TemplateSummary /> }
|
|
94
94
|
</Tabs.TabPanel>
|
|
95
95
|
<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>
|
|
96
96
|
<BlockInspector />
|
|
@@ -105,7 +105,7 @@ const SettingsSidebar = () => {
|
|
|
105
105
|
sidebarName,
|
|
106
106
|
isSettingsSidebarActive,
|
|
107
107
|
keyboardShortcut,
|
|
108
|
-
|
|
108
|
+
isEditingTemplate,
|
|
109
109
|
} = useSelect( ( select ) => {
|
|
110
110
|
// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.
|
|
111
111
|
// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.
|
|
@@ -132,8 +132,8 @@ const SettingsSidebar = () => {
|
|
|
132
132
|
sidebarName: sidebar,
|
|
133
133
|
isSettingsSidebarActive: isSettingsSidebar,
|
|
134
134
|
keyboardShortcut: shortcut,
|
|
135
|
-
|
|
136
|
-
select( editorStore ).
|
|
135
|
+
isEditingTemplate:
|
|
136
|
+
select( editorStore ).getCurrentPostType() === 'wp_template',
|
|
137
137
|
};
|
|
138
138
|
}, [] );
|
|
139
139
|
|
|
@@ -161,7 +161,7 @@ const SettingsSidebar = () => {
|
|
|
161
161
|
<SidebarContent
|
|
162
162
|
sidebarName={ sidebarName }
|
|
163
163
|
keyboardShortcut={ keyboardShortcut }
|
|
164
|
-
|
|
164
|
+
isEditingTemplate={ isEditingTemplate }
|
|
165
165
|
/>
|
|
166
166
|
</Tabs>
|
|
167
167
|
);
|
|
@@ -4,16 +4,12 @@
|
|
|
4
4
|
import { Icon, layout } from '@wordpress/icons';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as editPostStore } from '../../../store';
|
|
7
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
12
8
|
|
|
13
9
|
function TemplateSummary() {
|
|
14
10
|
const template = useSelect( ( select ) => {
|
|
15
|
-
const {
|
|
16
|
-
return
|
|
11
|
+
const { getCurrentPost } = select( editorStore );
|
|
12
|
+
return getCurrentPost();
|
|
17
13
|
}, [] );
|
|
18
14
|
|
|
19
15
|
if ( ! template ) {
|
|
@@ -30,6 +30,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
30
30
|
renderingMode,
|
|
31
31
|
isBlockBasedTheme,
|
|
32
32
|
hasV3BlocksOnly,
|
|
33
|
+
isEditingTemplate,
|
|
33
34
|
} = useSelect( ( select ) => {
|
|
34
35
|
const { isFeatureActive } = select( editPostStore );
|
|
35
36
|
const { getEditorSettings, getRenderingMode } = select( editorStore );
|
|
@@ -43,6 +44,8 @@ export default function VisualEditor( { styles } ) {
|
|
|
43
44
|
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
|
|
44
45
|
return type.apiVersion >= 3;
|
|
45
46
|
} ),
|
|
47
|
+
isEditingTemplate:
|
|
48
|
+
select( editorStore ).getCurrentPostType() === 'wp_template',
|
|
46
49
|
};
|
|
47
50
|
}, [] );
|
|
48
51
|
const hasMetaBoxes = useSelect(
|
|
@@ -74,12 +77,11 @@ export default function VisualEditor( { styles } ) {
|
|
|
74
77
|
const isToBeIframed =
|
|
75
78
|
( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&
|
|
76
79
|
! hasMetaBoxes ) ||
|
|
77
|
-
|
|
80
|
+
isEditingTemplate;
|
|
78
81
|
|
|
79
82
|
return (
|
|
80
83
|
<div
|
|
81
84
|
className={ classnames( 'edit-post-visual-editor', {
|
|
82
|
-
'is-template-mode': renderingMode === 'template-only',
|
|
83
85
|
'has-inline-canvas': ! isToBeIframed,
|
|
84
86
|
} ) }
|
|
85
87
|
>
|
|
@@ -12,17 +12,18 @@ import WelcomeGuideTemplate from './template';
|
|
|
12
12
|
import { store as editPostStore } from '../../store';
|
|
13
13
|
|
|
14
14
|
export default function WelcomeGuide() {
|
|
15
|
-
const { isActive,
|
|
15
|
+
const { isActive, isEditingTemplate } = useSelect( ( select ) => {
|
|
16
16
|
const { isFeatureActive } = select( editPostStore );
|
|
17
|
-
const {
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
const { getCurrentPostType } = select( editorStore );
|
|
18
|
+
const _isEditingTemplate = getCurrentPostType() === 'wp_template';
|
|
19
|
+
|
|
20
|
+
const feature = _isEditingTemplate
|
|
20
21
|
? 'welcomeGuideTemplate'
|
|
21
22
|
: 'welcomeGuide';
|
|
22
23
|
|
|
23
24
|
return {
|
|
24
25
|
isActive: isFeatureActive( feature ),
|
|
25
|
-
|
|
26
|
+
isEditingTemplate: _isEditingTemplate,
|
|
26
27
|
};
|
|
27
28
|
}, [] );
|
|
28
29
|
|
|
@@ -30,5 +31,9 @@ export default function WelcomeGuide() {
|
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
return
|
|
34
|
+
return isEditingTemplate ? (
|
|
35
|
+
<WelcomeGuideTemplate />
|
|
36
|
+
) : (
|
|
37
|
+
<WelcomeGuideDefault />
|
|
38
|
+
);
|
|
34
39
|
}
|
package/src/editor.js
CHANGED
|
@@ -42,36 +42,16 @@ function Editor( {
|
|
|
42
42
|
( select ) => {
|
|
43
43
|
const { isFeatureActive, getEditedPostTemplate } =
|
|
44
44
|
select( editPostStore );
|
|
45
|
-
const {
|
|
46
|
-
|
|
47
|
-
getPostType,
|
|
48
|
-
getEntityRecords,
|
|
49
|
-
canUser,
|
|
50
|
-
} = select( coreStore );
|
|
45
|
+
const { getEntityRecord, getPostType, canUser } =
|
|
46
|
+
select( coreStore );
|
|
51
47
|
const { getEditorSettings } = select( editorStore );
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if ( isTemplate ) {
|
|
60
|
-
const posts = getEntityRecords(
|
|
61
|
-
'postType',
|
|
62
|
-
currentPost.postType,
|
|
63
|
-
{
|
|
64
|
-
wp_id: currentPost.postId,
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
postObject = posts?.[ 0 ];
|
|
68
|
-
} else {
|
|
69
|
-
postObject = getEntityRecord(
|
|
70
|
-
'postType',
|
|
71
|
-
currentPost.postType,
|
|
72
|
-
currentPost.postId
|
|
73
|
-
);
|
|
74
|
-
}
|
|
48
|
+
|
|
49
|
+
const postObject = getEntityRecord(
|
|
50
|
+
'postType',
|
|
51
|
+
currentPost.postType,
|
|
52
|
+
currentPost.postId
|
|
53
|
+
);
|
|
54
|
+
|
|
75
55
|
const supportsTemplateMode =
|
|
76
56
|
getEditorSettings().supportsTemplateMode;
|
|
77
57
|
const isViewable =
|
|
@@ -84,7 +64,10 @@ function Editor( {
|
|
|
84
64
|
'preferredStyleVariations'
|
|
85
65
|
),
|
|
86
66
|
template:
|
|
87
|
-
supportsTemplateMode &&
|
|
67
|
+
supportsTemplateMode &&
|
|
68
|
+
isViewable &&
|
|
69
|
+
canEditTemplate &&
|
|
70
|
+
currentPost.postType !== 'wp_template'
|
|
88
71
|
? getEditedPostTemplate()
|
|
89
72
|
: null,
|
|
90
73
|
post: postObject,
|
|
@@ -94,12 +77,15 @@ function Editor( {
|
|
|
94
77
|
);
|
|
95
78
|
|
|
96
79
|
const { updatePreferredStyleVariations } = useDispatch( editPostStore );
|
|
80
|
+
const defaultRenderingMode =
|
|
81
|
+
currentPost.postType === 'wp_template' ? 'all' : 'post-only';
|
|
97
82
|
|
|
98
83
|
const editorSettings = useMemo( () => {
|
|
99
84
|
const result = {
|
|
100
85
|
...settings,
|
|
101
86
|
getPostLinkProps,
|
|
102
87
|
goBack,
|
|
88
|
+
defaultRenderingMode,
|
|
103
89
|
__experimentalPreferredStyleVariations: {
|
|
104
90
|
value: preferredStyleVariations,
|
|
105
91
|
onChange: updatePreferredStyleVariations,
|
|
@@ -114,6 +100,7 @@ function Editor( {
|
|
|
114
100
|
updatePreferredStyleVariations,
|
|
115
101
|
getPostLinkProps,
|
|
116
102
|
goBack,
|
|
103
|
+
defaultRenderingMode,
|
|
117
104
|
] );
|
|
118
105
|
|
|
119
106
|
if ( ! post ) {
|
|
@@ -50,7 +50,7 @@ export default function usePostHistory( initialPostId, initialPostType ) {
|
|
|
50
50
|
return {
|
|
51
51
|
href: newUrl,
|
|
52
52
|
onClick: ( event ) => {
|
|
53
|
-
event
|
|
53
|
+
event?.preventDefault();
|
|
54
54
|
dispatch( {
|
|
55
55
|
type: 'push',
|
|
56
56
|
post: { postId: params.postId, postType: params.postType },
|
|
@@ -7,16 +7,16 @@ import { __ } from '@wordpress/i18n';
|
|
|
7
7
|
import { store as editorStore } from '@wordpress/editor';
|
|
8
8
|
|
|
9
9
|
export default function WelcomeGuideMenuItem() {
|
|
10
|
-
const
|
|
10
|
+
const isEditingTemplate = useSelect(
|
|
11
11
|
( select ) =>
|
|
12
|
-
select( editorStore ).
|
|
12
|
+
select( editorStore ).getCurrentPostType() === 'wp_template',
|
|
13
13
|
[]
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<PreferenceToggleMenuItem
|
|
18
18
|
scope="core/edit-post"
|
|
19
|
-
name={
|
|
19
|
+
name={ isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide' }
|
|
20
20
|
label={ __( 'Welcome Guide' ) }
|
|
21
21
|
/>
|
|
22
22
|
);
|
package/src/store/actions.js
CHANGED
|
@@ -469,15 +469,6 @@ export function setIsEditingTemplate() {
|
|
|
469
469
|
return { type: 'NOTHING' };
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
-
/**
|
|
473
|
-
* Switches to the template mode.
|
|
474
|
-
*/
|
|
475
|
-
export const __unstableSwitchToTemplateMode =
|
|
476
|
-
() =>
|
|
477
|
-
( { registry } ) => {
|
|
478
|
-
registry.dispatch( editorStore ).setRenderingMode( 'template-only' );
|
|
479
|
-
};
|
|
480
|
-
|
|
481
472
|
/**
|
|
482
473
|
* Create a block based template.
|
|
483
474
|
*
|