@wordpress/media-editor 0.10.1 → 0.11.1

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 (85) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/components/media-editor/index.cjs +41 -51
  3. package/build/components/media-editor/index.cjs.map +3 -3
  4. package/build/components/media-editor-crop-panel/index.cjs +15 -45
  5. package/build/components/media-editor-crop-panel/index.cjs.map +3 -3
  6. package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
  7. package/build/components/media-editor-image-controls/index.cjs +230 -0
  8. package/build/components/media-editor-image-controls/index.cjs.map +7 -0
  9. package/build/components/media-form/index.cjs +12 -23
  10. package/build/components/media-form/index.cjs.map +3 -3
  11. package/build/image-editor/core/constants.cjs +3 -0
  12. package/build/image-editor/core/constants.cjs.map +2 -2
  13. package/build/image-editor/core/stencil-math.cjs +11 -2
  14. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  15. package/build/image-editor/react/components/cropper.cjs +12 -7
  16. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  17. package/build-module/components/media-editor/index.mjs +41 -51
  18. package/build-module/components/media-editor/index.mjs.map +2 -2
  19. package/build-module/components/media-editor-crop-panel/index.mjs +8 -51
  20. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  21. package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
  22. package/build-module/components/media-editor-image-controls/index.mjs +221 -0
  23. package/build-module/components/media-editor-image-controls/index.mjs.map +7 -0
  24. package/build-module/components/media-form/index.mjs +12 -13
  25. package/build-module/components/media-form/index.mjs.map +2 -2
  26. package/build-module/image-editor/core/constants.mjs +2 -0
  27. package/build-module/image-editor/core/constants.mjs.map +2 -2
  28. package/build-module/image-editor/core/stencil-math.mjs +9 -1
  29. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  30. package/build-module/image-editor/react/components/cropper.mjs +12 -7
  31. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  32. package/build-style/style-rtl.css +136 -47
  33. package/build-style/style.css +136 -46
  34. package/build-types/components/media-editor/index.d.ts +6 -7
  35. package/build-types/components/media-editor/index.d.ts.map +1 -1
  36. package/build-types/components/media-editor-crop-panel/index.d.ts +11 -6
  37. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  38. package/build-types/components/media-editor-fine-rotation/index.d.ts +4 -3
  39. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  40. package/build-types/components/media-editor-image-controls/index.d.ts +46 -0
  41. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -0
  42. package/build-types/components/media-editor-toolbar/index.d.ts +24 -0
  43. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -0
  44. package/build-types/components/media-editor-transform-controls/index.d.ts +18 -5
  45. package/build-types/components/media-editor-transform-controls/index.d.ts.map +1 -1
  46. package/build-types/components/media-form/index.d.ts.map +1 -1
  47. package/build-types/image-editor/core/constants.d.ts +10 -0
  48. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  49. package/build-types/image-editor/core/stencil-math.d.ts +16 -3
  50. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  51. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  52. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +108 -0
  53. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -0
  54. package/package.json +25 -20
  55. package/src/components/media-editor/index.tsx +69 -77
  56. package/src/components/media-editor/style.scss +124 -4
  57. package/src/components/media-editor-crop-panel/index.tsx +16 -62
  58. package/src/components/media-editor-crop-panel/test/index.tsx +25 -41
  59. package/src/components/media-editor-fine-rotation/index.tsx +4 -3
  60. package/src/components/media-editor-image-controls/index.tsx +262 -0
  61. package/src/components/media-editor-image-controls/style.scss +48 -0
  62. package/src/components/media-editor-image-controls/test/index.tsx +150 -0
  63. package/src/components/media-editor-modal/style.scss +32 -42
  64. package/src/components/media-form/index.tsx +17 -21
  65. package/src/components/media-form/style.scss +6 -0
  66. package/src/components/rotation-ruler/style.scss +10 -3
  67. package/src/image-editor/core/constants.ts +11 -0
  68. package/src/image-editor/core/stencil-math.ts +23 -0
  69. package/src/image-editor/core/test/stencil-math.ts +39 -0
  70. package/src/image-editor/react/components/cropper.scss +28 -17
  71. package/src/image-editor/react/components/cropper.tsx +17 -7
  72. package/src/style.scss +2 -1
  73. package/tsconfig.tsbuildinfo +1 -1
  74. package/build/components/media-editor-transform-controls/index.cjs +0 -84
  75. package/build/components/media-editor-transform-controls/index.cjs.map +0 -7
  76. package/build/components/media-form/sidebar-datetime-view.cjs +0 -53
  77. package/build/components/media-form/sidebar-datetime-view.cjs.map +0 -7
  78. package/build-module/components/media-editor-transform-controls/index.mjs +0 -68
  79. package/build-module/components/media-editor-transform-controls/index.mjs.map +0 -7
  80. package/build-module/components/media-form/sidebar-datetime-view.mjs +0 -32
  81. package/build-module/components/media-form/sidebar-datetime-view.mjs.map +0 -7
  82. package/src/components/media-editor-transform-controls/index.tsx +0 -70
  83. package/src/components/media-editor-transform-controls/style.scss +0 -8
  84. package/src/components/media-form/sidebar-datetime-view.tsx +0 -47
  85. package/src/components/media-form/test/sidebar-datetime-view.test.tsx +0 -96
