@wordpress/editor 14.49.1 → 14.51.1-next.v.202607070741.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 (262) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/components/collab-sidebar/format.cjs +83 -0
  3. package/build/components/collab-sidebar/format.cjs.map +7 -0
  4. package/build/components/collab-sidebar/hooks.cjs +117 -16
  5. package/build/components/collab-sidebar/hooks.cjs.map +2 -2
  6. package/build/components/collab-sidebar/index.cjs +18 -2
  7. package/build/components/collab-sidebar/index.cjs.map +2 -2
  8. package/build/components/collab-sidebar/note-highlight-styles.cjs +67 -0
  9. package/build/components/collab-sidebar/note-highlight-styles.cjs.map +7 -0
  10. package/build/components/collab-sidebar/utils.cjs +139 -0
  11. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  12. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +55 -30
  13. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
  14. package/build/components/commands/index.cjs +99 -3
  15. package/build/components/commands/index.cjs.map +2 -2
  16. package/build/components/document-bar/index.cjs +28 -34
  17. package/build/components/document-bar/index.cjs.map +2 -2
  18. package/build/components/entities-saved-states/index.cjs +1 -4
  19. package/build/components/entities-saved-states/index.cjs.map +2 -2
  20. package/build/components/header/index.cjs +1 -8
  21. package/build/components/header/index.cjs.map +2 -2
  22. package/build/components/media-categories/index.cjs +92 -6
  23. package/build/components/media-categories/index.cjs.map +2 -2
  24. package/build/components/page-attributes/parent.cjs +0 -1
  25. package/build/components/page-attributes/parent.cjs.map +2 -2
  26. package/build/components/post-author/combobox.cjs +0 -1
  27. package/build/components/post-author/combobox.cjs.map +2 -2
  28. package/build/components/post-author/select.cjs +0 -1
  29. package/build/components/post-author/select.cjs.map +2 -2
  30. package/build/components/post-preview-button/index.cjs +29 -2
  31. package/build/components/post-preview-button/index.cjs.map +2 -2
  32. package/build/components/post-publish-panel/maybe-upload-media.cjs +15 -26
  33. package/build/components/post-publish-panel/maybe-upload-media.cjs.map +3 -3
  34. package/build/components/post-revisions-preview/revisions-slider.cjs +3 -1
  35. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  36. package/build/components/post-taxonomies/flat-term-selector.cjs +0 -1
  37. package/build/components/post-taxonomies/flat-term-selector.cjs.map +2 -2
  38. package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -2
  39. package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
  40. package/build/components/post-template/classic-theme.cjs +0 -1
  41. package/build/components/post-template/classic-theme.cjs.map +2 -2
  42. package/build/components/preferences-modal/index.cjs +54 -28
  43. package/build/components/preferences-modal/index.cjs.map +2 -2
  44. package/build/components/preview-dropdown/index.cjs +38 -9
  45. package/build/components/preview-dropdown/index.cjs.map +3 -3
  46. package/build/components/provider/use-block-editor-settings.cjs +23 -9
  47. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  48. package/build/components/resizable-editor/index.cjs +54 -9
  49. package/build/components/resizable-editor/index.cjs.map +3 -3
  50. package/build/components/sidebar/dataform-post-summary.cjs +5 -1
  51. package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
  52. package/build/components/sidebar/index.cjs +29 -38
  53. package/build/components/sidebar/index.cjs.map +3 -3
  54. package/build/components/sidebar/post-summary.cjs +0 -13
  55. package/build/components/sidebar/post-summary.cjs.map +3 -3
  56. package/build/components/visual-editor/index.cjs +15 -11
  57. package/build/components/visual-editor/index.cjs.map +3 -3
  58. package/build/dataviews/store/private-actions.cjs +24 -19
  59. package/build/dataviews/store/private-actions.cjs.map +2 -2
  60. package/build/store/actions.cjs +5 -3
  61. package/build/store/actions.cjs.map +2 -2
  62. package/build/store/constants.cjs +26 -0
  63. package/build/store/constants.cjs.map +2 -2
  64. package/build/store/private-actions.cjs +25 -18
  65. package/build/store/private-actions.cjs.map +3 -3
  66. package/build/store/private-selectors.cjs +5 -0
  67. package/build/store/private-selectors.cjs.map +2 -2
  68. package/build/store/reducer.cjs +6 -6
  69. package/build/store/reducer.cjs.map +2 -2
  70. package/build/store/selectors.cjs +3 -1
  71. package/build/store/selectors.cjs.map +2 -2
  72. package/build/utils/device-type.cjs +52 -0
  73. package/build/utils/device-type.cjs.map +7 -0
  74. package/build/utils/media-sideload-from-url/index.cjs +63 -0
  75. package/build/utils/media-sideload-from-url/index.cjs.map +7 -0
  76. package/build-module/components/collab-sidebar/format.mjs +57 -0
  77. package/build-module/components/collab-sidebar/format.mjs.map +7 -0
  78. package/build-module/components/collab-sidebar/hooks.mjs +121 -16
  79. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  80. package/build-module/components/collab-sidebar/index.mjs +21 -5
  81. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  82. package/build-module/components/collab-sidebar/note-highlight-styles.mjs +41 -0
  83. package/build-module/components/collab-sidebar/note-highlight-styles.mjs.map +7 -0
  84. package/build-module/components/collab-sidebar/utils.mjs +133 -0
  85. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  86. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +55 -30
  87. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  88. package/build-module/components/commands/index.mjs +99 -3
  89. package/build-module/components/commands/index.mjs.map +2 -2
  90. package/build-module/components/document-bar/index.mjs +28 -34
  91. package/build-module/components/document-bar/index.mjs.map +2 -2
  92. package/build-module/components/entities-saved-states/index.mjs +1 -4
  93. package/build-module/components/entities-saved-states/index.mjs.map +2 -2
  94. package/build-module/components/header/index.mjs +1 -13
  95. package/build-module/components/header/index.mjs.map +2 -2
  96. package/build-module/components/media-categories/index.mjs +93 -7
  97. package/build-module/components/media-categories/index.mjs.map +2 -2
  98. package/build-module/components/page-attributes/parent.mjs +0 -1
  99. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  100. package/build-module/components/post-author/combobox.mjs +0 -1
  101. package/build-module/components/post-author/combobox.mjs.map +2 -2
  102. package/build-module/components/post-author/select.mjs +0 -1
  103. package/build-module/components/post-author/select.mjs.map +2 -2
  104. package/build-module/components/post-preview-button/index.mjs +29 -2
  105. package/build-module/components/post-preview-button/index.mjs.map +2 -2
  106. package/build-module/components/post-publish-panel/maybe-upload-media.mjs +19 -27
  107. package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +2 -2
  108. package/build-module/components/post-revisions-preview/revisions-slider.mjs +3 -1
  109. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  110. package/build-module/components/post-taxonomies/flat-term-selector.mjs +0 -1
  111. package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
  112. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -2
  113. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
  114. package/build-module/components/post-template/classic-theme.mjs +0 -1
  115. package/build-module/components/post-template/classic-theme.mjs.map +2 -2
  116. package/build-module/components/preferences-modal/index.mjs +54 -28
  117. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  118. package/build-module/components/preview-dropdown/index.mjs +38 -9
  119. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  120. package/build-module/components/provider/use-block-editor-settings.mjs +23 -9
  121. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  122. package/build-module/components/resizable-editor/index.mjs +55 -10
  123. package/build-module/components/resizable-editor/index.mjs.map +2 -2
  124. package/build-module/components/sidebar/dataform-post-summary.mjs +6 -2
  125. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  126. package/build-module/components/sidebar/index.mjs +29 -42
  127. package/build-module/components/sidebar/index.mjs.map +2 -2
  128. package/build-module/components/sidebar/post-summary.mjs +0 -13
  129. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  130. package/build-module/components/visual-editor/index.mjs +16 -13
  131. package/build-module/components/visual-editor/index.mjs.map +2 -2
  132. package/build-module/dataviews/store/private-actions.mjs +26 -19
  133. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  134. package/build-module/store/actions.mjs +5 -3
  135. package/build-module/store/actions.mjs.map +2 -2
  136. package/build-module/store/constants.mjs +25 -0
  137. package/build-module/store/constants.mjs.map +2 -2
  138. package/build-module/store/private-actions.mjs +27 -17
  139. package/build-module/store/private-actions.mjs.map +2 -2
  140. package/build-module/store/private-selectors.mjs +4 -0
  141. package/build-module/store/private-selectors.mjs.map +2 -2
  142. package/build-module/store/reducer.mjs +5 -5
  143. package/build-module/store/reducer.mjs.map +2 -2
  144. package/build-module/store/selectors.mjs +3 -1
  145. package/build-module/store/selectors.mjs.map +2 -2
  146. package/build-module/utils/device-type.mjs +25 -0
  147. package/build-module/utils/device-type.mjs.map +7 -0
  148. package/build-module/utils/media-sideload-from-url/index.mjs +32 -0
  149. package/build-module/utils/media-sideload-from-url/index.mjs.map +7 -0
  150. package/build-style/style-rtl.css +84 -39
  151. package/build-style/style.css +84 -39
  152. package/build-types/components/collab-sidebar/format.d.ts +17 -0
  153. package/build-types/components/collab-sidebar/format.d.ts.map +1 -0
  154. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  155. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  156. package/build-types/components/collab-sidebar/note-highlight-styles.d.ts +31 -0
  157. package/build-types/components/collab-sidebar/note-highlight-styles.d.ts.map +1 -0
  158. package/build-types/components/collab-sidebar/utils.d.ts +82 -2
  159. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  160. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  161. package/build-types/components/commands/index.d.ts.map +1 -1
  162. package/build-types/components/document-bar/index.d.ts.map +1 -1
  163. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  164. package/build-types/components/header/index.d.ts.map +1 -1
  165. package/build-types/components/media-categories/index.d.ts +12 -3
  166. package/build-types/components/media-categories/index.d.ts.map +1 -1
  167. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  168. package/build-types/components/post-author/combobox.d.ts.map +1 -1
  169. package/build-types/components/post-author/select.d.ts.map +1 -1
  170. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  171. package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
  172. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  173. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  174. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  175. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  176. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  177. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  178. package/build-types/components/resizable-editor/index.d.ts.map +1 -1
  179. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  180. package/build-types/components/sidebar/index.d.ts.map +1 -1
  181. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  182. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  183. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  184. package/build-types/store/actions.d.ts.map +1 -1
  185. package/build-types/store/constants.d.ts +6 -0
  186. package/build-types/store/constants.d.ts.map +1 -1
  187. package/build-types/store/index.d.ts +2 -2
  188. package/build-types/store/private-actions.d.ts +9 -15
  189. package/build-types/store/private-actions.d.ts.map +1 -1
  190. package/build-types/store/private-selectors.d.ts +7 -0
  191. package/build-types/store/private-selectors.d.ts.map +1 -1
  192. package/build-types/store/reducer.d.ts +6 -7
  193. package/build-types/store/reducer.d.ts.map +1 -1
  194. package/build-types/store/selectors.d.ts +1 -1
  195. package/build-types/store/selectors.d.ts.map +1 -1
  196. package/build-types/utils/device-type.d.ts +23 -0
  197. package/build-types/utils/device-type.d.ts.map +1 -0
  198. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  199. package/build-types/utils/media-sideload-from-url/index.d.ts +18 -0
  200. package/build-types/utils/media-sideload-from-url/index.d.ts.map +1 -0
  201. package/package.json +48 -46
  202. package/src/components/collab-sidebar/format.js +72 -0
  203. package/src/components/collab-sidebar/hooks.js +203 -22
  204. package/src/components/collab-sidebar/index.js +19 -5
  205. package/src/components/collab-sidebar/note-highlight-styles.js +83 -0
  206. package/src/components/collab-sidebar/style.scss +9 -0
  207. package/src/components/collab-sidebar/test/note-highlight-styles.js +106 -0
  208. package/src/components/collab-sidebar/test/utils.js +471 -0
  209. package/src/components/collab-sidebar/utils.js +225 -2
  210. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +265 -262
  211. package/src/components/collaborators-presence/use-collaborator-notifications.ts +70 -34
  212. package/src/components/commands/index.js +142 -0
  213. package/src/components/document-bar/index.js +0 -9
  214. package/src/components/document-bar/style.scss +0 -17
  215. package/src/components/entities-saved-states/index.js +1 -5
  216. package/src/components/header/index.js +1 -15
  217. package/src/components/header/style.scss +7 -3
  218. package/src/components/media-categories/index.js +160 -6
  219. package/src/components/media-categories/test/index.js +202 -0
  220. package/src/components/page-attributes/parent.js +0 -1
  221. package/src/components/post-author/combobox.js +0 -1
  222. package/src/components/post-author/select.js +0 -1
  223. package/src/components/post-preview-button/index.js +68 -2
  224. package/src/components/post-publish-panel/maybe-upload-media.js +25 -30
  225. package/src/components/post-publish-panel/style.scss +1 -1
  226. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -127
  227. package/src/components/post-revisions-preview/revisions-slider.js +4 -1
  228. package/src/components/post-revisions-preview/test/block-diff.js +2 -2
  229. package/src/components/post-taxonomies/flat-term-selector.js +0 -1
  230. package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -2
  231. package/src/components/post-template/classic-theme.js +0 -1
  232. package/src/components/preferences-modal/index.js +40 -22
  233. package/src/components/preferences-modal/test/index.js +83 -0
  234. package/src/components/preview-dropdown/index.js +42 -3
  235. package/src/components/provider/use-block-editor-settings.js +42 -7
  236. package/src/components/resizable-editor/index.js +71 -9
  237. package/src/components/resizable-editor/style.scss +7 -0
  238. package/src/components/sidebar/dataform-post-summary.js +13 -1
  239. package/src/components/sidebar/index.js +32 -47
  240. package/src/components/sidebar/post-summary.js +0 -17
  241. package/src/components/styles-canvas/style.scss +1 -2
  242. package/src/components/visual-editor/index.js +19 -15
  243. package/src/components/visual-editor/style.scss +11 -4
  244. package/src/dataviews/store/private-actions.ts +30 -26
  245. package/src/store/actions.js +6 -3
  246. package/src/store/constants.ts +45 -0
  247. package/src/store/private-actions.js +38 -28
  248. package/src/store/private-selectors.js +10 -0
  249. package/src/store/reducer.js +7 -9
  250. package/src/store/selectors.js +3 -1
  251. package/src/store/test/actions.js +31 -22
  252. package/src/utils/device-type.js +46 -0
  253. package/src/utils/media-sideload-from-url/index.js +54 -0
  254. package/src/utils/media-sideload-from-url/test/index.js +162 -0
  255. package/build/components/post-publish-panel/media-util.cjs +0 -72
  256. package/build/components/post-publish-panel/media-util.cjs.map +0 -7
  257. package/build-module/components/post-publish-panel/media-util.mjs +0 -46
  258. package/build-module/components/post-publish-panel/media-util.mjs.map +0 -7
  259. package/build-types/components/post-publish-panel/media-util.d.ts +0 -20
  260. package/build-types/components/post-publish-panel/media-util.d.ts.map +0 -1
  261. package/src/components/post-publish-panel/media-util.js +0 -87
  262. package/src/components/post-publish-panel/test/media-util.js +0 -118
