@wordpress/editor 14.8.12 → 14.8.14

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 (89) hide show
  1. package/build/components/editor-interface/index.js +2 -1
  2. package/build/components/editor-interface/index.js.map +1 -1
  3. package/build/components/page-attributes/parent.js +5 -5
  4. package/build/components/page-attributes/parent.js.map +1 -1
  5. package/build/components/post-author/panel.js +4 -4
  6. package/build/components/post-author/panel.js.map +1 -1
  7. package/build/components/post-content-information/index.js +1 -2
  8. package/build/components/post-content-information/index.js.map +1 -1
  9. package/build/components/post-last-revision/index.js +1 -1
  10. package/build/components/post-last-revision/index.js.map +1 -1
  11. package/build/components/post-schedule/label.js +1 -1
  12. package/build/components/post-schedule/label.js.map +1 -1
  13. package/build/components/post-taxonomies/flat-term-selector.js +11 -1
  14. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  15. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  16. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  17. package/build/components/post-url/panel.js +3 -3
  18. package/build/components/post-url/panel.js.map +1 -1
  19. package/build/components/preferences-modal/index.js +26 -22
  20. package/build/components/preferences-modal/index.js.map +1 -1
  21. package/build/components/sidebar/header.js +2 -1
  22. package/build/components/sidebar/header.js.map +1 -1
  23. package/build/components/sidebar/index.js +3 -3
  24. package/build/components/sidebar/index.js.map +1 -1
  25. package/build/components/time-to-read/index.js +2 -2
  26. package/build/components/time-to-read/index.js.map +1 -1
  27. package/build/dataviews/actions/delete-post.js +2 -2
  28. package/build/dataviews/actions/delete-post.js.map +1 -1
  29. package/build/dataviews/actions/duplicate-template-part.js +2 -2
  30. package/build/dataviews/actions/duplicate-template-part.js.map +1 -1
  31. package/build/store/private-actions.js +2 -2
  32. package/build/store/private-actions.js.map +1 -1
  33. package/build-module/components/editor-interface/index.js +2 -1
  34. package/build-module/components/editor-interface/index.js.map +1 -1
  35. package/build-module/components/page-attributes/parent.js +5 -5
  36. package/build-module/components/page-attributes/parent.js.map +1 -1
  37. package/build-module/components/post-author/panel.js +4 -4
  38. package/build-module/components/post-author/panel.js.map +1 -1
  39. package/build-module/components/post-content-information/index.js +1 -2
  40. package/build-module/components/post-content-information/index.js.map +1 -1
  41. package/build-module/components/post-last-revision/index.js +1 -1
  42. package/build-module/components/post-last-revision/index.js.map +1 -1
  43. package/build-module/components/post-schedule/label.js +1 -1
  44. package/build-module/components/post-schedule/label.js.map +1 -1
  45. package/build-module/components/post-taxonomies/flat-term-selector.js +13 -4
  46. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  47. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  48. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  49. package/build-module/components/post-url/panel.js +3 -3
  50. package/build-module/components/post-url/panel.js.map +1 -1
  51. package/build-module/components/preferences-modal/index.js +26 -22
  52. package/build-module/components/preferences-modal/index.js.map +1 -1
  53. package/build-module/components/sidebar/header.js +2 -1
  54. package/build-module/components/sidebar/header.js.map +1 -1
  55. package/build-module/components/sidebar/index.js +4 -4
  56. package/build-module/components/sidebar/index.js.map +1 -1
  57. package/build-module/components/time-to-read/index.js +2 -2
  58. package/build-module/components/time-to-read/index.js.map +1 -1
  59. package/build-module/dataviews/actions/delete-post.js +3 -3
  60. package/build-module/dataviews/actions/delete-post.js.map +1 -1
  61. package/build-module/dataviews/actions/duplicate-template-part.js +3 -3
  62. package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -1
  63. package/build-module/store/private-actions.js +3 -3
  64. package/build-module/store/private-actions.js.map +1 -1
  65. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  66. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  67. package/build-types/components/post-author/panel.d.ts.map +1 -1
  68. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  69. package/build-types/components/preferences-modal/index.d.ts.map +1 -1
  70. package/build-types/components/sidebar/index.d.ts.map +1 -1
  71. package/package.json +14 -14
  72. package/src/components/editor-interface/index.js +3 -2
  73. package/src/components/page-attributes/parent.js +6 -4
  74. package/src/components/post-author/panel.js +4 -2
  75. package/src/components/post-content-information/index.js +1 -1
  76. package/src/components/post-last-revision/index.js +1 -1
  77. package/src/components/post-schedule/label.js +1 -1
  78. package/src/components/post-taxonomies/flat-term-selector.js +15 -4
  79. package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  80. package/src/components/post-url/panel.js +4 -2
  81. package/src/components/preferences-modal/index.js +26 -19
  82. package/src/components/preferences-modal/test/index.js +1 -1
  83. package/src/components/sidebar/header.js +3 -2
  84. package/src/components/sidebar/index.js +5 -3
  85. package/src/components/time-to-read/index.js +3 -3
  86. package/src/dataviews/actions/delete-post.tsx +3 -3
  87. package/src/dataviews/actions/duplicate-template-part.tsx +3 -3
  88. package/src/store/private-actions.js +3 -3
  89. package/tsconfig.tsbuildinfo +1 -1