@@ -21,71 +21,51 @@
21
21
  min-height: 0;
22
22
  }
23
23
 
24
- // Footer chrome — three layouts driven by `is-wide` / `is-medium` /
25
- // `is-narrow` modifier classes set from the media editor. Wide is a single
26
- // flex row; medium and narrow stack via `flex-direction: column`. Each
27
- // layout has its own JSX tree (not `order` reshuffling, which the project's
28
- // stylelint rule treats as an a11y red flag), so DOM order always matches
29
- // visual order.
24
+ // Footer chrome — two layouts driven by `is-wide` / `is-narrow` modifier
25
+ // classes set from the media editor at the sidebar-collapse breakpoint.
26
+ // Wide is a single flex row (History | Cancel/Save); narrow stacks via
27
+ // `flex-direction: column` (image controls above the History |
28
+ // Cancel/Save row). Each layout has its own JSX tree (not `order`
29
+ // reshuffling, which the project's stylelint rule treats as an a11y red
30
+ // flag), so DOM order always matches visual order.
30
31
  .media-editor-modal.components-modal__frame .media-editor-modal__footer {
31
32
  flex-shrink: 0;
32
33
  display: flex;
33
34
  gap: $grid-unit-20;
34
- padding: $grid-unit-10 $grid-unit-30;
35
- border-top: $border-width solid $gray-300;
35
+ // Borderless: sections are demarcated by the inset canvas panel and
36
+ // spacing, not divider lines. 16px top / 32px sides / 24px bottom.
37
+ padding: $grid-unit-20 $grid-unit-40 $grid-unit-30;
36
38
  background: $white;
39
+ // Above the `.interface-interface-skeleton__sidebar` which has a z-index of 100000.
40
+ z-index: z-index(".media-editor-modal__footer");
37
41
 
38
42
  &.is-wide {
39
43
  flex-direction: row;
40
44
  align-items: center;
41
45
 
42
- // Wide-only wrapper: ruler + transform controls are grouped
43
- // together, centered between History and Cancel/Save with a
44
- // divider rule between them — preserving the long-standing
45
- // wide-desktop look.
46
- .media-editor-modal__footer-toolbar {
47
- flex: 1 1 0;
48
- min-width: 0;
49
- display: flex;
50
- align-items: center;
51
- justify-content: center;
52
- gap: $grid-unit-10;
53
- }
54
-
55
- .media-editor-fine-rotation {
56
- flex: 1 1 280px;
57
- min-width: 0;
58
- max-width: 360px;
59
- }
60
-
61
- .media-editor-transform-controls {
62
- border-left: $border-width solid $gray-300;
63
- padding-left: $grid-unit-15;
64
- }
65
-
66
- // `margin-left: auto` guarantees right alignment whether or not
67
- // History / the toolbar is rendered (handles non-image
68
- // attachments where only `FooterActions` is present).
46
+ // Panel mode: the footer holds only History (left) and
47
+ // Cancel/Save (right). `margin-left: auto` pins the actions to the
48
+ // right edge whether or not History renders (e.g. non-image
49
+ // attachments show only `FooterActions`).
69
50
  .media-editor__footer-actions {
70
51
  margin-left: auto;
71
52
  }
72
53
  }
73
54
 
74
- &.is-medium,
75
55
  &.is-narrow {
76
56
  flex-direction: column;
77
57
  }
78
58
 
79
- // Narrow only: transform cluster sits on its own row, centered.
80
- &.is-narrow > .media-editor-transform-controls {
59
+ // Narrow only: image controls sit on their own row, centered.
60
+ &.is-narrow > .media-editor-image-controls {
81
61
  align-self: center;
82
62
  }
83
63
  }
84
64
 
85
- // Secondary row used by medium (History + Transform + Cancel/Save) and
86
- // narrow (History + Cancel/Save). `margin-left: auto` on the transform
65
+ // Secondary row used by medium (History + Image controls + Cancel/Save) and
66
+ // narrow (History + Cancel/Save). `margin-left: auto` on the image controls
87
67
  // cluster and on Cancel/Save splits any free space — History gets the
88
- // left edge, Cancel/Save the right edge, and the transform cluster (when
68
+ // left edge, Cancel/Save the right edge, and the image controls (when
89
69
  // present, i.e. medium only) approximately centers. Exact centering only
90
70
  // holds when History and Cancel/Save have matching widths; in practice
91
71
  // they're close enough that the offset is imperceptible.
@@ -95,12 +75,22 @@
95
75
  align-items: center;
96
76
  gap: $grid-unit-20;
97
77
 
98
- .media-editor-transform-controls,
78
+ .media-editor-image-controls,
99
79
  .media-editor__footer-actions {
100
80
  margin-left: auto;
101
81
  }
102
82
  }