@@ -22,10 +22,11 @@ import { privateApis as mediaEditorPrivateApis } from '@wordpress/media-editor';
22
22
  /**
23
23
  * Internal dependencies
24
24
  */
25
- import inserterMediaCategories from '../media-categories';
25
+ import getInserterMediaCategories from '../media-categories';
26
26
  import { mediaUpload } from '../../utils';
27
27
  import mediaUploadOnSuccess from '../../utils/media-upload/on-success';
28
28
  import { default as mediaSideload } from '../../utils/media-sideload';
29
+ import { default as mediaSideloadFromUrl } from '../../utils/media-sideload-from-url';
29
30
  import { default as mediaFinalize } from '../../utils/media-finalize';
30
31
  import { default as mediaDelete } from '../../utils/media-delete';
31
32
  import { store as editorStore } from '../../store';
@@ -114,10 +115,10 @@ const {
114
115
  getMediaSelectKey,
115
116
  isIsolatedEditorKey,
116
117
  deviceTypeKey,
117
- onViewportStateChangeKey,
118
118
  isNavigationOverlayContextKey,
119
119
  isNavigationPostEditorKey,
120
120
  mediaUploadOnSuccessKey,
121
+ mediaSideloadFromUrlKey,
121
122
  openMediaEditorModalKey,
122
123
  } = unlock( privateApis );