@@ -48,7 +48,7 @@ export function getFullPostScheduleLabel( dateAttribute ) {
48
48
 
49
49
  const timezoneAbbreviation = getTimezoneAbbreviation();
50
50
  const formattedDate = dateI18n(
51
- // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
51
+ // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
52
52
  _x( 'F j, Y g:i\xa0a', 'post schedule full date format' ),
53
53
  date
54
54
  );
@@ -2,8 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __, _x, sprintf } from '@wordpress/i18n';
5
- import { useEffect, useMemo, useState } from '@wordpress/element';
6
- import { FormTokenField, withFilters } from '@wordpress/components';
5
+ import { Fragment, useEffect, useMemo, useState } from '@wordpress/element';
6
+ import {
7
+ FormTokenField,
8
+ withFilters,
9
+ __experimentalVStack as VStack,
10
+ } from '@wordpress/components';
7
11
  import { useSelect, useDispatch } from '@wordpress/data';
8
12
  import deprecated from '@wordpress/deprecated';
9
13
  import { store as coreStore } from '@wordpress/core-data';
@@ -53,6 +57,13 @@ const termNamesToIds = ( names, terms ) => {
53
57
  .filter( ( id ) => id !== undefined );
54
58
  };
55
59
 
60
+ const Wrapper = ( { children, __nextHasNoMarginBottom } ) =>
61
+ __nextHasNoMarginBottom ? (
62
+ <VStack spacing={ 4 }>{ children }</VStack>
63
+ ) : (
64
+ <Fragment>{ children }</Fragment>
65
+ );
66
+
56
67
  /**
57
68
  * Renders a flat term selector component.
58
69
  *
@@ -289,7 +300,7 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
289
300
  );
290
301
 
291
302
  return (
292
- <>
303
+ <Wrapper __nextHasNoMarginBottom={ __nextHasNoMarginBottom }>
293
304
  <FormTokenField
294
305
  __next40pxDefaultSize
295
306
  value={ values }
@@ -306,7 +317,7 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
306
317
  __nextHasNoMarginBottom={ __nextHasNoMarginBottom }
307
318
  />
308
319
  <MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />
309
- </>
320
+ </Wrapper>
310
321
  );
311
322
  }
312
323
 
@@ -310,7 +310,7 @@ export function HierarchicalTermSelector( { slug } ) {
310
310
  const defaultName =
311
311
  slug === 'category' ? __( 'Category' ) : __( 'Term' );
312
312
  const termAddedMessage = sprintf(
313
- /* translators: %s: taxonomy name */
313
+ /* translators: %s: term name. */
314
314
  _x( '%s added', 'term' ),
315
315
  taxonomy?.labels?.singular_name ?? defaultName
316
316
  );
