@wordpress/editor 14.36.0 → 14.36.1-next.6deb34194.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 (65) hide show
  1. package/README.md +2 -2
  2. package/build/components/autocompleters/user.js.map +2 -2
  3. package/build/components/collab-sidebar/comments.js +4 -12
  4. package/build/components/collab-sidebar/comments.js.map +2 -2
  5. package/build/components/collab-sidebar/hooks.js +7 -19
  6. package/build/components/collab-sidebar/hooks.js.map +2 -2
  7. package/build/components/document-bar/index.js +19 -8
  8. package/build/components/document-bar/index.js.map +3 -3
  9. package/build/components/document-bar/useEditedSectionDetails.js +95 -0
  10. package/build/components/document-bar/useEditedSectionDetails.js.map +7 -0
  11. package/build/components/page-attributes/parent.js +1 -0
  12. package/build/components/page-attributes/parent.js.map +2 -2
  13. package/build/components/post-card-panel/index.js +1 -1
  14. package/build/components/post-card-panel/index.js.map +2 -2
  15. package/build/dataviews/store/private-actions.js +9 -1
  16. package/build/dataviews/store/private-actions.js.map +2 -2
  17. package/build/utils/get-template-part-icon.js +9 -4
  18. package/build/utils/get-template-part-icon.js.map +3 -3
  19. package/build-module/components/autocompleters/user.js.map +2 -2
  20. package/build-module/components/collab-sidebar/comments.js +4 -12
  21. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  22. package/build-module/components/collab-sidebar/hooks.js +7 -20
  23. package/build-module/components/collab-sidebar/hooks.js.map +2 -2
  24. package/build-module/components/document-bar/index.js +20 -9
  25. package/build-module/components/document-bar/index.js.map +2 -2
  26. package/build-module/components/document-bar/useEditedSectionDetails.js +74 -0
  27. package/build-module/components/document-bar/useEditedSectionDetails.js.map +7 -0
  28. package/build-module/components/page-attributes/parent.js +1 -0
  29. package/build-module/components/page-attributes/parent.js.map +2 -2
  30. package/build-module/components/post-card-panel/index.js +1 -1
  31. package/build-module/components/post-card-panel/index.js.map +2 -2
  32. package/build-module/dataviews/store/private-actions.js +11 -2
  33. package/build-module/dataviews/store/private-actions.js.map +2 -2
  34. package/build-module/utils/get-template-part-icon.js +10 -4
  35. package/build-module/utils/get-template-part-icon.js.map +2 -2
  36. package/build-style/style-rtl.css +44 -126
  37. package/build-style/style.css +44 -126
  38. package/build-types/components/autocompleters/user.d.ts +8 -2
  39. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  40. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  41. package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
  42. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  43. package/build-types/components/document-bar/index.d.ts.map +1 -1
  44. package/build-types/components/document-bar/useEditedSectionDetails.d.ts +8 -0
  45. package/build-types/components/document-bar/useEditedSectionDetails.d.ts.map +1 -0
  46. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  47. package/build-types/components/post-template/hooks.d.ts +1 -1
  48. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  49. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  50. package/build-types/store/index.d.ts +1 -1
  51. package/build-types/store/index.d.ts.map +1 -1
  52. package/build-types/utils/get-template-part-icon.d.ts +3 -3
  53. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  54. package/package.json +40 -40
  55. package/src/components/autocompleters/user.js +6 -0
  56. package/src/components/collab-sidebar/comments.js +16 -23
  57. package/src/components/collab-sidebar/hooks.js +7 -24
  58. package/src/components/document-bar/index.js +41 -9
  59. package/src/components/document-bar/useEditedSectionDetails.js +103 -0
  60. package/src/components/global-styles-sidebar/style.scss +2 -2
  61. package/src/components/page-attributes/parent.js +2 -1
  62. package/src/components/post-card-panel/index.js +1 -1
  63. package/src/dataviews/store/private-actions.ts +16 -0
  64. package/src/utils/get-template-part-icon.js +19 -6
  65. package/tsconfig.tsbuildinfo +1 -1
