@wordpress/editor 12.2.1 → 12.4.0-next.e230fbab09.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 (152) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/deprecated.js +1 -1
  3. package/build/components/deprecated.js.map +1 -1
  4. package/build/components/deprecated.native.js.map +1 -1
  5. package/build/components/editor-help/index.native.js.map +1 -1
  6. package/build/components/entities-saved-states/entity-record-item.js +1 -1
  7. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  8. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  9. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  10. package/build/components/index.js.map +1 -1
  11. package/build/components/index.native.js.map +1 -1
  12. package/build/components/local-autosave-monitor/index.js +5 -5
  13. package/build/components/local-autosave-monitor/index.js.map +1 -1
  14. package/build/components/post-featured-image/index.js +4 -4
  15. package/build/components/post-featured-image/index.js.map +1 -1
  16. package/build/components/post-last-revision/index.js +3 -3
  17. package/build/components/post-last-revision/index.js.map +1 -1
  18. package/build/components/post-locked-modal/index.js +1 -3
  19. package/build/components/post-locked-modal/index.js.map +1 -1
  20. package/build/components/post-saved-state/index.js +1 -1
  21. package/build/components/post-saved-state/index.js.map +1 -1
  22. package/build/components/post-schedule/index.js +3 -3
  23. package/build/components/post-schedule/index.js.map +1 -1
  24. package/build/components/post-slug/index.js +2 -4
  25. package/build/components/post-slug/index.js.map +1 -1
  26. package/build/components/post-switch-to-draft-button/index.js +19 -14
  27. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  28. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  29. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  30. package/build/components/post-title/index.native.js +2 -2
  31. package/build/components/post-title/index.native.js.map +1 -1
  32. package/build/components/post-trash/index.js +15 -29
  33. package/build/components/post-trash/index.js.map +1 -1
  34. package/build/components/provider/index.js +1 -1
  35. package/build/components/provider/index.js.map +1 -1
  36. package/build/components/provider/index.native.js +24 -15
  37. package/build/components/provider/index.native.js.map +1 -1
  38. package/build/components/provider/use-block-editor-settings.js +3 -8
  39. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  40. package/build/store/actions.js +231 -225
  41. package/build/store/actions.js.map +1 -1
  42. package/build/store/actions.native.js +6 -4
  43. package/build/store/actions.native.js.map +1 -1
  44. package/build/store/index.js +1 -8
  45. package/build/store/index.js.map +1 -1
  46. package/build/store/{controls.js → local-autosave.js} +1 -18
  47. package/build/store/local-autosave.js.map +1 -0
  48. package/build/store/reducer.js +0 -2
  49. package/build/store/reducer.js.map +1 -1
  50. package/build/store/selectors.js +8 -10
  51. package/build/store/selectors.js.map +1 -1
  52. package/build/store/utils/notice-builder.js +9 -4
  53. package/build/store/utils/notice-builder.js.map +1 -1
  54. package/build/utils/url.js +9 -26
  55. package/build/utils/url.js.map +1 -1
  56. package/build-module/components/deprecated.js +1 -1
  57. package/build-module/components/deprecated.js.map +1 -1
  58. package/build-module/components/deprecated.native.js +1 -1
  59. package/build-module/components/deprecated.native.js.map +1 -1
  60. package/build-module/components/editor-help/index.native.js.map +1 -1
  61. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  62. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  63. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  64. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  65. package/build-module/components/index.js +3 -3
  66. package/build-module/components/index.js.map +1 -1
  67. package/build-module/components/index.native.js +3 -3
  68. package/build-module/components/index.native.js.map +1 -1
  69. package/build-module/components/local-autosave-monitor/index.js +1 -1
  70. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  71. package/build-module/components/post-featured-image/index.js +4 -4
  72. package/build-module/components/post-featured-image/index.js.map +1 -1
  73. package/build-module/components/post-last-revision/index.js +2 -2
  74. package/build-module/components/post-last-revision/index.js.map +1 -1
  75. package/build-module/components/post-locked-modal/index.js +1 -2
  76. package/build-module/components/post-locked-modal/index.js.map +1 -1
  77. package/build-module/components/post-saved-state/index.js +1 -1
  78. package/build-module/components/post-saved-state/index.js.map +1 -1
  79. package/build-module/components/post-schedule/index.js +3 -3
  80. package/build-module/components/post-schedule/index.js.map +1 -1
  81. package/build-module/components/post-slug/index.js +1 -2
  82. package/build-module/components/post-slug/index.js.map +1 -1
  83. package/build-module/components/post-switch-to-draft-button/index.js +22 -16
  84. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  85. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  86. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  87. package/build-module/components/post-title/index.native.js +2 -2
  88. package/build-module/components/post-title/index.native.js.map +1 -1
  89. package/build-module/components/post-trash/index.js +15 -27
  90. package/build-module/components/post-trash/index.js.map +1 -1
  91. package/build-module/components/provider/index.js +1 -1
  92. package/build-module/components/provider/index.js.map +1 -1
  93. package/build-module/components/provider/index.native.js +26 -17
  94. package/build-module/components/provider/index.native.js.map +1 -1
  95. package/build-module/components/provider/use-block-editor-settings.js +3 -8
  96. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  97. package/build-module/store/actions.js +208 -207
  98. package/build-module/store/actions.js.map +1 -1
  99. package/build-module/store/actions.native.js +3 -3
  100. package/build-module/store/actions.native.js.map +1 -1
  101. package/build-module/store/index.js +1 -6
  102. package/build-module/store/index.js.map +1 -1
  103. package/build-module/store/{controls.js → local-autosave.js} +1 -15
  104. package/build-module/store/local-autosave.js.map +1 -0
  105. package/build-module/store/reducer.js +0 -2
  106. package/build-module/store/reducer.js.map +1 -1
  107. package/build-module/store/selectors.js +8 -9
  108. package/build-module/store/selectors.js.map +1 -1
  109. package/build-module/store/utils/notice-builder.js +9 -4
  110. package/build-module/store/utils/notice-builder.js.map +1 -1
  111. package/build-module/utils/url.js +8 -25
  112. package/build-module/utils/url.js.map +1 -1
  113. package/package.json +26 -27
  114. package/src/components/deprecated.js +1 -1
  115. package/src/components/deprecated.native.js +1 -1
  116. package/src/components/document-outline/test/index.js +1 -1
  117. package/src/components/editor-help/index.native.js +2 -2
  118. package/src/components/entities-saved-states/entity-record-item.js +1 -1
  119. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  120. package/src/components/index.js +3 -3
  121. package/src/components/index.native.js +3 -3
  122. package/src/components/local-autosave-monitor/index.js +4 -1
  123. package/src/components/post-author/test/check.js +1 -1
  124. package/src/components/post-featured-image/index.js +4 -4
  125. package/src/components/post-last-revision/index.js +2 -2
  126. package/src/components/post-locked-modal/index.js +1 -2
  127. package/src/components/post-saved-state/index.js +1 -1
  128. package/src/components/post-saved-state/test/index.js +2 -2
  129. package/src/components/post-schedule/index.js +3 -3
  130. package/src/components/post-slug/index.js +1 -2
  131. package/src/components/post-switch-to-draft-button/index.js +35 -24
  132. package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  133. package/src/components/post-text-editor/test/index.js +1 -1
  134. package/src/components/post-title/index.native.js +2 -2
  135. package/src/components/post-trash/index.js +12 -24
  136. package/src/components/provider/index.js +1 -1
  137. package/src/components/provider/index.native.js +27 -23
  138. package/src/components/provider/use-block-editor-settings.js +3 -14
  139. package/src/store/actions.js +137 -249
  140. package/src/store/actions.native.js +3 -3
  141. package/src/store/index.js +0 -6
  142. package/src/store/{controls.js → local-autosave.js} +0 -8
  143. package/src/store/reducer.js +0 -2
  144. package/src/store/selectors.js +8 -9
  145. package/src/store/test/actions.js +244 -416
  146. package/src/store/test/selectors.js +1 -1
  147. package/src/store/utils/notice-builder.js +9 -4
  148. package/src/store/utils/test/notice-builder.js +1 -0
  149. package/src/utils/url.js +8 -30
  150. package/build/store/controls.js.map +0 -1
  151. package/build-module/store/controls.js.map +0 -1
  152. package/src/utils/test/url.js +0 -22
