@wordpress/editor 13.30.0 → 13.32.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 (219) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +857 -0
  3. package/build/bindings/index.js +3 -1
  4. package/build/bindings/index.js.map +1 -1
  5. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +107 -0
  6. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
  7. package/build/components/commands/index.js +1 -1
  8. package/build/components/commands/index.js.map +1 -1
  9. package/build/components/deprecated.js +158 -0
  10. package/build/components/deprecated.js.map +1 -1
  11. package/build/components/document-bar/index.js +7 -10
  12. package/build/components/document-bar/index.js.map +1 -1
  13. package/build/components/document-outline/index.js +1 -1
  14. package/build/components/document-outline/index.js.map +1 -1
  15. package/build/components/editor-canvas/edit-template-blocks-notification.js +2 -39
  16. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  17. package/build/components/editor-canvas/index.js +3 -0
  18. package/build/components/editor-canvas/index.js.map +1 -1
  19. package/build/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
  20. package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  21. package/build/components/entities-saved-states/index.js +28 -88
  22. package/build/components/entities-saved-states/index.js.map +1 -1
  23. package/build/components/error-boundary/index.native.js +133 -0
  24. package/build/components/error-boundary/index.native.js.map +1 -0
  25. package/build/components/index.js +33 -8
  26. package/build/components/index.js.map +1 -1
  27. package/build/components/index.native.js +9 -1
  28. package/build/components/index.native.js.map +1 -1
  29. package/build/components/inserter-sidebar/index.js +5 -1
  30. package/build/components/inserter-sidebar/index.js.map +1 -1
  31. package/build/components/list-view-sidebar/index.js +2 -1
  32. package/build/components/list-view-sidebar/index.js.map +1 -1
  33. package/build/components/pattern-overrides-panel/index.js +30 -0
  34. package/build/components/pattern-overrides-panel/index.js.map +1 -0
  35. package/build/components/plugin-document-setting-panel/index.js +123 -0
  36. package/build/components/plugin-document-setting-panel/index.js.map +1 -0
  37. package/build/components/plugin-post-publish-panel/index.js +68 -0
  38. package/build/components/plugin-post-publish-panel/index.js.map +1 -0
  39. package/build/components/plugin-pre-publish-panel/index.js +71 -0
  40. package/build/components/plugin-pre-publish-panel/index.js.map +1 -0
  41. package/build/components/post-actions/actions.js +455 -0
  42. package/build/components/post-actions/actions.js.map +1 -0
  43. package/build/components/post-card-panel/index.js +93 -0
  44. package/build/components/post-card-panel/index.js.map +1 -0
  45. package/build/components/post-featured-image/index.js +3 -8
  46. package/build/components/post-featured-image/index.js.map +1 -1
  47. package/build/components/post-featured-image/panel.js +7 -3
  48. package/build/components/post-featured-image/panel.js.map +1 -1
  49. package/build/components/post-sync-status/index.js +0 -72
  50. package/build/components/post-sync-status/index.js.map +1 -1
  51. package/build/components/post-taxonomies/flat-term-selector.js +7 -3
  52. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  53. package/build/components/post-title/index.native.js +1 -1
  54. package/build/components/post-title/index.native.js.map +1 -1
  55. package/build/components/provider/disable-non-page-content-blocks.js +36 -20
  56. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  57. package/build/components/provider/index.js +1 -1
  58. package/build/components/provider/index.js.map +1 -1
  59. package/build/components/provider/use-block-editor-settings.js +8 -9
  60. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  61. package/build/components/provider/use-hide-blocks-from-inserter.js +4 -3
  62. package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
  63. package/build/components/template-areas/index.js +70 -0
  64. package/build/components/template-areas/index.js.map +1 -0
  65. package/build/hooks/use-select-nearest-editable-block.js +87 -0
  66. package/build/hooks/use-select-nearest-editable-block.js.map +1 -0
  67. package/build/private-apis.js +6 -2
  68. package/build/private-apis.js.map +1 -1
  69. package/build/store/actions.js +46 -6
  70. package/build/store/actions.js.map +1 -1
  71. package/build/store/constants.js +3 -1
  72. package/build/store/constants.js.map +1 -1
  73. package/build/store/private-actions.js +80 -1
  74. package/build/store/private-actions.js.map +1 -1
  75. package/build/store/private-selectors.js +56 -3
  76. package/build/store/private-selectors.js.map +1 -1
  77. package/build/store/reducer.js +14 -1
  78. package/build/store/reducer.js.map +1 -1
  79. package/build/store/selectors.js +21 -11
  80. package/build/store/selectors.js.map +1 -1
  81. package/build/store/utils/get-filtered-template-parts.js +71 -0
  82. package/build/store/utils/get-filtered-template-parts.js.map +1 -0
  83. package/build-module/bindings/index.js +3 -1
  84. package/build-module/bindings/index.js.map +1 -1
  85. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +100 -0
  86. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
  87. package/build-module/components/commands/index.js +1 -1
  88. package/build-module/components/commands/index.js.map +1 -1
  89. package/build-module/components/deprecated.js +159 -0
  90. package/build-module/components/deprecated.js.map +1 -1
  91. package/build-module/components/document-bar/index.js +8 -11
  92. package/build-module/components/document-bar/index.js.map +1 -1
  93. package/build-module/components/document-outline/index.js +1 -1
  94. package/build-module/components/document-outline/index.js.map +1 -1
  95. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +4 -41
  96. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  97. package/build-module/components/editor-canvas/index.js +3 -0
  98. package/build-module/components/editor-canvas/index.js.map +1 -1
  99. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
  100. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  101. package/build-module/components/entities-saved-states/index.js +29 -89
  102. package/build-module/components/entities-saved-states/index.js.map +1 -1
  103. package/build-module/components/error-boundary/index.native.js +125 -0
  104. package/build-module/components/error-boundary/index.native.js.map +1 -0
  105. package/build-module/components/index.js +5 -1
  106. package/build-module/components/index.js.map +1 -1
  107. package/build-module/components/index.native.js +1 -0
  108. package/build-module/components/index.native.js.map +1 -1
  109. package/build-module/components/inserter-sidebar/index.js +5 -1
  110. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  111. package/build-module/components/list-view-sidebar/index.js +2 -1
  112. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  113. package/build-module/components/pattern-overrides-panel/index.js +23 -0
  114. package/build-module/components/pattern-overrides-panel/index.js.map +1 -0
  115. package/build-module/components/plugin-document-setting-panel/index.js +115 -0
  116. package/build-module/components/plugin-document-setting-panel/index.js.map +1 -0
  117. package/build-module/components/plugin-post-publish-panel/index.js +61 -0
  118. package/build-module/components/plugin-post-publish-panel/index.js.map +1 -0
  119. package/build-module/components/plugin-pre-publish-panel/index.js +64 -0
  120. package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -0
  121. package/build-module/components/post-actions/actions.js +444 -0
  122. package/build-module/components/post-actions/actions.js.map +1 -0
  123. package/build-module/components/post-card-panel/index.js +85 -0
  124. package/build-module/components/post-card-panel/index.js.map +1 -0
  125. package/build-module/components/post-featured-image/index.js +4 -9
  126. package/build-module/components/post-featured-image/index.js.map +1 -1
  127. package/build-module/components/post-featured-image/panel.js +6 -2
  128. package/build-module/components/post-featured-image/panel.js.map +1 -1
  129. package/build-module/components/post-sync-status/index.js +2 -73
  130. package/build-module/components/post-sync-status/index.js.map +1 -1
  131. package/build-module/components/post-taxonomies/flat-term-selector.js +7 -3
  132. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  133. package/build-module/components/post-title/index.native.js +1 -1
  134. package/build-module/components/post-title/index.native.js.map +1 -1
  135. package/build-module/components/provider/disable-non-page-content-blocks.js +36 -20
  136. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  137. package/build-module/components/provider/index.js +1 -1
  138. package/build-module/components/provider/index.js.map +1 -1
  139. package/build-module/components/provider/use-block-editor-settings.js +9 -10
  140. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  141. package/build-module/components/provider/use-hide-blocks-from-inserter.js +4 -3
  142. package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
  143. package/build-module/components/template-areas/index.js +63 -0
  144. package/build-module/components/template-areas/index.js.map +1 -0
  145. package/build-module/hooks/use-select-nearest-editable-block.js +80 -0
  146. package/build-module/hooks/use-select-nearest-editable-block.js.map +1 -0
  147. package/build-module/private-apis.js +6 -2
  148. package/build-module/private-apis.js.map +1 -1
  149. package/build-module/store/actions.js +37 -3
  150. package/build-module/store/actions.js.map +1 -1
  151. package/build-module/store/constants.js +2 -0
  152. package/build-module/store/constants.js.map +1 -1
  153. package/build-module/store/private-actions.js +78 -0
  154. package/build-module/store/private-actions.js.map +1 -1
  155. package/build-module/store/private-selectors.js +54 -3
  156. package/build-module/store/private-selectors.js.map +1 -1
  157. package/build-module/store/reducer.js +13 -1
  158. package/build-module/store/reducer.js.map +1 -1
  159. package/build-module/store/selectors.js +19 -10
  160. package/build-module/store/selectors.js.map +1 -1
  161. package/build-module/store/utils/get-filtered-template-parts.js +64 -0
  162. package/build-module/store/utils/get-filtered-template-parts.js.map +1 -0
  163. package/build-style/style-rtl.css +76 -33
  164. package/build-style/style.css +76 -33
  165. package/package.json +35 -33
  166. package/src/bindings/index.js +4 -1
  167. package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +108 -0
  168. package/src/components/commands/index.js +1 -1
  169. package/src/components/deprecated.js +157 -0
  170. package/src/components/document-bar/index.js +12 -17
  171. package/src/components/document-bar/style.scss +9 -12
  172. package/src/components/document-outline/index.js +2 -1
  173. package/src/components/document-tools/style.scss +4 -11
  174. package/src/components/editor-canvas/edit-template-blocks-notification.js +6 -56
  175. package/src/components/editor-canvas/index.js +4 -0
  176. package/src/components/entities-saved-states/hooks/use-is-dirty.js +18 -22
  177. package/src/components/entities-saved-states/index.js +45 -121
  178. package/src/components/entities-saved-states/test/use-is-dirty.js +3 -0
  179. package/src/components/error-boundary/index.native.js +192 -0
  180. package/src/components/error-boundary/style.native.scss +116 -0
  181. package/src/components/index.js +5 -4
  182. package/src/components/index.native.js +1 -0
  183. package/src/components/inserter-sidebar/index.js +7 -1
  184. package/src/components/list-view-sidebar/index.js +1 -0
  185. package/src/components/list-view-sidebar/style.scss +1 -1
  186. package/src/components/pattern-overrides-panel/index.js +26 -0
  187. package/src/components/plugin-document-setting-panel/index.js +121 -0
  188. package/src/components/plugin-post-publish-panel/index.js +64 -0
  189. package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +39 -0
  190. package/src/components/plugin-post-publish-panel/test/index.js +33 -0
  191. package/src/components/plugin-pre-publish-panel/index.js +67 -0
  192. package/src/components/plugin-pre-publish-panel/test/index.js +33 -0
  193. package/src/components/post-actions/actions.js +582 -0
  194. package/src/components/post-card-panel/index.js +108 -0
  195. package/src/components/post-card-panel/style.scss +32 -0
  196. package/src/components/post-featured-image/index.js +6 -15
  197. package/src/components/post-featured-image/panel.js +9 -3
  198. package/src/components/post-featured-image/style.scss +9 -13
  199. package/src/components/post-sync-status/index.js +1 -94
  200. package/src/components/post-taxonomies/flat-term-selector.js +13 -8
  201. package/src/components/post-title/index.native.js +1 -1
  202. package/src/components/provider/disable-non-page-content-blocks.js +40 -20
  203. package/src/components/provider/index.js +1 -1
  204. package/src/components/provider/test/disable-non-page-content-blocks.js +35 -14
  205. package/src/components/provider/use-block-editor-settings.js +11 -11
  206. package/src/components/provider/use-hide-blocks-from-inserter.js +5 -3
  207. package/src/components/template-areas/index.js +85 -0
  208. package/src/components/template-areas/style.scss +23 -0
  209. package/src/hooks/use-select-nearest-editable-block.js +95 -0
  210. package/src/private-apis.js +6 -2
  211. package/src/store/actions.js +37 -3
  212. package/src/store/constants.js +2 -0
  213. package/src/store/private-actions.js +111 -0
  214. package/src/store/private-selectors.js +105 -17
  215. package/src/store/reducer.js +13 -0
  216. package/src/store/selectors.js +50 -40
  217. package/src/store/utils/get-filtered-template-parts.js +69 -0
  218. package/src/store/utils/test/get-filtered-template-parts.js +189 -0
  219. package/src/style.scss +2 -0