@@ -341,7 +341,7 @@ export function HierarchicalTermSelector( { slug } ) {
341
341
 
342
342
  const resultCount = getResultCount( newFilteredTermsTree );
343
343
  const resultsFoundMessage = sprintf(
344
- /* translators: %d: number of results */
344
+ /* translators: %d: number of results. */
345
345
  _n( '%d result found.', '%d results found.', resultCount ),
346
346
  resultCount
347
347
  );
@@ -86,8 +86,10 @@ function PostURLToggle( { isOpen, onClick } ) {
86
86
  className="editor-post-url__panel-toggle"
87
87
  variant="tertiary"
88
88
  aria-expanded={ isOpen }
89
- // translators: %s: Current post link.
90
- aria-label={ sprintf( __( 'Change link: %s' ), decodedSlug ) }
89
+ aria-label={
90
+ // translators: %s: Current post link.
91
+ sprintf( __( 'Change link: %s' ), decodedSlug )
92
+ }
91
93
  onClick={ onClick }
92
94
  >
93
95
  <Truncate numberOfLines={ 1 }>
@@ -36,25 +36,40 @@ const {
36
36
  } = unlock( preferencesPrivateApis );
37
37
 
38
38
  export default function EditorPreferencesModal( { extraSections = {} } ) {
39
+ const isActive = useSelect( ( select ) => {
40
+ return select( interfaceStore ).isModalActive( 'editor/preferences' );
41
+ }, [] );
42
+ const { closeModal } = useDispatch( interfaceStore );
43
+
44
+ if ( ! isActive ) {
45
+ return null;
46
+ }
47
+
48
+ // Please wrap all contents inside PreferencesModalContents to prevent all
49
+ // hooks from executing when the modal is not open.
50
+ return (
51
+ <PreferencesModal closeModal={ closeModal }>
52
+ <PreferencesModalContents extraSections={ extraSections } />
53
+ </PreferencesModal>
54
+ );
55
+ }
56
+
57
+ function PreferencesModalContents( { extraSections = {} } ) {
39
58
  const isLargeViewport = useViewportMatch( 'medium' );
40
- const { isActive, showBlockBreadcrumbsOption } = useSelect(
59
+ const showBlockBreadcrumbsOption = useSelect(
41
60
  ( select ) => {
42
61
  const { getEditorSettings } = select( editorStore );
43
62
  const { get } = select( preferencesStore );
44
- const { isModalActive } = select( interfaceStore );
45
63
  const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
46
64
  const isDistractionFreeEnabled = get( 'core', 'distractionFree' );
47
- return {
48
- showBlockBreadcrumbsOption:
49
- ! isDistractionFreeEnabled &&
50
- isLargeViewport &&
51
- isRichEditingEnabled,
52
- isActive: isModalActive( 'editor/preferences' ),
53
- };
65
+ return (
66
+ ! isDistractionFreeEnabled &&
67
+ isLargeViewport &&
68
+ isRichEditingEnabled
69
+ );
54
70
  },
55
71
  [ isLargeViewport ]
56
72
  );
57
- const { closeModal } = useDispatch( interfaceStore );
58
73
  const { setIsListViewOpened, setIsInserterOpened } =
59
74
  useDispatch( editorStore );
60
75
  const { set: setPreference } = useDispatch( preferencesStore );
@@ -330,13 +345,5 @@ export default function EditorPreferencesModal( { extraSections = {} } ) {
330
345
  ]
331
346
  );
332
347
 
333
- if ( ! isActive ) {
334
- return null;
335
- }
336
-
337
- return (
338
- <PreferencesModal closeModal={ closeModal }>
339
- <PreferencesModalTabs sections={ sections } />
340
- </PreferencesModal>
341
- );
348
+ return <PreferencesModalTabs sections={ sections } />;
342
349
  }
@@ -19,7 +19,7 @@ jest.mock( '@wordpress/compose/src/hooks/use-viewport-match', () => jest.fn() );
19
19
 
20
20
  describe( 'EditPostPreferencesModal', () => {
21
21
  it( 'should not render when the modal is not active', () => {
22
- useSelect.mockImplementation( () => [ false, false, false ] );
22
+ useSelect.mockImplementation( () => false );
23
23
  render( <EditPostPreferencesModal /> );
24
24
  expect(
25
25
  screen.queryByRole( 'dialog', { name: 'Preferences' } )
@@ -20,8 +20,9 @@ const SidebarHeader = ( _, ref ) => {
20
20
  const { getPostTypeLabel } = select( editorStore );
21
21
 
22
22
  return {
23
- // translators: Default label for the Document sidebar tab, not selected.
24
- documentLabel: getPostTypeLabel() || _x( 'Document', 'noun' ),
23
+ documentLabel:
24
+ // translators: Default label for the Document sidebar tab, not selected.
25
+ getPostTypeLabel() || _x( 'Document', 'noun, sidebar' ),
25
26
  };
26
27
  }, [] );
27
28
 
@@ -13,7 +13,7 @@ import {
13
13
  useEffect,
14
14
  useRef,
15
15
  } from '@wordpress/element';
16
- import { isRTL, __ } from '@wordpress/i18n';
16
+ import { isRTL, __, _x } from '@wordpress/i18n';
17
17
  import { drawerLeft, drawerRight } from '@wordpress/icons';
18
18
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
19
19
  import { privateApis as componentsPrivateApis } from '@wordpress/components';
@@ -101,8 +101,10 @@ const SidebarContent = ( {
101
101
  // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
102
102
  className="editor-sidebar__panel"
103
103
  headerClassName="editor-sidebar__panel-tabs"
104
- /* translators: button label text should, if possible, be under 16 characters. */
105
- title={ __( 'Settings' ) }
104
+ title={
105
+ /* translators: button label text should, if possible, be under 16 characters. */
106
+ _x( 'Settings', 'sidebar button label' )
107
+ }
106
108
  toggleShortcut={ keyboardShortcut }
107
109
  icon={ isRTL() ? drawerLeft : drawerRight }
108
110
  isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
@@ -47,10 +47,10 @@ export default function TimeToRead() {
47
47
  } )
48
48
  : createInterpolateElement(
49
49
  sprintf(
50
- /* translators: %s is the number of minutes the post will take to read. */
50
+ /* translators: %s: the number of minutes to read the post. */
51
51
  _n(
52
- '<span>%d</span> minute',
53
- '<span>%d</span> minutes',
52
+ '<span>%s</span> minute',
53
+ '<span>%s</span> minutes',
54
54
  minutesToRead
55
55
  ),
56
56
  minutesToRead
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { trash } from '@wordpress/icons';
5
5
  import { useDispatch } from '@wordpress/data';
6
- import { __, _n, sprintf } from '@wordpress/i18n';
6
+ import { __, _x, _n, sprintf } from '@wordpress/i18n';
7
7
  import { useState } from '@wordpress/element';
8
8
  import {
9
9
  Button,
@@ -67,8 +67,8 @@ const deletePostAction: Action< Post > = {
67
67
  items.length
68
68
  )
69
69
  : sprintf(
70
- // translators: %s: The template or template part's titles
71
- __( 'Delete "%s"?' ),
70
+ // translators: %s: The template or template part's title
71
+ _x( 'Delete "%s"?', 'template part' ),
72
72
  getItemTitle( items[ 0 ] )
73
73
  ) }
74
74
  </Text>
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useDispatch } from '@wordpress/data';
5
- import { __, sprintf, _x } from '@wordpress/i18n';
5
+ import { _x, sprintf } from '@wordpress/i18n';
6
6
  import { store as noticesStore } from '@wordpress/notices';
7
7
  import { useMemo } from '@wordpress/element';
8
8
  // @ts-ignore
@@ -42,7 +42,7 @@ const duplicateTemplatePart: Action< TemplatePart > = {
42
42
  createSuccessNotice(
43
43
  sprintf(
44
44
  // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
45
- __( '"%s" duplicated.' ),
45
+ _x( '"%s" duplicated.', 'template part' ),
46
46
  getItemTitle( item )
47
47
  ),
48
48
  { type: 'snackbar', id: 'edit-site-patterns-success' }
@@ -55,7 +55,7 @@ const duplicateTemplatePart: Action< TemplatePart > = {
55
55
  defaultArea={ item.area }
56
56
  defaultTitle={ sprintf(
57
57
  /* translators: %s: Existing template part title */
58
- __( '%s (Copy)' ),
58
+ _x( '%s (Copy)', 'template part' ),
59
59
  getItemTitle( item )
60
60
  ) }
61
61
  onCreate={ onTemplatePartSuccess }
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { store as coreStore } from '@wordpress/core-data';
5
- import { __, sprintf } from '@wordpress/i18n';
5
+ import { __, _x, sprintf } from '@wordpress/i18n';
6
6
  import { store as noticesStore } from '@wordpress/notices';
7
7
  import { store as blockEditorStore } from '@wordpress/block-editor';
8
8
  import { store as preferencesStore } from '@wordpress/preferences';
@@ -410,8 +410,8 @@ export const removeTemplates =
410
410
  decodeEntities( title )
411
411
  )
412
412
  : sprintf(
413
- /* translators: The template/part's name. */
414
- __( '"%s" deleted.' ),
413
+ /* translators: %s: The template/part's name. */
414
+ _x( '"%s" deleted.', 'template part' ),
415
415
  decodeEntities( title )
416
416
  );
417
417
  } else {