@wordpress/edit-site 4.0.0 → 4.0.2

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 (81) hide show
  1. package/build/components/add-new-template/new-template-part.js +4 -1
  2. package/build/components/add-new-template/new-template-part.js.map +1 -1
  3. package/build/components/error-boundary/index.js +11 -27
  4. package/build/components/error-boundary/index.js.map +1 -1
  5. package/build/components/error-boundary/warning.js +70 -0
  6. package/build/components/error-boundary/warning.js.map +1 -0
  7. package/build/components/global-styles/navigation-button.js +7 -27
  8. package/build/components/global-styles/navigation-button.js.map +1 -1
  9. package/build/components/global-styles/typography-panel.js +5 -2
  10. package/build/components/global-styles/typography-panel.js.map +1 -1
  11. package/build/components/global-styles/use-global-styles-output.js +21 -4
  12. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  13. package/build/components/list/table.js +3 -1
  14. package/build/components/list/table.js.map +1 -1
  15. package/build/components/navigation-sidebar/navigation-toggle/index.js +15 -4
  16. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  17. package/build/components/routes/redirect-to-homepage.js +22 -3
  18. package/build/components/routes/redirect-to-homepage.js.map +1 -1
  19. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
  20. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  21. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  22. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  23. package/build/index.js +15 -1
  24. package/build/index.js.map +1 -1
  25. package/build/store/actions.js +191 -155
  26. package/build/store/actions.js.map +1 -1
  27. package/build/store/index.js +0 -3
  28. package/build/store/index.js.map +1 -1
  29. package/build/store/selectors.js +3 -2
  30. package/build/store/selectors.js.map +1 -1
  31. package/build-module/components/add-new-template/new-template-part.js +4 -1
  32. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  33. package/build-module/components/error-boundary/index.js +9 -26
  34. package/build-module/components/error-boundary/index.js.map +1 -1
  35. package/build-module/components/error-boundary/warning.js +60 -0
  36. package/build-module/components/error-boundary/warning.js.map +1 -0
  37. package/build-module/components/global-styles/navigation-button.js +8 -28
  38. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  39. package/build-module/components/global-styles/typography-panel.js +6 -3
  40. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  41. package/build-module/components/global-styles/use-global-styles-output.js +20 -4
  42. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  43. package/build-module/components/list/table.js +2 -1
  44. package/build-module/components/list/table.js.map +1 -1
  45. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -4
  46. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  47. package/build-module/components/routes/redirect-to-homepage.js +22 -3
  48. package/build-module/components/routes/redirect-to-homepage.js.map +1 -1
  49. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
  50. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  51. package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
  52. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  53. package/build-module/index.js +13 -1
  54. package/build-module/index.js.map +1 -1
  55. package/build-module/store/actions.js +170 -145
  56. package/build-module/store/actions.js.map +1 -1
  57. package/build-module/store/index.js +0 -2
  58. package/build-module/store/index.js.map +1 -1
  59. package/build-module/store/selectors.js +3 -2
  60. package/build-module/store/selectors.js.map +1 -1
  61. package/build-style/style-rtl.css +11 -10
  62. package/build-style/style.css +11 -10
  63. package/package.json +18 -18
  64. package/src/components/add-new-template/new-template-part.js +7 -1
  65. package/src/components/error-boundary/index.js +11 -28
  66. package/src/components/error-boundary/warning.js +59 -0
  67. package/src/components/global-styles/navigation-button.js +6 -25
  68. package/src/components/global-styles/typography-panel.js +12 -5
  69. package/src/components/global-styles/use-global-styles-output.js +19 -3
  70. package/src/components/list/table.js +5 -2
  71. package/src/components/navigation-sidebar/navigation-toggle/index.js +13 -4
  72. package/src/components/navigation-sidebar/navigation-toggle/style.scss +32 -31
  73. package/src/components/routes/redirect-to-homepage.js +27 -4
  74. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
  75. package/src/components/template-part-converter/convert-to-template-part.js +6 -1
  76. package/src/index.js +17 -1
  77. package/src/store/actions.js +161 -205
  78. package/src/store/index.js +0 -2
  79. package/src/store/selectors.js +3 -0
  80. package/src/store/test/actions.js +186 -92
  81. package/src/store/test/selectors.js +8 -1
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import apiFetch from '@wordpress/api-fetch';
4
5
  import { parse, __unstableSerializeAndClean } from '@wordpress/blocks';
