@wordpress/editor 12.0.21 → 12.2.1-next.f435e9e01b.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 (102) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +7 -1
  4. package/build/components/deprecated.js +5 -5
  5. package/build/components/deprecated.js.map +1 -1
  6. package/build/components/editor-help/add-blocks.native.js +1 -1
  7. package/build/components/editor-help/add-blocks.native.js.map +1 -1
  8. package/build/components/editor-help/index.native.js +1 -1
  9. package/build/components/editor-help/index.native.js.map +1 -1
  10. package/build/components/entities-saved-states/index.js +18 -16
  11. package/build/components/entities-saved-states/index.js.map +1 -1
  12. package/build/components/index.js +18 -0
  13. package/build/components/index.js.map +1 -1
  14. package/build/components/post-format/index.js +6 -4
  15. package/build/components/post-format/index.js.map +1 -1
  16. package/build/components/post-locked-modal/index.js +34 -25
  17. package/build/components/post-locked-modal/index.js.map +1 -1
  18. package/build/components/post-publish-panel/maybe-category-panel.js +81 -0
  19. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -0
  20. package/build/components/post-publish-panel/prepublish.js +3 -1
  21. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  22. package/build/components/post-taxonomies/most-used-terms.js +3 -3
  23. package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
  24. package/build/components/post-title/index.native.js +1 -0
  25. package/build/components/post-title/index.native.js.map +1 -1
  26. package/build/components/post-trash/index.js +1 -1
  27. package/build/components/post-trash/index.js.map +1 -1
  28. package/build/components/post-visibility/index.js +30 -14
  29. package/build/components/post-visibility/index.js.map +1 -1
  30. package/build/components/provider/index.native.js +12 -6
  31. package/build/components/provider/index.native.js.map +1 -1
  32. package/build/components/provider/use-block-editor-settings.js +11 -6
  33. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  34. package/build/store/actions.js +21 -15
  35. package/build/store/actions.js.map +1 -1
  36. package/build/store/selectors.js +12 -39
  37. package/build/store/selectors.js.map +1 -1
  38. package/build/store/utils/notice-builder.js +1 -1
  39. package/build/store/utils/notice-builder.js.map +1 -1
  40. package/build-module/components/deprecated.js +5 -4
  41. package/build-module/components/deprecated.js.map +1 -1
  42. package/build-module/components/editor-help/add-blocks.native.js +1 -1
  43. package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
  44. package/build-module/components/editor-help/index.native.js +1 -1
  45. package/build-module/components/editor-help/index.native.js.map +1 -1
  46. package/build-module/components/entities-saved-states/index.js +19 -16
  47. package/build-module/components/entities-saved-states/index.js.map +1 -1
  48. package/build-module/components/index.js +2 -0
  49. package/build-module/components/index.js.map +1 -1
  50. package/build-module/components/post-format/index.js +7 -5
  51. package/build-module/components/post-format/index.js.map +1 -1
  52. package/build-module/components/post-locked-modal/index.js +37 -25
  53. package/build-module/components/post-locked-modal/index.js.map +1 -1
  54. package/build-module/components/post-publish-panel/maybe-category-panel.js +66 -0
  55. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -0
  56. package/build-module/components/post-publish-panel/prepublish.js +2 -1
  57. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  58. package/build-module/components/post-taxonomies/most-used-terms.js +3 -3
  59. package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
  60. package/build-module/components/post-title/index.native.js +1 -0
  61. package/build-module/components/post-title/index.native.js.map +1 -1
  62. package/build-module/components/post-trash/index.js +1 -1
  63. package/build-module/components/post-trash/index.js.map +1 -1
  64. package/build-module/components/post-visibility/index.js +31 -15
  65. package/build-module/components/post-visibility/index.js.map +1 -1
  66. package/build-module/components/provider/index.native.js +10 -7
  67. package/build-module/components/provider/index.native.js.map +1 -1
  68. package/build-module/components/provider/use-block-editor-settings.js +11 -6
  69. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  70. package/build-module/store/actions.js +21 -15
  71. package/build-module/store/actions.js.map +1 -1
  72. package/build-module/store/selectors.js +10 -35
  73. package/build-module/store/selectors.js.map +1 -1
  74. package/build-module/store/utils/notice-builder.js +1 -1
  75. package/build-module/store/utils/notice-builder.js.map +1 -1
  76. package/build-style/style-rtl.css +9 -27
  77. package/build-style/style.css +9 -27
  78. package/package.json +31 -30
  79. package/src/components/autosave-monitor/test/index.js +1 -1
  80. package/src/components/deprecated.js +2 -5
  81. package/src/components/editor-help/add-blocks.native.js +1 -1
  82. package/src/components/editor-help/index.native.js +1 -1
  83. package/src/components/entities-saved-states/index.js +21 -15
  84. package/src/components/entities-saved-states/style.scss +0 -12
  85. package/src/components/index.js +2 -0
  86. package/src/components/post-format/index.js +9 -10
  87. package/src/components/post-locked-modal/index.js +92 -53
  88. package/src/components/post-locked-modal/style.scss +7 -17
  89. package/src/components/post-publish-panel/maybe-category-panel.js +88 -0
  90. package/src/components/post-publish-panel/prepublish.js +2 -0
  91. package/src/components/post-taxonomies/README.md +25 -1
  92. package/src/components/post-taxonomies/most-used-terms.js +3 -3
  93. package/src/components/post-title/index.native.js +1 -0
  94. package/src/components/post-trash/index.js +1 -1
  95. package/src/components/post-visibility/index.js +25 -11
  96. package/src/components/provider/index.native.js +10 -7
  97. package/src/components/provider/use-block-editor-settings.js +14 -4
  98. package/src/store/actions.js +18 -23
  99. package/src/store/selectors.js +9 -40
  100. package/src/store/test/actions.js +1 -41
  101. package/src/store/utils/notice-builder.js +1 -1
  102. package/src/store/utils/test/notice-builder.js +1 -1
