@wordpress/media-editor 0.8.0 → 0.8.1-next.v.202605131032.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.
- package/build/components/media-editor/index.cjs +560 -0
- package/build/components/media-editor/index.cjs.map +7 -0
- package/build/components/media-editor-canvas/index.cjs +14 -2
- package/build/components/media-editor-canvas/index.cjs.map +2 -2
- package/build/components/media-editor-crop-panel/index.cjs +34 -27
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +162 -0
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +7 -0
- package/build/components/media-editor-modal/index.cjs +42 -430
- package/build/components/media-editor-modal/index.cjs.map +3 -3
- package/build/components/media-editor-toolbar/index.cjs +143 -75
- package/build/components/media-editor-toolbar/index.cjs.map +3 -3
- package/build/components/media-form/index.cjs +3 -0
- package/build/components/media-form/index.cjs.map +2 -2
- package/build/components/rotation-ruler/index.cjs +197 -0
- package/build/components/rotation-ruler/index.cjs.map +7 -0
- package/build/components/rotation-ruler/use-ruler-drag.cjs +154 -0
- package/build/components/rotation-ruler/use-ruler-drag.cjs.map +7 -0
- package/build/hooks/use-crop-gesture-handlers.cjs +43 -0
- package/build/hooks/use-crop-gesture-handlers.cjs.map +7 -0
- package/build/image-editor/core/constants.cjs +9 -0
- package/build/image-editor/core/constants.cjs.map +2 -2
- package/build/image-editor/core/containment.cjs +7 -13
- package/build/image-editor/core/containment.cjs.map +2 -2
- package/build/image-editor/core/interaction-controller.cjs +43 -7
- package/build/image-editor/core/interaction-controller.cjs.map +2 -2
- package/build/image-editor/core/state.cjs +5 -1
- package/build/image-editor/core/state.cjs.map +2 -2
- package/build/image-editor/core/transform-style.cjs.map +1 -1
- package/build/image-editor/core/types.cjs.map +1 -1
- package/build/image-editor/core/viewport-state.cjs +50 -0
- package/build/image-editor/core/viewport-state.cjs.map +7 -0
- package/build/image-editor/react/components/cropper.cjs +192 -72
- package/build/image-editor/react/components/cropper.cjs.map +3 -3
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs +5 -2
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +16 -4
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
- package/build/image-editor/react/components/viewport-provider.cjs +51 -0
- package/build/image-editor/react/components/viewport-provider.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +53 -6
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-cropper-state.cjs +127 -8
- package/build/image-editor/react/hooks/use-cropper-state.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-interaction.cjs +26 -5
- package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-viewport-state.cjs +51 -0
- package/build/image-editor/react/hooks/use-viewport-state.cjs.map +7 -0
- package/build/image-editor/react/visually-hidden-style.cjs +41 -0
- package/build/image-editor/react/visually-hidden-style.cjs.map +7 -0
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +545 -0
- package/build-module/components/media-editor/index.mjs.map +7 -0
- package/build-module/components/media-editor-canvas/index.mjs +14 -2
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +35 -28
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +144 -0
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +7 -0
- package/build-module/components/media-editor-modal/index.mjs +46 -455
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-toolbar/index.mjs +137 -77
- package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
- package/build-module/components/media-form/index.mjs +3 -0
- package/build-module/components/media-form/index.mjs.map +2 -2
- package/build-module/components/rotation-ruler/index.mjs +166 -0
- package/build-module/components/rotation-ruler/index.mjs.map +7 -0
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs +126 -0
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +7 -0
- package/build-module/hooks/use-crop-gesture-handlers.mjs +17 -0
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +7 -0
- package/build-module/image-editor/core/constants.mjs +6 -0
- package/build-module/image-editor/core/constants.mjs.map +2 -2
- package/build-module/image-editor/core/containment.mjs +6 -12
- package/build-module/image-editor/core/containment.mjs.map +2 -2
- package/build-module/image-editor/core/interaction-controller.mjs +50 -8
- package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
- package/build-module/image-editor/core/state.mjs +5 -1
- package/build-module/image-editor/core/state.mjs.map +2 -2
- package/build-module/image-editor/core/transform-style.mjs.map +1 -1
- package/build-module/image-editor/core/viewport-state.mjs +24 -0
- package/build-module/image-editor/core/viewport-state.mjs.map +7 -0
- package/build-module/image-editor/react/components/cropper.mjs +195 -73
- package/build-module/image-editor/react/components/cropper.mjs.map +3 -3
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +5 -2
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +26 -5
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
- package/build-module/image-editor/react/components/viewport-provider.mjs +27 -0
- package/build-module/image-editor/react/components/viewport-provider.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +59 -7
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs +134 -9
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-interaction.mjs +26 -5
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs +29 -0
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +7 -0
- package/build-module/image-editor/react/visually-hidden-style.mjs +16 -0
- package/build-module/image-editor/react/visually-hidden-style.mjs.map +7 -0
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-style/style-rtl.css +254 -29
- package/build-style/style.css +254 -29
- package/build-types/components/media-editor/index.d.ts +34 -0
- package/build-types/components/media-editor/index.d.ts.map +1 -0
- package/build-types/components/media-editor-canvas/index.d.ts +10 -1
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts +6 -0
- package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -0
- package/build-types/components/media-editor-modal/index.d.ts +2 -2
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-provider/index.d.ts +1 -1
- package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
- package/build-types/components/media-editor-toolbar/index.d.ts +4 -1
- package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/index.d.ts +46 -0
- package/build-types/components/rotation-ruler/index.d.ts.map +1 -0
- package/build-types/components/rotation-ruler/stories/index.story.d.ts +14 -0
- package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +1 -0
- package/build-types/components/rotation-ruler/use-ruler-drag.d.ts +61 -0
- package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -0
- package/build-types/hooks/use-crop-gesture-handlers.d.ts +42 -0
- package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -0
- package/build-types/image-editor/core/constants.d.ts +9 -0
- package/build-types/image-editor/core/constants.d.ts.map +1 -1
- package/build-types/image-editor/core/containment.d.ts +11 -7
- package/build-types/image-editor/core/containment.d.ts.map +1 -1
- package/build-types/image-editor/core/interaction-controller.d.ts +14 -2
- package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
- package/build-types/image-editor/core/state.d.ts.map +1 -1
- package/build-types/image-editor/core/transform-style.d.ts +1 -1
- package/build-types/image-editor/core/types.d.ts +25 -0
- package/build-types/image-editor/core/types.d.ts.map +1 -1
- package/build-types/image-editor/core/viewport-state.d.ts +7 -0
- package/build-types/image-editor/core/viewport-state.d.ts.map +1 -0
- package/build-types/image-editor/react/components/cropper-provider.d.ts +1 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper.d.ts +2 -1
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +3 -13
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +1 -1
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +1 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
- package/build-types/image-editor/react/components/viewport-provider.d.ts +9 -0
- package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +29 -0
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +5 -2
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +19 -0
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -0
- package/build-types/image-editor/react/visually-hidden-style.d.ts +6 -0
- package/build-types/image-editor/react/visually-hidden-style.d.ts.map +1 -0
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +3 -3
- package/build-types/store/actions.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/components/media-editor/index.tsx +709 -0
- package/src/components/media-editor/style.scss +89 -0
- package/src/components/media-editor-canvas/index.tsx +24 -0
- package/src/components/media-editor-crop-panel/index.tsx +39 -27
- package/src/components/media-editor-crop-panel/test/index.tsx +109 -0
- package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +177 -0
- package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +53 -0
- package/src/components/media-editor-modal/index.tsx +49 -589
- package/src/components/media-editor-modal/style.scss +13 -112
- package/src/components/media-editor-toolbar/index.tsx +122 -63
- package/src/components/media-editor-toolbar/style.scss +39 -11
- package/src/components/media-form/index.tsx +5 -0
- package/src/components/rotation-ruler/README.md +37 -0
- package/src/components/rotation-ruler/index.tsx +266 -0
- package/src/components/rotation-ruler/stories/index.story.tsx +54 -0
- package/src/components/rotation-ruler/style.scss +147 -0
- package/src/components/rotation-ruler/test/index.tsx +109 -0
- package/src/components/rotation-ruler/use-ruler-drag.ts +230 -0
- package/src/hooks/use-crop-gesture-handlers.ts +54 -0
- package/src/image-editor/core/constants.ts +12 -0
- package/src/image-editor/core/containment.ts +16 -28
- package/src/image-editor/core/interaction-controller.ts +66 -10
- package/src/image-editor/core/state.ts +15 -8
- package/src/image-editor/core/test/camera.ts +15 -26
- package/src/image-editor/core/test/interaction-controller.ts +158 -7
- package/src/image-editor/core/test/state.ts +21 -1
- package/src/image-editor/core/transform-style.ts +1 -1
- package/src/image-editor/core/types.ts +16 -0
- package/src/image-editor/core/viewport-state.ts +33 -0
- package/src/image-editor/docs/architecture.md +1 -1
- package/src/image-editor/docs/recipes.md +2 -2
- package/src/image-editor/react/components/cropper.scss +28 -0
- package/src/image-editor/react/components/cropper.tsx +268 -72
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +12 -12
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +27 -8
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +29 -3
- package/src/image-editor/react/components/test/cropper.tsx +294 -5
- package/src/image-editor/react/components/viewport-provider.tsx +39 -0
- package/src/image-editor/react/hooks/test/use-aria-announcer.ts +81 -0
- package/src/image-editor/react/hooks/test/use-cropper-state.ts +286 -0
- package/src/image-editor/react/hooks/test/use-interaction.ts +1 -0
- package/src/image-editor/react/hooks/use-aria-announcer.ts +68 -7
- package/src/image-editor/react/hooks/use-cropper-state.ts +230 -11
- package/src/image-editor/react/hooks/use-interaction.ts +36 -6
- package/src/image-editor/react/hooks/use-viewport-state.ts +48 -0
- package/src/image-editor/react/visually-hidden-style.ts +15 -0
- package/src/private-apis.ts +2 -0
- package/src/style.scss +3 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,27 +6,21 @@ import {
|
|
|
6
6
|
useMemo,
|
|
7
7
|
useRef,
|
|
8
8
|
useEffect,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useId,
|
|
9
11
|
forwardRef
|
|
10
12
|
} from "@wordpress/element";
|
|
11
13
|
import { __ } from "@wordpress/i18n";
|
|
12
14
|
import { getImageFit } from "../../core/camera.mjs";
|
|
13
|
-
import {
|
|
15
|
+
import { getImageCropBounds } from "../../core/containment.mjs";
|
|
14
16
|
import { useInteraction } from "../hooks/use-interaction.mjs";
|
|
15
17
|
import { useTransformStyle } from "../hooks/use-transform-style.mjs";
|
|
16
18
|
import { useAriaAnnouncer } from "../hooks/use-aria-announcer.mjs";
|
|
17
19
|
import { RectangleStencil } from "./stencils/rectangle-stencil.mjs";
|
|
18
20
|
import { DimmingOverlay } from "./overlays/dimming-overlay.mjs";
|
|
19
21
|
import { GridOverlay } from "./overlays/grid-overlay.mjs";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='d3d6b4ac29']")) {
|
|
23
|
-
const style = document.createElement("style");
|
|
24
|
-
style.setAttribute("data-wp-hash", "d3d6b4ac29");
|
|
25
|
-
style.appendChild(document.createTextNode('.wp-media-editor-image-editor{cursor:grab;height:100%;overflow:hidden;position:relative;touch-action:none;user-select:none;width:100%}.wp-media-editor-image-editor__canvas{inset:22px;position:absolute}.wp-media-editor-image-editor--dragging{cursor:grabbing}.wp-media-editor-image-editor__image{left:0;position:absolute;top:0;transform-origin:center center;will-change:transform}.wp-media-editor-image-editor__stencil{pointer-events:none;position:absolute}.wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px #000000b3;pointer-events:none;position:absolute;transition:box-shadow .15s ease}.wp-media-editor-image-editor--dragging .wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px #00000080}.wp-media-editor-image-editor__grid{overflow:hidden;pointer-events:none;position:absolute;transition:opacity .15s ease}.wp-media-editor-image-editor__canvas--grid-interactive .wp-media-editor-image-editor__grid{opacity:0;transition-delay:.1s}.wp-media-editor-image-editor__canvas--show-grid .wp-media-editor-image-editor__grid{opacity:1;transition-delay:0s}.wp-media-editor-image-editor__grid-line{background:#fff6;position:absolute}.wp-media-editor-image-editor__grid-line--horizontal{height:1px;left:0;width:100%}.wp-media-editor-image-editor__grid-line--vertical{height:100%;top:0;width:1px}.wp-media-editor-image-editor__stencil-rect{border:1px solid #ffffffb3;box-sizing:border-box;pointer-events:none;position:absolute}.wp-media-editor-image-editor__handle{appearance:none;background:#fff9;border:1px solid #ffffffe6;border-radius:50%;box-sizing:border-box;cursor:default;font:inherit;height:12px;margin:0;padding:0;pointer-events:auto;position:absolute;transition:background-color .15s ease,box-shadow .15s ease;width:12px}.wp-media-editor-image-editor__handle:focus{outline:none}.wp-media-editor-image-editor__handle:focus-visible{background:var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba));border-color:#0000;box-shadow:0 0 0 2px #fff,0 0 0 4px var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba))}.wp-media-editor-image-editor__handle:before{content:"";height:44px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:44px}.wp-media-editor-image-editor__handle--n{cursor:ns-resize;left:50%;margin-left:-6px;top:-6px}.wp-media-editor-image-editor__handle--s{bottom:-6px;cursor:ns-resize;left:50%;margin-left:-6px}.wp-media-editor-image-editor__handle--e{cursor:ew-resize;margin-top:-6px;right:-6px;top:50%}.wp-media-editor-image-editor__handle--w{cursor:ew-resize;left:-6px;margin-top:-6px;top:50%}.wp-media-editor-image-editor__handle--nw{cursor:nwse-resize;left:-6px;top:-6px}.wp-media-editor-image-editor__handle--ne{cursor:nesw-resize;right:-6px;top:-6px}.wp-media-editor-image-editor__handle--sw{bottom:-6px;cursor:nesw-resize;left:-6px}.wp-media-editor-image-editor__handle--se{bottom:-6px;cursor:nwse-resize;right:-6px}'));
|
|
26
|
-
document.head.appendChild(style);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// packages/media-editor/src/image-editor/react/components/cropper.tsx
|
|
22
|
+
import { ViewportProvider, useViewport } from "./viewport-provider.mjs";
|
|
23
|
+
import { VISUALLY_HIDDEN_STYLE } from "../visually-hidden-style.mjs";
|
|
30
24
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
25
|
var CROP_RECT_EPSILON = 1e-6;
|
|
32
26
|
function computeInscribedRect(aspectRatio, visualSize) {
|
|
@@ -58,6 +52,7 @@ function CropperInner({
|
|
|
58
52
|
maxZoom,
|
|
59
53
|
aspectRatio,
|
|
60
54
|
freeformCrop = false,
|
|
55
|
+
focusOnMount = false,
|
|
61
56
|
onImageLoaded,
|
|
62
57
|
onStateChange,
|
|
63
58
|
onGestureStart,
|
|
@@ -65,11 +60,44 @@ function CropperInner({
|
|
|
65
60
|
className
|
|
66
61
|
}, ref) {
|
|
67
62
|
const { state, setImage, setCropRect, settleCrop } = controller;
|
|
63
|
+
const {
|
|
64
|
+
viewport: viewportState,
|
|
65
|
+
setViewportPan,
|
|
66
|
+
resetViewport
|
|
67
|
+
} = useViewport();
|
|
68
68
|
const canvasRef = useRef(null);
|
|
69
|
+
const cropAreaDescriptionId = useId();
|
|
70
|
+
const [isCropAreaFocused, setIsCropAreaFocused] = useState(focusOnMount);
|
|
71
|
+
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
69
72
|
const [canvasSize, setCanvasSize] = useState({
|
|
70
73
|
width: 0,
|
|
71
74
|
height: 0
|
|
72
75
|
});
|
|
76
|
+
useLayoutEffect(() => {
|
|
77
|
+
if (focusOnMount) {
|
|
78
|
+
canvasRef.current?.focus({ preventScroll: true });
|
|
79
|
+
}
|
|
80
|
+
}, [focusOnMount]);
|
|
81
|
+
const handleCropAreaFocus = useCallback(
|
|
82
|
+
(event) => {
|
|
83
|
+
if (event.target === event.currentTarget) {
|
|
84
|
+
setIsCropAreaFocused(true);
|
|
85
|
+
if (event.relatedTarget !== null && event.currentTarget.matches(":focus-visible")) {
|
|
86
|
+
setIsFocusVisible(true);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
[]
|
|
91
|
+
);
|
|
92
|
+
const handleCropAreaBlur = useCallback(
|
|
93
|
+
(event) => {
|
|
94
|
+
if (event.target === event.currentTarget) {
|
|
95
|
+
setIsCropAreaFocused(false);
|
|
96
|
+
setIsFocusVisible(false);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
[]
|
|
100
|
+
);
|
|
73
101
|
useEffect(() => {
|
|
74
102
|
const element = canvasRef.current;
|
|
75
103
|
if (!element) {
|
|
@@ -106,7 +134,7 @@ function CropperInner({
|
|
|
106
134
|
[canvasSize, naturalWidth, naturalHeight, state.rotation]
|
|
107
135
|
);
|
|
108
136
|
useEffect(() => {
|
|
109
|
-
if (freeformCrop || visualSize.width === 0 || visualSize.height === 0) {
|
|
137
|
+
if (freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) {
|
|
110
138
|
return;
|
|
111
139
|
}
|
|
112
140
|
const rect = computeInscribedRect(aspectRatio, visualSize);
|
|
@@ -131,8 +159,11 @@ function CropperInner({
|
|
|
131
159
|
if (!state.image || elementSize.width === 0) {
|
|
132
160
|
return void 0;
|
|
133
161
|
}
|
|
134
|
-
return
|
|
135
|
-
}, [state, elementSize, visualSize
|
|
162
|
+
return getImageCropBounds(state, elementSize, visualSize);
|
|
163
|
+
}, [state, elementSize, visualSize]);
|
|
164
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
165
|
+
const isResizingRef = useRef(false);
|
|
166
|
+
const isSettlingRef = useRef(false);
|
|
136
167
|
const {
|
|
137
168
|
handlers,
|
|
138
169
|
onWheelNative,
|
|
@@ -145,16 +176,36 @@ function CropperInner({
|
|
|
145
176
|
onGestureStart,
|
|
146
177
|
onGestureEnd
|
|
147
178
|
});
|
|
179
|
+
const canvasHandlers = {
|
|
180
|
+
...handlers,
|
|
181
|
+
onPointerDown: (event) => {
|
|
182
|
+
handlers.onPointerDown?.(event);
|
|
183
|
+
setIsFocusVisible(false);
|
|
184
|
+
},
|
|
185
|
+
onKeyDown: (event) => {
|
|
186
|
+
if (event.target === event.currentTarget && !["Shift", "Control", "Alt", "Meta"].includes(event.key)) {
|
|
187
|
+
setIsFocusVisible(true);
|
|
188
|
+
}
|
|
189
|
+
handlers.onKeyDown?.(event);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
148
192
|
useEffect(() => {
|
|
149
193
|
const el = canvasRef.current;
|
|
150
194
|
if (!el) {
|
|
151
195
|
return;
|
|
152
196
|
}
|
|
153
|
-
|
|
197
|
+
const handleWheel = (event) => {
|
|
198
|
+
if (isResizingRef.current || isSettlingRef.current) {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
onWheelNative(event);
|
|
203
|
+
};
|
|
204
|
+
el.addEventListener("wheel", handleWheel, {
|
|
154
205
|
passive: false
|
|
155
206
|
});
|
|
156
207
|
return () => {
|
|
157
|
-
el.removeEventListener("wheel",
|
|
208
|
+
el.removeEventListener("wheel", handleWheel);
|
|
158
209
|
};
|
|
159
210
|
}, [onWheelNative]);
|
|
160
211
|
const transformString = useTransformStyle(state, visualSize);
|
|
@@ -177,8 +228,32 @@ function CropperInner({
|
|
|
177
228
|
const handleCropChange = useCallback(
|
|
178
229
|
(rect) => {
|
|
179
230
|
setCropRect(rect);
|
|
231
|
+
if (isResizingRef.current && visualSize.width > 0 && visualSize.height > 0) {
|
|
232
|
+
const offsetX = (canvasSize.width - visualSize.width) / 2;
|
|
233
|
+
const offsetY = (canvasSize.height - visualSize.height) / 2;
|
|
234
|
+
const rightOverflow = Math.max(
|
|
235
|
+
0,
|
|
236
|
+
offsetX + (rect.x + rect.width) * visualSize.width - canvasSize.width
|
|
237
|
+
);
|
|
238
|
+
const leftOverflow = Math.max(
|
|
239
|
+
0,
|
|
240
|
+
-(offsetX + rect.x * visualSize.width)
|
|
241
|
+
);
|
|
242
|
+
const bottomOverflow = Math.max(
|
|
243
|
+
0,
|
|
244
|
+
offsetY + (rect.y + rect.height) * visualSize.height - canvasSize.height
|
|
245
|
+
);
|
|
246
|
+
const topOverflow = Math.max(
|
|
247
|
+
0,
|
|
248
|
+
-(offsetY + rect.y * visualSize.height)
|
|
249
|
+
);
|
|
250
|
+
setViewportPan({
|
|
251
|
+
x: -rightOverflow + leftOverflow,
|
|
252
|
+
y: -bottomOverflow + topOverflow
|
|
253
|
+
});
|
|
254
|
+
}
|
|
180
255
|
},
|
|
181
|
-
[setCropRect]
|
|
256
|
+
[setCropRect, setViewportPan, canvasSize, visualSize]
|
|
182
257
|
);
|
|
183
258
|
const [settling, setSettling] = useState(false);
|
|
184
259
|
const settleTimerRef = useRef();
|
|
@@ -187,28 +262,42 @@ function CropperInner({
|
|
|
187
262
|
clearTimeout(settleTimerRef.current);
|
|
188
263
|
};
|
|
189
264
|
}, []);
|
|
190
|
-
const [isResizing, setIsResizing] = useState(false);
|
|
191
265
|
const isInteractiveGrid = showGrid === "interactive";
|
|
192
266
|
const showInteractiveGrid = isInteractiveGrid && (isInteractionPlacementActive || isResizing || isPlacementActive);
|
|
193
267
|
const handleEscape = useCallback(() => {
|
|
268
|
+
setIsFocusVisible(true);
|
|
194
269
|
canvasRef.current?.focus({ preventScroll: true });
|
|
195
270
|
}, []);
|
|
196
271
|
const handleResizeStart = useCallback(() => {
|
|
272
|
+
isResizingRef.current = true;
|
|
197
273
|
setIsResizing(true);
|
|
274
|
+
clearTimeout(settleTimerRef.current);
|
|
275
|
+
isSettlingRef.current = false;
|
|
276
|
+
setSettling(false);
|
|
277
|
+
resetViewport();
|
|
198
278
|
onGestureStart?.();
|
|
199
|
-
}, [onGestureStart]);
|
|
279
|
+
}, [onGestureStart, resetViewport]);
|
|
200
280
|
const handleResizeEnd = useCallback(() => {
|
|
281
|
+
isResizingRef.current = false;
|
|
201
282
|
setIsResizing(false);
|
|
283
|
+
isSettlingRef.current = true;
|
|
202
284
|
setSettling(true);
|
|
285
|
+
resetViewport();
|
|
203
286
|
settleCrop();
|
|
204
287
|
onGestureEnd?.();
|
|
205
288
|
clearTimeout(settleTimerRef.current);
|
|
206
289
|
settleTimerRef.current = setTimeout(() => {
|
|
290
|
+
isSettlingRef.current = false;
|
|
207
291
|
setSettling(false);
|
|
208
292
|
}, 200);
|
|
209
|
-
}, [settleCrop, onGestureEnd]);
|
|
210
|
-
|
|
211
|
-
|
|
293
|
+
}, [settleCrop, onGestureEnd, resetViewport]);
|
|
294
|
+
let imageTransition;
|
|
295
|
+
if (settling) {
|
|
296
|
+
imageTransition = "transform 200ms ease-out";
|
|
297
|
+
} else if (isZooming) {
|
|
298
|
+
imageTransition = "transform 150ms linear";
|
|
299
|
+
}
|
|
300
|
+
const settleStencilTransition = settling ? "left 200ms ease-out, top 200ms ease-out, width 200ms ease-out, height 200ms ease-out" : void 0;
|
|
212
301
|
const imageStyle = useMemo(() => {
|
|
213
302
|
if (elementSize.width === 0 || elementSize.height === 0) {
|
|
214
303
|
return {};
|
|
@@ -226,6 +315,18 @@ function CropperInner({
|
|
|
226
315
|
transition: imageTransition
|
|
227
316
|
};
|
|
228
317
|
}, [canvasSize, elementSize, transformString, imageTransition]);
|
|
318
|
+
const settleTransition = settling ? "transform 200ms ease-out" : void 0;
|
|
319
|
+
const willChange = isResizing || settling ? "transform" : void 0;
|
|
320
|
+
let stageStyle;
|
|
321
|
+
if (viewportState.pan.x !== 0 || viewportState.pan.y !== 0) {
|
|
322
|
+
stageStyle = {
|
|
323
|
+
transform: `translate(${viewportState.pan.x}px, ${viewportState.pan.y}px)`,
|
|
324
|
+
transition: settleTransition,
|
|
325
|
+
willChange
|
|
326
|
+
};
|
|
327
|
+
} else if (settling) {
|
|
328
|
+
stageStyle = { transition: settleTransition, willChange };
|
|
329
|
+
}
|
|
229
330
|
const setContainerRef = useCallback(
|
|
230
331
|
(element) => {
|
|
231
332
|
if (typeof ref === "function") {
|
|
@@ -252,54 +353,82 @@ function CropperInner({
|
|
|
252
353
|
className: clsx(
|
|
253
354
|
"wp-media-editor-image-editor__canvas",
|
|
254
355
|
isInteractiveGrid && "wp-media-editor-image-editor__canvas--grid-interactive",
|
|
255
|
-
showInteractiveGrid && "wp-media-editor-image-editor__canvas--show-grid"
|
|
356
|
+
showInteractiveGrid && "wp-media-editor-image-editor__canvas--show-grid",
|
|
357
|
+
settling && "wp-media-editor-image-editor__canvas--settling",
|
|
358
|
+
// Show the keyboard focus outline only when the canvas
|
|
359
|
+
// itself (not a child handle) has keyboard focus.
|
|
360
|
+
isFocusVisible && isCropAreaFocused && "wp-media-editor-image-editor__canvas--focus-visible"
|
|
256
361
|
),
|
|
257
362
|
tabIndex: 0,
|
|
258
363
|
role: "group",
|
|
259
|
-
"aria-label": __("
|
|
260
|
-
|
|
364
|
+
"aria-label": __("Crop area"),
|
|
365
|
+
"aria-describedby": isCropAreaFocused ? cropAreaDescriptionId : void 0,
|
|
366
|
+
onFocus: handleCropAreaFocus,
|
|
367
|
+
onBlur: handleCropAreaBlur,
|
|
368
|
+
...canvasHandlers,
|
|
261
369
|
children: [
|
|
262
370
|
/* @__PURE__ */ jsx(
|
|
263
|
-
"
|
|
264
|
-
{
|
|
265
|
-
className: "wp-media-editor-image-editor__image",
|
|
266
|
-
src,
|
|
267
|
-
alt: "",
|
|
268
|
-
onLoad: handleImageLoad,
|
|
269
|
-
style: imageStyle,
|
|
270
|
-
draggable: false
|
|
271
|
-
}
|
|
272
|
-
),
|
|
273
|
-
showDimming && /* @__PURE__ */ jsx(
|
|
274
|
-
DimmingOverlay,
|
|
275
|
-
{
|
|
276
|
-
cropRect: state.cropRect,
|
|
277
|
-
containerSize: canvasSize,
|
|
278
|
-
imageSize: visualSize
|
|
279
|
-
}
|
|
280
|
-
),
|
|
281
|
-
/* @__PURE__ */ jsx(
|
|
282
|
-
StencilComponent,
|
|
371
|
+
"div",
|
|
283
372
|
{
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
onResizeEnd: handleResizeEnd,
|
|
290
|
-
onEscape: handleEscape,
|
|
291
|
-
aspectRatio,
|
|
292
|
-
freeformCrop,
|
|
293
|
-
stencilTransition: settleStencilTransition,
|
|
294
|
-
cropBounds
|
|
373
|
+
id: cropAreaDescriptionId,
|
|
374
|
+
style: VISUALLY_HIDDEN_STYLE,
|
|
375
|
+
children: __(
|
|
376
|
+
"When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls."
|
|
377
|
+
)
|
|
295
378
|
}
|
|
296
379
|
),
|
|
297
|
-
|
|
298
|
-
|
|
380
|
+
/* @__PURE__ */ jsxs(
|
|
381
|
+
"div",
|
|
299
382
|
{
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
383
|
+
className: "wp-media-editor-image-editor__stage",
|
|
384
|
+
"data-testid": "cropper-stage",
|
|
385
|
+
style: stageStyle,
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsx(
|
|
388
|
+
"img",
|
|
389
|
+
{
|
|
390
|
+
className: "wp-media-editor-image-editor__image",
|
|
391
|
+
src,
|
|
392
|
+
alt: "",
|
|
393
|
+
onLoad: handleImageLoad,
|
|
394
|
+
style: imageStyle,
|
|
395
|
+
draggable: false
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
showDimming && /* @__PURE__ */ jsx(
|
|
399
|
+
DimmingOverlay,
|
|
400
|
+
{
|
|
401
|
+
cropRect: state.cropRect,
|
|
402
|
+
containerSize: canvasSize,
|
|
403
|
+
imageSize: visualSize,
|
|
404
|
+
transition: settleStencilTransition
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ jsx(
|
|
408
|
+
StencilComponent,
|
|
409
|
+
{
|
|
410
|
+
cropRect: state.cropRect,
|
|
411
|
+
containerSize: canvasSize,
|
|
412
|
+
imageSize: visualSize,
|
|
413
|
+
onCropChange: handleCropChange,
|
|
414
|
+
onResizeStart: handleResizeStart,
|
|
415
|
+
onResizeEnd: handleResizeEnd,
|
|
416
|
+
onEscape: handleEscape,
|
|
417
|
+
aspectRatio,
|
|
418
|
+
freeformCrop,
|
|
419
|
+
stencilTransition: settleStencilTransition,
|
|
420
|
+
cropBounds
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
(showGrid === true || isInteractiveGrid) && /* @__PURE__ */ jsx(
|
|
424
|
+
GridOverlay,
|
|
425
|
+
{
|
|
426
|
+
cropRect: state.cropRect,
|
|
427
|
+
containerSize: canvasSize,
|
|
428
|
+
imageSize: visualSize
|
|
429
|
+
}
|
|
430
|
+
)
|
|
431
|
+
]
|
|
303
432
|
}
|
|
304
433
|
),
|
|
305
434
|
/* @__PURE__ */ jsx(
|
|
@@ -308,17 +437,7 @@ function CropperInner({
|
|
|
308
437
|
"aria-live": "polite",
|
|
309
438
|
"aria-atomic": "true",
|
|
310
439
|
className: "wp-media-editor-image-editor__aria-live",
|
|
311
|
-
style:
|
|
312
|
-
position: "absolute",
|
|
313
|
-
width: 1,
|
|
314
|
-
height: 1,
|
|
315
|
-
padding: 0,
|
|
316
|
-
margin: -1,
|
|
317
|
-
overflow: "hidden",
|
|
318
|
-
clip: "rect(0, 0, 0, 0)",
|
|
319
|
-
whiteSpace: "nowrap",
|
|
320
|
-
border: 0
|
|
321
|
-
},
|
|
440
|
+
style: VISUALLY_HIDDEN_STYLE,
|
|
322
441
|
children: ariaMessage
|
|
323
442
|
}
|
|
324
443
|
)
|
|
@@ -328,9 +447,12 @@ function CropperInner({
|
|
|
328
447
|
}
|
|
329
448
|
);
|
|
330
449
|
}
|
|
331
|
-
var
|
|
450
|
+
var CropperInnerWithRef = forwardRef(
|
|
332
451
|
CropperInner
|
|
333
452
|
);
|
|
453
|
+
var Cropper = forwardRef(
|
|
454
|
+
(props, ref) => /* @__PURE__ */ jsx(ViewportProvider, { children: /* @__PURE__ */ jsx(CropperInnerWithRef, { ...props, ref }) })
|
|
455
|
+
);
|
|
334
456
|
export {
|
|
335
457
|
Cropper
|
|
336
458
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/image-editor/react/components/cropper.tsx"
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCropperState,\n\tStencilProps,\n\tSize,\n\tNormalizedRect,\n} from '../../core/types';\nimport type { UseCropperStateReturn } from '../hooks/use-cropper-state';\nimport { getImageFit } from '../../core/camera';\nimport { getCropBounds } from '../../core/containment';\nimport { useInteraction } from '../hooks/use-interaction';\nimport { useTransformStyle } from '../hooks/use-transform-style';\nimport { useAriaAnnouncer } from '../hooks/use-aria-announcer';\nimport { RectangleStencil } from './stencils/rectangle-stencil';\nimport { DimmingOverlay } from './overlays/dimming-overlay';\nimport { GridOverlay } from './overlays/grid-overlay';\nimport './cropper.scss';\n\n/** Threshold for comparing normalized crop rect values. */\nconst CROP_RECT_EPSILON = 1e-6;\n\n// Largest rect of the given pixel aspect ratio that fits inside the visual\n// bounds, centered in [0,1] \u00D7 [0,1] normalized space. Returns a full-frame\n// rect (1\u00D71) if `aspectRatio` is unset or non-positive.\nfunction computeInscribedRect(\n\taspectRatio: number | undefined,\n\tvisualSize: Size\n): NormalizedRect {\n\tlet w = 1;\n\tlet h = 1;\n\tif ( aspectRatio && aspectRatio > 0 && visualSize.width > 0 ) {\n\t\t// normalizedRatio = w/h in normalized space that produces the\n\t\t// desired pixel aspect ratio.\n\t\t// pixelW = w * visualW, pixelH = h * visualH\n\t\t// pixelW / pixelH = aspectRatio\n\t\t// => w / h = aspectRatio * visualH / visualW\n\t\tconst normalizedRatio =\n\t\t\t( aspectRatio * visualSize.height ) / visualSize.width;\n\t\tif ( normalizedRatio <= 1 ) {\n\t\t\tw = normalizedRatio;\n\t\t} else {\n\t\t\th = 1 / normalizedRatio;\n\t\t}\n\t}\n\treturn {\n\t\tx: ( 1 - w ) / 2,\n\t\ty: ( 1 - h ) / 2,\n\t\twidth: w,\n\t\theight: h,\n\t};\n}\n\n/**\n * Props for the Cropper component.\n */\nexport interface CropperProps {\n\t/** Image source URL. */\n\tsrc: string;\n\t/** The full state/setter object from `useCropperState`. */\n\tcontroller: UseCropperStateReturn;\n\t/** Stencil component for the crop area. Defaults to RectangleStencil. */\n\tstencil?: React.ComponentType< StencilProps >;\n\t/** Show the rule-of-thirds grid overlay, or only during interactions. */\n\tshowGrid?: boolean | 'interactive';\n\t/** Whether external placement activity should keep the grid visible. */\n\tisPlacementActive?: boolean;\n\t/** Show the dimming overlay outside the crop area. */\n\tshowDimming?: boolean;\n\t/** Minimum zoom level. */\n\tminZoom?: number;\n\t/** Maximum zoom level. */\n\tmaxZoom?: number;\n\t/** Fixed aspect ratio (width / height) in pixel space for the crop area. */\n\taspectRatio?: number;\n\t/**\n\t * Enable freeform crop mode with resizable handles.\n\t * When false (default), the crop area is fixed and centered.\n\t * When true, the crop area has resize handles and can be freely repositioned.\n\t */\n\tfreeformCrop?: boolean;\n\t/** Callback fired when the image is loaded. */\n\tonImageLoaded?: ( size: Size ) => void;\n\t/**\n\t * Callback fired on every state change. Fires at pointermove rate\n\t * during drags, so keep the handler light \u2014 no heavy work, no\n\t * expensive parent re-renders. For commit-style events (drag end,\n\t * settled crop), use `onGestureEnd` instead.\n\t *\n\t * Useful for lightweight syncing with external tools, analytics,\n\t * or AI agents. Receives the full state so consumers can derive\n\t * whatever they need.\n\t */\n\tonStateChange?: ( state: CropperState ) => void;\n\t/** Fires when a continuous gesture begins (pan drag, handle resize, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointerup, resize settle). */\n\tonGestureEnd?: () => void;\n\t/** Additional className for the container. */\n\tclassName?: string;\n}\n\n/**\n * The main image cropper component.\n *\n * Renders an image within a container with interactive crop overlays.\n * Creates the camera once per render via getImageFit, then passes\n * derived values to stencil, overlays, and interaction hooks.\n *\n * The component fills its parent container (100% width and height).\n * Wrap it in a sized container to control its dimensions.\n *\n * @param root0 Component props implementing CropperProps.\n * @param root0.src Image source URL.\n * @param root0.controller The full state/setter object from `useCropperState`.\n * @param root0.stencil Custom stencil component.\n * @param root0.showGrid Grid overlay mode: false | true | 'interactive'.\n * @param root0.isPlacementActive Keep grid visible during external placement activity.\n * @param root0.showDimming Show dimming overlay outside crop.\n * @param root0.minZoom Minimum zoom level.\n * @param root0.maxZoom Maximum zoom level.\n * @param root0.aspectRatio Fixed aspect ratio (width/height).\n * @param root0.freeformCrop Enable resize handles.\n * @param root0.onImageLoaded Image load callback.\n * @param root0.onStateChange Every-frame state callback.\n * @param root0.onGestureStart Gesture boundary start.\n * @param root0.onGestureEnd Gesture boundary end.\n * @param root0.className Additional CSS class.\n * @param ref Forwarded ref for the container div.\n */\nfunction CropperInner(\n\t{\n\t\tsrc,\n\t\tcontroller,\n\t\tstencil: StencilComponent = RectangleStencil,\n\t\tshowGrid = false,\n\t\tisPlacementActive = false,\n\t\tshowDimming = true,\n\t\tminZoom,\n\t\tmaxZoom,\n\t\taspectRatio,\n\t\tfreeformCrop = false,\n\t\tonImageLoaded,\n\t\tonStateChange,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t\tclassName,\n\t}: CropperProps,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst { state, setImage, setCropRect, settleCrop } = controller;\n\t// Canvas measurement via ResizeObserver. The canvas is the inner\n\t// positioning context for image/stencil/handles \u2014 inset from the root\n\t// by the handle gutter, so crop math operates on the reduced box.\n\tconst canvasRef = useRef< HTMLDivElement >( null );\n\tconst [ canvasSize, setCanvasSize ] = useState< Size >( {\n\t\twidth: 0,\n\t\theight: 0,\n\t} );\n\n\tuseEffect( () => {\n\t\tconst element = canvasRef.current;\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new ResizeObserver( ( entries ) => {\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst { width, height } = entry.contentRect;\n\t\t\t\tsetCanvasSize( ( prev ) => {\n\t\t\t\t\tif ( prev.width === width && prev.height === height ) {\n\t\t\t\t\t\treturn prev;\n\t\t\t\t\t}\n\t\t\t\t\treturn { width, height };\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t\tobserver.observe( element );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [] );\n\n\t// Notify consumer of state changes.\n\tuseEffect( () => {\n\t\tonStateChange?.( state );\n\t}, [ state, onStateChange ] );\n\n\t// ARIA live region: announce significant state changes for screen readers.\n\tconst ariaMessage = useAriaAnnouncer( state );\n\n\t// Compute fitted image dimensions and visual bounds from camera math.\n\tconst naturalWidth = state.image?.naturalWidth ?? 0;\n\tconst naturalHeight = state.image?.naturalHeight ?? 0;\n\tconst { elementSize, visualSize } = useMemo(\n\t\t() =>\n\t\t\tgetImageFit(\n\t\t\t\tcanvasSize,\n\t\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\t\tstate.rotation\n\t\t\t),\n\t\t[ canvasSize, naturalWidth, naturalHeight, state.rotation ]\n\t);\n\n\t// In fixed-crop mode, auto-size the crop rect to fill the visual area\n\t// while respecting the aspect ratio. The crop is always centered.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfreeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetCropRect( rect );\n\t}, [ freeformCrop, aspectRatio, visualSize, setCropRect, state.cropRect ] );\n\n\t// In freeform mode, when aspectRatio changes, reshape the crop to the\n\t// largest inscribed rect of the new ratio.\n\tconst prevAspectRatioRef = useRef( aspectRatio );\n\tuseEffect( () => {\n\t\tif ( prevAspectRatioRef.current === aspectRatio ) {\n\t\t\treturn;\n\t\t}\n\t\tprevAspectRatioRef.current = aspectRatio;\n\n\t\tif (\n\t\t\t! freeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetCropRect( computeInscribedRect( aspectRatio, visualSize ) );\n\t}, [ aspectRatio, freeformCrop, visualSize, setCropRect ] );\n\n\t// Compute the crop handle bounds from the actual image footprint.\n\t// Depends on the full state object because getCropBounds reads\n\t// crop, zoom, rotation, flip, and image. React Compiler requires\n\t// the complete dependency; the computation is lightweight (a few\n\t// trig ops + 4 corner transforms).\n\tconst cropBounds = useMemo( () => {\n\t\tif ( ! state.image || elementSize.width === 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getCropBounds( state, elementSize, visualSize, canvasSize );\n\t}, [ state, elementSize, visualSize, canvasSize ] );\n\n\t// Use the interaction hook for mouse, touch, and keyboard events.\n\tconst {\n\t\thandlers,\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isInteractionPlacementActive,\n\t} = useInteraction( state, controller, canvasSize, visualSize, {\n\t\tminZoom,\n\t\tmaxZoom,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t} );\n\n\t// Register wheel handler natively with { passive: false } so\n\t// preventDefault works. React's onWheel registers as passive. Bound\n\t// to the canvas (not the root) so pointer geometry inside the handler\n\t// resolves against the canvas box.\n\tuseEffect( () => {\n\t\tconst el = canvasRef.current;\n\t\tif ( ! el ) {\n\t\t\treturn;\n\t\t}\n\t\tel.addEventListener( 'wheel', onWheelNative, {\n\t\t\tpassive: false,\n\t\t} );\n\t\treturn () => {\n\t\t\tel.removeEventListener( 'wheel', onWheelNative );\n\t\t};\n\t}, [ onWheelNative ] );\n\n\t// Use the transform style hook for the image CSS transform.\n\tconst transformString = useTransformStyle( state, visualSize );\n\n\t/**\n\t * Handle the image load event.\n\t */\n\tconst handleImageLoad = useCallback(\n\t\t( event: React.SyntheticEvent< HTMLImageElement > ) => {\n\t\t\tconst img = event.currentTarget;\n\t\t\tconst size: Size = {\n\t\t\t\twidth: img.naturalWidth,\n\t\t\t\theight: img.naturalHeight,\n\t\t\t};\n\n\t\t\tsetImage( {\n\t\t\t\tsrc,\n\t\t\t\tnaturalWidth: size.width,\n\t\t\t\tnaturalHeight: size.height,\n\t\t\t} );\n\n\t\t\tonImageLoaded?.( size );\n\t\t},\n\t\t[ src, setImage, onImageLoaded ]\n\t);\n\n\t/**\n\t * Handle crop rect changes from the stencil (during drag).\n\t */\n\tconst handleCropChange = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tsetCropRect( rect );\n\t\t},\n\t\t[ setCropRect ]\n\t);\n\n\t// Settling animation: brief linear transition after resize end.\n\tconst [ settling, setSettling ] = useState( false );\n\tconst settleTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\n\t// Clear the pending settle timer on unmount so it can't fire a\n\t// state update on an unmounted component.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( settleTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst isInteractiveGrid = showGrid === 'interactive';\n\tconst showInteractiveGrid =\n\t\tisInteractiveGrid &&\n\t\t( isInteractionPlacementActive || isResizing || isPlacementActive );\n\n\t/**\n\t * Handle Escape on a resize handle \u2014 return focus to the canvas so\n\t * arrow keys pan the image rather than resize.\n\t */\n\tconst handleEscape = useCallback( () => {\n\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t}, [] );\n\n\tconst handleResizeStart = useCallback( () => {\n\t\tsetIsResizing( true );\n\t\tonGestureStart?.();\n\t}, [ onGestureStart ] );\n\n\t/**\n\t * Handle resize end \u2014 settle the crop rect (re-center, fill height).\n\t */\n\tconst handleResizeEnd = useCallback( () => {\n\t\tsetIsResizing( false );\n\t\tsetSettling( true );\n\t\tsettleCrop();\n\t\tonGestureEnd?.();\n\t\tclearTimeout( settleTimerRef.current );\n\t\tsettleTimerRef.current = setTimeout( () => {\n\t\t\tsetSettling( false );\n\t\t}, 200 );\n\t}, [ settleCrop, onGestureEnd ] );\n\n\tconst imageTransition =\n\t\tsettling || isZooming ? 'transform 150ms linear' : undefined;\n\tconst settleStencilTransition = settling\n\t\t? 'left 150ms linear, top 150ms linear, width 150ms linear, height 150ms linear'\n\t\t: undefined;\n\n\t// Compute the image's CSS style.\n\tconst imageStyle = useMemo( (): React.CSSProperties => {\n\t\tif ( elementSize.width === 0 || elementSize.height === 0 ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst centerX = ( canvasSize.width - elementSize.width ) / 2;\n\t\tconst centerY = ( canvasSize.height - elementSize.height ) / 2;\n\t\treturn {\n\t\t\twidth: elementSize.width,\n\t\t\theight: elementSize.height,\n\t\t\tmaxWidth: elementSize.width,\n\t\t\tmaxHeight: elementSize.height,\n\t\t\tleft: centerX,\n\t\t\ttop: centerY,\n\t\t\ttransform: transformString,\n\t\t\ttransition: imageTransition,\n\t\t};\n\t}, [ canvasSize, elementSize, transformString, imageTransition ] );\n\n\t// Forward the root element to the consumer's ref.\n\tconst setContainerRef = useCallback(\n\t\t( element: HTMLDivElement | null ) => {\n\t\t\tif ( typeof ref === 'function' ) {\n\t\t\t\tref( element );\n\t\t\t} else if ( ref ) {\n\t\t\t\t(\n\t\t\t\t\tref as React.MutableRefObject< HTMLDivElement | null >\n\t\t\t\t ).current = element;\n\t\t\t}\n\t\t},\n\t\t[ ref ]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ setContainerRef }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-media-editor-image-editor',\n\t\t\t\tisDragging && 'wp-media-editor-image-editor--dragging',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t{ /*\n\t\t\t * The canvas is the interactive, inset surface. Handles and\n\t\t\t * the ARIA role/tabIndex live here so pointer geometry\n\t\t\t * (getBoundingClientRect on e.currentTarget) resolves against\n\t\t\t * the same box that crop math uses. The root stays as the\n\t\t\t * clipping shell for the dimming overlay's box-shadow.\n\t\t\t *\n\t\t\t * Not role=\"application\" \u2014 that disables the screen reader's\n\t\t\t * normal keyboard interception, too heavy-handed for a single\n\t\t\t * widget. Screen reader users get the ARIA live region below\n\t\t\t * as the announcement channel.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tref={ canvasRef }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-media-editor-image-editor__canvas',\n\t\t\t\t\tisInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--grid-interactive',\n\t\t\t\t\tshowInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--show-grid'\n\t\t\t\t) }\n\t\t\t\ttabIndex={ 0 }\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ __( 'Image editor' ) }\n\t\t\t\t{ ...handlers }\n\t\t\t>\n\t\t\t\t{ /* The image layer */ }\n\t\t\t\t<img\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__image\"\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tonLoad={ handleImageLoad }\n\t\t\t\t\tstyle={ imageStyle }\n\t\t\t\t\tdraggable={ false }\n\t\t\t\t/>\n\n\t\t\t\t{ /* Dimming overlay outside the crop area */ }\n\t\t\t\t{ showDimming && (\n\t\t\t\t\t<DimmingOverlay\n\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* The stencil (crop area with handles) */ }\n\t\t\t\t<StencilComponent\n\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\tonCropChange={ handleCropChange }\n\t\t\t\t\tonResizeStart={ handleResizeStart }\n\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\tonEscape={ handleEscape }\n\t\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\tstencilTransition={ settleStencilTransition }\n\t\t\t\t\tcropBounds={ cropBounds }\n\t\t\t\t/>\n\n\t\t\t\t{ /* Rule-of-thirds grid */ }\n\t\t\t\t{ ( showGrid === true || isInteractiveGrid ) && (\n\t\t\t\t\t<GridOverlay\n\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* ARIA live region for screen reader announcements */ }\n\t\t\t\t<div\n\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t\taria-atomic=\"true\"\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__aria-live\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\twidth: 1,\n\t\t\t\t\t\theight: 1,\n\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\tmargin: -1,\n\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\tclip: 'rect(0, 0, 0, 0)',\n\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\tborder: 0,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ ariaMessage }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport const Cropper = forwardRef< HTMLDivElement, CropperProps >(\n\tCropperInner\n);\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='d3d6b4ac29']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"d3d6b4ac29\");\n\tstyle.appendChild(document.createTextNode(\".wp-media-editor-image-editor{cursor:grab;height:100%;overflow:hidden;position:relative;touch-action:none;user-select:none;width:100%}.wp-media-editor-image-editor__canvas{inset:22px;position:absolute}.wp-media-editor-image-editor--dragging{cursor:grabbing}.wp-media-editor-image-editor__image{left:0;position:absolute;top:0;transform-origin:center center;will-change:transform}.wp-media-editor-image-editor__stencil{pointer-events:none;position:absolute}.wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px #000000b3;pointer-events:none;position:absolute;transition:box-shadow .15s ease}.wp-media-editor-image-editor--dragging .wp-media-editor-image-editor__dimming{box-shadow:0 0 0 9999px #00000080}.wp-media-editor-image-editor__grid{overflow:hidden;pointer-events:none;position:absolute;transition:opacity .15s ease}.wp-media-editor-image-editor__canvas--grid-interactive .wp-media-editor-image-editor__grid{opacity:0;transition-delay:.1s}.wp-media-editor-image-editor__canvas--show-grid .wp-media-editor-image-editor__grid{opacity:1;transition-delay:0s}.wp-media-editor-image-editor__grid-line{background:#fff6;position:absolute}.wp-media-editor-image-editor__grid-line--horizontal{height:1px;left:0;width:100%}.wp-media-editor-image-editor__grid-line--vertical{height:100%;top:0;width:1px}.wp-media-editor-image-editor__stencil-rect{border:1px solid #ffffffb3;box-sizing:border-box;pointer-events:none;position:absolute}.wp-media-editor-image-editor__handle{appearance:none;background:#fff9;border:1px solid #ffffffe6;border-radius:50%;box-sizing:border-box;cursor:default;font:inherit;height:12px;margin:0;padding:0;pointer-events:auto;position:absolute;transition:background-color .15s ease,box-shadow .15s ease;width:12px}.wp-media-editor-image-editor__handle:focus{outline:none}.wp-media-editor-image-editor__handle:focus-visible{background:var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba));border-color:#0000;box-shadow:0 0 0 2px #fff,0 0 0 4px var(--wp-image-editor-focus-color,var(--wp-admin-theme-color,#007cba))}.wp-media-editor-image-editor__handle:before{content:\\\"\\\";height:44px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:44px}.wp-media-editor-image-editor__handle--n{cursor:ns-resize;left:50%;margin-left:-6px;top:-6px}.wp-media-editor-image-editor__handle--s{bottom:-6px;cursor:ns-resize;left:50%;margin-left:-6px}.wp-media-editor-image-editor__handle--e{cursor:ew-resize;margin-top:-6px;right:-6px;top:50%}.wp-media-editor-image-editor__handle--w{cursor:ew-resize;left:-6px;margin-top:-6px;top:50%}.wp-media-editor-image-editor__handle--nw{cursor:nwse-resize;left:-6px;top:-6px}.wp-media-editor-image-editor__handle--ne{cursor:nesw-resize;right:-6px;top:-6px}.wp-media-editor-image-editor__handle--sw{bottom:-6px;cursor:nesw-resize;left:-6px}.wp-media-editor-image-editor__handle--se{bottom:-6px;cursor:nwse-resize;right:-6px}\"));\n\tdocument.head.appendChild(style);\n}\n"],
|
|
5
|
-
"mappings": ";AAIA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AAYnB,SAAS,mBAAmB;AAC5B,SAAS,
|
|
3
|
+
"sources": ["../../../../src/image-editor/react/components/cropper.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseId,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCropperState,\n\tStencilProps,\n\tSize,\n\tNormalizedRect,\n} from '../../core/types';\nimport type { UseCropperStateReturn } from '../hooks/use-cropper-state';\nimport { getImageFit } from '../../core/camera';\nimport { getImageCropBounds } from '../../core/containment';\nimport { useInteraction } from '../hooks/use-interaction';\nimport { useTransformStyle } from '../hooks/use-transform-style';\nimport { useAriaAnnouncer } from '../hooks/use-aria-announcer';\nimport { RectangleStencil } from './stencils/rectangle-stencil';\nimport { DimmingOverlay } from './overlays/dimming-overlay';\nimport { GridOverlay } from './overlays/grid-overlay';\nimport { ViewportProvider, useViewport } from './viewport-provider';\nimport { VISUALLY_HIDDEN_STYLE } from '../visually-hidden-style';\n\n/** Threshold for comparing normalized crop rect values. */\nconst CROP_RECT_EPSILON = 1e-6;\n\n// Largest rect of the given pixel aspect ratio that fits inside the visual\n// bounds, centered in [0,1] \u00D7 [0,1] normalized space. Returns a full-frame\n// rect (1\u00D71) if `aspectRatio` is unset or non-positive.\nfunction computeInscribedRect(\n\taspectRatio: number | undefined,\n\tvisualSize: Size\n): NormalizedRect {\n\tlet w = 1;\n\tlet h = 1;\n\tif ( aspectRatio && aspectRatio > 0 && visualSize.width > 0 ) {\n\t\t// normalizedRatio = w/h in normalized space that produces the\n\t\t// desired pixel aspect ratio.\n\t\t// pixelW = w * visualW, pixelH = h * visualH\n\t\t// pixelW / pixelH = aspectRatio\n\t\t// => w / h = aspectRatio * visualH / visualW\n\t\tconst normalizedRatio =\n\t\t\t( aspectRatio * visualSize.height ) / visualSize.width;\n\t\tif ( normalizedRatio <= 1 ) {\n\t\t\tw = normalizedRatio;\n\t\t} else {\n\t\t\th = 1 / normalizedRatio;\n\t\t}\n\t}\n\treturn {\n\t\tx: ( 1 - w ) / 2,\n\t\ty: ( 1 - h ) / 2,\n\t\twidth: w,\n\t\theight: h,\n\t};\n}\n\n/**\n * Props for the Cropper component.\n */\nexport interface CropperProps {\n\t/** Image source URL. */\n\tsrc: string;\n\t/** The full state/setter object from `useCropperState`. */\n\tcontroller: UseCropperStateReturn;\n\t/** Stencil component for the crop area. Defaults to RectangleStencil. */\n\tstencil?: React.ComponentType< StencilProps >;\n\t/** Show the rule-of-thirds grid overlay, or only during interactions. */\n\tshowGrid?: boolean | 'interactive';\n\t/** Whether external placement activity should keep the grid visible. */\n\tisPlacementActive?: boolean;\n\t/** Show the dimming overlay outside the crop area. */\n\tshowDimming?: boolean;\n\t/** Minimum zoom level. */\n\tminZoom?: number;\n\t/** Maximum zoom level. */\n\tmaxZoom?: number;\n\t/** Fixed aspect ratio (width / height) in pixel space for the crop area. */\n\taspectRatio?: number;\n\t/**\n\t * Enable freeform crop mode with resizable handles.\n\t * When false (default), the crop area is fixed and centered.\n\t * When true, the crop area has resize handles and can be freely repositioned.\n\t */\n\tfreeformCrop?: boolean;\n\t/** Focus the crop area when the cropper mounts. */\n\tfocusOnMount?: boolean;\n\t/** Callback fired when the image is loaded. */\n\tonImageLoaded?: ( size: Size ) => void;\n\t/**\n\t * Callback fired on every state change. Fires at pointermove rate\n\t * during drags, so keep the handler light \u2014 no heavy work, no\n\t * expensive parent re-renders. For commit-style events (drag end,\n\t * settled crop), use `onGestureEnd` instead.\n\t *\n\t * Useful for lightweight syncing with external tools, analytics,\n\t * or AI agents. Receives the full state so consumers can derive\n\t * whatever they need.\n\t */\n\tonStateChange?: ( state: CropperState ) => void;\n\t/** Fires when a continuous gesture begins (pan drag, handle resize, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointerup, resize settle). */\n\tonGestureEnd?: () => void;\n\t/** Additional className for the container. */\n\tclassName?: string;\n}\n\n/**\n * The main image cropper component.\n *\n * Renders an image within a container with interactive crop overlays.\n * Creates the camera once per render via getImageFit, then passes\n * derived values to stencil, overlays, and interaction hooks.\n *\n * The component fills its parent container (100% width and height).\n * Wrap it in a sized container to control its dimensions.\n *\n * @param root0 Component props implementing CropperProps.\n * @param root0.src Image source URL.\n * @param root0.controller The full state/setter object from `useCropperState`.\n * @param root0.stencil Custom stencil component.\n * @param root0.showGrid Grid overlay mode: false | true | 'interactive'.\n * @param root0.isPlacementActive Keep grid visible during external placement activity.\n * @param root0.showDimming Show dimming overlay outside crop.\n * @param root0.minZoom Minimum zoom level.\n * @param root0.maxZoom Maximum zoom level.\n * @param root0.aspectRatio Fixed aspect ratio (width/height).\n * @param root0.freeformCrop Enable resize handles.\n * @param root0.focusOnMount Focus the crop area on mount.\n * @param root0.onImageLoaded Image load callback.\n * @param root0.onStateChange Every-frame state callback.\n * @param root0.onGestureStart Gesture boundary start.\n * @param root0.onGestureEnd Gesture boundary end.\n * @param root0.className Additional CSS class.\n * @param ref Forwarded ref for the container div.\n */\nfunction CropperInner(\n\t{\n\t\tsrc,\n\t\tcontroller,\n\t\tstencil: StencilComponent = RectangleStencil,\n\t\tshowGrid = false,\n\t\tisPlacementActive = false,\n\t\tshowDimming = true,\n\t\tminZoom,\n\t\tmaxZoom,\n\t\taspectRatio,\n\t\tfreeformCrop = false,\n\t\tfocusOnMount = false,\n\t\tonImageLoaded,\n\t\tonStateChange,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t\tclassName,\n\t}: CropperProps,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst { state, setImage, setCropRect, settleCrop } = controller;\n\tconst {\n\t\tviewport: viewportState,\n\t\tsetViewportPan,\n\t\tresetViewport,\n\t} = useViewport();\n\t// Canvas measurement via ResizeObserver. The canvas is the inner\n\t// positioning context for image/stencil/handles \u2014 inset from the root\n\t// by the handle gutter, so crop math operates on the reduced box.\n\tconst canvasRef = useRef< HTMLDivElement >( null );\n\tconst cropAreaDescriptionId = useId();\n\tconst [ isCropAreaFocused, setIsCropAreaFocused ] =\n\t\tuseState( focusOnMount );\n\tconst [ isFocusVisible, setIsFocusVisible ] = useState( false );\n\tconst [ canvasSize, setCanvasSize ] = useState< Size >( {\n\t\twidth: 0,\n\t\theight: 0,\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tif ( focusOnMount ) {\n\t\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t\t}\n\t}, [ focusOnMount ] );\n\n\tconst handleCropAreaFocus = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( true );\n\t\t\t\t// Show the outline only when focus arrived via keyboard\n\t\t\t\t// navigation. relatedTarget is null for pointer-initiated and\n\t\t\t\t// cross-window focus, so it reliably excludes those cases\n\t\t\t\t// without needing a separate ref or flag.\n\t\t\t\tif (\n\t\t\t\t\tevent.relatedTarget !== null &&\n\t\t\t\t\tevent.currentTarget.matches( ':focus-visible' )\n\t\t\t\t) {\n\t\t\t\t\tsetIsFocusVisible( true );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleCropAreaBlur = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( false );\n\t\t\t\tsetIsFocusVisible( false );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tconst element = canvasRef.current;\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new ResizeObserver( ( entries ) => {\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst { width, height } = entry.contentRect;\n\t\t\t\tsetCanvasSize( ( prev ) => {\n\t\t\t\t\tif ( prev.width === width && prev.height === height ) {\n\t\t\t\t\t\treturn prev;\n\t\t\t\t\t}\n\t\t\t\t\treturn { width, height };\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t\tobserver.observe( element );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [] );\n\n\t// Notify consumer of state changes.\n\tuseEffect( () => {\n\t\tonStateChange?.( state );\n\t}, [ state, onStateChange ] );\n\n\t// ARIA live region: announce significant state changes for screen readers.\n\tconst ariaMessage = useAriaAnnouncer( state );\n\n\t// Compute fitted image dimensions and visual bounds from camera math.\n\tconst naturalWidth = state.image?.naturalWidth ?? 0;\n\tconst naturalHeight = state.image?.naturalHeight ?? 0;\n\tconst { elementSize, visualSize } = useMemo(\n\t\t() =>\n\t\t\tgetImageFit(\n\t\t\t\tcanvasSize,\n\t\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\t\tstate.rotation\n\t\t\t),\n\t\t[ canvasSize, naturalWidth, naturalHeight, state.rotation ]\n\t);\n\n\t// In fixed-crop mode, auto-size the crop rect only when a fixed aspect\n\t// ratio is selected. With \"Free\" selected, turning freeform handles off\n\t// should preserve the user's current unconstrained crop.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfreeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetCropRect( rect );\n\t}, [ freeformCrop, aspectRatio, visualSize, setCropRect, state.cropRect ] );\n\n\t// In freeform mode, when aspectRatio changes, reshape the crop to the\n\t// largest inscribed rect of the new ratio.\n\tconst prevAspectRatioRef = useRef( aspectRatio );\n\tuseEffect( () => {\n\t\tif ( prevAspectRatioRef.current === aspectRatio ) {\n\t\t\treturn;\n\t\t}\n\t\tprevAspectRatioRef.current = aspectRatio;\n\n\t\tif (\n\t\t\t! freeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetCropRect( computeInscribedRect( aspectRatio, visualSize ) );\n\t}, [ aspectRatio, freeformCrop, visualSize, setCropRect ] );\n\n\t// Compute the crop handle bounds from the actual image footprint.\n\t// Depends on the full state object because getImageCropBounds reads\n\t// crop, zoom, rotation, flip, and image. React Compiler requires\n\t// the complete dependency; the computation is lightweight (a few\n\t// trig ops + 4 corner transforms).\n\tconst cropBounds = useMemo( () => {\n\t\tif ( ! state.image || elementSize.width === 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getImageCropBounds( state, elementSize, visualSize );\n\t}, [ state, elementSize, visualSize ] );\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst isResizingRef = useRef( false );\n\tconst isSettlingRef = useRef( false );\n\n\t// Use the interaction hook for mouse, touch, and keyboard events.\n\tconst {\n\t\thandlers,\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isInteractionPlacementActive,\n\t} = useInteraction( state, controller, canvasSize, visualSize, {\n\t\tminZoom,\n\t\tmaxZoom,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t} );\n\n\t// Compose focus-visibility tracking into the canvas event handlers.\n\t// Kept as a spread rather than explicit props to avoid triggering\n\t// jsx-a11y/no-noninteractive-element-interactions on role=\"group\".\n\tconst canvasHandlers = {\n\t\t...handlers,\n\t\tonPointerDown: ( event: React.PointerEvent< HTMLDivElement > ) => {\n\t\t\thandlers.onPointerDown?.( event );\n\t\t\t// Called after handlers so it lands last in the React batch \u2014\n\t\t\t// el.focus() inside the handler fires onFocus, which may\n\t\t\t// otherwise set isFocusVisible back to true.\n\t\t\tsetIsFocusVisible( false );\n\t\t},\n\t\tonKeyDown: ( event: React.KeyboardEvent< HTMLDivElement > ) => {\n\t\t\t// Guard against keydowns bubbling up from child handles\n\t\t\t// (e.g. Tab between handles, unhandled keys). Modifier-only\n\t\t\t// keypresses are excluded \u2014 they precede another key rather\n\t\t\t// than indicating deliberate keyboard interaction on their own.\n\t\t\tif (\n\t\t\t\tevent.target === event.currentTarget &&\n\t\t\t\t! [ 'Shift', 'Control', 'Alt', 'Meta' ].includes( event.key )\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( true );\n\t\t\t}\n\t\t\thandlers.onKeyDown?.( event );\n\t\t},\n\t};\n\n\t// Register wheel handler natively with { passive: false } so\n\t// preventDefault works. React's onWheel registers as passive. Bound\n\t// to the canvas (not the root) so pointer geometry inside the handler\n\t// resolves against the canvas box.\n\tuseEffect( () => {\n\t\tconst el = canvasRef.current;\n\t\tif ( ! el ) {\n\t\t\treturn;\n\t\t}\n\t\tconst handleWheel = ( event: WheelEvent ) => {\n\t\t\t// Block wheel zoom while resizing or settling \u2014 the stage CSS\n\t\t\t// transform changes getBoundingClientRect() during this window,\n\t\t\t// so focal-point math would resolve against the wrong center.\n\t\t\tif ( isResizingRef.current || isSettlingRef.current ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonWheelNative( event );\n\t\t};\n\t\tel.addEventListener( 'wheel', handleWheel, {\n\t\t\tpassive: false,\n\t\t} );\n\t\treturn () => {\n\t\t\tel.removeEventListener( 'wheel', handleWheel );\n\t\t};\n\t}, [ onWheelNative ] );\n\n\t// Use the transform style hook for the image CSS transform.\n\tconst transformString = useTransformStyle( state, visualSize );\n\n\t/**\n\t * Handle the image load event.\n\t */\n\tconst handleImageLoad = useCallback(\n\t\t( event: React.SyntheticEvent< HTMLImageElement > ) => {\n\t\t\tconst img = event.currentTarget;\n\t\t\tconst size: Size = {\n\t\t\t\twidth: img.naturalWidth,\n\t\t\t\theight: img.naturalHeight,\n\t\t\t};\n\n\t\t\tsetImage( {\n\t\t\t\tsrc,\n\t\t\t\tnaturalWidth: size.width,\n\t\t\t\tnaturalHeight: size.height,\n\t\t\t} );\n\n\t\t\tonImageLoaded?.( size );\n\t\t},\n\t\t[ src, setImage, onImageLoaded ]\n\t);\n\n\tconst handleCropChange = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tsetCropRect( rect );\n\t\t\t// During a resize drag, pan the viewport so the handle stays\n\t\t\t// visible even when the crop extends beyond the canvas edge.\n\t\t\tif (\n\t\t\t\tisResizingRef.current &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0\n\t\t\t) {\n\t\t\t\tconst offsetX = ( canvasSize.width - visualSize.width ) / 2;\n\t\t\t\tconst offsetY = ( canvasSize.height - visualSize.height ) / 2;\n\t\t\t\tconst rightOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetX +\n\t\t\t\t\t\t( rect.x + rect.width ) * visualSize.width -\n\t\t\t\t\t\tcanvasSize.width\n\t\t\t\t);\n\t\t\t\tconst leftOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetX + rect.x * visualSize.width )\n\t\t\t\t);\n\t\t\t\tconst bottomOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetY +\n\t\t\t\t\t\t( rect.y + rect.height ) * visualSize.height -\n\t\t\t\t\t\tcanvasSize.height\n\t\t\t\t);\n\t\t\t\tconst topOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetY + rect.y * visualSize.height )\n\t\t\t\t);\n\t\t\t\tsetViewportPan( {\n\t\t\t\t\tx: -rightOverflow + leftOverflow,\n\t\t\t\t\ty: -bottomOverflow + topOverflow,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ setCropRect, setViewportPan, canvasSize, visualSize ]\n\t);\n\n\t// Settling animation: brief linear transition after resize end.\n\tconst [ settling, setSettling ] = useState( false );\n\tconst settleTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\n\t// Clear the pending settle timer on unmount so it can't fire a\n\t// state update on an unmounted component.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( settleTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tconst isInteractiveGrid = showGrid === 'interactive';\n\tconst showInteractiveGrid =\n\t\tisInteractiveGrid &&\n\t\t( isInteractionPlacementActive || isResizing || isPlacementActive );\n\n\t/**\n\t * Handle Escape on a resize handle \u2014 return focus to the canvas so\n\t * arrow keys pan the image rather than resize.\n\t */\n\tconst handleEscape = useCallback( () => {\n\t\t// Escape is always a keyboard action, so show the outline immediately\n\t\t// rather than relying on the focus handler's :focus-visible check.\n\t\tsetIsFocusVisible( true );\n\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t}, [] );\n\n\tconst handleResizeStart = useCallback( () => {\n\t\tisResizingRef.current = true;\n\t\tsetIsResizing( true );\n\t\t// Clear any in-flight settle so transitions don't apply during the\n\t\t// new drag (rapid successive resizes would otherwise inherit the\n\t\t// previous settle animation).\n\t\tclearTimeout( settleTimerRef.current );\n\t\tisSettlingRef.current = false;\n\t\tsetSettling( false );\n\t\tresetViewport();\n\t\tonGestureStart?.();\n\t}, [ onGestureStart, resetViewport ] );\n\n\t/**\n\t * Handle resize end \u2014 settle the crop rect (re-center, fill height)\n\t * and reset the viewport pan back to neutral.\n\t */\n\tconst handleResizeEnd = useCallback( () => {\n\t\tisResizingRef.current = false;\n\t\tsetIsResizing( false );\n\t\tisSettlingRef.current = true;\n\t\tsetSettling( true );\n\t\t// Reset viewport pan first so it transitions back to zero in sync\n\t\t// with the settle animation on the image.\n\t\tresetViewport();\n\t\tsettleCrop();\n\t\tonGestureEnd?.();\n\t\tclearTimeout( settleTimerRef.current );\n\t\tsettleTimerRef.current = setTimeout( () => {\n\t\t\tisSettlingRef.current = false;\n\t\t\tsetSettling( false );\n\t\t}, 200 );\n\t}, [ settleCrop, onGestureEnd, resetViewport ] );\n\n\tlet imageTransition: string | undefined;\n\tif ( settling ) {\n\t\timageTransition = 'transform 200ms ease-out';\n\t} else if ( isZooming ) {\n\t\timageTransition = 'transform 150ms linear';\n\t}\n\tconst settleStencilTransition = settling\n\t\t? 'left 200ms ease-out, top 200ms ease-out, width 200ms ease-out, height 200ms ease-out'\n\t\t: undefined;\n\n\t// Compute the image's CSS style.\n\tconst imageStyle = useMemo( (): React.CSSProperties => {\n\t\tif ( elementSize.width === 0 || elementSize.height === 0 ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst centerX = ( canvasSize.width - elementSize.width ) / 2;\n\t\tconst centerY = ( canvasSize.height - elementSize.height ) / 2;\n\t\treturn {\n\t\t\twidth: elementSize.width,\n\t\t\theight: elementSize.height,\n\t\t\tmaxWidth: elementSize.width,\n\t\t\tmaxHeight: elementSize.height,\n\t\t\tleft: centerX,\n\t\t\ttop: centerY,\n\t\t\ttransform: transformString,\n\t\t\ttransition: imageTransition,\n\t\t};\n\t}, [ canvasSize, elementSize, transformString, imageTransition ] );\n\n\t// Viewport pan CSS transform for the stage div. Applied during resize\n\t// drags to keep handles visible when the crop extends past the canvas edge.\n\t// Transitions back to zero during the settle animation.\n\t// will-change promotes the stage to its own compositor layer while the\n\t// transform is active, keeping per-frame pan updates off the main thread.\n\tconst settleTransition = settling ? 'transform 200ms ease-out' : undefined;\n\tconst willChange = isResizing || settling ? 'transform' : undefined;\n\tlet stageStyle: React.CSSProperties | undefined;\n\tif ( viewportState.pan.x !== 0 || viewportState.pan.y !== 0 ) {\n\t\tstageStyle = {\n\t\t\ttransform: `translate(${ viewportState.pan.x }px, ${ viewportState.pan.y }px)`,\n\t\t\ttransition: settleTransition,\n\t\t\twillChange,\n\t\t};\n\t} else if ( settling ) {\n\t\tstageStyle = { transition: settleTransition, willChange };\n\t}\n\n\t// Forward the root element to the consumer's ref.\n\tconst setContainerRef = useCallback(\n\t\t( element: HTMLDivElement | null ) => {\n\t\t\tif ( typeof ref === 'function' ) {\n\t\t\t\tref( element );\n\t\t\t} else if ( ref ) {\n\t\t\t\t(\n\t\t\t\t\tref as React.MutableRefObject< HTMLDivElement | null >\n\t\t\t\t ).current = element;\n\t\t\t}\n\t\t},\n\t\t[ ref ]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ setContainerRef }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-media-editor-image-editor',\n\t\t\t\tisDragging && 'wp-media-editor-image-editor--dragging',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t{ /*\n\t\t\t * The canvas is the interactive, inset surface. Handles and\n\t\t\t * the ARIA role/tabIndex live here so pointer geometry\n\t\t\t * (getBoundingClientRect on e.currentTarget) resolves against\n\t\t\t * the same box that crop math uses. The root stays as the\n\t\t\t * clipping shell for the dimming overlay's box-shadow.\n\t\t\t *\n\t\t\t * Not role=\"application\" \u2014 that disables the screen reader's\n\t\t\t * normal keyboard interception, too heavy-handed for a single\n\t\t\t * widget. Screen reader users get the ARIA live region below\n\t\t\t * as the announcement channel.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tref={ canvasRef }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-media-editor-image-editor__canvas',\n\t\t\t\t\tisInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--grid-interactive',\n\t\t\t\t\tshowInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--show-grid',\n\t\t\t\t\tsettling &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--settling',\n\t\t\t\t\t// Show the keyboard focus outline only when the canvas\n\t\t\t\t\t// itself (not a child handle) has keyboard focus.\n\t\t\t\t\tisFocusVisible &&\n\t\t\t\t\t\tisCropAreaFocused &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--focus-visible'\n\t\t\t\t) }\n\t\t\t\ttabIndex={ 0 }\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ __( 'Crop area' ) }\n\t\t\t\taria-describedby={\n\t\t\t\t\tisCropAreaFocused ? cropAreaDescriptionId : undefined\n\t\t\t\t}\n\t\t\t\tonFocus={ handleCropAreaFocus }\n\t\t\t\tonBlur={ handleCropAreaBlur }\n\t\t\t\t{ ...canvasHandlers }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tid={ cropAreaDescriptionId }\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ /*\n\t\t\t\t * The stage is an inner full-size div that receives the\n\t\t\t\t * viewport pan CSS transform. Keeping the transform here\n\t\t\t\t * (rather than on the canvas) means the canvas always stays\n\t\t\t\t * at its natural position, so the root div's background is\n\t\t\t\t * never exposed when the stage is panned during a resize drag.\n\t\t\t\t */ }\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__stage\"\n\t\t\t\t\tdata-testid=\"cropper-stage\"\n\t\t\t\t\tstyle={ stageStyle }\n\t\t\t\t>\n\t\t\t\t\t{ /* The image layer */ }\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"wp-media-editor-image-editor__image\"\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tonLoad={ handleImageLoad }\n\t\t\t\t\t\tstyle={ imageStyle }\n\t\t\t\t\t\tdraggable={ false }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Dimming overlay outside the crop area */ }\n\t\t\t\t\t{ showDimming && (\n\t\t\t\t\t\t<DimmingOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t\ttransition={ settleStencilTransition }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ /* The stencil (crop area with handles) */ }\n\t\t\t\t\t<StencilComponent\n\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\tonCropChange={ handleCropChange }\n\t\t\t\t\t\tonResizeStart={ handleResizeStart }\n\t\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\t\tonEscape={ handleEscape }\n\t\t\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\t\tstencilTransition={ settleStencilTransition }\n\t\t\t\t\t\tcropBounds={ cropBounds }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Rule-of-thirds grid */ }\n\t\t\t\t\t{ ( showGrid === true || isInteractiveGrid ) && (\n\t\t\t\t\t\t<GridOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\n\t\t\t\t{ /* ARIA live region for screen reader announcements */ }\n\t\t\t\t<div\n\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t\taria-atomic=\"true\"\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__aria-live\"\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ ariaMessage }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nconst CropperInnerWithRef = forwardRef< HTMLDivElement, CropperProps >(\n\tCropperInner\n);\n\nexport const Cropper = forwardRef< HTMLDivElement, CropperProps >(\n\t( props, ref ) => (\n\t\t<ViewportProvider>\n\t\t\t<CropperInnerWithRef { ...props } ref={ ref } />\n\t\t</ViewportProvider>\n\t)\n);\n"],
|
|
5
|
+
"mappings": ";AAIA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AAYnB,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,mBAAmB;AAC9C,SAAS,6BAA6B;AAwlBlC,cAeA,YAfA;AArlBJ,IAAM,oBAAoB;AAK1B,SAAS,qBACR,aACA,YACiB;AACjB,MAAI,IAAI;AACR,MAAI,IAAI;AACR,MAAK,eAAe,cAAc,KAAK,WAAW,QAAQ,GAAI;AAM7D,UAAM,kBACH,cAAc,WAAW,SAAW,WAAW;AAClD,QAAK,mBAAmB,GAAI;AAC3B,UAAI;AAAA,IACL,OAAO;AACN,UAAI,IAAI;AAAA,IACT;AAAA,EACD;AACA,SAAO;AAAA,IACN,IAAK,IAAI,KAAM;AAAA,IACf,IAAK,IAAI,KAAM;AAAA,IACf,OAAO;AAAA,IACP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cAAC;AAAA;AAAA,gBACA,aAAU;AAAA,gBACV,eAAY;AAAA,gBACZ,WAAU;AAAA,gBACV,OAAQ;AAAA,gBAEN;AAAA;AAAA,YACH;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAM,sBAAsB;AAAA,EAC3B;AACD;AAEO,IAAM,UAAU;AAAA,EACtB,CAAE,OAAO,QACR,oBAAC,oBACA,8BAAC,uBAAsB,GAAG,OAAQ,KAAY,GAC/C;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
function DimmingOverlay({
|
|
4
4
|
cropRect,
|
|
5
5
|
containerSize,
|
|
6
|
-
imageSize
|
|
6
|
+
imageSize,
|
|
7
|
+
transition
|
|
7
8
|
}) {
|
|
8
9
|
if (containerSize.width === 0 || containerSize.height === 0) {
|
|
9
10
|
return null;
|
|
@@ -14,6 +15,7 @@ function DimmingOverlay({
|
|
|
14
15
|
const top = offsetY + cropRect.y * imageSize.height;
|
|
15
16
|
const width = cropRect.width * imageSize.width;
|
|
16
17
|
const height = cropRect.height * imageSize.height;
|
|
18
|
+
const composedTransition = transition ? `${transition}, box-shadow 0.15s ease` : void 0;
|
|
17
19
|
return /* @__PURE__ */ jsx(
|
|
18
20
|
"div",
|
|
19
21
|
{
|
|
@@ -22,7 +24,8 @@ function DimmingOverlay({
|
|
|
22
24
|
left,
|
|
23
25
|
top,
|
|
24
26
|
width,
|
|
25
|
-
height
|
|
27
|
+
height,
|
|
28
|
+
transition: composedTransition
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/image-editor/react/components/overlays/dimming-overlay.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { NormalizedRect, Size } from '../../../core/types';\n\n/**\n * Props for the DimmingOverlay component.\n */\ninterface DimmingOverlayProps {\n\t/** The crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** The container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** The rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n}\n\n
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { NormalizedRect, Size } from '../../../core/types';\n\n/**\n * Props for the DimmingOverlay component.\n */\ninterface DimmingOverlayProps {\n\t/** The crop rectangle in normalized coordinates. */\n\tcropRect: NormalizedRect;\n\t/** The container element dimensions in pixels. */\n\tcontainerSize: Size;\n\t/** The rendered image dimensions in pixels within the container. */\n\timageSize: Size;\n\t/** CSS transition string, e.g. during settle animation. */\n\ttransition?: string;\n}\n\n// Renders a semi-transparent overlay outside the crop rectangle using a\n// box-shadow that dims everything outside the crop rect position.\nexport function DimmingOverlay( {\n\tcropRect,\n\tcontainerSize,\n\timageSize,\n\ttransition,\n}: DimmingOverlayProps ) {\n\tif ( containerSize.width === 0 || containerSize.height === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst offsetX = ( containerSize.width - imageSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - imageSize.height ) / 2;\n\tconst left = offsetX + cropRect.x * imageSize.width;\n\tconst top = offsetY + cropRect.y * imageSize.height;\n\tconst width = cropRect.width * imageSize.width;\n\tconst height = cropRect.height * imageSize.height;\n\n\t// Compose any incoming transition with the stylesheet's box-shadow\n\t// transition so the drag-dimming effect isn't overwritten.\n\tconst composedTransition = transition\n\t\t? `${ transition }, box-shadow 0.15s ease`\n\t\t: undefined;\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-media-editor-image-editor__dimming\"\n\t\t\tstyle={ {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\ttransition: composedTransition,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AA6CE;AAxBK,SAAS,eAAgB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAyB;AACxB,MAAK,cAAc,UAAU,KAAK,cAAc,WAAW,GAAI;AAC9D,WAAO;AAAA,EACR;AAEA,QAAM,WAAY,cAAc,QAAQ,UAAU,SAAU;AAC5D,QAAM,WAAY,cAAc,SAAS,UAAU,UAAW;AAC9D,QAAM,OAAO,UAAU,SAAS,IAAI,UAAU;AAC9C,QAAM,MAAM,UAAU,SAAS,IAAI,UAAU;AAC7C,QAAM,QAAQ,SAAS,QAAQ,UAAU;AACzC,QAAM,SAAS,SAAS,SAAS,UAAU;AAI3C,QAAM,qBAAqB,aACxB,GAAI,UAAW,4BACf;AAEH,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,MACb;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|