5
- import { controls, dispatch } from '@wordpress/data';
6
- import { apiFetch } from '@wordpress/data-controls';
7
6
  import { addQueryArgs, getPathAndQueryString } from '@wordpress/url';
8
7
  import { __, sprintf } from '@wordpress/i18n';
9
8
  import { store as noticesStore } from '@wordpress/notices';
@@ -18,7 +17,7 @@ import { speak } from '@wordpress/a11y';
18
17
  import { STORE_NAME as editSiteStoreName } from './constants';
19
18
  import isTemplateRevertable from '../utils/is-template-revertable';
20
19
  /**
21
- * Returns an action object used to toggle a feature flag.
20
+ * Action that toggles a feature flag.
22
21
  *
23
22
  * @param {string} feature Feature name.
24
23
  *
@@ -32,7 +31,7 @@ export function toggleFeature(feature) {
32
31
  };
33
32
  }
34
33
  /**
35
- * Returns an action object used to toggle the width of the editing canvas.
34
+ * Action that changes the width of the editing canvas.
36
35
  *
37
36
  * @param {string} deviceType
38
37
  *
@@ -46,51 +45,58 @@ export function __experimentalSetPreviewDeviceType(deviceType) {
46
45
  };
47
46
  }
48
47
  /**
49
- * Returns an action object used to set a template.
48
+ * Action that sets a template, optionally fetching it from REST API.
50
49
  *
51
50
  * @param {number} templateId The template ID.
52
51
  * @param {string} templateSlug The template slug.
53
52
  * @return {Object} Action object.
54
53
  */
55
54
 
56
- export function* setTemplate(templateId, templateSlug) {
57
- const pageContext = {
58
- templateSlug
59
- };
55
+ export const setTemplate = (templateId, templateSlug) => async _ref => {
56
+ let {
57
+ dispatch,
58
+ registry
59
+ } = _ref;
60
60
 
61
61
  if (!templateSlug) {
62
- const template = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'postType', 'wp_template', templateId);
63
- pageContext.templateSlug = template === null || template === void 0 ? void 0 : template.slug;
62
+ const template = await registry.resolveSelect(coreStore).getEntityRecord('postType', 'wp_template', templateId);
63
+ templateSlug = template === null || template === void 0 ? void 0 : template.slug;
64
64
  }
65
65
 
66
- return {
66
+ dispatch({
67
67
  type: 'SET_TEMPLATE',
68
68
  templateId,
69
69
  page: {
70
- context: pageContext
70
+ context: {
71
+ templateSlug
72
+ }
71
73
  }
72
- };
73
- }
74
+ });
75
+ };
74
76
  /**
75
- * Adds a new template, and sets it as the current template.
77
+ * Action that adds a new template and sets it as the current template.
76
78
  *
77
79
  * @param {Object} template The template.
78
80
  *
79
81
  * @return {Object} Action object used to set the current template.
80
82
  */
81
83
 