123
124
 
@@ -153,6 +154,8 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
153
154
  deviceType,
154
155
  isNavigationOverlayContext,
155
156
  isRevisionsMode,
157
+ viewablePostTypeLabel,
158
+ currentPostId,
156
159
  } = useSelect(
157
160
  ( select ) => {
158
161
  const {
@@ -160,9 +163,12 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
160
163
  getRawEntityRecord,
161
164
  getEntityRecord,
162
165
  getBlockPatternCategories,
166
+ getPostType,
163
167
  } = select( coreStore );
164
168
  const { get } = select( preferencesStore );
165
169
  const { getBlockTypes } = select( blocksStore );
170
+ const { getCurrentPostId, getCurrentPostType } =
171
+ select( editorStore );
166
172
  const { getDeviceType, isRevisionsMode: _isRevisionsMode } = unlock(
167
173
  select( editorStore )
168
174
  );
@@ -178,6 +184,19 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
178
184
  // Fetch image sizes from REST API index for client-side media processing.
179
185
  const baseData = getEntityRecord( 'root', '__unstableBase' );
180
186
 
187
+ // The attached-images category follows the post being edited, not the
188
+ // root-level entity in `postType`/`postId`. With "Show template" on,
189
+ // the root becomes the template (wp_template), but media still attaches
190
+ // to the page being edited.
191
+ //
192
+ // Guard on a truthy slug: `getPostType()` with no slug resolves the
193
+ // whole `/wp/v2/types` collection rather than the single, already
194
+ // fetched record for the current type.
195
+ const currentPostType = getCurrentPostType();
196
+ const postTypeObject = currentPostType
197
+ ? getPostType( currentPostType )
198
+ : undefined;
199
+
181
200
  function getSectionRootBlock() {
182
201
  if ( renderingMode === 'template-locked' ) {
183
202
  return getBlocksByName( 'core/post-content' )?.[ 0 ] ?? '';
@@ -221,6 +240,14 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
221
240
  } ),
222
241
  pageOnFront: siteSettings?.page_on_front,
223
242
  pageForPosts: siteSettings?.page_for_posts,
243
+ // The post type's singular name, but only for real, front-end
244
+ // rendered content (`viewable`). Empty for synced patterns,
245
+ // navigation and templates, which gates the attached-images
246
+ // category off for them and words its copy for everything else.
247
+ viewablePostTypeLabel: postTypeObject?.viewable
248
+ ? postTypeObject?.labels?.singular_name
249
+ : undefined,
250
+ currentPostId: getCurrentPostId(),
224
251
  restBlockPatternCategories: getBlockPatternCategories(),
225
252
  sectionRootClientId: getSectionRootBlock(),
226
253
  deviceType: getDeviceType(),
@@ -276,9 +303,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
276
303
  );
277
304
 
278
305
  const { undo, setIsInserterOpened } = useDispatch( editorStore );
279
- const { updateDeviceTypeForViewportState } = unlock(
280
- useDispatch( editorStore )
281
- );
282
306
  const { editMediaEntity } = unlock( useDispatch( coreStore ) );
283
307
  const { saveEntityRecord } = useDispatch( coreStore );
284
308
  const { openMediaEditorModal } = useDispatch( mediaEditorStore );
@@ -325,6 +349,15 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
325
349
 
326
350
  const forceDisableFocusMode = settings.focusMode === false;
327
351
 
352
+ // The "Attachments" media category depends on the edited post and its post
353
+ // type label (which gates whether it's offered and words its copy), so the
354
+ // categories are derived rather than being a static list.
355
+ const inserterMediaCategories = useMemo(
356
+ () =>
357
+ getInserterMediaCategories( currentPostId, viewablePostTypeLabel ),
358
+ [ currentPostId, viewablePostTypeLabel ]
359
+ );
360
+
328
361
  return useMemo( () => {
329
362
  const blockEditorSettings = {
330
363
  ...Object.fromEntries(
@@ -359,6 +392,9 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
359
392
  ? mediaUploadOnSuccess
360
393
  : undefined,
361
394
  mediaSideload: hasUploadPermissions ? mediaSideload : undefined,
395
+ [ mediaSideloadFromUrlKey ]: hasUploadPermissions
396
+ ? mediaSideloadFromUrl
397
+ : undefined,
362
398
  mediaFinalize: hasUploadPermissions ? mediaFinalize : undefined,
363
399
  mediaDelete: hasUploadPermissions ? mediaDelete : undefined,
364
400
  __experimentalBlockPatterns: blockPatterns,
@@ -418,7 +454,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
418
454
  renderingMode === 'template-locked' ||
419
455
  settings.disableContentOnlyForTemplateParts,
420
456
  ...( deviceType ? { [ deviceTypeKey ]: deviceType } : {} ),
421
- [ onViewportStateChangeKey ]: updateDeviceTypeForViewportState,
422
457
  [ isNavigationOverlayContextKey ]: isNavigationOverlayContext,
423
458
  };
424
459
 
@@ -440,6 +475,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
440
475
  hasUploadPermissions,
441
476
  blockPatterns,
442
477
  blockPatternCategories,
478
+ inserterMediaCategories,
443
479
  canUseUnfilteredHTML,
444
480
  undo,
445
481
  createPageEntity,
@@ -454,7 +490,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
454
490
  renderingMode,
455
491
  editMediaEntity,
456
492
  openMediaEditorModal,
457
- updateDeviceTypeForViewportState,
458
493
  deviceType,
459
494
  allImageSizes,
460
495
  bigImageSizeThreshold,
@@ -6,13 +6,16 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState, useRef, useCallback } from '@wordpress/element';
9
+ import { useDispatch, useSelect } from '@wordpress/data';
10
+ import { useRef, useCallback, useState } from '@wordpress/element';
10
11
  import { ResizableBox } from '@wordpress/components';
11
12
 
12
13
  /**
13
14
  * Internal dependencies
14
15
  */
15
16
  import ResizeHandle from './resize-handle';
17
+ import { store as editorStore } from '../../store';
18
+ import { unlock } from '../../lock-unlock';
16
19
 
17
20
  // Removes the inline styles in the drag handles.
18
21
  const HANDLE_STYLES_OVERRIDE = {
@@ -27,28 +30,87 @@ const HANDLE_STYLES_OVERRIDE = {
27
30
  left: undefined,
28
31
  };
29
32
 
33
+ /**
34
+ * Checks if the current width is at the max width.
35
+ *
36
+ * @param {number} currentWidth - The current width of the editor.
37
+ * @param {number} containerWidth - The width of the container.
38
+ * @param {number} tolerance - The tolerance for the max width in pixels.
39
+ * @return {boolean} - True if the current width is at the max width, false otherwise.
40
+ */
41
+ function isAtMaxWidth( currentWidth, containerWidth, tolerance = 0 ) {
42
+ return containerWidth > 0 && currentWidth >= containerWidth - tolerance;
43
+ }
44
+
30
45
  function ResizableEditor( { className, enableResizing, height, children } ) {
31
- const [ width, setWidth ] = useState( '100%' );
46
+ const [ isResizing, setIsResizing ] = useState( false );
47
+ const { setCanvasWidth } = unlock( useDispatch( editorStore ) );
48
+ const canvasWidth = useSelect(
49
+ ( select ) => {
50
+ if ( ! enableResizing ) {
51
+ return undefined;
52
+ }
53
+ const { getCanvasWidth } = unlock( select( editorStore ) );
54
+ return getCanvasWidth();
55
+ },
56
+ [ enableResizing ]
57
+ );
58
+
32
59
  const resizableRef = useRef();
33
- const resizeWidthBy = useCallback( ( deltaPixels ) => {
34
- if ( resizableRef.current ) {
35
- setWidth( resizableRef.current.offsetWidth + deltaPixels );
36
- }
37
- }, [] );
60
+ const resizeWidthBy = useCallback(
61
+ ( deltaPixels ) => {
62
+ if ( resizableRef.current ) {
63
+ const _isAtMaxWidth = isAtMaxWidth(
64
+ resizableRef.current.offsetWidth + deltaPixels,
65
+ resizableRef.current.parentElement?.offsetWidth ?? 0,
66
+ 80
67
+ );
68
+ setCanvasWidth(
69
+ _isAtMaxWidth
70
+ ? undefined
71
+ : resizableRef.current.offsetWidth + deltaPixels
72
+ );
73
+ }
74
+ },
75
+ [ setCanvasWidth ]
76
+ );
77
+
78
+ const updateCanvasWidth = useCallback(
79
+ ( element ) => {
80
+ const currentWidth = element.offsetWidth;
81
+ const containerWidth = element.parentElement?.offsetWidth ?? 0;
82
+ setCanvasWidth(
83
+ isAtMaxWidth( currentWidth, containerWidth, 80 )
84
+ ? undefined
85
+ : currentWidth
86
+ );
87
+ },
88
+ [ setCanvasWidth ]
89
+ );
90
+
38
91
  return (
39
92
  <ResizableBox
40
93
  className={ clsx( 'editor-resizable-editor', className, {
41
94
  'is-resizable': enableResizing,
95
+ 'is-resizing': isResizing,
42
96
  } ) }
43
97
  ref={ ( api ) => {
44
98
  resizableRef.current = api?.resizable;
45
99
  } }
46
100
  size={ {
47
- width: enableResizing ? width : '100%',
101
+ width:
102
+ enableResizing && canvasWidth ? canvasWidth + 'px' : '100%',
48
103
  height: enableResizing && height ? height : '100%',
49
104
  } }
105
+ onResizeStart={ () => {
106
+ setIsResizing( true );
107
+ } }
108
+ onResize={ ( event, direction, element ) => {
109
+ updateCanvasWidth( element );
110
+ } }
50
111
  onResizeStop={ ( event, direction, element ) => {
51
- setWidth( element.style.width );
112
+ setIsResizing( false );
113
+ updateCanvasWidth( element );
52
114
  } }
53
115
  minWidth={ 300 }
54
116
  maxWidth="100%"
@@ -2,6 +2,13 @@
2
2
  @use "@wordpress/base-styles/colors" as *;
3
3
  @use "@wordpress/base-styles/variables" as *;
4
4
 
5
+ // Don't apply transition when resized using the resizer handle.
6
+ .editor-resizable-editor:not(.is-resizing) {
7
+ @media (prefers-reduced-motion: no-preference) {
8
+ transition: width 0.2s ease-out;
9
+ }
10
+ }
11
+
5
12
  // To hide the horizontal scrollbar and show the drag handle on the
6
13
  // left and right of the container.
7
14
  .editor-resizable-editor.is-resizable {
@@ -13,6 +13,7 @@ import { useViewConfig } from '@wordpress/views';
13
13
  * Internal dependencies
14
14
  */
15
15
  import PostCardPanel from '../post-card-panel';
16
+ import PluginPostStatusInfo from '../plugin-post-status-info';
16
17
  import PostPanelSection from '../post-panel-section';
17
18
  import { store as editorStore } from '../../store';
18
19
  import PostTrash from '../post-trash';
@@ -394,7 +395,18 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
394
395
  onChange={ onChange }
395
396
  />
396
397
  { ! isPostStatusRemoved && (
397
- <PostTrash onActionPerformed={ onActionPerformed } />
398
+ <>
399
+ <PluginPostStatusInfo.Slot>
400
+ { ( fills ) =>
401
+ fills.length > 0 && (
402
+ <Stack direction="column" gap="xs">
403
+ { fills }
404
+ </Stack>
405
+ )
406
+ }
407
+ </PluginPostStatusInfo.Slot>
408
+ <PostTrash onActionPerformed={ onActionPerformed } />
409
+ </>
398
410
  ) }
399
411
  </Stack>
400
412
  </PostPanelSection>
@@ -20,6 +20,7 @@ import PatternOverridesPanel from '../pattern-overrides-panel';
20
20
  import PluginDocumentSettingPanel from '../plugin-document-setting-panel';
21
21
  import PluginSidebar from '../plugin-sidebar';
22
22
  import PostSummary from './post-summary';
23
+ import DataFormPostSummary from './dataform-post-summary';
23
24
  import PostRevisionSummary from './post-revision-summary';
24
25
  import PostTaxonomiesPanel from '../post-taxonomies/panel';
25
26
  import PostTransformPanel from '../post-transform-panel';
@@ -32,11 +33,6 @@ import useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-side
32
33
  import { sidebars } from './constants';
33
34
  import { unlock } from '../../lock-unlock';
34
35
  import { store as editorStore } from '../../store';
35
- import {
36
- NAVIGATION_POST_TYPE,
37
- TEMPLATE_PART_POST_TYPE,
38
- TEMPLATE_POST_TYPE,
39
- } from '../../store/constants';
40
36
 
41
37
  const { Tabs } = unlock( componentsPrivateApis );
42
38
 
@@ -47,7 +43,6 @@ const SidebarContent = ( {
47
43
  keyboardShortcut,
48
44
  onActionPerformed,
49
45
  extraPanels,
50
- postType,
51
46
  } ) => {
52
47
  const tabListRef = useRef( null );
53
48
  // Because `PluginSidebar` renders a `ComplementaryArea`, we
@@ -89,15 +84,20 @@ const SidebarContent = ( {
89
84
  if ( isRevisionsMode ) {
90
85
  tabContent = <PostRevisionSummary />;
91
86
  } else {
87
+ const isDataFormInspectorEnabled =
88
+ window?.__experimentalDataFormInspector;
92
89
  tabContent = (
93
90
  <>
94
- <PostSummary onActionPerformed={ onActionPerformed } />
91
+ { isDataFormInspectorEnabled ? (
92
+ <DataFormPostSummary
93
+ onActionPerformed={ onActionPerformed }
94
+ />
95
+ ) : (
96
+ <PostSummary onActionPerformed={ onActionPerformed } />
97
+ ) }
95
98
  <PluginDocumentSettingPanel.Slot />
96
99
  <TemplateContentPanel />
97
- { window?.__experimentalDataFormInspector &&
98
- [ 'page', 'post' ].includes( postType ) && (
99
- <TemplateActionsPanel />
100
- ) }
100
+ { isDataFormInspectorEnabled && <TemplateActionsPanel /> }
101
101
  <TemplatePartContentPanel />
102
102
  <PostTransformPanel />
103
103
  <PostTaxonomiesPanel />
@@ -144,42 +144,29 @@ const SidebarContent = ( {
144
144
 
145
145
  const Sidebar = ( { extraPanels, onActionPerformed } ) => {
146
146
  useAutoSwitchEditorSidebars();
147
- const { tabName, keyboardShortcut, showSummary, postType } = useSelect(
148
- ( select ) => {
149
- const shortcut = select(
150
- keyboardShortcutsStore
151
- ).getShortcutRepresentation( 'core/editor/toggle-sidebar' );
152
-
153
- const sidebar =
154
- select( interfaceStore ).getActiveComplementaryArea( 'core' );
155
- const _isEditorSidebarOpened = [
156
- sidebars.block,
157
- sidebars.document,
158
- ].includes( sidebar );
159
- let _tabName = sidebar;
160
- if ( ! _isEditorSidebarOpened ) {
161
- _tabName = !! select(
162
- blockEditorStore
163
- ).getBlockSelectionStart()
164
- ? sidebars.block
165
- : sidebars.document;
166
- }
147
+ const { tabName, keyboardShortcut } = useSelect( ( select ) => {
148
+ const shortcut = select(
149
+ keyboardShortcutsStore
150
+ ).getShortcutRepresentation( 'core/editor/toggle-sidebar' );
167
151
 
168
- const _postType = select( editorStore ).getCurrentPostType();
152
+ const sidebar =
153
+ select( interfaceStore ).getActiveComplementaryArea( 'core' );
154
+ const _isEditorSidebarOpened = [
155
+ sidebars.block,
156
+ sidebars.document,
157
+ ].includes( sidebar );
158
+ let _tabName = sidebar;
159
+ if ( ! _isEditorSidebarOpened ) {
160
+ _tabName = !! select( blockEditorStore ).getBlockSelectionStart()
161
+ ? sidebars.block
162
+ : sidebars.document;
163
+ }
169
164
 
170
- return {
171
- tabName: _tabName,
172
- keyboardShortcut: shortcut,
173
- showSummary: ! [
174
- TEMPLATE_POST_TYPE,
175
- TEMPLATE_PART_POST_TYPE,
176
- NAVIGATION_POST_TYPE,
177
- ].includes( _postType ),
178
- postType: _postType,
179
- };
180
- },
181
- []
182
- );
165
+ return {
166
+ tabName: _tabName,
167
+ keyboardShortcut: shortcut,
168
+ };
169
+ }, [] );
183
170
 
184
171
  const { enableComplementaryArea } = useDispatch( interfaceStore );
185
172
 
@@ -201,10 +188,8 @@ const Sidebar = ( { extraPanels, onActionPerformed } ) => {
201
188
  <SidebarContent
202
189
  tabName={ tabName }
203
190
  keyboardShortcut={ keyboardShortcut }
204
- showSummary={ showSummary }
205
191
  onActionPerformed={ onActionPerformed }
206
192
  extraPanels={ extraPanels }
207
- postType={ postType }
208
193
  />
209
194
  </Tabs>
210
195
  );
@@ -7,7 +7,6 @@ import { useSelect } from '@wordpress/data';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import DataFormPostSummary from './dataform-post-summary';
11
10
  import PluginPostStatusInfo from '../plugin-post-status-info';
12
11
  import PostAuthorPanel from '../post-author/panel';
13
12
  import PostCardPanel from '../post-card-panel';
@@ -37,22 +36,6 @@ import PostTrash from '../post-trash';
37
36
  const PANEL_NAME = 'post-status';
38
37
 
39
38
  export default function PostSummary( { onActionPerformed } ) {
40
- const postType = useSelect(
41
- ( select ) => select( editorStore ).getCurrentPostType(),
42
- []
43
- );
44
- if (
45
- window?.__experimentalDataFormInspector &&
46
- [ 'page', 'post', 'wp_template', 'wp_template_part' ].includes(
47
- postType
48
- )
49
- ) {
50
- return <DataFormPostSummary onActionPerformed={ onActionPerformed } />;
51
- }
52
- return <ClassicPostSummary onActionPerformed={ onActionPerformed } />;
53
- }
54
-
55
- function ClassicPostSummary( { onActionPerformed } ) {
56
39
  const { isRemovedPostStatusPanel, postType, postId } = useSelect(
57
40
  ( select ) => {
58
41
  // We use isEditorPanelRemoved to hide the panel if it was programmatically removed. We do
@@ -3,7 +3,7 @@
3
3
 
4
4
  .editor-styles-canvas {
5
5
  height: 100%;
6
- padding: $grid-unit-20;
6
+ padding: $grid-unit-30;
7
7
 
8
8
  // This is the gray background color that's applied behind "isolation mode".
9
9
  // The color normally comes from .editor-visual-editor, but that class is missing here.
@@ -19,7 +19,6 @@
19
19
 
20
20
  .editor-styles-canvas__section {
21
21
  background: $white; // Fallback color, overridden by JavaScript.
22
- border-radius: $radius-large;
23
22
  bottom: 0;
24
23
  left: 0;
25
24
  overflow: hidden;
@@ -14,7 +14,6 @@ import {
14
14
  useSettings,
15
15
  RecursionProvider,
16
16
  privateApis as blockEditorPrivateApis,
17
- __experimentalUseResizeCanvas as useResizeCanvas,
18
17
  } from '@wordpress/block-editor';
19
18
  import { useEffect, useRef, useMemo } from '@wordpress/element';
20
19
  import { useSelect } from '@wordpress/data';
@@ -112,6 +111,7 @@ function VisualEditor( {
112
111
  postType,
113
112
  isPreview,
114
113
  styles,
114
+ hasCanvasWidth,
115
115
  } = useSelect( ( select ) => {
116
116
  const {
117
117
  getCurrentPostId,
@@ -120,6 +120,7 @@ function VisualEditor( {
120
120
  getEditorSettings,
121
121
  getRenderingMode,
122
122
  getDeviceType,
123
+ getCanvasWidth,
123
124
  } = unlock( select( editorStore ) );
124
125
  const { getPostType, getEditedEntityRecord } = select( coreStore );
125
126
  const postTypeSlug = getCurrentPostType();
@@ -161,6 +162,7 @@ function VisualEditor( {
161
162
  postType: postTypeSlug,
162
163
  isPreview: editorSettings.isPreviewMode,
163
164
  styles: editorSettings.styles,
165
+ hasCanvasWidth: getCanvasWidth() !== undefined,
164
166
  };
165
167
  }, [] );
166
168
  const { isCleanNewPost } = useSelect( editorStore );
@@ -185,7 +187,6 @@ function VisualEditor( {
185
187
  }, [] );
186
188
 
187
189
  const localRef = useRef();
188
- const deviceStyles = useResizeCanvas( deviceType );
189
190
  const [ globalLayoutSettings ] = useSettings( 'layout' );
190
191
 
191
192
  // fallbackLayout is used if there is no Post Content,
@@ -319,17 +320,19 @@ function VisualEditor( {
319
320
  .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
320
321
 
321
322
  const enableResizing =
322
- [
323
+ ( [
323
324
  NAVIGATION_POST_TYPE,
324
325
  TEMPLATE_PART_POST_TYPE,
325
326
  PATTERN_POST_TYPE,
326
327
  ].includes( postType ) &&
327
- // Disable in previews / view mode.
328
- ! isPreview &&
329
- // Disable resizing in mobile viewport.
330
- ! isMobileViewport &&
331
- // Disable resizing in zoomed-out mode.
332
- ! isZoomedOut;
328
+ // Disable in previews / view mode.
329
+ ! isPreview &&
330
+ // Disable resizing in mobile viewport.
331
+ ! isMobileViewport &&
332
+ // Disable resizing in zoomed-out mode.
333
+ ! isZoomedOut ) ||
334
+ // When the canvas has an explicit width, always allow resizing.
335
+ hasCanvasWidth;
333
336
 
334
337
  const isNavigationPreview = postType === NAVIGATION_POST_TYPE && isPreview;
335
338
 
@@ -394,8 +397,12 @@ function VisualEditor( {
394
397
  'edit-post-visual-editor',
395
398
  className,
396
399
  {
397
- 'has-padding': isFocusedEntity || enableResizing,
398
- 'is-resizable': enableResizing,
400
+ // Vertical padding frames a width-constrained canvas
401
+ // (device preview or after a resize) as a centered preview.
402
+ 'has-vertical-padding': isFocusedEntity || hasCanvasWidth,
403
+ // Horizontal padding leaves room for the resize handles
404
+ // that appear on the left/right of a resizable canvas.
405
+ 'has-horizontal-padding': isFocusedEntity || enableResizing,
399
406
  'is-iframed': ! disableIframe,
400
407
  }
401
408
  ) }
@@ -409,10 +416,7 @@ function VisualEditor( {
409
416
  height="100%"
410
417
  iframeProps={ {
411
418
  ...iframeProps,
412
- style: {
413
- ...iframeProps?.style,
414
- ...deviceStyles,
415
- },
419
+ style: iframeProps?.style,
416
420
  } }
417
421
  >
418
422
  { themeSupportsLayout &&
@@ -3,6 +3,7 @@
3
3
  .editor-visual-editor {
4
4
  position: relative;
5
5
  display: flex;
6
+ max-height: 100%;
6
7
 
7
8
  // This duplicates the iframe background but it's necessary in some situations
8
9
  // when the iframe doesn't cover the whole canvas
@@ -19,12 +20,18 @@
19
20
  // Centralize the editor horizontally (flex-direction is column).
20
21
  align-items: center;
21
22
 
22
- &.is-resizable {
23
- max-height: 100%;
23
+ @media (prefers-reduced-motion: no-preference) {
24
+ transition: padding 0.2s ease-out;
24
25
  }
25
26
 
26
- &.has-padding {
27
- padding: $grid-unit-30 $grid-unit-30 0;
27
+ &.has-vertical-padding {
28
+ padding-top: $grid-unit-30;
29
+ padding-bottom: $grid-unit-30;
30
+ }
31
+
32
+ &.has-horizontal-padding {
33
+ padding-left: $grid-unit-30;
34
+ padding-right: $grid-unit-30;
28
35
  }
29
36
 
30
37
  // In the iframed canvas this keeps extra scrollbars from appearing (when block toolbars overflow). In the