@wordpress/editor 13.22.0 → 13.24.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 (137) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/entities-saved-states/index.js +15 -1
  3. package/build/components/entities-saved-states/index.js.map +1 -1
  4. package/build/components/index.js +32 -0
  5. package/build/components/index.js.map +1 -1
  6. package/build/components/page-attributes/order.js +1 -0
  7. package/build/components/page-attributes/order.js.map +1 -1
  8. package/build/components/post-author/panel.js +24 -0
  9. package/build/components/post-author/panel.js.map +1 -0
  10. package/build/components/post-featured-image/index.js +3 -1
  11. package/build/components/post-featured-image/index.js.map +1 -1
  12. package/build/components/post-panel-row/index.js +36 -0
  13. package/build/components/post-panel-row/index.js.map +1 -0
  14. package/build/components/post-saved-state/index.js +21 -16
  15. package/build/components/post-saved-state/index.js.map +1 -1
  16. package/build/components/post-schedule/panel.js +67 -0
  17. package/build/components/post-schedule/panel.js.map +1 -0
  18. package/build/components/post-sync-status/index.js +9 -5
  19. package/build/components/post-sync-status/index.js.map +1 -1
  20. package/build/components/post-title/constants.js +11 -0
  21. package/build/components/post-title/constants.js.map +1 -0
  22. package/build/components/post-title/index.js +61 -90
  23. package/build/components/post-title/index.js.map +1 -1
  24. package/build/components/post-title/index.native.js +1 -1
  25. package/build/components/post-title/index.native.js.map +1 -1
  26. package/build/components/post-title/post-title-raw.js +92 -0
  27. package/build/components/post-title/post-title-raw.js.map +1 -0
  28. package/build/components/post-title/use-post-title-focus.js +64 -0
  29. package/build/components/post-title/use-post-title-focus.js.map +1 -0
  30. package/build/components/post-title/use-post-title.js +41 -0
  31. package/build/components/post-title/use-post-title.js.map +1 -0
  32. package/build/components/post-url/panel.js +70 -0
  33. package/build/components/post-url/panel.js.map +1 -0
  34. package/build/components/provider/constants.js +9 -0
  35. package/build/components/provider/constants.js.map +1 -0
  36. package/build/components/provider/disable-non-page-content-blocks.js +63 -0
  37. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -0
  38. package/build/components/provider/index.js +126 -14
  39. package/build/components/provider/index.js.map +1 -1
  40. package/build/components/provider/use-block-editor-settings.js +22 -17
  41. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  42. package/build/components/provider/use-block-editor-settings.native.js +2 -2
  43. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  44. package/build/private-apis.js +7 -1
  45. package/build/private-apis.js.map +1 -1
  46. package/build/store/actions.js +23 -2
  47. package/build/store/actions.js.map +1 -1
  48. package/build/store/reducer.js +10 -1
  49. package/build/store/reducer.js.map +1 -1
  50. package/build/store/selectors.js +16 -2
  51. package/build/store/selectors.js.map +1 -1
  52. package/build-module/components/entities-saved-states/index.js +16 -2
  53. package/build-module/components/entities-saved-states/index.js.map +1 -1
  54. package/build-module/components/index.js +4 -0
  55. package/build-module/components/index.js.map +1 -1
  56. package/build-module/components/page-attributes/order.js +1 -0
  57. package/build-module/components/page-attributes/order.js.map +1 -1
  58. package/build-module/components/post-author/panel.js +14 -0
  59. package/build-module/components/post-author/panel.js.map +1 -0
  60. package/build-module/components/post-featured-image/index.js +3 -1
  61. package/build-module/components/post-featured-image/index.js.map +1 -1
  62. package/build-module/components/post-panel-row/index.js +27 -0
  63. package/build-module/components/post-panel-row/index.js.map +1 -0
  64. package/build-module/components/post-saved-state/index.js +22 -17
  65. package/build-module/components/post-saved-state/index.js.map +1 -1
  66. package/build-module/components/post-schedule/panel.js +59 -0
  67. package/build-module/components/post-schedule/panel.js.map +1 -0
  68. package/build-module/components/post-sync-status/index.js +10 -7
  69. package/build-module/components/post-sync-status/index.js.map +1 -1
  70. package/build-module/components/post-title/constants.js +3 -0
  71. package/build-module/components/post-title/constants.js.map +1 -0
  72. package/build-module/components/post-title/index.js +62 -92
  73. package/build-module/components/post-title/index.js.map +1 -1
  74. package/build-module/components/post-title/index.native.js +3 -3
  75. package/build-module/components/post-title/index.native.js.map +1 -1
  76. package/build-module/components/post-title/post-title-raw.js +83 -0
  77. package/build-module/components/post-title/post-title-raw.js.map +1 -0
  78. package/build-module/components/post-title/use-post-title-focus.js +57 -0
  79. package/build-module/components/post-title/use-post-title-focus.js.map +1 -0
  80. package/build-module/components/post-title/use-post-title.js +33 -0
  81. package/build-module/components/post-title/use-post-title.js.map +1 -0
  82. package/build-module/components/post-url/panel.js +62 -0
  83. package/build-module/components/post-url/panel.js.map +1 -0
  84. package/build-module/components/provider/constants.js +2 -0
  85. package/build-module/components/provider/constants.js.map +1 -0
  86. package/build-module/components/provider/disable-non-page-content-blocks.js +56 -0
  87. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -0
  88. package/build-module/components/provider/index.js +127 -15
  89. package/build-module/components/provider/index.js.map +1 -1
  90. package/build-module/components/provider/use-block-editor-settings.js +22 -17
  91. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  92. package/build-module/components/provider/use-block-editor-settings.native.js +2 -2
  93. package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
  94. package/build-module/private-apis.js +6 -1
  95. package/build-module/private-apis.js.map +1 -1
  96. package/build-module/store/actions.js +21 -0
  97. package/build-module/store/actions.js.map +1 -1
  98. package/build-module/store/reducer.js +9 -1
  99. package/build-module/store/reducer.js.map +1 -1
  100. package/build-module/store/selectors.js +11 -0
  101. package/build-module/store/selectors.js.map +1 -1
  102. package/build-style/style-rtl.css +70 -10
  103. package/build-style/style.css +70 -10
  104. package/package.json +31 -31
  105. package/src/components/entities-saved-states/index.js +16 -1
  106. package/src/components/index.js +4 -0
  107. package/src/components/page-attributes/order.js +1 -0
  108. package/src/components/post-author/panel.js +18 -0
  109. package/src/components/post-author/style.scss +7 -0
  110. package/src/components/post-featured-image/index.js +3 -1
  111. package/src/components/post-panel-row/index.js +26 -0
  112. package/src/components/post-panel-row/style.scss +21 -0
  113. package/src/components/post-saved-state/index.js +46 -37
  114. package/src/components/post-schedule/panel.js +65 -0
  115. package/src/components/post-schedule/style.scss +23 -0
  116. package/src/components/post-sync-status/index.js +10 -8
  117. package/src/components/post-sync-status/style.scss +3 -18
  118. package/src/components/post-title/constants.js +4 -0
  119. package/src/components/post-title/index.js +56 -88
  120. package/src/components/post-title/index.native.js +4 -8
  121. package/src/components/post-title/post-title-raw.js +82 -0
  122. package/src/components/post-title/style.scss +5 -0
  123. package/src/components/post-title/use-post-title-focus.js +50 -0
  124. package/src/components/post-title/use-post-title.js +25 -0
  125. package/src/components/post-url/panel.js +60 -0
  126. package/src/components/post-url/style.scss +19 -0
  127. package/src/components/provider/README.md +37 -0
  128. package/src/components/provider/constants.js +5 -0
  129. package/src/components/provider/disable-non-page-content-blocks.js +55 -0
  130. package/src/components/provider/index.js +200 -14
  131. package/src/components/provider/use-block-editor-settings.js +54 -35
  132. package/src/components/provider/use-block-editor-settings.native.js +2 -2
  133. package/src/private-apis.js +6 -0
  134. package/src/store/actions.js +21 -0
  135. package/src/store/reducer.js +10 -0
  136. package/src/store/selectors.js +11 -0
  137. package/src/style.scss +4 -0