@@ -6,9 +6,8 @@ import { has } from 'lodash';
6
6
  * WordPress dependencies
7
7
  */
8
8
 
9
+ import apiFetch from '@wordpress/api-fetch';
9
10
  import deprecated from '@wordpress/deprecated';
10
- import { controls } from '@wordpress/data';
11
- import { apiFetch } from '@wordpress/data-controls';
12
11
  import { parse, synchronizeBlocksWithTemplate, __unstableSerializeAndClean } from '@wordpress/blocks';
13
12
  import { store as noticesStore } from '@wordpress/notices';
14
13
  import { store as coreStore } from '@wordpress/core-data';
@@ -17,7 +16,8 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
17
16
  * Internal dependencies
18
17
  */
19
18
 
20
- import { STORE_NAME, TRASH_POST_NOTICE_ID } from './constants';
19
+ import { TRASH_POST_NOTICE_ID } from './constants';
20
+ import { localAutosaveSet } from './local-autosave';
21
21
  import { getNotificationArgumentsForSaveSuccess, getNotificationArgumentsForSaveFail, getNotificationArgumentsForTrashFail } from './utils/notice-builder';
22
22
  /**
23
23
  * Returns an action generator used in signalling that editor has initialized with
@@ -28,15 +28,11 @@ import { getNotificationArgumentsForSaveSuccess, getNotificationArgumentsForSave
28
28
  * @param {Array?} template Block Template.
29
29
  */
