@wordpress/editor 14.4.0 → 14.5.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 (222) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/post-meta.js +12 -0
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/blog-title/index.js +1 -1
  5. package/build/components/blog-title/index.js.map +1 -1
  6. package/build/components/commands/index.js +8 -2
  7. package/build/components/commands/index.js.map +1 -1
  8. package/build/components/document-bar/index.js +1 -1
  9. package/build/components/document-bar/index.js.map +1 -1
  10. package/build/components/header/index.js +2 -3
  11. package/build/components/header/index.js.map +1 -1
  12. package/build/components/page-attributes/parent.js +6 -2
  13. package/build/components/page-attributes/parent.js.map +1 -1
  14. package/build/components/post-actions/actions.js +38 -344
  15. package/build/components/post-actions/actions.js.map +1 -1
  16. package/build/components/post-actions/index.js +16 -6
  17. package/build/components/post-actions/index.js.map +1 -1
  18. package/build/components/post-author/hook.js +10 -3
  19. package/build/components/post-author/hook.js.map +1 -1
  20. package/build/components/post-author/panel.js +2 -1
  21. package/build/components/post-author/panel.js.map +1 -1
  22. package/build/components/post-card-panel/index.js +1 -1
  23. package/build/components/post-card-panel/index.js.map +1 -1
  24. package/build/components/post-comments/index.js +6 -20
  25. package/build/components/post-comments/index.js.map +1 -1
  26. package/build/components/post-status/index.js +17 -41
  27. package/build/components/post-status/index.js.map +1 -1
  28. package/build/components/post-template/create-new-template-modal.js +3 -0
  29. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  30. package/build/components/post-url/panel.js +3 -2
  31. package/build/components/post-url/panel.js.map +1 -1
  32. package/build/components/preview-dropdown/index.js +82 -17
  33. package/build/components/preview-dropdown/index.js.map +1 -1
  34. package/build/components/provider/disable-non-page-content-blocks.js +14 -18
  35. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  36. package/build/components/site-discussion/index.js +6 -20
  37. package/build/components/site-discussion/index.js.map +1 -1
  38. package/build/components/template-content-panel/index.js +14 -12
  39. package/build/components/template-content-panel/index.js.map +1 -1
  40. package/build/components/visual-editor/index.js +2 -1
  41. package/build/components/visual-editor/index.js.map +1 -1
  42. package/build/dataviews/actions/export-pattern.native.js +9 -0
  43. package/build/dataviews/actions/export-pattern.native.js.map +1 -0
  44. package/build/dataviews/actions/permanently-delete-post.js +107 -0
  45. package/build/dataviews/actions/permanently-delete-post.js.map +1 -0
  46. package/build/dataviews/actions/restore-post.js +112 -0
  47. package/build/dataviews/actions/restore-post.js.map +1 -0
  48. package/build/dataviews/actions/trash-post.js +142 -0
  49. package/build/dataviews/actions/trash-post.js.map +1 -0
  50. package/build/dataviews/store/private-actions.js +45 -0
  51. package/build/dataviews/store/private-actions.js.map +1 -1
  52. package/build/dataviews/store/private-selectors.js +10 -10
  53. package/build/dataviews/store/private-selectors.js.map +1 -1
  54. package/build/dataviews/store/reducer.js +15 -1
  55. package/build/dataviews/store/reducer.js.map +1 -1
  56. package/build/dataviews/types.js.map +1 -1
  57. package/build/private-apis.js +0 -2
  58. package/build/private-apis.js.map +1 -1
  59. package/build/store/actions.js +16 -2
  60. package/build/store/actions.js.map +1 -1
  61. package/build/store/private-actions.js +8 -1
  62. package/build/store/private-actions.js.map +1 -1
  63. package/build/store/private-selectors.js +33 -2
  64. package/build/store/private-selectors.js.map +1 -1
  65. package/build-module/bindings/post-meta.js +12 -0
  66. package/build-module/bindings/post-meta.js.map +1 -1
  67. package/build-module/components/blog-title/index.js +1 -1
  68. package/build-module/components/blog-title/index.js.map +1 -1
  69. package/build-module/components/commands/index.js +8 -2
  70. package/build-module/components/commands/index.js.map +1 -1
  71. package/build-module/components/document-bar/index.js +1 -1
  72. package/build-module/components/document-bar/index.js.map +1 -1
  73. package/build-module/components/header/index.js +2 -3
  74. package/build-module/components/header/index.js.map +1 -1
  75. package/build-module/components/page-attributes/parent.js +7 -3
  76. package/build-module/components/page-attributes/parent.js.map +1 -1
  77. package/build-module/components/post-actions/actions.js +44 -350
  78. package/build-module/components/post-actions/actions.js.map +1 -1
  79. package/build-module/components/post-actions/index.js +16 -6
  80. package/build-module/components/post-actions/index.js.map +1 -1
  81. package/build-module/components/post-author/hook.js +10 -3
  82. package/build-module/components/post-author/hook.js.map +1 -1
  83. package/build-module/components/post-author/panel.js +2 -1
  84. package/build-module/components/post-author/panel.js.map +1 -1
  85. package/build-module/components/post-card-panel/index.js +1 -1
  86. package/build-module/components/post-card-panel/index.js.map +1 -1
  87. package/build-module/components/post-comments/index.js +7 -23
  88. package/build-module/components/post-comments/index.js.map +1 -1
  89. package/build-module/components/post-status/index.js +19 -43
  90. package/build-module/components/post-status/index.js.map +1 -1
  91. package/build-module/components/post-template/create-new-template-modal.js +3 -0
  92. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  93. package/build-module/components/post-url/panel.js +4 -5
  94. package/build-module/components/post-url/panel.js.map +1 -1
  95. package/build-module/components/preview-dropdown/index.js +84 -19
  96. package/build-module/components/preview-dropdown/index.js.map +1 -1
  97. package/build-module/components/provider/disable-non-page-content-blocks.js +15 -19
  98. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  99. package/build-module/components/site-discussion/index.js +7 -21
  100. package/build-module/components/site-discussion/index.js.map +1 -1
  101. package/build-module/components/template-content-panel/index.js +15 -13
  102. package/build-module/components/template-content-panel/index.js.map +1 -1
  103. package/build-module/components/visual-editor/index.js +2 -1
  104. package/build-module/components/visual-editor/index.js.map +1 -1
  105. package/build-module/dataviews/actions/export-pattern.native.js +3 -0
  106. package/build-module/dataviews/actions/export-pattern.native.js.map +1 -0
  107. package/build-module/dataviews/actions/permanently-delete-post.js +99 -0
  108. package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -0
  109. package/build-module/dataviews/actions/restore-post.js +104 -0
  110. package/build-module/dataviews/actions/restore-post.js.map +1 -0
  111. package/build-module/dataviews/actions/trash-post.js +135 -0
  112. package/build-module/dataviews/actions/trash-post.js.map +1 -0
  113. package/build-module/dataviews/store/private-actions.js +40 -0
  114. package/build-module/dataviews/store/private-actions.js.map +1 -1
  115. package/build-module/dataviews/store/private-selectors.js +8 -9
  116. package/build-module/dataviews/store/private-selectors.js.map +1 -1
  117. package/build-module/dataviews/store/reducer.js +15 -1
  118. package/build-module/dataviews/store/reducer.js.map +1 -1
  119. package/build-module/dataviews/types.js.map +1 -1
  120. package/build-module/private-apis.js +0 -2
  121. package/build-module/private-apis.js.map +1 -1
  122. package/build-module/store/actions.js +16 -2
  123. package/build-module/store/actions.js.map +1 -1
  124. package/build-module/store/private-actions.js +8 -1
  125. package/build-module/store/private-actions.js.map +1 -1
  126. package/build-module/store/private-selectors.js +32 -2
  127. package/build-module/store/private-selectors.js.map +1 -1
  128. package/build-style/style-rtl.css +19 -3
  129. package/build-style/style.css +19 -3
  130. package/build-types/bindings/post-meta.d.ts +6 -0
  131. package/build-types/bindings/post-meta.d.ts.map +1 -1
  132. package/build-types/components/commands/index.d.ts.map +1 -1
  133. package/build-types/components/header/index.d.ts.map +1 -1
  134. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  135. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  136. package/build-types/components/post-actions/index.d.ts.map +1 -1
  137. package/build-types/components/post-author/hook.d.ts +1 -1
  138. package/build-types/components/post-author/hook.d.ts.map +1 -1
  139. package/build-types/components/post-author/panel.d.ts.map +1 -1
  140. package/build-types/components/post-comments/index.d.ts.map +1 -1
  141. package/build-types/components/post-status/index.d.ts +2 -1
  142. package/build-types/components/post-status/index.d.ts.map +1 -1
  143. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  144. package/build-types/components/post-url/panel.d.ts.map +1 -1
  145. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  146. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  147. package/build-types/components/site-discussion/index.d.ts.map +1 -1
  148. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  149. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  150. package/build-types/dataviews/actions/export-pattern.native.d.ts +3 -0
  151. package/build-types/dataviews/actions/export-pattern.native.d.ts.map +1 -0
  152. package/build-types/dataviews/actions/permanently-delete-post.d.ts +5 -0
  153. package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -0
  154. package/build-types/dataviews/actions/restore-post.d.ts +5 -0
  155. package/build-types/dataviews/actions/restore-post.d.ts.map +1 -0
  156. package/build-types/dataviews/actions/trash-post.d.ts +5 -0
  157. package/build-types/dataviews/actions/trash-post.d.ts.map +1 -0
  158. package/build-types/dataviews/store/private-actions.d.ts +8 -3
  159. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  160. package/build-types/dataviews/store/private-selectors.d.ts +2 -1
  161. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
  162. package/build-types/dataviews/store/reducer.d.ts +4 -1
  163. package/build-types/dataviews/store/reducer.d.ts.map +1 -1
  164. package/build-types/dataviews/types.d.ts +9 -0
  165. package/build-types/dataviews/types.d.ts.map +1 -1
  166. package/build-types/private-apis.d.ts.map +1 -1
  167. package/build-types/store/actions.d.ts.map +1 -1
  168. package/build-types/store/private-actions.d.ts.map +1 -1
  169. package/build-types/store/private-selectors.d.ts +11 -0
  170. package/build-types/store/private-selectors.d.ts.map +1 -1
  171. package/build-types/store/reducer.d.ts +1 -0
  172. package/build-types/store/reducer.d.ts.map +1 -1
  173. package/package.json +36 -36
  174. package/src/bindings/post-meta.js +20 -0
  175. package/src/components/blog-title/index.js +1 -1
  176. package/src/components/commands/index.js +4 -2
  177. package/src/components/document-bar/index.js +1 -1
  178. package/src/components/document-bar/style.scss +1 -1
  179. package/src/components/editor-interface/style.scss +5 -0
  180. package/src/components/header/index.js +1 -2
  181. package/src/components/list-view-sidebar/style.scss +4 -0
  182. package/src/components/page-attributes/parent.js +25 -7
  183. package/src/components/post-actions/actions.js +47 -470
  184. package/src/components/post-actions/index.js +19 -7
  185. package/src/components/post-author/hook.js +11 -3
  186. package/src/components/post-author/panel.js +3 -1
  187. package/src/components/post-card-panel/index.js +1 -1
  188. package/src/components/post-comments/index.js +7 -20
  189. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  190. package/src/components/post-status/index.js +11 -41
  191. package/src/components/post-template/create-new-template-modal.js +7 -1
  192. package/src/components/post-url/panel.js +8 -2
  193. package/src/components/preview-dropdown/index.js +113 -35
  194. package/src/components/preview-dropdown/style.scss +5 -0
  195. package/src/components/provider/disable-non-page-content-blocks.js +27 -24
  196. package/src/components/site-discussion/index.js +7 -19
  197. package/src/components/template-content-panel/index.js +36 -21
  198. package/src/components/visual-editor/index.js +8 -6
  199. package/src/components/visual-editor/style.scss +1 -3
  200. package/src/dataviews/actions/export-pattern.native.tsx +3 -0
  201. package/src/dataviews/actions/permanently-delete-post.tsx +116 -0
  202. package/src/dataviews/actions/restore-post.tsx +134 -0
  203. package/src/dataviews/actions/trash-post.tsx +196 -0
  204. package/src/dataviews/store/private-actions.ts +68 -0
  205. package/src/dataviews/store/private-selectors.ts +9 -17
  206. package/src/dataviews/store/reducer.ts +20 -1
  207. package/src/dataviews/types.ts +11 -0
  208. package/src/private-apis.js +0 -2
  209. package/src/store/actions.js +36 -13
  210. package/src/store/private-actions.js +8 -4
  211. package/src/store/private-selectors.js +45 -2
  212. package/src/store/test/private-selectors.js +78 -0
  213. package/tsconfig.tsbuildinfo +1 -1
  214. package/build/dataviews/actions/index.js +0 -32
  215. package/build/dataviews/actions/index.js.map +0 -1
  216. package/build-module/dataviews/actions/index.js +0 -24
  217. package/build-module/dataviews/actions/index.js.map +0 -1
  218. package/build-types/dataviews/actions/index.d.ts +0 -2
  219. package/build-types/dataviews/actions/index.d.ts.map +0 -1
  220. package/src/components/document-outline/test/__snapshots__/index.js.snap +0 -111
  221. package/src/components/document-outline/test/index.js +0 -185
  222. package/src/dataviews/actions/index.ts +0 -25
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@wordpress/icons");
8
+ var _coreData = require("@wordpress/core-data");
9
+ var _i18n = require("@wordpress/i18n");
10
+ var _notices = require("@wordpress/notices");
11
+ var _utils = require("./utils");
12
+ /**
13
+ * WordPress dependencies
14
+ */
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+
20
+ const restorePost = {
21
+ id: 'restore',
22
+ label: (0, _i18n.__)('Restore'),
23
+ isPrimary: true,
24
+ icon: _icons.backup,
25
+ supportsBulk: true,
26
+ isEligible(item) {
27
+ return !(0, _utils.isTemplateOrTemplatePart)(item) && item.type !== 'wp_block' && item.status === 'trash' && item.permissions?.update;
28
+ },
29
+ async callback(posts, {
30
+ registry,
31
+ onActionPerformed
32
+ }) {
33
+ const {
34
+ createSuccessNotice,
35
+ createErrorNotice
36
+ } = registry.dispatch(_notices.store);
37
+ const {
38
+ editEntityRecord,
39
+ saveEditedEntityRecord
40
+ } = registry.dispatch(_coreData.store);
41
+ await Promise.allSettled(posts.map(post => {
42
+ return editEntityRecord('postType', post.type, post.id, {
43
+ status: 'draft'
44
+ });
45
+ }));
46
+ const promiseResult = await Promise.allSettled(posts.map(post => {
47
+ return saveEditedEntityRecord('postType', post.type, post.id, {
48
+ throwOnError: true
49
+ });
50
+ }));
51
+ if (promiseResult.every(({
52
+ status
53
+ }) => status === 'fulfilled')) {
54
+ let successMessage;
55
+ if (posts.length === 1) {
56
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
57
+ (0, _i18n.__)('"%s" has been restored.'), (0, _utils.getItemTitle)(posts[0]));
58
+ } else if (posts[0].type === 'page') {
59
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
60
+ (0, _i18n.__)('%d pages have been restored.'), posts.length);
61
+ } else {
62
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
63
+ (0, _i18n.__)('%d posts have been restored.'), posts.length);
64
+ }
65
+ createSuccessNotice(successMessage, {
66
+ type: 'snackbar',
67
+ id: 'restore-post-action'
68
+ });
69
+ if (onActionPerformed) {
70
+ onActionPerformed(posts);
71
+ }
72
+ } else {
73
+ // If there was at lease one failure.
74
+ let errorMessage;
75
+ // If we were trying to move a single post to the trash.
76
+ if (promiseResult.length === 1) {
77
+ const typedError = promiseResult[0];
78
+ if (typedError.reason?.message) {
79
+ errorMessage = typedError.reason.message;
80
+ } else {
81
+ errorMessage = (0, _i18n.__)('An error occurred while restoring the post.');
82
+ }
83
+ // If we were trying to move multiple posts to the trash
84
+ } else {
85
+ const errorMessages = new Set();
86
+ const failedPromises = promiseResult.filter(({
87
+ status
88
+ }) => status === 'rejected');
89
+ for (const failedPromise of failedPromises) {
90
+ const typedError = failedPromise;
91
+ if (typedError.reason?.message) {
92
+ errorMessages.add(typedError.reason.message);
93
+ }
94
+ }
95
+ if (errorMessages.size === 0) {
96
+ errorMessage = (0, _i18n.__)('An error occurred while restoring the posts.');
97
+ } else if (errorMessages.size === 1) {
98
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
99
+ (0, _i18n.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
100
+ } else {
101
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
102
+ (0, _i18n.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
103
+ }
104
+ }
105
+ createErrorNotice(errorMessage, {
106
+ type: 'snackbar'
107
+ });
108
+ }
109
+ }
110
+ };
111
+ var _default = exports.default = restorePost;
112
+ //# sourceMappingURL=restore-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_icons","require","_coreData","_i18n","_notices","_utils","restorePost","id","label","__","isPrimary","icon","backup","supportsBulk","isEligible","item","isTemplateOrTemplatePart","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","noticesStore","editEntityRecord","saveEditedEntityRecord","coreStore","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","sprintf","getItemTitle","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/restore-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default restorePost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMK,WAA0C,GAAG;EAClDC,EAAE,EAAE,SAAS;EACbC,KAAK,EAAE,IAAAC,QAAE,EAAE,SAAU,CAAC;EACtBC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,aAAM;EACZC,YAAY,EAAE,IAAI;EAClBC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OACC,CAAE,IAAAC,+BAAwB,EAAED,IAAK,CAAC,IAClCA,IAAI,CAACE,IAAI,KAAK,UAAU,IACxBF,IAAI,CAACG,MAAM,KAAK,OAAO,IACvBH,IAAI,CAACI,WAAW,EAAEC,MAAM;EAE1B,CAAC;E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rB;UACA,IAAAhC,QAAE,EAAE,iDAAkD,CAAC,EACvD,CAAE,GAAGsC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAG,IAAAF,aAAO,GACrB;UACA,IAAAhC,QAAE,EACD,oDACD,CAAC,EACD,CAAE,GAAGsC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACA5B,iBAAiB,CAAEiB,YAAY,EAAE;QAChC1B,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEanD,WAAW","ignoreList":[]}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@wordpress/icons");
8
+ var _data = require("@wordpress/data");
9
+ var _coreData = require("@wordpress/core-data");
10
+ var _i18n = require("@wordpress/i18n");
11
+ var _notices = require("@wordpress/notices");
12
+ var _element = require("@wordpress/element");
13
+ var _components = require("@wordpress/components");
14
+ var _utils = require("./utils");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ const trashPost = {
25
+ id: 'move-to-trash',
26
+ label: (0, _i18n.__)('Move to trash'),
27
+ isPrimary: true,
28
+ icon: _icons.trash,
29
+ isEligible(item) {
30
+ if ((0, _utils.isTemplateOrTemplatePart)(item) || item.type === 'wp_block') {
31
+ return false;
32
+ }
33
+ return !!item.status && !['auto-draft', 'trash'].includes(item.status) && item.permissions?.delete;
34
+ },
35
+ supportsBulk: true,
36
+ hideModalHeader: true,
37
+ RenderModal: ({
38
+ items,
39
+ closeModal,
40
+ onActionPerformed
41
+ }) => {
42
+ const [isBusy, setIsBusy] = (0, _element.useState)(false);
43
+ const {
44
+ createSuccessNotice,
45
+ createErrorNotice
46
+ } = (0, _data.useDispatch)(_notices.store);
47
+ const {
48
+ deleteEntityRecord
49
+ } = (0, _data.useDispatch)(_coreData.store);
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
51
+ spacing: "5",
52
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
53
+ children: items.length === 1 ? (0, _i18n.sprintf)(
54
+ // translators: %s: The item's title.
55
+ (0, _i18n.__)('Are you sure you want to move "%s" to the trash?'), (0, _utils.getItemTitle)(items[0])) : (0, _i18n.sprintf)(
56
+ // translators: %d: The number of items (2 or more).
57
+ (0, _i18n._n)('Are you sure you want to move %d item to the trash ?', 'Are you sure you want to move %d items to the trash ?', items.length), items.length)
58
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
59
+ justify: "right",
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
61
+ variant: "tertiary",
62
+ onClick: closeModal,
63
+ disabled: isBusy,
64
+ accessibleWhenDisabled: true,
65
+ children: (0, _i18n.__)('Cancel')
66
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
67
+ variant: "primary",
68
+ onClick: async () => {
69
+ setIsBusy(true);
70
+ const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id.toString(), {}, {
71
+ throwOnError: true
72
+ })));
73
+ // If all the promises were fulfilled with success.
74
+ if (promiseResult.every(({
75
+ status
76
+ }) => status === 'fulfilled')) {
77
+ let successMessage;
78
+ if (promiseResult.length === 1) {
79
+ successMessage = (0, _i18n.sprintf)( /* translators: The item's title. */
80
+ (0, _i18n.__)('"%s" moved to the trash.'), (0, _utils.getItemTitle)(items[0]));
81
+ } else {
82
+ successMessage = (0, _i18n.sprintf)( /* translators: The number of items. */
83
+ (0, _i18n._n)('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
84
+ }
85
+ createSuccessNotice(successMessage, {
86
+ type: 'snackbar',
87
+ id: 'move-to-trash-action'
88
+ });
89
+ } else {
90
+ // If there was at least one failure.
91
+ let errorMessage;
92
+ // If we were trying to delete a single item.
93
+ if (promiseResult.length === 1) {
94
+ const typedError = promiseResult[0];
95
+ if (typedError.reason?.message) {
96
+ errorMessage = typedError.reason.message;
97
+ } else {
98
+ errorMessage = (0, _i18n.__)('An error occurred while moving the item to the trash.');
99
+ }
100
+ // If we were trying to delete multiple items.
101
+ } else {
102
+ const errorMessages = new Set();
103
+ const failedPromises = promiseResult.filter(({
104
+ status
105
+ }) => status === 'rejected');
106
+ for (const failedPromise of failedPromises) {
107
+ const typedError = failedPromise;
108
+ if (typedError.reason?.message) {
109
+ errorMessages.add(typedError.reason.message);
110
+ }
111
+ }
112
+ if (errorMessages.size === 0) {
113
+ errorMessage = (0, _i18n.__)('An error occurred while moving the items to the trash.');
114
+ } else if (errorMessages.size === 1) {
115
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
116
+ (0, _i18n.__)('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
117
+ } else {
118
+ errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
119
+ (0, _i18n.__)('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
120
+ }
121
+ }
122
+ createErrorNotice(errorMessage, {
123
+ type: 'snackbar'
124
+ });
125
+ }
126
+ if (onActionPerformed) {
127
+ onActionPerformed(items);
128
+ }
129
+ setIsBusy(false);
130
+ closeModal?.();
131
+ },
132
+ isBusy: isBusy,
133
+ disabled: isBusy,
134
+ accessibleWhenDisabled: true,
135
+ children: (0, _i18n._x)('Trash', 'verb')
136
+ })]
137
+ })]
138
+ });
139
+ }
140
+ };
141
+ var _default = exports.default = trashPost;
142
+ //# sourceMappingURL=trash-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_icons","require","_data","_coreData","_i18n","_notices","_element","_components","_utils","_jsxRuntime","trashPost","id","label","__","isPrimary","icon","trash","isEligible","item","isTemplateOrTemplatePart","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","useState","createSuccessNotice","createErrorNotice","useDispatch","noticesStore","deleteEntityRecord","coreStore","jsxs","__experimentalVStack","spacing","children","jsx","__experimentalText","length","sprintf","getItemTitle","_n","__experimentalHStack","justify","Button","variant","onClick","disabled","accessibleWhenDisabled","promiseResult","Promise","allSettled","map","toString","throwOnError","every","successMessage","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","_x","_default","exports","default"],"sources":["@wordpress/editor/src/dataviews/actions/trash-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%s item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%s items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default trashPost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE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,CAACM,IAAI,KAAK,CAAC,EAAG;kBAC/BV,YAAY,GAAG,IAAApD,QAAE,EAChB,wDACD,CAAC;gBACF,CAAC,MAAM,IAAKwD,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;kBACtCV,YAAY,GAAG,IAAAlB,aAAO,GACrB;kBACA,IAAAlC,QAAE,EACD,0DACD,CAAC,EACD,CAAE,GAAGwD,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;gBACF,CAAC,MAAM;kBACNJ,YAAY,GAAG,IAAAlB,aAAO,GACrB;kBACA,IAAAlC,QAAE,EACD,8DACD,CAAC,EACD,CAAE,GAAGwD,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;gBACF;cACD;cACAzC,iBAAiB,CAAE8B,YAAY,EAAE;gBAChC7C,IAAI,EAAE;cACP,CAAE,CAAC;YACJ;YACA,IAAKU,iBAAiB,EAAG;cACxBA,iBAAiB,CAAEF,KAAM,CAAC;YAC3B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBwB,QAAQ,EAAGxB,MAAQ;UACnByB,sBAAsB;UAAAb,QAAA,EAEpB,IAAAkC,QAAE,EAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatE,SAAS","ignoreList":[]}
@@ -1,14 +1,31 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.registerEntityAction = registerEntityAction;
8
+ exports.registerPostTypeActions = void 0;
9
+ exports.setIsReady = setIsReady;
7
10
  exports.unregisterEntityAction = unregisterEntityAction;