103
83
 
84
+ // Active (enabled) undo/redo icon buttons take the admin accent colour so
85
+ // they read as live alongside the Reset/Cancel/Save actions. Disabled
86
+ // buttons (rendered with `aria-disabled` via `accessibleWhenDisabled`)
87
+ // keep the default muted icon colour.
88
+ // NOTE: overrides @wordpress/components Button internals (`.components-button`,
89
+ // `.has-icon`), scoped to our history-actions wrapper. Update if renamed.
90
+ .media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
91
+ color: var(--wp-admin-theme-color);
92
+ }
93
+
104
94
  .media-editor-modal {
105
95
  display: flex;
106
96
  flex-direction: column;
@@ -6,7 +6,6 @@ import type { Form, Field } from '@wordpress/dataviews';
6
6
  import { Spinner, __experimentalVStack as VStack } from '@wordpress/components';
7
7
  import { VisuallyHidden } from '@wordpress/ui';
8
8
  import { __ } from '@wordpress/i18n';
9
- import { useMemo } from '@wordpress/element';
10
9
  import type { ReactNode } from 'react';
11
10
 
12
11
  /**
@@ -14,7 +13,6 @@ import type { ReactNode } from 'react';
14
13
  */
15
14
  import { useMediaEditorContext } from '../media-editor-provider';
16
15
  import type { Media } from '../media-editor-provider';
17
- import SidebarDatetimeView from './sidebar-datetime-view';
18
16
 
19
17
  /**
20
18
  * Props for MediaForm component.
@@ -41,18 +39,6 @@ export default function MediaForm( {
41
39
  }: MediaFormProps ) {
42
40
  const { media, fields, onChange } = useMediaEditorContext();
43
41
 
44
- // Render readonly datetime fields compactly in the sidebar: date only,
45
- // with the full datetime exposed on hover via Tooltip and `title`.
46
- const formFields = useMemo(
47
- () =>
48
- fields.map( ( field: Field< Media > ) =>
49
- field.type === 'datetime' && field.readOnly
50
- ? { ...field, render: SidebarDatetimeView }
51
- : field
52
- ),
53
- [ fields ]
54
- );
55
-
56
42
  if ( ! media || ! onChange ) {
57
43
  return (
58
44
  <div className="media-editor-form media-editor-form--loading">
@@ -61,18 +47,28 @@ export default function MediaForm( {
61
47
  );
62
48
  }
63
49
 
50
+ // Fields that use a regular (non-panel) layout, rendered at the top.
51
+ const regularFieldIds = [ 'title', 'alt_text', 'caption', 'description' ];
52
+
53
+ // Place the non-panel (regular layout) fields at the top of the array,
54
+ // with the remaining panel fields below.
55
+ const sortedFields = [
56
+ ...fields.filter( ( field: Field< Media > ) =>
57
+ regularFieldIds.includes( field.id )
58
+ ),
59
+ ...fields.filter(
60
+ ( field: Field< Media > ) => ! regularFieldIds.includes( field.id )
61
+ ),
62
+ ];
63
+
64
64
  // Default form structure with panel layout
65
65
  const defaultForm: Form = {
66
66
  layout: {
67
67
  type: 'panel',
68
68
  },
69
- fields: fields.map( ( field: Field< Media > ) => {
69
+ fields: sortedFields.map( ( field: Field< Media > ) => {
70
70
  // Use regular layout for main editable fields
71
- if (
72
- [ 'title', 'alt_text', 'caption', 'description' ].includes(
73
- field.id
74
- )
75
- ) {
71
+ if ( regularFieldIds.includes( field.id ) ) {
76
72
  return {
77
73
  id: field.id,
78
74
  layout: {
@@ -96,7 +92,7 @@ export default function MediaForm( {
96
92
  { header }
97
93
  <DataForm
98
94
  data={ media }
99
- fields={ formFields }
95
+ fields={ fields }
100
96
  form={ form }
101
97
  onChange={ onChange }
102
98
  />
@@ -0,0 +1,6 @@
1
+ // Discourage an orphaned "am/pm" (or other single-word widow) when a read-only
2
+ // value wraps in the narrow Details panel. Progressive enhancement: browsers
3
+ // without `text-wrap: pretty` simply wrap normally.
4
+ .media-editor-form .dataforms-layouts-panel__field-control {
5
+ text-wrap: pretty;
6
+ }
@@ -80,6 +80,12 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
80
80
 
81
81
  .rotation-ruler__ticks {
82
82
  position: absolute;
83
+ // The tick offset is applied as a JS-set inline `transform: translateX()`
84
+ // (see rotation-ruler/index.tsx), which rtlcss can't mirror. If rtlcss
85
+ // flipped this `left` to `right`, the anchor and the transform would
86
+ // disagree and the ticks would render off-screen in RTL. Keep it `left`
87
+ // so the two stay in sync; the strip is a symmetric number line anyway.
88
+ /*rtl:ignore*/
83
89
  left: 50%;
84
90
  top: 0;
85
91
  display: block;
@@ -118,8 +124,9 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
118
124
  // pointer while the SVG behind it transitions smoothly. The label box
119
125
  // is sized to the number alone — the unit is positioned absolutely so
120
126
  // it does not influence centering — and a fixed-width ::before
121
- // pseudo-element provides the white-fading-to-transparent mask that
122
- // occludes the static labels directly behind.
127
+ // pseudo-element provides the grey-fading-to-transparent mask (matching
128
+ // the canvas/ruler surface) that occludes the static labels directly
129
+ // behind.
123
130
  .rotation-ruler__active-label {
124
131
  position: absolute;
125
132
  top: 0;
@@ -140,7 +147,7 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
140
147
  width: 60px;
141
148
  height: 100%;
142
149
  transform: translateX(-50%);
143
- background: linear-gradient(to right, transparent 0, $white 12px, $white calc(100% - 12px), transparent 100%);
150
+ background: linear-gradient(to right, transparent 0, $gray-200 12px, $gray-200 calc(100% - 12px), transparent 100%);
144
151
  }
145
152
  }
