@wordpress/editor 14.47.0 → 14.48.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 (213) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/build/components/block-removal-warnings/index.cjs +0 -3
  3. package/build/components/block-removal-warnings/index.cjs.map +2 -2
  4. package/build/components/collab-sidebar/note-indicator-toolbar.cjs +49 -43
  5. package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +3 -3
  6. package/build/components/collaborators-overlay/use-block-highlighting.cjs +1 -8
  7. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
  8. package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -7
  9. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  10. package/build/components/more-menu/view-more-menu-group.cjs +1 -2
  11. package/build/components/more-menu/view-more-menu-group.cjs.map +2 -2
  12. package/build/components/page-attributes/parent.cjs +1 -0
  13. package/build/components/page-attributes/parent.cjs.map +2 -2
  14. package/build/components/post-publish-button/index.cjs +114 -157
  15. package/build/components/post-publish-button/index.cjs.map +3 -3
  16. package/build/components/post-revisions-preview/block-diff.cjs +21 -9
  17. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  18. package/build/components/post-revisions-preview/preserve-client-ids.cjs +2 -2
  19. package/build/components/post-revisions-preview/preserve-client-ids.cjs.map +2 -2
  20. package/build/components/provider/index.cjs +2 -0
  21. package/build/components/provider/index.cjs.map +3 -3
  22. package/build/components/provider/use-block-editor-settings.cjs +1 -1
  23. package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
  24. package/build/components/provider/use-network-reconnect.cjs +51 -0
  25. package/build/components/provider/use-network-reconnect.cjs.map +7 -0
  26. package/build/components/revision-fields-diff/index.cjs +2 -2
  27. package/build/components/revision-fields-diff/index.cjs.map +2 -2
  28. package/build/components/sidebar/index.cjs +1 -4
  29. package/build/components/sidebar/index.cjs.map +2 -2
  30. package/build/components/template-actions-panel/block-theme-content.cjs +7 -1
  31. package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
  32. package/build/components/upload-progress-snackbar/index.cjs +161 -0
  33. package/build/components/upload-progress-snackbar/index.cjs.map +7 -0
  34. package/build/components/upload-progress-snackbar/tracker.cjs +90 -0
  35. package/build/components/upload-progress-snackbar/tracker.cjs.map +7 -0
  36. package/build/private-apis.cjs +2 -0
  37. package/build/private-apis.cjs.map +3 -3
  38. package/build/store/selectors.cjs +1 -2
  39. package/build/store/selectors.cjs.map +2 -2
  40. package/build/utils/media-upload/index.cjs +16 -0
  41. package/build/utils/media-upload/index.cjs.map +3 -3
  42. package/build-module/components/block-removal-warnings/index.mjs +0 -3
  43. package/build-module/components/block-removal-warnings/index.mjs.map +2 -2
  44. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs +53 -44
  45. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +2 -2
  46. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +1 -8
  47. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  48. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -7
  49. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  50. package/build-module/components/more-menu/view-more-menu-group.mjs +1 -2
  51. package/build-module/components/more-menu/view-more-menu-group.mjs.map +2 -2
  52. package/build-module/components/page-attributes/parent.mjs +1 -0
  53. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  54. package/build-module/components/post-publish-button/index.mjs +116 -159
  55. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  56. package/build-module/components/post-revisions-preview/block-diff.mjs +20 -8
  57. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  58. package/build-module/components/post-revisions-preview/preserve-client-ids.mjs +1 -1
  59. package/build-module/components/post-revisions-preview/preserve-client-ids.mjs.map +1 -1
  60. package/build-module/components/provider/index.mjs +2 -0
  61. package/build-module/components/provider/index.mjs.map +2 -2
  62. package/build-module/components/provider/use-block-editor-settings.mjs +1 -1
  63. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  64. package/build-module/components/provider/use-network-reconnect.mjs +30 -0
  65. package/build-module/components/provider/use-network-reconnect.mjs.map +7 -0
  66. package/build-module/components/revision-fields-diff/index.mjs +2 -2
  67. package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
  68. package/build-module/components/sidebar/index.mjs +2 -11
  69. package/build-module/components/sidebar/index.mjs.map +2 -2
  70. package/build-module/components/template-actions-panel/block-theme-content.mjs +7 -1
  71. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
  72. package/build-module/components/upload-progress-snackbar/index.mjs +135 -0
  73. package/build-module/components/upload-progress-snackbar/index.mjs.map +7 -0
  74. package/build-module/components/upload-progress-snackbar/tracker.mjs +61 -0
  75. package/build-module/components/upload-progress-snackbar/tracker.mjs.map +7 -0
  76. package/build-module/private-apis.mjs +2 -0
  77. package/build-module/private-apis.mjs.map +2 -2
  78. package/build-module/store/selectors.mjs +1 -2
  79. package/build-module/store/selectors.mjs.map +2 -2
  80. package/build-module/utils/media-upload/index.mjs +19 -0
  81. package/build-module/utils/media-upload/index.mjs.map +2 -2
  82. package/build-style/style-rtl.css +479 -84
  83. package/build-style/style.css +479 -84
  84. package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
  85. package/build-types/components/collab-sidebar/add-comment.d.ts +6 -0
  86. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
  87. package/build-types/components/collab-sidebar/comment-author-info.d.ts +8 -0
  88. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -0
  89. package/build-types/components/collab-sidebar/comment-form.d.ts +9 -0
  90. package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -0
  91. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +6 -0
  92. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -0
  93. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +6 -0
  94. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -0
  95. package/build-types/components/collab-sidebar/comments.d.ts +10 -0
  96. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
  97. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
  98. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +0 -3
  99. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  100. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  101. package/build-types/components/document-bar/index.d.ts +2 -2
  102. package/build-types/components/document-bar/index.d.ts.map +1 -1
  103. package/build-types/components/global-styles-provider/index.d.ts +16 -0
  104. package/build-types/components/global-styles-provider/index.d.ts.map +1 -0
  105. package/build-types/components/media/index.d.ts +3 -0
  106. package/build-types/components/media/index.d.ts.map +1 -0
  107. package/build-types/components/media/metadata-panel.d.ts +12 -0
  108. package/build-types/components/media/metadata-panel.d.ts.map +1 -0
  109. package/build-types/components/media/preview.d.ts +9 -0
  110. package/build-types/components/media/preview.d.ts.map +1 -0
  111. package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
  112. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  113. package/build-types/components/post-locked-modal/index.d.ts +6 -1
  114. package/build-types/components/post-publish-button/index.d.ts +9 -9
  115. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  116. package/build-types/components/post-revisions-preview/block-diff.d.ts +3 -0
  117. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  118. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +6 -1
  119. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +6 -1
  120. package/build-types/components/post-text-editor/index.d.ts +1 -1
  121. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  122. package/build-types/components/post-text-editor/utils.d.ts +29 -0
  123. package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
  124. package/build-types/components/provider/index.d.ts.map +1 -1
  125. package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
  126. package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
  127. package/build-types/components/revision-fields-diff/index.d.ts +3 -0
  128. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
  129. package/build-types/components/sidebar/index.d.ts.map +1 -1
  130. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
  131. package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
  132. package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
  133. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
  134. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
  135. package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
  136. package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
  137. package/build-types/private-apis.d.ts.map +1 -1
  138. package/build-types/store/selectors.d.ts.map +1 -1
  139. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  140. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  141. package/package.json +55 -52
  142. package/src/components/README.md +1 -1
  143. package/src/components/block-removal-warnings/index.js +0 -7
  144. package/src/components/collab-sidebar/note-indicator-toolbar.js +73 -60
  145. package/src/components/collaborators-overlay/use-block-highlighting.ts +0 -9
  146. package/src/components/collaborators-overlay/use-render-cursors.ts +0 -8
  147. package/src/components/collaborators-presence/avatar/test/index.tsx +8 -3
  148. package/src/components/more-menu/view-more-menu-group.js +1 -2
  149. package/src/components/page-attributes/parent.js +1 -0
  150. package/src/components/post-publish-button/index.js +143 -192
  151. package/src/components/post-publish-button/test/index.js +137 -114
  152. package/src/components/post-revisions-preview/block-diff.js +63 -19
  153. package/src/components/post-revisions-preview/preserve-client-ids.js +1 -1
  154. package/src/components/post-revisions-preview/test/block-diff.js +109 -6
  155. package/src/components/provider/index.js +4 -0
  156. package/src/components/provider/test/use-network-reconnect.js +137 -0
  157. package/src/components/provider/use-block-editor-settings.js +2 -2
  158. package/src/components/provider/use-network-reconnect.js +44 -0
  159. package/src/components/revision-fields-diff/index.js +7 -2
  160. package/src/components/sidebar/index.js +2 -11
  161. package/src/components/template-actions-panel/block-theme-content.js +10 -1
  162. package/src/components/upload-progress-snackbar/README.md +26 -0
  163. package/src/components/upload-progress-snackbar/index.js +216 -0
  164. package/src/components/upload-progress-snackbar/stories/index.story.tsx +85 -0
  165. package/src/components/upload-progress-snackbar/style.scss +30 -0
  166. package/src/components/upload-progress-snackbar/test/index.js +199 -0
  167. package/src/components/upload-progress-snackbar/tracker.js +105 -0
  168. package/src/private-apis.js +2 -0
  169. package/src/store/selectors.js +1 -3
  170. package/src/style.scss +1 -0
  171. package/src/utils/media-upload/index.js +27 -0
  172. package/src/components/commands/index.native.js +0 -2
  173. package/src/components/deprecated.native.js +0 -47
  174. package/src/components/editor-help/add-blocks.native.js +0 -40
  175. package/src/components/editor-help/customize-blocks.native.js +0 -40
  176. package/src/components/editor-help/help-detail-navigation-screen.native.js +0 -67
  177. package/src/components/editor-help/help-get-support-button.native.js +0 -38
  178. package/src/components/editor-help/help-section-title.native.js +0 -29
  179. package/src/components/editor-help/help-topic-row.native.js +0 -33
  180. package/src/components/editor-help/icon-move-blocks.native.js +0 -10
  181. package/src/components/editor-help/index.native.js +0 -208
  182. package/src/components/editor-help/intro-to-blocks.native.js +0 -91
  183. package/src/components/editor-help/move-blocks.native.js +0 -55
  184. package/src/components/editor-help/remove-blocks.native.js +0 -35
  185. package/src/components/editor-help/style.android.scss +0 -6
  186. package/src/components/editor-help/style.ios.scss +0 -6
  187. package/src/components/editor-help/test/index.native.js +0 -81
  188. package/src/components/editor-help/view-sections.native.js +0 -79
  189. package/src/components/error-boundary/index.native.js +0 -192
  190. package/src/components/error-boundary/style.native.scss +0 -116
  191. package/src/components/index.native.js +0 -15
  192. package/src/components/offline-status/index.native.js +0 -99
  193. package/src/components/offline-status/style.native.scss +0 -28
  194. package/src/components/offline-status/test/index.native.js +0 -108
  195. package/src/components/post-title/index.native.js +0 -282
  196. package/src/components/post-title/style.native.scss +0 -13
  197. package/src/components/post-title/test/__snapshots__/index.native.js.snap +0 -25
  198. package/src/components/post-title/test/index.native.js +0 -78
  199. package/src/components/provider/index.native.js +0 -497
  200. package/src/components/provider/use-block-editor-settings.native.js +0 -48
  201. package/src/components/template-part-menu-items/index.native.js +0 -3
  202. package/src/hooks/index.native.js +0 -0
  203. package/src/index.native.js +0 -16
  204. package/src/private-apis.native.js +0 -33
  205. package/src/store/actions.native.js +0 -27
  206. package/src/store/reducer.native.js +0 -94
  207. package/src/store/selectors.native.js +0 -57
  208. package/src/store/test/actions.native.js +0 -16
  209. package/src/store/test/reducer.native.js +0 -36
  210. package/src/store/test/selectors.native.js +0 -28
  211. package/src/utils/index.native.js +0 -6
  212. package/src/utils/media-sideload/index.native.js +0 -1
  213. package/src/utils/media-upload/index.native.js +0 -1
