@wordpress/editor 14.19.3 → 14.21.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 +4 -0
- package/README.md +1 -1
- package/build/components/commands/index.js +1 -1
- package/build/components/commands/index.js.map +1 -1
- package/build/components/plugin-pre-publish-panel/index.js +1 -1
- package/build/components/plugin-pre-publish-panel/index.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-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 +5 -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/block-theme.js +1 -3
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +1 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/create-new-template.js +1 -4
- package/build/components/post-template/create-new-template.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/preview-dropdown/index.js +2 -4
- package/build/components/preview-dropdown/index.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/plugin-pre-publish-panel/index.js +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.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-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 +5 -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/block-theme.js +1 -3
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +1 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/create-new-template.js +1 -4
- package/build-module/components/post-template/create-new-template.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/preview-dropdown/index.js +2 -4
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -137
- package/build-style/style.css +6 -137
- package/build-types/components/plugin-pre-publish-panel/index.d.ts +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-status/index.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template.d.ts +1 -3
- package/build-types/components/post-template/create-new-template.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/preview-dropdown/index.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/plugin-pre-publish-panel/index.js +1 -1
- package/src/components/post-actions/actions.js +13 -8
- 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 +7 -2
- package/src/components/post-sticky/index.js +1 -1
- package/src/components/post-template/block-theme.js +1 -3
- package/src/components/post-template/create-new-template-modal.js +1 -0
- package/src/components/post-template/create-new-template.js +1 -2
- package/src/components/post-template/hooks.js +12 -8
- package/src/components/post-template/style.scss +4 -0
- 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/preview-dropdown/index.js +6 -3
- package/src/style.scss +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/components/post-visibility/style.scss +0 -27
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { _public as public };
|
|
7
|
-
export namespace _private {
|
|
8
|
-
let label_1: string;
|
|
9
|
-
export { label_1 as label };
|
|
10
|
-
let info_1: string;
|
|
11
|
-
export { info_1 as info };
|
|
12
|
-
}
|
|
13
|
-
export { _private as private };
|
|
14
|
-
export namespace password {
|
|
15
|
-
let label_2: string;
|
|
16
|
-
export { label_2 as label };
|
|
17
|
-
let info_2: string;
|
|
18
|
-
export { info_2 as info };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
export const VISIBILITY_OPTIONS: {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}[];
|
|
21
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/post-visibility/utils.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/post-visibility/utils.js"],"names":[],"mappings":"AAKA;;;;IAgBE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/preview-dropdown/index.js"],"names":[],"mappings":"AAgCA;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/preview-dropdown/index.js"],"names":[],"mappings":"AAgCA;;;uCA2KC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.21.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -34,41 +34,41 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "7.25.7",
|
|
37
|
-
"@wordpress/a11y": "^4.
|
|
38
|
-
"@wordpress/api-fetch": "^7.
|
|
39
|
-
"@wordpress/blob": "^4.
|
|
40
|
-
"@wordpress/block-editor": "^14.
|
|
41
|
-
"@wordpress/blocks": "^14.
|
|
42
|
-
"@wordpress/commands": "^1.
|
|
43
|
-
"@wordpress/components": "^29.
|
|
44
|
-
"@wordpress/compose": "^7.
|
|
45
|
-
"@wordpress/core-data": "^7.
|
|
46
|
-
"@wordpress/data": "^10.
|
|
47
|
-
"@wordpress/dataviews": "^4.
|
|
48
|
-
"@wordpress/date": "^5.
|
|
49
|
-
"@wordpress/deprecated": "^4.
|
|
50
|
-
"@wordpress/dom": "^4.
|
|
51
|
-
"@wordpress/element": "^6.
|
|
52
|
-
"@wordpress/fields": "^0.
|
|
53
|
-
"@wordpress/hooks": "^4.
|
|
54
|
-
"@wordpress/html-entities": "^4.
|
|
55
|
-
"@wordpress/i18n": "^5.
|
|
56
|
-
"@wordpress/icons": "^10.
|
|
57
|
-
"@wordpress/interface": "^9.
|
|
58
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
59
|
-
"@wordpress/keycodes": "^4.
|
|
60
|
-
"@wordpress/media-utils": "^5.
|
|
61
|
-
"@wordpress/notices": "^5.
|
|
62
|
-
"@wordpress/patterns": "^2.
|
|
63
|
-
"@wordpress/plugins": "^7.
|
|
64
|
-
"@wordpress/preferences": "^4.
|
|
65
|
-
"@wordpress/private-apis": "^1.
|
|
66
|
-
"@wordpress/reusable-blocks": "^5.
|
|
67
|
-
"@wordpress/rich-text": "^7.
|
|
68
|
-
"@wordpress/server-side-render": "^5.
|
|
69
|
-
"@wordpress/url": "^4.
|
|
70
|
-
"@wordpress/warning": "^3.
|
|
71
|
-
"@wordpress/wordcount": "^4.
|
|
37
|
+
"@wordpress/a11y": "^4.21.0",
|
|
38
|
+
"@wordpress/api-fetch": "^7.21.0",
|
|
39
|
+
"@wordpress/blob": "^4.21.0",
|
|
40
|
+
"@wordpress/block-editor": "^14.16.0",
|
|
41
|
+
"@wordpress/blocks": "^14.10.0",
|
|
42
|
+
"@wordpress/commands": "^1.21.0",
|
|
43
|
+
"@wordpress/components": "^29.7.0",
|
|
44
|
+
"@wordpress/compose": "^7.21.0",
|
|
45
|
+
"@wordpress/core-data": "^7.21.0",
|
|
46
|
+
"@wordpress/data": "^10.21.0",
|
|
47
|
+
"@wordpress/dataviews": "^4.17.0",
|
|
48
|
+
"@wordpress/date": "^5.21.0",
|
|
49
|
+
"@wordpress/deprecated": "^4.21.0",
|
|
50
|
+
"@wordpress/dom": "^4.21.0",
|
|
51
|
+
"@wordpress/element": "^6.21.0",
|
|
52
|
+
"@wordpress/fields": "^0.13.0",
|
|
53
|
+
"@wordpress/hooks": "^4.21.0",
|
|
54
|
+
"@wordpress/html-entities": "^4.21.0",
|
|
55
|
+
"@wordpress/i18n": "^5.21.0",
|
|
56
|
+
"@wordpress/icons": "^10.21.0",
|
|
57
|
+
"@wordpress/interface": "^9.6.0",
|
|
58
|
+
"@wordpress/keyboard-shortcuts": "^5.21.0",
|
|
59
|
+
"@wordpress/keycodes": "^4.21.0",
|
|
60
|
+
"@wordpress/media-utils": "^5.21.0",
|
|
61
|
+
"@wordpress/notices": "^5.21.0",
|
|
62
|
+
"@wordpress/patterns": "^2.21.0",
|
|
63
|
+
"@wordpress/plugins": "^7.21.0",
|
|
64
|
+
"@wordpress/preferences": "^4.21.0",
|
|
65
|
+
"@wordpress/private-apis": "^1.21.0",
|
|
66
|
+
"@wordpress/reusable-blocks": "^5.21.0",
|
|
67
|
+
"@wordpress/rich-text": "^7.21.0",
|
|
68
|
+
"@wordpress/server-side-render": "^5.21.0",
|
|
69
|
+
"@wordpress/url": "^4.21.0",
|
|
70
|
+
"@wordpress/warning": "^3.21.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.21.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"client-zip": "^2.4.5",
|
|
74
74
|
"clsx": "^2.1.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "104af00f9abcd7a4d36b87e648f148c72cc4ea5f"
|
|
92
92
|
}
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
}
|
|
25
25
|
.editor-autocompleters__user-slug {
|
|
26
26
|
margin-left: 8px;
|
|
27
|
-
color: $gray-700;
|
|
28
27
|
white-space: nowrap;
|
|
29
28
|
text-overflow: ellipsis;
|
|
30
29
|
overflow: none;
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
flex-grow: 0;
|
|
33
32
|
flex-shrink: 0;
|
|
34
33
|
}
|
|
35
|
-
&:
|
|
36
|
-
color:
|
|
34
|
+
&:not(.is-primary) .editor-autocompleters__user-slug {
|
|
35
|
+
color: $gray-700;
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -223,7 +223,7 @@ const getEditorCommandLoader = () =>
|
|
|
223
223
|
|
|
224
224
|
commands.push( {
|
|
225
225
|
name: 'core/open-settings-sidebar',
|
|
226
|
-
label: __( 'Show or hide the Settings panel
|
|
226
|
+
label: __( 'Show or hide the Settings panel' ),
|
|
227
227
|
icon: isRTL() ? drawerLeft : drawerRight,
|
|
228
228
|
callback: ( { close } ) => {
|
|
229
229
|
const activeSidebar = getActiveComplementaryArea( 'core' );
|
|
@@ -17,7 +17,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' );
|
|
|
17
17
|
* When no title is provided it is always opened.
|
|
18
18
|
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
|
|
19
19
|
* icon slug string, or an SVG WP element, to be rendered when
|
|
20
|
-
* the sidebar is pinned to toolbar.
|
|
20
|
+
* the sidebar is pinned to toolbar. If `false` is passed, no icon will be rendered.
|
|
21
21
|
* @param {React.ReactNode} props.children Children to be rendered
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
@@ -26,21 +26,26 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
|
26
26
|
|
|
27
27
|
const { canManageOptions, hasFrontPageTemplate } = useSelect(
|
|
28
28
|
( select ) => {
|
|
29
|
-
const { getEntityRecords } = select( coreStore );
|
|
30
|
-
const
|
|
31
|
-
|
|
29
|
+
const { getEntityRecords, canUser } = select( coreStore );
|
|
30
|
+
const canUpdateSettings = canUser( 'update', {
|
|
31
|
+
kind: 'root',
|
|
32
|
+
name: 'site',
|
|
32
33
|
} );
|
|
34
|
+
const templates =
|
|
35
|
+
'page' === postType && canUpdateSettings
|
|
36
|
+
? getEntityRecords( 'postType', 'wp_template', {
|
|
37
|
+
per_page: -1,
|
|
38
|
+
} )
|
|
39
|
+
: [];
|
|
33
40
|
|
|
34
41
|
return {
|
|
35
|
-
canManageOptions:
|
|
36
|
-
kind: 'root',
|
|
37
|
-
name: 'site',
|
|
38
|
-
} ),
|
|
42
|
+
canManageOptions: canUpdateSettings,
|
|
39
43
|
hasFrontPageTemplate: !! templates?.find(
|
|
40
44
|
( template ) => template?.slug === 'front-page'
|
|
41
45
|
),
|
|
42
46
|
};
|
|
43
|
-
}
|
|
47
|
+
},
|
|
48
|
+
[ postType ]
|
|
44
49
|
);
|
|
45
50
|
|
|
46
51
|
const setAsHomepageAction = useSetAsHomepageAction();
|
|
@@ -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
|
*/
|
|
@@ -194,7 +194,12 @@ export default function PostStatus() {
|
|
|
194
194
|
title={ __( 'Status & visibility' ) }
|
|
195
195
|
onClose={ onClose }
|
|
196
196
|
/>
|
|
197
|
-
<form
|
|
197
|
+
<form
|
|
198
|
+
onSubmit={ ( event ) => {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
onClose();
|
|
201
|
+
} }
|
|
202
|
+
>
|
|
198
203
|
<VStack spacing={ 4 }>
|
|
199
204
|
<RadioControl
|
|
200
205
|
className="editor-change-status__options"
|
|
@@ -230,7 +235,7 @@ export default function PostStatus() {
|
|
|
230
235
|
'Password protected'
|
|
231
236
|
) }
|
|
232
237
|
help={ __(
|
|
233
|
-
'Only visible to those who know the password'
|
|
238
|
+
'Only visible to those who know the password.'
|
|
234
239
|
) }
|
|
235
240
|
checked={ showPassword }
|
|
236
241
|
onChange={
|
|
@@ -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
|
|
@@ -141,9 +141,7 @@ export default function BlockThemeControl( { id } ) {
|
|
|
141
141
|
|
|
142
142
|
<SwapTemplateButton onClick={ onClose } />
|
|
143
143
|
<ResetDefaultTemplate onClick={ onClose } />
|
|
144
|
-
{ canCreateTemplate &&
|
|
145
|
-
<CreateNewTemplate onClick={ onClose } />
|
|
146
|
-
) }
|
|
144
|
+
{ canCreateTemplate && <CreateNewTemplate /> }
|
|
147
145
|
</MenuGroup>
|
|
148
146
|
<MenuGroup>
|
|
149
147
|
<MenuItem
|
|
@@ -111,6 +111,7 @@ export default function CreateNewTemplateModal( { onClose } ) {
|
|
|
111
111
|
onRequestClose={ cancel }
|
|
112
112
|
focusOnMount="firstContentElement"
|
|
113
113
|
size="small"
|
|
114
|
+
overlayClassName="editor-post-template__create-template-modal"
|
|
114
115
|
>
|
|
115
116
|
<form
|
|
116
117
|
className="editor-post-template__create-form"
|
|
@@ -13,7 +13,7 @@ import { useState } from '@wordpress/element';
|
|
|
13
13
|
import CreateNewTemplateModal from './create-new-template-modal';
|
|
14
14
|
import { useAllowSwitchingTemplates } from './hooks';
|
|
15
15
|
|
|
16
|
-
export default function CreateNewTemplate(
|
|
16
|
+
export default function CreateNewTemplate() {
|
|
17
17
|
const { canCreateTemplates } = useSelect( ( select ) => {
|
|
18
18
|
const { canUser } = select( coreStore );
|
|
19
19
|
return {
|
|
@@ -44,7 +44,6 @@ export default function CreateNewTemplate( { onClick } ) {
|
|
|
44
44
|
<CreateNewTemplateModal
|
|
45
45
|
onClose={ () => {
|
|
46
46
|
setIsCreateModalOpen( false );
|
|
47
|
-
onClick();
|
|
48
47
|
} }
|
|
49
48
|
/>
|
|
50
49
|
) }
|
|
@@ -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
|
);
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
z-index: z-index(".editor-post-template__swap-template-modal");
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
.editor-post-template__create-template-modal {
|
|
6
|
+
z-index: z-index(".editor-post-template__create-template-modal");
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
.editor-post-template__swap-template-modal-content .block-editor-block-patterns-list {
|
|
6
10
|
column-count: 2;
|
|
7
11
|
column-gap: $grid-unit-30;
|
|
@@ -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 && (
|