@wordpress/edit-post 6.6.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 +6 -0
- package/README.md +1 -1
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +12 -4
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/template-title/index.js.map +1 -1
- package/build/components/header/tools-more-menu-group/index.js.map +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/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build/components/sidebar/featured-image/index.js.map +1 -1
- package/build/components/sidebar/page-attributes/index.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.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/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +14 -7
- 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/components/visual-editor/block-inspector-button.js +3 -7
- package/build/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build/editor.js +1 -1
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +9 -1
- package/build/editor.native.js.map +1 -1
- package/build/plugins/copy-content-menu-item/index.js +1 -1
- package/build/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +8 -8
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +13 -5
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/template-title/index.js.map +1 -1
- package/build-module/components/header/tools-more-menu-group/index.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/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build-module/components/sidebar/featured-image/index.js.map +1 -1
- package/build-module/components/sidebar/page-attributes/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.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/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +15 -5
- 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/components/visual-editor/block-inspector-button.js +3 -5
- package/build-module/components/visual-editor/block-inspector-button.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 +10 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build-module/store/actions.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 +60 -49
- package/build-style/style.css +60 -49
- package/package.json +28 -28
- package/src/components/block-manager/category.js +2 -2
- package/src/components/block-manager/index.js +15 -4
- package/src/components/device-preview/index.js +4 -6
- package/src/components/editor-initialization/listener-hooks.js +2 -3
- package/src/components/header/fullscreen-mode-close/index.js +2 -3
- package/src/components/header/header-toolbar/index.js +6 -11
- package/src/components/header/index.js +6 -9
- package/src/components/header/mode-switcher/index.js +4 -4
- package/src/components/header/post-publish-button-or-toggle.js +4 -6
- package/src/components/header/template-title/delete-template.js +2 -3
- package/src/components/header/template-title/index.js +2 -3
- package/src/components/header/tools-more-menu-group/index.js +2 -3
- 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/keyboard-shortcut-help-modal/test/index.js +2 -1
- package/src/components/keyboard-shortcuts/index.js +4 -8
- package/src/components/layout/actions-panel.js +6 -9
- package/src/components/layout/index.js +12 -21
- package/src/components/layout/index.native.js +4 -5
- package/src/components/preferences-modal/options/enable-custom-fields.js +2 -2
- package/src/components/preferences-modal/options/enable-panel.js +2 -3
- package/src/components/preferences-modal/options/enable-publish-sidebar.js +2 -3
- package/src/components/secondary-sidebar/inserter-sidebar.js +2 -3
- package/src/components/sidebar/discussion-panel/index.js +2 -3
- package/src/components/sidebar/featured-image/index.js +2 -3
- package/src/components/sidebar/page-attributes/index.js +2 -3
- package/src/components/sidebar/plugin-document-setting-panel/index.js +2 -3
- package/src/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/src/components/sidebar/plugin-sidebar/index.js +2 -3
- package/src/components/sidebar/post-excerpt/index.js +2 -3
- package/src/components/sidebar/post-link/index.js +2 -3
- package/src/components/sidebar/post-schedule/index.js +8 -4
- package/src/components/sidebar/post-schedule/style.scss +19 -6
- package/src/components/sidebar/post-status/index.js +5 -4
- 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 +5 -4
- package/src/components/sidebar/settings-sidebar/index.js +0 -2
- package/src/components/start-page-options/index.js +48 -28
- package/src/components/visual-editor/block-inspector-button.js +4 -8
- package/src/editor.js +8 -10
- package/src/editor.native.js +13 -6
- package/src/plugins/copy-content-menu-item/index.js +1 -1
- package/src/store/actions.js +322 -295
- package/src/store/selectors.js +21 -24
- package/src/style.scss +1 -1
- package/build/components/sidebar/template/actions.js +0 -167
- 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 -153
- 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 -203
- package/src/components/sidebar/template/index.js +0 -164
- package/src/components/sidebar/template/style.scss +0 -43
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
5
|
+
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { addTemplate } from '@wordpress/icons';
|
|
8
|
+
import { Notice, SelectControl, Button } from '@wordpress/components';
|
|
9
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { store as editPostStore } from '../../../store';
|
|
17
|
+
import PostTemplateCreateModal from './create-modal';
|
|
18
|
+
|
|
19
|
+
export default function PostTemplateForm( { onClose } ) {
|
|
20
|
+
const {
|
|
21
|
+
isPostsPage,
|
|
22
|
+
availableTemplates,
|
|
23
|
+
fetchedTemplates,
|
|
24
|
+
selectedTemplateSlug,
|
|
25
|
+
canCreate,
|
|
26
|
+
canEdit,
|
|
27
|
+
} = useSelect( ( select ) => {
|
|
28
|
+
const editorSettings = select( editorStore ).getEditorSettings();
|
|
29
|
+
const siteSettings = select( coreStore ).getEntityRecord(
|
|
30
|
+
'root',
|
|
31
|
+
'site'
|
|
32
|
+
);
|
|
33
|
+
const _isPostsPage =
|
|
34
|
+
select( editorStore ).getCurrentPostId() ===
|
|
35
|
+
siteSettings?.page_for_posts;
|
|
36
|
+
const canCreateTemplates = select( coreStore ).canUser(
|
|
37
|
+
'create',
|
|
38
|
+
'templates'
|
|
39
|
+
);
|
|
40
|
+
return {
|
|
41
|
+
isPostsPage: _isPostsPage,
|
|
42
|
+
availableTemplates: editorSettings.availableTemplates,
|
|
43
|
+
fetchedTemplates: select( coreStore ).getEntityRecords(
|
|
44
|
+
'postType',
|
|
45
|
+
'wp_template',
|
|
46
|
+
{
|
|
47
|
+
post_type: select( editorStore ).getCurrentPostType(),
|
|
48
|
+
per_page: -1,
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
selectedTemplateSlug:
|
|
52
|
+
select( editorStore ).getEditedPostAttribute( 'template' ),
|
|
53
|
+
canCreate: canCreateTemplates && ! _isPostsPage,
|
|
54
|
+
canEdit:
|
|
55
|
+
canCreateTemplates &&
|
|
56
|
+
editorSettings.supportsTemplateMode &&
|
|
57
|
+
!! select( editPostStore ).getEditedPostTemplate(),
|
|
58
|
+
};
|
|
59
|
+
}, [] );
|
|
60
|
+
|
|
61
|
+
const options = useMemo(
|
|
62
|
+
() =>
|
|
63
|
+
Object.entries( {
|
|
64
|
+
...availableTemplates,
|
|
65
|
+
...Object.fromEntries(
|
|
66
|
+
( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [
|
|
67
|
+
slug,
|
|
68
|
+
title.rendered,
|
|
69
|
+
] )
|
|
70
|
+
),
|
|
71
|
+
} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),
|
|
72
|
+
[ availableTemplates, fetchedTemplates ]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const selectedOption =
|
|
76
|
+
options.find( ( option ) => option.value === selectedTemplateSlug ) ??
|
|
77
|
+
options.find( ( option ) => ! option.value ); // The default option has '' value.
|
|
78
|
+
|
|
79
|
+
const { editPost } = useDispatch( editorStore );
|
|
80
|
+
const { __unstableSwitchToTemplateMode } = useDispatch( editPostStore );
|
|
81
|
+
|
|
82
|
+
const [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className="edit-post-post-template__form">
|
|
86
|
+
<InspectorPopoverHeader
|
|
87
|
+
title={ __( 'Template' ) }
|
|
88
|
+
help={ __(
|
|
89
|
+
'Templates define the way content is displayed when viewing your site.'
|
|
90
|
+
) }
|
|
91
|
+
actions={
|
|
92
|
+
canCreate
|
|
93
|
+
? [
|
|
94
|
+
{
|
|
95
|
+
icon: addTemplate,
|
|
96
|
+
label: __( 'Add template' ),
|
|
97
|
+
onClick: () => setIsCreateModalOpen( true ),
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
: []
|
|
101
|
+
}
|
|
102
|
+
onClose={ onClose }
|
|
103
|
+
/>
|
|
104
|
+
{ isPostsPage ? (
|
|
105
|
+
<Notice
|
|
106
|
+
className="edit-post-post-template__notice"
|
|
107
|
+
status="warning"
|
|
108
|
+
isDismissible={ false }
|
|
109
|
+
>
|
|
110
|
+
{ __( 'The posts page template cannot be changed.' ) }
|
|
111
|
+
</Notice>
|
|
112
|
+
) : (
|
|
113
|
+
<SelectControl
|
|
114
|
+
hideLabelFromVision
|
|
115
|
+
label={ __( 'Template' ) }
|
|
116
|
+
value={ selectedOption?.value ?? '' }
|
|
117
|
+
options={ options }
|
|
118
|
+
onChange={ ( slug ) =>
|
|
119
|
+
editPost( { template: slug || '' } )
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
122
|
+
) }
|
|
123
|
+
{ canEdit && (
|
|
124
|
+
<p>
|
|
125
|
+
<Button
|
|
126
|
+
variant="link"
|
|
127
|
+
onClick={ () => __unstableSwitchToTemplateMode() }
|
|
128
|
+
>
|
|
129
|
+
{ __( 'Edit template' ) }
|
|
130
|
+
</Button>
|
|
131
|
+
</p>
|
|
132
|
+
) }
|
|
133
|
+
{ isCreateModalOpen && (
|
|
134
|
+
<PostTemplateCreateModal
|
|
135
|
+
onClose={ () => setIsCreateModalOpen( false ) }
|
|
136
|
+
/>
|
|
137
|
+
) }
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
|
+
import { PanelRow, Dropdown, Button } from '@wordpress/components';
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import PostTemplateForm from './form';
|
|
15
|
+
|
|
16
|
+
export default function PostTemplate() {
|
|
17
|
+
const anchorRef = useRef();
|
|
18
|
+
|
|
19
|
+
const isVisible = useSelect( ( select ) => {
|
|
20
|
+
const postTypeSlug = select( editorStore ).getCurrentPostType();
|
|
21
|
+
const postType = select( coreStore ).getPostType( postTypeSlug );
|
|
22
|
+
if ( ! postType?.viewable ) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const settings = select( editorStore ).getEditorSettings();
|
|
27
|
+
const hasTemplates =
|
|
28
|
+
!! settings.availableTemplates &&
|
|
29
|
+
Object.keys( settings.availableTemplates ).length > 0;
|
|
30
|
+
if ( hasTemplates ) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const canCreateTemplates =
|
|
35
|
+
select( coreStore ).canUser( 'create', 'templates' ) ?? false;
|
|
36
|
+
return canCreateTemplates;
|
|
37
|
+
}, [] );
|
|
38
|
+
|
|
39
|
+
if ( ! isVisible ) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<PanelRow className="edit-post-post-template" ref={ anchorRef }>
|
|
45
|
+
<span>{ __( 'Template' ) }</span>
|
|
46
|
+
<Dropdown
|
|
47
|
+
popoverProps={ { anchorRef } }
|
|
48
|
+
position="bottom left"
|
|
49
|
+
className="edit-post-post-template__dropdown"
|
|
50
|
+
contentClassName="edit-post-post-template__dialog"
|
|
51
|
+
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
52
|
+
<PostTemplateToggle
|
|
53
|
+
isOpen={ isOpen }
|
|
54
|
+
onClick={ onToggle }
|
|
55
|
+
/>
|
|
56
|
+
) }
|
|
57
|
+
renderContent={ ( { onClose } ) => (
|
|
58
|
+
<PostTemplateForm onClose={ onClose } />
|
|
59
|
+
) }
|
|
60
|
+
/>
|
|
61
|
+
</PanelRow>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function PostTemplateToggle( { isOpen, onClick } ) {
|
|
66
|
+
const templateTitle = useSelect( ( select ) => {
|
|
67
|
+
const templateSlug =
|
|
68
|
+
select( editorStore ).getEditedPostAttribute( 'template' );
|
|
69
|
+
|
|
70
|
+
const settings = select( editorStore ).getEditorSettings();
|
|
71
|
+
if ( settings.availableTemplates[ templateSlug ] ) {
|
|
72
|
+
return settings.availableTemplates[ templateSlug ];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const template = select( coreStore )
|
|
76
|
+
.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )
|
|
77
|
+
?.find( ( { slug } ) => slug === templateSlug );
|
|
78
|
+
|
|
79
|
+
return template?.title.rendered;
|
|
80
|
+
}, [] );
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Button
|
|
84
|
+
className="edit-post-post-template__toggle"
|
|
85
|
+
variant="tertiary"
|
|
86
|
+
aria-expanded={ isOpen }
|
|
87
|
+
aria-label={
|
|
88
|
+
templateTitle
|
|
89
|
+
? sprintf(
|
|
90
|
+
// translators: %s: Name of the currently selected template.
|
|
91
|
+
__( 'Select template: %s' ),
|
|
92
|
+
templateTitle
|
|
93
|
+
)
|
|
94
|
+
: __( 'Select template' )
|
|
95
|
+
}
|
|
96
|
+
onClick={ onClick }
|
|
97
|
+
>
|
|
98
|
+
{ templateTitle ?? __( '(none)' ) }
|
|
99
|
+
</Button>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.edit-post-post-template {
|
|
2
|
+
width: 100%;
|
|
3
|
+
justify-content: flex-start;
|
|
4
|
+
|
|
5
|
+
span {
|
|
6
|
+
display: block;
|
|
7
|
+
width: 45%;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.edit-post-post-template__dropdown {
|
|
12
|
+
max-width: 55%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.components-button.edit-post-post-template__toggle {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
width: 100%;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.edit-post-post-template__dialog {
|
|
23
|
+
z-index: z-index(".edit-post-post-template__dialog");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.edit-post-post-template__form {
|
|
27
|
+
// sidebar width - popover padding - form margin
|
|
28
|
+
min-width: $sidebar-width - $grid-unit-20 - $grid-unit-20;
|
|
29
|
+
margin: $grid-unit-10;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.edit-post-post-template__create-modal {
|
|
33
|
+
.components-modal__header {
|
|
34
|
+
border-bottom: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.components-modal__content::before {
|
|
38
|
+
margin-bottom: $grid-unit-05;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.edit-post-post-template__create-form {
|
|
43
|
+
@include break-medium() {
|
|
44
|
+
width: $grid-unit * 40;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.edit-post-post-visibility {
|
|
2
2
|
width: 100%;
|
|
3
|
-
justify-content:
|
|
3
|
+
justify-content: flex-start;
|
|
4
4
|
|
|
5
5
|
span {
|
|
6
6
|
display: block;
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.edit-post-post-visibility__dialog .
|
|
12
|
-
// sidebar width - padding -
|
|
13
|
-
width: $sidebar-width - $grid-unit-20 - $
|
|
11
|
+
.edit-post-post-visibility__dialog .editor-post-visibility {
|
|
12
|
+
// sidebar width - popover padding - form margin
|
|
13
|
+
min-width: $sidebar-width - $grid-unit-20 - $grid-unit-20;
|
|
14
|
+
margin: $grid-unit-10;
|
|
14
15
|
}
|
|
@@ -25,7 +25,6 @@ import PageAttributes from '../page-attributes';
|
|
|
25
25
|
import MetaBoxes from '../../meta-boxes';
|
|
26
26
|
import PluginDocumentSettingPanel from '../plugin-document-setting-panel';
|
|
27
27
|
import PluginSidebarEditPost from '../plugin-sidebar';
|
|
28
|
-
import Template from '../template';
|
|
29
28
|
import TemplateSummary from '../template-summary';
|
|
30
29
|
import { __ } from '@wordpress/i18n';
|
|
31
30
|
import { useSelect } from '@wordpress/data';
|
|
@@ -86,7 +85,6 @@ const SettingsSidebar = () => {
|
|
|
86
85
|
{ ! isTemplateMode && sidebarName === 'edit-post/document' && (
|
|
87
86
|
<>
|
|
88
87
|
<PostStatus />
|
|
89
|
-
<Template />
|
|
90
88
|
<PluginDocumentSettingPanel.Slot />
|
|
91
89
|
<LastRevision />
|
|
92
90
|
<PostLink />
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Modal } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
6
|
+
import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
7
7
|
import {
|
|
8
8
|
store as blockEditorStore,
|
|
9
9
|
__experimentalBlockPatternsList as BlockPatternsList,
|
|
@@ -17,17 +17,42 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
17
17
|
*/
|
|
18
18
|
import { store as editPostStore } from '../../store';
|
|
19
19
|
|
|
20
|
+
function useStartPatterns() {
|
|
21
|
+
// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
|
|
22
|
+
// and it has no postTypes declares and the current post type is page or if
|
|
23
|
+
// the current post type is part of the postTypes declared.
|
|
24
|
+
const { blockPatternsWithPostContentBlockType, postType } = useSelect(
|
|
25
|
+
( select ) => {
|
|
26
|
+
const { __experimentalGetPatternsByBlockTypes } =
|
|
27
|
+
select( blockEditorStore );
|
|
28
|
+
const { getCurrentPostType } = select( editorStore );
|
|
29
|
+
return {
|
|
30
|
+
// get pa
|
|
31
|
+
blockPatternsWithPostContentBlockType:
|
|
32
|
+
__experimentalGetPatternsByBlockTypes(
|
|
33
|
+
'core/post-content'
|
|
34
|
+
),
|
|
35
|
+
postType: getCurrentPostType(),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return useMemo( () => {
|
|
42
|
+
// filter patterns without postTypes declared if the current postType is page
|
|
43
|
+
// or patterns that declare the current postType in its post type array.
|
|
44
|
+
return blockPatternsWithPostContentBlockType.filter( ( pattern ) => {
|
|
45
|
+
return (
|
|
46
|
+
( postType === 'page' && ! pattern.postTypes ) ||
|
|
47
|
+
( Array.isArray( pattern.postTypes ) &&
|
|
48
|
+
pattern.postTypes.includes( postType ) )
|
|
49
|
+
);
|
|
50
|
+
} );
|
|
51
|
+
}, [ postType, blockPatternsWithPostContentBlockType ] );
|
|
52
|
+
}
|
|
53
|
+
|
|
20
54
|
function PatternSelection( { onChoosePattern } ) {
|
|
21
|
-
const
|
|
22
|
-
const { __experimentalGetPatternsByBlockTypes } = select(
|
|
23
|
-
blockEditorStore
|
|
24
|
-
);
|
|
25
|
-
return {
|
|
26
|
-
blockPatterns: __experimentalGetPatternsByBlockTypes(
|
|
27
|
-
'core/post-content'
|
|
28
|
-
),
|
|
29
|
-
};
|
|
30
|
-
}, [] );
|
|
55
|
+
const blockPatterns = useStartPatterns();
|
|
31
56
|
const shownBlockPatterns = useAsyncList( blockPatterns );
|
|
32
57
|
const { resetEditorBlocks } = useDispatch( editorStore );
|
|
33
58
|
return (
|
|
@@ -52,33 +77,28 @@ export default function StartPageOptions() {
|
|
|
52
77
|
const [ modalState, setModalState ] = useState(
|
|
53
78
|
START_PAGE_MODAL_STATES.INITIAL
|
|
54
79
|
);
|
|
80
|
+
const blockPatterns = useStartPatterns();
|
|
81
|
+
const hasStartPattern = blockPatterns.length > 0;
|
|
55
82
|
const shouldOpenModel = useSelect(
|
|
56
83
|
( select ) => {
|
|
57
|
-
if (
|
|
84
|
+
if (
|
|
85
|
+
! hasStartPattern ||
|
|
86
|
+
modalState !== START_PAGE_MODAL_STATES.INITIAL
|
|
87
|
+
) {
|
|
58
88
|
return false;
|
|
59
89
|
}
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
getCurrentPostType,
|
|
65
|
-
getEditedPostContent,
|
|
66
|
-
isEditedPostSaveable,
|
|
67
|
-
} = select( editorStore );
|
|
68
|
-
const { isEditingTemplate, isFeatureActive } = select(
|
|
69
|
-
editPostStore
|
|
70
|
-
);
|
|
90
|
+
const { getEditedPostContent, isEditedPostSaveable } =
|
|
91
|
+
select( editorStore );
|
|
92
|
+
const { isEditingTemplate, isFeatureActive } =
|
|
93
|
+
select( editPostStore );
|
|
71
94
|
return (
|
|
72
|
-
getCurrentPostType() === 'page' &&
|
|
73
95
|
! isEditedPostSaveable() &&
|
|
74
96
|
'' === getEditedPostContent() &&
|
|
75
97
|
! isEditingTemplate() &&
|
|
76
|
-
! isFeatureActive( 'welcomeGuide' )
|
|
77
|
-
__experimentalGetPatternsByBlockTypes( 'core/post-content' )
|
|
78
|
-
.length >= 1
|
|
98
|
+
! isFeatureActive( 'welcomeGuide' )
|
|
79
99
|
);
|
|
80
100
|
},
|
|
81
|
-
[ modalState ]
|
|
101
|
+
[ modalState, hasStartPattern ]
|
|
82
102
|
);
|
|
83
103
|
|
|
84
104
|
useEffect( () => {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { noop } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -17,6 +12,8 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
|
17
12
|
*/
|
|
18
13
|
import { store as editPostStore } from '../../store';
|
|
19
14
|
|
|
15
|
+
const noop = () => {};
|
|
16
|
+
|
|
20
17
|
export function BlockInspectorButton( { onClick = noop, small = false } ) {
|
|
21
18
|
const { shortcut, areAdvancedSettingsOpened } = useSelect(
|
|
22
19
|
( select ) => ( {
|
|
@@ -29,9 +26,8 @@ export function BlockInspectorButton( { onClick = noop, small = false } ) {
|
|
|
29
26
|
} ),
|
|
30
27
|
[]
|
|
31
28
|
);
|
|
32
|
-
const { openGeneralSidebar, closeGeneralSidebar } =
|
|
33
|
-
editPostStore
|
|
34
|
-
);
|
|
29
|
+
const { openGeneralSidebar, closeGeneralSidebar } =
|
|
30
|
+
useDispatch( editPostStore );
|
|
35
31
|
|
|
36
32
|
const label = areAdvancedSettingsOpened
|
|
37
33
|
? __( 'Hide more settings' )
|
package/src/editor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { forEach,
|
|
4
|
+
import { forEach, map, without } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -56,9 +56,8 @@ function Editor( {
|
|
|
56
56
|
getEditedPostTemplate,
|
|
57
57
|
getHiddenBlockTypes,
|
|
58
58
|
} = select( editPostStore );
|
|
59
|
-
const { getEntityRecord, getPostType, getEntityRecords } =
|
|
60
|
-
coreStore
|
|
61
|
-
);
|
|
59
|
+
const { getEntityRecord, getPostType, getEntityRecords } =
|
|
60
|
+
select( coreStore );
|
|
62
61
|
const { getEditorSettings } = select( editorStore );
|
|
63
62
|
const { getBlockTypes } = select( blocksStore );
|
|
64
63
|
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes(
|
|
@@ -75,8 +74,8 @@ function Editor( {
|
|
|
75
74
|
} else {
|
|
76
75
|
postObject = getEntityRecord( 'postType', postType, postId );
|
|
77
76
|
}
|
|
78
|
-
const supportsTemplateMode =
|
|
79
|
-
.supportsTemplateMode;
|
|
77
|
+
const supportsTemplateMode =
|
|
78
|
+
getEditorSettings().supportsTemplateMode;
|
|
80
79
|
const isViewable = getPostType( postType )?.viewable ?? false;
|
|
81
80
|
|
|
82
81
|
return {
|
|
@@ -104,9 +103,8 @@ function Editor( {
|
|
|
104
103
|
[ postType, postId ]
|
|
105
104
|
);
|
|
106
105
|
|
|
107
|
-
const { updatePreferredStyleVariations, setIsInserterOpened } =
|
|
108
|
-
editPostStore
|
|
109
|
-
);
|
|
106
|
+
const { updatePreferredStyleVariations, setIsInserterOpened } =
|
|
107
|
+
useDispatch( editPostStore );
|
|
110
108
|
|
|
111
109
|
const editorSettings = useMemo( () => {
|
|
112
110
|
const result = {
|
|
@@ -128,7 +126,7 @@ function Editor( {
|
|
|
128
126
|
};
|
|
129
127
|
|
|
130
128
|
// Omit hidden block types if exists and non-empty.
|
|
131
|
-
if (
|
|
129
|
+
if ( hiddenBlockTypes.length > 0 ) {
|
|
132
130
|
// Defer to passed setting for `allowedBlockTypes` if provided as
|
|
133
131
|
// anything other than `true` (where `true` is equivalent to allow
|
|
134
132
|
// all block types).
|
package/src/editor.native.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import memize from 'memize';
|
|
5
|
-
import {
|
|
5
|
+
import { map, without } from 'lodash';
|
|
6
6
|
import { I18nManager } from 'react-native';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -62,7 +62,7 @@ class Editor extends Component {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// Omit hidden block types if exists and non-empty.
|
|
65
|
-
if (
|
|
65
|
+
if ( hiddenBlockTypes.length > 0 ) {
|
|
66
66
|
if ( settings.allowedBlockTypes === undefined ) {
|
|
67
67
|
// If no specific flags for allowedBlockTypes are set, assume `true`
|
|
68
68
|
// meaning allow all block types.
|
|
@@ -92,12 +92,15 @@ class Editor extends Component {
|
|
|
92
92
|
() => {
|
|
93
93
|
if ( this.postTitleRef ) {
|
|
94
94
|
this.postTitleRef.focus();
|
|
95
|
+
} else {
|
|
96
|
+
// If the post title ref is not available, we postpone setting focus to when it's available.
|
|
97
|
+
this.focusTitleWhenAvailable = true;
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
);
|
|
98
101
|
|
|
99
|
-
this.subscriptionParentFeaturedImageIdNativeUpdated =
|
|
100
|
-
( payload ) => {
|
|
102
|
+
this.subscriptionParentFeaturedImageIdNativeUpdated =
|
|
103
|
+
subscribeFeaturedImageIdNativeUpdated( ( payload ) => {
|
|
101
104
|
editEntityRecord(
|
|
102
105
|
'postType',
|
|
103
106
|
postType,
|
|
@@ -107,8 +110,7 @@ class Editor extends Component {
|
|
|
107
110
|
undoIgnore: true,
|
|
108
111
|
}
|
|
109
112
|
);
|
|
110
|
-
}
|
|
111
|
-
);
|
|
113
|
+
} );
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
componentWillUnmount() {
|
|
@@ -122,6 +124,11 @@ class Editor extends Component {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
setTitleRef( titleRef ) {
|
|
127
|
+
if ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {
|
|
128
|
+
this.focusTitleWhenAvailable = false;
|
|
129
|
+
titleRef.focus();
|
|
130
|
+
}
|
|
131
|
+
|
|
125
132
|
this.postTitleRef = titleRef;
|
|
126
133
|
}
|
|
127
134
|
|