@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.
Files changed (261) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +4 -196
  3. package/build/components/browser-url/index.js.map +1 -1
  4. package/build/components/editor-initialization/index.js +0 -1
  5. package/build/components/editor-initialization/index.js.map +1 -1
  6. package/build/components/editor-initialization/listener-hooks.js +1 -38
  7. package/build/components/editor-initialization/listener-hooks.js.map +1 -1
  8. package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
  9. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  10. package/build/components/header/index.js +4 -4
  11. package/build/components/header/index.js.map +1 -1
  12. package/build/components/header/index.native.js +1 -1
  13. package/build/components/header/index.native.js.map +1 -1
  14. package/build/components/header/main-dashboard-button/index.js.map +1 -1
  15. package/build/components/header/more-menu/index.js +7 -6
  16. package/build/components/header/more-menu/index.js.map +1 -1
  17. package/build/components/header/post-publish-button-or-toggle.js +9 -6
  18. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  19. package/build/components/header/preferences-menu-item/index.js +12 -4
  20. package/build/components/header/preferences-menu-item/index.js.map +1 -1
  21. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  22. package/build/components/header/writing-menu/index.js.map +1 -1
  23. package/build/components/init-pattern-modal/index.js.map +1 -1
  24. package/build/components/keyboard-shortcuts/index.js +1 -36
  25. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  26. package/build/components/layout/actions-panel.js.map +1 -1
  27. package/build/components/layout/index.js +12 -20
  28. package/build/components/layout/index.js.map +1 -1
  29. package/build/components/layout/index.native.js.map +1 -1
  30. package/build/components/meta-boxes/index.js.map +1 -1
  31. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  32. package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  33. package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
  34. package/build/components/preferences-modal/enable-panel.js.map +1 -1
  35. package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
  36. package/build/components/preferences-modal/index.js +1 -21
  37. package/build/components/preferences-modal/index.js.map +1 -1
  38. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  39. package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  40. package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  41. package/build/components/sidebar/post-format/index.js.map +1 -1
  42. package/build/components/sidebar/post-pending-status/index.js.map +1 -1
  43. package/build/components/sidebar/post-slug/index.js.map +1 -1
  44. package/build/components/sidebar/post-status/index.js +9 -9
  45. package/build/components/sidebar/post-status/index.js.map +1 -1
  46. package/build/components/sidebar/post-sticky/index.js.map +1 -1
  47. package/build/components/sidebar/post-trash/index.js.map +1 -1
  48. package/build/components/sidebar/post-visibility/index.js.map +1 -1
  49. package/build/components/sidebar/settings-header/index.js.map +1 -1
  50. package/build/components/sidebar/settings-sidebar/index.js +37 -40
  51. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  52. package/build/components/text-editor/index.js.map +1 -1
  53. package/build/components/visual-editor/block-inspector-button.js +1 -1
  54. package/build/components/visual-editor/block-inspector-button.js.map +1 -1
  55. package/build/components/visual-editor/header.native.js.map +1 -1
  56. package/build/components/visual-editor/index.js +4 -1
  57. package/build/components/visual-editor/index.js.map +1 -1
  58. package/build/components/visual-editor/index.native.js.map +1 -1
  59. package/build/components/visual-editor/use-padding-appender.js +62 -0
  60. package/build/components/visual-editor/use-padding-appender.js.map +1 -0
  61. package/build/components/welcome-guide/default.js.map +1 -1
  62. package/build/components/welcome-guide/image.js.map +1 -1
  63. package/build/components/welcome-guide/index.js.map +1 -1
  64. package/build/components/welcome-guide/template.js.map +1 -1
  65. package/build/editor.js +2 -2
  66. package/build/editor.js.map +1 -1
  67. package/build/editor.native.js.map +1 -1
  68. package/build/hooks/commands/use-common-commands.js +5 -22
  69. package/build/hooks/commands/use-common-commands.js.map +1 -1
  70. package/build/hooks/components/index.js.map +1 -1
  71. package/build/hooks/index.js.map +1 -1
  72. package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
  73. package/build/hooks/validate-multiple-use/index.js.map +1 -1
  74. package/build/index.js +4 -8
  75. package/build/index.js.map +1 -1
  76. package/build/index.native.js.map +1 -1
  77. package/build/lock-unlock.js.map +1 -1
  78. package/build/plugins/copy-content-menu-item/index.js.map +1 -1
  79. package/build/plugins/index.js.map +1 -1
  80. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +7 -4
  81. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  82. package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
  83. package/build/store/actions.js +10 -8
  84. package/build/store/actions.js.map +1 -1
  85. package/build/store/constants.js.map +1 -1
  86. package/build/store/index.js +1 -1
  87. package/build/store/index.js.map +1 -1
  88. package/build/store/reducer.js.map +1 -1
  89. package/build/store/selectors.js +34 -19
  90. package/build/store/selectors.js.map +1 -1
  91. package/build/utils/meta-boxes.js.map +1 -1
  92. package/build-module/components/browser-url/index.js.map +1 -1
  93. package/build-module/components/editor-initialization/index.js +1 -2
  94. package/build-module/components/editor-initialization/index.js.map +1 -1
  95. package/build-module/components/editor-initialization/listener-hooks.js +2 -38
  96. package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
  97. package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
  98. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  99. package/build-module/components/header/index.js +3 -3
  100. package/build-module/components/header/index.js.map +1 -1
  101. package/build-module/components/header/index.native.js +1 -1
  102. package/build-module/components/header/index.native.js.map +1 -1
  103. package/build-module/components/header/main-dashboard-button/index.js.map +1 -1
  104. package/build-module/components/header/more-menu/index.js +5 -4
  105. package/build-module/components/header/more-menu/index.js.map +1 -1
  106. package/build-module/components/header/post-publish-button-or-toggle.js +9 -6
  107. package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
  108. package/build-module/components/header/preferences-menu-item/index.js +11 -3
  109. package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
  110. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  111. package/build-module/components/header/writing-menu/index.js.map +1 -1
  112. package/build-module/components/init-pattern-modal/index.js.map +1 -1
  113. package/build-module/components/keyboard-shortcuts/index.js +1 -36
  114. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  115. package/build-module/components/layout/actions-panel.js.map +1 -1
  116. package/build-module/components/layout/index.js +11 -19
  117. package/build-module/components/layout/index.js.map +1 -1
  118. package/build-module/components/layout/index.native.js.map +1 -1
  119. package/build-module/components/meta-boxes/index.js.map +1 -1
  120. package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
  121. package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  122. package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
  123. package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
  124. package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
  125. package/build-module/components/preferences-modal/index.js +1 -20
  126. package/build-module/components/preferences-modal/index.js.map +1 -1
  127. package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
  128. package/build-module/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  129. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  130. package/build-module/components/sidebar/post-format/index.js.map +1 -1
  131. package/build-module/components/sidebar/post-pending-status/index.js.map +1 -1
  132. package/build-module/components/sidebar/post-slug/index.js.map +1 -1
  133. package/build-module/components/sidebar/post-status/index.js +9 -10
  134. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  135. package/build-module/components/sidebar/post-sticky/index.js.map +1 -1
  136. package/build-module/components/sidebar/post-trash/index.js.map +1 -1
  137. package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
  138. package/build-module/components/sidebar/settings-header/index.js.map +1 -1
  139. package/build-module/components/sidebar/settings-sidebar/index.js +38 -41
  140. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  141. package/build-module/components/text-editor/index.js.map +1 -1
  142. package/build-module/components/visual-editor/block-inspector-button.js +1 -1
  143. package/build-module/components/visual-editor/block-inspector-button.js.map +1 -1
  144. package/build-module/components/visual-editor/header.native.js.map +1 -1
  145. package/build-module/components/visual-editor/index.js +4 -1
  146. package/build-module/components/visual-editor/index.js.map +1 -1
  147. package/build-module/components/visual-editor/index.native.js.map +1 -1
  148. package/build-module/components/visual-editor/use-padding-appender.js +55 -0
  149. package/build-module/components/visual-editor/use-padding-appender.js.map +1 -0
  150. package/build-module/components/welcome-guide/default.js.map +1 -1
  151. package/build-module/components/welcome-guide/image.js.map +1 -1
  152. package/build-module/components/welcome-guide/index.js.map +1 -1
  153. package/build-module/components/welcome-guide/template.js.map +1 -1
  154. package/build-module/editor.js +2 -2
  155. package/build-module/editor.js.map +1 -1
  156. package/build-module/editor.native.js.map +1 -1
  157. package/build-module/hooks/commands/use-common-commands.js +7 -24
  158. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  159. package/build-module/hooks/components/index.js.map +1 -1
  160. package/build-module/hooks/index.js.map +1 -1
  161. package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
  162. package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
  163. package/build-module/index.js +5 -5
  164. package/build-module/index.js.map +1 -1
  165. package/build-module/index.native.js.map +1 -1
  166. package/build-module/lock-unlock.js.map +1 -1
  167. package/build-module/plugins/copy-content-menu-item/index.js.map +1 -1
  168. package/build-module/plugins/index.js.map +1 -1
  169. package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +6 -3
  170. package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  171. package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
  172. package/build-module/store/actions.js +8 -7
  173. package/build-module/store/actions.js.map +1 -1
  174. package/build-module/store/constants.js.map +1 -1
  175. package/build-module/store/index.js.map +1 -1
  176. package/build-module/store/reducer.js.map +1 -1
  177. package/build-module/store/selectors.js +33 -18
  178. package/build-module/store/selectors.js.map +1 -1
  179. package/build-module/utils/meta-boxes.js.map +1 -1
  180. package/build-style/classic-rtl.css +2 -2
  181. package/build-style/classic.css +2 -2
  182. package/build-style/style-rtl.css +12 -448
  183. package/build-style/style.css +12 -448
  184. package/package.json +32 -34
  185. package/src/classic.scss +1 -1
  186. package/src/components/editor-initialization/index.js +1 -5
  187. package/src/components/editor-initialization/listener-hooks.js +1 -40
  188. package/src/components/editor-initialization/test/listener-hooks.js +1 -96
  189. package/src/components/header/index.js +2 -3
  190. package/src/components/header/index.native.js +1 -1
  191. package/src/components/header/more-menu/index.js +3 -4
  192. package/src/components/header/post-publish-button-or-toggle.js +8 -3
  193. package/src/components/header/preferences-menu-item/index.js +9 -3
  194. package/src/components/header/style.scss +5 -3
  195. package/src/components/header/test/index.js +13 -1
  196. package/src/components/keyboard-shortcuts/index.js +3 -44
  197. package/src/components/layout/index.js +14 -41
  198. package/src/components/preferences-modal/index.js +1 -24
  199. package/src/components/sidebar/post-status/index.js +6 -9
  200. package/src/components/sidebar/settings-sidebar/index.js +62 -58
  201. package/src/components/visual-editor/block-inspector-button.js +1 -1
  202. package/src/components/visual-editor/index.js +4 -0
  203. package/src/components/visual-editor/use-padding-appender.js +66 -0
  204. package/src/editor.js +2 -2
  205. package/src/hooks/commands/use-common-commands.js +11 -26
  206. package/src/index.js +8 -4
  207. package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
  208. package/src/store/actions.js +10 -12
  209. package/src/store/selectors.js +41 -33
  210. package/src/store/test/actions.js +11 -10
  211. package/src/style.scss +1 -19
  212. package/build/components/header/plugin-more-menu-item/index.js +0 -78
  213. package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
  214. package/build/components/header/plugin-sidebar-more-menu-item/index.js +0 -71
  215. package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
  216. package/build/components/keyboard-shortcut-help-modal/config.js +0 -78
  217. package/build/components/keyboard-shortcut-help-modal/config.js.map +0 -1
  218. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -49
  219. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
  220. package/build/components/keyboard-shortcut-help-modal/index.js +0 -132
  221. package/build/components/keyboard-shortcut-help-modal/index.js.map +0 -1
  222. package/build/components/keyboard-shortcut-help-modal/shortcut.js +0 -55
  223. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
  224. package/build/components/sidebar/plugin-post-status-info/index.js +0 -73
  225. package/build/components/sidebar/plugin-post-status-info/index.js.map +0 -1
  226. package/build/components/sidebar/plugin-sidebar/index.js +0 -104
  227. package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
  228. package/build/components/start-page-options/index.js +0 -107
  229. package/build/components/start-page-options/index.js.map +0 -1
  230. package/build-module/components/header/plugin-more-menu-item/index.js +0 -73
  231. package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
  232. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +0 -65
  233. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
  234. package/build-module/components/keyboard-shortcut-help-modal/config.js +0 -71
  235. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +0 -1
  236. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -41
  237. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
  238. package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -122
  239. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +0 -1
  240. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -48
  241. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
  242. package/build-module/components/sidebar/plugin-post-status-info/index.js +0 -66
  243. package/build-module/components/sidebar/plugin-post-status-info/index.js.map +0 -1
  244. package/build-module/components/sidebar/plugin-sidebar/index.js +0 -98
  245. package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
  246. package/build-module/components/start-page-options/index.js +0 -100
  247. package/build-module/components/start-page-options/index.js.map +0 -1
  248. package/src/components/header/plugin-more-menu-item/index.js +0 -73
  249. package/src/components/header/plugin-sidebar-more-menu-item/index.js +0 -64
  250. package/src/components/keyboard-shortcut-help-modal/config.js +0 -53
  251. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -43
  252. package/src/components/keyboard-shortcut-help-modal/index.js +0 -163
  253. package/src/components/keyboard-shortcut-help-modal/shortcut.js +0 -67
  254. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -61
  255. package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -36
  256. package/src/components/sidebar/plugin-post-status-info/index.js +0 -63
  257. package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +0 -11
  258. package/src/components/sidebar/plugin-post-status-info/test/index.js +0 -29
  259. package/src/components/sidebar/plugin-sidebar/index.js +0 -94
  260. package/src/components/start-page-options/index.js +0 -108
  261. 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 } = unlock( editorPrivateApis );
