@wordpress/edit-post 6.8.0 → 6.9.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/README.md +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/build/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +6 -6
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +4 -2
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-template/create-modal.js +116 -0
- package/build/components/sidebar/post-template/create-modal.js.map +1 -0
- package/build/components/sidebar/post-template/form.js +123 -0
- package/build/components/sidebar/post-template/form.js.map +1 -0
- package/build/components/sidebar/post-template/index.js +123 -0
- package/build/components/sidebar/post-template/index.js.map +1 -0
- package/build/components/sidebar/settings-sidebar/index.js +1 -3
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +31 -13
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/editor.js +1 -1
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -1
- package/build/editor.native.js.map +1 -1
- package/build/store/selectors.js +8 -8
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/build-module/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +7 -4
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +3 -2
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js +104 -0
- package/build-module/components/sidebar/post-template/create-modal.js.map +1 -0
- package/build-module/components/sidebar/post-template/form.js +106 -0
- package/build-module/components/sidebar/post-template/form.js.map +1 -0
- package/build-module/components/sidebar/post-template/index.js +109 -0
- package/build-module/components/sidebar/post-template/index.js.map +1 -0
- package/build-module/components/sidebar/settings-sidebar/index.js +1 -2
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +32 -14
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/editor.js +2 -2
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +2 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/store/selectors.js +8 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +56 -44
- package/build-style/style.css +56 -44
- package/package.json +27 -27
- package/src/components/keyboard-shortcut-help-modal/config.js +8 -0
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +14 -0
- package/src/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/src/components/sidebar/post-schedule/index.js +5 -3
- package/src/components/sidebar/post-schedule/style.scss +18 -3
- package/src/components/sidebar/post-status/index.js +3 -1
- package/src/components/sidebar/post-template/create-modal.js +146 -0
- package/src/components/sidebar/post-template/form.js +140 -0
- package/src/components/sidebar/post-template/index.js +101 -0
- package/src/components/sidebar/post-template/style.scss +46 -0
- package/src/components/sidebar/post-visibility/style.scss +4 -4
- package/src/components/sidebar/settings-sidebar/index.js +0 -2
- package/src/components/start-page-options/index.js +46 -22
- package/src/editor.js +2 -2
- package/src/editor.native.js +2 -2
- package/src/store/selectors.js +5 -8
- package/src/style.scss +1 -1
- package/build/components/sidebar/template/actions.js +0 -172
- package/build/components/sidebar/template/actions.js.map +0 -1
- package/build/components/sidebar/template/index.js +0 -164
- package/build/components/sidebar/template/index.js.map +0 -1
- package/build-module/components/sidebar/template/actions.js +0 -158
- package/build-module/components/sidebar/template/actions.js.map +0 -1
- package/build-module/components/sidebar/template/index.js +0 -145
- package/build-module/components/sidebar/template/index.js.map +0 -1
- package/src/components/sidebar/template/actions.js +0 -206
- package/src/components/sidebar/template/index.js +0 -160
- package/src/components/sidebar/template/style.scss +0 -43
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { partial, isEmpty, map, fromPairs } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import { useMemo } from '@wordpress/element';
|
|
11
|
-
import { Notice, PanelBody, SelectControl } from '@wordpress/components';
|
|
12
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
13
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import PostTemplateActions from './actions';
|
|
20
|
-
import { store as editPostStore } from '../../../store';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Module Constants
|
|
24
|
-
*/
|
|
25
|
-
const PANEL_NAME = 'template';
|
|
26
|
-
|
|
27
|
-
export function TemplatePanel() {
|
|
28
|
-
const {
|
|
29
|
-
isEnabled,
|
|
30
|
-
isOpened,
|
|
31
|
-
isPostsPage,
|
|
32
|
-
selectedTemplate,
|
|
33
|
-
availableTemplates,
|
|
34
|
-
fetchedTemplates,
|
|
35
|
-
isViewable,
|
|
36
|
-
template,
|
|
37
|
-
supportsTemplateMode,
|
|
38
|
-
canUserCreate,
|
|
39
|
-
} = useSelect( ( select ) => {
|
|
40
|
-
const {
|
|
41
|
-
isEditorPanelEnabled,
|
|
42
|
-
isEditorPanelOpened,
|
|
43
|
-
getEditedPostTemplate,
|
|
44
|
-
} = select( editPostStore );
|
|
45
|
-
const {
|
|
46
|
-
getEditedPostAttribute,
|
|
47
|
-
getEditorSettings,
|
|
48
|
-
getCurrentPostId,
|
|
49
|
-
getCurrentPostType,
|
|
50
|
-
} = select( editorStore );
|
|
51
|
-
const { getPostType, getEntityRecord, getEntityRecords, canUser } =
|
|
52
|
-
select( coreStore );
|
|
53
|
-
|
|
54
|
-
const currentPostId = getCurrentPostId();
|
|
55
|
-
const currentPostType = getCurrentPostType();
|
|
56
|
-
const settings = getEntityRecord( 'root', 'site' );
|
|
57
|
-
const _isViewable = getPostType( currentPostType )?.viewable ?? false;
|
|
58
|
-
const _supportsTemplateMode =
|
|
59
|
-
select( editorStore ).getEditorSettings().supportsTemplateMode &&
|
|
60
|
-
_isViewable;
|
|
61
|
-
|
|
62
|
-
const templateRecords = getEntityRecords( 'postType', 'wp_template', {
|
|
63
|
-
post_type: currentPostType,
|
|
64
|
-
per_page: -1,
|
|
65
|
-
} );
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
69
|
-
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
70
|
-
isPostsPage: currentPostId === settings?.page_for_posts,
|
|
71
|
-
selectedTemplate: getEditedPostAttribute( 'template' ),
|
|
72
|
-
availableTemplates: getEditorSettings().availableTemplates,
|
|
73
|
-
fetchedTemplates: templateRecords,
|
|
74
|
-
template: _supportsTemplateMode && getEditedPostTemplate(),
|
|
75
|
-
isViewable: _isViewable,
|
|
76
|
-
supportsTemplateMode: _supportsTemplateMode,
|
|
77
|
-
canUserCreate: canUser( 'create', 'templates' ),
|
|
78
|
-
};
|
|
79
|
-
}, [] );
|
|
80
|
-
|
|
81
|
-
const templates = useMemo( () => {
|
|
82
|
-
return {
|
|
83
|
-
...availableTemplates,
|
|
84
|
-
...fromPairs(
|
|
85
|
-
( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [
|
|
86
|
-
slug,
|
|
87
|
-
title.rendered,
|
|
88
|
-
] )
|
|
89
|
-
),
|
|
90
|
-
};
|
|
91
|
-
}, [ availableTemplates, fetchedTemplates ] );
|
|
92
|
-
|
|
93
|
-
const { toggleEditorPanelOpened } = useDispatch( editPostStore );
|
|
94
|
-
const { editPost } = useDispatch( editorStore );
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
! isEnabled ||
|
|
98
|
-
! isViewable ||
|
|
99
|
-
( isEmpty( availableTemplates ) &&
|
|
100
|
-
( ! supportsTemplateMode || ! canUserCreate ) )
|
|
101
|
-
) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const onTogglePanel = partial( toggleEditorPanelOpened, PANEL_NAME );
|
|
106
|
-
|
|
107
|
-
let panelTitle = __( 'Template' );
|
|
108
|
-
if ( !! template ) {
|
|
109
|
-
panelTitle = sprintf(
|
|
110
|
-
/* translators: %s: template title */
|
|
111
|
-
__( 'Template: %s' ),
|
|
112
|
-
template?.title ?? template.slug
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<PanelBody
|
|
118
|
-
title={ panelTitle }
|
|
119
|
-
opened={ isOpened }
|
|
120
|
-
onToggle={ onTogglePanel }
|
|
121
|
-
>
|
|
122
|
-
{ isPostsPage ? (
|
|
123
|
-
<Notice
|
|
124
|
-
className="edit-post-template__notice"
|
|
125
|
-
status="warning"
|
|
126
|
-
isDismissible={ false }
|
|
127
|
-
>
|
|
128
|
-
{ __( 'The posts page template cannot be changed.' ) }
|
|
129
|
-
</Notice>
|
|
130
|
-
) : (
|
|
131
|
-
<SelectControl
|
|
132
|
-
hideLabelFromVision
|
|
133
|
-
label={ __( 'Template:' ) }
|
|
134
|
-
value={
|
|
135
|
-
Object.keys( templates ).includes( selectedTemplate )
|
|
136
|
-
? selectedTemplate
|
|
137
|
-
: ''
|
|
138
|
-
}
|
|
139
|
-
onChange={ ( templateSlug ) => {
|
|
140
|
-
editPost( {
|
|
141
|
-
template: templateSlug || '',
|
|
142
|
-
} );
|
|
143
|
-
} }
|
|
144
|
-
options={ map(
|
|
145
|
-
templates,
|
|
146
|
-
( templateName, templateSlug ) => ( {
|
|
147
|
-
value: templateSlug,
|
|
148
|
-
label: templateName,
|
|
149
|
-
} )
|
|
150
|
-
) }
|
|
151
|
-
/>
|
|
152
|
-
) }
|
|
153
|
-
{ canUserCreate && (
|
|
154
|
-
<PostTemplateActions isPostsPage={ isPostsPage } />
|
|
155
|
-
) }
|
|
156
|
-
</PanelBody>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export default TemplatePanel;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
.edit-post-template__modal {
|
|
2
|
-
.components-base-control {
|
|
3
|
-
@include break-medium() {
|
|
4
|
-
width: $grid-unit * 40;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.components-modal__header {
|
|
9
|
-
border-bottom: none;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.components-modal__content::before {
|
|
13
|
-
margin-bottom: $grid-unit-05;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.edit-post-template__modal-actions {
|
|
18
|
-
margin-top: $grid-unit-15;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.edit-post-template-modal__tip {
|
|
22
|
-
padding: $grid-unit-20 $grid-unit-30;
|
|
23
|
-
background: $gray-100;
|
|
24
|
-
border-radius: $radius-block-ui;
|
|
25
|
-
|
|
26
|
-
@include break-medium() {
|
|
27
|
-
width: $grid-unit * 30;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.edit-post-template__notice {
|
|
32
|
-
margin: 0 0 $grid-unit-10 0;
|
|
33
|
-
|
|
34
|
-
.components-notice__content {
|
|
35
|
-
margin: 0;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.edit-post-template__actions {
|
|
40
|
-
button:not(:last-child) {
|
|
41
|
-
margin-right: $grid-unit-10;
|
|
42
|
-
}
|
|
43
|
-
}
|