@@ -2,9 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Button } from '@wordpress/components';
5
- import { Component } from '@wordpress/element';
6
- import { withSelect, withDispatch } from '@wordpress/data';
7
- import { compose } from '@wordpress/compose';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
8
6
 
9
7
  /**
10
8
  * Internal dependencies
@@ -14,220 +12,173 @@ import { store as editorStore } from '../../store';
14
12
 
15
13
  const noop = () => {};
16
14
 
17
- export class PostPublishButton extends Component {
18
- constructor( props ) {
19
- super( props );
15
+ export function PostPublishButton( {
16
+ forceIsDirty,
17
+ isOpen,
18
+ isToggle,
19
+ onSubmit = noop,
20
+ onToggle,
21
+ setEntitiesSavedStatesCallback,
22
+ } ) {
23
+ const {
24
+ hasPublishAction,
25
+ isBeingScheduled,
26
+ isPostSavingLocked,
27
+ isPublishable,
28
+ isPublished,
29
+ isSaveable,
30
+ isSaving,
31
+ isAutoSaving,
32
+ visibility,
33
+ hasNonPostEntityChanges,
34
+ isSavingNonPostEntityChanges,
35
+ postStatus,
36
+ postStatusHasChanged,
37
+ postType,
38
+ postId,
39
+ } = useSelect( ( select ) => {
40
+ const store = select( editorStore );
41
+ return {
42
+ isSaving: store.isSavingPost(),
43
+ isAutoSaving: store.isAutosavingPost(),
44
+ isBeingScheduled: store.isEditedPostBeingScheduled(),
45
+ visibility: store.getEditedPostVisibility(),
46
+ isSaveable: store.isEditedPostSaveable(),
47
+ isPostSavingLocked: store.isPostSavingLocked(),
48
+ isPublishable: store.isEditedPostPublishable(),
49
+ isPublished: store.isCurrentPostPublished(),
50
+ hasPublishAction:
51
+ store.getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,
52
+ postType: store.getCurrentPostType(),
53
+ postId: store.getCurrentPostId(),
54
+ postStatus: store.getEditedPostAttribute( 'status' ),
55
+ postStatusHasChanged: store.getPostEdits()?.status,
56
+ hasNonPostEntityChanges: store.hasNonPostEntityChanges(),
57
+ isSavingNonPostEntityChanges: store.isSavingNonPostEntityChanges(),
58
+ };
59
+ }, [] );
20
60
 
21
- this.createOnClick = this.createOnClick.bind( this );
22
- this.closeEntitiesSavedStates =
23
- this.closeEntitiesSavedStates.bind( this );
61
+ const { editPost, savePost } = useDispatch( editorStore );
24
62
 
25
- this.state = {
26
- entitiesSavedStatesCallback: false,
27
- };
28
- }
63
+ const savePostStatus = ( status ) => {
64
+ editPost( { status }, { undoIgnore: true } );
65
+ savePost();
66
+ };
29
67
 
30
- createOnClick( callback ) {
31
- return ( ...args ) => {
32
- const { hasNonPostEntityChanges, setEntitiesSavedStatesCallback } =
33
- this.props;
68
+ const createOnClick =
69
+ ( callback ) =>
70
+ ( ...args ) => {
34
71
  // If a post with non-post entities is published, but the user
35
72
  // elects to not save changes to the non-post entities, those
36
73
  // entities will still be dirty when the Publish button is clicked.
37
74
  // We also need to check that the `setEntitiesSavedStatesCallback`
38
75
  // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
39
76
  if ( hasNonPostEntityChanges && setEntitiesSavedStatesCallback ) {
40
- // The modal for multiple entity saving will open,
41
- // hold the callback for saving/publishing the post
42
- // so that we can call it if the post entity is checked.
43
- this.setState( {
44
- entitiesSavedStatesCallback: () => callback( ...args ),
45
- } );
77
+ // The modal for multiple entity saving will open. If the post
78
+ // entity is checked when it closes, run the held callback.
79
+ const onClose = ( savedEntities ) => {
80
+ if (
81
+ savedEntities &&
82
+ savedEntities.some(
83
+ ( elt ) =>
84
+ elt.kind === 'postType' &&
85
+ elt.name === postType &&
86
+ elt.key === postId
87
+ )
88
+ ) {
89
+ callback( ...args );
90
+ }
91
+ };
46
92
 
47
93
  // Open the save panel by setting its callback.
48
94
  // To set a function on the useState hook, we must set it
49
95
  // with another function (() => myFunction). Passing the
50
96
  // function on its own will cause an error when called.
51
- setEntitiesSavedStatesCallback(
52
- () => this.closeEntitiesSavedStates
53
- );
97
+ setEntitiesSavedStatesCallback( () => onClose );
54
98
  return noop;
55
99
  }
56
100
 
57
101
  return callback( ...args );
58
102
  };
59
- }
60
103
 
61
- closeEntitiesSavedStates( savedEntities ) {
62
- const { postType, postId } = this.props;
63
- const { entitiesSavedStatesCallback } = this.state;
64
- this.setState( { entitiesSavedStatesCallback: false }, () => {
65
- if (
66
- savedEntities &&
67
- savedEntities.some(
68
- ( elt ) =>
69
- elt.kind === 'postType' &&
70
- elt.name === postType &&
71
- elt.key === postId
72
- )
73
- ) {
74
- // The post entity was checked, call the held callback from `createOnClick`.
75
- entitiesSavedStatesCallback();
76
- }
77
- } );
104
+ const isButtonDisabled =
105
+ isPostSavingLocked ||
106
+ ( ( isSaving ||
107
+ ! isSaveable ||
108
+ ( ! isPublishable && ! forceIsDirty ) ) &&
109
+ ( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
110
+
111
+ const isToggleDisabled =
112
+ isPostSavingLocked ||
113
+ ( ( isPublished ||
114
+ isSaving ||
115
+ ! isSaveable ||
116
+ ( ! isPublishable && ! forceIsDirty ) ) &&
117
+ ( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
118
+
119
+ // If the new status has not changed explicitly, we derive it from
120
+ // other factors, like having a publish action, etc.. We need to preserve
121
+ // this because it affects when to show the pre and post publish panels.
122
+ // If it has changed though explicitly, we need to respect that.
123
+ let publishStatus = 'publish';
124
+ if ( postStatusHasChanged ) {
125
+ publishStatus = postStatus;
126
+ } else if ( ! hasPublishAction ) {
127
+ publishStatus = 'pending';
128
+ } else if ( visibility === 'private' ) {
129
+ publishStatus = 'private';
130
+ } else if ( isBeingScheduled ) {
131
+ publishStatus = 'future';
78
132
  }
79
133
 
80
- render() {
81
- const {
82
- forceIsDirty,
83
- hasPublishAction,
84
- isBeingScheduled,
85
- isOpen,
86
- isPostSavingLocked,
87
- isPublishable,
88
- isPublished,
89
- isSaveable,
90
- isSaving,
91
- isAutoSaving,
92
- isToggle,
93
- savePostStatus,
94
- onSubmit = noop,
95
- onToggle,
96
- visibility,
97
- hasNonPostEntityChanges,
98
- isSavingNonPostEntityChanges,
99
- postStatus,
100
- postStatusHasChanged,
101
- } = this.props;
102
-
103
- const isButtonDisabled =
104
- isPostSavingLocked ||
105
- ( ( isSaving ||
106
- ! isSaveable ||
107
- ( ! isPublishable && ! forceIsDirty ) ) &&
108
- ( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
109
-
110
- const isToggleDisabled =
111
- isPostSavingLocked ||
112
- ( ( isPublished ||
113
- isSaving ||
114
- ! isSaveable ||
115
- ( ! isPublishable && ! forceIsDirty ) ) &&
116
- ( ! hasNonPostEntityChanges || isSavingNonPostEntityChanges ) );
117
-
118
- // If the new status has not changed explicitly, we derive it from
119
- // other factors, like having a publish action, etc.. We need to preserve
120
- // this because it affects when to show the pre and post publish panels.
121
- // If it has changed though explicitly, we need to respect that.
122
- let publishStatus = 'publish';
123
- if ( postStatusHasChanged ) {
124
- publishStatus = postStatus;
125
- } else if ( ! hasPublishAction ) {
126
- publishStatus = 'pending';
127
- } else if ( visibility === 'private' ) {
128
- publishStatus = 'private';
129
- } else if ( isBeingScheduled ) {
130
- publishStatus = 'future';
134
+ const onClickButton = () => {
135
+ if ( isButtonDisabled ) {
136
+ return;
131
137
  }
132
-
133
- const onClickButton = () => {
134
- if ( isButtonDisabled ) {
135
- return;
136
- }
137
- onSubmit();
138
- savePostStatus( publishStatus );
139
- };
140
-
141
- // Callback to open the publish panel.
142
- const onClickToggle = () => {
143
- if ( isToggleDisabled ) {
144
- return;
145
- }
146
- onToggle();
147
- };
148
-
149
- const buttonProps = {
150
- 'aria-disabled': isButtonDisabled,
151
- className: 'editor-post-publish-button',
152
- isBusy: ! isAutoSaving && isSaving,
153
- variant: 'primary',
154
- onClick: this.createOnClick( onClickButton ),
155
- 'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined,
156
- };
157
-
158
- const toggleProps = {
159
- 'aria-disabled': isToggleDisabled,
160
- 'aria-expanded': isOpen,
161
- className: 'editor-post-publish-panel__toggle',
162
- isBusy: isSaving && isPublished,
163
- variant: 'primary',
164
- size: 'compact',
165
- onClick: this.createOnClick( onClickToggle ),
166
- 'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined,
167
- };
168
- const componentProps = isToggle ? toggleProps : buttonProps;
169
- return (
170
- <>
171
- <Button
172
- { ...componentProps }
173
- className={ `${ componentProps.className } editor-post-publish-button__button` }
174
- size="compact"
175
- >
176
- <PublishButtonLabel />
177
- </Button>
178
- </>
179
- );
180
- }
138
+ onSubmit();
139
+ savePostStatus( publishStatus );
140
+ };
141
+
142
+ // Callback to open the publish panel.
143
+ const onClickToggle = () => {
144
+ if ( isToggleDisabled ) {
145
+ return;
146
+ }
147
+ onToggle();
148
+ };
149
+
150
+ const buttonProps = {
151
+ 'aria-disabled': isButtonDisabled,
152
+ className: 'editor-post-publish-button',
153
+ isBusy: ! isAutoSaving && isSaving,
154
+ variant: 'primary',
155
+ onClick: createOnClick( onClickButton ),
156
+ 'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined,
157
+ };
158
+
159
+ const toggleProps = {
160
+ 'aria-disabled': isToggleDisabled,
161
+ 'aria-expanded': isOpen,
162
+ className: 'editor-post-publish-panel__toggle',
163
+ isBusy: isSaving && isPublished,
164
+ variant: 'primary',
165
+ size: 'compact',
166
+ onClick: createOnClick( onClickToggle ),
167
+ 'aria-haspopup': hasNonPostEntityChanges ? 'dialog' : undefined,
168
+ };
169
+ const componentProps = isToggle ? toggleProps : buttonProps;
170
+ return (
171
+ <Button
172
+ { ...componentProps }
173
+ className={ `${ componentProps.className } editor-post-publish-button__button` }
174
+ size="compact"
175
+ >
176
+ <PublishButtonLabel />
177
+ </Button>
178
+ );
181
179
  }
182
180
 
183
181
  /**
184
182
  * Renders the publish button.
185
183
  */