146
153
 
@@ -30,6 +30,17 @@ export const MAX_ZOOM = 10;
30
30
  */
31
31
  export const MIN_CROP_PIXELS = 24;
32
32
 
33
+ /**
34
+ * Minimum on-screen crop rect dimension in CSS pixels. The source-pixel
35
+ * floor (`MIN_CROP_PIXELS`) keeps crops from going sub-pixel, but on a large
36
+ * image fit into a small canvas it can render only a few CSS pixels wide —
37
+ * too small to grab the resize handles. This floor keeps the crop operable
38
+ * regardless of display scale; it binds when zoomed out and yields to the
39
+ * source-pixel floor once the image is shown large enough. Sized to one
40
+ * handle touch target (`$handle-touch-target-size` in `cropper.scss`).
41
+ */
42
+ export const MIN_CROP_SCREEN_PX = 44;
43
+
33
44
  /**
34
45
  * Wheel zoom sensitivity. A deltaY of 100 changes zoom by 0.25.
35
46
  * This could be made configurable as a prop to the Cropper component.
@@ -1,10 +1,33 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
+ import { MIN_CROP_PIXELS, MIN_CROP_SCREEN_PX } from './constants';
4
5
  import type { HandlePosition, NormalizedRect, Size } from './types';
5
6
 
6
7
  export type { HandlePosition };
7
8
 
9
+ /**
10
+ * Resolve the minimum crop dimension, in source-image pixels, for the current
11
+ * display scale.
12
+ *
13
+ * Two floors compete: a fixed source-pixel floor (`MIN_CROP_PIXELS`) that
14
+ * avoids sub-pixel crops, and an on-screen floor (`MIN_CROP_SCREEN_PX`) that
15
+ * keeps the crop large enough to grab. The on-screen floor converted to source
16
+ * pixels is `MIN_CROP_SCREEN_PX / displayScale`; the binding constraint is the
17
+ * larger of the two. When zoomed out (small `displayScale`) the on-screen floor
18
+ * dominates; once the image is shown large enough the source-pixel floor takes
19
+ * over.
20
+ *
21
+ * @param displayScale CSS pixels rendered per source pixel (fit scale × zoom).
22
+ * @return Minimum crop dimension in source-image pixels.
23
+ */
24
+ export function getMinCropPixels( displayScale: number ): number {
25
+ if ( displayScale <= 0 ) {
26
+ return MIN_CROP_PIXELS;
27
+ }
28
+ return Math.max( MIN_CROP_PIXELS, MIN_CROP_SCREEN_PX / displayScale );
29
+ }
30
+
8
31
  /**
9
32
  * Default minimum crop rect dimension in normalized space, used when no
10
33
  * explicit per-axis minimum is supplied (e.g. before the source image
@@ -5,11 +5,50 @@ import {
5
5
  computeFreeResizeRect,
6
6
  computeLockedResizeRect,
7
7
  computeShiftLockedResizeRect,
8
+ getMinCropPixels,
8
9
  type CropBounds,
9
10
  type ResizeDragState,
10
11
  } from '../stencil-math';
12
+ import { MIN_CROP_PIXELS, MIN_CROP_SCREEN_PX } from '../constants';
11
13
  import type { Size } from '../types';
12
14
 
15
+ describe( 'getMinCropPixels — operable on-screen floor', () => {
16
+ it( 'returns the source-pixel hard floor when the image is shown large enough', () => {
17
+ // displayScale = 2 CSS px per source px (zoomed in). The usability
18
+ // term is 44 / 2 = 22 px, below the 24-source-px hard floor, so the
19
+ // hard floor wins.
20
+ expect( getMinCropPixels( 2 ) ).toBe( MIN_CROP_PIXELS );
21
+ } );
22
+
23
+ it( 'raises the floor so the crop stays operable when the image is shown small', () => {
24
+ // A large image fit into a small window: ~0.2 CSS px per source px.
25
+ // 24 source px would render as ~4.8 px on screen — unusable. The
26
+ // usability term (44 / 0.2 = 220 source px) must win.
27
+ expect( getMinCropPixels( 0.2 ) ).toBeCloseTo(
28
+ MIN_CROP_SCREEN_PX / 0.2,
29
+ 5
30
+ );
31
+ expect( getMinCropPixels( 0.2 ) ).toBeGreaterThan( MIN_CROP_PIXELS );
32
+ } );
33
+
34
+ it( 'crosses over from usability floor to hard floor at displayScale = MIN_CROP_SCREEN_PX / MIN_CROP_PIXELS', () => {
35
+ const crossover = MIN_CROP_SCREEN_PX / MIN_CROP_PIXELS;
36
+ expect( getMinCropPixels( crossover ) ).toBeCloseTo(
37
+ MIN_CROP_PIXELS,
38
+ 5
39
+ );
40
+ // Just below the crossover, the usability term exceeds the hard floor.
41
+ expect( getMinCropPixels( crossover * 0.99 ) ).toBeGreaterThan(
42
+ MIN_CROP_PIXELS
43
+ );
44
+ } );
45
+
46
+ it( 'falls back to the hard floor for a non-positive display scale', () => {
47
+ expect( getMinCropPixels( 0 ) ).toBe( MIN_CROP_PIXELS );
48
+ expect( getMinCropPixels( -1 ) ).toBe( MIN_CROP_PIXELS );
49
+ } );
50
+ } );
51
+
13
52
  const FULL_BOUNDS: CropBounds = { minX: 0, minY: 0, maxX: 1, maxY: 1 };
14
53
 
15
54
  describe( 'computeLockedResizeRect — driver-axis selection', () => {
@@ -1,6 +1,9 @@
1
- // Handle touch target size — used both for the handle ::before hit area and
2
- // for the inner canvas inset (half the touch target on each side so the full
3
- // reach extends to the crop edge).
1
+ @use "@wordpress/base-styles/colors" as *;
2
+ @use "@wordpress/base-styles/variables" as *;
3
+
4
+ // Handle touch target size — used for the handle ::before hit area. The
5
+ // inner canvas inset must stay at least half this (22px) so the handles'
6
+ // reach isn't clipped by the root.
4
7
  $handle-touch-target-size: 44px;
5
8
 
6
9
  .wp-media-editor-image-editor {
@@ -15,12 +18,15 @@ $handle-touch-target-size: 44px;
15
18
  // Inner gutter for resize handles. Handles use negative offsets and a
16
19
  // touch target that extends past the crop edge; the root clips overflow
17
20
  // (required for the dimming overlay's box-shadow trick), so a flush
18
- // handle would be clipped. The inner `__canvas` wrapper is inset by half
19
- // the touch target, reserving reach room on all sides while keeping the
20
- // root as the clipping boundary.
21
+ // handle would be clipped. The inner `__canvas` wrapper is inset to
22
+ // reserve reach room on all sides while keeping the root as the clipping
23
+ // boundary. `$grid-unit-30` (24px) ≥ half the 44px touch target, so the
24
+ // handles still clear the edge.
21
25
  &__canvas {
22
26
  position: absolute;
23
- inset: calc($handle-touch-target-size / 2);
27
+ inset: $grid-unit-30;
28
+ min-height: 100px;
29
+ min-width: 100px;
24
30
 
25
31
  // Suppress the browser's default focus ring — the crop rectangle
26
32
  // border provides the custom keyboard-focus indicator instead.
@@ -56,15 +62,16 @@ $handle-touch-target-size: 44px;
56
62
  &__dimming {
57
63
  position: absolute;
58
64
  pointer-events: none;
59
- /* Large shadow spread dims everything outside the crop area.
60
- Darker at rest for clear crop framing, lighter during drag
61
- so the user can see where they're panning. */
62
- box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
65
+ /* Large shadow spread washes everything outside the crop area
66
+ toward the canvas grey ($gray-200). Slightly stronger at rest
67
+ for clear crop framing, lighter during drag so the user can see
68
+ where they're panning. */
69
+ box-shadow: 0 0 0 9999px rgba($gray-200, 0.6);
63
70
  transition: box-shadow 0.15s ease;