@@ -70,28 +70,22 @@ export function Comments( {
70
70
  useDispatch( blockEditorStore )
71
71
  );
72
72
 
73
- const {
74
- blockCommentId,
75
- selectedBlockClientId,
76
- orderedBlockIds,
77
- blockMode,
78
- } = useSelect( ( select ) => {
79
- const {
80
- getBlockAttributes,
81
- getSelectedBlockClientId,
82
- getClientIdsWithDescendants,
83
- getBlockMode,
84
- } = select( blockEditorStore );
85
- const clientId = getSelectedBlockClientId();
86
- return {
87
- blockCommentId: clientId
88
- ? getBlockAttributes( clientId )?.metadata?.noteId
89
- : null,
90
- selectedBlockClientId: clientId,
91
- orderedBlockIds: getClientIdsWithDescendants(),
92
- blockMode: clientId ? getBlockMode( clientId ) : null,
93
- };
94
- }, [] );
73
+ const { blockCommentId, selectedBlockClientId, orderedBlockIds } =
74
+ useSelect( ( select ) => {
75
+ const {
76
+ getBlockAttributes,
77
+ getSelectedBlockClientId,
78
+ getClientIdsWithDescendants,
79
+ } = select( blockEditorStore );
80
+ const clientId = getSelectedBlockClientId();
81
+ return {
82
+ blockCommentId: clientId
83
+ ? getBlockAttributes( clientId )?.metadata?.noteId
84
+ : null,
85
+ selectedBlockClientId: clientId,
86
+ orderedBlockIds: getClientIdsWithDescendants(),
87
+ };
88
+ }, [] );
95
89
 
96
90
  const relatedBlockElement = useBlockElement( selectedBlockClientId );
97
91
 
@@ -318,7 +312,6 @@ export function Comments( {
318
312
  threads,
319
313
  selectedThread,
320
314
  setCanvasMinHeight,
321
- blockMode,
322
315
  ] );
323
316
 
324
317
  const handleThreadNavigation = ( event, thread, isSelected ) => {
@@ -14,7 +14,6 @@ import { __ } from '@wordpress/i18n';
14
14
  import {
15
15
  useEffect,
16
16
  useMemo,
17
- useRef,
18
17
  useCallback,
19
18
  useReducer,
20
19
  } from '@wordpress/element';
@@ -36,9 +35,7 @@ import { collabSidebarName } from './constants';
36
35
  import { unlock } from '../../lock-unlock';
37
36
  import { noop } from './utils';
38
37
 
39
- const { useBlockElementRef, cleanEmptyObject } = unlock(
40
- blockEditorPrivateApis
41
- );
38
+ const { useBlockElement, cleanEmptyObject } = unlock( blockEditorPrivateApis );
42
39
 
43
40
  export function useBlockComments( postId ) {
44
41
  const [ commentLastUpdated, reflowComments ] = useReducer(
@@ -369,20 +366,7 @@ export function useFloatingThread( {
369
366
  setBlockRef,
370
367
  commentLastUpdated,
371
368
  } ) {
372
- const blockRef = useRef();
373
- useBlockElementRef( thread.blockClientId, blockRef );
374
-
375
- const blockMode = useSelect(
376
- ( select ) => {
377
- return thread.blockClientId
378
- ? select( blockEditorStore ).getBlockMode(
379
- thread.blockClientId
380
- )
381
- : null;
382
- },
383
- [ thread.blockClientId ]
384
- );
385
-
369
+ const blockElement = useBlockElement( thread.blockClientId );
386
370
  const updateHeight = useCallback(
387
371
  ( id, newHeight ) => {
388
372
  setHeights( ( prev ) => {
@@ -408,17 +392,17 @@ export function useFloatingThread( {
408
392
 
409
393
  // Store the block reference for each thread.
410
394
  useEffect( () => {
411
- if ( blockRef.current ) {
412
- refs.setReference( blockRef.current );
395
+ if ( blockElement ) {
396
+ refs.setReference( blockElement );
413
397
  }
414
- }, [ blockRef, refs, commentLastUpdated, blockMode ] );
398
+ }, [ blockElement, refs, commentLastUpdated ] );
415
399
 
416
400
  // Track thread heights.
417
401
  useEffect( () => {
418
402
  if ( refs.floating?.current ) {
419
- setBlockRef( thread.id, blockRef.current );
403
+ setBlockRef( thread.id, blockElement );
420
404
  }
421
- }, [ thread.id, refs.floating, setBlockRef ] );
405
+ }, [ blockElement, thread.id, refs.floating, setBlockRef ] );
422
406
 
423
407
  // When the selected thread changes, update heights, triggering offset recalculation.
424
408
  useEffect( () => {
@@ -435,7 +419,6 @@ export function useFloatingThread( {
435
419
  ] );
436
420
 
437
421
  return {
438
- blockRef,
439
422
  y,
440
423
  refs,
441
424
  };
@@ -14,7 +14,7 @@ import {
14
14
  __unstableMotion as motion,
15
15
  __unstableAnimatePresence as AnimatePresence,
16
16
  } from '@wordpress/components';
17
- import { BlockIcon } from '@wordpress/block-editor';
17
+ import { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';
18
18
  import { chevronLeftSmall, chevronRightSmall, layout } from '@wordpress/icons';
19
19
  import { displayShortcut } from '@wordpress/keycodes';
20
20
  import { store as coreStore } from '@wordpress/core-data';
@@ -33,6 +33,7 @@ import usePageTypeBadge from '../../utils/pageTypeBadge';
33
33
  import { getTemplateInfo } from '../../utils/get-template-info';
34
34
  import { getStylesCanvasTitle } from '../styles-canvas';
35
35
  import { unlock } from '../../lock-unlock';
36
+ import useEditedSectionDetails from './useEditedSectionDetails';
36
37
 
37
38
  /** @typedef {import("@wordpress/components").IconType} IconType */
38
39
 
@@ -56,6 +57,14 @@ const MotionButton = motion.create( Button );
56
57
  * @return {React.ReactNode} The rendered DocumentBar component.
57
58
  */
58
59
  export default function DocumentBar( props ) {
60
+ // Get action to lock the pattern design
61
+ const { stopEditingContentOnlySection } = unlock(
62
+ useDispatch( blockEditorStore )
63
+ );
64
+
65
+ // Get details about the currently edited content-only section
66
+ const unlockedPatternInfo = useEditedSectionDetails();
67
+
59
68
  const {
60
69
  postId,
61
70
  postType,
@@ -133,11 +142,28 @@ export default function DocumentBar( props ) {
133
142
  const isReducedMotion = useReducedMotion();
134
143
 
135
144
  const isTemplate = TEMPLATE_POST_TYPES.includes( postType );
136
- const hasBackButton = !! onNavigateToPreviousEntityRecord;
145
+ const hasBackButton =
146
+ !! onNavigateToPreviousEntityRecord || !! unlockedPatternInfo;
137
147
  const entityTitle = isTemplate ? templateTitle : documentTitle;
138
- const title = props.title || stylesCanvasTitle || entityTitle;
148
+
149
+ // Use pattern info if a pattern block is unlocked, otherwise use document/entity info
150
+ const title =
151
+ unlockedPatternInfo?.patternTitle ||
152
+ props.title ||
153
+ stylesCanvasTitle ||
154
+ entityTitle;
139
155
  const icon = props.icon;
140
156
 
157
+ // Determine the back button action
158
+ const handleBackClick = ( event ) => {
159
+ event.stopPropagation();
160
+ if ( unlockedPatternInfo ) {
161
+ stopEditingContentOnlySection();
162
+ } else if ( onNavigateToPreviousEntityRecord ) {
163
+ onNavigateToPreviousEntityRecord();
164
+ }
165
+ };
166
+
141
167
  const pageTypeBadge = usePageTypeBadge( postId );
142
168
 
143
169
  const mountedRef = useRef( false );
@@ -156,10 +182,7 @@ export default function DocumentBar( props ) {
156
182
  <MotionButton
157
183
  className="editor-document-bar__back"
158
184
  icon={ isRTL() ? chevronRightSmall : chevronLeftSmall }
159
- onClick={ ( event ) => {
160
- event.stopPropagation();
161
- onNavigateToPreviousEntityRecord();
162
- } }
185
+ onClick={ handleBackClick }
163
186
  size="compact"
164
187
  initial={
165
188
  mountedRef.current
@@ -219,12 +242,21 @@ export default function DocumentBar( props ) {
219
242
  ? stripHTML( title )
220
243
  : __( 'No title' ) }
221
244
  </span>
222
- { pageTypeBadge && (
245
+ { unlockedPatternInfo && (
246
+ <span className="editor-document-bar__post-type-label">
247
+ { unlockedPatternInfo.type ===
248
+ 'template-part'
249
+ ? `· ${ __( 'Template Part' ) }`
250
+ : `· ${ __( 'Pattern' ) }` }
251
+ </span>
252
+ ) }
253
+ { ! unlockedPatternInfo && pageTypeBadge && (
223
254
  <span className="editor-document-bar__post-type-label">
224
255
  { `· ${ pageTypeBadge }` }
225
256
  </span>
226
257
  ) }
227
- { postTypeLabel &&
258
+ { ! unlockedPatternInfo &&
259
+ postTypeLabel &&
228
260
  ! props.title &&
229
261
  ! pageTypeBadge && (
230
262
  <span className="editor-document-bar__post-type-label">
@@ -0,0 +1,103 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { decodeEntities } from '@wordpress/html-entities';
6
+ import { store as blockEditorStore } from '@wordpress/block-editor';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { unlock } from '../../lock-unlock';
13
+
14
+ /**
15
+ * Hook to get details about the currently edited content-only section.
16
+ * Only returns information when the content only pattern insertion experiment is enabled.
17
+ *
18
+ * @return {Object|null} Object with patternName, patternTitle, and type, or null if no section is being edited or experiment is disabled.
19
+ */
20
+ export default function useEditedSectionDetails() {
21
+ return useSelect( ( select ) => {
22
+ // Only run when the content only pattern insertion experiment is enabled
23
+ if ( ! window?.__experimentalContentOnlyPatternInsertion ) {
24
+ return null;
25
+ }
26
+
27
+ const {
28
+ getBlockAttributes,
29
+ getBlockName,
30
+ __experimentalGetParsedPattern,
31
+ } = select( blockEditorStore );
32
+ const { getEditedEntityRecord, getCurrentTheme } = select( coreStore );
33
+ const { getEditedContentOnlySection } = unlock(
34
+ select( blockEditorStore )
35
+ );
36
+
37
+ // Get the clientId of the unlocked pattern/section
38
+ const editedSectionId = getEditedContentOnlySection();
39
+ if ( ! editedSectionId ) {
40
+ return null;
41
+ }
42
+
43
+ const attributes = getBlockAttributes( editedSectionId );
44
+
45
+ // Handle unsynced patterns (contentOnly patterns with patternName)
46
+ const patternName = attributes?.metadata?.patternName;
47
+ if ( patternName ) {
48
+ // Get pattern details if available
49
+ const pattern =
50
+ typeof __experimentalGetParsedPattern === 'function'
51
+ ? __experimentalGetParsedPattern( patternName )
52
+ : null;
53
+
54
+ return {
55
+ patternName,
56
+ patternTitle: pattern?.title || attributes?.metadata?.name,
57
+ type: 'pattern',
58
+ };
59
+ }
60
+
61
+ const blockName = getBlockName( editedSectionId );
62
+
63
+ // Handle synced patterns (core/block)
64
+ if ( blockName === 'core/block' && !! attributes?.ref ) {
65
+ const entity = getEditedEntityRecord(
66
+ 'postType',
67
+ 'wp_block',
68
+ attributes.ref
69
+ );
70
+ if ( entity?.title ) {
71
+ return {
72
+ patternName: attributes.ref,
73
+ patternTitle: decodeEntities( entity.title ),
74
+ type: 'synced-pattern',
75
+ };
76
+ }
77
+ }
78
+
79
+ // Handle template parts (core/template-part)
80
+ if ( blockName === 'core/template-part' && !! attributes?.slug ) {
81
+ const theme = attributes.theme || getCurrentTheme()?.stylesheet;
82
+ const templatePartId = theme
83
+ ? `${ theme }//${ attributes.slug }`
84
+ : null;
85
+ if ( templatePartId ) {
86
+ const entity = getEditedEntityRecord(
87
+ 'postType',
88
+ 'wp_template_part',
89
+ templatePartId
90
+ );
91
+ if ( entity?.title ) {
92
+ return {
93
+ patternName: attributes.slug,
94
+ patternTitle: decodeEntities( entity.title ),
95
+ type: 'template-part',
96
+ };
97
+ }
98
+ }
99
+ }
100
+
101
+ return null;
102
+ }, [] );
103
+ }
@@ -10,8 +10,8 @@
10
10
  flex: 1;
11
11
  }
12
12
 
13
- .components-navigator-screen {
14
- padding: 0;
13
+ .global-styles-ui-sidebar__navigator-screen.components-navigator-screen {
14
+ padding: $grid-unit-15;
15
15
  }
16
16
  }
17
17
 
@@ -91,9 +91,10 @@ export function PageAttributesParent() {
91
91
  _fields: 'id,title,parent',
92
92
  };
93
93
 
94
- // Perform a search when the field is changed.
94
+ // Perform a search by relevance when the field is changed.
95
95
  if ( !! fieldValue ) {
96
96
  query.search = fieldValue;
97
+ query.orderby = 'relevance';
97
98
  }
98
99
 
99
100
  const parentPost = pageId
@@ -102,7 +102,7 @@ export default function PostCardPanel( {
102
102
  <HStack
103
103
  spacing={ 2 }
104
104
  className="editor-post-card-panel__header"
105
- align="flex-start"
105
+ alignment="flex-start"
106
106
  >
107
107
  <Icon className="editor-post-card-panel__icon" icon={ icon } />
108
108
  <Text
@@ -34,6 +34,7 @@ import {
34
34
  templateTitleField,
35
35
  pageTitleField,
36
36
  patternTitleField,
37
+ notesField,
37
38
  } from '@wordpress/fields';
38
39
 
39
40
  /**
@@ -50,6 +51,20 @@ declare global {
50
51
  }
51
52
  }
52
53
 
54
+ /**
55
+ * Check if a post type supports editor notes.
56
+ *
57
+ * @param supports The post type supports object.
58
+ * @return Whether editor notes are supported.
59
+ */
60
+ function hasEditorNotesSupport( supports?: PostType[ 'supports' ] ): boolean {
61
+ const editor = supports?.editor;
62
+ if ( Array.isArray( editor ) ) {
63
+ return !! editor[ 0 ]?.notes;
64
+ }
65
+ return false;
66
+ }
67
+
53
68
  export function registerEntityAction< Item >(
54
69
  kind: string,
55
70
  name: string,
@@ -210,6 +225,7 @@ export const registerPostTypeSchema =
210
225
  postTypeConfig.supports?.editor &&
211
226
  postTypeConfig.viewable &&
212
227
  postPreviewField,
228
+ hasEditorNotesSupport( postTypeConfig.supports ) && notesField,
213
229
  ].filter( Boolean );
214
230
  if ( postTypeConfig.supports?.title ) {
215
231
  let _titleField;
@@ -5,22 +5,35 @@ import {
5
5
  header as headerIcon,
6
6
  footer as footerIcon,
7
7
  sidebar as sidebarIcon,
8
+ tableColumnAfter as overlayIcon,
8
9
  symbolFilled as symbolFilledIcon,
9
10
  } from '@wordpress/icons';
11
+
10
12
  /**
11
- * Helper function to retrieve the corresponding icon by name.
13
+ * Helper function to retrieve the corresponding icon by area name or icon name.
12
14
  *
13
- * @param {string} iconName The name of the icon.
15
+ * @param {string} areaOrIconName The area name (e.g., 'header', 'overlay') or icon name (e.g., 'menu').
14
16
  *
15
17
  * @return {Object} The corresponding icon.
16
18
  */
17
- export function getTemplatePartIcon( iconName ) {
18
- if ( 'header' === iconName ) {
19
+ export function getTemplatePartIcon( areaOrIconName ) {
20
+ // Handle area names first
21
+ if ( 'header' === areaOrIconName ) {
19
22
  return headerIcon;
20
- } else if ( 'footer' === iconName ) {
23
+ } else if ( 'footer' === areaOrIconName ) {
21
24
  return footerIcon;
22
- } else if ( 'sidebar' === iconName ) {
25
+ } else if ( 'sidebar' === areaOrIconName ) {
23
26
  return sidebarIcon;
27
+ } else if ( 'overlay' === areaOrIconName ) {
28
+ // TODO: Replace with a proper overlay icon when available.
29
+ // Using tableColumnAfter as a placeholder.
30
+ return overlayIcon;
31
+ }
32
+ // Handle icon names for backwards compatibility
33
+ if ( 'menu' === areaOrIconName ) {
34
+ // TODO: Replace with a proper overlay icon when available.
35
+ // Using tableColumnAfter as a placeholder.
36
+ return overlayIcon;
24
37
  }
25
38
  return symbolFilledIcon;
26
39
  }