186
- export default compose( [
187
- withSelect( ( select ) => {
188
- const {
189
- isSavingPost,
190
- isAutosavingPost,
191
- isEditedPostBeingScheduled,
192
- getEditedPostVisibility,
193
- isCurrentPostPublished,
194
- isEditedPostSaveable,
195
- isEditedPostPublishable,
196
- isPostSavingLocked,
197
- getCurrentPost,
198
- getCurrentPostType,
199
- getCurrentPostId,
200
- hasNonPostEntityChanges,
201
- isSavingNonPostEntityChanges,
202
- getEditedPostAttribute,
203
- getPostEdits,
204
- } = select( editorStore );
205
- return {
206
- isSaving: isSavingPost(),
207
- isAutoSaving: isAutosavingPost(),
208
- isBeingScheduled: isEditedPostBeingScheduled(),
209
- visibility: getEditedPostVisibility(),
210
- isSaveable: isEditedPostSaveable(),
211
- isPostSavingLocked: isPostSavingLocked(),
212
- isPublishable: isEditedPostPublishable(),
213
- isPublished: isCurrentPostPublished(),
214
- hasPublishAction:
215
- getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,
216
- postType: getCurrentPostType(),
217
- postId: getCurrentPostId(),
218
- postStatus: getEditedPostAttribute( 'status' ),
219
- postStatusHasChanged: getPostEdits()?.status,
220
- hasNonPostEntityChanges: hasNonPostEntityChanges(),
221
- isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
222
- };
223
- } ),
224
- withDispatch( ( dispatch ) => {
225
- const { editPost, savePost } = dispatch( editorStore );
226
- return {
227
- savePostStatus: ( status ) => {
228
- editPost( { status }, { undoIgnore: true } );
229
- savePost();
230
- },
231
- };
232
- } ),
233
- ] )( PostPublishButton );
184
+ export default PostPublishButton;