64
71
  }
65
72
 
66
73
  &--dragging &__dimming {
67
- box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
74
+ box-shadow: 0 0 0 9999px rgba($gray-200, 0.4);
68
75
  }
69
76
 
70
77
  &__grid {
@@ -122,7 +129,9 @@ $handle-touch-target-size: 44px;
122
129
 
123
130
  &__stencil-rect {
124
131
  position: absolute;
125
- border: 1px solid rgba(255, 255, 255, 0.7);
132
+ // Dark crop outline, matching the sidebar control/heading text so
133
+ // the crop boundary stays legible against the light grey wash.
134
+ border: 1px solid $gray-900;
126
135
  box-sizing: border-box;
127
136
  pointer-events: none;
128
137
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
@@ -152,8 +161,10 @@ $handle-touch-target-size: 44px;
152
161
  position: absolute;
153
162
  width: 12px;
154
163
  height: 12px;
155
- background: rgba(255, 255, 255, 0.6);
156
- border: 1px solid rgba(255, 255, 255, 0.9);
164
+ // Solid white fill with an accent-blue border so the handles read
165
+ // clearly against the light grey wash.
166
+ background: $white;
167
+ border: 1px solid var(--wp-admin-theme-color, #007cba);
157
168
  border-radius: 50%;
158
169
  box-sizing: border-box;
159
170
  pointer-events: auto;
@@ -163,8 +174,8 @@ $handle-touch-target-size: 44px;
163
174
  outline: none;
164
175
  }
165
176
 
166
- // Double ring (white inner + theme-color outer) for legibility
167
- // over the dark dimming overlay. Gated on the JS-controlled
177
+ // Double ring (white inner + theme-color outer) for a clear
178
+ // keyboard-focus state on the handle. Gated on the JS-controlled
168
179
  // keyboard-active class so that mouse interactions after a
169
180
  // keyboard session — e.g., clicking a handle to start a drag —
170
181
  // don't leave the active ring stuck on the handle.
@@ -32,7 +32,7 @@ import type {
32
32
  import type { CropperController } from '../hooks/use-cropper-reducer';
33
33
  import { getImageFit, getRotatedBBox } from '../../core/camera';
34
34
  import { getImageCropBounds, getMinZoom } from '../../core/containment';
35
- import { MIN_CROP_PIXELS } from '../../core/constants';
35
+ import { getMinCropPixels } from '../../core/stencil-math';
36
36
  import { computeInscribedRect } from '../../core/crop-rect';
37
37
  import { useInteraction } from '../hooks/use-interaction';
38
38
  import { useTransformStyle } from '../hooks/use-transform-style';
@@ -275,6 +275,11 @@ function CropperInner(
275
275
  // floor scales with `zoom` to keep the source-pixel floor constant.
276
276
  // Without this, SETTLE_CROP zooms in proportional to the shrink and
277
277
  // successive drags can crop arbitrarily small.
278
+ //
279
+ // The source-pixel floor is resolved per display scale so the crop
280
+ // stays grabbable: a large image fit into a small canvas would render
281
+ // the 24px floor only a few CSS pixels wide. `elementSize.width /
282
+ // naturalWidth` is the fit scale; × zoom gives CSS px per source px.
278
283
  const minCropSize: Size | undefined = useMemo( () => {
279
284
  if ( naturalWidth <= 0 || naturalHeight <= 0 ) {
280
285
  return undefined;
@@ -285,14 +290,19 @@ function CropperInner(
285
290
  naturalHeight,
286
291
  snapRotation
287
292
  );
293
+ const displayScale = ( elementSize.width / naturalWidth ) * state.zoom;
294
+ const minPixels = getMinCropPixels( displayScale );
288
295
  return {
289
- width: Math.min( 1, ( MIN_CROP_PIXELS * state.zoom ) / bbox.width ),
290
- height: Math.min(
291
- 1,
292
- ( MIN_CROP_PIXELS * state.zoom ) / bbox.height
293
- ),
296
+ width: Math.min( 1, ( minPixels * state.zoom ) / bbox.width ),
297
+ height: Math.min( 1, ( minPixels * state.zoom ) / bbox.height ),
294
298
  };
295
- }, [ naturalWidth, naturalHeight, state.rotation, state.zoom ] );
299
+ }, [
300
+ naturalWidth,
301
+ naturalHeight,
302
+ state.rotation,
303
+ state.zoom,
304
+ elementSize.width,
305
+ ] );
296
306
 
297
307
  // Report the rendered image size to the controller. Composite
298
308
  // controllers need it to compute aspect-ratio reshapes from the
package/src/style.scss CHANGED
@@ -2,8 +2,9 @@
2
2
  @use "./components/media-preview/style.scss" as *;
3
3
  @use "./image-editor/style.scss" as *;
4
4
  @use "./components/media-editor/style.scss" as *;
5
+ @use "./components/media-form/style.scss" as *;
5
6
  @use "./components/media-editor-modal/style.scss" as *;
6
7
  @use "./components/media-editor-canvas/style.scss" as *;
7
- @use "./components/media-editor-transform-controls/style.scss" as *;
8
+ @use "./components/media-editor-image-controls/style.scss" as *;
8
9
  @use "./components/media-editor-keyboard-shortcuts-modal/style.scss" as *;
9
10
  @use "./components/rotation-ruler/style.scss" as *;