@wordpress/editor 14.48.2-next.v.202606191442.0 → 14.49.1

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 (94) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +5 -13
  3. package/build/components/autosave-monitor/index.cjs +40 -83
  4. package/build/components/autosave-monitor/index.cjs.map +3 -3
  5. package/build/components/post-publish-panel/postpublish.cjs +0 -1
  6. package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
  7. package/build/components/post-status/index.cjs +0 -1
  8. package/build/components/post-status/index.cjs.map +2 -2
  9. package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -1
  10. package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
  11. package/build/components/post-template/create-new-template-modal.cjs +0 -1
  12. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  13. package/build/components/post-text-editor/utils.cjs +2 -2
  14. package/build/components/post-text-editor/utils.cjs.map +1 -1
  15. package/build/components/post-visibility/index.cjs +0 -1
  16. package/build/components/post-visibility/index.cjs.map +2 -2
  17. package/build/components/provider/disable-non-page-content-blocks.cjs +23 -3
  18. package/build/components/provider/disable-non-page-content-blocks.cjs.map +2 -2
  19. package/build/components/provider/navigation-block-editing-mode.cjs +9 -2
  20. package/build/components/provider/navigation-block-editing-mode.cjs.map +2 -2
  21. package/build/components/provider/use-block-editor-settings.cjs +2 -1
  22. package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
  23. package/build/components/sidebar/dataform-post-summary.cjs +87 -32
  24. package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
  25. package/build/components/sidebar/post-summary.cjs +8 -6
  26. package/build/components/sidebar/post-summary.cjs.map +3 -3
  27. package/build/dataviews/store/private-actions.cjs +3 -1
  28. package/build/dataviews/store/private-actions.cjs.map +2 -2
  29. package/build/store/private-actions.cjs +2 -2
  30. package/build/store/private-actions.cjs.map +2 -2
  31. package/build-module/components/autosave-monitor/index.mjs +42 -81
  32. package/build-module/components/autosave-monitor/index.mjs.map +2 -2
  33. package/build-module/components/post-publish-panel/postpublish.mjs +0 -1
  34. package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
  35. package/build-module/components/post-status/index.mjs +0 -1
  36. package/build-module/components/post-status/index.mjs.map +2 -2
  37. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -1
  38. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
  39. package/build-module/components/post-template/create-new-template-modal.mjs +0 -1
  40. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  41. package/build-module/components/post-text-editor/utils.mjs +2 -2
  42. package/build-module/components/post-text-editor/utils.mjs.map +1 -1
  43. package/build-module/components/post-visibility/index.mjs +0 -1
  44. package/build-module/components/post-visibility/index.mjs.map +2 -2
  45. package/build-module/components/provider/disable-non-page-content-blocks.mjs +23 -3
  46. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
  47. package/build-module/components/provider/navigation-block-editing-mode.mjs +10 -3
  48. package/build-module/components/provider/navigation-block-editing-mode.mjs.map +2 -2
  49. package/build-module/components/provider/use-block-editor-settings.mjs +2 -1
  50. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  51. package/build-module/components/sidebar/dataform-post-summary.mjs +88 -33
  52. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  53. package/build-module/components/sidebar/post-summary.mjs +8 -6
  54. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  55. package/build-module/dataviews/store/private-actions.mjs +5 -1
  56. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  57. package/build-module/store/private-actions.mjs +2 -2
  58. package/build-module/store/private-actions.mjs.map +2 -2
  59. package/build-style/style-rtl.css +29 -33
  60. package/build-style/style.css +29 -33
  61. package/build-types/components/autosave-monitor/index.d.ts +11 -29
  62. package/build-types/components/autosave-monitor/index.d.ts.map +1 -1
  63. package/build-types/components/post-publish-panel/postpublish.d.ts.map +1 -1
  64. package/build-types/components/post-status/index.d.ts.map +1 -1
  65. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  66. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  67. package/build-types/components/post-visibility/index.d.ts.map +1 -1
  68. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  69. package/build-types/components/provider/navigation-block-editing-mode.d.ts.map +1 -1
  70. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  71. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  72. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  73. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  74. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  75. package/package.json +46 -46
  76. package/src/components/autosave-monitor/index.js +69 -104
  77. package/src/components/autosave-monitor/test/index.js +137 -122
  78. package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -0
  79. package/src/components/post-publish-panel/postpublish.js +0 -1
  80. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +7 -2
  81. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +1 -0
  82. package/src/components/post-status/index.js +0 -1
  83. package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -1
  84. package/src/components/post-template/create-new-template-modal.js +0 -1
  85. package/src/components/post-text-editor/utils.js +2 -2
  86. package/src/components/post-visibility/index.js +0 -1
  87. package/src/components/provider/disable-non-page-content-blocks.js +23 -6
  88. package/src/components/provider/navigation-block-editing-mode.js +10 -4
  89. package/src/components/provider/use-block-editor-settings.js +3 -1
  90. package/src/components/sidebar/dataform-post-summary.js +133 -49
  91. package/src/components/sidebar/post-summary.js +12 -10
  92. package/src/dataviews/store/private-actions.ts +8 -1
  93. package/src/store/private-actions.js +2 -2
  94. package/src/store/test/actions.js +2 -2
