@wordpress/editor 14.19.0 → 14.20.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/commands/index.js +1 -1
- package/build/components/commands/index.js.map +1 -1
- package/build/components/document-bar/index.js +3 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +21 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js +32 -20
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +2 -2
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/post-actions/actions.js +10 -8
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-card-panel/index.js +3 -3
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +19 -3
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +16 -6
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-status/index.js +1 -1
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/index.js +1 -1
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-template/hooks.js +6 -5
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +2 -3
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-visibility/index.js +39 -109
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js +2 -2
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js +14 -15
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/provider/index.js +7 -4
- package/build/components/provider/index.js.map +1 -1
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +8 -7
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/commands/index.js +1 -1
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +3 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +21 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +32 -20
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +2 -2
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/post-actions/actions.js +10 -8
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +3 -3
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +19 -3
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +16 -6
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-status/index.js +1 -1
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/index.js +1 -1
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-template/hooks.js +6 -5
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +2 -3
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-visibility/index.js +41 -111
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js +3 -3
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js +13 -14
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/provider/index.js +7 -4
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-selectors.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 +4 -138
- package/build-style/style.css +4 -138
- package/build-types/components/document-outline/index.d.ts.map +1 -1
- package/build-types/components/document-outline/item.d.ts +2 -1
- package/build-types/components/document-outline/item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/post-visibility/index.d.ts.map +1 -1
- package/build-types/components/post-visibility/label.d.ts.map +1 -1
- package/build-types/components/post-visibility/utils.d.ts +5 -20
- package/build-types/components/post-visibility/utils.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/autocompleters/style.scss +2 -3
- package/src/components/commands/index.js +1 -1
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/index.js +27 -1
- package/src/components/document-outline/item.js +38 -23
- package/src/components/document-outline/style.scss +2 -0
- package/src/components/entities-saved-states/entity-record-item.js +1 -4
- package/src/components/post-actions/actions.js +13 -8
- package/src/components/post-card-panel/index.js +2 -2
- package/src/components/post-publish-panel/maybe-category-panel.js +20 -5
- package/src/components/post-publish-panel/maybe-tags-panel.js +39 -22
- package/src/components/post-status/index.js +1 -1
- package/src/components/post-sticky/index.js +1 -1
- package/src/components/post-template/hooks.js +12 -8
- package/src/components/post-template/swap-template-button.js +6 -4
- package/src/components/post-visibility/index.js +41 -118
- package/src/components/post-visibility/label.js +7 -4
- package/src/components/post-visibility/utils.js +11 -8
- package/src/components/provider/index.js +9 -4
- package/src/store/private-selectors.js +2 -4
- package/src/store/selectors.js +9 -14
- package/src/style.scss +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/components/post-visibility/style.scss +0 -27
|
@@ -14,7 +14,7 @@ import HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selec
|
|
|
14
14
|
import { store as editorStore } from '../../store';
|
|
15
15
|
|
|
16
16
|
function MaybeCategoryPanel() {
|
|
17
|
-
const hasNoCategory = useSelect( ( select ) => {
|
|
17
|
+
const { hasNoCategory, hasSiteCategories } = useSelect( ( select ) => {
|
|
18
18
|
const postType = select( editorStore ).getCurrentPostType();
|
|
19
19
|
const { canUser, getEntityRecord } = select( coreStore );
|
|
20
20
|
const categoriesTaxonomy = getEntityRecord(
|
|
@@ -39,19 +39,30 @@ function MaybeCategoryPanel() {
|
|
|
39
39
|
select( editorStore ).getEditedPostAttribute(
|
|
40
40
|
categoriesTaxonomy.rest_base
|
|
41
41
|
);
|
|
42
|
+
const siteCategories = postTypeSupportsCategories
|
|
43
|
+
? !! select( coreStore ).getEntityRecords( 'taxonomy', 'category', {
|
|
44
|
+
exclude: [ defaultCategoryId ],
|
|
45
|
+
per_page: 1,
|
|
46
|
+
} )?.length
|
|
47
|
+
: false;
|
|
42
48
|
|
|
43
49
|
// This boolean should return true if everything is loaded
|
|
44
50
|
// ( categoriesTaxonomy, defaultCategory )
|
|
45
51
|
// and the post has not been assigned a category different than "uncategorized".
|
|
46
|
-
|
|
52
|
+
const noCategory =
|
|
47
53
|
!! categoriesTaxonomy &&
|
|
48
54
|
!! defaultCategory &&
|
|
49
55
|
postTypeSupportsCategories &&
|
|
50
56
|
( categories?.length === 0 ||
|
|
51
57
|
( categories?.length === 1 &&
|
|
52
|
-
defaultCategory?.id === categories[ 0 ] ) )
|
|
53
|
-
|
|
58
|
+
defaultCategory?.id === categories[ 0 ] ) );
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
hasNoCategory: noCategory,
|
|
62
|
+
hasSiteCategories: siteCategories,
|
|
63
|
+
};
|
|
54
64
|
}, [] );
|
|
65
|
+
|
|
55
66
|
const [ shouldShowPanel, setShouldShowPanel ] = useState( false );
|
|
56
67
|
useEffect( () => {
|
|
57
68
|
// We use state to avoid hiding the panel if the user edits the categories
|
|
@@ -61,7 +72,11 @@ function MaybeCategoryPanel() {
|
|
|
61
72
|
}
|
|
62
73
|
}, [ hasNoCategory ] );
|
|
63
74
|
|
|
64
|
-
|
|
75
|
+
// We only want to show the category panel:
|
|
76
|
+
// if the post type supports categories,
|
|
77
|
+
// if the site has categories other than the default category,
|
|
78
|
+
// and if the post has no other categories than the default category.
|
|
79
|
+
if ( ! shouldShowPanel || ! hasSiteCategories ) {
|
|
65
80
|
return null;
|
|
66
81
|
}
|
|
67
82
|
|
|
@@ -34,28 +34,45 @@ const TagsPanel = () => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const MaybeTagsPanel = () => {
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const _isPostTypeSupported = tagsTaxonomy?.types?.includes( postType );
|
|
45
|
-
const areTagsFetched = tagsTaxonomy !== undefined;
|
|
46
|
-
const tags =
|
|
47
|
-
tagsTaxonomy &&
|
|
48
|
-
select( editorStore ).getEditedPostAttribute(
|
|
49
|
-
tagsTaxonomy.rest_base
|
|
37
|
+
const { postHasTags, siteHasTags, isPostTypeSupported } = useSelect(
|
|
38
|
+
( select ) => {
|
|
39
|
+
const postType = select( editorStore ).getCurrentPostType();
|
|
40
|
+
const tagsTaxonomy = select( coreStore ).getEntityRecord(
|
|
41
|
+
'root',
|
|
42
|
+
'taxonomy',
|
|
43
|
+
'post_tag'
|
|
50
44
|
);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
const _isPostTypeSupported =
|
|
46
|
+
tagsTaxonomy?.types?.includes( postType );
|
|
47
|
+
const areTagsFetched = tagsTaxonomy !== undefined;
|
|
48
|
+
const tags =
|
|
49
|
+
tagsTaxonomy &&
|
|
50
|
+
select( editorStore ).getEditedPostAttribute(
|
|
51
|
+
tagsTaxonomy.rest_base
|
|
52
|
+
);
|
|
53
|
+
const siteTags = _isPostTypeSupported
|
|
54
|
+
? !! select( coreStore ).getEntityRecords(
|
|
55
|
+
'taxonomy',
|
|
56
|
+
'post_tag',
|
|
57
|
+
{ per_page: 1 }
|
|
58
|
+
)?.length
|
|
59
|
+
: false;
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
return {
|
|
62
|
+
postHasTags: !! tags?.length,
|
|
63
|
+
siteHasTags: siteTags,
|
|
64
|
+
isPostTypeSupported: areTagsFetched && _isPostTypeSupported,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
[]
|
|
68
|
+
);
|
|
69
|
+
const [ hadTagsWhenOpeningThePanel ] = useState( postHasTags );
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* We only want to show the tag panel if the post type supports
|
|
73
|
+
* tags and the site has tags.
|
|
74
|
+
*/
|
|
75
|
+
if ( ! isPostTypeSupported || ! siteHasTags ) {
|
|
59
76
|
return null;
|
|
60
77
|
}
|
|
61
78
|
|
|
@@ -63,9 +80,9 @@ const MaybeTagsPanel = () => {
|
|
|
63
80
|
* We only want to show the tag panel if the post didn't have
|
|
64
81
|
* any tags when the user hit the Publish button.
|
|
65
82
|
*
|
|
66
|
-
* We can't use the prop.
|
|
83
|
+
* We can't use the prop.postHasTags because it'll change to true
|
|
67
84
|
* if the user adds a new tag within the pre-publish panel.
|
|
68
|
-
* This would force a re-render and a new prop.
|
|
85
|
+
* This would force a re-render and a new prop.postHasTags check,
|
|
69
86
|
* hiding this panel and keeping the user from adding
|
|
70
87
|
* more than one tag.
|
|
71
88
|
*/
|
|
@@ -29,7 +29,7 @@ export default function PostSticky() {
|
|
|
29
29
|
<CheckboxControl
|
|
30
30
|
className="editor-post-sticky__checkbox-control"
|
|
31
31
|
label={ __( 'Sticky' ) }
|
|
32
|
-
help={ __( 'Pin this post to the top of the blog' ) }
|
|
32
|
+
help={ __( 'Pin this post to the top of the blog.' ) }
|
|
33
33
|
checked={ postSticky }
|
|
34
34
|
onChange={ () => editPost( { sticky: ! postSticky } ) }
|
|
35
35
|
__nextHasNoMarginBottom
|
|
@@ -31,17 +31,21 @@ export function useAllowSwitchingTemplates() {
|
|
|
31
31
|
} )
|
|
32
32
|
? getEntityRecord( 'root', 'site' )
|
|
33
33
|
: undefined;
|
|
34
|
-
|
|
35
|
-
per_page: -1,
|
|
36
|
-
} );
|
|
34
|
+
|
|
37
35
|
const isPostsPage = +postId === siteSettings?.page_for_posts;
|
|
36
|
+
const isFrontPage =
|
|
37
|
+
postType === 'page' && +postId === siteSettings?.page_on_front;
|
|
38
38
|
// If current page is set front page or posts page, we also need
|
|
39
39
|
// to check if the current theme has a template for it. If not
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const templates = isFrontPage
|
|
41
|
+
? getEntityRecords( 'postType', 'wp_template', {
|
|
42
|
+
per_page: -1,
|
|
43
|
+
} )
|
|
44
|
+
: [];
|
|
45
|
+
const hasFrontPage =
|
|
46
|
+
isFrontPage &&
|
|
47
|
+
!! templates?.some( ( { slug } ) => slug === 'front-page' );
|
|
48
|
+
return ! isPostsPage && ! hasFrontPage;
|
|
45
49
|
},
|
|
46
50
|
[ postId, postType ]
|
|
47
51
|
);
|
|
@@ -20,9 +20,7 @@ export default function SwapTemplateButton( { onClick } ) {
|
|
|
20
20
|
const { postType, postId } = useEditedPostContext();
|
|
21
21
|
const availableTemplates = useAvailableTemplates( postType );
|
|
22
22
|
const { editEntityRecord } = useDispatch( coreStore );
|
|
23
|
-
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
23
|
+
|
|
26
24
|
const onTemplateSelect = async ( template ) => {
|
|
27
25
|
editEntityRecord(
|
|
28
26
|
'postType',
|
|
@@ -36,7 +34,11 @@ export default function SwapTemplateButton( { onClick } ) {
|
|
|
36
34
|
};
|
|
37
35
|
return (
|
|
38
36
|
<>
|
|
39
|
-
<MenuItem
|
|
37
|
+
<MenuItem
|
|
38
|
+
disabled={ ! availableTemplates?.length }
|
|
39
|
+
accessibleWhenDisabled
|
|
40
|
+
onClick={ () => setShowModal( true ) }
|
|
41
|
+
>
|
|
40
42
|
{ __( 'Change template' ) }
|
|
41
43
|
</MenuItem>
|
|
42
44
|
{ showModal && (
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useState } from '@wordpress/element';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
TextControl,
|
|
8
|
+
RadioControl,
|
|
9
|
+
__experimentalVStack as VStack,
|
|
9
10
|
} from '@wordpress/components';
|
|
10
11
|
import { useInstanceId } from '@wordpress/compose';
|
|
11
12
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -14,7 +15,7 @@ import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
17
|
-
import {
|
|
18
|
+
import { VISIBILITY_OPTIONS } from './utils';
|
|
18
19
|
import { store as editorStore } from '../../store';
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -33,45 +34,29 @@ export default function PostVisibility( { onClose } ) {
|
|
|
33
34
|
password: select( editorStore ).getEditedPostAttribute( 'password' ),
|
|
34
35
|
} ) );
|
|
35
36
|
|
|
36
|
-
const { editPost
|
|
37
|
+
const { editPost } = useDispatch( editorStore );
|
|
37
38
|
|
|
38
39
|
const [ hasPassword, setHasPassword ] = useState( !! password );
|
|
39
|
-
const [ showPrivateConfirmDialog, setShowPrivateConfirmDialog ] =
|
|
40
|
-
useState( false );
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const confirmPrivate = () => {
|
|
55
|
-
editPost( { status: 'private', password: '' } );
|
|
56
|
-
setHasPassword( false );
|
|
57
|
-
setShowPrivateConfirmDialog( false );
|
|
58
|
-
savePost();
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const handleDialogCancel = () => {
|
|
62
|
-
setShowPrivateConfirmDialog( false );
|
|
63
|
-
};
|
|
41
|
+
function updateVisibility( value ) {
|
|
42
|
+
const nextValues = {
|
|
43
|
+
public: {
|
|
44
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
45
|
+
password: '',
|
|
46
|
+
},
|
|
47
|
+
private: { status: 'private', password: '' },
|
|
48
|
+
password: {
|
|
49
|
+
status: visibility === 'private' ? 'draft' : status,
|
|
50
|
+
password: password || '',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
password: password || '',
|
|
69
|
-
} );
|
|
70
|
-
setHasPassword( true );
|
|
71
|
-
};
|
|
54
|
+
editPost( nextValues[ value ] );
|
|
55
|
+
setHasPassword( value === 'password' );
|
|
56
|
+
}
|
|
72
57
|
|
|
73
|
-
const updatePassword = (
|
|
74
|
-
editPost( { password:
|
|
58
|
+
const updatePassword = ( value ) => {
|
|
59
|
+
editPost( { password: value } );
|
|
75
60
|
};
|
|
76
61
|
|
|
77
62
|
return (
|
|
@@ -81,90 +66,28 @@ export default function PostVisibility( { onClose } ) {
|
|
|
81
66
|
help={ __( 'Control how this post is viewed.' ) }
|
|
82
67
|
onClose={ onClose }
|
|
83
68
|
/>
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
{ __( 'Visibility' ) }
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
label={ visibilityOptions.public.label }
|
|
92
|
-
info={ visibilityOptions.public.info }
|
|
93
|
-
checked={ visibility === 'public' && ! hasPassword }
|
|
94
|
-
onChange={ setPublic }
|
|
95
|
-
/>
|
|
96
|
-
<PostVisibilityChoice
|
|
97
|
-
instanceId={ instanceId }
|
|
98
|
-
value="private"
|
|
99
|
-
label={ visibilityOptions.private.label }
|
|
100
|
-
info={ visibilityOptions.private.info }
|
|
101
|
-
checked={ visibility === 'private' }
|
|
102
|
-
onChange={ setPrivate }
|
|
103
|
-
/>
|
|
104
|
-
<PostVisibilityChoice
|
|
105
|
-
instanceId={ instanceId }
|
|
106
|
-
value="password"
|
|
107
|
-
label={ visibilityOptions.password.label }
|
|
108
|
-
info={ visibilityOptions.password.info }
|
|
109
|
-
checked={ hasPassword }
|
|
110
|
-
onChange={ setPasswordProtected }
|
|
69
|
+
<VStack spacing={ 4 }>
|
|
70
|
+
<RadioControl
|
|
71
|
+
label={ __( 'Visibility' ) }
|
|
72
|
+
hideLabelFromVision
|
|
73
|
+
options={ VISIBILITY_OPTIONS }
|
|
74
|
+
selected={ hasPassword ? 'password' : visibility }
|
|
75
|
+
onChange={ updateVisibility }
|
|
111
76
|
/>
|
|
112
77
|
{ hasPassword && (
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onChange={ updatePassword }
|
|
125
|
-
value={ password }
|
|
126
|
-
placeholder={ __( 'Use a secure password' ) }
|
|
127
|
-
/>
|
|
128
|
-
</div>
|
|
78
|
+
<TextControl
|
|
79
|
+
label={ __( 'Password' ) }
|
|
80
|
+
onChange={ updatePassword }
|
|
81
|
+
value={ password }
|
|
82
|
+
placeholder={ __( 'Use a secure password' ) }
|
|
83
|
+
type="text"
|
|
84
|
+
id={ `editor-post-visibility__password-input-${ instanceId }` }
|
|
85
|
+
__next40pxDefaultSize
|
|
86
|
+
__nextHasNoMarginBottom
|
|
87
|
+
maxLength={ 255 }
|
|
88
|
+
/>
|
|
129
89
|
) }
|
|
130
|
-
</
|
|
131
|
-
<ConfirmDialog
|
|
132
|
-
isOpen={ showPrivateConfirmDialog }
|
|
133
|
-
onConfirm={ confirmPrivate }
|
|
134
|
-
onCancel={ handleDialogCancel }
|
|
135
|
-
confirmButtonText={ __( 'Publish' ) }
|
|
136
|
-
size="medium"
|
|
137
|
-
>
|
|
138
|
-
{ __( 'Would you like to privately publish this post now?' ) }
|
|
139
|
-
</ConfirmDialog>
|
|
140
|
-
</div>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function PostVisibilityChoice( { instanceId, value, label, info, ...props } ) {
|
|
145
|
-
return (
|
|
146
|
-
<div className="editor-post-visibility__choice">
|
|
147
|
-
<input
|
|
148
|
-
type="radio"
|
|
149
|
-
name={ `editor-post-visibility__setting-${ instanceId }` }
|
|
150
|
-
value={ value }
|
|
151
|
-
id={ `editor-post-${ value }-${ instanceId }` }
|
|
152
|
-
aria-describedby={ `editor-post-${ value }-${ instanceId }-description` }
|
|
153
|
-
className="editor-post-visibility__radio"
|
|
154
|
-
{ ...props }
|
|
155
|
-
/>
|
|
156
|
-
<label
|
|
157
|
-
htmlFor={ `editor-post-${ value }-${ instanceId }` }
|
|
158
|
-
className="editor-post-visibility__label"
|
|
159
|
-
>
|
|
160
|
-
{ label }
|
|
161
|
-
</label>
|
|
162
|
-
<p
|
|
163
|
-
id={ `editor-post-${ value }-${ instanceId }-description` }
|
|
164
|
-
className="editor-post-visibility__info"
|
|
165
|
-
>
|
|
166
|
-
{ info }
|
|
167
|
-
</p>
|
|
90
|
+
</VStack>
|
|
168
91
|
</div>
|
|
169
92
|
);
|
|
170
93
|
}
|
|
@@ -6,7 +6,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { VISIBILITY_OPTIONS } from './utils';
|
|
10
10
|
import { store as editorStore } from '../../store';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -24,8 +24,11 @@ export default function PostVisibilityLabel() {
|
|
|
24
24
|
* @return {string} Post visibility label.
|
|
25
25
|
*/
|
|
26
26
|
export function usePostVisibilityLabel() {
|
|
27
|
-
const visibility = useSelect(
|
|
28
|
-
select( editorStore ).getEditedPostVisibility()
|
|
27
|
+
const visibility = useSelect(
|
|
28
|
+
( select ) => select( editorStore ).getEditedPostVisibility(),
|
|
29
|
+
[]
|
|
29
30
|
);
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
return VISIBILITY_OPTIONS.find( ( option ) => option.value === visibility )
|
|
33
|
+
?.label;
|
|
31
34
|
}
|
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
|
|
6
|
+
export const VISIBILITY_OPTIONS = [
|
|
7
|
+
{
|
|
8
8
|
label: __( 'Public' ),
|
|
9
|
-
|
|
9
|
+
value: 'public',
|
|
10
|
+
description: __( 'Visible to everyone.' ),
|
|
10
11
|
},
|
|
11
|
-
|
|
12
|
+
{
|
|
12
13
|
label: __( 'Private' ),
|
|
13
|
-
|
|
14
|
+
value: 'private',
|
|
15
|
+
description: __( 'Only visible to site admins and editors.' ),
|
|
14
16
|
},
|
|
15
|
-
|
|
17
|
+
{
|
|
16
18
|
label: __( 'Password protected' ),
|
|
17
|
-
|
|
19
|
+
value: 'password',
|
|
20
|
+
description: __( 'Only visible to those who know the password.' ),
|
|
18
21
|
},
|
|
19
|
-
|
|
22
|
+
];
|
|
@@ -182,6 +182,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
182
182
|
} = unlock( select( editorStore ) );
|
|
183
183
|
const { getEntitiesConfig } = select( coreStore );
|
|
184
184
|
|
|
185
|
+
const _mode = getRenderingMode();
|
|
185
186
|
const _defaultMode = getDefaultRenderingMode( post.type );
|
|
186
187
|
/**
|
|
187
188
|
* To avoid content "flash", wait until rendering mode has been resolved.
|
|
@@ -190,16 +191,20 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
190
191
|
* - Wait for template to be resolved if the default mode is 'template-locked'.
|
|
191
192
|
* - Wait for default mode to be resolved otherwise.
|
|
192
193
|
*/
|
|
193
|
-
const
|
|
194
|
+
const hasResolvedDefaultMode =
|
|
194
195
|
_defaultMode === 'template-locked'
|
|
195
196
|
? hasTemplate
|
|
196
197
|
: _defaultMode !== undefined;
|
|
198
|
+
// Wait until the default mode is retrieved and start rendering canvas.
|
|
199
|
+
const isRenderingModeReady = _defaultMode !== undefined;
|
|
197
200
|
|
|
198
201
|
return {
|
|
199
202
|
editorSettings: getEditorSettings(),
|
|
200
|
-
isReady: __unstableIsEditorReady()
|
|
201
|
-
mode:
|
|
202
|
-
defaultMode:
|
|
203
|
+
isReady: __unstableIsEditorReady(),
|
|
204
|
+
mode: isRenderingModeReady ? _mode : undefined,
|
|
205
|
+
defaultMode: hasResolvedDefaultMode
|
|
206
|
+
? _defaultMode
|
|
207
|
+
: undefined,
|
|
203
208
|
selection: getEditorSelection(),
|
|
204
209
|
postTypeEntities:
|
|
205
210
|
post.type === 'wp_template'
|
|
@@ -105,10 +105,8 @@ export const getPostIcon = createRegistrySelector(
|
|
|
105
105
|
postType === 'wp_template'
|
|
106
106
|
) {
|
|
107
107
|
const templateAreas =
|
|
108
|
-
select( coreStore ).
|
|
109
|
-
|
|
110
|
-
'__unstableBase'
|
|
111
|
-
)?.default_template_part_areas || [];
|
|
108
|
+
select( coreStore ).getCurrentTheme()
|
|
109
|
+
?.default_template_part_areas || [];
|
|
112
110
|
|
|
113
111
|
const areaData = templateAreas.find(
|
|
114
112
|
( item ) => options.area === item.area
|
package/src/store/selectors.js
CHANGED
|
@@ -1709,11 +1709,10 @@ export const __experimentalGetDefaultTemplateTypes = createRegistrySelector(
|
|
|
1709
1709
|
{
|
|
1710
1710
|
since: '6.8',
|
|
1711
1711
|
alternative:
|
|
1712
|
-
"select('core/core-data').
|
|
1712
|
+
"select('core/core-data').getCurrentTheme()?.default_template_types",
|
|
1713
1713
|
}
|
|
1714
1714
|
);
|
|
1715
|
-
return select( coreStore ).
|
|
1716
|
-
?.default_template_types;
|
|
1715
|
+
return select( coreStore ).getCurrentTheme()?.default_template_types;
|
|
1717
1716
|
}
|
|
1718
1717
|
);
|
|
1719
1718
|
|
|
@@ -1732,12 +1731,12 @@ export const __experimentalGetDefaultTemplatePartAreas = createRegistrySelector(
|
|
|
1732
1731
|
{
|
|
1733
1732
|
since: '6.8',
|
|
1734
1733
|
alternative:
|
|
1735
|
-
"select('core/core-data').
|
|
1734
|
+
"select('core/core-data').getCurrentTheme()?.default_template_part_areas",
|
|
1736
1735
|
}
|
|
1737
1736
|
);
|
|
1738
1737
|
|
|
1739
1738
|
const areas =
|
|
1740
|
-
select( coreStore ).
|
|
1739
|
+
select( coreStore ).getCurrentTheme()
|
|
1741
1740
|
?.default_template_part_areas || [];
|
|
1742
1741
|
|
|
1743
1742
|
return areas.map( ( item ) => {
|
|
@@ -1763,10 +1762,8 @@ export const __experimentalGetDefaultTemplateType = createRegistrySelector(
|
|
|
1763
1762
|
since: '6.8',
|
|
1764
1763
|
}
|
|
1765
1764
|
);
|
|
1766
|
-
const templateTypes =
|
|
1767
|
-
|
|
1768
|
-
'__unstableBase'
|
|
1769
|
-
)?.default_template_types;
|
|
1765
|
+
const templateTypes =
|
|
1766
|
+
select( coreStore ).getCurrentTheme()?.default_template_types;
|
|
1770
1767
|
|
|
1771
1768
|
if ( ! templateTypes ) {
|
|
1772
1769
|
return EMPTY_OBJECT;
|
|
@@ -1799,13 +1796,11 @@ export const __experimentalGetTemplateInfo = createRegistrySelector(
|
|
|
1799
1796
|
return EMPTY_OBJECT;
|
|
1800
1797
|
}
|
|
1801
1798
|
|
|
1802
|
-
const
|
|
1803
|
-
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
|
|
1804
|
-
?.default_template_types || [];
|
|
1799
|
+
const currentTheme = select( coreStore ).getCurrentTheme();
|
|
1805
1800
|
|
|
1801
|
+
const templateTypes = currentTheme?.default_template_types || [];
|
|
1806
1802
|
const templateAreas =
|
|
1807
|
-
|
|
1808
|
-
?.default_template_part_areas || [];
|
|
1803
|
+
currentTheme?.default_template_part_areas || [];
|
|
1809
1804
|
|
|
1810
1805
|
return getTemplateInfo( {
|
|
1811
1806
|
template,
|
package/src/style.scss
CHANGED
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
@import "./components/post-text-editor/style.scss";
|
|
42
42
|
@import "./components/post-title/style.scss";
|
|
43
43
|
@import "./components/post-url/style.scss";
|
|
44
|
-
@import "./components/post-visibility/style.scss";
|
|
45
44
|
@import "./components/posts-per-page/style.scss";
|
|
46
45
|
@import "./components/post-trash/style.scss";
|
|
47
46
|
@import "./components/preview-dropdown/style.scss";
|