@@ -0,0 +1,88 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { some } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { __ } from '@wordpress/i18n';
10
+ import { useSelect } from '@wordpress/data';
11
+ import { PanelBody } from '@wordpress/components';
12
+ import { store as coreStore } from '@wordpress/core-data';
13
+ import { useState, useEffect } from '@wordpress/element';
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';
19
+ import { store as editorStore } from '../../store';
20
+
21
+ function MaybeCategoryPanel() {
22
+ const hasNoCategory = useSelect( ( select ) => {
23
+ const postType = select( editorStore ).getCurrentPostType();
24
+ const categoriesTaxonomy = select( coreStore ).getTaxonomy(
25
+ 'category'
26
+ );
27
+ const defaultCategorySlug = 'uncategorized';
28
+ const defaultCategory = select( coreStore ).getEntityRecords(
29
+ 'taxonomy',
30
+ 'category',
31
+ {
32
+ slug: defaultCategorySlug,
33
+ }
34
+ )?.[ 0 ];
35
+ const postTypeSupportsCategories =
36
+ categoriesTaxonomy &&
37
+ some( categoriesTaxonomy.types, ( type ) => type === postType );
38
+ const categories =
39
+ categoriesTaxonomy &&
40
+ select( editorStore ).getEditedPostAttribute(
41
+ categoriesTaxonomy.rest_base
42
+ );
43
+
44
+ // This boolean should return true if everything is loaded
45
+ // ( categoriesTaxonomy, defaultCategory )
46
+ // and the post has not been assigned a category different than "uncategorized".
47
+ return (
48
+ !! categoriesTaxonomy &&
49
+ !! defaultCategory &&
50
+ postTypeSupportsCategories &&
51
+ ( categories?.length === 0 ||
52
+ ( categories?.length === 1 &&
53
+ defaultCategory.id === categories[ 0 ] ) )
54
+ );
55
+ }, [] );
56
+ const [ shouldShowPanel, setShouldShowPanel ] = useState( false );
57
+ useEffect( () => {
58
+ // We use state to avoid hiding the panel if the user edits the categories
59
+ // and adds one within the panel itself (while visible).
60
+ if ( hasNoCategory ) {
61
+ setShouldShowPanel( true );
62
+ }
63
+ }, [ hasNoCategory ] );
64
+
65
+ if ( ! shouldShowPanel ) {
66
+ return null;
67
+ }
68
+
69
+ const panelBodyTitle = [
70
+ __( 'Suggestion:' ),
71
+ <span className="editor-post-publish-panel__link" key="label">
72
+ { __( 'Assign a category' ) }
73
+ </span>,
74
+ ];
75
+
76
+ return (
77
+ <PanelBody initialOpen={ false } title={ panelBodyTitle }>
78
+ <p>
79
+ { __(
80
+ 'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'
81
+ ) }
82
+ </p>
83
+ <HierarchicalTermSelector slug="category" />
84
+ </PanelBody>
85
+ );
86
+ }
87
+
88
+ export default MaybeCategoryPanel;
@@ -24,6 +24,7 @@ import PostScheduleLabel from '../post-schedule/label';
24
24
  import MaybeTagsPanel from './maybe-tags-panel';