@@ -2,10 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { useDispatch, useSelect } from '@wordpress/data';
5
+ import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
6
6
  import { store as coreDataStore } from '@wordpress/core-data';
7
7
  import { DataForm } from '@wordpress/dataviews';
8
- import { __experimentalVStack as VStack } from '@wordpress/components';
8
+ import { Stack } from '@wordpress/ui';
9
9
  import { useMemo } from '@wordpress/element';
10
10
  import { useViewConfig } from '@wordpress/views';
11
11
 
@@ -21,6 +21,91 @@ import { usePostTemplatePanelMode } from '../post-template/hooks';
21
21
  import revisionsField from '../../dataviews/fields/revisions';
22
22
 
23
23
  const EMPTY_FORM = { layout: { type: 'panel' }, fields: [] };
24
+ const VIEW_CONFIG_FIELDS = [ 'form' ];
25
+
26
+ /**
27
+ * Bridges the legacy editor-panel visibility controls onto the DataForm summary,
28
+ * returning the form with the hidden fields removed. The new inspector has no
29
+ * concept of the Preferences → Panels switches or of `removeEditorPanel`, so we
30
+ * reproduce their effect on the form.
31
+ *
32
+ * @param {Object} form The DataForm summary form configuration.
33
+ * @return {Object} The form with the hidden fields removed.
34
+ */
35
+ function useInspectorPanelVisibility( form ) {
36
+ const {
37
+ isPostStatusRemoved,
38
+ featuredImageEnabled,
39
+ excerptEnabled,
40
+ discussionEnabled,
41
+ pageAttributesEnabled,
42
+ } = useSelect( ( select ) => {
43
+ const { isEditorPanelRemoved, isEditorPanelEnabled } =
44
+ select( editorStore );
45
+ return {
46
+ isPostStatusRemoved: isEditorPanelRemoved( 'post-status' ),
47
+ featuredImageEnabled: isEditorPanelEnabled( 'featured-image' ),
48
+ excerptEnabled: isEditorPanelEnabled( 'post-excerpt' ),
49
+ discussionEnabled: isEditorPanelEnabled( 'discussion-panel' ),
50
+ pageAttributesEnabled: isEditorPanelEnabled( 'page-attributes' ),
51
+ };
52
+ }, [] );
53
+
54
+ const visibleForm = useMemo( () => {
55
+ if ( ! form.fields?.length ) {
56
+ return form;
57
+ }
58
+ // `featured_media`/`excerpt` are their own top-level panels and
59
+ // `post-content-info` is always shown, so they survive. Everything else
60
+ // belongs to the `post-status` summary panel: `discussion`/`parent` honor
61
+ // their own switch, but every one of them is hidden while the `post-status`
62
+ // panel is removed.
63
+ const visibilityById = {
64
+ featured_media: featuredImageEnabled,
65
+ excerpt: excerptEnabled,
66
+ 'post-content-info': true,
67
+ discussion: discussionEnabled && ! isPostStatusRemoved,
68
+ parent: pageAttributesEnabled && ! isPostStatusRemoved,
69
+ };
70
+ const isFieldVisible = ( id ) =>
71
+ id in visibilityById ? visibilityById[ id ] : ! isPostStatusRemoved;
72
+ // Recurse into `children` so a panel-tied field is dropped wherever it
73
+ // sits in the form: the PHP view-config filter can nest such a field
74
+ // inside another field's group.
75
+ const filterFields = ( fields ) =>
76
+ fields.reduce( ( acc, field ) => {
77
+ const id = typeof field === 'string' ? field : field.id;
78
+ if ( ! isFieldVisible( id ) ) {
79
+ return acc;
80
+ }
81
+ if (
82
+ typeof field !== 'string' &&
83
+ Array.isArray( field.children )
84
+ ) {
85
+ const children = filterFields( field.children );
86
+ // A group whose children were all removed would render as
87
+ // an empty panel, so drop it too.
88
+ if ( ! children.length ) {
89
+ return acc;
90
+ }
91
+ acc.push( { ...field, children } );
92
+ return acc;
93
+ }
94
+ acc.push( field );
95
+ return acc;
96
+ }, [] );
97
+ return { ...form, fields: filterFields( form.fields ) };
98
+ }, [
99
+ form,
100
+ isPostStatusRemoved,
101
+ featuredImageEnabled,
102
+ excerptEnabled,
103
+ discussionEnabled,
104
+ pageAttributesEnabled,
105
+ ] );
106
+
107
+ return visibleForm;
108
+ }
24
109
 