@@ -0,0 +1,444 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { external, trash, edit, backup } from '@wordpress/icons';
6
+ import { addQueryArgs } from '@wordpress/url';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { decodeEntities } from '@wordpress/html-entities';
9
+ import { store as coreStore } from '@wordpress/core-data';
10
+ import { __, _n, sprintf } from '@wordpress/i18n';
11
+ import { store as noticesStore } from '@wordpress/notices';
12
+ import { useMemo, useState } from '@wordpress/element';
13
+ import { Button, TextControl, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
14
+ function getItemTitle(item) {
15
+ if (typeof item.title === 'string') {
16
+ return decodeEntities(item.title);
17
+ }
18
+ return decodeEntities(item.title?.rendered || '');
19
+ }
20
+ export const trashPostAction = {
21
+ id: 'move-to-trash',
22
+ label: __('Move to Trash'),
23
+ isPrimary: true,
24
+ icon: trash,
25
+ isEligible({
26
+ status
27
+ }) {
28
+ return status !== 'trash';
29
+ },
30
+ supportsBulk: true,
31
+ hideModalHeader: true,
32
+ RenderModal: ({
33
+ items: posts,
34
+ closeModal,
35
+ onActionPerformed
36
+ }) => {
37
+ const {
38
+ createSuccessNotice,
39
+ createErrorNotice
40
+ } = useDispatch(noticesStore);
41
+ const {
42
+ deleteEntityRecord
43
+ } = useDispatch(coreStore);
44
+ return createElement(VStack, {
45
+ spacing: "5"
46
+ }, createElement(Text, null, posts.length === 1 ? sprintf(
47
+ // translators: %s: The page's title.
48
+ __('Are you sure you want to delete "%s"?'), getItemTitle(posts[0])) : sprintf(
49
+ // translators: %d: The number of pages (2 or more).
50
+ _n('Are you sure you want to delete %d page?', 'Are you sure you want to delete %d pages?', posts.length), posts.length)), createElement(HStack, {
51
+ justify: "right"
52
+ }, createElement(Button, {
53
+ variant: "tertiary",
54
+ onClick: closeModal
55
+ }, __('Cancel')), createElement(Button, {
56
+ variant: "primary",
57
+ onClick: async () => {
58
+ const promiseResult = await Promise.allSettled(posts.map(post => {
59
+ return deleteEntityRecord('postType', post.type, post.id, {}, {
60
+ throwOnError: true
61
+ });
62
+ }));
63
+ // If all the promises were fulfilled with success.
64
+ if (promiseResult.every(({
65
+ status
66
+ }) => status === 'fulfilled')) {
67
+ let successMessage;
68
+ if (promiseResult.length === 1) {
69
+ successMessage = sprintf( /* translators: The posts's title. */
70
+ __('"%s" moved to the Trash.'), getItemTitle(posts[0]));
71
+ } else {
72
+ successMessage = __('Pages moved to the Trash.');
73
+ }
74
+ createSuccessNotice(successMessage, {
75
+ type: 'snackbar',
76
+ id: 'edit-site-page-trashed'
77
+ });
78
+ } else {
79
+ // If there was at lease one failure.
80
+ let errorMessage;
81
+ // If we were trying to move a single post to the trash.
82
+ if (promiseResult.length === 1) {
83
+ if (promiseResult[0].reason?.message) {
84
+ errorMessage = promiseResult[0].reason.message;
85
+ } else {
86
+ errorMessage = __('An error occurred while moving the post to the trash.');
87
+ }
88
+ // If we were trying to move multiple posts to the trash
89
+ } else {
90
+ const errorMessages = new Set();
91
+ const failedPromises = promiseResult.filter(({
92
+ status
93
+ }) => status === 'rejected');
94
+ for (const failedPromise of failedPromises) {
95
+ if (failedPromise.reason?.message) {
96
+ errorMessages.add(failedPromise.reason.message);
97
+ }
98
+ }
99
+ if (errorMessages.size === 0) {
100
+ errorMessage = __('An error occurred while moving the posts to the trash.');
101
+ } else if (errorMessages.size === 1) {
102
+ errorMessage = sprintf( /* translators: %s: an error message */
103
+ __('An error occurred while moving the posts to the trash: %s'), [...errorMessages][0]);
104
+ } else {
105
+ errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
106
+ __('Some errors occurred while moving the pages to the trash: %s'), [...errorMessages].join(','));
107
+ }
108
+ createErrorNotice(errorMessage, {
109
+ type: 'snackbar'
110
+ });
111
+ }
112
+ }
113
+ if (onActionPerformed) {
114
+ onActionPerformed(posts);
115
+ }
116
+ closeModal();
117
+ }
118
+ }, __('Delete'))));
119
+ }
120
+ };
121
+ export function usePermanentlyDeletePostAction() {
122
+ const {
123
+ createSuccessNotice,
124
+ createErrorNotice
125
+ } = useDispatch(noticesStore);
126
+ const {
127
+ deleteEntityRecord
128
+ } = useDispatch(coreStore);
129
+ return useMemo(() => ({
130
+ id: 'permanently-delete',
131
+ label: __('Permanently delete'),
132
+ supportsBulk: true,
133
+ isEligible({
134
+ status
135
+ }) {
136
+ return status === 'trash';
137
+ },
138
+ async callback(posts, onActionPerformed) {
139
+ const promiseResult = await Promise.allSettled(posts.map(post => {
140
+ return deleteEntityRecord('postType', post.type, post.id, {
141
+ force: true
142
+ }, {
143
+ throwOnError: true
144
+ });
145
+ }));
146
+ // If all the promises were fulfilled with success.
147
+ if (promiseResult.every(({
148
+ status
149
+ }) => status === 'fulfilled')) {
150
+ let successMessage;
151
+ if (promiseResult.length === 1) {
152
+ successMessage = sprintf( /* translators: The posts's title. */
153
+ __('"%s" permanently deleted.'), getItemTitle(posts[0]));
154
+ } else {
155
+ successMessage = __('The posts were permanently deleted.');
156
+ }
157
+ createSuccessNotice(successMessage, {
158
+ type: 'snackbar',
159
+ id: 'edit-site-post-permanently-deleted'
160
+ });
161
+ if (onActionPerformed) {
162
+ onActionPerformed(posts);
163
+ }
164
+ } else {
165
+ // If there was at lease one failure.
166
+ let errorMessage;
167
+ // If we were trying to permanently delete a single post.
168
+ if (promiseResult.length === 1) {
169
+ if (promiseResult[0].reason?.message) {
170
+ errorMessage = promiseResult[0].reason.message;
171
+ } else {
172
+ errorMessage = __('An error occurred while permanently deleting the post.');
173
+ }
174
+ // If we were trying to permanently delete multiple posts
175
+ } else {
176
+ const errorMessages = new Set();
177
+ const failedPromises = promiseResult.filter(({
178
+ status
179
+ }) => status === 'rejected');
180
+ for (const failedPromise of failedPromises) {
181
+ if (failedPromise.reason?.message) {
182
+ errorMessages.add(failedPromise.reason.message);
183
+ }
184
+ }
185
+ if (errorMessages.size === 0) {
186
+ errorMessage = __('An error occurred while permanently deleting the posts.');
187
+ } else if (errorMessages.size === 1) {
188
+ errorMessage = sprintf( /* translators: %s: an error message */
189
+ __('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]);
190
+ } else {
191
+ errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
192
+ __('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(','));
193
+ }
194
+ createErrorNotice(errorMessage, {
195
+ type: 'snackbar'
196
+ });
197
+ }
198
+ }
199
+ }
200
+ }), [createSuccessNotice, createErrorNotice, deleteEntityRecord]);
201
+ }
202
+ export function useRestorePostAction() {
203
+ const {
204
+ createSuccessNotice,
205
+ createErrorNotice
206
+ } = useDispatch(noticesStore);
207
+ const {
208
+ editEntityRecord,
209
+ saveEditedEntityRecord
210
+ } = useDispatch(coreStore);
211
+ return useMemo(() => ({
212
+ id: 'restore',
213
+ label: __('Restore'),
214
+ isPrimary: true,
215
+ icon: backup,
216
+ supportsBulk: true,
217
+ isEligible({
218
+ status
219
+ }) {
220
+ return status === 'trash';
221
+ },
222
+ async callback(posts, onActionPerformed) {
223
+ try {
224
+ for (const post of posts) {
225
+ await editEntityRecord('postType', post.type, post.id, {
226
+ status: 'draft'
227
+ });
228
+ await saveEditedEntityRecord('postType', post.type, post.id, {
229
+ throwOnError: true
230
+ });
231
+ }
232
+ createSuccessNotice(posts.length > 1 ? sprintf( /* translators: The number of posts. */
233
+ __('%d posts have been restored.'), posts.length) : sprintf( /* translators: The number of posts. */
234
+ __('"%s" has been restored.'), getItemTitle(posts[0])), {
235
+ type: 'snackbar',
236
+ id: 'edit-site-post-restored'
237
+ });
238
+ if (onActionPerformed) {
239
+ onActionPerformed(posts);
240
+ }
241
+ } catch (error) {
242
+ let errorMessage;
243
+ if (error.message && error.code !== 'unknown_error' && error.message) {
244
+ errorMessage = error.message;
245
+ } else if (posts.length > 1) {
246
+ errorMessage = __('An error occurred while restoring the posts.');
247
+ } else {
248
+ errorMessage = __('An error occurred while restoring the post.');
249
+ }
250
+ createErrorNotice(errorMessage, {
251
+ type: 'snackbar'
252
+ });
253
+ }
254
+ }
255
+ }), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]);
256
+ }
257
+ export const viewPostAction = {
258
+ id: 'view-post',
259
+ label: __('View'),
260
+ isPrimary: true,
261
+ icon: external,
262
+ isEligible(post) {
263
+ return post.status !== 'trash';
264
+ },
265
+ callback(posts, onActionPerformed) {
266
+ const post = posts[0];
267
+ window.open(post.link, '_blank');
268
+ if (onActionPerformed) {
269
+ onActionPerformed(posts);
270
+ }
271
+ }
272
+ };
273
+ export const editPostAction = {
274
+ id: 'edit-post',
275
+ label: __('Edit'),
276
+ isPrimary: true,
277
+ icon: edit,
278
+ isEligible({
279
+ status
280
+ }) {
281
+ return status !== 'trash';
282
+ },
283
+ callback(posts, onActionPerformed) {
284
+ if (onActionPerformed) {
285
+ onActionPerformed(posts);
286
+ }
287
+ }
288
+ };
289
+ export const postRevisionsAction = {
290
+ id: 'view-post-revisions',
291
+ label: __('View revisions'),
292
+ isPrimary: false,
293
+ isEligible: post => {
294
+ var _post$_links$predeces, _post$_links$version;
295
+ if (post.status === 'trash') {
296
+ return false;
297
+ }
298
+ const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
299
+ const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
300
+ return lastRevisionId && revisionsCount > 1;
301
+ },
302
+ callback(posts, onActionPerformed) {
303
+ const post = posts[0];
304
+ const href = addQueryArgs('revision.php', {
305
+ revision: post?._links?.['predecessor-version']?.[0]?.id
306
+ });
307
+ document.location.href = href;
308
+ if (onActionPerformed) {
309
+ onActionPerformed(posts);
310
+ }
311
+ }
312
+ };
313
+ export const renamePostAction = {
314
+ id: 'rename-post',
315
+ label: __('Rename'),
316
+ isEligible(post) {
317
+ return post.status !== 'trash';
318
+ },
319
+ RenderModal: ({
320
+ items,
321
+ closeModal
322
+ }) => {
323
+ const [item] = items;
324
+ const originalTitle = decodeEntities(typeof item.title === 'string' ? item.title : item.title.rendered);
325
+ const [title, setTitle] = useState(() => originalTitle);
326
+ const {
327
+ editEntityRecord,
328
+ saveEditedEntityRecord
329
+ } = useDispatch(coreStore);
330
+ const {
331
+ createSuccessNotice,
332
+ createErrorNotice
333
+ } = useDispatch(noticesStore);
334
+ async function onRename(event) {
335
+ event.preventDefault();
336
+ try {
337
+ await editEntityRecord('postType', item.type, item.id, {
338
+ title
339
+ });
340
+ // Update state before saving rerenders the list.
341
+ setTitle('');
342
+ closeModal();
343
+ // Persist edited entity.
344
+ await saveEditedEntityRecord('postType', item.type, item.id, {
345
+ throwOnError: true
346
+ });
347
+ createSuccessNotice(__('Name updated'), {
348
+ type: 'snackbar'
349
+ });
350
+ } catch (error) {
351
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while updating the name');
352
+ createErrorNotice(errorMessage, {
353
+ type: 'snackbar'
354
+ });
355
+ }
356
+ }
357
+ return createElement("form", {
358
+ onSubmit: onRename
359
+ }, createElement(VStack, {
360
+ spacing: "5"
361
+ }, createElement(TextControl, {
362
+ __nextHasNoMarginBottom: true,
363
+ __next40pxDefaultSize: true,
364
+ label: __('Name'),
365
+ value: title,
366
+ onChange: setTitle,
367
+ required: true
368
+ }), createElement(HStack, {
369
+ justify: "right"
370
+ }, createElement(Button, {
371
+ __next40pxDefaultSize: true,
372
+ variant: "tertiary",
373
+ onClick: () => {
374
+ closeModal();
375
+ }
376
+ }, __('Cancel')), createElement(Button, {
377
+ __next40pxDefaultSize: true,
378
+ variant: "primary",
379
+ type: "submit"
380
+ }, __('Save')))));
381
+ }
382
+ };
383
+ export function usePostActions(onActionPerformed, actionIds = null) {
384
+ const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
385
+ const restorePostAction = useRestorePostAction();
386
+ return useMemo(() => {
387
+ // By default, return all actions...
388
+ const defaultActions = [editPostAction, viewPostAction, restorePostAction, permanentlyDeletePostAction, postRevisionsAction, renamePostAction, trashPostAction];
389
+
390
+ // ... unless `actionIds` was specified, in which case we find the
391
+ // actions matching the given IDs.
392
+ const actions = actionIds ? actionIds.map(actionId => defaultActions.find(({
393
+ id
394
+ }) => actionId === id)) : defaultActions;
395
+ if (onActionPerformed) {
396
+ for (let i = 0; i < actions.length; ++i) {
397
+ if (actions[i].callback) {
398
+ const existingCallback = actions[i].callback;
399
+ actions[i] = {
400
+ ...actions[i],
401
+ callback: (items, _onActionPerformed) => {
402
+ existingCallback(items, _items => {
403
+ if (_onActionPerformed) {
404
+ _onActionPerformed(_items);
405
+ }
406
+ onActionPerformed(actions[i].id, _items);
407
+ });
408
+ }
409
+ };
410
+ }
411
+ if (actions[i].RenderModal) {
412
+ const ExistingRenderModal = actions[i].RenderModal;
413
+ actions[i] = {
414
+ ...actions[i],
415
+ RenderModal: props => {
416
+ return createElement(ExistingRenderModal, {
417
+ items: props.items,
418
+ closeModal: props.closeModal,
419
+ onActionPerformed: _items => {
420
+ if (props.onActionPerformed) {
421
+ props.onActionPerformed(_items);
422
+ }
423
+ onActionPerformed(actions[i].id, _items);
424
+ }
425
+ });
426
+ }
427
+ };
428
+ }
429
+ }
430
+ }
431
+ return actions;
432
+ },
433
+ // Disable reason: if provided, `actionIds` is a shallow array of
434
+ // strings, and the strings themselves should be part of the useMemo
435
+ // dependencies. Two different disable statements are needed, as the
436
+ // first flags what it thinks are missing dependencies, and the second
437
+ // flags the array spread operation.
438
+ //
439
+ // eslint-disable-next-line react-hooks/exhaustive-deps
440
+ [
441
+ // eslint-disable-next-line react-hooks/exhaustive-deps
442
+ ...(actionIds || []), permanentlyDeletePostAction, restorePostAction, onActionPerformed]);
443
+ }
444
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["external","trash","edit","backup","addQueryArgs","useDispatch","decodeEntities","store","coreStore","__","_n","sprintf","noticesStore","useMemo","useState","Button","TextControl","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","getItemTitle","item","title","rendered","trashPostAction","id","label","isPrimary","icon","isEligible","status","supportsBulk","hideModalHeader","RenderModal","items","posts","closeModal","onActionPerformed","createSuccessNotice","createErrorNotice","deleteEntityRecord","createElement","spacing","length","justify","variant","onClick","promiseResult","Promise","allSettled","map","post","type","throwOnError","every","successMessage","errorMessage","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join","usePermanentlyDeletePostAction","callback","force","useRestorePostAction","editEntityRecord","saveEditedEntityRecord","error","code","viewPostAction","window","open","link","editPostAction","postRevisionsAction","_post$_links$predeces","_post$_links$version","lastRevisionId","_links","revisionsCount","count","href","revision","document","location","renamePostAction","originalTitle","setTitle","onRename","event","preventDefault","onSubmit","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","required","usePostActions","actionIds","permanentlyDeletePostAction","restorePostAction","defaultActions","actions","actionId","find","i","existingCallback","_onActionPerformed","_items","ExistingRenderModal","props"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external, trash, edit, backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useMemo, useState } from '@wordpress/element';\n\nimport {\n\tButton,\n\tTextControl,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\nfunction getItemTitle( item ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\treturn decodeEntities( item.title?.rendered || '' );\n}\n\nexport const trashPostAction = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to Trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items: posts, closeModal, onActionPerformed } ) => {\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{ posts.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The page's title.\n\t\t\t\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\t\t\t\tgetItemTitle( posts[ 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 pages (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 delete %d page?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to delete %d pages?',\n\t\t\t\t\t\t\t\t\tposts.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tposts.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 variant=\"tertiary\" onClick={ closeModal }>\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\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\tposts.map( ( post ) => {\n\t\t\t\t\t\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\t\t\t\tpost.id,\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 posts'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( posts[ 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 = __(\n\t\t\t\t\t\t\t\t\t\t'Pages moved to the Trash.'\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: 'edit-site-page-trashed',\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 lease 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 move a single post to the trash.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\tpromiseResult[ 0 ].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 post 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 move multiple posts to the trash\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\tif ( failedPromise.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\tfailedPromise.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 posts 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 posts 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 pages 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\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\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\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( posts );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\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 function usePermanentlyDeletePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'permanently-delete',\n\t\t\tlabel: __( 'Permanently delete' ),\n\t\t\tsupportsBulk: true,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( posts, onActionPerformed ) {\n\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\tposts.map( ( post ) => {\n\t\t\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t);\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\tif (\n\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tlet successMessage;\n\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsuccessMessage = __(\n\t\t\t\t\t\t\t'The posts were permanently deleted.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'edit-site-post-permanently-deleted',\n\t\t\t\t\t} );\n\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\tonActionPerformed( posts );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If there was at lease one failure.\n\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t// If we were trying to permanently delete a single post.\n\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the post.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\tfailedPromise.reason.message\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the posts.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the posts: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terrorMessage = sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the posts: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\ttype: 'snackbar',\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} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function useRestorePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'restore',\n\t\t\tlabel: __( 'Restore' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tsupportsBulk: true,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( posts, onActionPerformed ) {\n\t\t\t\ttry {\n\t\t\t\t\tfor ( const post of posts ) {\n\t\t\t\t\t\tawait editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tposts.length > 1\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\t\t\t\t\tposts.length\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-restored',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\tonActionPerformed( posts );\n\t\t\t\t\t}\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tlet errorMessage;\n\t\t\t\t\tif (\n\t\t\t\t\t\terror.message &&\n\t\t\t\t\t\terror.code !== 'unknown_error' &&\n\t\t\t\t\t\terror.message\n\t\t\t\t\t) {\n\t\t\t\t\t\terrorMessage = error.message;\n\t\t\t\t\t} else if ( posts.length > 1 ) {\n\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( posts, onActionPerformed ) {\n\t\tconst post = posts[ 0 ];\n\t\twindow.open( post.link, '_blank' );\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport const editPostAction = {\n\tid: 'edit-post',\n\tlabel: __( 'Edit' ),\n\tisPrimary: true,\n\ticon: edit,\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\tcallback( posts, onActionPerformed ) {\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\nexport const postRevisionsAction = {\n\tid: 'view-post-revisions',\n\tlabel: __( 'View revisions' ),\n\tisPrimary: false,\n\tisEligible: ( post ) => {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( posts, onActionPerformed ) {\n\t\tconst post = posts[ 0 ];\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport const renamePostAction = {\n\tid: 'rename-post',\n\tlabel: __( 'Rename' ),\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tRenderModal: ( { items, closeModal } ) => {\n\t\tconst [ item ] = items;\n\t\tconst originalTitle = decodeEntities(\n\t\t\ttypeof item.title === 'string' ? item.title : item.title.rendered\n\t\t);\n\t\tconst [ title, setTitle ] = useState( () => originalTitle );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tuseDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\tasync function onRename( event ) {\n\t\t\tevent.preventDefault();\n\t\t\ttry {\n\t\t\t\tawait editEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\t\ttitle,\n\t\t\t\t} );\n\t\t\t\t// Update state before saving rerenders the list.\n\t\t\t\tsetTitle( '' );\n\t\t\t\tcloseModal();\n\t\t\t\t// Persist edited entity.\n\t\t\t\tawait saveEditedEntityRecord( 'postType', item.type, item.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t\tcreateSuccessNotice( __( 'Name updated' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} catch ( error ) {\n\t\t\t\tconst errorMessage =\n\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: __( 'An error occurred while updating the name' );\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t);\n\t},\n};\n\nexport function usePostActions( onActionPerformed, actionIds = null ) {\n\tconst permanentlyDeletePostAction = usePermanentlyDeletePostAction();\n\tconst restorePostAction = useRestorePostAction();\n\treturn useMemo(\n\t\t() => {\n\t\t\t// By default, return all actions...\n\t\t\tconst defaultActions = [\n\t\t\t\teditPostAction,\n\t\t\t\tviewPostAction,\n\t\t\t\trestorePostAction,\n\t\t\t\tpermanentlyDeletePostAction,\n\t\t\t\tpostRevisionsAction,\n\t\t\t\trenamePostAction,\n\t\t\t\ttrashPostAction,\n\t\t\t];\n\n\t\t\t// ... unless `actionIds` was specified, in which case we find the\n\t\t\t// actions matching the given IDs.\n\t\t\tconst actions = actionIds\n\t\t\t\t? actionIds.map( ( actionId ) =>\n\t\t\t\t\t\tdefaultActions.find( ( { id } ) => actionId === id )\n\t\t\t\t )\n\t\t\t\t: defaultActions;\n\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\t\tcallback: ( items, _onActionPerformed ) => {\n\t\t\t\t\t\t\t\texistingCallback( items, ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( _onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t_onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\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};\n\t\t\t\t\t}\n\t\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t\titems={ props.items }\n\t\t\t\t\t\t\t\t\t\tcloseModal={ props.closeModal }\n\t\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t\t_items\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);\n\t\t\t\t\t\t\t},\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\treturn actions;\n\t\t},\n\n\t\t// Disable reason: if provided, `actionIds` is a shallow array of\n\t\t// strings, and the strings themselves should be part of the useMemo\n\t\t// dependencies. Two different disable statements are needed, as the\n\t\t// first flags what it thinks are missing dependencies, and the second\n\t\t// flags the array spread operation.\n\t\t//\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t...( actionIds || [] ),\n\t\t\tpermanentlyDeletePostAction,\n\t\t\trestorePostAction,\n\t\t\tonActionPerformed,\n\t\t]\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,KAAK,EAAEC,IAAI,EAAEC,MAAM,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASJ,KAAK,IAAIK,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AAEtD,SACCC,MAAM,EACNC,WAAW,EACXC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAE9B,SAASC,YAAYA,CAAEC,IAAI,EAAG;EAC7B,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAOnB,cAAc,CAAEkB,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,OAAOnB,cAAc,CAAEkB,IAAI,CAACC,KAAK,E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;UACD,CAAC;QACF;MACD;IACD;IACA,OAAON,OAAO;EACf,CAAC;EAED;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACC;EACA,IAAKJ,SAAS,IAAI,EAAE,CAAE,EACtBC,2BAA2B,EAC3BC,iBAAiB,EACjBrE,iBAAiB,CAEnB,CAAC;AACF"}
@@ -0,0 +1,85 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import classnames from 'classnames';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { Icon, __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalText as Text, PanelBody } from '@wordpress/components';
11
+ import { store as coreStore } from '@wordpress/core-data';
12
+ import { useSelect } from '@wordpress/data';
13
+ import { __, sprintf } from '@wordpress/i18n';
14
+ import { humanTimeDiff } from '@wordpress/date';
15
+ import { decodeEntities } from '@wordpress/html-entities';
16
+
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+ import { store as editorStore } from '../../store';
21
+ import { TEMPLATE_POST_TYPE } from '../../store/constants';
22
+ import { unlock } from '../../lock-unlock';
23
+ import TemplateAreas from '../template-areas';
24
+ export default function PostCardPanel({
25
+ className,
26
+ actions
27
+ }) {
28
+ const {
29
+ modified,
30
+ title,
31
+ templateInfo,
32
+ icon,
33
+ postType
34
+ } = useSelect(select => {
35
+ const {
36
+ getEditedPostAttribute,
37
+ getCurrentPostType,
38
+ getCurrentPostId,
39
+ __experimentalGetTemplateInfo
40
+ } = select(editorStore);
41
+ const {
42
+ getEditedEntityRecord
43
+ } = select(coreStore);
44
+ const _type = getCurrentPostType();
45
+ const _id = getCurrentPostId();
46
+ const _record = getEditedEntityRecord('postType', _type, _id);
47
+ const _templateInfo = __experimentalGetTemplateInfo(_record);
48
+ return {
49
+ title: _templateInfo?.title || getEditedPostAttribute('title'),
50
+ modified: getEditedPostAttribute('modified'),
51
+ id: _id,
52
+ postType: _type,
53
+ templateInfo: _templateInfo,
54
+ icon: unlock(select(editorStore)).getPostIcon(_type, {
55
+ area: _record?.area
56
+ })
57
+ };
58
+ });
59
+ const description = templateInfo?.description;
60
+ const lastEditedText = modified && sprintf(
61
+ // translators: %s: Human-readable time difference, e.g. "2 days ago".
62
+ __('Last edited %s.'), humanTimeDiff(modified));
63
+ return createElement(PanelBody, null, createElement("div", {
64
+ className: classnames('editor-post-card-panel', className)
65
+ }, createElement(HStack, {
66
+ spacing: 2,
67
+ className: "editor-post-card-panel__header",
68
+ align: "flex-start"
69
+ }, createElement(Icon, {
70
+ className: "editor-post-card-panel__icon",
71
+ icon: icon
72
+ }), createElement(Text, {
73
+ numberOfLines: 2,
74
+ truncate: true,
75
+ className: "editor-post-card-panel__title",
76
+ weight: 500,
77
+ as: "h2"
78
+ }, title ? decodeEntities(title) : __('No Title')), actions), createElement(VStack, {
79
+ className: "editor-post-card-panel__content"
80
+ }, (description || lastEditedText) && createElement(VStack, {
81
+ className: "editor-post-card-panel__description",
82
+ spacing: 2
83
+ }, description && createElement(Text, null, description), lastEditedText && createElement(Text, null, lastEditedText)), postType === TEMPLATE_POST_TYPE && createElement(TemplateAreas, null))));
84
+ }
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["classnames","Icon","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalText","Text","PanelBody","store","coreStore","useSelect","__","sprintf","humanTimeDiff","decodeEntities","editorStore","TEMPLATE_POST_TYPE","unlock","TemplateAreas","PostCardPanel","className","actions","modified","title","templateInfo","icon","postType","select","getEditedPostAttribute","getCurrentPostType","getCurrentPostId","__experimentalGetTemplateInfo","getEditedEntityRecord","_type","_id","_record","_templateInfo","id","getPostIcon","area","description","lastEditedText","createElement","spacing","align","numberOfLines","truncate","weight","as"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tPanelBody,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { humanTimeDiff } from '@wordpress/date';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport TemplateAreas from '../template-areas';\n\nexport default function PostCardPanel( { className, actions } ) {\n\tconst { modified, title, templateInfo, icon, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\t__experimentalGetTemplateInfo,\n\t\t\t} = select( editorStore );\n\t\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\t\tconst _type = getCurrentPostType();\n\t\t\tconst _id = getCurrentPostId();\n\t\t\tconst _record = getEditedEntityRecord( 'postType', _type, _id );\n\t\t\tconst _templateInfo = __experimentalGetTemplateInfo( _record );\n\t\t\treturn {\n\t\t\t\ttitle:\n\t\t\t\t\t_templateInfo?.title || getEditedPostAttribute( 'title' ),\n\t\t\t\tmodified: getEditedPostAttribute( 'modified' ),\n\t\t\t\tid: _id,\n\t\t\t\tpostType: _type,\n\t\t\t\ttemplateInfo: _templateInfo,\n\t\t\t\ticon: unlock( select( editorStore ) ).getPostIcon( _type, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t};\n\t\t}\n\t);\n\tconst description = templateInfo?.description;\n\tconst lastEditedText =\n\t\tmodified &&\n\t\tsprintf(\n\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t__( 'Last edited %s.' ),\n\t\t\thumanTimeDiff( modified )\n\t\t);\n\n\treturn (\n\t\t<PanelBody>\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'editor-post-card-panel', className ) }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__icon\"\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t/>\n\t\t\t\t\t<Text\n\t\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\t\ttruncate\n\t\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\tas=\"h2\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title ? decodeEntities( title ) : __( 'No Title' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ actions }\n\t\t\t\t</HStack>\n\t\t\t\t<VStack className=\"editor-post-card-panel__content\">\n\t\t\t\t\t{ ( description || lastEditedText ) && (\n\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\tclassName=\"editor-post-card-panel__description\"\n\t\t\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ description && <Text>{ description }</Text> }\n\t\t\t\t\t\t\t{ lastEditedText && (\n\t\t\t\t\t\t\t\t<Text>{ lastEditedText }</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t) }\n\t\t\t\t\t{ postType === TEMPLATE_POST_TYPE && <TemplateAreas /> }\n\t\t\t\t</VStack>\n\t\t\t</div>\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,IAAI,EACJC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,SAAS,QACH,uBAAuB;AAC9B,SAASC,K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4,7 +4,7 @@ import { createElement } from "react";
4
4
  */
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
6
  import { applyFilters } from '@wordpress/hooks';
7
- import { DropZone, Button, Spinner, ResponsiveWrapper, withNotices, withFilters, __experimentalHStack as HStack } from '@wordpress/components';
7
+ import { DropZone, Button, Spinner, withNotices, withFilters, __experimentalHStack as HStack } from '@wordpress/components';
8
8
  import { isBlobURL } from '@wordpress/blob';
9
9
  import { useState, useRef } from '@wordpress/element';
10
10
  import { compose } from '@wordpress/compose';
@@ -70,8 +70,6 @@ function PostFeaturedImage({
70
70
  getSettings
71
71
  } = useSelect(blockEditorStore);
72
72
  const {
73
- mediaWidth,
74
- mediaHeight,
75
73
  mediaSourceUrl
76
74
  } = getMediaDetails(media, currentPostId);
77
75
  function onDropFiles(filesList) {
@@ -121,14 +119,11 @@ function PostFeaturedImage({
121
119
  onClick: open,
122
120
  "aria-label": !featuredImageId ? null : __('Edit or replace the image'),
123
121
  "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`
124
- }, !!featuredImageId && media && createElement(ResponsiveWrapper, {
125
- naturalWidth: mediaWidth,
126
- naturalHeight: mediaHeight,
127
- isInline: true
128
- }, createElement("img", {
122
+ }, !!featuredImageId && media && createElement("img", {
123
+ className: "editor-post-featured-image__preview-image",
129
124
  src: mediaSourceUrl,
130
125
  alt: ""
131
- })), isLoading && createElement(Spinner, null), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)), !!featuredImageId && createElement(HStack, {
126
+ }), isLoading && createElement(Spinner, null), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)), !!featuredImageId && createElement(HStack, {
132
127
  className: "editor-post-featured-image__actions"
133
128
  }, createElement(Button, {
134
129
  className: "editor-post-featured-image__action",