25
25
  import MaybePostFormatPanel from './maybe-post-format-panel';
26
26
  import { store as editorStore } from '../../store';
27
+ import MaybeCategoryPanel from './maybe-category-panel';
27
28
 
28
29
  function PostPublishPanelPrepublish( { children } ) {
29
30
  const {
@@ -145,6 +146,7 @@ function PostPublishPanelPrepublish( { children } ) {
145
146
  ) }
146
147
  <MaybePostFormatPanel />
147
148
  <MaybeTagsPanel />
149
+ <MaybeCategoryPanel />
148
150
  { children }
149
151
  </div>
150
152
  );
@@ -33,7 +33,31 @@ function customizeProductTypeSelector( OriginalComponent ) {
33
33
 
34
34
  wp.hooks.addFilter(
35
35
  'editor.PostTaxonomyType',
36
- 'my-custom-plugin',
36
+ 'my-plugin/set-custom-term-selector',
37
37
  customizeProductTypeSelector
38
38
  );
39
39
  ```
40
+
41
+ Or, to use the hierarchical term selector with a non-hierarchical taxonomy `track`,
42
+ you can set the `HierarchicalTermSelector` component as shown below.
43
+
44
+ ```js
45
+ const el = wp.element.createElement;
46
+ const HierarchicalTermSelector = wp.editor.PostTaxonomiesHierarchicalTermSelector;
47
+
48
+ function customizeTrackSelector( OriginalComponent ) {
49
+ return function ( props ) {
50
+ if ( props.slug === 'track' ) {
51
+ return el( HierarchicalTermSelector, props );
52
+ } else {
53
+ return el( OriginalComponent, props );
54
+ }
55
+ };
56
+ }
57
+
58
+ wp.hooks.addFilter(
59
+ 'editor.PostTaxonomyType',
60
+ 'my-plugin/set-hierarchical-term-selector',
61
+ customizeTrackSelector
62
+ );
63
+ ```
@@ -15,9 +15,9 @@ import { store as coreStore } from '@wordpress/core-data';
15
15
  */
16
16
  import { unescapeTerms } from '../../utils/terms';
17
17
 
18
- const MAX_MOST_USED_TERMS = 10;
18
+ const MIN_MOST_USED_TERMS = 3;
19
19
  const DEFAULT_QUERY = {
20
- per_page: MAX_MOST_USED_TERMS,
20
+ per_page: 10,
21
21
  orderby: 'count',
22
22
  order: 'desc',
23
23
  hide_empty: true,
@@ -34,7 +34,7 @@ export default function MostUsedTerms( { onSelect, taxonomy } ) {
34
34
  );
35
35
  return {
36
36
  _terms: mostUsedTerms,
37
- showTerms: mostUsedTerms?.length === MAX_MOST_USED_TERMS,
37
+ showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,
38
38
  };
39
39
  }, [] );
40
40
 
@@ -147,6 +147,7 @@ class PostTitle extends Component {
147
147
  style={ titleStyles }
148
148
  styles={ styles }
149
149
  fontSize={ 24 }
150
+ lineHeight={ 1 }
150
151
  fontWeight={ 'bold' }
151
152
  deleteEnter={ true }
152
153
  onChange={ ( value ) => {
@@ -22,7 +22,7 @@ function PostTrash( { isNew, postId, postType, ...props } ) {
22
22
  <Button
23
23
  className="editor-post-trash"
24
24
  isDestructive
25
- variant="tertiary"
25
+ variant="secondary"
26
26
  onClick={ onClick }
27
27
  >
28
28
  { __( 'Move to trash' ) }
@@ -3,7 +3,10 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { Component } from '@wordpress/element';
6
- import { VisuallyHidden } from '@wordpress/components';
6
+ import {
7
+ VisuallyHidden,
8
+ __experimentalConfirmDialog as ConfirmDialog,
9
+ } from '@wordpress/components';
7
10
  import { withInstanceId, compose } from '@wordpress/compose';
8
11
  import { withSelect, withDispatch } from '@wordpress/data';
9
12
 
@@ -24,6 +27,7 @@ export class PostVisibility extends Component {
24
27
 
25
28
  this.state = {
26
29
  hasPassword: !! props.password,
30
+ showPrivateConfirmDialog: false,
27
31
  };
28
32
  }
29
33
 
@@ -35,21 +39,23 @@ export class PostVisibility extends Component {
35
39
  }
36
40
 
37
41
  setPrivate() {
38
- if (
39
- // eslint-disable-next-line no-alert
40
- ! window.confirm(
41
- __( 'Would you like to privately publish this post now?' )
42
- )
43
- ) {
44
- return;
45
- }
42
+ this.setState( { showPrivateConfirmDialog: true } );
43
+ }
46
44
 
45
+ confirmPrivate = () => {
47
46
  const { onUpdateVisibility, onSave } = this.props;
48
47
 
49
48
  onUpdateVisibility( 'private' );
50
- this.setState( { hasPassword: false } );
49
+ this.setState( {
50
+ hasPassword: false,
51
+ showPrivateConfirmDialog: false,
52
+ } );
51
53
  onSave();
52
- }
54
+ };
55
+
56
+ handleDialogCancel = () => {
57
+ this.setState( { showPrivateConfirmDialog: false } );
58
+ };
53
59
 
54
60
  setPasswordProtected() {
55
61
  const { visibility, onUpdateVisibility, status, password } = this.props;
@@ -145,6 +151,14 @@ export class PostVisibility extends Component {
145
151
  />
146
152
  </div>
147
153
  ),
154
+ <ConfirmDialog
155
+ key="private-publish-confirmation"
156
+ isOpen={ this.state.showPrivateConfirmDialog }
157
+ onConfirm={ this.confirmPrivate }
158
+ onCancel={ this.handleDialogCancel }
159
+ >
160
+ { __( 'Would you like to privately publish this post now?' ) }
161
+ </ConfirmDialog>,
148
162
  ];
149
163
  }
150
164
  }
@@ -56,7 +56,10 @@ const postTypeEntities = [
56
56
  },
57
57
  rawAttributes: [ 'title', 'excerpt', 'content' ],
58
58
  } ) );
59
- import { EditorHelpTopics } from '@wordpress/editor';
59
+ import { EditorHelpTopics, store as editorStore } from '@wordpress/editor';
60
+ import { store as noticesStore } from '@wordpress/notices';
61
+ import { store as coreStore } from '@wordpress/core-data';
62
+ import { store as editPostStore } from '@wordpress/edit-post';
60
63
 
61
64
  /**
62
65
  * Internal dependencies
@@ -350,8 +353,8 @@ export default compose( [
350
353
  getEditorBlocks,
351
354
  getEditedPostAttribute,
352
355
  getEditedPostContent,
353
- } = select( 'core/editor' );
354
- const { getEditorMode } = select( 'core/edit-post' );
356
+ } = select( editorStore );
357
+ const { getEditorMode } = select( editPostStore );
355
358
 
356
359
  const {
357
360
  getBlockIndex,
@@ -374,16 +377,16 @@ export default compose( [
374
377
  };
375
378
  } ),
376
379
  withDispatch( ( dispatch ) => {
377
- const { editPost, resetEditorBlocks } = dispatch( 'core/editor' );
380
+ const { editPost, resetEditorBlocks } = dispatch( editorStore );
378
381
  const {
379
382
  updateSettings,
380
383
  clearSelectedBlock,
381
384
  insertBlock,
382
385
  replaceBlock,
383
386
  } = dispatch( blockEditorStore );
384
- const { switchEditorMode } = dispatch( 'core/edit-post' );
385
- const { addEntities, receiveEntityRecords } = dispatch( 'core' );
386
- const { createSuccessNotice } = dispatch( 'core/notices' );
387
+ const { switchEditorMode } = dispatch( editPostStore );
388
+ const { addEntities, receiveEntityRecords } = dispatch( coreStore );
389
+ const { createSuccessNotice } = dispatch( noticesStore );
387
390
 
388
391
  return {
389
392
  updateSettings,
@@ -35,12 +35,18 @@ function useBlockEditorSettings( settings, hasTemplate ) {
35
35
  hasUploadPermissions,
36
36
  canUseUnfilteredHTML,
37
37
  userCanCreatePages,
38
+ pageOnFront,
38
39
  } = useSelect( ( select ) => {
39
40
  const { canUserUseUnfilteredHTML } = select( editorStore );
40
41
  const isWeb = Platform.OS === 'web';
41
- const { canUser, getUnstableBase, hasFinishedResolution } = select(
42
- coreStore
43
- );
42
+ const {
43
+ canUser,
44
+ getUnstableBase,
45
+ hasFinishedResolution,
46
+ getEntityRecord,
47
+ } = select( coreStore );
48
+
49
+ const siteSettings = getEntityRecord( 'root', 'site' );
44
50
 
45
51
  const siteData = getUnstableBase();
46
52
 
@@ -64,6 +70,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
64
70
  hasResolvedLocalSiteData: hasFinishedResolvingSiteData,
65
71
  baseUrl: siteData?.url || '',
66
72
  userCanCreatePages: canUser( 'create', 'pages' ),
73
+ pageOnFront: siteSettings?.page_on_front,
67
74
  };
68
75
  }, [] );
69
76
 
@@ -93,10 +100,10 @@ function useBlockEditorSettings( settings, hasTemplate ) {
93
100
  '__experimentalBlockDirectory',
94
101
  '__experimentalBlockPatternCategories',
95
102
  '__experimentalBlockPatterns',
103
+ '__experimentalDiscussionSettings',
96
104
  '__experimentalFeatures',
97
105
  '__experimentalPreferredStyleVariations',
98
106
  '__experimentalSetIsInserterOpened',
99
- '__experimentalGenerateAnchors',
100
107
  '__unstableGalleryWithImageBlocks',
101
108
  'alignWide',
102
109
  'allowedBlockTypes',
@@ -128,6 +135,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
128
135
  'titlePlaceholder',
129
136
  'supportsLayout',
130
137
  'widgetTypesToHideFromLegacyWidgetBlock',
138
+ '__unstableResolvedAssets',
131
139
  ] ),
132
140
  mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
133
141
  __experimentalReusableBlocks: reusableBlocks,
@@ -139,6 +147,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
139
147
  outlineMode: hasTemplate,
140
148
  __experimentalCreatePageEntity: createPageEntity,
141
149
  __experimentalUserCanCreatePages: userCanCreatePages,
150
+ pageOnFront,
142
151
  } ),
143
152
  [
144
153
  settings,
@@ -148,6 +157,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
148
157
  undo,
149
158
  hasTemplate,
150
159
  userCanCreatePages,
160
+ pageOnFront,
151
161
  ]
152
162
  );
153
163
  }
@@ -280,27 +280,17 @@ export function* savePost( options = {} ) {
280
280
  }
281
281
 
282
282
  /**
283
- * Action generator for handling refreshing the current post.
283
+ * Action for refreshing the current post.
284
+ *
285
+ * @deprecated Since WordPress 6.0.
284
286
  */
285
- export function* refreshPost() {
286
- const post = yield controls.select( STORE_NAME, 'getCurrentPost' );
287
- const postTypeSlug = yield controls.select(
288
- STORE_NAME,
289
- 'getCurrentPostType'
290
- );
291
- const postType = yield controls.resolveSelect(
292
- coreStore,
293
- 'getPostType',
294
- postTypeSlug
295
- );
296
- const newPost = yield apiFetch( {
297
- // Timestamp arg allows caller to bypass browser caching, which is
298
- // expected for this specific function.
299
- path:
300
- `/wp/v2/${ postType.rest_base }/${ post.id }` +
301
- `?context=edit&_timestamp=${ Date.now() }`,
287
+ export function refreshPost() {
288
+ deprecated( "wp.data.dispatch( 'core/editor' ).refreshPost", {
289
+ since: '6.0',
290
+ version: '6.3',
291
+ alternative: 'Use the core entities store instead',
302
292
  } );
303
- yield controls.dispatch( STORE_NAME, 'resetPost', newPost );
293
+ return { type: 'DO_NOTHING' };
304
294
  }
305
295
 
306
296
  /**
@@ -404,13 +394,17 @@ export function* undo() {
404
394
  }
405
395
 
406
396
  /**
407
- * Returns an action object used in signalling that undo history record should
408
- * be created.
397
+ * Action that creates an undo history record.
409
398
  *
410
- * @return {Object} Action object.
399
+ * @deprecated Since WordPress 6.0
411
400
  */
412
401
  export function createUndoLevel() {
413
- return { type: 'CREATE_UNDO_LEVEL' };
402
+ deprecated( "wp.data.dispatch( 'core/editor' ).createUndoLevel", {
403
+ since: '6.0',
404
+ version: '6.3',
405
+ alternative: 'Use the core entities store instead',
406
+ } );
407
+ return { type: 'DO_NOTHING' };
414
408
  }
415
409
 
416
410
  /**
@@ -629,6 +623,7 @@ const getBlockEditorAction = ( name ) =>
629
623
  since: '5.3',
630
624
  alternative:
631
625
  "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
626
+ version: '6.2',
632
627
  } );
633
628
  yield controls.dispatch( blockEditorStore, name, ...args );
634
629
  };
@@ -277,41 +277,6 @@ export const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
277
277
  );
278
278
  } );
279
279
 
280
- /**
281
- * Returns a new reference when edited values have changed. This is useful in
282
- * inferring where an edit has been made between states by comparison of the
283
- * return values using strict equality.
284
- *
285
- * @deprecated since Gutenberg 6.5.0.
286
- *
287
- * @example
288
- *
289
- * ```
290
- * const hasEditOccurred = (
291
- * getReferenceByDistinctEdits( beforeState ) !==
292
- * getReferenceByDistinctEdits( afterState )
293
- * );
294
- * ```
295
- *
296
- * @param {Object} state Editor state.
297
- *
298
- * @return {*} A value whose reference will change only when an edit occurs.
299
- */
300
- export const getReferenceByDistinctEdits = createRegistrySelector(
301
- ( select ) => (/* state */) => {
302
- deprecated(
303
- "`wp.data.select( 'core/editor' ).getReferenceByDistinctEdits`",
304
- {
305
- since: '5.4',
306
- alternative:
307
- "`wp.data.select( 'core' ).getReferenceByDistinctEdits`",
308
- }
309
- );
310
-
311
- return select( coreStore ).getReferenceByDistinctEdits();
312
- }
313
- );
314
-
315
280
  /**
316
281
  * Returns an attribute value of the saved post.
317
282
  *
@@ -839,7 +804,12 @@ export function getEditedPostPreviewLink( state ) {
839
804
  }
840
805
 
841
806
  let previewLink = getAutosaveAttribute( state, 'preview_link' );
842
- if ( ! previewLink ) {
807
+ // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
808
+ // If the post is draft, ignore the preview link from the autosave record,
809
+ // because the preview could be a stale autosave if the post was switched from
810
+ // published to draft.
811
+ // See: https://github.com/WordPress/gutenberg/pull/37952
812
+ if ( ! previewLink || 'draft' === getCurrentPost( state ).status ) {
843
813
  previewLink = getEditedPostAttribute( state, 'link' );
844
814
  if ( previewLink ) {
845
815
  previewLink = addQueryArgs( previewLink, { preview: true } );
@@ -1166,8 +1136,7 @@ export function getEditorBlocks( state ) {
1166
1136
  */
1167
1137
  export function getEditorSelectionStart( state ) {
1168
1138
  deprecated( "select('core/editor').getEditorSelectionStart", {
1169
- since: '10.0',
1170
- plugin: 'Gutenberg',
1139
+ since: '5.8',
1171
1140
  alternative: "select('core/editor').getEditorSelection",
1172
1141
  } );
1173
1142
  return getEditedPostAttribute( state, 'selection' )?.selectionStart;
@@ -1183,8 +1152,7 @@ export function getEditorSelectionStart( state ) {
1183
1152
  */
1184
1153
  export function getEditorSelectionEnd( state ) {
1185
1154
  deprecated( "select('core/editor').getEditorSelectionStart", {
1186
- since: '10.0',
1187
- plugin: 'Gutenberg',
1155
+ since: '5.8',
1188
1156
  alternative: "select('core/editor').getEditorSelection",
1189
1157
  } );
1190
1158
  return getEditedPostAttribute( state, 'selection' )?.selectionEnd;
@@ -1258,6 +1226,7 @@ function getBlockEditorSelector( name ) {
1258
1226
  deprecated( "`wp.data.select( 'core/editor' )." + name + '`', {
1259
1227
  since: '5.3',
1260
1228
  alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
1229
+ version: '6.2',
1261
1230
  } );