30
30
 
31
- export function* setupEditor(post, edits, template) {
32
- yield resetPost(post);
33
- yield {
34
- type: 'SETUP_EDITOR',
35
- post,
36
- edits,
37
- template
38
- };
39
- yield setupEditorState(post); // Apply a template for new posts only, if exists.
31
+ export const setupEditor = (post, edits, template) => _ref => {
32
+ let {
33
+ dispatch
34
+ } = _ref;
35
+ dispatch.setupEditorState(post); // Apply a template for new posts only, if exists.
40
36
 
41
37
  const isNewPost = post.status === 'auto-draft';
42
38
 
@@ -54,15 +50,20 @@ export function* setupEditor(post, edits, template) {
54
50
 
55
51
  let blocks = parse(content);
56
52
  blocks = synchronizeBlocksWithTemplate(blocks, template);
57
- yield resetEditorBlocks(blocks, {
53
+ dispatch.resetEditorBlocks(blocks, {
58
54
  __unstableShouldCreateUndoLevel: false
59
55
  });
60
56
  }
61
57
 
62
- if (edits && Object.keys(edits).some(key => edits[key] !== (has(post, [key, 'raw']) ? post[key].raw : post[key]))) {
63
- yield editPost(edits);
58
+ if (edits && Object.values(edits).some(_ref2 => {
59
+ var _post$key$raw, _post$key;
60
+
61
+ let [key, edit] = _ref2;
62
+ return edit !== ((_post$key$raw = (_post$key = post[key]) === null || _post$key === void 0 ? void 0 : _post$key.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
63
+ })) {
64
+ dispatch.editPost(edits);
64
65
  }
65
- }
66
+ };
66
67
  /**
67
68
  * Returns an action object signalling that the editor is being destroyed and
68
69
  * that any necessary state or side-effect cleanup should occur.
@@ -79,45 +80,17 @@ export function __experimentalTearDownEditor() {
79
80
  * Returns an action object used in signalling that the latest version of the
80
81
  * post has been received, either by initialization or save.
81
82
  *
82
- * @param {Object} post Post object.
83
- *
84
- * @return {Object} Action object.
85
- */
86
-
87
- export function resetPost(post) {
88
- return {
89
- type: 'RESET_POST',
90
- post
91
- };
92
- }
93
- /**
94
- * Action for dispatching that a post update request has started.
95
- *
96
- * @param {Object} options
97
- *
98
- * @return {Object} An action object
99
- */
100
-
101
- export function __experimentalRequestPostUpdateStart() {
102
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
103
- return {
104
- type: 'REQUEST_POST_UPDATE_START',
105
- options
106
- };
107
- }
108
- /**
109
- * Action for dispatching that a post update request has finished.
110
- *
111
- * @param {Object} options
112
- *
113
- * @return {Object} An action object
83
+ * @deprecated Since WordPress 6.0.
114
84
  */
115
85
 
116
- export function __experimentalRequestPostUpdateFinish() {
117
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
86
+ export function resetPost() {
87
+ deprecated("wp.data.dispatch( 'core/editor' ).resetPost", {
88
+ since: '6.0',
89
+ version: '6.3',
90
+ alternative: 'Initialize the editor with the setupEditorState action'
91
+ });
118
92
  return {
119
- type: 'REQUEST_POST_UPDATE_FINISH',
120
- options
93
+ type: 'DO_NOTHING'
121
94
  };
122
95
  }
123
96
  /**
@@ -158,81 +131,96 @@ export function setupEditorState(post) {
158
131
  *
159
132
  * @param {Object} edits Post attributes to edit.
160
133
  * @param {Object} options Options for the edit.
161
- *
162
- * @yield {Object} Action object or control.
163
134
  */
164
135
 
165
- export function* editPost(edits, options) {
136
+ export const editPost = (edits, options) => _ref3 => {
137
+ let {
138
+ select,
139
+ registry
140
+ } = _ref3;
166
141
  const {
167
142
  id,
168
143
  type
169
- } = yield controls.select(STORE_NAME, 'getCurrentPost');
170
- yield controls.dispatch(coreStore, 'editEntityRecord', 'postType', type, id, edits, options);
171
- }
144
+ } = select.getCurrentPost();
145
+ registry.dispatch(coreStore).editEntityRecord('postType', type, id, edits, options);
146
+ };
172
147
  /**
173
- * Action generator for saving the current post in the editor.
148
+ * Action for saving the current post in the editor.
174
149
  *
175
150
  * @param {Object} options
176
151
  */
177
152
 
178
- export function* savePost() {
153
+ export const savePost = function () {
179
154
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
155
+ return async _ref4 => {
156
+ let {
157
+ select,
158
+ dispatch,
159
+ registry
160
+ } = _ref4;
161
+
162
+ if (!select.isEditedPostSaveable()) {
163
+ return;
164
+ }
180
165
 
181
- if (!(yield controls.select(STORE_NAME, 'isEditedPostSaveable'))) {
182
- return;
183
- }
184
-
185
- let edits = {
186
- content: yield controls.select(STORE_NAME, 'getEditedPostContent')
187
- };
166
+ const content = select.getEditedPostContent();
188
167
 
189
- if (!options.isAutosave) {
190
- yield controls.dispatch(STORE_NAME, 'editPost', edits, {
191
- undoIgnore: true
192
- });
193
- }
168
+ if (!options.isAutosave) {
169
+ dispatch.editPost({
170
+ content
171
+ }, {
172
+ undoIgnore: true
173
+ });
174
+ }
194
175
 
195
- yield __experimentalRequestPostUpdateStart(options);
196
- const previousRecord = yield controls.select(STORE_NAME, 'getCurrentPost');
197
- edits = {
198
- id: previousRecord.id,
199
- ...(yield controls.select(coreStore, 'getEntityRecordNonTransientEdits', 'postType', previousRecord.type, previousRecord.id)),
200
- ...edits
201
- };
202
- yield controls.dispatch(coreStore, 'saveEntityRecord', 'postType', previousRecord.type, edits, options);
203
- yield __experimentalRequestPostUpdateFinish(options);
204
- const error = yield controls.select(coreStore, 'getLastEntitySaveError', 'postType', previousRecord.type, previousRecord.id);
205
-
206
- if (error) {
207
- const args = getNotificationArgumentsForSaveFail({
208
- post: previousRecord,
209
- edits,
210
- error
176
+ const previousRecord = select.getCurrentPost();
177
+ const edits = {
178
+ id: previousRecord.id,
179
+ ...registry.select(coreStore).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
180
+ content
181
+ };
182
+ dispatch({
183
+ type: 'REQUEST_POST_UPDATE_START',
184
+ options
211
185
  });
212
-
213
- if (args.length) {
214
- yield controls.dispatch(noticesStore, 'createErrorNotice', ...args);
215
- }
216
- } else {
217
- const updatedRecord = yield controls.select(STORE_NAME, 'getCurrentPost');
218
- const args = getNotificationArgumentsForSaveSuccess({
219
- previousPost: previousRecord,
220
- post: updatedRecord,
221
- postType: yield controls.resolveSelect(coreStore, 'getPostType', updatedRecord.type),
186
+ await registry.dispatch(coreStore).saveEntityRecord('postType', previousRecord.type, edits, options);
187
+ dispatch({
188
+ type: 'REQUEST_POST_UPDATE_FINISH',
222
189
  options
223
190
  });
224
-
225
- if (args.length) {
226
- yield controls.dispatch(noticesStore, 'createSuccessNotice', ...args);
227
- } // Make sure that any edits after saving create an undo level and are
228
- // considered for change detection.
229
-
230
-
231
- if (!options.isAutosave) {
232
- yield controls.dispatch(blockEditorStore, '__unstableMarkLastChangeAsPersistent');
191
+ const error = registry.select(coreStore).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
192
+
193
+ if (error) {
194
+ const args = getNotificationArgumentsForSaveFail({
195
+ post: previousRecord,
196
+ edits,
197
+ error
198
+ });
199
+
200
+ if (args.length) {
201
+ registry.dispatch(noticesStore).createErrorNotice(...args);
202
+ }
203
+ } else {
204
+ const updatedRecord = select.getCurrentPost();
205
+ const args = getNotificationArgumentsForSaveSuccess({
206
+ previousPost: previousRecord,
207
+ post: updatedRecord,
208
+ postType: await registry.resolveSelect(coreStore).getPostType(updatedRecord.type),
209
+ options
210
+ });
211
+
212
+ if (args.length) {
213
+ registry.dispatch(noticesStore).createSuccessNotice(...args);
214
+ } // Make sure that any edits after saving create an undo level and are
215
+ // considered for change detection.
216
+
217
+
218
+ if (!options.isAutosave) {
219
+ registry.dispatch(blockEditorStore).__unstableMarkLastChangeAsPersistent();
220
+ }
233
221
  }
234
- }
235
- }
222
+ };
223
+ };
236
224
  /**
237
225
  * Action for refreshing the current post.
238
226
  *
@@ -250,29 +238,34 @@ export function refreshPost() {
250
238
  };
251
239
  }
252
240
  /**
253
- * Action generator for trashing the current post in the editor.
241
+ * Action for trashing the current post in the editor.
254
242
  */
255
243
 
256
- export function* trashPost() {
257
- const postTypeSlug = yield controls.select(STORE_NAME, 'getCurrentPostType');
258
- const postType = yield controls.resolveSelect(coreStore, 'getPostType', postTypeSlug);
259
- yield controls.dispatch(noticesStore, 'removeNotice', TRASH_POST_NOTICE_ID);
244
+ export const trashPost = () => async _ref5 => {
245
+ let {
246
+ select,
247
+ dispatch,
248
+ registry
249
+ } = _ref5;
250
+ const postTypeSlug = select.getCurrentPostType();
251
+ const postType = await registry.resolveSelect(coreStore).getPostType(postTypeSlug);
252
+ registry.dispatch(noticesStore).removeNotice(TRASH_POST_NOTICE_ID);
260
253
 
261
254
  try {
262
- const post = yield controls.select(STORE_NAME, 'getCurrentPost');
263
- yield apiFetch({
255
+ const post = select.getCurrentPost();
256
+ await apiFetch({
264
257
  path: `/wp/v2/${postType.rest_base}/${post.id}`,
265
258
  method: 'DELETE'
266
259
  });
267
- yield controls.dispatch(STORE_NAME, 'savePost');
260
+ await dispatch.savePost();
268
261
  } catch (error) {
269
- yield controls.dispatch(noticesStore, 'createErrorNotice', ...getNotificationArgumentsForTrashFail({
262
+ registry.dispatch(noticesStore).createErrorNotice(...getNotificationArgumentsForTrashFail({
270
263
  error
271
264
  }));
272
265
  }
273
- }
266
+ };
274
267
  /**
275
- * Action generator used in signalling that the post should autosave. This
268
+ * Action that autosaves the current post. This
276
269
  * includes server-side autosaving (default) and client-side (a.k.a. local)
277
270
  * autosaving (e.g. on the Web, the post might be committed to Session
278
271
  * Storage).
@@ -280,52 +273,52 @@ export function* trashPost() {
280
273
  * @param {Object?} options Extra flags to identify the autosave.
281
274
  */
282
275
 
283
- export function* autosave() {
276
+ export const autosave = function () {
284
277
  let {
285
278
  local = false,
286
279
  ...options
287
280
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
288
-
289
- if (local) {
290
- const post = yield controls.select(STORE_NAME, 'getCurrentPost');
291
- const isPostNew = yield controls.select(STORE_NAME, 'isEditedPostNew');
292
- const title = yield controls.select(STORE_NAME, 'getEditedPostAttribute', 'title');
293
- const content = yield controls.select(STORE_NAME, 'getEditedPostAttribute', 'content');
294
- const excerpt = yield controls.select(STORE_NAME, 'getEditedPostAttribute', 'excerpt');
295
- yield {
296
- type: 'LOCAL_AUTOSAVE_SET',
297
- postId: post.id,
298
- isPostNew,
299
- title,
300
- content,
301
- excerpt
302
- };
303
- } else {
304
- yield controls.dispatch(STORE_NAME, 'savePost', {
305
- isAutosave: true,
306
- ...options
307
- });
308
- }
309
- }
281
+ return async _ref6 => {
282
+ let {
283
+ select,
284
+ dispatch
285
+ } = _ref6;
286
+
287
+ if (local) {
288
+ const post = select.getCurrentPost();
289
+ const isPostNew = select.isEditedPostNew();
290
+ const title = select.getEditedPostAttribute('title');
291
+ const content = select.getEditedPostAttribute('content');
292
+ const excerpt = select.getEditedPostAttribute('excerpt');
293
+ localAutosaveSet(post.id, isPostNew, title, content, excerpt);
294
+ } else {
295
+ await dispatch.savePost({
296
+ isAutosave: true,
297
+ ...options
298
+ });
299
+ }
300
+ };
301
+ };
310
302
  /**
311
- * Returns an action object used in signalling that undo history should
312
- * restore last popped state.
313
- *
314
- * @yield {Object} Action object.
303
+ * Action that restores last popped state in undo history.
315
304
  */
316
305
 
317
- export function* redo() {
318
- yield controls.dispatch(coreStore, 'redo');
319
- }
306
+ export const redo = () => _ref7 => {
307
+ let {
308
+ registry
309
+ } = _ref7;
310
+ registry.dispatch(coreStore).redo();
311
+ };
320
312
  /**
321
- * Returns an action object used in signalling that undo history should pop.
322
- *
323
- * @yield {Object} Action object.
313
+ * Action that pops a record from undo history and undoes the edit.
324
314
  */
325
315
 
326
- export function* undo() {
327
- yield controls.dispatch(coreStore, 'undo');
328
- }
316
+ export const undo = () => _ref8 => {
317
+ let {
318
+ registry
319
+ } = _ref8;
320
+ registry.dispatch(coreStore).undo();
321
+ };
329
322
  /**
330
323
  * Action that creates an undo history record.
331
324
  *
@@ -343,10 +336,9 @@ export function createUndoLevel() {
343
336
  };
344
337
  }
345
338
  /**
346
- * Returns an action object used to lock the editor.
339
+ * Action that locks the editor.
347
340
  *
348
341
  * @param {Object} lock Details about the post lock status, user, and nonce.
349
- *
350
342
  * @return {Object} Action object.
351
343
  */
352
344
 
@@ -357,8 +349,7 @@ export function updatePostLock(lock) {
357
349
  };
358
350
  }
359
351
  /**
360
- * Returns an action object used in signalling that the user has enabled the
361
- * publish sidebar.
352
+ * Action that enables the publish sidebar.
362
353
  *
363
354
  * @return {Object} Action object
364
355
  */
@@ -369,8 +360,7 @@ export function enablePublishSidebar() {
369
360
  };
370
361
  }
371
362
  /**
372
- * Returns an action object used in signalling that the user has disabled the
373
- * publish sidebar.
363
+ * Action that disables the publish sidebar.
374
364
  *
375
365
  * @return {Object} Action object
376
366
  */
@@ -381,7 +371,7 @@ export function disablePublishSidebar() {
381
371
  };
382
372
  }
383
373
  /**
384
- * Returns an action object used to signal that post saving is locked.
374
+ * Action that locks post saving.
385
375
  *
386
376
  * @param {string} lockName The lock name.
387
377
  *
@@ -431,7 +421,7 @@ export function lockPostSaving(lockName) {
431
421
  };
432
422
  }
433
423
  /**
434
- * Returns an action object used to signal that post saving is unlocked.
424
+ * Action that unlocks post saving.
435
425
  *
436
426
  * @param {string} lockName The lock name.
437
427
  *
@@ -451,7 +441,7 @@ export function unlockPostSaving(lockName) {
451
441
  };
452
442
  }
453
443
  /**
454
- * Returns an action object used to signal that post autosaving is locked.
444
+ * Action that locks post autosaving.
455
445
  *
456
446
  * @param {string} lockName The lock name.
457
447
  *
@@ -471,7 +461,7 @@ export function lockPostAutosaving(lockName) {
471
461
  };
472
462
  }
473
463
  /**
474
- * Returns an action object used to signal that post autosaving is unlocked.
464
+ * Action that unlocks post autosaving.
475
465
  *
476
466
  * @param {string} lockName The lock name.
477
467
  *
@@ -495,45 +485,52 @@ export function unlockPostAutosaving(lockName) {
495
485
  *
496
486
  * @param {Array} blocks Block Array.
497
487
  * @param {?Object} options Optional options.
498
- *
499
- * @yield {Object} Action object
500
488
  */
501
489
 
502
- export function* resetEditorBlocks(blocks) {
490
+ export const resetEditorBlocks = function (blocks) {
503
491
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
504
- const {
505
- __unstableShouldCreateUndoLevel,
506
- selection
507
- } = options;
508
- const edits = {
509
- blocks,
510
- selection
511
- };
512
-
513
- if (__unstableShouldCreateUndoLevel !== false) {
492
+ return _ref9 => {
493
+ let {
494
+ select,
495
+ dispatch,
496
+ registry
497
+ } = _ref9;
514
498
  const {
515
- id,
516
- type
517
- } = yield controls.select(STORE_NAME, 'getCurrentPost');
518
- const noChange = (yield controls.select(coreStore, 'getEditedEntityRecord', 'postType', type, id)).blocks === edits.blocks;
519
-
520
- if (noChange) {
521
- return yield controls.dispatch(coreStore, '__unstableCreateUndoLevel', 'postType', type, id);
522
- } // We create a new function here on every persistent edit
523
- // to make sure the edit makes the post dirty and creates
524
- // a new undo level.
525
-
526
-
527
- edits.content = _ref => {
528
- let {
529
- blocks: blocksForSerialization = []
530
- } = _ref;
531
- return __unstableSerializeAndClean(blocksForSerialization);
499
+ __unstableShouldCreateUndoLevel,
500
+ selection
501
+ } = options;
502
+ const edits = {
503
+ blocks,
504
+ selection
532
505
  };
533
- }
534
506
 
535
- yield* editPost(edits);
536
- }
507
+ if (__unstableShouldCreateUndoLevel !== false) {
508
+ const {
509
+ id,
510
+ type
511
+ } = select.getCurrentPost();
512
+ const noChange = registry.select(coreStore).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
513
+
514
+ if (noChange) {
515
+ registry.dispatch(coreStore).__unstableCreateUndoLevel('postType', type, id);
516
+
517
+ return;
518
+ } // We create a new function here on every persistent edit
519
+ // to make sure the edit makes the post dirty and creates
520
+ // a new undo level.
521
+
522
+
523
+ edits.content = _ref10 => {
524
+ let {
525
+ blocks: blocksForSerialization = []
526
+ } = _ref10;
527
+ return __unstableSerializeAndClean(blocksForSerialization);
528
+ };
529
+ }
530
+
531
+ dispatch.editPost(edits);
532
+ };
533
+ };
537
534
  /*
538
535
  * Returns an action object used in signalling that the post editor settings have been updated.
539
536
  *
@@ -552,18 +549,22 @@ export function updateEditorSettings(settings) {
552
549
  * Backward compatibility
553
550
  */
554
551
 
555
- const getBlockEditorAction = name => function* () {
556
- deprecated("`wp.data.dispatch( 'core/editor' )." + name + '`', {
557
- since: '5.3',
558
- alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
559
- version: '6.2'
560
- });
561
-
552
+ const getBlockEditorAction = name => function () {
562
553
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
563
554
  args[_key] = arguments[_key];
564
555
  }
565
556
 
566
- yield controls.dispatch(blockEditorStore, name, ...args);
557
+ return _ref11 => {
558
+ let {
559
+ registry
560
+ } = _ref11;
561
+ deprecated("`wp.data.dispatch( 'core/editor' )." + name + '`', {
562
+ since: '5.3',
563
+ alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
564
+ version: '6.2'
565
+ });
566
+ registry.dispatch(blockEditorStore)[name](...args);
567
+ };
567
568
  };
568
569
  /**
569
570
  * @see resetBlocks in core/block-editor store.