@wordpress/media-editor 0.15.0 → 0.17.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 (295) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +115 -119
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  5. package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
  6. package/build/components/media-editor-canvas/index.cjs +0 -2
  7. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  8. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  9. package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
  10. package/build/components/media-editor-image-controls/index.cjs.map +2 -2
  11. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +2 -2
  12. package/build/components/media-editor-modal/build-modifiers.cjs.map +2 -2
  13. package/build/components/media-editor-modal/index.cjs +31 -15
  14. package/build/components/media-editor-modal/index.cjs.map +3 -3
  15. package/build/components/media-editor-provider/index.cjs.map +2 -2
  16. package/build/components/media-form/index.cjs.map +2 -2
  17. package/build/components/media-preview/index.cjs.map +2 -2
  18. package/build/components/rotation-ruler/index.cjs.map +2 -2
  19. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +2 -2
  20. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  21. package/build/image-editor/core/camera.cjs.map +2 -2
  22. package/build/image-editor/core/constants.cjs.map +2 -2
  23. package/build/image-editor/core/containment.cjs.map +2 -2
  24. package/build/image-editor/core/crop-rect.cjs.map +2 -2
  25. package/build/image-editor/core/export/canvas-renderer.cjs.map +2 -2
  26. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  27. package/build/image-editor/core/math/sanitize.cjs.map +2 -2
  28. package/build/image-editor/core/setter-helpers.cjs.map +2 -2
  29. package/build/image-editor/core/source-region.cjs.map +2 -2
  30. package/build/image-editor/core/state.cjs.map +2 -2
  31. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  32. package/build/image-editor/core/transform-style.cjs.map +2 -2
  33. package/build/image-editor/core/transforms/pipeline.cjs.map +2 -2
  34. package/build/image-editor/core/viewport-state.cjs.map +2 -2
  35. package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
  36. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  37. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +2 -2
  38. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
  39. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +2 -2
  40. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  41. package/build/image-editor/react/components/viewport-provider.cjs.map +2 -2
  42. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +2 -2
  43. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  44. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +2 -2
  45. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  46. package/build/image-editor/react/hooks/use-transform-style.cjs.map +2 -2
  47. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +2 -2
  48. package/build/lock-unlock.cjs.map +2 -2
  49. package/build/private-apis.cjs.map +2 -2
  50. package/build/state/composite-reducer.cjs.map +2 -2
  51. package/build/state/media-editor-state-provider.cjs.map +2 -2
  52. package/build/state/types.cjs.map +2 -2
  53. package/build/state/use-media-editor-state.cjs.map +2 -2
  54. package/build/store/index.cjs.map +2 -2
  55. package/build/store/reducer.cjs.map +2 -2
  56. package/build/store/selectors.cjs.map +2 -2
  57. package/build-module/components/media-editor/index.mjs +117 -120
  58. package/build-module/components/media-editor/index.mjs.map +2 -2
  59. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  60. package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
  61. package/build-module/components/media-editor-canvas/index.mjs +0 -2
  62. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  63. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  64. package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
  65. package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
  66. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +2 -2
  67. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +2 -2
  68. package/build-module/components/media-editor-modal/index.mjs +31 -15
  69. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  70. package/build-module/components/media-editor-provider/index.mjs.map +2 -2
  71. package/build-module/components/media-form/index.mjs.map +2 -2
  72. package/build-module/components/media-preview/index.mjs.map +2 -2
  73. package/build-module/components/rotation-ruler/index.mjs.map +2 -2
  74. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +2 -2
  75. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  76. package/build-module/image-editor/core/camera.mjs.map +2 -2
  77. package/build-module/image-editor/core/constants.mjs.map +2 -2
  78. package/build-module/image-editor/core/containment.mjs.map +2 -2
  79. package/build-module/image-editor/core/crop-rect.mjs.map +2 -2
  80. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +2 -2
  81. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  82. package/build-module/image-editor/core/math/sanitize.mjs.map +2 -2
  83. package/build-module/image-editor/core/setter-helpers.mjs.map +2 -2
  84. package/build-module/image-editor/core/source-region.mjs.map +2 -2
  85. package/build-module/image-editor/core/state.mjs.map +2 -2
  86. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  87. package/build-module/image-editor/core/transform-style.mjs.map +2 -2
  88. package/build-module/image-editor/core/transforms/pipeline.mjs.map +2 -2
  89. package/build-module/image-editor/core/viewport-state.mjs.map +2 -2
  90. package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
  91. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  92. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +2 -2
  93. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
  94. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +2 -2
  95. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  96. package/build-module/image-editor/react/components/viewport-provider.mjs.map +2 -2
  97. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +2 -2
  98. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  99. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +2 -2
  100. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  101. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +2 -2
  102. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +2 -2
  103. package/build-module/lock-unlock.mjs.map +2 -2
  104. package/build-module/private-apis.mjs.map +2 -2
  105. package/build-module/state/composite-reducer.mjs.map +2 -2
  106. package/build-module/state/media-editor-state-provider.mjs.map +2 -2
  107. package/build-module/state/types.mjs.map +2 -2
  108. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  109. package/build-module/store/index.mjs.map +2 -2
  110. package/build-module/store/reducer.mjs.map +2 -2
  111. package/build-module/store/selectors.mjs.map +2 -2
  112. package/build-style/style-rtl.css +6 -6
  113. package/build-style/style.css +6 -6
  114. package/build-types/components/media-editor/index.d.ts +46 -11
  115. package/build-types/components/media-editor/index.d.ts.map +1 -1
  116. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  117. package/build-types/components/media-editor/use-save-media-editor.d.ts +0 -3
  118. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  119. package/build-types/components/media-editor-canvas/index.d.ts +1 -4
  120. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  121. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  122. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  123. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  125. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -3
  126. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
  127. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  128. package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
  129. package/build-types/components/media-form/index.d.ts.map +1 -1
  130. package/build-types/components/media-preview/index.d.ts.map +1 -1
  131. package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
  132. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  133. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  134. package/build-types/image-editor/core/camera.d.ts +0 -3
  135. package/build-types/image-editor/core/camera.d.ts.map +1 -1
  136. package/build-types/image-editor/core/constants.d.ts +0 -3
  137. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  138. package/build-types/image-editor/core/containment.d.ts +0 -3
  139. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  140. package/build-types/image-editor/core/crop-rect.d.ts +0 -3
  141. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -1
  142. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -3
  143. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -1
  144. package/build-types/image-editor/core/interaction-controller.d.ts +0 -3
  145. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  146. package/build-types/image-editor/core/math/sanitize.d.ts +0 -3
  147. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -1
  148. package/build-types/image-editor/core/setter-helpers.d.ts +0 -3
  149. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -1
  150. package/build-types/image-editor/core/source-region.d.ts +0 -3
  151. package/build-types/image-editor/core/source-region.d.ts.map +1 -1
  152. package/build-types/image-editor/core/state.d.ts +0 -3
  153. package/build-types/image-editor/core/state.d.ts.map +1 -1
  154. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  155. package/build-types/image-editor/core/transform-style.d.ts +0 -3
  156. package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
  157. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -3
  158. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -1
  159. package/build-types/image-editor/core/viewport-state.d.ts +0 -3
  160. package/build-types/image-editor/core/viewport-state.d.ts.map +1 -1
  161. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -3
  162. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  163. package/build-types/image-editor/react/components/cropper.d.ts +0 -6
  164. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  165. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -3
  166. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -1
  167. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -3
  168. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
  169. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -3
  170. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
  171. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -3
  172. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  173. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -3
  174. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -1
  175. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -3
  176. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -1
  177. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -3
  178. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  179. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -3
  180. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -1
  181. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -3
  182. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  183. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -3
  184. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -1
  185. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -3
  186. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -1
  187. package/build-types/lock-unlock.d.ts.map +1 -1
  188. package/build-types/private-apis.d.ts.map +1 -1
  189. package/build-types/state/composite-reducer.d.ts +0 -3
  190. package/build-types/state/composite-reducer.d.ts.map +1 -1
  191. package/build-types/state/media-editor-state-provider.d.ts +0 -3
  192. package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
  193. package/build-types/state/types.d.ts +0 -3
  194. package/build-types/state/types.d.ts.map +1 -1
  195. package/build-types/state/use-media-editor-state.d.ts +0 -3
  196. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  197. package/build-types/store/index.d.ts.map +1 -1
  198. package/build-types/store/reducer.d.ts +0 -3
  199. package/build-types/store/reducer.d.ts.map +1 -1
  200. package/build-types/store/selectors.d.ts +0 -3
  201. package/build-types/store/selectors.d.ts.map +1 -1
  202. package/global.d.ts +5 -0
  203. package/package.json +24 -22
  204. package/src/components/media-editor/index.tsx +233 -194
  205. package/src/components/media-editor/style.scss +6 -3
  206. package/src/components/media-editor/test/use-crop-options.tsx +0 -7
  207. package/src/components/media-editor/use-crop-options.ts +0 -7
  208. package/src/components/media-editor/use-save-media-editor.ts +0 -7
  209. package/src/components/media-editor-canvas/index.tsx +5 -20
  210. package/src/components/media-editor-crop-panel/index.tsx +0 -7
  211. package/src/components/media-editor-crop-panel/test/index.tsx +0 -7
  212. package/src/components/media-editor-fine-rotation/index.tsx +0 -7
  213. package/src/components/media-editor-image-controls/index.tsx +0 -7
  214. package/src/components/media-editor-image-controls/test/index.tsx +0 -7
  215. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +0 -3
  216. package/src/components/media-editor-modal/build-modifiers.ts +0 -3
  217. package/src/components/media-editor-modal/index.tsx +43 -19
  218. package/src/components/media-editor-modal/style.scss +8 -4
  219. package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -8
  220. package/src/components/media-editor-modal/test/index.tsx +0 -11
  221. package/src/components/media-editor-provider/index.tsx +0 -3
  222. package/src/components/media-form/index.tsx +0 -7
  223. package/src/components/media-preview/index.tsx +0 -7
  224. package/src/components/rotation-ruler/index.tsx +0 -11
  225. package/src/components/rotation-ruler/stories/index.story.tsx +0 -11
  226. package/src/components/rotation-ruler/test/index.tsx +0 -7
  227. package/src/components/rotation-ruler/use-ruler-drag.ts +0 -3
  228. package/src/hooks/use-crop-gesture-handlers.ts +0 -7
  229. package/src/image-editor/core/camera.ts +0 -7
  230. package/src/image-editor/core/constants.ts +0 -7
  231. package/src/image-editor/core/containment.ts +0 -7
  232. package/src/image-editor/core/crop-rect.ts +0 -3
  233. package/src/image-editor/core/export/canvas-renderer.ts +0 -3
  234. package/src/image-editor/core/export/test/canvas-renderer.ts +0 -3
  235. package/src/image-editor/core/interaction-controller.ts +0 -3
  236. package/src/image-editor/core/math/sanitize.ts +0 -3
  237. package/src/image-editor/core/math/test/sanitize.ts +0 -3
  238. package/src/image-editor/core/setter-helpers.ts +0 -3
  239. package/src/image-editor/core/source-region.ts +0 -7
  240. package/src/image-editor/core/state.ts +0 -3
  241. package/src/image-editor/core/stencil-math.ts +0 -3
  242. package/src/image-editor/core/test/interaction-controller.ts +0 -3
  243. package/src/image-editor/core/test/preview-export-parity.ts +0 -1
  244. package/src/image-editor/core/test/stencil-math.ts +0 -3
  245. package/src/image-editor/core/transform-style.ts +0 -3
  246. package/src/image-editor/core/transforms/pipeline.ts +0 -3
  247. package/src/image-editor/core/transforms/test/pipeline.ts +0 -3
  248. package/src/image-editor/core/viewport-state.ts +0 -3
  249. package/src/image-editor/react/components/cropper-provider.tsx +0 -7
  250. package/src/image-editor/react/components/cropper.tsx +0 -12
  251. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -7
  252. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -3
  253. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -3
  254. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -7
  255. package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +0 -7
  256. package/src/image-editor/react/components/test/cropper.tsx +0 -7
  257. package/src/image-editor/react/components/viewport-provider.tsx +0 -7
  258. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -3
  259. package/src/image-editor/react/hooks/test/use-aria-announcer.ts +0 -11
  260. package/src/image-editor/react/hooks/test/use-cropper-reducer.ts +0 -7
  261. package/src/image-editor/react/hooks/test/use-interaction.ts +0 -7
  262. package/src/image-editor/react/hooks/test/use-transform-style.ts +0 -7
  263. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -7
  264. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -7
  265. package/src/image-editor/react/hooks/use-interaction.ts +0 -7
  266. package/src/image-editor/react/hooks/use-transform-style.ts +0 -7
  267. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -7
  268. package/src/image-editor/stories/rectangle-crop.story.tsx +15 -11
  269. package/src/lock-unlock.ts +0 -3
  270. package/src/private-apis.ts +0 -3
  271. package/src/state/composite-reducer.ts +0 -3
  272. package/src/state/media-editor-state-provider.tsx +0 -7
  273. package/src/state/test/use-media-editor-state.ts +0 -7
  274. package/src/state/types.ts +0 -3
  275. package/src/state/use-media-editor-state.ts +0 -7
  276. package/src/store/index.ts +0 -7
  277. package/src/store/reducer.ts +0 -3
  278. package/src/store/selectors.ts +0 -3
  279. package/src/store/test/reducer.ts +0 -3
  280. package/tsconfig.build.json +26 -0
  281. package/tsconfig.build.tsbuildinfo +1 -0
  282. package/tsconfig.json +22 -15
  283. package/build-types/components/media-editor-toolbar/index.d.ts +0 -24
  284. package/build-types/components/media-editor-toolbar/index.d.ts.map +0 -1
  285. package/build-types/components/media-editor-transform-controls/index.d.ts +0 -21
  286. package/build-types/components/media-editor-transform-controls/index.d.ts.map +0 -1
  287. package/build-types/components/media-form/sidebar-datetime-view.d.ts +0 -10
  288. package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +0 -1
  289. package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -14
  290. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
  291. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -108
  292. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
  293. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -16
  294. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
  295. package/tsconfig.tsbuildinfo +0 -1