43
-
42
+ const { PostCardPanel, PostActions, interfaceStore } =
43
+ unlock( editorPrivateApis );
44
44
  const { Tabs } = unlock( componentsPrivateApis );
45
- const { PatternOverridesPanel } = unlock( editorPrivateApis );
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
- const SidebarContent = ( {
57
- sidebarName,
58
- keyboardShortcut,
59
- isEditingTemplate,
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 `PluginSidebarEditPost` renders a `ComplementaryArea`, we
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' ) === sidebarName
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
- }, [ sidebarName ] );
98
+ }, [ tabName ] );
93
99
 
94
100
  return (
95
- <PluginSidebarEditPost
96
- identifier={ sidebarName }
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
- </PluginSidebarEditPost>
147
+ </PluginSidebar>
136
148
  );
137
149
  };
138
150
 
139
151
  const SettingsSidebar = () => {
140
- const {
141
- sidebarName,
142
- isSettingsSidebarActive,
143
- keyboardShortcut,
144
- isEditingTemplate,
145
- } = useSelect( ( select ) => {
146
- // The settings sidebar is used by the edit-post/document and edit-post/block sidebars.
147
- // sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.
148
- // If one of the two sidebars is active the component will contain the content of that sidebar.
149
- // When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost
150
- // component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName
151
- // should contain the sidebar that will be active when the toggle button is pressed. If a block
152
- // is selected, that should be edit-post/block otherwise it's edit-post/document.
153
- let sidebar = select( interfaceStore ).getActiveComplementaryArea(
154
- editPostStore.name
155
- );
156
- let isSettingsSidebar = true;
157
- if ( ! [ sidebars.document, sidebars.block ].includes( sidebar ) ) {
158
- isSettingsSidebar = false;
159
- if ( select( blockEditorStore ).getBlockSelectionStart() ) {
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
- sidebar = sidebars.document;
163
- }
164
- const shortcut = select(
165
- keyboardShortcutsStore
166
- ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );
167
- return {
168
- sidebarName: sidebar,
169
- isSettingsSidebarActive: isSettingsSidebar,
170
- keyboardShortcut: shortcut,
171
- isEditingTemplate:
172
- select( editorStore ).getCurrentPostType() === 'wp_template',
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
- // Due to how this component is controlled (via a value from the
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
- sidebarName={ sidebarName }
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/edit-post/toggle-sidebar' ),
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 canEditTemplate = canUser( 'create', 'templates' );
61
+ const canViewTemplate = canUser( 'read', 'templates' );
62
62
  return {
63
63
  template:
64
64
  supportsTemplateMode &&
65
65
  isViewable &&
66
- canEditTemplate &&
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 { store as interfaceStore } from '@wordpress/interface';
17
- import { store as editorStore } from '@wordpress/editor';
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: select(
37
- interfaceStore
38
- ).getActiveComplementaryArea( editPostStore.name ),
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 { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';
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 { store as interfaceStore } from '@wordpress/interface';
8
+ import { privateApis as editorPrivateApis } from '@wordpress/editor';
9
9
 
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
- import { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';
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( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );
21
+ openModal( 'editor/keyboard-shortcut-help' );
20
22
  } }
21
23
  shortcut={ displayShortcut.access( 'h' ) }
22
24
  >
@@ -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 { store as editorStore } from '@wordpress/editor';
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( editPostStore.name, name );
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/edit-post', pluginName );
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
  /**
@@ -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 { store as editorStore } from '@wordpress/editor';
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 = select( coreStore )
574
- .getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )
575
- ?.find( ( template ) => template.slug === currentTemplate );
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 select( coreStore ).getEditedEntityRecord(
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 ( post.slug ) {
601
+ if ( slug ) {
593
602
  slugToCheck =
594
- post.type === 'page'
595
- ? `${ post.type }-${ post.slug }`
596
- : `single-${ post.type }-${ post.slug }`;
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,