11
+ var _coreData = require("@wordpress/core-data");
12
+ var _hooks = require("@wordpress/hooks");
13
+ var _deletePost = _interopRequireDefault(require("../actions/delete-post"));
14
+ var _exportPattern = _interopRequireDefault(require("../actions/export-pattern"));
15
+ var _resetPost = _interopRequireDefault(require("../actions/reset-post"));
16
+ var _trashPost = _interopRequireDefault(require("../actions/trash-post"));
17
+ var _permanentlyDeletePost = _interopRequireDefault(require("../actions/permanently-delete-post"));
18
+ var _restorePost = _interopRequireDefault(require("../actions/restore-post"));
19
+ var _store = require("../../store");
20
+ var _lockUnlock = require("../../lock-unlock");
8
21
  /**
9
22
  * WordPress dependencies
10
23
  */
11
24
 
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+
12
29
  function registerEntityAction(kind, name, config) {
13
30
  return {
14
31
  type: 'REGISTER_ENTITY_ACTION',
@@ -25,4 +42,32 @@ function unregisterEntityAction(kind, name, actionId) {
25
42
  actionId
26
43
  };
27
44
  }
45
+ function setIsReady(kind, name) {
46
+ return {
47
+ type: 'SET_IS_READY',
48
+ kind,
49
+ name
50
+ };
51
+ }
52
+ const registerPostTypeActions = postType => async ({
53
+ registry
54
+ }) => {
55
+ const isReady = (0, _lockUnlock.unlock)(registry.select(_store.store)).isEntityReady('postType', postType);
56
+ if (isReady) {
57
+ return;
58
+ }
59
+ (0, _lockUnlock.unlock)(registry.dispatch(_store.store)).setIsReady('postType', postType);
60
+ const postTypeConfig = await registry.resolveSelect(_coreData.store).getPostType(postType);
61
+ const actions = [postTypeConfig.slug === 'wp_block' ? _exportPattern.default : undefined, _resetPost.default, _restorePost.default, _deletePost.default, _trashPost.default, _permanentlyDeletePost.default];
62
+ registry.batch(() => {
63
+ actions.forEach(action => {
64
+ if (action === undefined) {
65
+ return;
66
+ }
67
+ (0, _lockUnlock.unlock)(registry.dispatch(_store.store)).registerEntityAction('postType', postType, action);
68
+ });
69
+ });
70
+ (0, _hooks.doAction)('core.registerPostTypeActions', postType);
71
+ };
72
+ exports.registerPostTypeActions = registerPostTypeActions;
28
73
  //# sourceMappingURL=private-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Action } from '@wordpress/dataviews';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;;AAGO,SAASA,oBAAoBA,CACnCC,IAAY,EACZC,IAAY,EACZC,MAAsB,EACrB;EACD,OAAO;IACNC,IAAI,EAAE,wBAAiC;IACvCH,IAAI;IACJC,IAAI;IACJC;EACD,CAAC;AACF;AAEO,SAASE,sBAAsBA,CACrCJ,IAAY,EACZC,IAAY,EACZI,QAAgB,EACf;EACD,OAAO;IACNF,IAAI,EAAE,0BAAmC;IACzCH,IAAI;IACJC,IAAI;IACJI;EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_hooks","_deletePost","_interopRequireDefault","_exportPattern","_resetPost","_trashPost","_permanentlyDeletePost","_restorePost","_store","_lockUnlock","registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId","setIsReady","registerPostTypeActions","postType","registry","isReady","unlock","select","editorStore","isEntityReady","dispatch","postTypeConfig","resolveSelect","coreStore","getPostType","actions","slug","exportPattern","undefined","resetPost","restorePost","deletePost","trashPost","permanentlyDeletePost","batch","forEach","action","doAction","exports"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport deletePost from '../actions/delete-post';\nimport exportPattern from '../actions/export-pattern';\nimport resetPost from '../actions/reset-post';\nimport trashPost from '../actions/trash-post';\nimport permanentlyDeletePost from '../actions/permanently-delete-post';\nimport restorePost from '../actions/restore-post';\nimport type { PostType } from '../types';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeActions =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\tresetPost,\n\t\t\trestorePost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t];\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tif ( action === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeActions', postType );\n\t};\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,cAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,UAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,UAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,sBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,YAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAlBA;AACA;AACA;;AAKA;AACA;AACA;;AAWO,SAASW,oBAAoBA,CACnCC,IAAY,EACZC,IAAY,EACZC,MAAsB,EACrB;EACD,OAAO;IACNC,IAAI,EAAE,wBAAiC;IACvCH,IAAI;IACJC,IAAI;IACJC;EACD,CAAC;AACF;AAEO,SAASE,sBAAsBA,CACrCJ,IAAY,EACZC,IAAY,EACZI,QAAgB,EACf;EACD,OAAO;IACNF,IAAI,EAAE,0BAAmC;IACzCH,IAAI;IACJC,IAAI;IACJI;EACD,CAAC;AACF;AAEO,SAASC,UAAUA,CAAEN,IAAY,EAAEC,IAAY,EAAG;EACxD,OAAO;IACNE,IAAI,EAAE,cAAuB;IAC7BH,IAAI;IACJC;EACD,CAAC;AACF;AAEO,MAAMM,uBAAuB,GACjCC,QAAgB,IAClB,OAAQ;EAAEC;AAA4B,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAG,IAAAC,kBAAM,EAAEF,QAAQ,CAACG,MAAM,CAAEC,YAAY,CAAE,CAAC,CAACC,aAAa,CACrE,UAAU,EACVN,QACD,CAAC;EACD,IAAKE,OAAO,EAAG;IACd;EACD;EAEA,IAAAC,kBAAM,EAAEF,QAAQ,CAACM,QAAQ,CAAEF,YAAY,CAAE,CAAC,CAACP,UAAU,CACpD,UAAU,EACVE,QACD,CAAC;EAED,MAAMQ,cAAc,GAAK,MAAMP,QAAQ,CACrCQ,aAAa,CAAEC,eAAU,CAAC,CAC1BC,WAAW,CAAEX,QAAS,CAAe;EAEvC,MAAMY,OAAO,GAAG,CACfJ,cAAc,CAACK,IAAI,KAAK,UAAU,GAAGC,sBAAa,GAAGC,SAAS,EAC9DC,kBAAS,EACTC,oBAAW,EACXC,mBAAU,EACVC,kBAAS,EACTC,8BAAqB,CACrB;EAEDnB,QAAQ,CAACoB,KAAK,CAAE,MAAM;IACrBT,OAAO,CAACU,OAAO,CAAIC,MAAM,IAAM;MAC9B,IAAKA,MAAM,KAAKR,SAAS,EAAG;QAC3B;MACD;MACA,IAAAZ,kBAAM,EAAEF,QAAQ,CAACM,QAAQ,CAAEF,YAAY,CAAE,CAAC,CAACd,oBAAoB,CAC9D,UAAU,EACVS,QAAQ,EACRuB,MACD,CAAC;IACF,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,IAAAC,eAAQ,EAAE,8BAA8B,EAAExB,QAAS,CAAC;AACrD,CAAC;AAACyB,OAAA,CAAA1B,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -3,18 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getEntityActions = void 0;
7
- var _data = require("@wordpress/data");
8
- /**
9
- * WordPress dependencies
10
- */
11
-
6
+ exports.getEntityActions = getEntityActions;
7
+ exports.isEntityReady = isEntityReady;
12
8
  /**
13
9
  * Internal dependencies
14
10
  */
15
11
 
16
- const getEntityActions = exports.getEntityActions = (0, _data.createSelector)((state, kind, name) => {
17
- var _state$actions$kind$n, _state$actions$kind$;
18
- return [...((_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : []), ...((_state$actions$kind$ = state.actions[kind]?.['*']) !== null && _state$actions$kind$ !== void 0 ? _state$actions$kind$ : [])];
19
- }, (state, kind, name) => [state.actions[kind]?.[name], state.actions[kind]?.['*']]);
12
+ const EMPTY_ARRAY = [];
13
+ function getEntityActions(state, kind, name) {
14
+ var _state$actions$kind$n;
15
+ return (_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : EMPTY_ARRAY;
16
+ }
17
+ function isEntityReady(state, kind, name) {
18
+ return state.isReady[kind]?.[name];
19
+ }
20
20
  //# sourceMappingURL=private-selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","getEntityActions","exports","createSelector","state","kind","name","_state$actions$kind$n","_state$actions$kind$","actions"],"sources":["@wordpress/editor/src/dataviews/store/private-selectors.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport type { State } from './reducer';\n\nexport const getEntityActions = createSelector(\n\t( state: State, kind: string, name: string ) => {\n\t\treturn [\n\t\t\t...( state.actions[ kind ]?.[ name ] ?? [] ),\n\t\t\t...( state.actions[ kind ]?.[ '*' ] ?? [] ),\n\t\t];\n\t},\n\t( state: State, kind: string, name: string ) => [\n\t\tstate.actions[ kind ]?.[ name ],\n\t\tstate.actions[ kind ]?.[ '*' ],\n\t]\n);\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAAE,oBAAc,EAC7C,CAAEC,KAAY,EAAEC,IAAY,EAAEC,IAAY,KAAM;EAAA,IAAAC,qBAAA,EAAAC,oBAAA;EAC/C,OAAO,CACN,KAAAD,qBAAA,GAAKH,KAAK,CAACK,OAAO,CAAEJ,IAAI,CAAE,GAAIC,IAAI,CAAE,cAAAC,qBAAA,cAAAA,qBAAA,GAAI,EAAE,CAAE,EAC5C,KAAAC,oBAAA,GAAKJ,KAAK,CAACK,OAAO,CAAEJ,IAAI,CAAE,GAAI,GAAG,CAAE,cAAAG,oBAAA,cAAAA,oBAAA,GAAI,EAAE,CAAE,CAC3C;AACF,CAAC,EACD,CAAEJ,KAAY,EAAEC,IAAY,EAAEC,IAAY,KAAM,CAC/CF,KAAK,CAACK,OAAO,CAAEJ,IAAI,CAAE,GAAIC,IAAI,CAAE,EAC/BF,KAAK,CAACK,OAAO,CAAEJ,IAAI,CAAE,GAAI,GAAG,CAAE,CAEhC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["EMPTY_ARRAY","getEntityActions","state","kind","name","_state$actions$kind$n","actions","isEntityReady","isReady"],"sources":["@wordpress/editor/src/dataviews/store/private-selectors.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { State } from './reducer';\n\nconst EMPTY_ARRAY = [] as [];\n\nexport function getEntityActions( state: State, kind: string, name: string ) {\n\treturn state.actions[ kind ]?.[ name ] ?? EMPTY_ARRAY;\n}\n\nexport function isEntityReady( state: State, kind: string, name: string ) {\n\treturn state.isReady[ kind ]?.[ name ];\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;;AAGA,MAAMA,WAAW,GAAG,EAAQ;AAErB,SAASC,gBAAgBA,CAAEC,KAAY,EAAEC,IAAY,EAAEC,IAAY,EAAG;EAAA,IAAAC,qBAAA;EAC5E,QAAAA,qBAAA,GAAOH,KAAK,CAACI,OAAO,CAAEH,IAAI,CAAE,GAAIC,IAAI,CAAE,cAAAC,qBAAA,cAAAA,qBAAA,GAAIL,WAAW;AACtD;AAEO,SAASO,aAAaA,CAAEL,KAAY,EAAEC,IAAY,EAAEC,IAAY,EAAG;EACzE,OAAOF,KAAK,CAACM,OAAO,CAAEL,IAAI,CAAE,GAAIC,IAAI,CAAE;AACvC","ignoreList":[]}
@@ -9,6 +9,19 @@ var _data = require("@wordpress/data");
9
9
  * WordPress dependencies
10
10
  */
11
11
 
12
+ function isReady(state = {}, action) {
13
+ switch (action.type) {
14
+ case 'SET_IS_READY':
15
+ return {
16
+ ...state,
17
+ [action.kind]: {
18
+ ...state[action.kind],
19
+ [action.name]: true
20
+ }
21
+ };
22
+ }
23
+ return state;
24
+ }
12
25
  function actions(state = {}, action) {
13
26
  var _state$action$kind$ac;
14
27
  switch (action.type) {
@@ -35,6 +48,7 @@ function actions(state = {}, action) {
35
48
  return state;
36
49
  }
37
50
  var _default = exports.default = (0, _data.combineReducers)({
38
- actions
51
+ actions,
52
+ isReady
39
53
  });
40
54
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","actions","state","action","_state$action$kind$ac","type","kind","name","filter","_action","id","config","_state$action$kind$ac2","actionId","_default","exports","default","combineReducers"],"sources":["@wordpress/editor/src/dataviews/store/reducer.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport type { Action } from '@wordpress/dataviews';\n\ntype ReduxAction =\n\t| ReturnType< typeof import('./private-actions').registerEntityAction >\n\t| ReturnType< typeof import('./private-actions').unregisterEntityAction >;\n\nexport type ActionState = Record< string, Record< string, Action< any >[] > >;\nexport type State = {\n\tactions: ActionState;\n};\n\nfunction actions( state: ActionState = {}, action: ReduxAction ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_ENTITY_ACTION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: [\n\t\t\t\t\t\t...(\n\t\t\t\t\t\t\tstate[ action.kind ]?.[ action.name ] ?? []\n\t\t\t\t\t\t).filter(\n\t\t\t\t\t\t\t( _action ) => _action.id !== action.config.id\n\t\t\t\t\t\t),\n\t\t\t\t\t\taction.config,\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_ENTITY_ACTION': {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: (\n\t\t\t\t\t\tstate[ action.kind ]?.[ action.name ] ?? []\n\t\t\t\t\t).filter( ( _action ) => _action.id !== action.actionId ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tactions,\n} );\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAaA,SAASC,OAAOA,CAAEC,KAAkB,GAAG,CAAC,CAAC,EAAEC,MAAmB,EAAG;EAAA,IAAAC,qBAAA;EAChE,QAASD,MAAM,CAACE,IAAI;IACnB,KAAK,wBAAwB;MAC5B,OAAO;QACN,GAAGH,KAAK;QACR,CAAEC,MAAM,CAACG,IAAI,GAAI;UAChB,GAAGJ,KAAK,CAAEC,MAAM,CAACG,IAAI,CAAE;UACvB,CAAEH,MAAM,CAACI,IAAI,GAAI,CAChB,GAAG,EAAAH,qBAAA,GACFF,KAAK,CAAEC,MAAM,CAACG,IAAI,CAAE,GAAIH,MAAM,CAACI,IAAI,CAAE,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,EAAE,EAC1CI,MAAM,CACLC,OAAO,IAAMA,OAAO,CAACC,EAAE,KAAKP,MAAM,CAACQ,MAAM,CAACD,EAC7C,CAAC,EACDP,MAAM,CAACQ,MAAM;QAEf;MACD,CAAC;IACF,KAAK,0BAA0B;MAAE;QAAA,IAAAC,sBAAA;QAChC,OAAO;UACN,GAAGV,KAAK;UACR,CAAEC,MAAM,CAACG,IAAI,GAAI;YAChB,GAAGJ,KAAK,CAAEC,MAAM,CAACG,IAAI,CAAE;YACvB,CAAEH,MAAM,CAACI,IAAI,GAAI,EAAAK,sBAAA,GAChBV,KAAK,CAAEC,MAAM,CAACG,IAAI,CAAE,GAAIH,MAAM,CAACI,IAAI,CAAE,cAAAK,sBAAA,cAAAA,sBAAA,GAAI,EAAE,EAC1CJ,MAAM,CAAIC,OAAO,IAAMA,OAAO,CAACC,EAAE,KAAKP,MAAM,CAACU,QAAS;UACzD;QACD,CAAC;MACF;EACD;EAEA,OAAOX,KAAK;AACb;AAAC,IAAAY,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,qBAAe,EAAE;EAC/BhB;AACD,CAAE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","isReady","state","action","type","kind","name","actions","_state$action$kind$ac","filter","_action","id","config","_state$action$kind$ac2","actionId","_default","exports","default","combineReducers"],"sources":["@wordpress/editor/src/dataviews/store/reducer.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport type { Action } from '@wordpress/dataviews';\n\ntype ReduxAction =\n\t| ReturnType< typeof import('./private-actions').registerEntityAction >\n\t| ReturnType< typeof import('./private-actions').unregisterEntityAction >\n\t| ReturnType< typeof import('./private-actions').setIsReady >;\n\nexport type ActionState = Record< string, Record< string, Action< any >[] > >;\nexport type ReadyState = Record< string, Record< string, boolean > >;\nexport type State = {\n\tactions: ActionState;\n\tisReady: ReadyState;\n};\n\nfunction isReady( state: ReadyState = {}, action: ReduxAction ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_READY':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: true,\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nfunction actions( state: ActionState = {}, action: ReduxAction ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_ENTITY_ACTION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: [\n\t\t\t\t\t\t...(\n\t\t\t\t\t\t\tstate[ action.kind ]?.[ action.name ] ?? []\n\t\t\t\t\t\t).filter(\n\t\t\t\t\t\t\t( _action ) => _action.id !== action.config.id\n\t\t\t\t\t\t),\n\t\t\t\t\t\taction.config,\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_ENTITY_ACTION': {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: (\n\t\t\t\t\t\tstate[ action.kind ]?.[ action.name ] ?? []\n\t\t\t\t\t).filter( ( _action ) => _action.id !== action.actionId ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tactions,\n\tisReady,\n} );\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAgBA,SAASC,OAAOA,CAAEC,KAAiB,GAAG,CAAC,CAAC,EAAEC,MAAmB,EAAG;EAC/D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,cAAc;MAClB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChB,GAAGH,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE;UACvB,CAAEF,MAAM,CAACG,IAAI,GAAI;QAClB;MACD,CAAC;EACH;EAEA,OAAOJ,KAAK;AACb;AAEA,SAASK,OAAOA,CAAEL,KAAkB,GAAG,CAAC,CAAC,EAAEC,MAAmB,EAAG;EAAA,IAAAK,qBAAA;EAChE,QAASL,MAAM,CAACC,IAAI;IACnB,KAAK,wBAAwB;MAC5B,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChB,GAAGH,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE;UACvB,CAAEF,MAAM,CAACG,IAAI,GAAI,CAChB,GAAG,EAAAE,qBAAA,GACFN,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE,GAAIF,MAAM,CAACG,IAAI,CAAE,cAAAE,qBAAA,cAAAA,qBAAA,GAAI,EAAE,EAC1CC,MAAM,CACLC,OAAO,IAAMA,OAAO,CAACC,EAAE,KAAKR,MAAM,CAACS,MAAM,CAACD,EAC7C,CAAC,EACDR,MAAM,CAACS,MAAM;QAEf;MACD,CAAC;IACF,KAAK,0BAA0B;MAAE;QAAA,IAAAC,sBAAA;QAChC,OAAO;UACN,GAAGX,KAAK;UACR,CAAEC,MAAM,CAACE,IAAI,GAAI;YAChB,GAAGH,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE;YACvB,CAAEF,MAAM,CAACG,IAAI,GAAI,EAAAO,sBAAA,GAChBX,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE,GAAIF,MAAM,CAACG,IAAI,CAAE,cAAAO,sBAAA,cAAAA,sBAAA,GAAI,EAAE,EAC1CJ,MAAM,CAAIC,OAAO,IAAMA,OAAO,CAACC,EAAE,KAAKR,MAAM,CAACW,QAAS;UACzD;QACD,CAAC;MACF;EACD;EAEA,OAAOZ,KAAK;AACb;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,qBAAe,EAAE;EAC/BX,OAAO;EACPN;AACD,CAAE,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/editor/src/dataviews/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'published'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface BasePost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\ttype: string;\n\tid: string | number;\n}\nexport interface TemplateOrTemplatePart extends BasePost {\n\ttype: 'wp_template' | 'wp_template_part';\n\tsource: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface Pattern extends BasePost {\n\tslug: string;\n\ttitle: { raw: string };\n\tcontent: { raw: string } | string;\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = TemplateOrTemplatePart | Pattern | BasePost;\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/editor/src/dataviews/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'published'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface BasePost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\ttype: string;\n\tid: string | number;\n}\nexport interface TemplateOrTemplatePart extends BasePost {\n\ttype: 'wp_template' | 'wp_template_part';\n\tsource: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface Pattern extends BasePost {\n\tslug: string;\n\ttitle: { raw: string };\n\tcontent: { raw: string } | string;\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = TemplateOrTemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\nexport interface PostType {\n\tslug: string;\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
@@ -20,7 +20,6 @@ var _toolsMoreMenuGroup = _interopRequireDefault(require("./components/more-menu
20
20
  var _viewMoreMenuGroup = _interopRequireDefault(require("./components/more-menu/view-more-menu-group"));
21
21
  var _resizableEditor = _interopRequireDefault(require("./components/resizable-editor"));
22
22
  var _globalStylesProvider = require("./components/global-styles-provider");
23
- var _actions2 = _interopRequireDefault(require("./dataviews/actions"));
24
23
  var _api = require("./bindings/api");
25
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
26
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -51,7 +50,6 @@ const privateApis = exports.privateApis = {};
51
50
  ToolsMoreMenuGroup: _toolsMoreMenuGroup.default,
52
51
  ViewMoreMenuGroup: _viewMoreMenuGroup.default,
53
52
  ResizableEditor: _resizableEditor.default,
54
- registerDefaultActions: _actions2.default,
55
53
  registerCoreBlockBindingsSources: _api.registerCoreBlockBindingsSources,
56
54
  bootstrapBlockBindingsSourcesFromServer: _api.bootstrapBlockBindingsSourcesFromServer,
57
55
  // This is a temporary private API while we're updating the site editor to use EditorProvider.
@@ -1 +1 @@
1
- {"version":3,"names":["interfaceApis","_interopRequireWildcard","require","_lockUnlock","_entitiesSavedStates","_contentSlotFill","_interopRequireDefault","_useBlockEditorSettings","_backButton","_createTemplatePartModal","_editor","_plugin","_preferencesModal","_actions","_toolsMoreMenuGroup","_viewMoreMenuGroup","_resizableEditor","_globalStylesProvider","_actions2","_api","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","store","interfaceStore","remainingInterfaceApis","privateApis","exports","lock","CreateTemplatePartModal","BackButton","EntitiesSavedStatesExtensible","Editor","EditorContentSlotFill","GlobalStylesProvider","mergeBaseAndUserConfigs","PluginPostExcerpt","PreferencesModal","usePostActions","ToolsMoreMenuGroup","ViewMoreMenuGroup","ResizableEditor","registerDefaultActions","registerCoreBlockBindingsSources","bootstrapBlockBindingsSourcesFromServer","useBlockEditorSettings"],"sources":["@wordpress/editor/src/private-apis.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport * as interfaceApis from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport EditorContentSlotFill from './components/editor-interface/content-slot-fill';\nimport useBlockEditorSettings from './components/provider/use-block-editor-settings';\nimport BackButton from './components/header/back-button';\nimport CreateTemplatePartModal from './components/create-template-part-modal';\nimport Editor from './components/editor';\nimport PluginPostExcerpt from './components/post-excerpt/plugin';\nimport PreferencesModal from './components/preferences-modal';\nimport { usePostActions } from './components/post-actions/actions';\nimport ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';\nimport ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';\nimport ResizableEditor from './components/resizable-editor';\nimport {\n\tmergeBaseAndUserConfigs,\n\tGlobalStylesProvider,\n} from './components/global-styles-provider';\nimport registerDefaultActions from './dataviews/actions';\nimport {\n\tregisterCoreBlockBindingsSources,\n\tbootstrapBlockBindingsSourcesFromServer,\n} from './bindings/api';\n\nconst { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreateTemplatePartModal,\n\tBackButton,\n\tEntitiesSavedStatesExtensible,\n\tEditor,\n\tEditorContentSlotFill,\n\tGlobalStylesProvider,\n\tmergeBaseAndUserConfigs,\n\tPluginPostExcerpt,\n\tPreferencesModal,\n\tusePostActions,\n\tToolsMoreMenuGroup,\n\tViewMoreMenuGroup,\n\tResizableEditor,\n\tregisterDefaultActions,\n\tregisterCoreBlockBindingsSources,\n\tbootstrapBlockBindingsSourcesFromServer,\n\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tuseBlockEditorSettings,\n\tinterfaceStore,\n\t...remainingInterfaceApis,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,aAAA,GAAA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CA,qCAAgC;EAChCC,uCAAuC,EAAvCA,4CAAuC;EAEvC;EACAC,sBAAsB,EAAtBA,+BAAsB;EACtBrB,cAAc;EACd,GAAGC;AACJ,CAAE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["interfaceApis","_interopRequireWildcard","require","_lockUnlock","_entitiesSavedStates","_contentSlotFill","_interopRequireDefault","_useBlockEditorSettings","_backButton","_createTemplatePartModal","_editor","_plugin","_preferencesModal","_actions","_toolsMoreMenuGroup","_viewMoreMenuGroup","_resizableEditor","_globalStylesProvider","_api","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","store","interfaceStore","remainingInterfaceApis","privateApis","exports","lock","CreateTemplatePartModal","BackButton","EntitiesSavedStatesExtensible","Editor","EditorContentSlotFill","GlobalStylesProvider","mergeBaseAndUserConfigs","PluginPostExcerpt","PreferencesModal","usePostActions","ToolsMoreMenuGroup","ViewMoreMenuGroup","ResizableEditor","registerCoreBlockBindingsSources","bootstrapBlockBindingsSourcesFromServer","useBlockEditorSettings"],"sources":["@wordpress/editor/src/private-apis.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport * as interfaceApis from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport EditorContentSlotFill from './components/editor-interface/content-slot-fill';\nimport useBlockEditorSettings from './components/provider/use-block-editor-settings';\nimport BackButton from './components/header/back-button';\nimport CreateTemplatePartModal from './components/create-template-part-modal';\nimport Editor from './components/editor';\nimport PluginPostExcerpt from './components/post-excerpt/plugin';\nimport PreferencesModal from './components/preferences-modal';\nimport { usePostActions } from './components/post-actions/actions';\nimport ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';\nimport ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';\nimport ResizableEditor from './components/resizable-editor';\nimport {\n\tmergeBaseAndUserConfigs,\n\tGlobalStylesProvider,\n} from './components/global-styles-provider';\nimport {\n\tregisterCoreBlockBindingsSources,\n\tbootstrapBlockBindingsSourcesFromServer,\n} from './bindings/api';\n\nconst { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreateTemplatePartModal,\n\tBackButton,\n\tEntitiesSavedStatesExtensible,\n\tEditor,\n\tEditorContentSlotFill,\n\tGlobalStylesProvider,\n\tmergeBaseAndUserConfigs,\n\tPluginPostExcerpt,\n\tPreferencesModal,\n\tusePostActions,\n\tToolsMoreMenuGroup,\n\tViewMoreMenuGroup,\n\tResizableEditor,\n\tregisterCoreBlockBindingsSources,\n\tbootstrapBlockBindingsSourcesFromServer,\n\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tuseBlockEditorSettings,\n\tinterfaceStore,\n\t...remainingInterfaceApis,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,WAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,wBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,OAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,OAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,iBAAA,GAAAN,sBAAA,CAAAJ,OAAA;AACA,IAAAW,QAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAR,sBAAA,CAAAJ,OAAA;AACA,IAAAa,kBAAA,GAAAT,sBAAA,CAAAJ,OAAA;AACA,IAAAc,gBAAA,GAAAV,sBAAA,CAAAJ,OAAA;AACA,IAAAe,qBAAA,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AGzC,aAAa;AAEnE,MAAM0C,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,CAAC,CAAC;AAC7B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBG,uBAAuB,EAAvBA,gCAAuB;EACvBC,UAAU,EAAVA,mBAAU;EACVC,6BAA6B,EAA7BA,kDAA6B;EAC7BC,MAAM,EAANA,eAAM;EACNC,qBAAqB,EAArBA,wBAAqB;EACrBC,oBAAoB,EAApBA,0CAAoB;EACpBC,uBAAuB,EAAvBA,6CAAuB;EACvBC,iBAAiB,EAAjBA,eAAiB;EACjBC,gBAAgB,EAAhBA,yBAAgB;EAChBC,cAAc,EAAdA,uBAAc;EACdC,kBAAkB,EAAlBA,2BAAkB;EAClBC,iBAAiB,EAAjBA,0BAAiB;EACjBC,eAAe,EAAfA,wBAAe;EACfC,gCAAgC,EAAhCA,qCAAgC;EAChCC,uCAAuC,EAAvCA,4CAAuC;EAEvC;EACAC,sBAAsB,EAAtBA,+BAAsB;EACtBpB,cAAc;EACd,GAAGC;AACJ,CAAE,CAAC","ignoreList":[]}
@@ -227,8 +227,22 @@ const savePost = (options = {}) => async ({
227
227
  type: 'REQUEST_POST_UPDATE_START',
228
228
  options
229
229
  });
230
- await registry.dispatch(_coreData.store).saveEntityRecord('postType', previousRecord.type, edits, options);
231
- let error = registry.select(_coreData.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
230
+ let error = false;
231
+ try {
232
+ error = await (0, _hooks.applyFilters)('editor.__unstablePreSavePost', Promise.resolve(false), options);
233
+ } catch (err) {
234
+ error = err;
235
+ }
236
+ if (!error) {
237
+ try {
238
+ await registry.dispatch(_coreData.store).saveEntityRecord('postType', previousRecord.type, edits, options);
239
+ } catch (err) {
240
+ error = err.message && err.code !== 'unknown_error' ? err.message : (0, _i18n.__)('An error occurred while updating.');
241
+ }
242
+ }
243
+ if (!error) {
244
+ error = registry.select(_coreData.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
245
+ }
232
246
  if (!error) {
233
247
  await (0, _hooks.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options).catch(err => {
234
248
  error = err;