@wordpress/edit-post 7.32.0 → 7.33.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 +4 -196
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/editor-initialization/index.js +0 -1
- package/build/components/editor-initialization/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js +1 -38
- 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.native.js.map +1 -1
- package/build/components/header/index.js +4 -4
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/index.native.js +1 -1
- package/build/components/header/index.native.js.map +1 -1
- package/build/components/header/main-dashboard-button/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +7 -6
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js +9 -6
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/preferences-menu-item/index.js +12 -4
- package/build/components/header/preferences-menu-item/index.js.map +1 -1
- package/build/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/init-pattern-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -36
- 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 +12 -20
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/index.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -21
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
- package/build/components/sidebar/post-format/index.js.map +1 -1
- package/build/components/sidebar/post-pending-status/index.js.map +1 -1
- package/build/components/sidebar/post-slug/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +9 -9
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-sticky/index.js.map +1 -1
- package/build/components/sidebar/post-trash/index.js.map +1 -1
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +37 -40
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/block-inspector-button.js +1 -1
- package/build/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build/components/visual-editor/header.native.js.map +1 -1
- package/build/components/visual-editor/index.js +4 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/visual-editor/index.native.js.map +1 -1
- package/build/components/visual-editor/use-padding-appender.js +62 -0
- package/build/components/visual-editor/use-padding-appender.js.map +1 -0
- package/build/components/welcome-guide/default.js.map +1 -1
- package/build/components/welcome-guide/image.js.map +1 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/editor.js +2 -2
- package/build/editor.js.map +1 -1
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +5 -22
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/components/index.js.map +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +4 -8
- package/build/index.js.map +1 -1
- package/build/index.native.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +7 -4
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +10 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +34 -19
- package/build/store/selectors.js.map +1 -1
- package/build/utils/meta-boxes.js.map +1 -1
- package/build-module/components/browser-url/index.js.map +1 -1
- package/build-module/components/editor-initialization/index.js +1 -2
- package/build-module/components/editor-initialization/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +2 -38
- 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.native.js.map +1 -1
- package/build-module/components/header/index.js +3 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/index.native.js +1 -1
- package/build-module/components/header/index.native.js.map +1 -1
- package/build-module/components/header/main-dashboard-button/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +5 -4
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js +9 -6
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/header/preferences-menu-item/index.js +11 -3
- package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
- package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/init-pattern-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -36
- 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 +11 -19
- 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/meta-boxes/index.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +1 -20
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
- package/build-module/components/sidebar/post-format/index.js.map +1 -1
- package/build-module/components/sidebar/post-pending-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-slug/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +9 -10
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-sticky/index.js.map +1 -1
- package/build-module/components/sidebar/post-trash/index.js.map +1 -1
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +38 -41
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/block-inspector-button.js +1 -1
- package/build-module/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build-module/components/visual-editor/header.native.js.map +1 -1
- package/build-module/components/visual-editor/index.js +4 -1
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/index.native.js.map +1 -1
- package/build-module/components/visual-editor/use-padding-appender.js +55 -0
- package/build-module/components/visual-editor/use-padding-appender.js.map +1 -0
- package/build-module/components/welcome-guide/default.js.map +1 -1
- package/build-module/components/welcome-guide/image.js.map +1 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/template.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.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +7 -24
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/components/index.js.map +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +5 -5
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +6 -3
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +8 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +33 -18
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/meta-boxes.js.map +1 -1
- package/build-style/classic-rtl.css +2 -2
- package/build-style/classic.css +2 -2
- package/build-style/style-rtl.css +12 -448
- package/build-style/style.css +12 -448
- package/package.json +32 -34
- package/src/classic.scss +1 -1
- package/src/components/editor-initialization/index.js +1 -5
- package/src/components/editor-initialization/listener-hooks.js +1 -40
- package/src/components/editor-initialization/test/listener-hooks.js +1 -96
- package/src/components/header/index.js +2 -3
- package/src/components/header/index.native.js +1 -1
- package/src/components/header/more-menu/index.js +3 -4
- package/src/components/header/post-publish-button-or-toggle.js +8 -3
- package/src/components/header/preferences-menu-item/index.js +9 -3
- package/src/components/header/style.scss +5 -3
- package/src/components/header/test/index.js +13 -1
- package/src/components/keyboard-shortcuts/index.js +3 -44
- package/src/components/layout/index.js +14 -41
- package/src/components/preferences-modal/index.js +1 -24
- package/src/components/sidebar/post-status/index.js +6 -9
- package/src/components/sidebar/settings-sidebar/index.js +62 -58
- package/src/components/visual-editor/block-inspector-button.js +1 -1
- package/src/components/visual-editor/index.js +4 -0
- package/src/components/visual-editor/use-padding-appender.js +66 -0
- package/src/editor.js +2 -2
- package/src/hooks/commands/use-common-commands.js +11 -26
- package/src/index.js +8 -4
- package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
- package/src/store/actions.js +10 -12
- package/src/store/selectors.js +41 -33
- package/src/store/test/actions.js +11 -10
- package/src/style.scss +1 -19
- package/build/components/header/plugin-more-menu-item/index.js +0 -78
- package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +0 -71
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +0 -78
- package/build/components/keyboard-shortcut-help-modal/config.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -49
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +0 -132
- package/build/components/keyboard-shortcut-help-modal/index.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +0 -55
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
- package/build/components/sidebar/plugin-post-status-info/index.js +0 -73
- package/build/components/sidebar/plugin-post-status-info/index.js.map +0 -1
- package/build/components/sidebar/plugin-sidebar/index.js +0 -104
- package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build/components/start-page-options/index.js +0 -107
- package/build/components/start-page-options/index.js.map +0 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +0 -73
- package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +0 -65
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +0 -71
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -41
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -122
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -48
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
- package/build-module/components/sidebar/plugin-post-status-info/index.js +0 -66
- package/build-module/components/sidebar/plugin-post-status-info/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +0 -98
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build-module/components/start-page-options/index.js +0 -100
- package/build-module/components/start-page-options/index.js.map +0 -1
- package/src/components/header/plugin-more-menu-item/index.js +0 -73
- package/src/components/header/plugin-sidebar-more-menu-item/index.js +0 -64
- package/src/components/keyboard-shortcut-help-modal/config.js +0 -53
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -43
- package/src/components/keyboard-shortcut-help-modal/index.js +0 -163
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +0 -67
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -61
- package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -36
- package/src/components/sidebar/plugin-post-status-info/index.js +0 -63
- package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +0 -11
- package/src/components/sidebar/plugin-post-status-info/test/index.js +0 -29
- package/src/components/sidebar/plugin-sidebar/index.js +0 -94
- package/src/components/start-page-options/index.js +0 -108
- package/src/components/start-page-options/style.scss +0 -26
|
@@ -15,18 +15,19 @@ import {
|
|
|
15
15
|
} from '@wordpress/element';
|
|
16
16
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
17
17
|
import { drawerLeft, drawerRight } from '@wordpress/icons';
|
|
18
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
19
18
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
20
19
|
import {
|
|
21
20
|
store as editorStore,
|
|
22
21
|
PageAttributesPanel,
|
|
23
22
|
PluginDocumentSettingPanel,
|
|
23
|
+
PluginSidebar,
|
|
24
24
|
PostDiscussionPanel,
|
|
25
25
|
PostExcerptPanel,
|
|
26
26
|
PostLastRevisionPanel,
|
|
27
27
|
PostTaxonomiesPanel,
|
|
28
28
|
privateApis as editorPrivateApis,
|
|
29
29
|
} from '@wordpress/editor';
|
|
30
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Internal dependencies
|
|
@@ -34,15 +35,15 @@ import {
|
|
|
34
35
|
import SettingsHeader from '../settings-header';
|
|
35
36
|
import PostStatus from '../post-status';
|
|
36
37
|
import MetaBoxes from '../../meta-boxes';
|
|
37
|
-
import PluginSidebarEditPost from '../plugin-sidebar';
|
|
38
38
|
import { store as editPostStore } from '../../../store';
|
|
39
39
|
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
40
40
|
import { unlock } from '../../../lock-unlock';
|
|
41
41
|
|
|
42
|
-
const { PostCardPanel } =
|
|
43
|
-
|
|
42
|
+
const { PostCardPanel, PostActions, interfaceStore } =
|
|
43
|
+
unlock( editorPrivateApis );
|
|
44
44
|
const { Tabs } = unlock( componentsPrivateApis );
|
|
45
|
-
const { PatternOverridesPanel } =
|
|
45
|
+
const { PatternOverridesPanel, useAutoSwitchEditorSidebars } =
|
|
46
|
+
unlock( editorPrivateApis );
|
|
46
47
|
|
|
47
48
|
const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {
|
|
48
49
|
web: true,
|
|
@@ -53,13 +54,18 @@ export const sidebars = {
|
|
|
53
54
|
block: 'edit-post/block',
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
function onActionPerformed( actionId, items ) {
|
|
58
|
+
if ( actionId === 'move-to-trash' ) {
|
|
59
|
+
const postType = items[ 0 ].type;
|
|
60
|
+
document.location.href = addQueryArgs( 'edit.php', {
|
|
61
|
+
post_type: postType,
|
|
62
|
+
} );
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const SidebarContent = ( { tabName, keyboardShortcut, isEditingTemplate } ) => {
|
|
61
67
|
const tabListRef = useRef( null );
|
|
62
|
-
// Because `
|
|
68
|
+
// Because `PluginSidebar` renders a `ComplementaryArea`, we
|
|
63
69
|
// need to forward the `Tabs` context so it can be passed through the
|
|
64
70
|
// underlying slot/fill.
|
|
65
71
|
const tabsContextValue = useContext( Tabs.Context );
|
|
@@ -76,7 +82,7 @@ const SidebarContent = ( {
|
|
|
76
82
|
// We are purposefully using a custom `data-tab-id` attribute here
|
|
77
83
|
// because we don't want rely on any assumptions about `Tabs`
|
|
78
84
|
// component internals.
|
|
79
|
-
( element ) => element.getAttribute( 'data-tab-id' ) ===
|
|
85
|
+
( element ) => element.getAttribute( 'data-tab-id' ) === tabName
|
|
80
86
|
);
|
|
81
87
|
const activeElement = selectedTabElement?.ownerDocument.activeElement;
|
|
82
88
|
const tabsHasFocus = tabsElements.some( ( element ) => {
|
|
@@ -89,11 +95,11 @@ const SidebarContent = ( {
|
|
|
89
95
|
) {
|
|
90
96
|
selectedTabElement?.focus();
|
|
91
97
|
}
|
|
92
|
-
}, [
|
|
98
|
+
}, [ tabName ] );
|
|
93
99
|
|
|
94
100
|
return (
|
|
95
|
-
<
|
|
96
|
-
identifier={
|
|
101
|
+
<PluginSidebar
|
|
102
|
+
identifier={ tabName }
|
|
97
103
|
header={
|
|
98
104
|
<Tabs.Context.Provider value={ tabsContextValue }>
|
|
99
105
|
<SettingsHeader ref={ tabListRef } />
|
|
@@ -113,7 +119,13 @@ const SidebarContent = ( {
|
|
|
113
119
|
>
|
|
114
120
|
<Tabs.Context.Provider value={ tabsContextValue }>
|
|
115
121
|
<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>
|
|
116
|
-
<PostCardPanel
|
|
122
|
+
<PostCardPanel
|
|
123
|
+
actions={
|
|
124
|
+
<PostActions
|
|
125
|
+
onActionPerformed={ onActionPerformed }
|
|
126
|
+
/>
|
|
127
|
+
}
|
|
128
|
+
/>
|
|
117
129
|
{ ! isEditingTemplate && (
|
|
118
130
|
<>
|
|
119
131
|
<PostStatus />
|
|
@@ -132,46 +144,43 @@ const SidebarContent = ( {
|
|
|
132
144
|
<BlockInspector />
|
|
133
145
|
</Tabs.TabPanel>
|
|
134
146
|
</Tabs.Context.Provider>
|
|
135
|
-
</
|
|
147
|
+
</PluginSidebar>
|
|
136
148
|
);
|
|
137
149
|
};
|
|
138
150
|
|
|
139
151
|
const SettingsSidebar = () => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
sidebar = sidebars.block;
|
|
152
|
+
useAutoSwitchEditorSidebars();
|
|
153
|
+
const { tabName, keyboardShortcut, isEditingTemplate } = useSelect(
|
|
154
|
+
( select ) => {
|
|
155
|
+
const shortcut = select(
|
|
156
|
+
keyboardShortcutsStore
|
|
157
|
+
).getShortcutRepresentation( 'core/editor/toggle-sidebar' );
|
|
158
|
+
|
|
159
|
+
const sidebar =
|
|
160
|
+
select( interfaceStore ).getActiveComplementaryArea( 'core' );
|
|
161
|
+
const _isEditorSidebarOpened = [
|
|
162
|
+
sidebars.block,
|
|
163
|
+
sidebars.document,
|
|
164
|
+
].includes( sidebar );
|
|
165
|
+
let _tabName = sidebar;
|
|
166
|
+
if ( ! _isEditorSidebarOpened ) {
|
|
167
|
+
_tabName = !! select(
|
|
168
|
+
blockEditorStore
|
|
169
|
+
).getBlockSelectionStart()
|
|
170
|
+
? sidebars.block
|
|
171
|
+
: sidebars.document;
|
|
161
172
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
};
|
|
174
|
-
}, [] );
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
tabName: _tabName,
|
|
176
|
+
keyboardShortcut: shortcut,
|
|
177
|
+
isEditingTemplate:
|
|
178
|
+
select( editorStore ).getCurrentPostType() ===
|
|
179
|
+
'wp_template',
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
[]
|
|
183
|
+
);
|
|
175
184
|
|
|
176
185
|
const { openGeneralSidebar } = useDispatch( editPostStore );
|
|
177
186
|
|
|
@@ -186,17 +195,12 @@ const SettingsSidebar = () => {
|
|
|
186
195
|
|
|
187
196
|
return (
|
|
188
197
|
<Tabs
|
|
189
|
-
|
|
190
|
-
// `interfaceStore`), when the sidebar closes the currently selected
|
|
191
|
-
// tab can't be found. This causes the component to continuously reset
|
|
192
|
-
// the selection to `null` in an infinite loop.Proactively setting
|
|
193
|
-
// the selected tab to `null` avoids that.
|
|
194
|
-
selectedTabId={ isSettingsSidebarActive ? sidebarName : null }
|
|
198
|
+
selectedTabId={ tabName }
|
|
195
199
|
onSelect={ onTabSelect }
|
|
196
200
|
selectOnMove={ false }
|
|
197
201
|
>
|
|
198
202
|
<SidebarContent
|
|
199
|
-
|
|
203
|
+
tabName={ tabName }
|
|
200
204
|
keyboardShortcut={ keyboardShortcut }
|
|
201
205
|
isEditingTemplate={ isEditingTemplate }
|
|
202
206
|
/>
|
|
@@ -19,7 +19,7 @@ export function BlockInspectorButton( { onClick = noop, small = false } ) {
|
|
|
19
19
|
( select ) => ( {
|
|
20
20
|
shortcut: select(
|
|
21
21
|
keyboardShortcutsStore
|
|
22
|
-
).getShortcutRepresentation( 'core/
|
|
22
|
+
).getShortcutRepresentation( 'core/editor/toggle-sidebar' ),
|
|
23
23
|
areAdvancedSettingsOpened:
|
|
24
24
|
select( editPostStore ).getActiveGeneralSidebarName() ===
|
|
25
25
|
'edit-post/block',
|
|
@@ -19,6 +19,7 @@ import { store as blocksStore } from '@wordpress/blocks';
|
|
|
19
19
|
*/
|
|
20
20
|
import { store as editPostStore } from '../../store';
|
|
21
21
|
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import { usePaddingAppender } from './use-padding-appender';
|
|
22
23
|
|
|
23
24
|
const { EditorCanvas } = unlock( editorPrivateApis );
|
|
24
25
|
|
|
@@ -53,6 +54,8 @@ export default function VisualEditor( { styles } ) {
|
|
|
53
54
|
[]
|
|
54
55
|
);
|
|
55
56
|
|
|
57
|
+
const paddingAppenderRef = usePaddingAppender();
|
|
58
|
+
|
|
56
59
|
let paddingBottom;
|
|
57
60
|
|
|
58
61
|
// Add a constant padding for the typewritter effect. When typing at the
|
|
@@ -91,6 +94,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
91
94
|
// We should auto-focus the canvas (title) on load.
|
|
92
95
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
93
96
|
autoFocus={ ! isWelcomeGuideVisible }
|
|
97
|
+
contentRef={ paddingAppenderRef }
|
|
94
98
|
/>
|
|
95
99
|
</div>
|
|
96
100
|
);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRegistry } from '@wordpress/data';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
8
|
+
|
|
9
|
+
export function usePaddingAppender() {
|
|
10
|
+
const registry = useRegistry();
|
|
11
|
+
return useRefEffect(
|
|
12
|
+
( node ) => {
|
|
13
|
+
function onMouseDown( event ) {
|
|
14
|
+
if ( event.target !== node ) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { ownerDocument } = node;
|
|
19
|
+
const { defaultView } = ownerDocument;
|
|
20
|
+
|
|
21
|
+
const paddingBottom = defaultView.parseInt(
|
|
22
|
+
defaultView.getComputedStyle( node ).paddingBottom,
|
|
23
|
+
10
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if ( ! paddingBottom ) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// only handle clicks under the last child
|
|
31
|
+
const lastChild = node.lastElementChild;
|
|
32
|
+
if ( ! lastChild ) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const lastChildRect = lastChild.getBoundingClientRect();
|
|
37
|
+
if ( event.clientY < lastChildRect.bottom ) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
|
|
43
|
+
const blockOrder = registry
|
|
44
|
+
.select( blockEditorStore )
|
|
45
|
+
.getBlockOrder( '' );
|
|
46
|
+
const lastBlockClientId = blockOrder[ blockOrder.length - 1 ];
|
|
47
|
+
const lastBlock = registry
|
|
48
|
+
.select( blockEditorStore )
|
|
49
|
+
.getBlock( lastBlockClientId );
|
|
50
|
+
const { selectBlock, insertDefaultBlock } =
|
|
51
|
+
registry.dispatch( blockEditorStore );
|
|
52
|
+
|
|
53
|
+
if ( isUnmodifiedDefaultBlock( lastBlock ) ) {
|
|
54
|
+
selectBlock( lastBlockClientId );
|
|
55
|
+
} else {
|
|
56
|
+
insertDefaultBlock();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
node.addEventListener( 'mousedown', onMouseDown );
|
|
60
|
+
return () => {
|
|
61
|
+
node.removeEventListener( 'mousedown', onMouseDown );
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
[ registry ]
|
|
65
|
+
);
|
|
66
|
+
}
|
package/src/editor.js
CHANGED
|
@@ -58,12 +58,12 @@ function Editor( {
|
|
|
58
58
|
getEditorSettings().supportsTemplateMode;
|
|
59
59
|
const isViewable =
|
|
60
60
|
getPostType( currentPost.postType )?.viewable ?? false;
|
|
61
|
-
const
|
|
61
|
+
const canViewTemplate = canUser( 'read', 'templates' );
|
|
62
62
|
return {
|
|
63
63
|
template:
|
|
64
64
|
supportsTemplateMode &&
|
|
65
65
|
isViewable &&
|
|
66
|
-
|
|
66
|
+
canViewTemplate &&
|
|
67
67
|
currentPost.postType !== 'wp_template'
|
|
68
68
|
? getEditedPostTemplate()
|
|
69
69
|
: null,
|
|
@@ -7,35 +7,37 @@ import {
|
|
|
7
7
|
drawerLeft,
|
|
8
8
|
drawerRight,
|
|
9
9
|
blockDefault,
|
|
10
|
-
keyboard,
|
|
11
10
|
fullscreen,
|
|
12
11
|
formatListBullets,
|
|
13
12
|
} from '@wordpress/icons';
|
|
14
13
|
import { useCommand } from '@wordpress/commands';
|
|
15
14
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
16
|
-
import {
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
store as editorStore,
|
|
17
|
+
privateApis as editorPrivateApis,
|
|
18
|
+
} from '@wordpress/editor';
|
|
18
19
|
import { store as noticesStore } from '@wordpress/notices';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Internal dependencies
|
|
22
23
|
*/
|
|
23
|
-
import { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';
|
|
24
|
-
import { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';
|
|
25
24
|
import { store as editPostStore } from '../../store';
|
|
25
|
+
import { unlock } from '../../lock-unlock';
|
|
26
|
+
|
|
27
|
+
const { interfaceStore } = unlock( editorPrivateApis );
|
|
26
28
|
|
|
27
29
|
export default function useCommonCommands() {
|
|
28
30
|
const { openGeneralSidebar, closeGeneralSidebar } =
|
|
29
31
|
useDispatch( editPostStore );
|
|
30
|
-
const { openModal } = useDispatch( interfaceStore );
|
|
31
32
|
const { activeSidebar, isFullscreen, isPublishSidebarEnabled } = useSelect(
|
|
32
33
|
( select ) => {
|
|
33
34
|
const { get } = select( preferencesStore );
|
|
34
35
|
|
|
35
36
|
return {
|
|
36
|
-
activeSidebar:
|
|
37
|
-
interfaceStore
|
|
38
|
-
|
|
37
|
+
activeSidebar:
|
|
38
|
+
select( interfaceStore ).getActiveComplementaryArea(
|
|
39
|
+
'core'
|
|
40
|
+
),
|
|
39
41
|
isPublishSidebarEnabled:
|
|
40
42
|
select( editorStore ).isPublishSidebarEnabled(),
|
|
41
43
|
isFullscreen: get( 'core/edit-post', 'fullscreenMode' ),
|
|
@@ -101,23 +103,6 @@ export default function useCommonCommands() {
|
|
|
101
103
|
},
|
|
102
104
|
} );
|
|
103
105
|
|
|
104
|
-
useCommand( {
|
|
105
|
-
name: 'core/open-preferences',
|
|
106
|
-
label: __( 'Editor preferences' ),
|
|
107
|
-
callback: () => {
|
|
108
|
-
openModal( PREFERENCES_MODAL_NAME );
|
|
109
|
-
},
|
|
110
|
-
} );
|
|
111
|
-
|
|
112
|
-
useCommand( {
|
|
113
|
-
name: 'core/open-shortcut-help',
|
|
114
|
-
label: __( 'Keyboard shortcuts' ),
|
|
115
|
-
icon: keyboard,
|
|
116
|
-
callback: () => {
|
|
117
|
-
openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );
|
|
118
|
-
},
|
|
119
|
-
} );
|
|
120
|
-
|
|
121
106
|
useCommand( {
|
|
122
107
|
name: 'core/toggle-publish-sidebar',
|
|
123
108
|
label: isPublishSidebarEnabled
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,10 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
PluginBlockSettingsMenuItem,
|
|
19
19
|
PluginDocumentSettingPanel,
|
|
20
|
+
PluginMoreMenuItem,
|
|
21
|
+
PluginPostStatusInfo,
|
|
22
|
+
PluginSidebar,
|
|
23
|
+
PluginSidebarMoreMenuItem,
|
|
20
24
|
privateApis as editorPrivateApis,
|
|
21
25
|
store as editorStore,
|
|
22
26
|
} from '@wordpress/editor';
|
|
@@ -164,12 +168,12 @@ export function reinitializeEditor() {
|
|
|
164
168
|
|
|
165
169
|
export { PluginBlockSettingsMenuItem };
|
|
166
170
|
export { PluginDocumentSettingPanel };
|
|
167
|
-
export {
|
|
171
|
+
export { PluginMoreMenuItem };
|
|
172
|
+
export { PluginPostStatusInfo };
|
|
173
|
+
export { PluginSidebar };
|
|
174
|
+
export { PluginSidebarMoreMenuItem };
|
|
168
175
|
export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';
|
|
169
|
-
export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';
|
|
170
176
|
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';
|
|
171
|
-
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
|
|
172
|
-
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';
|
|
173
177
|
export { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';
|
|
174
178
|
export { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';
|
|
175
179
|
export { __experimentalPluginPostExcerpt };
|
|
@@ -5,18 +5,20 @@ import { MenuItem } from '@wordpress/components';
|
|
|
5
5
|
import { withDispatch } from '@wordpress/data';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
8
|
-
import {
|
|
8
|
+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
|
|
15
|
+
const { interfaceStore } = unlock( editorPrivateApis );
|
|
14
16
|
|
|
15
17
|
export function KeyboardShortcutsHelpMenuItem( { openModal } ) {
|
|
16
18
|
return (
|
|
17
19
|
<MenuItem
|
|
18
20
|
onClick={ () => {
|
|
19
|
-
openModal(
|
|
21
|
+
openModal( 'editor/keyboard-shortcut-help' );
|
|
20
22
|
} }
|
|
21
23
|
shortcut={ displayShortcut.access( 'h' ) }
|
|
22
24
|
>
|
package/src/store/actions.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
6
5
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
store as editorStore,
|
|
8
|
+
privateApis as editorPrivateApis,
|
|
9
|
+
} from '@wordpress/editor';
|
|
8
10
|
import deprecated from '@wordpress/deprecated';
|
|
9
11
|
import { addFilter } from '@wordpress/hooks';
|
|
10
12
|
|
|
@@ -12,9 +14,10 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
12
14
|
* Internal dependencies
|
|
13
15
|
*/
|
|
14
16
|
import { getMetaBoxContainer } from '../utils/meta-boxes';
|
|
15
|
-
import { store as editPostStore } from '.';
|
|
16
17
|
import { unlock } from '../lock-unlock';
|
|
17
18
|
|
|
19
|
+
const { interfaceStore } = unlock( editorPrivateApis );
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
* Returns an action object used in signalling that the user opened an editor sidebar.
|
|
20
23
|
*
|
|
@@ -25,7 +28,7 @@ export const openGeneralSidebar =
|
|
|
25
28
|
( { registry } ) => {
|
|
26
29
|
registry
|
|
27
30
|
.dispatch( interfaceStore )
|
|
28
|
-
.enableComplementaryArea(
|
|
31
|
+
.enableComplementaryArea( 'core', name );
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
/**
|
|
@@ -34,9 +37,7 @@ export const openGeneralSidebar =
|
|
|
34
37
|
export const closeGeneralSidebar =
|
|
35
38
|
() =>
|
|
36
39
|
( { registry } ) =>
|
|
37
|
-
registry
|
|
38
|
-
.dispatch( interfaceStore )
|
|
39
|
-
.disableComplementaryArea( editPostStore.name );
|
|
40
|
+
registry.dispatch( interfaceStore ).disableComplementaryArea( 'core' );
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* Returns an action object used in signalling that the user opened a modal.
|
|
@@ -219,14 +220,11 @@ export const togglePinnedPluginItem =
|
|
|
219
220
|
( { registry } ) => {
|
|
220
221
|
const isPinned = registry
|
|
221
222
|
.select( interfaceStore )
|
|
222
|
-
.isItemPinned( 'core
|
|
223
|
+
.isItemPinned( 'core', pluginName );
|
|
223
224
|
|
|
224
225
|
registry
|
|
225
226
|
.dispatch( interfaceStore )
|
|
226
|
-
[ isPinned ? 'unpinItem' : 'pinItem' ](
|
|
227
|
-
'core/edit-post',
|
|
228
|
-
pluginName
|
|
229
|
-
);
|
|
227
|
+
[ isPinned ? 'unpinItem' : 'pinItem' ]( 'core', pluginName );
|
|
230
228
|
};
|
|
231
229
|
|
|
232
230
|
/**
|
package/src/store/selectors.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import createSelector from 'rememo';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import { createRegistrySelector } from '@wordpress/data';
|
|
10
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
4
|
+
import { createSelector, createRegistrySelector } from '@wordpress/data';
|
|
11
5
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
12
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
store as editorStore,
|
|
9
|
+
privateApis as editorPrivateApis,
|
|
10
|
+
} from '@wordpress/editor';
|
|
14
11
|
import deprecated from '@wordpress/deprecated';
|
|
15
12
|
|
|
16
13
|
/**
|
|
@@ -18,6 +15,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
18
15
|
*/
|
|
19
16
|
import { unlock } from '../lock-unlock';
|
|
20
17
|
|
|
18
|
+
const { interfaceStore } = unlock( editorPrivateApis );
|
|
21
19
|
const EMPTY_ARRAY = [];
|
|
22
20
|
const EMPTY_OBJECT = {};
|
|
23
21
|
|
|
@@ -43,9 +41,7 @@ export const getEditorMode = createRegistrySelector(
|
|
|
43
41
|
export const isEditorSidebarOpened = createRegistrySelector(
|
|
44
42
|
( select ) => () => {
|
|
45
43
|
const activeGeneralSidebar =
|
|
46
|
-
select( interfaceStore ).getActiveComplementaryArea(
|
|
47
|
-
'core/edit-post'
|
|
48
|
-
);
|
|
44
|
+
select( interfaceStore ).getActiveComplementaryArea( 'core' );
|
|
49
45
|
return [ 'edit-post/document', 'edit-post/block' ].includes(
|
|
50
46
|
activeGeneralSidebar
|
|
51
47
|
);
|
|
@@ -62,9 +58,7 @@ export const isEditorSidebarOpened = createRegistrySelector(
|
|
|
62
58
|
export const isPluginSidebarOpened = createRegistrySelector(
|
|
63
59
|
( select ) => () => {
|
|
64
60
|
const activeGeneralSidebar =
|
|
65
|
-
select( interfaceStore ).getActiveComplementaryArea(
|
|
66
|
-
'core/edit-post'
|
|
67
|
-
);
|
|
61
|
+
select( interfaceStore ).getActiveComplementaryArea( 'core' );
|
|
68
62
|
return (
|
|
69
63
|
!! activeGeneralSidebar &&
|
|
70
64
|
! [ 'edit-post/document', 'edit-post/block' ].includes(
|
|
@@ -90,9 +84,7 @@ export const isPluginSidebarOpened = createRegistrySelector(
|
|
|
90
84
|
*/
|
|
91
85
|
export const getActiveGeneralSidebarName = createRegistrySelector(
|
|
92
86
|
( select ) => () => {
|
|
93
|
-
return select( interfaceStore ).getActiveComplementaryArea(
|
|
94
|
-
'core/edit-post'
|
|
95
|
-
);
|
|
87
|
+
return select( interfaceStore ).getActiveComplementaryArea( 'core' );
|
|
96
88
|
}
|
|
97
89
|
);
|
|
98
90
|
|
|
@@ -352,10 +344,7 @@ export const isFeatureActive = createRegistrySelector(
|
|
|
352
344
|
*/
|
|
353
345
|
export const isPluginItemPinned = createRegistrySelector(
|
|
354
346
|
( select ) => ( state, pluginName ) => {
|
|
355
|
-
return select( interfaceStore ).isItemPinned(
|
|
356
|
-
'core/edit-post',
|
|
357
|
-
pluginName
|
|
358
|
-
);
|
|
347
|
+
return select( interfaceStore ).isItemPinned( 'core', pluginName );
|
|
359
348
|
}
|
|
360
349
|
);
|
|
361
350
|
|
|
@@ -567,36 +556,55 @@ export function areMetaBoxesInitialized( state ) {
|
|
|
567
556
|
*/
|
|
568
557
|
export const getEditedPostTemplate = createRegistrySelector(
|
|
569
558
|
( select ) => () => {
|
|
559
|
+
const {
|
|
560
|
+
id: postId,
|
|
561
|
+
type: postType,
|
|
562
|
+
slug,
|
|
563
|
+
} = select( editorStore ).getCurrentPost();
|
|
564
|
+
const { getSite, getEditedEntityRecord, getEntityRecords } =
|
|
565
|
+
select( coreStore );
|
|
566
|
+
const siteSettings = getSite();
|
|
567
|
+
// First check if the current page is set as the posts page.
|
|
568
|
+
const isPostsPage = +postId === siteSettings?.page_for_posts;
|
|
569
|
+
if ( isPostsPage ) {
|
|
570
|
+
const defaultTemplateId = select( coreStore ).getDefaultTemplateId(
|
|
571
|
+
{ slug: 'home' }
|
|
572
|
+
);
|
|
573
|
+
return getEditedEntityRecord(
|
|
574
|
+
'postType',
|
|
575
|
+
'wp_template',
|
|
576
|
+
defaultTemplateId
|
|
577
|
+
);
|
|
578
|
+
}
|
|
570
579
|
const currentTemplate =
|
|
571
580
|
select( editorStore ).getEditedPostAttribute( 'template' );
|
|
572
581
|
if ( currentTemplate ) {
|
|
573
|
-
const templateWithSameSlug =
|
|
574
|
-
|
|
575
|
-
|
|
582
|
+
const templateWithSameSlug = getEntityRecords(
|
|
583
|
+
'postType',
|
|
584
|
+
'wp_template',
|
|
585
|
+
{ per_page: -1 }
|
|
586
|
+
)?.find( ( template ) => template.slug === currentTemplate );
|
|
576
587
|
if ( ! templateWithSameSlug ) {
|
|
577
588
|
return templateWithSameSlug;
|
|
578
589
|
}
|
|
579
|
-
return
|
|
590
|
+
return getEditedEntityRecord(
|
|
580
591
|
'postType',
|
|
581
592
|
'wp_template',
|
|
582
593
|
templateWithSameSlug.id
|
|
583
594
|
);
|
|
584
595
|
}
|
|
585
|
-
|
|
586
|
-
const post = select( editorStore ).getCurrentPost();
|
|
587
596
|
let slugToCheck;
|
|
588
597
|
// In `draft` status we might not have a slug available, so we use the `single`
|
|
589
598
|
// post type templates slug(ex page, single-post, single-product etc..).
|
|
590
599
|
// Pages do not need the `single` prefix in the slug to be prioritized
|
|
591
600
|
// through template hierarchy.
|
|
592
|
-
if (
|
|
601
|
+
if ( slug ) {
|
|
593
602
|
slugToCheck =
|
|
594
|
-
|
|
595
|
-
? `${
|
|
596
|
-
: `single-${
|
|
603
|
+
postType === 'page'
|
|
604
|
+
? `${ postType }-${ slug }`
|
|
605
|
+
: `single-${ postType }-${ slug }`;
|
|
597
606
|
} else {
|
|
598
|
-
slugToCheck =
|
|
599
|
-
post.type === 'page' ? 'page' : `single-${ post.type }`;
|
|
607
|
+
slugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;
|
|
600
608
|
}
|
|
601
609
|
const defaultTemplateId = select( coreStore ).getDefaultTemplateId( {
|
|
602
610
|
slug: slugToCheck,
|