82
- export function* addTemplate(template) {
83
- const newTemplate = yield controls.dispatch(coreStore, 'saveEntityRecord', 'postType', 'wp_template', template);
84
+ export const addTemplate = template => async _ref2 => {
85
+ let {
86
+ dispatch,
87
+ registry
88
+ } = _ref2;
89
+ const newTemplate = await registry.dispatch(coreStore).saveEntityRecord('postType', 'wp_template', template);
84
90
 
85
91
  if (template.content) {
86
- yield controls.dispatch(coreStore, 'editEntityRecord', 'postType', 'wp_template', newTemplate.id, {
92
+ registry.dispatch(coreStore).editEntityRecord('postType', 'wp_template', newTemplate.id, {
87
93
  blocks: parse(template.content)
88
94
  }, {
89
95
  undoIgnore: true
90
96
  });
91
97
  }
92
98
 
93
- return {
99
+ dispatch({
94
100
  type: 'SET_TEMPLATE',
95
101
  templateId: newTemplate.id,
96
102
  page: {
@@ -98,39 +104,43 @@ export function* addTemplate(template) {
98
104
  templateSlug: newTemplate.slug
99
105
  }
100
106
  }
101
- };
102
- }
107
+ });
108
+ };
103
109
  /**
104
- * Removes a template.
110
+ * Action that removes a template.
105
111
  *
106
112
  * @param {Object} template The template object.
107
113
  */
108
114
 
109
- export function* removeTemplate(template) {
115
+ export const removeTemplate = template => async _ref3 => {
116
+ let {
117
+ registry
118
+ } = _ref3;
119
+
110
120
  try {
111
- yield controls.dispatch(coreStore, 'deleteEntityRecord', 'postType', template.type, template.id, {
121
+ await registry.dispatch(coreStore).deleteEntityRecord('postType', template.type, template.id, {
112
122
  force: true
113
123
  });
114
- const lastError = yield controls.select(coreStore, 'getLastEntityDeleteError', 'postType', template.type, template.id);
124
+ const lastError = registry.select(coreStore).getLastEntityDeleteError('postType', template.type, template.id);
115
125
 
116
126
  if (lastError) {
117
127
  throw lastError;
118
128
  }
119
129
 
120
- yield controls.dispatch(noticesStore, 'createSuccessNotice', sprintf(
130
+ registry.dispatch(noticesStore).createSuccessNotice(sprintf(
121
131
  /* translators: The template/part's name. */
122
132
  __('"%s" deleted.'), template.title.rendered), {
123
133
  type: 'snackbar'
124
134
  });
125
135
  } catch (error) {
126
136
  const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while deleting the template.');
127
- yield controls.dispatch(noticesStore, 'createErrorNotice', errorMessage, {
137
+ registry.dispatch(noticesStore).createErrorNotice(errorMessage, {
128
138
  type: 'snackbar'
129
139
  });
130
140
  }
131
- }
141
+ };
132
142
  /**
133
- * Returns an action object used to set a template part.
143
+ * Action that sets a template part.
134
144
  *
135
145
  * @param {string} templatePartId The template part ID.
136
146
  *
@@ -144,8 +154,8 @@ export function setTemplatePart(templatePartId) {
144
154
  };
145
155
  }
146
156
  /**
147
- * Updates the homeTemplateId state with the templateId of the page resolved
148
- * from the given path.
157
+ * Action that sets the home template ID to the template ID of the page resolved
158
+ * from a given path.
149
159
  *
150
160
  * @param {number} homeTemplateId The template ID for the homepage.
151
161
  */
@@ -169,32 +179,39 @@ export function setHomeTemplateId(homeTemplateId) {
169
179
  * @return {number} The resolved template ID for the page route.
170
180
  */
171
181
 
172
- export function* setPage(page) {
182
+ export const setPage = page => async _ref4 => {
173
183
  var _page$context;
174
184
 
185
+ let {
186
+ dispatch,
187
+ registry
188
+ } = _ref4;
189
+
175
190
  if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
176
- const entity = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'postType', page.context.postType || 'post', page.context.postId); // If the entity is undefined for some reason, path will resolve to "/"
191
+ const entity = await registry.resolveSelect(coreStore).getEntityRecord('postType', page.context.postType || 'post', page.context.postId); // If the entity is undefined for some reason, path will resolve to "/"
177
192
 
178
193
  page.path = getPathAndQueryString(entity === null || entity === void 0 ? void 0 : entity.link);
179
194
  }
180
195
 
181
- const {
182
- id: templateId,
183
- slug: templateSlug
184
- } = yield controls.resolveSelect(coreStore, '__experimentalGetTemplateForLink', page.path);
185
- yield {
196
+ const template = await registry.resolveSelect(coreStore).__experimentalGetTemplateForLink(page.path);
197
+
198
+ if (!template) {
199
+ return;
200
+ }
201
+
202
+ dispatch({
186
203
  type: 'SET_PAGE',
187
- page: !templateSlug ? page : { ...page,
204
+ page: template.slug ? { ...page,
188
205
  context: { ...page.context,
189
- templateSlug
206
+ templateSlug: template.slug
190
207
  }
191
- },
192
- templateId
193
- };
194
- return templateId;
195
- }
208
+ } : page,
209
+ templateId: template.id
210
+ });
211
+ return template.id;
212
+ };
196
213
  /**
197
- * Returns an action object used to set the active navigation panel menu.
214
+ * Action that sets the active navigation panel menu.
198
215
  *
199
216
  * @param {string} menu Menu prop of active menu.
200
217
  *
@@ -233,7 +250,7 @@ export function setIsNavigationPanelOpened(isOpen) {
233
250
  };
234
251
  }
235
252
  /**
236
- * Returns an action object used to open/close the inserter.
253
+ * Opens or closes the inserter.
237
254
  *
238
255
  * @param {boolean|Object} value Whether the inserter should be
239
256
  * opened (true) or closed (false).
@@ -287,136 +304,144 @@ export function setIsListViewOpened(isOpen) {
287
304
  * reverting the template. Default true.
288
305
  */
289
306
 
290
- export function* revertTemplate(template) {
307
+ export const revertTemplate = function (template) {
291
308
  let {
292
309
  allowUndo = true
293
310
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
311
+ return async _ref5 => {
312
+ let {
313
+ registry
314
+ } = _ref5;
294
315
 
295
- if (!isTemplateRevertable(template)) {
296
- yield controls.dispatch(noticesStore, 'createErrorNotice', __('This template is not revertable.'), {
297
- type: 'snackbar'
298
- });
299
- return;
300
- }
301
-
302
- try {
303
- var _fileTemplate$content;
304
-
305
- const templateEntity = yield controls.select(coreStore, 'getEntity', 'postType', template.type);
306
-
307
- if (!templateEntity) {
308
- yield controls.dispatch(noticesStore, 'createErrorNotice', __('The editor has encountered an unexpected error. Please reload.'), {
316
+ if (!isTemplateRevertable(template)) {
317
+ registry.dispatch(noticesStore).createErrorNotice(__('This template is not revertable.'), {
309
318
  type: 'snackbar'
310
319
  });
311
320
  return;
312
321
  }
313
322
 
314
- const fileTemplatePath = addQueryArgs(`${templateEntity.baseURL}/${template.id}`, {
315
- context: 'edit',
316
- source: 'theme'
317
- });
318
- const fileTemplate = yield apiFetch({
319
- path: fileTemplatePath
320
- });
323
+ try {
324
+ var _fileTemplate$content;
321
325
 
322
- if (!fileTemplate) {
323
- yield controls.dispatch(noticesStore, 'createErrorNotice', __('The editor has encountered an unexpected error. Please reload.'), {
324
- type: 'snackbar'
326
+ const templateEntity = registry.select(coreStore).getEntity('postType', template.type);
327
+
328
+ if (!templateEntity) {
329
+ registry.dispatch(noticesStore).createErrorNotice(__('The editor has encountered an unexpected error. Please reload.'), {
330
+ type: 'snackbar'
331
+ });
332
+ return;
333
+ }
334
+
335
+ const fileTemplatePath = addQueryArgs(`${templateEntity.baseURL}/${template.id}`, {
336
+ context: 'edit',
337
+ source: 'theme'
325
338
  });
326
- return;
327
- }
339
+ const fileTemplate = await apiFetch({
340
+ path: fileTemplatePath
341
+ });
342
+
343
+ if (!fileTemplate) {
344
+ registry.dispatch(noticesStore).createErrorNotice(__('The editor has encountered an unexpected error. Please reload.'), {
345
+ type: 'snackbar'
346
+ });
347
+ return;
348
+ }
328
349
 
329
- const serializeBlocks = _ref => {
330
- let {
331
- blocks: blocksForSerialization = []
332
- } = _ref;
333
- return __unstableSerializeAndClean(blocksForSerialization);
334
- };
350
+ const serializeBlocks = _ref6 => {
351
+ let {
352
+ blocks: blocksForSerialization = []
353
+ } = _ref6;
354
+ return __unstableSerializeAndClean(blocksForSerialization);
355
+ };
335
356
 
336
- const edited = yield controls.select(coreStore, 'getEditedEntityRecord', 'postType', template.type, template.id); // We are fixing up the undo level here to make sure we can undo
337
- // the revert in the header toolbar correctly.
357
+ const edited = registry.select(coreStore).getEditedEntityRecord('postType', template.type, template.id); // We are fixing up the undo level here to make sure we can undo
358
+ // the revert in the header toolbar correctly.
338
359
 
339
- yield controls.dispatch(coreStore, 'editEntityRecord', 'postType', template.type, template.id, {
340
- content: serializeBlocks,
341
- // required to make the `undo` behave correctly
342
- blocks: edited.blocks,
343
- // required to revert the blocks in the editor
344
- source: 'custom' // required to avoid turning the editor into a dirty state
360
+ registry.dispatch(coreStore).editEntityRecord('postType', template.type, template.id, {
361
+ content: serializeBlocks,
362
+ // required to make the `undo` behave correctly
363
+ blocks: edited.blocks,
364
+ // required to revert the blocks in the editor
365
+ source: 'custom' // required to avoid turning the editor into a dirty state
345
366
 
346
- }, {
347
- undoIgnore: true // required to merge this edit with the last undo level
367
+ }, {
368
+ undoIgnore: true // required to merge this edit with the last undo level
348
369
 
349
- });
350
- const blocks = parse(fileTemplate === null || fileTemplate === void 0 ? void 0 : (_fileTemplate$content = fileTemplate.content) === null || _fileTemplate$content === void 0 ? void 0 : _fileTemplate$content.raw);
351
- yield controls.dispatch(coreStore, 'editEntityRecord', 'postType', template.type, fileTemplate.id, {
352
- content: serializeBlocks,
353
- blocks,
354
- source: 'theme'
355
- });
370
+ });
371
+ const blocks = parse(fileTemplate === null || fileTemplate === void 0 ? void 0 : (_fileTemplate$content = fileTemplate.content) === null || _fileTemplate$content === void 0 ? void 0 : _fileTemplate$content.raw);
372
+ registry.dispatch(coreStore).editEntityRecord('postType', template.type, fileTemplate.id, {
373
+ content: serializeBlocks,
374
+ blocks,
375
+ source: 'theme'
376
+ });
356
377
 
357
- if (allowUndo) {
358
- const undoRevert = async () => {
359
- await dispatch(coreStore).editEntityRecord('postType', template.type, edited.id, {
360
- content: serializeBlocks,
361
- blocks: edited.blocks,
362
- source: 'custom'
378
+ if (allowUndo) {
379
+ const undoRevert = () => {
380
+ registry.dispatch(coreStore).editEntityRecord('postType', template.type, edited.id, {
381
+ content: serializeBlocks,
382
+ blocks: edited.blocks,
383
+ source: 'custom'
384
+ });
385
+ };
386
+
387
+ registry.dispatch(noticesStore).createSuccessNotice(__('Template reverted.'), {
388
+ type: 'snackbar',
389
+ actions: [{
390
+ label: __('Undo'),
391
+ onClick: undoRevert
392
+ }]
363
393
  });
364
- };
365
-
366
- yield controls.dispatch(noticesStore, 'createSuccessNotice', __('Template reverted.'), {
367
- type: 'snackbar',
368
- actions: [{
369
- label: __('Undo'),
370
- onClick: undoRevert
371
- }]
394
+ } else {
395
+ registry.dispatch(noticesStore).createSuccessNotice(__('Template reverted.'));
396
+ }
397
+ } catch (error) {
398
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('Template revert failed. Please reload.');
399
+ registry.dispatch(noticesStore).createErrorNotice(errorMessage, {
400
+ type: 'snackbar'
372
401
  });
373
- } else {
374
- yield controls.dispatch(noticesStore, 'createSuccessNotice', __('Template reverted.'));
375
402
  }
376
- } catch (error) {
377
- const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('Template revert failed. Please reload.');
378
- yield controls.dispatch(noticesStore, 'createErrorNotice', errorMessage, {
379
- type: 'snackbar'
380
- });
381
- }
382
- }
403
+ };
404
+ };
383
405
  /**
384
- * Returns an action object used in signalling that the user opened an editor sidebar.
406
+ * Action that opens an editor sidebar.
385
407
  *
386
408
  * @param {?string} name Sidebar name to be opened.
387
- *
388
- * @yield {Object} Action object.
389
409
  */
390
410
 
391
- export function* openGeneralSidebar(name) {
392
- yield controls.dispatch(interfaceStore, 'enableComplementaryArea', editSiteStoreName, name);
393
- }
411
+ export const openGeneralSidebar = name => _ref7 => {
412
+ let {
413
+ registry
414
+ } = _ref7;
415
+ registry.dispatch(interfaceStore).enableComplementaryArea(editSiteStoreName, name);
416
+ };
394
417
  /**
395
- * Returns an action object signalling that the user closed the sidebar.
396
- *
397
- * @yield {Object} Action object.
418
+ * Action that closes the sidebar.
398
419
  */
399
420
 
400
- export function* closeGeneralSidebar() {
401
- yield controls.dispatch(interfaceStore, 'disableComplementaryArea', editSiteStoreName);
402
- }
403
- export function* switchEditorMode(mode) {
404
- yield {
421
+ export const closeGeneralSidebar = () => _ref8 => {
422
+ let {
423
+ registry
424
+ } = _ref8;
425
+ registry.dispatch(interfaceStore).disableComplementaryArea(editSiteStoreName);
426
+ };
427
+ export const switchEditorMode = mode => _ref9 => {
428
+ let {
429
+ dispatch,
430
+ registry
431
+ } = _ref9;
432
+ dispatch({
405
433
  type: 'SWITCH_MODE',
406
434
  mode
407
- }; // Unselect blocks when we switch to a non visual mode.
435
+ }); // Unselect blocks when we switch to a non visual mode.
408
436
 
409
437
  if (mode !== 'visual') {
410
- yield controls.dispatch(blockEditorStore.name, 'clearSelectedBlock');
438
+ registry.dispatch(blockEditorStore).clearSelectedBlock();
411
439
  }
412
440
 
413
- const messages = {
414
- visual: __('Visual editor selected'),
415
- mosaic: __('Mosaic view selected')
416
- };
417
-
418
- if (messages[mode]) {
419
- speak(messages[mode], 'assertive');
441
+ if (mode === 'visual') {
442
+ speak(__('Visual editor selected'), 'assertive');
443
+ } else if (mode === 'mosaic') {
444
+ speak(__('Mosaic view selected'), 'assertive');
420
445
  }
421
- }
446
+ };
422
447
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["parse","__unstableSerializeAndClean","controls","dispatch","apiFetch","addQueryArgs","getPathAndQueryString","__","sprintf","store","noticesStore","coreStore","interfaceStore","blockEditorStore","speak","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","resolveSelect","slug","page","context","addTemplate","newTemplate","content","id","blocks","undoIgnore","removeTemplate","force","lastError","select","title","rendered","error","errorMessage","message","code","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","openGeneralSidebar","name","closeGeneralSidebar","switchEditorMode","mode","messages","visual","mosaic"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,iBAAnC;AACA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,cAAlB,QAAwC,sBAAxC;AACA,SAASH,KAAK,IAAII,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,UAAU,IAAIC,iBAAvB,QAAgD,aAAhD;AACA,OAAOC,oBAAP,MAAiC,iCAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;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pF,EAAE,CAAE,sBAAF;AAFM,GAAjB;;AAIA,MAAKkF,QAAQ,CAAED,IAAF,CAAb,EAAwB;AACvB1E,IAAAA,KAAK,CAAE2E,QAAQ,CAAED,IAAF,CAAV,EAAoB,WAApB,CAAL;AACA;AACD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * Adds a new template, and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template.\n *\n * @param {Object} template The template object.\n */\nexport function* removeTemplate( template ) {\n\ttry {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'deleteEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{ force: true }\n\t\t);\n\n\t\tconst lastError = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getLastEntityDeleteError',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n\n/**\n * Returns an action object used to set a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\tpage.path = getPathAndQueryString( entity?.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport function* revertTemplate( template, { allowUndo = true } = {} ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = async () => {\n\t\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' )\n\t\t\t);\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n\nexport function* switchEditorMode( mode ) {\n\tyield {\n\t\ttype: 'SWITCH_MODE',\n\t\tmode,\n\t};\n\n\t// Unselect blocks when we switch to a non visual mode.\n\tif ( mode !== 'visual' ) {\n\t\tyield controls.dispatch( blockEditorStore.name, 'clearSelectedBlock' );\n\t}\n\tconst messages = {\n\t\tvisual: __( 'Visual editor selected' ),\n\t\tmosaic: __( 'Mosaic view selected' ),\n\t};\n\tif ( messages[ mode ] ) {\n\t\tspeak( messages[ mode ], 'assertive' );\n\t}\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["apiFetch","parse","__unstableSerializeAndClean","addQueryArgs","getPathAndQueryString","__","sprintf","store","noticesStore","coreStore","interfaceStore","blockEditorStore","speak","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","dispatch","registry","template","resolveSelect","getEntityRecord","slug","page","context","addTemplate","newTemplate","saveEntityRecord","content","editEntityRecord","id","blocks","undoIgnore","removeTemplate","deleteEntityRecord","force","lastError","select","getLastEntityDeleteError","createSuccessNotice","title","rendered","error","errorMessage","message","code","createErrorNotice","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","__experimentalGetTemplateForLink","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","getEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","getEditedEntityRecord","raw","undoRevert","actions","label","onClick","openGeneralSidebar","name","enableComplementaryArea","closeGeneralSidebar","disableComplementaryArea","switchEditorMode","mode","clearSelectedBlock"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,cAAlB,QAAwC,sBAAxC;AACA,SAASH,KAAK,IAAII,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,UAAU,IAAIC,iBAAvB,QAAgD,aAAhD;AACA,OAAOC,oBAAP,MAAiC,iCAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;A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;AAMP;AACA;AACA;;AACA,OAAO,MAAME,mBAAmB,GAAG,MAAM,SAAoB;AAAA,MAAlB;AAAEtE,IAAAA;AAAF,GAAkB;AAC5DA,EAAAA,QAAQ,CACND,QADF,CACYd,cADZ,EAEEsF,wBAFF,CAE4BlF,iBAF5B;AAGA,CAJM;AAMP,OAAO,MAAMmF,gBAAgB,GAAKC,IAAF,IAAY,SAA8B;AAAA,MAA5B;AAAE1E,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACzED,EAAAA,QAAQ,CAAE;AAAEN,IAAAA,IAAI,EAAE,aAAR;AAAuBgF,IAAAA;AAAvB,GAAF,CAAR,CADyE,CAGzE;;AACA,MAAKA,IAAI,KAAK,QAAd,EAAyB;AACxBzE,IAAAA,QAAQ,CAACD,QAAT,CAAmBb,gBAAnB,EAAsCwF,kBAAtC;AACA;;AAED,MAAKD,IAAI,KAAK,QAAd,EAAyB;AACxBtF,IAAAA,KAAK,CAAEP,EAAE,CAAE,wBAAF,CAAJ,EAAkC,WAAlC,CAAL;AACA,GAFD,MAEO,IAAK6F,IAAI,KAAK,QAAd,EAAyB;AAC/BtF,IAAAA,KAAK,CAAEP,EAAE,CAAE,sBAAF,CAAJ,EAAgC,WAAhC,CAAL;AACA;AACD,CAbM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Action that toggles a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Action that changes the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Action that sets a template, optionally fetching it from REST API.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport const setTemplate = ( templateId, templateSlug ) => async ( {\n\tdispatch,\n\tregistry,\n} ) => {\n\tif ( ! templateSlug ) {\n\t\tconst template = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecord( 'postType', 'wp_template', templateId );\n\t\ttemplateSlug = template?.slug;\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: { templateSlug } },\n\t} );\n};\n\n/**\n * Action that adds a new template and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport const addTemplate = ( template ) => async ( { dispatch, registry } ) => {\n\tconst newTemplate = await registry\n\t\t.dispatch( coreStore )\n\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\n\tif ( template.content ) {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\tnewTemplate.id,\n\t\t\t\t{ blocks: parse( template.content ) },\n\t\t\t\t{ undoIgnore: true }\n\t\t\t);\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t} );\n};\n\n/**\n * Action that removes a template.\n *\n * @param {Object} template The template object.\n */\nexport const removeTemplate = ( template ) => async ( { registry } ) => {\n\ttry {\n\t\tawait registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.deleteEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\tforce: true,\n\t\t\t} );\n\n\t\tconst lastError = registry\n\t\t\t.select( coreStore )\n\t\t\t.getLastEntityDeleteError( 'postType', template.type, template.id );\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t}\n};\n\n/**\n * Action that sets a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Action that sets the home template ID to the template ID of the page resolved\n * from a given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport const setPage = ( page ) => async ( { dispatch, registry } ) => {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpage.context.postType || 'post',\n\t\t\t\tpage.context.postId\n\t\t\t);\n\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\tpage.path = getPathAndQueryString( entity?.link );\n\t}\n\n\tconst template = await registry\n\t\t.resolveSelect( coreStore )\n\t\t.__experimentalGetTemplateForLink( page.path );\n\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tdispatch( {\n\t\ttype: 'SET_PAGE',\n\t\tpage: template.slug\n\t\t\t? {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug: template.slug,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: page,\n\t\ttemplateId: template.id,\n\t} );\n\n\treturn template.id;\n};\n\n/**\n * Action that sets the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Opens or closes the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate = (\n\ttemplate,\n\t{ allowUndo = true } = {}\n) => async ( { registry } ) => {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntity( 'postType', template.type );\n\n\t\tif ( ! templateEntity ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\n\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\n\t\tconst edited = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord( 'postType', template.type, template.id );\n\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t} );\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = () => {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.editEntityRecord( 'postType', template.type, edited.id, {\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t} );\n\t\t\t};\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t} );\n\t\t} else {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ) );\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t}\n};\n/**\n * Action that opens an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar = ( name ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.enableComplementaryArea( editSiteStoreName, name );\n};\n\n/**\n * Action that closes the sidebar.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editSiteStoreName );\n};\n\nexport const switchEditorMode = ( mode ) => ( { dispatch, registry } ) => {\n\tdispatch( { type: 'SWITCH_MODE', mode } );\n\n\t// Unselect blocks when we switch to a non visual mode.\n\tif ( mode !== 'visual' ) {\n\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t}\n\n\tif ( mode === 'visual' ) {\n\t\tspeak( __( 'Visual editor selected' ), 'assertive' );\n\t} else if ( mode === 'mosaic' ) {\n\t\tspeak( __( 'Mosaic view selected' ), 'assertive' );\n\t}\n};\n"]}
@@ -2,7 +2,6 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createReduxStore, registerStore } from '@wordpress/data';
5
- import { controls } from '@wordpress/data-controls';
6
5
  /**
7
6
  * Internal dependencies
8
7
  */
@@ -15,7 +14,6 @@ export const storeConfig = {
15
14
  reducer,
16
15
  actions,
17
16
  selectors,
18
- controls,
19
17
  persist: ['preferences']
20
18
  };
21
19
  export const store = createReduxStore(STORE_NAME, storeConfig); // Once we build a more generic persistence plugin that works across types of stores
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["createReduxStore","registerStore","controls","reducer","actions","selectors","STORE_NAME","storeConfig","persist","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,QAAT,QAAyB,0BAAzB;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AACA,SAASC,UAAT,QAA2B,aAA3B;AAEA,OAAO,MAAMC,WAAW,GAAG;AAC1BJ,EAAAA,OAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BH,EAAAA,QAJ0B;AAK1BM,EAAAA,OAAO,EAAE,CAAE,aAAF;AALiB,CAApB;AAQP,OAAO,MAAMC,KAAK,GAAGT,gBAAgB,CAAEM,UAAF,EAAcC,WAAd,CAA9B,C,CAEP;AACA;;AACAN,aAAa,CAAEK,UAAF,EAAcC,WAAd,CAAb","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\nimport { controls } from '@wordpress/data-controls';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n\tcontrols,\n\tpersist: [ 'preferences' ],\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregisterStore( STORE_NAME, storeConfig );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["createReduxStore","registerStore","reducer","actions","selectors","STORE_NAME","storeConfig","persist","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AACA,SAASC,UAAT,QAA2B,aAA3B;AAEA,OAAO,MAAMC,WAAW,GAAG;AAC1BJ,EAAAA,OAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BG,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJiB,CAApB;AAOP,OAAO,MAAMC,KAAK,GAAGR,gBAAgB,CAAEK,UAAF,EAAcC,WAAd,CAA9B,C,CAEP;AACA;;AACAL,aAAa,CAAEI,UAAF,EAAcC,WAAd,CAAb","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'preferences' ],\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregisterStore( STORE_NAME, storeConfig );\n"]}
@@ -83,7 +83,8 @@ export const getSettings = createSelector((state, setIsInserterOpen) => {
83
83
  focusMode: isFeatureActive(state, 'focusMode'),
84
84
  hasFixedToolbar: isFeatureActive(state, 'fixedToolbar'),
85
85
  __experimentalSetIsInserterOpened: setIsInserterOpen,
86
- __experimentalReusableBlocks: getReusableBlocks(state)
86
+ __experimentalReusableBlocks: getReusableBlocks(state),
87
+ __experimentalPreferPatternsOnRoot: 'wp_template' === getEditedPostType(state)
87
88
  };
88
89
  const canUserCreateMedia = getCanUserCreateMedia(state);
89
90
 
@@ -109,7 +110,7 @@ export const getSettings = createSelector((state, setIsInserterOpen) => {
109
110
  };
110
111
 
111
112
  return settings;
112
- }, state => [getCanUserCreateMedia(state), state.settings, isFeatureActive(state, 'focusMode'), isFeatureActive(state, 'fixedToolbar'), getReusableBlocks(state)]);
113
+ }, state => [getCanUserCreateMedia(state), state.settings, isFeatureActive(state, 'focusMode'), isFeatureActive(state, 'fixedToolbar'), getReusableBlocks(state), getEditedPostType(state)]);
113
114
  /**
114
115
  * Returns the current home template ID.
115
116
  *