@@ -1,9 +1,5 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import {
5
2
  Button,
6
- Flex,
7
3
  Spinner,
8
4
  __experimentalConfirmDialog as ConfirmDialog,
9
5
  } from '@wordpress/components';
@@ -12,8 +8,10 @@ import { useViewportMatch } from '@wordpress/compose';
12
8
  import { useDispatch, useSelect } from '@wordpress/data';
13
9
  import { store as coreStore } from '@wordpress/core-data';
14
10
  import {
11
+ createContext,
15
12
  createPortal,
16
13
  useCallback,
14
+ useContext,
17
15
  useEffect,
18
16
  useMemo,
19
17
  useRef,
@@ -32,14 +30,9 @@ import {
32
30
  ComplementaryArea,
33
31
  InterfaceSkeleton,
34
32
  PinnedItems,
35
- // No type declarations available for @wordpress/interface.
36
- // @ts-expect-error
33
+ // @ts-expect-error `@wordpress/interface` is not typed yet.
37
34
  } from '@wordpress/interface';
38
35
  import type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';
39
-
40
- /**
41
- * Internal dependencies
42
- */
43
36
  import { MediaEditorProvider } from '../media-editor-provider';
44
37
  import type { Media } from '../media-editor-provider';
45
38
  import MediaPreview from '../media-preview';
@@ -77,18 +70,14 @@ interface EditorTab {
77
70
 
78
71
  export interface MediaEditorFrameProps {
79
72
  children: ReactNode;
80
- headerActions: ReactNode;
81
- footerActions: ReactNode;
82
73
  /**
83
- * Footer layout selector. Frames apply this to the footer container
84
- * as a modifier class. Tracks the sidebar-collapse breakpoint (`medium`).
85
- *
86
- * - `wide` — sidebar is a column; footer is a single row of History |
87
- * Cancel/Save (transform controls live in the Crop panel).
88
- * - `narrow` — sidebar collapsed; transform controls sit above a
89
- * History | Cancel/Save row.
74
+ * Whether the media being edited is an image. The history and transform
75
+ * clusters render nothing for other media types, so a frame uses this to
76
+ * decide whether the container it would put them in is worth rendering at
77
+ * all.
90
78
  */
91
- footerLayout: 'wide' | 'narrow';
79
+ isImage: boolean;
80
+ layout: 'wide' | 'narrow';
92
81
  onRequestClose: () => void;
93
82
  onKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;
94
83
  shouldCloseOnClickOutside: boolean;
@@ -106,18 +95,37 @@ export interface MediaEditorProps {
106
95
  renderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;
107
96
  noticesClassName?: string;
108
97
  noticesPortalElement?: Element | null;
109
- showCloseButton?: boolean;
110
98
  shouldCloseOnEsc?: boolean;
99
+ /**
100
+ * The `@wordpress/interface` scope for the details sidebar and its pinned
101
+ * items. Frames should pass a distinct scope so that sidebar visibility —
102
+ * which is persisted per scope to user meta — is remembered separately for
103
+ * each surface. The modal is a transient surface where a collapsed sidebar
104
+ * is a reasonable choice; the full-screen route is one where the sidebar is
105
+ * the primary metadata surface and should open by default. Sharing a scope
106
+ * would let a choice made in one decide the other's starting state.
107
+ *
108
+ * @default 'media-editor'
109
+ */
110
+ scope?: string;
111
+ }
112
+
113
+ interface MediaEditorSidebarProps {
114
+ tabs: EditorTab[];
115
+ activeTabId?: string;
116
+ onTabChange: ( tabId: string ) => void;
117
+ scope: string;
111
118
  }
112
119
 
113
- function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
114
- // The tab list and panels must share one `<Tabs.Root>`, but they render in
115
- // separate `ComplementaryArea` regions (header vs body). A non-virtual Slot
116
- // reconciles both inline at the Slot, so the `Root` is lifted to wrap this
117
- // Fill and that Slot together — see `MediaEditorContent`.
120
+ function MediaEditorSidebar( {
121
+ tabs,
122
+ activeTabId,
123
+ onTabChange,
124
+ scope,
125
+ }: MediaEditorSidebarProps ) {
118
126
  return (
119
127
  <ComplementaryArea
120
- scope="media-editor"
128
+ scope={ scope }
121
129
  identifier="media-editor/details"
122
130
  title={ __( 'Details' ) }
123
131
  icon={ drawerRight }
@@ -126,6 +134,16 @@ function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
126
134
  panelClassName="media-editor__sidebar-panel"
127
135
  headerClassName="media-editor__sidebar-header"
128
136
  closeLabel={ __( 'Close media panel' ) }
137
+ // Makes `Tabs.Root` the container, so the tab list passed as
138
+ // `header` and the panels below share a subtree across the fill.
139
+ render={
140
+ <Tabs.Root
141
+ value={ activeTabId }
142
+ onValueChange={ ( value ) =>
143
+ onTabChange( value as string )
144
+ }
145
+ />
146
+ }
129
147
  header={
130
148
  <Tabs.List variant="minimal">
131
149
  { tabs.map( ( tab ) => (
@@ -145,26 +163,64 @@ function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
145
163
  );
146
164
  }
147
165
 
148
- interface HeaderActionsProps {
149
- isSaving: boolean;
166
+ /**
167
+ * Everything the frame's action clusters need from the editor. Supplied by
168
+ * context rather than by props so the clusters can be module-level components:
169
+ * a component created during a render has a new identity on every pass, which
170
+ * remounts its subtree and drops focus mid-interaction.
171
+ */
172
+ interface MediaEditorFrameContextValue {
150
173
  isImage: boolean;
151
- showCloseButton?: boolean;
174
+ isSaving: boolean;
175
+ hasMedia: boolean;
176
+ hasChanges: boolean;
177
+ isUndoRedoDisabled: boolean;
178
+ scope: string;
179
+ aspectRatioPresets?: AspectRatioPreset[];
152
180
  onCancel: () => void;
181
+ onSave: () => void;
182
+ onReset: () => void;
153
183
  }
154
184
 
155
- function HeaderActions( {
156
- isSaving,
157
- isImage,
158
- showCloseButton = false,
159
- onCancel,
160
- }: HeaderActionsProps ) {
185
+ const MediaEditorFrameContext =
186
+ createContext< MediaEditorFrameContextValue | null >( null );
187
+
188
+ /**
189
+ * Hook to access the media editor's frame context.
190
+ *
191
+ * Must be used within a MediaEditor component.
192
+ *
193
+ * @return MediaEditorFrameContextValue the action clusters render from.
194
+ */
195
+ function useMediaEditorFrameContext(): MediaEditorFrameContextValue {
196
+ const context = useContext( MediaEditorFrameContext );
197
+ if ( ! context ) {
198
+ throw new Error(
199
+ 'useMediaEditorFrameContext must be used within MediaEditor'
200
+ );
201
+ }
202
+ return context;
203
+ }
204
+
205
+ export interface HeaderActionsProps {
206
+ /**
207
+ * Whether to include a Close button. Frames with a dismissal affordance of
208
+ * their own — a route's breadcrumbs, say — leave it out.
209
+ *
210
+ * @default false
211
+ */
212
+ showCloseButton?: boolean;
213
+ }
214
+
215
+ function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
216
+ const { isImage, isSaving, onCancel, scope } = useMediaEditorFrameContext();
161
217
  const [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );
162
218
  return (
163
- <Flex
219
+ <Stack
164
220
  className="media-editor__header-actions"
165
221
  justify="flex-end"
166
- expanded={ false }
167
- gap={ 2 }
222
+ align="center"
223
+ gap="sm"
168
224
  >
169
225
  { isImage && (
170
226
  <Button
@@ -174,7 +230,7 @@ function HeaderActions( {
174
230
  onClick={ () => setIsShortcutsModalOpen( true ) }
175
231
  />
176
232
  ) }
177
- <PinnedItems.Slot scope="media-editor" />
233
+ <PinnedItems.Slot scope={ scope } />
178
234
  { showCloseButton && (
179
235
  <Button
180
236
  size="compact"
@@ -190,19 +246,13 @@ function HeaderActions( {
190
246
  onClose={ () => setIsShortcutsModalOpen( false ) }
191
247
  />
192
248
  ) }
193
- </Flex>
249
+ </Stack>
194
250
  );
195
251
  }
196
252
 
197
- interface HistoryActionsProps {
198
- isUndoRedoDisabled?: boolean;
199
- onReset: () => void;
200
- }
201
-
202
- function HistoryActions( {
203
- isUndoRedoDisabled = false,
204
- onReset,
205
- }: HistoryActionsProps ) {
253
+ function HistoryActions() {
254
+ const { isImage, isUndoRedoDisabled, onReset } =
255
+ useMediaEditorFrameContext();
206
256
  const {
207
257
  reset,
208
258
  isDirty,
@@ -213,6 +263,11 @@ function HistoryActions( {
213
263
  beginGesture,
214
264
  endGesture,
215
265
  } = useMediaEditor();
266
+ // Non-image media has no edit history. Checked after the hooks above so
267
+ // the hook order stays stable across renders.
268
+ if ( ! isImage ) {
269
+ return null;
270
+ }
216
271
  const handleUndo = () => {
217
272
  if ( isUndoRedoDisabled ) {
218
273
  return;
@@ -232,10 +287,10 @@ function HistoryActions( {
232
287
  endGesture();
233
288
  };
234
289
  return (
235
- <Flex
290
+ <Stack
236
291
  className="media-editor__history-actions"
237
- expanded={ false }
238
- gap={ 2 }
292
+ align="center"
293
+ gap="sm"
239
294
  >
240
295
  <Button
241
296
  size="compact"
@@ -270,35 +325,34 @@ function HistoryActions( {
270
325
  accessibleWhenDisabled
271
326
  onClick={ handleRedo }
272
327
  />
273
- </Flex>
328
+ </Stack>
274
329
  );
275
330
  }
276
331
 
277
- interface FooterActionsProps {
278
- isSaving: boolean;
279
- hasMedia: boolean;
280
- hasChanges: boolean;
281
- onCancel: () => void;
282
- onSave: () => void;
332
+ export interface SaveActionsProps {
333
+ /**
334
+ * Button height. Footers take the 40px default; frames placing these in a
335
+ * page header pass `compact` to match the header's other controls.
336
+ *
337
+ * @default 'default'
338
+ */
339
+ size?: 'default' | 'compact';
283
340
  }
284
341
 
285
- function FooterActions( {
286
- isSaving,
287
- hasMedia,
288
- hasChanges,
289
- onCancel,
290
- onSave,
291
- }: FooterActionsProps ) {
342
+ function SaveActions( { size = 'default' }: SaveActionsProps ) {
343
+ const { isSaving, hasMedia, hasChanges, onCancel, onSave } =
344
+ useMediaEditorFrameContext();
292
345
  const saveDisabled = isSaving || ! hasMedia || ! hasChanges;
293
346
  return (
294
- <Flex
295
- className="media-editor__footer-actions"
347
+ <Stack
348
+ className="media-editor__save-actions"
296
349
  justify="flex-end"
297
- expanded={ false }
298
- gap={ 2 }
350
+ align="center"
351
+ gap="sm"
299
352
  >
300
353
  <Button
301
354
  __next40pxDefaultSize
355
+ size={ size }
302
356
  variant="tertiary"
303
357
  onClick={ onCancel }
304
358
  disabled={ isSaving }
@@ -308,6 +362,7 @@ function FooterActions( {
308
362
  </Button>
309
363
  <Button
310
364
  __next40pxDefaultSize
365
+ size={ size }
311
366
  variant="primary"
312
367
  onClick={ onSave }
313
368
  isBusy={ isSaving }
@@ -316,7 +371,23 @@ function FooterActions( {
316
371
  >
317
372
  { __( 'Save' ) }
318
373
  </Button>
319
- </Flex>
374
+ </Stack>
375
+ );
376
+ }
377
+
378
+ function ImageControls() {
379
+ const { isImage, aspectRatioPresets } = useMediaEditorFrameContext();
380
+ // Non-image media has nothing to transform. Placement is the frame's call:
381
+ // render this only in the `narrow` layout, since above that breakpoint the
382
+ // Crop panel holds these controls already.
383
+ if ( ! isImage ) {
384
+ return null;
385
+ }
386
+ return (
387
+ <MediaEditorImageControls
388
+ showAspectRatioControl
389
+ aspectRatioPresets={ aspectRatioPresets }
390
+ />
320
391
  );
321
392
  }
322
393
 
@@ -329,19 +400,19 @@ function MediaEditorContent( {
329
400
  renderFrame,
330
401
  noticesClassName = 'media-editor__snackbar',
331
402
  noticesPortalElement,
332
- showCloseButton = false,
333
403
  shouldCloseOnEsc = false,
404
+ scope = 'media-editor',
334
405
  }: MediaEditorProps ) {
335
406
  const cropper = useMediaEditor();
336
407
  // The sidebar is a side column from the `small` breakpoint up and collapses
337
408
  // to an overlay below it — mirroring InterfaceSkeleton's behaviour, shifted
338
409
  // from `medium` to `small` (see the matching CSS overrides in style.scss).
339
410
  // Track that single breakpoint: in "panel mode" (≥ small) the
340
- // rotate/flip/zoom controls live in the Crop panel and the footer is just
341
- // History + Cancel/Save; below it the controls drop into the footer. (The
342
- // fine-rotation ruler always sits under the canvas.)
411
+ // rotate/flip/zoom controls live in the Crop panel; below it they have no
412
+ // panel to live in and the frame places them instead. (The fine-rotation
413
+ // ruler always sits under the canvas.)
343
414
  const isPanelLayout = useViewportMatch( 'small' );
344
- const footerLayout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';
415
+ const layout: 'wide' | 'narrow' = isPanelLayout ? 'wide' : 'narrow';
345
416
 
346
417
  const { media, hasEdits } = useSelect(
347
418
  ( select ) => {
@@ -578,62 +649,60 @@ function MediaEditorContent( {
578
649
  onChange={ handleChange }
579
650
  settings={ { fields } }
580
651
  >
581
- { ! media ? (
582
- <div className="media-editor">
652
+ <div className="media-editor">
653
+ { ! media ? (
583
654
  <div className="media-editor__loading">
584
655
  <Spinner />
585
656
  </div>
586
- </div>
587
- ) : (
588
- <Tabs.Root
589
- className="media-editor"
590
- value={ activeTabId }
591
- onValueChange={ ( value ) =>
592
- setSelectedTabId( value as string )
593
- }
594
- >
595
- <MediaEditorSidebar tabs={ tabs } />
596
- <InterfaceSkeleton
597
- className="media-editor__skeleton"
598
- labels={ {
599
- body: isImage
600
- ? __( 'Image editor' )
601
- : __( 'Media preview' ),
602
- sidebar: __( 'Media details' ),
603
- } }
604
- content={
605
- <div className="media-editor__content">
606
- <div className="media-editor__canvas-area">
607
- { isImage ? (
608
- <MediaEditorCanvas
609
- focusOnMount
610
- isPlacementActive={
611
- isPlacementActive
612
- }
613
- onGestureStart={
614
- handleCanvasGestureStart
615
- }
616
- onGestureEnd={
617
- handleCanvasGestureEnd
618
- }
619
- />
620
- ) : (
621
- <MediaPreview />
657
+ ) : (
658
+ <>
659
+ <MediaEditorSidebar
660
+ tabs={ tabs }
661
+ activeTabId={ activeTabId }
662
+ onTabChange={ setSelectedTabId }
663
+ scope={ scope }
664
+ />
665
+ <InterfaceSkeleton
666
+ className="media-editor__skeleton"
667
+ labels={ {
668
+ body: isImage
669
+ ? __( 'Image editor' )
670
+ : __( 'Media preview' ),
671
+ sidebar: __( 'Media details' ),
672
+ } }
673
+ content={
674
+ <div className="media-editor__content">
675
+ <div className="media-editor__canvas-area">
676
+ { isImage ? (
677
+ <MediaEditorCanvas
678
+ isPlacementActive={
679
+ isPlacementActive
680
+ }
681
+ onGestureStart={
682
+ handleCanvasGestureStart
683
+ }
684
+ onGestureEnd={
685
+ handleCanvasGestureEnd
686
+ }
687
+ />
688
+ ) : (
689
+ <MediaPreview />
690
+ ) }
691
+ </div>
692
+ { isImage && (
693
+ <div className="media-editor__canvas-toolbar">
694
+ { ruler }
695
+ </div>
622
696
  ) }
623
697
  </div>
624
- { isImage && (
625
- <div className="media-editor__canvas-toolbar">
626
- { ruler }
627
- </div>
628
- ) }
629
- </div>
630
- }
631
- sidebar={
632
- <ComplementaryArea.Slot scope="media-editor" />
633
- }
634
- />
635
- </Tabs.Root>
636
- ) }
698
+ }
699
+ sidebar={
700
+ <ComplementaryArea.Slot scope={ scope } />
701
+ }
702
+ />
703
+ </>
704
+ ) }
705
+ </div>
637
706
  <ConfirmDialog
638
707
  isOpen={ isDiscardDialogOpen }
639
708
  confirmButtonText={ __( 'Discard' ) }
@@ -654,74 +723,36 @@ function MediaEditorContent( {
654
723
  </MediaEditorProvider>
655
724
  );
656
725
 
657
- const history = isImage ? (
658
- <HistoryActions
659
- isUndoRedoDisabled={ isCropInteractionActive }
660
- onReset={ resetCropOptions }
661
- />
662
- ) : null;
663
- const imageControls = isImage ? (
664
- <MediaEditorImageControls
665
- showAspectRatioControl
666
- aspectRatioPresets={ aspectRatioPresets }
667
- />
668
- ) : null;
669
- const actions = (
670
- <FooterActions
671
- isSaving={ isSaving }
672
- hasMedia={ !! media }
673
- hasChanges={ hasChanges }
674
- onCancel={ handleRequestClose }
675
- onSave={ saveMediaEditor }
676
- />
677
- );
678
-
679
- // The fine-rotation ruler always lives under the canvas (in
680
- // `media-editor__content`), never the footer, so it stays constrained to
681
- // the canvas column at every viewport. One JSX tree per layout; DOM order
682
- // matches visual order.
683
- let footerActions: ReactNode;
684
- if ( footerLayout === 'wide' ) {
685
- // Sidebar is a column: image controls live in the Crop panel, so
686
- // the footer is just History + Cancel/Save.
687
- footerActions = (
688
- <>
689
- { history }
690
- { actions }
691
- </>
692
- );
693
- } else {
694
- // Sidebar collapsed: the image controls drop into the footer.
695
- footerActions = (
696
- <>
697
- { imageControls }
698
- <div className="media-editor-modal__footer-row">
699
- { history }
700
- { actions }
701
- </div>
702
- </>
703
- );
704
- }
705
-
706
- return renderFrame( {
707
- children,
708
- headerActions: (
709
- <HeaderActions
710
- isSaving={ isSaving }
711
- isImage={ isImage }
712
- showCloseButton={ showCloseButton }
713
- onCancel={ handleRequestClose }
714
- />
715
- ),
716
- footerActions,
717
- footerLayout,
718
- onRequestClose: handleRequestClose,
719
- onKeyDown: handleKeyDown,
720
- shouldCloseOnClickOutside: ! hasChanges && ! isSaving,
726
+ // Rebuilt each render, like the elements it replaces: consumers re-render
727
+ // as they always did, but the cluster component types stay stable.
728
+ const contextValue: MediaEditorFrameContextValue = {
729
+ isImage,
721
730
  isSaving,
722
- hasChanges,
723
731
  hasMedia: !! media,
724
- } );
732
+ hasChanges,
733
+ isUndoRedoDisabled: isCropInteractionActive,
734
+ scope,
735
+ aspectRatioPresets,
736
+ onCancel: handleRequestClose,
737
+ onSave: saveMediaEditor,
738
+ onReset: resetCropOptions,
739
+ };
740
+
741
+ return (
742
+ <MediaEditorFrameContext.Provider value={ contextValue }>
743
+ { renderFrame( {
744
+ children,
745
+ isImage,
746
+ layout,
747
+ onRequestClose: handleRequestClose,
748
+ onKeyDown: handleKeyDown,
749
+ shouldCloseOnClickOutside: ! hasChanges && ! isSaving,
750
+ isSaving,
751
+ hasChanges,
752
+ hasMedia: !! media,
753
+ } ) }
754
+ </MediaEditorFrameContext.Provider>
755
+ );
725
756
  }
726
757
 
727
758
  export function MediaEditor( props: MediaEditorProps ) {
@@ -732,4 +763,12 @@ export function MediaEditor( props: MediaEditorProps ) {
732
763
  );
733
764
  }
734
765
 
766
+ // Attached to `MediaEditor` so frames import and arrange them, the way
767
+ // `DataViewsPicker` exposes its own sub-components. They read what they need
768
+ // from context, so a frame only chooses where they go and how they look.
769
+ MediaEditor.HeaderActions = HeaderActions;
770
+ MediaEditor.HistoryActions = HistoryActions;
771
+ MediaEditor.SaveActions = SaveActions;
772
+ MediaEditor.ImageControls = ImageControls;
773
+
735
774
  export default MediaEditor;
@@ -102,10 +102,13 @@
102
102
  .media-editor__sidebar {
103
103
  @include reset;
104
104
 
105
- // Small left gutter so the tabs and panel content (and the zoom
106
- // slider's thumb at its minimum) sit off the sidebar edge.
105
+ // Equal inline gutter so focus rings (outline + offset) and the zoom
106
+ // slider thumb at its minimum sit inside the sidebar without shifting
107
+ // the panel toward one edge. The complementary area uses overflow: auto
108
+ // and the skeleton sidebar overflow: hidden, so a 1px-only left inset
109
+ // still clips the 2px focus outline.
107
110
  @include break-small() {
108
- padding-left: 1px;
111
+ padding-inline: $grid-unit-10;
109
112
  }
110
113
  }
111
114
 
@@ -1,11 +1,4 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import { fireEvent, render, screen } from '@testing-library/react';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
2
  import { useCropOptions } from '../use-crop-options';
10
3
  import { ORIGINAL_ASPECT_RATIO } from '../../../image-editor/core/constants';
11
4
  import { MediaEditorStateProvider } from '../../../state';
@@ -1,11 +1,4 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import { useMemo } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
2
  import { DEFAULT_ASPECT_RATIOS } from '../../image-editor/core/constants';
10
3
  import type { AspectRatioPreset } from '../../image-editor/core/constants';
11
4
  import { useMediaEditor, resolveAspectRatio } from '../../state';
@@ -1,16 +1,9 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
1
  import apiFetch from '@wordpress/api-fetch';
5
2
  import { useDispatch, useRegistry } from '@wordpress/data';
6
3
  import { store as coreStore } from '@wordpress/core-data';
7
4
  import { useCallback, useState } from '@wordpress/element';
8
5
  import { __, sprintf } from '@wordpress/i18n';
9
6
  import { store as noticesStore } from '@wordpress/notices';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
7
  import type { Media } from '../media-editor-provider';
15
8
  import type { MediaEditorController } from '../../state';
16
9
  import {