@@ -9,9 +9,11 @@ import {
9
9
  BlockEditorProvider,
10
10
  BlockContextProvider,
11
11
  privateApis as blockEditorPrivateApis,
12
+ store as blockEditorStore,
12
13
  } from '@wordpress/block-editor';
13
14
  import { store as noticesStore } from '@wordpress/notices';
14
15
  import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
16
+ import { createBlock } from '@wordpress/blocks';
15
17
 
16
18
  /**
17
19
  * Internal dependencies
@@ -20,26 +22,205 @@ import withRegistryProvider from './with-registry-provider';
20
22
  import { store as editorStore } from '../../store';
21
23
  import useBlockEditorSettings from './use-block-editor-settings';
22
24
  import { unlock } from '../../lock-unlock';
25
+ import DisableNonPageContentBlocks from './disable-non-page-content-blocks';
26
+ import { PAGE_CONTENT_BLOCK_TYPES } from './constants';
23
27
 
24
28
  const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
25
29
  const { PatternsMenuItems } = unlock( editPatternsPrivateApis );
26
30
 
31
+ const noop = () => {};
32
+
33
+ /**
34
+ * For the Navigation block editor, we need to force the block editor to contentOnly for that block.
35
+ *
36
+ * Set block editing mode to contentOnly when entering Navigation focus mode.
37
+ * this ensures that non-content controls on the block will be hidden and thus
38
+ * the user can focus on editing the Navigation Menu content only.
39
+ *
40
+ * @param {string} navigationBlockClientId ClientId.
41
+ */
42
+ function useForceFocusModeForNavigation( navigationBlockClientId ) {
43
+ const { setBlockEditingMode, unsetBlockEditingMode } =
44
+ useDispatch( blockEditorStore );
45
+
46
+ useEffect( () => {
47
+ if ( ! navigationBlockClientId ) {
48
+ return;
49
+ }
50
+
51
+ setBlockEditingMode( navigationBlockClientId, 'contentOnly' );
52
+
53
+ return () => {
54
+ unsetBlockEditingMode( navigationBlockClientId );
55
+ };
56
+ }, [
57
+ navigationBlockClientId,
58
+ unsetBlockEditingMode,
59
+ setBlockEditingMode,
60
+ ] );
61
+ }
62
+
63
+ /**
64
+ * Helper method to extract the post content block types from a template.
65
+ *
66
+ * @param {Array} blocks Template blocks.
67
+ *
68
+ * @return {Array} Flattened object.
69
+ */
70
+ function extractPageContentBlockTypesFromTemplateBlocks( blocks ) {
71
+ const result = [];
72
+ for ( let i = 0; i < blocks.length; i++ ) {
73
+ // Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,
74
+ // we skip it because we only want to render stand-alone page content blocks in the block list.
75
+ if ( blocks[ i ].name === 'core/query' ) {
76
+ continue;
77
+ }
78
+ if ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {
79
+ result.push( createBlock( blocks[ i ].name ) );
80
+ }
81
+ if ( blocks[ i ].innerBlocks.length ) {
82
+ result.push(
83
+ ...extractPageContentBlockTypesFromTemplateBlocks(
84
+ blocks[ i ].innerBlocks
85
+ )
86
+ );
87
+ }
88
+ }
89
+
90
+ return result;
91
+ }
92
+
93
+ /**
94
+ * Depending on the post, template and template mode,
95
+ * returns the appropriate blocks and change handlers for the block editor provider.
96
+ *
97
+ * @param {Array} post Block list.
98
+ * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
99
+ * @param {string} mode Rendering mode.
100
+ * @return {Array} Block editor props.
101
+ */
102
+ function useBlockEditorProps( post, template, mode ) {
103
+ const rootLevelPost =
104
+ mode === 'post-only' || ! template ? 'post' : 'template';
105
+ const [ postBlocks, onInput, onChange ] = useEntityBlockEditor(
106
+ 'postType',
107
+ post.type,
108
+ { id: post.id }
109
+ );
110
+ const [ templateBlocks, onInputTemplate, onChangeTemplate ] =
111
+ useEntityBlockEditor( 'postType', template?.type, {
112
+ id: template?.id,
113
+ } );
114
+ const blocks = useMemo( () => {
115
+ if ( post.type === 'wp_navigation' ) {
116
+ return [
117
+ createBlock( 'core/navigation', {
118
+ ref: post.id,
119
+ // As the parent editor is locked with `templateLock`, the template locking
120
+ // must be explicitly "unset" on the block itself to allow the user to modify
121
+ // the block's content.
122
+ templateLock: false,
123
+ } ),
124
+ ];
125
+ }
126
+
127
+ if ( mode === 'post-only' ) {
128
+ const postContentBlocks =
129
+ extractPageContentBlockTypesFromTemplateBlocks(
130
+ templateBlocks
131
+ );
132
+ return [
133
+ createBlock(
134
+ 'core/group',
135
+ {
136
+ layout: { type: 'constrained' },
137
+ style: {
138
+ spacing: {
139
+ margin: {
140
+ top: '4em', // Mimics the post editor.
141
+ },
142
+ },
143
+ },
144
+ },
145
+ postContentBlocks.length
146
+ ? postContentBlocks
147
+ : [
148
+ createBlock( 'core/post-title' ),
149
+ createBlock( 'core/post-content' ),
150
+ ]
151
+ ),
152
+ ];
153
+ }
154
+
155
+ if ( rootLevelPost === 'template' ) {
156
+ return templateBlocks;
157
+ }
158
+
159
+ return postBlocks;
160
+ }, [
161
+ templateBlocks,
162
+ postBlocks,
163
+ rootLevelPost,
164
+ post.type,
165
+ post.id,
166
+ mode,
167
+ ] );
168
+ const disableRootLevelChanges =
169
+ ( !! template && mode === 'template-locked' ) ||
170
+ post.type === 'wp_navigation' ||
171
+ mode === 'post-only';
172
+ const navigationBlockClientId =
173
+ post.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;
174
+ useForceFocusModeForNavigation( navigationBlockClientId );
175
+ if ( disableRootLevelChanges ) {
176
+ return [ blocks, noop, noop ];
177
+ }
178
+
179
+ return [
180
+ blocks,
181
+ rootLevelPost === 'post' ? onInput : onInputTemplate,
182
+ rootLevelPost === 'post' ? onChange : onChangeTemplate,
183
+ ];
184
+ }
185
+
27
186
  export const ExperimentalEditorProvider = withRegistryProvider(
28
187
  ( {
29
- __unstableTemplate,
30
188
  post,
31
189
  settings,
32
190
  recovery,
33
191
  initialEdits,
34
192
  children,
35
193
  BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
194
+ __unstableTemplate: template,
36
195
  } ) => {
196
+ const mode = useSelect(
197
+ ( select ) => select( editorStore ).getRenderingMode(),
198
+ []
199
+ );
200
+ const shouldRenderTemplate = !! template && mode !== 'post-only';
201
+ const rootLevelPost = shouldRenderTemplate ? template : post;
37
202
  const defaultBlockContext = useMemo( () => {
38
- if ( post.type === 'wp_template' ) {
39
- return {};
40
- }
41
- return { postId: post.id, postType: post.type };
42
- }, [ post.id, post.type ] );
203
+ const postContext =
204
+ rootLevelPost.type !== 'wp_template' ||
205
+ ( shouldRenderTemplate && mode !== 'template-only' )
206
+ ? { postId: post.id, postType: post.type }
207
+ : {};
208
+
209
+ return {
210
+ ...postContext,
211
+ templateSlug:
212
+ rootLevelPost.type === 'wp_template'
213
+ ? rootLevelPost.slug
214
+ : undefined,
215
+ };
216
+ }, [
217
+ mode,
218
+ post.id,
219
+ post.type,
220
+ rootLevelPost.type,
221
+ rootLevelPost?.slug,
222
+ shouldRenderTemplate,
223
+ ] );
43
224
  const { editorSettings, selection, isReady } = useSelect(
44
225
  ( select ) => {
45
226
  const {
@@ -55,16 +236,18 @@ export const ExperimentalEditorProvider = withRegistryProvider(
55
236
  },
56
237
  []
57
238
  );
58
- const { id, type } = __unstableTemplate ?? post;
59
- const [ blocks, onInput, onChange ] = useEntityBlockEditor(
60
- 'postType',
61
- type,
62
- { id }
63
- );
239
+ const { id, type } = rootLevelPost;
64
240
  const blockEditorSettings = useBlockEditorSettings(
65
241
  editorSettings,
66
- !! __unstableTemplate
242
+ type,
243
+ id
67
244
  );
245
+ const [ blocks, onInput, onChange ] = useBlockEditorProps(
246
+ post,
247
+ template,
248
+ mode
249
+ );
250
+
68
251
  const {
69
252
  updatePostLock,
70
253
  setupEditor,
@@ -108,7 +291,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
108
291
  // Synchronize the editor settings as they change.
109
292
  useEffect( () => {
110
293
  updateEditorSettings( settings );
111
- }, [ settings ] );
294
+ }, [ settings, updateEditorSettings ] );
112
295
 
113
296
  if ( ! isReady ) {
114
297
  return null;
@@ -132,6 +315,9 @@ export const ExperimentalEditorProvider = withRegistryProvider(
132
315
  >
133
316
  { children }
134
317
  <PatternsMenuItems />
318
+ { [ 'post-only', 'template-locked' ].includes(
319
+ mode
320
+ ) && <DisableNonPageContentBlocks /> }
135
321
  </BlockEditorProviderComponent>
136
322
  </BlockContextProvider>
137
323
  </EntityProvider>
@@ -67,8 +67,6 @@ const BLOCK_EDITOR_SETTINGS = [
67
67
  'postsPerPage',
68
68
  'readOnly',
69
69
  'styles',
70
- 'template',
71
- 'templateLock',
72
70
  'titlePlaceholder',
73
71
  'supportsLayout',
74
72
  'widgetTypesToHideFromLegacyWidgetBlock',
@@ -76,17 +74,20 @@ const BLOCK_EDITOR_SETTINGS = [
76
74
  '__unstableIsPreviewMode',
77
75
  '__unstableResolvedAssets',
78
76
  '__unstableIsBlockBasedTheme',
77
+ '__experimentalArchiveTitleTypeLabel',
78
+ '__experimentalArchiveTitleNameLabel',
79
79
  ];
80
80
 
81
81
  /**
82
82
  * React hook used to compute the block editor settings to use for the post editor.
83
83
  *
84
- * @param {Object} settings EditorProvider settings prop.
85
- * @param {boolean} hasTemplate Whether template mode is enabled.
84
+ * @param {Object} settings EditorProvider settings prop.
85
+ * @param {string} postType Editor root level post type.
86
+ * @param {string} postId Editor root level post ID.
86
87
  *
87
88
  * @return {Object} Block Editor Settings.
88
89
  */
89
- function useBlockEditorSettings( settings, hasTemplate ) {
90
+ function useBlockEditorSettings( settings, postType, postId ) {
90
91
  const {
91
92
  reusableBlocks,
92
93
  hasUploadPermissions,
@@ -94,36 +95,42 @@ function useBlockEditorSettings( settings, hasTemplate ) {
94
95
  userCanCreatePages,
95
96
  pageOnFront,
96
97
  pageForPosts,
97
- postType,
98
98
  userPatternCategories,
99
- } = useSelect( ( select ) => {
100
- const { canUserUseUnfilteredHTML, getCurrentPostType } =
101
- select( editorStore );
102
- const isWeb = Platform.OS === 'web';
103
- const { canUser, getEntityRecord, getUserPatternCategories } =
104
- select( coreStore );
99
+ } = useSelect(
100
+ ( select ) => {
101
+ const isWeb = Platform.OS === 'web';
102
+ const {
103
+ canUser,
104
+ getRawEntityRecord,
105
+ getEntityRecord,
106
+ getUserPatternCategories,
107
+ getEntityRecords,
108
+ } = select( coreStore );
105
109
 
106
- const siteSettings = canUser( 'read', 'settings' )
107
- ? getEntityRecord( 'root', 'site' )
108
- : undefined;
110
+ const siteSettings = canUser( 'read', 'settings' )
111
+ ? getEntityRecord( 'root', 'site' )
112
+ : undefined;
109
113
 
110
- return {
111
- canUseUnfilteredHTML: canUserUseUnfilteredHTML(),
112
- reusableBlocks: isWeb
113
- ? select( coreStore ).getEntityRecords(
114
- 'postType',
115
- 'wp_block',
116
- { per_page: -1 }
117
- )
118
- : EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.
119
- hasUploadPermissions: canUser( 'create', 'media' ) ?? true,
120
- userCanCreatePages: canUser( 'create', 'pages' ),
121
- pageOnFront: siteSettings?.page_on_front,
122
- pageForPosts: siteSettings?.page_for_posts,
123
- postType: getCurrentPostType(),
124
- userPatternCategories: getUserPatternCategories(),
125
- };
126
- }, [] );
114
+ return {
115
+ canUseUnfilteredHTML: getRawEntityRecord(
116
+ 'postType',
117
+ postType,
118
+ postId
119
+ )?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),
120
+ reusableBlocks: isWeb
121
+ ? getEntityRecords( 'postType', 'wp_block', {
122
+ per_page: -1,
123
+ } )
124
+ : EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.
125
+ hasUploadPermissions: canUser( 'create', 'media' ) ?? true,
126
+ userCanCreatePages: canUser( 'create', 'pages' ),
127
+ pageOnFront: siteSettings?.page_on_front,
128
+ pageForPosts: siteSettings?.page_for_posts,
129
+ userPatternCategories: getUserPatternCategories(),
130
+ };
131
+ },
132
+ [ postType, postId ]
133
+ );
127
134
 
128
135
  const settingsBlockPatterns =
129
136
  settings.__experimentalAdditionalBlockPatterns ?? // WP 6.0
@@ -214,14 +221,26 @@ function useBlockEditorSettings( settings, hasTemplate ) {
214
221
  fetchLinkSuggestions( search, searchOptions, settings ),
215
222
  inserterMediaCategories,
216
223
  __experimentalFetchRichUrlData: fetchUrlData,
224
+ // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
225
+ // This might be better as a generic "canUser" selector.
217
226
  __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
227
+ //Todo: this is only needed for native and should probably be removed.
218
228
  __experimentalUndo: undo,
219
- outlineMode: hasTemplate,
229
+ // Check whether we want all site editor frames to have outlines
230
+ // including the navigation / pattern / parts editors.
231
+ outlineMode: postType === 'wp_template',
232
+ // Check these two properties: they were not present in the site editor.
220
233
  __experimentalCreatePageEntity: createPageEntity,
221
234
  __experimentalUserCanCreatePages: userCanCreatePages,
222
235
  pageOnFront,
223
236
  pageForPosts,
224
- __experimentalPreferPatternsOnRoot: hasTemplate,
237
+ __experimentalPreferPatternsOnRoot: postType === 'wp_template',
238
+ templateLock:
239
+ postType === 'wp_navigation' ? 'insert' : settings.templateLock,
240
+ template:
241
+ postType === 'wp_navigation'
242
+ ? [ [ 'core/navigation', {}, [] ] ]
243
+ : settings.template,
225
244
  } ),
226
245
  [
227
246
  settings,
@@ -232,11 +251,11 @@ function useBlockEditorSettings( settings, hasTemplate ) {
232
251
  blockPatternCategories,
233
252
  canUseUnfilteredHTML,
234
253
  undo,
235
- hasTemplate,
236
254
  createPageEntity,
237
255
  userCanCreatePages,
238
256
  pageOnFront,
239
257
  pageForPosts,
258
+ postType,
240
259
  ]
241
260
  );
242
261
  }
@@ -13,8 +13,8 @@ import { store as editorStore } from '../../store';
13
13
 
14
14
  const EMPTY_BLOCKS_LIST = [];
15
15
 
16
- function useNativeBlockEditorSettings( settings, hasTemplate ) {
17
- const editorSettings = useBlockEditorSettings( settings, hasTemplate );
16
+ function useNativeBlockEditorSettings( settings, postType, postId ) {
17
+ const editorSettings = useBlockEditorSettings( settings, postType, postId );
18
18
  const supportReusableBlock = settings.capabilities?.reusableBlock === true;
19
19
 
20
20
  const { reusableBlocks, isTitleSelected } = useSelect(
@@ -4,9 +4,15 @@
4
4
  import { ExperimentalEditorProvider } from './components/provider';
5
5
  import { lock } from './lock-unlock';
6
6
  import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
7
+ import useBlockEditorSettings from './components/provider/use-block-editor-settings';
8
+ import PostPanelRow from './components/post-panel-row';
7
9
 
8
10
  export const privateApis = {};
9
11
  lock( privateApis, {
10
12
  ExperimentalEditorProvider,
11
13
  EntitiesSavedStatesExtensible,
14
+ PostPanelRow,
15
+
16
+ // This is a temporary private API while we're updating the site editor to use EditorProvider.
17
+ useBlockEditorSettings,
12
18
  } );
@@ -548,6 +548,27 @@ export function updateEditorSettings( settings ) {
548
548
  };
549
549
  }
550
550
 
551
+ /**
552
+ * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
553
+ *
554
+ * - `all`: This is the default mode. It renders the post editor with all the features available. If a template is provided, it's preferred over the post.
555
+ * - `template-only`: This mode renders the editor with only the template blocks visible.
556
+ * - `post-only`: This mode extracts the post blocks from the template and renders only those. The idea is to allow the user to edit the post/page in isolation without the wrapping template.
557
+ * - `template-locked`: This mode renders both the template and the post blocks but the template blocks are locked and can't be edited. The post blocks are editable.
558
+ *
559
+ * @param {string} mode Mode (one of 'template-only', 'post-only', 'template-locked' or 'all').
560
+ */
561
+ export const setRenderingMode =
562
+ ( mode ) =>
563
+ ( { dispatch, registry } ) => {
564
+ registry.dispatch( blockEditorStore ).clearSelectedBlock();
565
+
566
+ dispatch( {
567
+ type: 'SET_RENDERING_MODE',
568
+ mode,
569
+ } );
570
+ };
571
+
551
572
  /**
552
573
  * Backward compatibility
553
574
  */
@@ -279,6 +279,15 @@ export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {
279
279
  return state;
280
280
  }
281
281
 
282
+ export function renderingMode( state = 'all', action ) {
283
+ switch ( action.type ) {
284
+ case 'SET_RENDERING_MODE':
285
+ return action.mode;
286
+ }
287
+
288
+ return state;
289
+ }
290
+
282
291
  export default combineReducers( {
283
292
  postId,
284
293
  postType,
@@ -290,4 +299,5 @@ export default combineReducers( {
290
299
  isReady,
291
300
  editorSettings,
292
301
  postAutosavingLock,
302
+ renderingMode,
293
303
  } );
@@ -1188,6 +1188,17 @@ export function getEditorSettings( state ) {
1188
1188
  return state.editorSettings;
1189
1189
  }
1190
1190
 
1191
+ /**
1192
+ * Returns the post editor's rendering mode.
1193
+ *
1194
+ * @param {Object} state Editor state.
1195
+ *
1196
+ * @return {string} Rendering mode.
1197
+ */
1198
+ export function getRenderingMode( state ) {
1199
+ return state.renderingMode;
1200
+ }
1201
+
1191
1202
  /*
1192
1203
  * Backward compatibility
1193
1204
  */
package/src/style.scss CHANGED
@@ -3,17 +3,21 @@
3
3
  @import "./components/editor-notices/style.scss";
4
4
  @import "./components/entities-saved-states/style.scss";
5
5
  @import "./components/error-boundary/style.scss";
6
+ @import "./components/post-author/style.scss";
6
7
  @import "./components/post-excerpt/style.scss";
7
8
  @import "./components/post-featured-image/style.scss";
8
9
  @import "./components/post-format/style.scss";
9
10
  @import "./components/post-last-revision/style.scss";
10
11
  @import "./components/post-locked-modal/style.scss";
12
+ @import "./components/post-panel-row/style.scss";
11
13
  @import "./components/post-publish-button/style.scss";
12
14
  @import "./components/post-publish-panel/style.scss";
13
15
  @import "./components/post-saved-state/style.scss";
16
+ @import "./components/post-schedule/style.scss";
14
17
  @import "./components/post-sync-status/style.scss";
15
18
  @import "./components/post-taxonomies/style.scss";
16
19
  @import "./components/post-text-editor/style.scss";
20
+ @import "./components/post-title/style.scss";
17
21
  @import "./components/post-url/style.scss";
18
22
  @import "./components/post-visibility/style.scss";
19
23
  @import "./components/post-trash/style.scss";