1262
1231
 
1263
1232
  return select( blockEditorStore )[ name ]( ...args );
@@ -196,7 +196,7 @@ describe( 'Post generator actions', () => {
196
196
  'createSuccessNotice',
197
197
  currentPostStatus === 'publish'
198
198
  ? 'Updated Post'
199
- : 'Saved',
199
+ : 'Draft saved',
200
200
  {
201
201
  actions: [],
202
202
  id: 'SAVE_POST_NOTICE_ID',
@@ -358,46 +358,6 @@ describe( 'Post generator actions', () => {
358
358
  } );
359
359
  } );
360
360
  } );
361
- describe( 'refreshPost()', () => {
362
- let fulfillment;
363
- const currentPost = { id: 10, content: 'foo' };
364
- const reset = () => ( fulfillment = actions.refreshPost() );
365
- it( 'yields expected action for selecting the currentPost', () => {
366
- reset();
367
- const { value } = fulfillment.next();
368
- expect( value ).toEqual(
369
- controls.select( STORE_NAME, 'getCurrentPost' )
370
- );
371
- } );
372
- it( 'yields expected action for selecting the current post type', () => {
373
- const { value } = fulfillment.next( currentPost );
374
- expect( value ).toEqual(
375
- controls.select( STORE_NAME, 'getCurrentPostType' )
376
- );
377
- } );
378
- it( 'yields expected action for selecting the post type object', () => {
379
- const { value } = fulfillment.next( postTypeSlug );
380
- expect( value ).toEqual(
381
- controls.resolveSelect( 'core', 'getPostType', postTypeSlug )
382
- );
383
- } );
384
- it( 'yields expected action for the api fetch call', () => {
385
- const { value } = fulfillment.next( postType );
386
- // since the timestamp is a computed value we can't do a direct comparison.
387
- // so we'll just see if the path has most of the value.
388
- expect( value.request.path ).toEqual(
389
- expect.stringContaining(
390
- `/wp/v2/${ postType.rest_base }/${ currentPost.id }?context=edit&_timestamp=`
391
- )
392
- );
393
- } );
394
- it( 'yields expected action for dispatching the reset of the post', () => {
395
- const { value } = fulfillment.next( currentPost );
396
- expect( value ).toEqual(
397
- controls.dispatch( STORE_NAME, 'resetPost', currentPost )
398
- );
399
- } );
400
- } );
401
361
  } );
402
362
 
403
363
  describe( 'Editor actions', () => {
@@ -38,7 +38,7 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
38
38
  // Always should a notice, which will be spoken for accessibility.
39
39
  if ( ! isPublished && ! willPublish ) {
40
40
  // If saving a non-published post, don't show notice.
41
- noticeMessage = __( 'Saved' );
41
+ noticeMessage = __( 'Draft saved' );
42
42
  shouldShowLink = false;
43
43
  } else if ( isPublished && ! willPublish ) {
44
44
  // If undoing publish status, show specific notice
@@ -34,7 +34,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
34
34
  [
35
35
  'when previous post is not published and post will not be published',
36
36
  [ 'draft', 'draft', false ],
37
- [ 'Saved', defaultExpectedAction ],
37
+ [ 'Draft saved', defaultExpectedAction ],
38
38
  ],
39
39
  [
40
40
  'when previous post is published and post will be unpublished',