25
110
  // Some post types expose summary fields that edit entities other than the one
26
111
  // being edited. Keyed by the post type that needs them, the related records are
@@ -89,18 +174,34 @@ function bindFieldToNamespace( field, namespace, isVisible = () => true ) {
89
174
  }
90
175
 
91
176
  export default function DataFormPostSummary( { onActionPerformed } ) {
92
- const { postType, postId } = useSelect( ( select ) => {
93
- const { getCurrentPostType, getCurrentPostId } = select( editorStore );
94
- return {
95
- postType: getCurrentPostType(),
96
- postId: getCurrentPostId(),
97
- };
98
- }, [] );
177
+ const { postType, postId, isPostStatusRemoved, availableTemplates } =
178
+ useSelect( ( select ) => {
179
+ const {
180
+ getCurrentPostType,
181
+ getCurrentPostId,
182
+ isEditorPanelRemoved,
183
+ getEditorSettings,
184
+ } = select( editorStore );
185
+ const _availableTemplates = select(
186
+ coreDataStore
187
+ ).getCurrentTheme()?.is_block_theme
188
+ ? null
189
+ : getEditorSettings().availableTemplates ?? null;
190
+ return {
191
+ postType: getCurrentPostType(),
192
+ postId: getCurrentPostId(),
193
+ isPostStatusRemoved: isEditorPanelRemoved( 'post-status' ),
194
+ availableTemplates: _availableTemplates,
195
+ };
196
+ }, [] );
99
197
  const { form: formConfig } = useViewConfig( {
100
198
  kind: 'postType',
101
199
  name: postType,
200
+ fields: VIEW_CONFIG_FIELDS,
102
201
  } );
103
- const form = formConfig ?? EMPTY_FORM;
202
+ // Bridge the legacy editor-panel visibility (Preferences → Panels and
203
+ // programmatic panel removal) onto the form by dropping hidden fields.
204
+ const form = useInspectorPanelVisibility( formConfig ?? EMPTY_FORM );
104
205
  const record = useSelect(
105
206
  ( select ) => {
106
207
  if ( ! postType || ! postId ) {
@@ -117,27 +218,14 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
117
218
 
118
219
  const templatePanelMode = usePostTemplatePanelMode();
119
220
 
120
- // Assemble every piece of supplementary data merged into the form `data`
121
- // alongside the post record: read-only editor data that the post's own
122
- // fields consume (e.g. the `template` field's `available_templates` in
123
- // classic themes), and the records of other entities targeted by namespaced
124
- // fields (keyed by `${ kind }_${ name }`) together with the id used to
125
- // persist edits back to each one.
126
- const { entityData, entityIds, availableTemplates } = useSelect(
221
+ const entityRecords = useSelect(
127
222
  ( select ) => {
128
- const { getEditedEntityRecord, canUser, getCurrentTheme } =
129
- select( coreDataStore );
130
-
131
- const _availableTemplates = getCurrentTheme()?.is_block_theme
132
- ? null
133
- : select( editorStore ).getEditorSettings()
134
- .availableTemplates ?? {};
223
+ const { getEditedEntityRecord, canUser } = select( coreDataStore );
135
224
 
136
- const extra = {};
137
- const ids = {};
225
+ const records = {};
138
226
 
139
227
  // Other entities the current post type needs merged into its form.
140
- for ( const [ key, entity ] of Object.entries(
228
+ for ( const [ namespace, entity ] of Object.entries(
141
229
  ENTITIES[ postType ] ?? {}
142
230
  ) ) {
143
231
  if (
@@ -153,39 +241,32 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
153
241
  if ( entity.getId && ! id ) {
154
242
  continue;
155
243
  }
156
- extra[ key ] = getEditedEntityRecord(
244
+ records[ namespace ] = getEditedEntityRecord(
157
245
  entity.kind,
158
246
  entity.name,
159
247
  id
160
248
  );
161
- ids[ key ] = id;
162
249
  }
163
250
 
164
- return {
165
- entityData: extra,
166
- entityIds: ids,
167
- availableTemplates: _availableTemplates,
168
- };
251
+ return records;
169
252
  },
170
253
  [ postType ]
171
254
  );
172
255
 
173
- // Merge the supplementary data onto the record only when there is any.
256
+ // Merge the supplementary data onto the record.
174
257
  const data = useMemo( () => {
175
258
  if ( ! record ) {
176
259
  return record;
177
260
  }
178
- const extra = { ...entityData };
261
+ const extra = { ...entityRecords };
179
262
  if ( availableTemplates && Object.keys( availableTemplates ).length ) {
180
263
  extra.available_templates = availableTemplates;
181
264
  }
182
- if ( ! Object.keys( extra ).length ) {
183
- return record;
184
- }
185
265
  return { ...record, ...extra };
186
- }, [ record, entityData, availableTemplates ] );
266
+ }, [ record, entityRecords, availableTemplates ] );
187
267
 
188
268
  const { editEntityRecord } = useDispatch( coreDataStore );
269
+ const registry = useRegistry();
189
270
 
190
271
  // Map of namespaced field id to the namespace key its entity is merged under.
191
272
  const fieldNamespaces = useMemo( () => {
@@ -264,12 +345,13 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
264
345
  for ( const [ key, value ] of Object.entries( edits ) ) {
265
346
  const entity = entities[ key ];
266
347
  if ( entity ) {
267
- editEntityRecord(
268
- entity.kind,
269
- entity.name,
270
- entityIds[ key ],
271
- value
272
- );
348
+ // Resolve the id the same way it was resolved to read the
349
+ // record, so the save targets the right entity regardless of
350
+ // its key field (`undefined` for the `root/site` singleton).
351
+ const id = entity.getId
352
+ ? entity.getId( registry.select )
353
+ : undefined;
354
+ editEntityRecord( entity.kind, entity.name, id, value );
273
355
  } else {
274
356
  baseEdits[ key ] = value;
275
357
  }
@@ -299,7 +381,7 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
299
381
  };
300
382
  return (
301
383
  <PostPanelSection className="editor-post-summary">
302
- <VStack spacing={ 4 }>
384
+ <Stack direction="column" gap="lg">
303
385
  <PostCardPanel
304
386
  postType={ postType }
305
387
  postId={ postId }
@@ -311,8 +393,10 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
311
393
  form={ form }
312
394
  onChange={ onChange }
313
395
  />
314
- <PostTrash onActionPerformed={ onActionPerformed } />
315
- </VStack>
396
+ { ! isPostStatusRemoved && (
397
+ <PostTrash onActionPerformed={ onActionPerformed } />
398
+ ) }
399
+ </Stack>
316
400
  </PostPanelSection>
317
401
  );
318
402
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __experimentalVStack as VStack } from '@wordpress/components';
4
+ import { Stack } from '@wordpress/ui';
5
5
  import { useSelect } from '@wordpress/data';
6
6
 
7
7
  /**
@@ -43,7 +43,9 @@ export default function PostSummary( { onActionPerformed } ) {
43
43
  );
44
44
  if (
45
45
  window?.__experimentalDataFormInspector &&
46
- [ 'page', 'post', 'wp_template' ].includes( postType )
46
+ [ 'page', 'post', 'wp_template', 'wp_template_part' ].includes(
47
+ postType
48
+ )
47
49
  ) {
48
50
  return <DataFormPostSummary onActionPerformed={ onActionPerformed } />;
49
51
  }
@@ -73,7 +75,7 @@ function ClassicPostSummary( { onActionPerformed } ) {
73
75
  <PluginPostStatusInfo.Slot>
74
76
  { ( fills ) => (
75
77
  <>
76
- <VStack spacing={ 4 }>
78
+ <Stack direction="column" gap="lg">
77
79
  <PostCardPanel
78
80
  postType={ postType }
79
81
  postId={ postId }
@@ -81,13 +83,13 @@ function ClassicPostSummary( { onActionPerformed } ) {
81
83
  />
82
84
  <PostFeaturedImagePanel withPanelBody={ false } />
83
85
  <PostExcerptPanel />
84
- <VStack spacing={ 1 }>
86
+ <Stack direction="column" gap="xs">
85
87
  <PostContentInformation />
86
88
  <PostLastEditedPanel />
87
- </VStack>
89
+ </Stack>
88
90
  { ! isRemovedPostStatusPanel && (
89
- <VStack spacing={ 4 }>
90
- <VStack spacing={ 1 }>
91
+ <Stack direction="column" gap="lg">
92
+ <Stack direction="column" gap="xs">
91
93
  <PostStatusPanel />
92
94
  <PostSchedulePanel />
93
95
  <PostURLPanel />
@@ -102,13 +104,13 @@ function ClassicPostSummary( { onActionPerformed } ) {
102
104
  <SiteDiscussion />
103
105
  <PostFormatPanel />
104
106
  { fills }
105
- </VStack>
107
+ </Stack>
106
108
  <PostTrash
107
109
  onActionPerformed={ onActionPerformed }
108
110
  />
109
- </VStack>
111
+ </Stack>
110
112
  ) }
111
- </VStack>
113
+ </Stack>
112
114
  </>
113
115
  ) }
114
116
  </PluginPostStatusInfo.Slot>
@@ -30,6 +30,8 @@ import {
30
30
  slugField,
31
31
  statusField,
32
32
  authorField,
33
+ templateAuthorField,
34
+ templatePartAuthorField,
33
35
  titleField,
34
36
  templateField,
35
37
  templateTitleField,
@@ -267,7 +269,12 @@ export const registerPostTypeSchema =
267
269
  postTypeConfig.supports?.thumbnail &&
268
270
  currentTheme?.theme_supports?.[ 'post-thumbnails' ] &&
269
271
  featuredImageField,
270
- postTypeConfig.supports?.author && authorField,
272
+ ! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
273
+ postTypeConfig.supports?.author &&
274
+ authorField,
275
+ postTypeConfig.slug === 'wp_template' && templateAuthorField,
276
+ postTypeConfig.slug === 'wp_template_part' &&
277
+ templatePartAuthorField,
271
278
  ! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
272
279
  statusField,
273
280
  ! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
@@ -21,8 +21,8 @@ import { unlock } from '../lock-unlock';
21
21
  export * from '../dataviews/store/private-actions';
22
22
 
23
23
  const DEVICE_TYPE_BY_VIEWPORT_STATE = {
24
- mobile: 'Mobile',
25
- tablet: 'Tablet',
24
+ '@mobile': 'Mobile',
25
+ '@tablet': 'Tablet',
26
26
  };
27
27
 
28
28
  /**
@@ -71,7 +71,7 @@ describe( 'Post actions', () => {
71
71
  unlock(
72
72
  registry.dispatch( editorStore )
73
73
  ).updateDeviceTypeForViewportState( {
74
- viewport: 'mobile',
74
+ viewport: '@mobile',
75
75
  showStateOnCanvas: true,
76
76
  } );
77
77
 
@@ -87,7 +87,7 @@ describe( 'Post actions', () => {
87
87
  unlock(
88
88
  registry.dispatch( editorStore )
89
89
  ).updateDeviceTypeForViewportState( {
90
- viewport: 'mobile',
90
+ viewport: '@mobile',
91
91
  showStateOnCanvas: false,
92
92
  } );
93
93